Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
89c11447
Commit
89c11447
authored
Aug 22, 2015
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #762 from Hixie/flex-bug
Reimplement 'stretch' for flexible items correctly.
parents
b61fe238
d81ec90c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
43 deletions
+67
-43
box.dart
packages/flutter/lib/rendering/box.dart
+1
-0
flex.dart
packages/flutter/lib/rendering/flex.dart
+58
-39
object.dart
packages/flutter/lib/rendering/object.dart
+8
-4
No files found.
packages/flutter/lib/rendering/box.dart
View file @
89c11447
...
...
@@ -396,6 +396,7 @@ abstract class RenderBox extends RenderObject {
assert
(
value
.
_owner
.
parent
==
this
);
}
_size
=
inDebugBuild
?
new
_DebugSize
(
value
,
this
,
debugCanParentUseSize
)
:
value
;
assert
(
debugDoesMeetConstraints
());
}
void
applyPaintTransform
(
Matrix4
transform
)
{
...
...
packages/flutter/lib/rendering/flex.dart
View file @
89c11447
...
...
@@ -85,7 +85,6 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
}
// Set during layout if overflow occurred on the main axis
TextBaseline
_textBaseline
;
TextBaseline
get
textBaseline
=>
_textBaseline
;
void
set
textBaseline
(
TextBaseline
value
)
{
...
...
@@ -95,6 +94,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
}
// Set during layout if overflow occurred on the main axis
double
_overflow
;
void
setupParentData
(
RenderBox
child
)
{
...
...
@@ -344,29 +344,29 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
if
(
alignItems
==
FlexAlignItems
.
stretch
)
{
switch
(
_direction
)
{
case
FlexDirection
.
horizontal
:
innerConstraints
=
new
BoxConstraints
(
minWidth:
constraints
.
maxWidth
,
maxWidth:
constraints
.
maxWidth
,
minHeight:
constraints
.
m
in
Height
,
innerConstraints
=
new
BoxConstraints
(
minWidth:
spaceForChild
,
maxWidth:
spaceForChild
,
minHeight:
constraints
.
m
ax
Height
,
maxHeight:
constraints
.
maxHeight
);
break
;
case
FlexDirection
.
vertical
:
innerConstraints
=
new
BoxConstraints
(
minWidth:
constraints
.
m
in
Width
,
innerConstraints
=
new
BoxConstraints
(
minWidth:
constraints
.
m
ax
Width
,
maxWidth:
constraints
.
maxWidth
,
minHeight:
constraints
.
maxHeight
,
maxHeight:
constraints
.
maxHeight
);
minHeight:
spaceForChild
,
maxHeight:
spaceForChild
);
break
;
}
}
else
{
switch
(
_direction
)
{
case
FlexDirection
.
horizontal
:
innerConstraints
=
new
BoxConstraints
(
m
axHeight:
constraints
.
maxHeight
,
m
in
Width:
spaceForChild
,
max
Width:
spaceForChild
);
innerConstraints
=
new
BoxConstraints
(
m
inWidth:
spaceForChild
,
m
ax
Width:
spaceForChild
,
max
Height:
constraints
.
maxHeight
);
break
;
case
FlexDirection
.
vertical
:
innerConstraints
=
new
BoxConstraints
(
m
inHeight:
spaceForChild
,
m
ax
Height:
spaceForChild
,
max
Width:
constraints
.
maxWidth
);
innerConstraints
=
new
BoxConstraints
(
m
axWidth:
constraints
.
maxWidth
,
m
in
Height:
spaceForChild
,
max
Height:
spaceForChild
);
break
;
}
}
...
...
@@ -467,35 +467,54 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
if
(
_overflow
>
0
)
{
context
.
canvas
.
save
();
context
.
canvas
.
clipRect
(
offset
&
size
);
defaultPaint
(
context
,
offset
);
context
.
canvas
.
restore
();
}
else
{
if
(
_overflow
<=
0.0
)
{
defaultPaint
(
context
,
offset
);
return
;
}
}
void
debugPaintSize
(
PaintingContext
context
,
Offset
offset
)
{
super
.
debugPaintSize
(
context
,
offset
);
if
(
_overflow
<=
0
)
return
;
// We have overflow. Clip it.
context
.
canvas
.
save
();
context
.
canvas
.
clipRect
(
offset
&
size
);
defaultPaint
(
context
,
offset
);
context
.
canvas
.
restore
();
assert
(()
{
// In debug mode, if you have overflow, we highlight where the
// overflow would be by painting that area red. Since that is
// likely to be clipped by an ancestor, we also draw a thick red
// line at the edge that's overflowing.
// If you do want clipping, use a RenderClip (Clip in the
// Widgets library).
Paint
markerPaint
=
new
Paint
()..
color
=
const
Color
(
0xE0FF0000
);
Paint
highlightPaint
=
new
Paint
()..
color
=
const
Color
(
0x7FFF0000
);
const
kMarkerSize
=
0.1
;
Rect
markerRect
,
overflowRect
;
switch
(
direction
)
{
case
FlexDirection
.
horizontal
:
markerRect
=
offset
+
new
Offset
(
size
.
width
*
(
1.0
-
kMarkerSize
),
0.0
)
&
new
Size
(
size
.
width
*
kMarkerSize
,
size
.
height
);
overflowRect
=
offset
+
new
Offset
(
size
.
width
,
0.0
)
&
new
Size
(
_overflow
,
size
.
height
);
break
;
case
FlexDirection
.
vertical
:
markerRect
=
offset
+
new
Offset
(
0.0
,
size
.
height
*
(
1.0
-
kMarkerSize
))
&
new
Size
(
size
.
width
,
size
.
height
*
kMarkerSize
);
overflowRect
=
offset
+
new
Offset
(
0.0
,
size
.
height
)
&
new
Size
(
size
.
width
,
_overflow
);
break
;
}
context
.
canvas
.
drawRect
(
markerRect
,
markerPaint
);
context
.
canvas
.
drawRect
(
overflowRect
,
highlightPaint
);
return
true
;
});
}
// Draw a red rectangle over the overflow area in debug mode
// You should be using a Clip if you want to clip your children
Paint
paint
=
new
Paint
()..
color
=
const
Color
(
0x7FFF0000
);
Rect
overflowRect
;
switch
(
direction
)
{
case
FlexDirection
.
horizontal
:
overflowRect
=
offset
+
new
Offset
(
size
.
width
,
0.0
)
&
new
Size
(
_overflow
,
size
.
height
);
break
;
case
FlexDirection
.
vertical
:
overflowRect
=
offset
+
new
Offset
(
0.0
,
size
.
height
)
&
new
Size
(
size
.
width
,
_overflow
);
break
;
}
context
.
canvas
.
drawRect
(
overflowRect
,
paint
);
String
toStringName
()
{
String
header
=
super
.
toStringName
();
if
(
_overflow
>
0.0
)
header
+=
' OVERFLOWING'
;
return
header
;
}
}
packages/flutter/lib/rendering/object.dart
View file @
89c11447
...
...
@@ -738,6 +738,13 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
String
toString
([
String
prefix
=
''
])
{
RenderObject
debugPreviousActiveLayout
=
_debugActiveLayout
;
_debugActiveLayout
=
null
;
String
header
=
toStringName
();
prefix
+=
' '
;
String
result
=
'
${header}
\n
${debugDescribeSettings(prefix)}${debugDescribeChildren(prefix)}
'
;
_debugActiveLayout
=
debugPreviousActiveLayout
;
return
result
;
}
String
toStringName
()
{
String
header
=
'
${runtimeType}
'
;
if
(
_relayoutSubtreeRoot
!=
null
&&
_relayoutSubtreeRoot
!=
this
)
{
int
count
=
1
;
...
...
@@ -752,10 +759,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
header
+=
' NEEDS-LAYOUT'
;
if
(!
attached
)
header
+=
' DETACHED'
;
prefix
+=
' '
;
String
result
=
'
${header}
\n
${debugDescribeSettings(prefix)}${debugDescribeChildren(prefix)}
'
;
_debugActiveLayout
=
debugPreviousActiveLayout
;
return
result
;
return
header
;
}
String
debugDescribeSettings
(
String
prefix
)
=>
'
${prefix}
parentData:
${parentData}
\n
${prefix}
constraints:
${constraints}
\n
'
;
String
debugDescribeChildren
(
String
prefix
)
=>
''
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment