提交 8c097b08 编写于 作者: M Matt Perry

Update BoxDecoration and RenderParagraph to use sky.Color instead of int.

Also add operator==, hashCode, toString, and some basic Color constants to
Color.

R=abarth@chromium.org, ianh@google.com

Review URL: https://codereview.chromium.org/1162023004
上级 3aa1e23d
...@@ -15,4 +15,7 @@ class Color { ...@@ -15,4 +15,7 @@ class Color {
((g & 0xff) << 8) | ((g & 0xff) << 8) |
((b & 0xff) << 0)); ((b & 0xff) << 0));
bool operator ==(other) => other is Color && _value == other._value;
int get hashCode => _value.hashCode;
String toString() => "Color(0x${_value.toRadixString(16).padLeft(8, '0')})";
} }
...@@ -14,11 +14,11 @@ class ContainerApp extends App { ...@@ -14,11 +14,11 @@ class ContainerApp extends App {
padding: new EdgeDims.all(10.0), padding: new EdgeDims.all(10.0),
margin: new EdgeDims.all(10.0), margin: new EdgeDims.all(10.0),
desiredSize: new sky.Size(double.INFINITY, 100.0), desiredSize: new sky.Size(double.INFINITY, 100.0),
decoration: new BoxDecoration(backgroundColor: 0xFF00FF00), decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF00FF00)),
child: new BlockContainer( child: new BlockContainer(
children: [ children: [
new Container( new Container(
decoration: new BoxDecoration(backgroundColor: 0xFFFFFF00), decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFFFFFF00)),
desiredSize: new sky.Size(double.INFINITY, 20.0) desiredSize: new sky.Size(double.INFINITY, 20.0)
) )
])), ])),
......
...@@ -11,9 +11,9 @@ import 'package:sky/framework/rendering/paragraph.dart'; ...@@ -11,9 +11,9 @@ import 'package:sky/framework/rendering/paragraph.dart';
class RenderSolidColor extends RenderDecoratedBox { class RenderSolidColor extends RenderDecoratedBox {
final Size desiredSize; final Size desiredSize;
final int backgroundColor; final Color backgroundColor;
RenderSolidColor(int backgroundColor, { this.desiredSize: const Size.infinite() }) RenderSolidColor(Color backgroundColor, { this.desiredSize: const Size.infinite() })
: backgroundColor = backgroundColor, : backgroundColor = backgroundColor,
super(decoration: new BoxDecoration(backgroundColor: backgroundColor)); super(decoration: new BoxDecoration(backgroundColor: backgroundColor));
...@@ -27,7 +27,7 @@ class RenderSolidColor extends RenderDecoratedBox { ...@@ -27,7 +27,7 @@ class RenderSolidColor extends RenderDecoratedBox {
void handlePointer(PointerEvent event) { void handlePointer(PointerEvent event) {
if (event.type == 'pointerdown') if (event.type == 'pointerdown')
decoration = new BoxDecoration(backgroundColor: 0xFFFF0000); decoration = new BoxDecoration(backgroundColor: const Color(0xFFFF0000));
else if (event.type == 'pointerup') else if (event.type == 'pointerup')
decoration = new BoxDecoration(backgroundColor: backgroundColor); decoration = new BoxDecoration(backgroundColor: backgroundColor);
} }
...@@ -39,11 +39,11 @@ void main() { ...@@ -39,11 +39,11 @@ void main() {
RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.Vertical); RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.Vertical);
RenderNode root = new RenderDecoratedBox( RenderNode root = new RenderDecoratedBox(
decoration: new BoxDecoration(backgroundColor: 0xFF606060), decoration: new BoxDecoration(backgroundColor: const Color(0xFF606060)),
child: flexRoot child: flexRoot
); );
RenderNode child = new RenderSolidColor(0xFFFFFF00); RenderNode child = new RenderSolidColor(const Color(0xFFFFFF00));
flexRoot.add(child); flexRoot.add(child);
child.parentData.flex = 2; child.parentData.flex = 2;
...@@ -55,8 +55,8 @@ alcatra. Pork pork belly alcatra, flank chuck drumstick biltong doner jowl. ...@@ -55,8 +55,8 @@ alcatra. Pork pork belly alcatra, flank chuck drumstick biltong doner jowl.
Pancetta meatball tongue tenderloin rump tail jowl boudin."""; Pancetta meatball tongue tenderloin rump tail jowl boudin.""";
child = new RenderDecoratedBox( child = new RenderDecoratedBox(
decoration: new BoxDecoration(backgroundColor: 0xFFFFFFFF), decoration: new BoxDecoration(backgroundColor: const Color(0xFFFFFFFF)),
child: new RenderParagraph(text: meatyString, color: 0xFF009900) child: new RenderParagraph(text: meatyString, color: const Color(0xFF009900))
); );
flexRoot.add(child); flexRoot.add(child);
child.parentData.flex = 1; child.parentData.flex = 1;
......
...@@ -463,7 +463,7 @@ class RenderBoxToRenderSectorAdapter extends RenderBox { ...@@ -463,7 +463,7 @@ class RenderBoxToRenderSectorAdapter extends RenderBox {
} }
class RenderSolidColor extends RenderDecoratedSector { class RenderSolidColor extends RenderDecoratedSector {
RenderSolidColor(int backgroundColor, { RenderSolidColor(sky.Color backgroundColor, {
this.desiredDeltaRadius: double.INFINITY, this.desiredDeltaRadius: double.INFINITY,
this.desiredDeltaTheta: kTwoPi this.desiredDeltaTheta: kTwoPi
}) : this.backgroundColor = backgroundColor, }) : this.backgroundColor = backgroundColor,
...@@ -471,7 +471,7 @@ class RenderSolidColor extends RenderDecoratedSector { ...@@ -471,7 +471,7 @@ class RenderSolidColor extends RenderDecoratedSector {
double desiredDeltaRadius; double desiredDeltaRadius;
double desiredDeltaTheta; double desiredDeltaTheta;
final int backgroundColor; final sky.Color backgroundColor;
SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) { SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) {
return new SectorDimensions.withConstraints(constraints, deltaTheta: 1.0); // 1.0 radians return new SectorDimensions.withConstraints(constraints, deltaTheta: 1.0); // 1.0 radians
...@@ -484,7 +484,7 @@ class RenderSolidColor extends RenderDecoratedSector { ...@@ -484,7 +484,7 @@ class RenderSolidColor extends RenderDecoratedSector {
void handlePointer(sky.PointerEvent event) { void handlePointer(sky.PointerEvent event) {
if (event.type == 'pointerdown') if (event.type == 'pointerdown')
decoration = new BoxDecoration(backgroundColor: 0xFFFF0000); decoration = new BoxDecoration(backgroundColor: const sky.Color(0xFFFF0000));
else if (event.type == 'pointerup') else if (event.type == 'pointerup')
decoration = new BoxDecoration(backgroundColor: backgroundColor); decoration = new BoxDecoration(backgroundColor: backgroundColor);
} }
...@@ -495,12 +495,12 @@ AppView app; ...@@ -495,12 +495,12 @@ AppView app;
void main() { void main() {
var rootCircle = new RenderSectorRing(padding: 20.0); var rootCircle = new RenderSectorRing(padding: 20.0);
rootCircle.add(new RenderSolidColor(0xFF00FFFF, desiredDeltaTheta: kTwoPi * 0.15)); rootCircle.add(new RenderSolidColor(const sky.Color(0xFF00FFFF), desiredDeltaTheta: kTwoPi * 0.15));
rootCircle.add(new RenderSolidColor(0xFF0000FF, desiredDeltaTheta: kTwoPi * 0.4)); rootCircle.add(new RenderSolidColor(const sky.Color(0xFF0000FF), desiredDeltaTheta: kTwoPi * 0.4));
var stack = new RenderSectorSlice(padding: 2.0); var stack = new RenderSectorSlice(padding: 2.0);
stack.add(new RenderSolidColor(0xFFFFFF00, desiredDeltaRadius: 20.0)); stack.add(new RenderSolidColor(const sky.Color(0xFFFFFF00), desiredDeltaRadius: 20.0));
stack.add(new RenderSolidColor(0xFFFF9000, desiredDeltaRadius: 20.0)); stack.add(new RenderSolidColor(const sky.Color(0xFFFF9000), desiredDeltaRadius: 20.0));
stack.add(new RenderSolidColor(0xFF00FF00)); stack.add(new RenderSolidColor(const sky.Color(0xFF00FF00)));
rootCircle.add(stack); rootCircle.add(stack);
var root = new RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCircle); var root = new RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCircle);
......
...@@ -12,7 +12,7 @@ AppView app; ...@@ -12,7 +12,7 @@ AppView app;
void main() { void main() {
RenderDecoratedBox green = new RenderDecoratedBox( RenderDecoratedBox green = new RenderDecoratedBox(
decoration: new BoxDecoration(backgroundColor: 0xFF00FF00)); decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF00FF00)));
RenderSizedBox box = new RenderSizedBox( RenderSizedBox box = new RenderSizedBox(
desiredSize: new sky.Size(200.0, 200.0), child: green); desiredSize: new sky.Size(200.0, 200.0), child: green);
......
...@@ -209,7 +209,7 @@ class StocksApp extends App { ...@@ -209,7 +209,7 @@ class StocksApp extends App {
return new Container( return new Container(
child: new BlockContainer(children: [buildToolBar()]), child: new BlockContainer(children: [buildToolBar()]),
decoration: new BoxDecoration( decoration: new BoxDecoration(
backgroundColor: 0xFFFFFFFF backgroundColor: const sky.Color(0xFFFFFFFF)
) )
); );
......
...@@ -30,7 +30,7 @@ class Icon extends Component { ...@@ -30,7 +30,7 @@ class Icon extends Component {
// TODO(jackson): Use a real image. // TODO(jackson): Use a real image.
return new Container( return new Container(
desiredSize: new sky.Size(size.toDouble(), size.toDouble()), desiredSize: new sky.Size(size.toDouble(), size.toDouble()),
decoration: new BoxDecoration(backgroundColor: 0xFFFF0000) decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFFFF0000))
); );
// return new Image(width: size, height: size, // return new Image(width: size, height: size,
// src: '${kAssetBase}/${category}/2x_web/ic_${subtype}_${size}dp.png'); // src: '${kAssetBase}/${category}/2x_web/ic_${subtype}_${size}dp.png');
......
...@@ -43,7 +43,7 @@ class ToolBar extends Component { ...@@ -43,7 +43,7 @@ class ToolBar extends Component {
), ),
desiredSize: new sky.Size.fromHeight(56.0), desiredSize: new sky.Size.fromHeight(56.0),
// padding: new EdgeDims(kStatusBarHeight.toDouble(), 8.0, 0.0, 8.0), // padding: new EdgeDims(kStatusBarHeight.toDouble(), 8.0, 0.0, 8.0),
decoration: new BoxDecoration(backgroundColor: backgroundColor.value) decoration: new BoxDecoration(backgroundColor: backgroundColor)
); );
} }
} }
...@@ -251,11 +251,7 @@ class RenderPadding extends RenderBox with RenderNodeWithChildMixin<RenderBox> { ...@@ -251,11 +251,7 @@ class RenderPadding extends RenderBox with RenderNodeWithChildMixin<RenderBox> {
// This must be immutable, because we won't notice when it changes // This must be immutable, because we won't notice when it changes
class BoxDecoration { class BoxDecoration {
// TODO(mpcomplete): go through and change the users of this class to pass const BoxDecoration({this.backgroundColor});
// a Color object.
BoxDecoration({
backgroundColor
}) : backgroundColor = new sky.Color(backgroundColor);
final sky.Color backgroundColor; final sky.Color backgroundColor;
} }
......
...@@ -16,7 +16,7 @@ class RenderParagraph extends RenderBox { ...@@ -16,7 +16,7 @@ class RenderParagraph extends RenderBox {
RenderParagraph({ RenderParagraph({
String text, String text,
int color sky.Color color
}) : _color = color { }) : _color = color {
_layoutRoot.rootElement = _document.createElement('p'); _layoutRoot.rootElement = _document.createElement('p');
this.text = text; this.text = text;
...@@ -31,9 +31,9 @@ class RenderParagraph extends RenderBox { ...@@ -31,9 +31,9 @@ class RenderParagraph extends RenderBox {
markNeedsLayout(); markNeedsLayout();
} }
int _color = 0xFF000000; sky.Color _color = const sky.Color(0xFF000000);
int get color => _color; sky.Color get color => _color;
void set color (int value) { void set color (sky.Color value) {
if (_color != value) { if (_color != value) {
_color = value; _color = value;
markNeedsPaint(); markNeedsPaint();
......
...@@ -5,12 +5,12 @@ PAINT FOR FRAME #1 ---------------------------------------------- ...@@ -5,12 +5,12 @@ PAINT FOR FRAME #1 ----------------------------------------------
1 | TestDisplayList() constructor: 800.0 x 600.0 1 | TestDisplayList() constructor: 800.0 x 600.0
1 | paintChild at 0.0,0.0 1 | paintChild at 0.0,0.0
1 | | TestDisplayList() constructor: 800.0 x 600.0 1 | | TestDisplayList() constructor: 800.0 x 600.0
1 | | drawRect(0.0:0.0:600.0:800.0, Paint(0xff0000ff)) 1 | | drawRect(0.0:0.0:600.0:800.0, Paint(Color(0xff0000ff)))
1 | | paintChild at 0.0,0.0 1 | | paintChild at 0.0,0.0
1 | | | TestDisplayList() constructor: 800.0 x 600.0 1 | | | TestDisplayList() constructor: 800.0 x 600.0
1 | | | paintChild at 50.0,50.0 1 | | | paintChild at 50.0,50.0
1 | | | | TestDisplayList() constructor: 800.0 x 600.0 1 | | | | TestDisplayList() constructor: 800.0 x 600.0
1 | | | | drawRect(0.0:0.0:100.0:700.0, Paint(0xff00ff00)) 1 | | | | drawRect(0.0:0.0:100.0:700.0, Paint(Color(0xff00ff00)))
------------------------------------------------------------------------ ------------------------------------------------------------------------
CONSOLE: PASS: padding CONSOLE: PASS: padding
CONSOLE: CONSOLE:
......
...@@ -15,10 +15,10 @@ void main() { ...@@ -15,10 +15,10 @@ void main() {
test("padding", () { test("padding", () {
var size = new RenderSizedBox(desiredSize: new sky.Size(double.INFINITY, 100.0)); var size = new RenderSizedBox(desiredSize: new sky.Size(double.INFINITY, 100.0));
var inner = new RenderDecoratedBox(decoration: new BoxDecoration(backgroundColor: 0xFF00FF00), child: size); var inner = new RenderDecoratedBox(decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF00FF00)), child: size);
var padding = new RenderPadding(padding: new EdgeDims.all(50.0), child: inner); var padding = new RenderPadding(padding: new EdgeDims.all(50.0), child: inner);
var block = new RenderBlock(children: [padding]); var block = new RenderBlock(children: [padding]);
var outer = new RenderDecoratedBox(decoration: new BoxDecoration(backgroundColor: 0xFF0000FF), child: block); var outer = new RenderDecoratedBox(decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF0000FF)), child: block);
app = new TestApp(outer); app = new TestApp(outer);
}); });
} }
...@@ -5,7 +5,7 @@ PAINT FOR FRAME #1 ---------------------------------------------- ...@@ -5,7 +5,7 @@ PAINT FOR FRAME #1 ----------------------------------------------
1 | TestDisplayList() constructor: 800.0 x 600.0 1 | TestDisplayList() constructor: 800.0 x 600.0
1 | paintChild at 0.0,0.0 1 | paintChild at 0.0,0.0
1 | | TestDisplayList() constructor: 800.0 x 600.0 1 | | TestDisplayList() constructor: 800.0 x 600.0
1 | | drawRect(0.0:0.0:600.0:800.0, Paint(0xff00ff00)) 1 | | drawRect(0.0:0.0:600.0:800.0, Paint(Color(0xff00ff00)))
------------------------------------------------------------------------ ------------------------------------------------------------------------
CONSOLE: PASS: should size to render view CONSOLE: PASS: should size to render view
CONSOLE: CONSOLE:
......
...@@ -14,7 +14,7 @@ void main() { ...@@ -14,7 +14,7 @@ void main() {
test("should size to render view", () { test("should size to render view", () {
RenderSizedBox root = new RenderSizedBox( RenderSizedBox root = new RenderSizedBox(
child: new RenderDecoratedBox( child: new RenderDecoratedBox(
decoration: new BoxDecoration(backgroundColor: 0xFF00FF00) decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF00FF00))
) )
); );
TestView renderView = new TestView(child: root); TestView renderView = new TestView(child: root);
......
...@@ -5,33 +5,33 @@ PAINT FOR FRAME #1 ---------------------------------------------- ...@@ -5,33 +5,33 @@ PAINT FOR FRAME #1 ----------------------------------------------
1 | TestDisplayList() constructor: 800.0 x 600.0 1 | TestDisplayList() constructor: 800.0 x 600.0
1 | paintChild at 0.0,0.0 1 | paintChild at 0.0,0.0
1 | | TestDisplayList() constructor: 800.0 x 600.0 1 | | TestDisplayList() constructor: 800.0 x 600.0
1 | | drawRect(0.0:0.0:600.0:800.0, Paint(0xff000000)) 1 | | drawRect(0.0:0.0:600.0:800.0, Paint(Color(0xff000000)))
1 | | paintChild at 0.0,0.0 1 | | paintChild at 0.0,0.0
1 | | | TestDisplayList() constructor: 800.0 x 600.0 1 | | | TestDisplayList() constructor: 800.0 x 600.0
1 | | | drawRect(0.0:0.0:82.5:800.0, Paint(0xffffff00)) 1 | | | drawRect(0.0:0.0:82.5:800.0, Paint(Color(0xffffff00)))
1 | | paintChild at 350.0,82.5 1 | | paintChild at 350.0,82.5
1 | | | TestDisplayList() constructor: 800.0 x 600.0 1 | | | TestDisplayList() constructor: 800.0 x 600.0
1 | | | drawRect(0.0:0.0:100.0:100.0, Paint(0x7700ffff)) 1 | | | drawRect(0.0:0.0:100.0:100.0, Paint(Color(0x7700ffff)))
1 | | paintChild at 0.0,182.5 1 | | paintChild at 0.0,182.5
1 | | | TestDisplayList() constructor: 800.0 x 600.0 1 | | | TestDisplayList() constructor: 800.0 x 600.0
1 | | | paintChild at 10.0,10.0 1 | | | paintChild at 10.0,10.0
1 | | | | TestDisplayList() constructor: 800.0 x 600.0 1 | | | | TestDisplayList() constructor: 800.0 x 600.0
1 | | | | drawRect(0.0:0.0:150.0:780.0, Paint(0xffffffff)) 1 | | | | drawRect(0.0:0.0:150.0:780.0, Paint(Color(0xffffffff)))
1 | | | | paintChild at 0.0,0.0 1 | | | | paintChild at 0.0,0.0
1 | | | | | TestDisplayList() constructor: 800.0 x 600.0 1 | | | | | TestDisplayList() constructor: 800.0 x 600.0
1 | | | | | drawRect(0.0:0.0:50.0:780.0, Paint(0xff00ff00)) 1 | | | | | drawRect(0.0:0.0:50.0:780.0, Paint(Color(0xff00ff00)))
1 | | | | paintChild at 0.0,50.0 1 | | | | paintChild at 0.0,50.0
1 | | | | | TestDisplayList() constructor: 800.0 x 600.0 1 | | | | | TestDisplayList() constructor: 800.0 x 600.0
1 | | | | | drawRect(0.0:0.0:100.0:780.0, Paint(0x7700ffff)) 1 | | | | | drawRect(0.0:0.0:100.0:780.0, Paint(Color(0x7700ffff)))
1 | | paintChild at 0.0,352.5 1 | | paintChild at 0.0,352.5
1 | | | TestDisplayList() constructor: 800.0 x 600.0 1 | | | TestDisplayList() constructor: 800.0 x 600.0
1 | | | drawRect(0.0:0.0:247.5:800.0, Paint(0xff333333)) 1 | | | drawRect(0.0:0.0:247.5:800.0, Paint(Color(0xff333333)))
1 | | | paintChild at 0.0,0.0 1 | | | paintChild at 0.0,0.0
1 | | | | TestDisplayList() constructor: 800.0 x 600.0 1 | | | | TestDisplayList() constructor: 800.0 x 600.0
1 | | | | drawRect(0.0:0.0:247.5:266.6666564941406, Paint(0x77ff00ff)) 1 | | | | drawRect(0.0:0.0:247.5:266.6666564941406, Paint(Color(0x77ff00ff)))
1 | | | paintChild at 266.6666666666667,0.0 1 | | | paintChild at 266.6666666666667,0.0
1 | | | | TestDisplayList() constructor: 800.0 x 600.0 1 | | | | TestDisplayList() constructor: 800.0 x 600.0
1 | | | | drawRect(0.0:0.0:247.5:533.3333129882812, Paint(0xff0000ff)) 1 | | | | drawRect(0.0:0.0:247.5:533.3333129882812, Paint(Color(0xff0000ff)))
------------------------------------------------------------------------ ------------------------------------------------------------------------
CONSOLE: PASS: should flex CONSOLE: PASS: should flex
CONSOLE: CONSOLE:
......
...@@ -13,9 +13,9 @@ import 'package:sky/framework/rendering/flex.dart'; ...@@ -13,9 +13,9 @@ import 'package:sky/framework/rendering/flex.dart';
class RenderSolidColor extends RenderDecoratedBox { class RenderSolidColor extends RenderDecoratedBox {
final sky.Size desiredSize; final sky.Size desiredSize;
final int backgroundColor; final sky.Color backgroundColor;
RenderSolidColor(int backgroundColor, { this.desiredSize: const sky.Size.infinite() }) RenderSolidColor(sky.Color backgroundColor, { this.desiredSize: const sky.Size.infinite() })
: backgroundColor = backgroundColor, : backgroundColor = backgroundColor,
super(decoration: new BoxDecoration(backgroundColor: backgroundColor)) { super(decoration: new BoxDecoration(backgroundColor: backgroundColor)) {
} }
...@@ -30,7 +30,7 @@ class RenderSolidColor extends RenderDecoratedBox { ...@@ -30,7 +30,7 @@ class RenderSolidColor extends RenderDecoratedBox {
void handlePointer(sky.PointerEvent event) { void handlePointer(sky.PointerEvent event) {
if (event.type == 'pointerdown') if (event.type == 'pointerdown')
decoration = new BoxDecoration(backgroundColor: 0xFFFF0000); decoration = new BoxDecoration(backgroundColor: const sky.Color(0xFFFF0000));
else if (event.type == 'pointerup') else if (event.type == 'pointerup')
decoration = new BoxDecoration(backgroundColor: backgroundColor); decoration = new BoxDecoration(backgroundColor: backgroundColor);
} }
...@@ -45,30 +45,30 @@ void main() { ...@@ -45,30 +45,30 @@ void main() {
RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.Vertical); RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.Vertical);
RenderDecoratedBox root = new RenderDecoratedBox( RenderDecoratedBox root = new RenderDecoratedBox(
decoration: new BoxDecoration(backgroundColor: 0xFF000000), decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF000000)),
child: flexRoot child: flexRoot
); );
void addFlexChildSolidColor(RenderFlex parent, int backgroundColor, { int flex: 0 }) { void addFlexChildSolidColor(RenderFlex parent, sky.Color backgroundColor, { int flex: 0 }) {
RenderSolidColor child = new RenderSolidColor(backgroundColor); RenderSolidColor child = new RenderSolidColor(backgroundColor);
parent.add(child); parent.add(child);
child.parentData.flex = flex; child.parentData.flex = flex;
} }
// Yellow bar at top // Yellow bar at top
addFlexChildSolidColor(flexRoot, 0xFFFFFF00, flex: 1); addFlexChildSolidColor(flexRoot, const sky.Color(0xFFFFFF00), flex: 1);
// Turquoise box // Turquoise box
flexRoot.add(new RenderSolidColor(0x7700FFFF, desiredSize: new sky.Size(100.0, 100.0))); flexRoot.add(new RenderSolidColor(const sky.Color(0x7700FFFF), desiredSize: new sky.Size(100.0, 100.0)));
// Green and cyan render block with padding // Green and cyan render block with padding
var renderBlock = new RenderBlock(); var renderBlock = new RenderBlock();
renderBlock.add(new RenderSolidColor(0xFF00FF00, desiredSize: new sky.Size(100.0, 50.0))); renderBlock.add(new RenderSolidColor(const sky.Color(0xFF00FF00), desiredSize: new sky.Size(100.0, 50.0)));
renderBlock.add(new RenderSolidColor(0x7700FFFF, desiredSize: new sky.Size(50.0, 100.0))); renderBlock.add(new RenderSolidColor(const sky.Color(0x7700FFFF), desiredSize: new sky.Size(50.0, 100.0)));
var renderDecoratedBlock = new RenderDecoratedBox( var renderDecoratedBlock = new RenderDecoratedBox(
decoration: new BoxDecoration(backgroundColor: 0xFFFFFFFF), decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFFFFFFFF)),
child: renderBlock child: renderBlock
); );
...@@ -77,11 +77,11 @@ void main() { ...@@ -77,11 +77,11 @@ void main() {
var row = new RenderFlex(direction: FlexDirection.Horizontal); var row = new RenderFlex(direction: FlexDirection.Horizontal);
// Purple and blue cells // Purple and blue cells
addFlexChildSolidColor(row, 0x77FF00FF, flex: 1); addFlexChildSolidColor(row, const sky.Color(0x77FF00FF), flex: 1);
addFlexChildSolidColor(row, 0xFF0000FF, flex: 2); addFlexChildSolidColor(row, const sky.Color(0xFF0000FF), flex: 2);
var decoratedRow = new RenderDecoratedBox( var decoratedRow = new RenderDecoratedBox(
decoration: new BoxDecoration(backgroundColor: 0xFF333333), decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF333333)),
child: row child: row
); );
......
...@@ -23,7 +23,7 @@ class TestDisplayList extends RenderNodeDisplayList { ...@@ -23,7 +23,7 @@ class TestDisplayList extends RenderNodeDisplayList {
} }
String explainPaint(sky.Paint paint) { String explainPaint(sky.Paint paint) {
return "Paint(0x${paint.color.value.toRadixString(16).padLeft(8, '0')})"; return "Paint(${paint.color})";
} }
void save() { void save() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册