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
306a364f
Commit
306a364f
authored
Jan 09, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1158 from Hixie/padding-debug
Add more debugPaintSizeEnabled construction lines.
parents
fb66bf11
20a01b42
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
183 additions
and
39 deletions
+183
-39
box.dart
packages/flutter/lib/src/rendering/box.dart
+50
-38
debug.dart
packages/flutter/lib/src/rendering/debug.dart
+15
-1
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+13
-0
shifted_box.dart
packages/flutter/lib/src/rendering/shifted_box.dart
+105
-0
No files found.
packages/flutter/lib/src/rendering/box.dart
View file @
306a364f
...
...
@@ -693,50 +693,62 @@ abstract class RenderBox extends RenderObject {
}
void
debugPaint
(
PaintingContext
context
,
Offset
offset
)
{
if
(
debugPaintSizeEnabled
)
debugPaintSize
(
context
,
offset
);
if
(
debugPaintBaselinesEnabled
)
debugPaintBaselines
(
context
,
offset
);
if
(
debugPaintPointersEnabled
)
debugPaintPointers
(
context
,
offset
);
assert
(()
{
if
(
debugPaintSizeEnabled
)
debugPaintSize
(
context
,
offset
);
if
(
debugPaintBaselinesEnabled
)
debugPaintBaselines
(
context
,
offset
);
if
(
debugPaintPointersEnabled
)
debugPaintPointers
(
context
,
offset
);
return
true
;
});
}
void
debugPaintSize
(
PaintingContext
context
,
Offset
offset
)
{
Paint
paint
=
new
Paint
()
..
style
=
ui
.
PaintingStyle
.
stroke
..
strokeWidth
=
1.0
..
color
=
debugPaintSizeColor
;
context
.
canvas
.
drawRect
(
offset
&
size
,
paint
);
assert
(()
{
Paint
paint
=
new
Paint
()
..
style
=
ui
.
PaintingStyle
.
stroke
..
strokeWidth
=
1.0
..
color
=
debugPaintSizeColor
;
context
.
canvas
.
drawRect
((
offset
&
size
).
deflate
(
0.5
),
paint
);
return
true
;
});
}
void
debugPaintBaselines
(
PaintingContext
context
,
Offset
offset
)
{
Paint
paint
=
new
Paint
()
..
style
=
ui
.
PaintingStyle
.
stroke
..
strokeWidth
=
0.25
;
Path
path
;
// ideographic baseline
double
baselineI
=
getDistanceToBaseline
(
TextBaseline
.
ideographic
,
onlyReal:
true
);
if
(
baselineI
!=
null
)
{
paint
.
color
=
debugPaintIdeographicBaselineColor
;
path
=
new
Path
();
path
.
moveTo
(
offset
.
dx
,
offset
.
dy
+
baselineI
);
path
.
lineTo
(
offset
.
dx
+
size
.
width
,
offset
.
dy
+
baselineI
);
context
.
canvas
.
drawPath
(
path
,
paint
);
}
// alphabetic baseline
double
baselineA
=
getDistanceToBaseline
(
TextBaseline
.
alphabetic
,
onlyReal:
true
);
if
(
baselineA
!=
null
)
{
paint
.
color
=
debugPaintAlphabeticBaselineColor
;
path
=
new
Path
();
path
.
moveTo
(
offset
.
dx
,
offset
.
dy
+
baselineA
);
path
.
lineTo
(
offset
.
dx
+
size
.
width
,
offset
.
dy
+
baselineA
);
context
.
canvas
.
drawPath
(
path
,
paint
);
}
assert
(()
{
Paint
paint
=
new
Paint
()
..
style
=
ui
.
PaintingStyle
.
stroke
..
strokeWidth
=
0.25
;
Path
path
;
// ideographic baseline
double
baselineI
=
getDistanceToBaseline
(
TextBaseline
.
ideographic
,
onlyReal:
true
);
if
(
baselineI
!=
null
)
{
paint
.
color
=
debugPaintIdeographicBaselineColor
;
path
=
new
Path
();
path
.
moveTo
(
offset
.
dx
,
offset
.
dy
+
baselineI
);
path
.
lineTo
(
offset
.
dx
+
size
.
width
,
offset
.
dy
+
baselineI
);
context
.
canvas
.
drawPath
(
path
,
paint
);
}
// alphabetic baseline
double
baselineA
=
getDistanceToBaseline
(
TextBaseline
.
alphabetic
,
onlyReal:
true
);
if
(
baselineA
!=
null
)
{
paint
.
color
=
debugPaintAlphabeticBaselineColor
;
path
=
new
Path
();
path
.
moveTo
(
offset
.
dx
,
offset
.
dy
+
baselineA
);
path
.
lineTo
(
offset
.
dx
+
size
.
width
,
offset
.
dy
+
baselineA
);
context
.
canvas
.
drawPath
(
path
,
paint
);
}
return
true
;
});
}
void
debugPaintPointers
(
PaintingContext
context
,
Offset
offset
)
{
if
(
_debugActivePointers
>
0
)
{
Paint
paint
=
new
Paint
()
..
color
=
new
Color
(
debugPaintPointersColorValue
|
((
0x04000000
*
depth
)
&
0xFF000000
));
context
.
canvas
.
drawRect
(
offset
&
size
,
paint
);
}
assert
(()
{
if
(
_debugActivePointers
>
0
)
{
Paint
paint
=
new
Paint
()
..
color
=
new
Color
(
debugPaintPointersColorValue
|
((
0x04000000
*
depth
)
&
0xFF000000
));
context
.
canvas
.
drawRect
(
offset
&
size
,
paint
);
}
return
true
;
});
}
void
debugDescribeSettings
(
List
<
String
>
settings
)
{
...
...
packages/flutter/lib/src/rendering/debug.dart
View file @
306a364f
...
...
@@ -13,12 +13,26 @@ import 'package:flutter/scheduler.dart';
export
'package:flutter/services.dart'
show
debugPrint
;
/// Causes each RenderBox to paint a box around its bounds.
/// Causes each RenderBox to paint a box around its bounds, and some extra
/// boxes, such as RenderPadding, to draw construction lines.
bool
debugPaintSizeEnabled
=
false
;
/// The color to use when painting RenderObject bounds.
ui
.
Color
debugPaintSizeColor
=
const
ui
.
Color
(
0xFF00FFFF
);
/// The color to use when painting some boxes that just add space (e.g. an empty
/// RenderConstrainedBox or RenderPadding).
ui
.
Color
debugPaintSpacingColor
=
const
ui
.
Color
(
0x90909090
);
/// The color to use when painting RenderPadding edges.
ui
.
Color
debugPaintPaddingColor
=
const
ui
.
Color
(
0x900090FF
);
/// The color to use when painting RenderPadding edges.
ui
.
Color
debugPaintPaddingInnerEdgeColor
=
const
ui
.
Color
(
0xFF0090FF
);
/// The color to use when painting the arrows used to show RenderPositionedBox alignment.
ui
.
Color
debugPaintArrowColor
=
const
ui
.
Color
(
0xFFFFFF00
);
/// Causes each RenderBox to paint a line at each of its baselines.
bool
debugPaintBaselinesEnabled
=
false
;
...
...
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
306a364f
...
...
@@ -158,6 +158,19 @@ class RenderConstrainedBox extends RenderProxyBox {
}
}
void
debugPaintSize
(
PaintingContext
context
,
Offset
offset
)
{
super
.
debugPaintSize
(
context
,
offset
);
assert
(()
{
Paint
paint
;
if
(
child
==
null
||
child
.
size
.
isEmpty
)
{
paint
=
new
Paint
()
..
color
=
debugPaintSpacingColor
;
context
.
canvas
.
drawRect
(
offset
&
size
,
paint
);
}
return
true
;
});
}
void
debugDescribeSettings
(
List
<
String
>
settings
)
{
super
.
debugDescribeSettings
(
settings
);
settings
.
add
(
'additionalConstraints:
$additionalConstraints
'
);
...
...
packages/flutter/lib/src/rendering/shifted_box.dart
View file @
306a364f
...
...
@@ -2,9 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:math'
as
math
;
import
'dart:ui'
as
ui
;
import
'package:flutter/painting.dart'
;
import
'box.dart'
;
import
'debug.dart'
;
import
'object.dart'
;
/// Abstract class for one-child-layout render boxes that provide control over
...
...
@@ -153,6 +157,50 @@ class RenderPadding extends RenderShiftedBox {
));
}
void
debugPaintSize
(
PaintingContext
context
,
Offset
offset
)
{
super
.
debugPaintSize
(
context
,
offset
);
assert
(()
{
Paint
paint
;
if
(
child
!=
null
&&
!
child
.
size
.
isEmpty
)
{
Path
path
;
paint
=
new
Paint
()
..
color
=
debugPaintPaddingColor
;
path
=
new
Path
()
..
moveTo
(
offset
.
dx
,
offset
.
dy
)
..
lineTo
(
offset
.
dx
+
size
.
width
,
offset
.
dy
)
..
lineTo
(
offset
.
dx
+
size
.
width
,
offset
.
dy
+
size
.
height
)
..
lineTo
(
offset
.
dx
,
offset
.
dy
+
size
.
height
)
..
close
()
..
moveTo
(
offset
.
dx
+
padding
.
left
,
offset
.
dy
+
padding
.
top
)
..
lineTo
(
offset
.
dx
+
padding
.
left
,
offset
.
dy
+
size
.
height
-
padding
.
bottom
)
..
lineTo
(
offset
.
dx
+
size
.
width
-
padding
.
right
,
offset
.
dy
+
size
.
height
-
padding
.
bottom
)
..
lineTo
(
offset
.
dx
+
size
.
width
-
padding
.
right
,
offset
.
dy
+
padding
.
top
)
..
close
();
context
.
canvas
.
drawPath
(
path
,
paint
);
paint
=
new
Paint
()
..
color
=
debugPaintPaddingInnerEdgeColor
;
const
kOutline
=
2.0
;
path
=
new
Path
()
..
moveTo
(
offset
.
dx
+
math
.
max
(
padding
.
left
-
kOutline
,
0.0
),
offset
.
dy
+
math
.
max
(
padding
.
top
-
kOutline
,
0.0
))
..
lineTo
(
offset
.
dx
+
math
.
min
(
size
.
width
-
padding
.
right
+
kOutline
,
size
.
width
),
offset
.
dy
+
math
.
max
(
padding
.
top
-
kOutline
,
0.0
))
..
lineTo
(
offset
.
dx
+
math
.
min
(
size
.
width
-
padding
.
right
+
kOutline
,
size
.
width
),
offset
.
dy
+
math
.
min
(
size
.
height
-
padding
.
bottom
+
kOutline
,
size
.
height
))
..
lineTo
(
offset
.
dx
+
math
.
max
(
padding
.
left
-
kOutline
,
0.0
),
offset
.
dy
+
math
.
min
(
size
.
height
-
padding
.
bottom
+
kOutline
,
size
.
height
))
..
close
()
..
moveTo
(
offset
.
dx
+
padding
.
left
,
offset
.
dy
+
padding
.
top
)
..
lineTo
(
offset
.
dx
+
padding
.
left
,
offset
.
dy
+
size
.
height
-
padding
.
bottom
)
..
lineTo
(
offset
.
dx
+
size
.
width
-
padding
.
right
,
offset
.
dy
+
size
.
height
-
padding
.
bottom
)
..
lineTo
(
offset
.
dx
+
size
.
width
-
padding
.
right
,
offset
.
dy
+
padding
.
top
)
..
close
();
context
.
canvas
.
drawPath
(
path
,
paint
);
}
else
{
paint
=
new
Paint
()
..
color
=
debugPaintSpacingColor
;
context
.
canvas
.
drawRect
(
offset
&
size
,
paint
);
}
return
true
;
});
}
void
debugDescribeSettings
(
List
<
String
>
settings
)
{
super
.
debugDescribeSettings
(
settings
);
settings
.
add
(
'padding:
$padding
'
);
...
...
@@ -245,6 +293,63 @@ class RenderPositionedBox extends RenderShiftedBox {
}
}
void
debugPaintSize
(
PaintingContext
context
,
Offset
offset
)
{
super
.
debugPaintSize
(
context
,
offset
);
assert
(()
{
Paint
paint
;
if
(
child
!=
null
&&
!
child
.
size
.
isEmpty
)
{
Path
path
;
paint
=
new
Paint
()
..
style
=
ui
.
PaintingStyle
.
stroke
..
strokeWidth
=
1.0
..
color
=
debugPaintArrowColor
;
path
=
new
Path
();
final
BoxParentData
childParentData
=
child
.
parentData
;
if
(
childParentData
.
offset
.
dy
>
0.0
)
{
// vertical alignment arrows
double
headSize
=
math
.
min
(
childParentData
.
offset
.
dy
*
0.2
,
10.0
);
path
..
moveTo
(
offset
.
dx
+
size
.
width
/
2.0
,
offset
.
dy
)
..
relativeLineTo
(
0.0
,
childParentData
.
offset
.
dy
-
headSize
)
..
relativeLineTo
(
headSize
,
0.0
)
..
relativeLineTo
(-
headSize
,
headSize
)
..
relativeLineTo
(-
headSize
,
-
headSize
)
..
relativeLineTo
(
headSize
,
0.0
)
..
moveTo
(
offset
.
dx
+
size
.
width
/
2.0
,
offset
.
dy
+
size
.
height
)
..
relativeLineTo
(
0.0
,
-
childParentData
.
offset
.
dy
+
headSize
)
..
relativeLineTo
(
headSize
,
0.0
)
..
relativeLineTo
(-
headSize
,
-
headSize
)
..
relativeLineTo
(-
headSize
,
headSize
)
..
relativeLineTo
(
headSize
,
0.0
);
context
.
canvas
.
drawPath
(
path
,
paint
);
}
if
(
childParentData
.
offset
.
dx
>
0.0
)
{
// horizontal alignment arrows
double
headSize
=
math
.
min
(
childParentData
.
offset
.
dx
*
0.2
,
10.0
);
path
..
moveTo
(
offset
.
dx
,
offset
.
dy
+
size
.
height
/
2.0
)
..
relativeLineTo
(
childParentData
.
offset
.
dx
-
headSize
,
0.0
)
..
relativeLineTo
(
0.0
,
headSize
)
..
relativeLineTo
(
headSize
,
-
headSize
)
..
relativeLineTo
(-
headSize
,
-
headSize
)
..
relativeLineTo
(
0.0
,
headSize
)
..
moveTo
(
offset
.
dx
+
size
.
width
,
offset
.
dy
+
size
.
height
/
2.0
)
..
relativeLineTo
(-
childParentData
.
offset
.
dx
+
headSize
,
0.0
)
..
relativeLineTo
(
0.0
,
headSize
)
..
relativeLineTo
(-
headSize
,
-
headSize
)
..
relativeLineTo
(
headSize
,
-
headSize
)
..
relativeLineTo
(
0.0
,
headSize
);
context
.
canvas
.
drawPath
(
path
,
paint
);
}
}
else
{
paint
=
new
Paint
()
..
color
=
debugPaintSpacingColor
;
context
.
canvas
.
drawRect
(
offset
&
size
,
paint
);
}
return
true
;
});
}
void
debugDescribeSettings
(
List
<
String
>
settings
)
{
super
.
debugDescribeSettings
(
settings
);
settings
.
add
(
'alignment:
$alignment
'
);
...
...
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