Commit dc491505 authored by Matt Perry's avatar 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
parent 28a43627
...@@ -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)
) )
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment