mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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
This commit is contained in:
parent
54e652d365
commit
6213436a7d
@ -14,11 +14,11 @@ class ContainerApp extends App {
|
||||
padding: new EdgeDims.all(10.0),
|
||||
margin: new EdgeDims.all(10.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(
|
||||
children: [
|
||||
new Container(
|
||||
decoration: new BoxDecoration(backgroundColor: 0xFFFFFF00),
|
||||
decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFFFFFF00)),
|
||||
desiredSize: new sky.Size(double.INFINITY, 20.0)
|
||||
)
|
||||
])),
|
||||
|
||||
@ -5,12 +5,12 @@ PAINT FOR FRAME #1 ----------------------------------------------
|
||||
1 | TestDisplayList() constructor: 800.0 x 600.0
|
||||
1 | paintChild at 0.0,0.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 | | | TestDisplayList() constructor: 800.0 x 600.0
|
||||
1 | | | paintChild at 50.0,50.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:
|
||||
|
||||
@ -15,10 +15,10 @@ void main() {
|
||||
|
||||
test("padding", () {
|
||||
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 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);
|
||||
});
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ PAINT FOR FRAME #1 ----------------------------------------------
|
||||
1 | TestDisplayList() constructor: 800.0 x 600.0
|
||||
1 | paintChild at 0.0,0.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:
|
||||
|
||||
@ -14,7 +14,7 @@ void main() {
|
||||
test("should size to render view", () {
|
||||
RenderSizedBox root = new RenderSizedBox(
|
||||
child: new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(backgroundColor: 0xFF00FF00)
|
||||
decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF00FF00))
|
||||
)
|
||||
);
|
||||
TestView renderView = new TestView(child: root);
|
||||
|
||||
@ -5,33 +5,33 @@ PAINT FOR FRAME #1 ----------------------------------------------
|
||||
1 | TestDisplayList() constructor: 800.0 x 600.0
|
||||
1 | paintChild at 0.0,0.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 | | | 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 | | | 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 | | | TestDisplayList() constructor: 800.0 x 600.0
|
||||
1 | | | paintChild at 10.0,10.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 | | | | | 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 | | | | | 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 | | | 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 | | | | 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 | | | | 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:
|
||||
|
||||
@ -13,9 +13,9 @@ import 'package:sky/framework/rendering/flex.dart';
|
||||
|
||||
class RenderSolidColor extends RenderDecoratedBox {
|
||||
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,
|
||||
super(decoration: new BoxDecoration(backgroundColor: backgroundColor)) {
|
||||
}
|
||||
@ -30,7 +30,7 @@ class RenderSolidColor extends RenderDecoratedBox {
|
||||
|
||||
void handlePointer(sky.PointerEvent event) {
|
||||
if (event.type == 'pointerdown')
|
||||
decoration = new BoxDecoration(backgroundColor: 0xFFFF0000);
|
||||
decoration = new BoxDecoration(backgroundColor: const sky.Color(0xFFFF0000));
|
||||
else if (event.type == 'pointerup')
|
||||
decoration = new BoxDecoration(backgroundColor: backgroundColor);
|
||||
}
|
||||
@ -45,30 +45,30 @@ void main() {
|
||||
RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.Vertical);
|
||||
|
||||
RenderDecoratedBox root = new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(backgroundColor: 0xFF000000),
|
||||
decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF000000)),
|
||||
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);
|
||||
parent.add(child);
|
||||
child.parentData.flex = flex;
|
||||
}
|
||||
|
||||
// Yellow bar at top
|
||||
addFlexChildSolidColor(flexRoot, 0xFFFFFF00, flex: 1);
|
||||
addFlexChildSolidColor(flexRoot, const sky.Color(0xFFFFFF00), flex: 1);
|
||||
|
||||
// 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
|
||||
var renderBlock = new RenderBlock();
|
||||
|
||||
renderBlock.add(new RenderSolidColor(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(0xFF00FF00), desiredSize: new sky.Size(100.0, 50.0)));
|
||||
renderBlock.add(new RenderSolidColor(const sky.Color(0x7700FFFF), desiredSize: new sky.Size(50.0, 100.0)));
|
||||
|
||||
var renderDecoratedBlock = new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(backgroundColor: 0xFFFFFFFF),
|
||||
decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFFFFFFFF)),
|
||||
child: renderBlock
|
||||
);
|
||||
|
||||
@ -77,11 +77,11 @@ void main() {
|
||||
var row = new RenderFlex(direction: FlexDirection.Horizontal);
|
||||
|
||||
// Purple and blue cells
|
||||
addFlexChildSolidColor(row, 0x77FF00FF, flex: 1);
|
||||
addFlexChildSolidColor(row, 0xFF0000FF, flex: 2);
|
||||
addFlexChildSolidColor(row, const sky.Color(0x77FF00FF), flex: 1);
|
||||
addFlexChildSolidColor(row, const sky.Color(0xFF0000FF), flex: 2);
|
||||
|
||||
var decoratedRow = new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(backgroundColor: 0xFF333333),
|
||||
decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF333333)),
|
||||
child: row
|
||||
);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user