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
e3d5c2b2
Commit
e3d5c2b2
authored
Jul 18, 2015
by
Collin Jackson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Draw debug rects when flex overflows
parent
e1aa0431
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
8 deletions
+25
-8
flex.dart
packages/flutter/lib/rendering/flex.dart
+25
-8
No files found.
packages/flutter/lib/rendering/flex.dart
View file @
e3d5c2b2
...
...
@@ -81,7 +81,8 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
}
bool
_overflowOccurredDuringLayout
=
false
;
// Set during layout if overflow occurred on the main axis
double
_overflow
;
void
setupParentData
(
RenderBox
child
)
{
if
(
child
.
parentData
is
!
FlexBoxParentData
)
...
...
@@ -314,6 +315,8 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
child
=
child
.
parentData
.
nextSibling
;
}
_overflow
=
math
.
max
(
0.0
,
-
freeSpace
);
freeSpace
=
math
.
max
(
0.0
,
freeSpace
);
// Steps 4-5. Distribute remaining space to flexible children.
double
spacePerFlex
=
totalFlex
>
0
?
(
freeSpace
/
totalFlex
)
:
0.0
;
...
...
@@ -351,7 +354,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
child
=
child
.
parentData
.
nextSibling
;
}
// Section 8.2: Axis Alignment using the justify-content property
// Section 8.2:
Main
Axis Alignment using the justify-content property
double
remainingSpace
=
math
.
max
(
0.0
,
freeSpace
-
usedSpace
);
double
leadingSpace
;
double
betweenSpace
;
...
...
@@ -378,20 +381,16 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
break
;
}
Size
desiredSize
;
switch
(
_direction
)
{
case
FlexDirection
.
horizontal
:
desiredSize
=
new
Size
(
mainSize
,
crossSize
);
size
=
constraints
.
constrain
(
desiredSize
);
size
=
constraints
.
constrain
(
new
Size
(
mainSize
,
crossSize
));
crossSize
=
size
.
height
;
break
;
case
FlexDirection
.
vertical
:
desiredSize
=
new
Size
(
crossSize
,
mainSize
);
size
=
constraints
.
constrain
(
new
Size
(
crossSize
,
mainSize
));
crossSize
=
size
.
width
;
break
;
}
_overflowOccurredDuringLayout
=
desiredSize
!=
size
;
// Position elements
double
childMainPosition
=
leadingSpace
;
...
...
@@ -439,7 +438,25 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
void
paint
(
PaintingCanvas
canvas
,
Offset
offset
)
{
if
(
_overflowOccurredDuringLayout
)
{
if
(
_overflow
>
0
)
{
assert
(()
{
// 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
;
}
canvas
.
drawRect
(
overflowRect
,
paint
);
return
true
;
});
canvas
.
save
();
canvas
.
clipRect
(
offset
&
size
);
defaultPaint
(
canvas
,
offset
);
...
...
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