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
7d7ee705
Commit
7d7ee705
authored
Aug 19, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #690 from abarth/foreground_decoration
Add the ability to draw a foreground box decoration
parents
7782a115
8f0efd54
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
5 deletions
+27
-5
proxy_box.dart
packages/flutter/lib/rendering/proxy_box.dart
+12
-2
basic.dart
packages/flutter/lib/widgets/basic.dart
+15
-3
No files found.
packages/flutter/lib/rendering/proxy_box.dart
View file @
7d7ee705
...
...
@@ -434,13 +434,20 @@ class RenderClipOval extends RenderProxyBox {
}
}
enum
BoxDecorationPosition
{
background
,
foreground
,
}
class
RenderDecoratedBox
extends
RenderProxyBox
{
RenderDecoratedBox
({
BoxDecoration
decoration
,
RenderBox
child
RenderBox
child
,
this
.
position
:
BoxDecorationPosition
.
background
})
:
_painter
=
new
BoxPainter
(
decoration
),
super
(
child
);
BoxDecorationPosition
position
;
final
BoxPainter
_painter
;
BoxDecoration
get
decoration
=>
_painter
.
decoration
;
...
...
@@ -483,8 +490,11 @@ class RenderDecoratedBox extends RenderProxyBox {
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
assert
(
size
.
width
!=
null
);
assert
(
size
.
height
!=
null
);
_painter
.
paint
(
context
.
canvas
,
offset
&
size
);
if
(
position
==
BoxDecorationPosition
.
background
)
_painter
.
paint
(
context
.
canvas
,
offset
&
size
);
super
.
paint
(
context
,
offset
);
if
(
position
==
BoxDecorationPosition
.
foreground
)
_painter
.
paint
(
context
.
canvas
,
offset
&
size
);
}
String
debugDescribeSettings
(
String
prefix
)
=>
'
${super.debugDescribeSettings(prefix)}${prefix}
decoration:
\n
${_painter.decoration.toString(prefix + " ")}
\n
'
;
...
...
packages/flutter/lib/widgets/basic.dart
View file @
7d7ee705
...
...
@@ -30,7 +30,7 @@ export 'package:sky/rendering/block.dart' show BlockDirection;
export
'package:sky/rendering/box.dart'
show
BoxConstraints
;
export
'package:sky/rendering/flex.dart'
show
FlexDirection
,
FlexJustifyContent
,
FlexAlignItems
;
export
'package:sky/rendering/object.dart'
show
Point
,
Offset
,
Size
,
Rect
,
Color
,
Paint
,
Path
;
export
'package:sky/rendering/proxy_box.dart'
show
BackgroundImage
,
BoxDecoration
,
BoxShadow
,
Border
,
BorderSide
,
EdgeDims
,
Shape
;
export
'package:sky/rendering/proxy_box.dart'
show
BackgroundImage
,
BoxDecoration
,
Box
DecorationPosition
,
Box
Shadow
,
Border
,
BorderSide
,
EdgeDims
,
Shape
;
export
'package:sky/rendering/toggleable.dart'
show
ValueChanged
;
export
'package:sky/rendering/viewport.dart'
show
ScrollDirection
;
export
'package:sky/widgets/framework.dart'
show
Key
,
GlobalKey
,
Widget
,
Component
,
StatefulComponent
,
App
,
runApp
,
Listener
,
ParentDataNode
;
...
...
@@ -70,17 +70,19 @@ class ColorFilter extends OneChildRenderObjectWrapper {
}
class
DecoratedBox
extends
OneChildRenderObjectWrapper
{
DecoratedBox
({
Key
key
,
this
.
decoration
,
Widget
child
})
DecoratedBox
({
Key
key
,
this
.
decoration
,
this
.
position
,
Widget
child
})
:
super
(
key:
key
,
child:
child
);
final
BoxDecoration
decoration
;
final
BoxDecorationPosition
position
;
RenderDecoratedBox
createNode
()
=>
new
RenderDecoratedBox
(
decoration:
decoration
);
RenderDecoratedBox
createNode
()
=>
new
RenderDecoratedBox
(
decoration:
decoration
,
position:
position
);
RenderDecoratedBox
get
renderObject
=>
super
.
renderObject
;
void
syncRenderObject
(
DecoratedBox
old
)
{
super
.
syncRenderObject
(
old
);
renderObject
.
decoration
=
decoration
;
renderObject
.
position
=
position
;
}
}
...
...
@@ -327,6 +329,7 @@ class Container extends Component {
this
.
child
,
this
.
constraints
,
this
.
decoration
,
this
.
foregroundDecoration
,
this
.
width
,
this
.
height
,
this
.
margin
,
...
...
@@ -337,6 +340,7 @@ class Container extends Component {
final
Widget
child
;
final
BoxConstraints
constraints
;
final
BoxDecoration
decoration
;
final
BoxDecoration
foregroundDecoration
;
final
EdgeDims
margin
;
final
EdgeDims
padding
;
final
Matrix4
transform
;
...
...
@@ -365,6 +369,14 @@ class Container extends Component {
if
(
decoration
!=
null
)
current
=
new
DecoratedBox
(
decoration:
decoration
,
child:
current
);
if
(
foregroundDecoration
!=
null
)
{
current
=
new
DecoratedBox
(
decoration:
foregroundDecoration
,
position:
BoxDecorationPosition
.
foreground
,
child:
current
);
}
if
(
width
!=
null
||
height
!=
null
)
{
current
=
new
SizedBox
(
width:
width
,
...
...
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