| Index: sky/sdk/example/rendering/sector_layout.dart
|
| diff --git a/sky/sdk/example/rendering/sector_layout.dart b/sky/sdk/example/rendering/sector_layout.dart
|
| index 24f09b3b46f308ca76748beb8a50287a6dcc1fa1..002a3aa6e92b1fc70a660fcc28d8bc2f9bb5ff46 100644
|
| --- a/sky/sdk/example/rendering/sector_layout.dart
|
| +++ b/sky/sdk/example/rendering/sector_layout.dart
|
| @@ -38,6 +38,7 @@ class SectorConstraints extends Constraints {
|
| return clamp(min: minDeltaTheta, max: maxDeltaTheta, value: deltaTheta);
|
| }
|
|
|
| + @override
|
| bool get isTight => minDeltaTheta >= maxDeltaTheta && minDeltaTheta >= maxDeltaTheta;
|
| }
|
|
|
| @@ -65,6 +66,7 @@ class SectorParentData extends ParentData {
|
|
|
| abstract class RenderSector extends RenderObject {
|
|
|
| + @override
|
| void setupParentData(RenderObject child) {
|
| if (child.parentData is! SectorParentData)
|
| child.parentData = new SectorParentData();
|
| @@ -74,7 +76,10 @@ abstract class RenderSector extends RenderObject {
|
| return new SectorDimensions.withConstraints(constraints);
|
| }
|
|
|
| + @override
|
| SectorConstraints get constraints => super.constraints;
|
| +
|
| + @override
|
| bool debugDoesMeetConstraints() {
|
| assert(constraints != null);
|
| assert(deltaRadius != null);
|
| @@ -86,11 +91,15 @@ abstract class RenderSector extends RenderObject {
|
| constraints.minDeltaTheta <= deltaTheta &&
|
| deltaTheta <= math.max(constraints.minDeltaTheta, constraints.maxDeltaTheta);
|
| }
|
| +
|
| + @override
|
| void performResize() {
|
| // default behaviour for subclasses that have sizedByParent = true
|
| deltaRadius = constraints.constrainDeltaRadius(0.0);
|
| deltaTheta = constraints.constrainDeltaTheta(0.0);
|
| }
|
| +
|
| + @override
|
| void performLayout() {
|
| // descendants have to either override performLayout() to set both
|
| // the dimensions and lay out children, or, set sizedByParent to
|
| @@ -127,6 +136,7 @@ abstract class RenderDecoratedSector extends RenderSector {
|
| }
|
|
|
| // offset must point to the center of the circle
|
| + @override
|
| void paint(PaintingCanvas canvas, Offset offset) {
|
| assert(deltaRadius != null);
|
| assert(deltaTheta != null);
|
| @@ -156,6 +166,7 @@ class SectorChildListParentData extends SectorParentData with ContainerParentDat
|
| class RenderSectorWithChildren extends RenderDecoratedSector with ContainerRenderObjectMixin<RenderSector, SectorChildListParentData> {
|
| RenderSectorWithChildren(BoxDecoration decoration) : super(decoration);
|
|
|
| + @override
|
| void hitTestChildren(HitTestResult result, { double radius, double theta }) {
|
| RenderSector child = lastChild;
|
| while (child != null) {
|
| @@ -197,12 +208,14 @@ class RenderSectorRing extends RenderSectorWithChildren {
|
| }
|
| }
|
|
|
| + @override
|
| void setupParentData(RenderObject child) {
|
| // TODO(ianh): avoid code duplication
|
| if (child.parentData is! SectorChildListParentData)
|
| child.parentData = new SectorChildListParentData();
|
| }
|
|
|
| + @override
|
| SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) {
|
| double outerDeltaRadius = constraints.constrainDeltaRadius(desiredDeltaRadius);
|
| double innerDeltaRadius = outerDeltaRadius - padding * 2.0;
|
| @@ -231,6 +244,7 @@ class RenderSectorRing extends RenderSectorWithChildren {
|
| deltaTheta: innerTheta);
|
| }
|
|
|
| + @override
|
| void performLayout() {
|
| assert(this.parentData is SectorParentData);
|
| deltaRadius = constraints.constrainDeltaRadius(desiredDeltaRadius);
|
| @@ -264,6 +278,7 @@ class RenderSectorRing extends RenderSectorWithChildren {
|
|
|
| // offset must point to the center of our circle
|
| // each sector then knows how to paint itself at its location
|
| + @override
|
| void paint(PaintingCanvas canvas, Offset offset) {
|
| // TODO(ianh): avoid code duplication
|
| super.paint(canvas, offset);
|
| @@ -307,12 +322,14 @@ class RenderSectorSlice extends RenderSectorWithChildren {
|
| }
|
| }
|
|
|
| + @override
|
| void setupParentData(RenderObject child) {
|
| // TODO(ianh): avoid code duplication
|
| if (child.parentData is! SectorChildListParentData)
|
| child.parentData = new SectorChildListParentData();
|
| }
|
|
|
| + @override
|
| SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) {
|
| assert(this.parentData is SectorParentData);
|
| double paddingTheta = math.atan(padding / this.parentData.radius);
|
| @@ -339,6 +356,7 @@ class RenderSectorSlice extends RenderSectorWithChildren {
|
| deltaTheta: outerDeltaTheta);
|
| }
|
|
|
| + @override
|
| void performLayout() {
|
| assert(this.parentData is SectorParentData);
|
| deltaTheta = constraints.constrainDeltaTheta(desiredDeltaTheta);
|
| @@ -369,6 +387,7 @@ class RenderSectorSlice extends RenderSectorWithChildren {
|
|
|
| // offset must point to the center of our circle
|
| // each sector then knows how to paint itself at its location
|
| + @override
|
| void paint(PaintingCanvas canvas, Offset offset) {
|
| // TODO(ianh): avoid code duplication
|
| super.paint(canvas, offset);
|
| @@ -407,29 +426,34 @@ class RenderBoxToRenderSectorAdapter extends RenderBox {
|
| markNeedsLayout();
|
| }
|
|
|
| + @override
|
| void setupParentData(RenderObject child) {
|
| if (child.parentData is! SectorParentData)
|
| child.parentData = new SectorParentData();
|
| }
|
|
|
| + @override
|
| double getMinIntrinsicWidth(BoxConstraints constraints) {
|
| if (child == null)
|
| return super.getMinIntrinsicWidth(constraints);
|
| return getIntrinsicDimensions(constraints).width;
|
| }
|
|
|
| + @override
|
| double getMaxIntrinsicWidth(BoxConstraints constraints) {
|
| if (child == null)
|
| return super.getMaxIntrinsicWidth(constraints);
|
| return getIntrinsicDimensions(constraints).width;
|
| }
|
|
|
| + @override
|
| double getMinIntrinsicHeight(BoxConstraints constraints) {
|
| if (child == null)
|
| return super.getMinIntrinsicHeight(constraints);
|
| return getIntrinsicDimensions(constraints).height;
|
| }
|
|
|
| + @override
|
| double getMaxIntrinsicHeight(BoxConstraints constraints) {
|
| if (child == null)
|
| return super.getMaxIntrinsicHeight(constraints);
|
| @@ -446,6 +470,7 @@ class RenderBoxToRenderSectorAdapter extends RenderBox {
|
| return constraints.constrain(new Size(dimension, dimension));
|
| }
|
|
|
| + @override
|
| void performLayout() {
|
| if (child == null) {
|
| size = constraints.constrain(Size.zero);
|
| @@ -462,6 +487,7 @@ class RenderBoxToRenderSectorAdapter extends RenderBox {
|
| }
|
| }
|
|
|
| + @override
|
| void paint(PaintingCanvas canvas, Offset offset) {
|
| super.paint(canvas, offset);
|
| if (child != null) {
|
| @@ -471,6 +497,7 @@ class RenderBoxToRenderSectorAdapter extends RenderBox {
|
| }
|
| }
|
|
|
| + @override
|
| bool hitTest(HitTestResult result, { Point position }) {
|
| double x = position.x;
|
| double y = position.y;
|
| @@ -492,7 +519,7 @@ class RenderBoxToRenderSectorAdapter extends RenderBox {
|
| result.add(new BoxHitTestEntry(this, position));
|
| return true;
|
| }
|
| -
|
| +
|
| }
|
|
|
| class RenderSolidColor extends RenderDecoratedSector {
|
| @@ -506,15 +533,18 @@ class RenderSolidColor extends RenderDecoratedSector {
|
| double desiredDeltaTheta;
|
| final Color backgroundColor;
|
|
|
| + @override
|
| SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) {
|
| return new SectorDimensions.withConstraints(constraints, deltaTheta: desiredDeltaTheta);
|
| }
|
|
|
| + @override
|
| void performLayout() {
|
| deltaRadius = constraints.constrainDeltaRadius(desiredDeltaRadius);
|
| deltaTheta = constraints.constrainDeltaTheta(desiredDeltaTheta);
|
| }
|
|
|
| + @override
|
| void handleEvent(sky.Event event, HitTestEntry entry) {
|
| if (event.type == 'pointerdown')
|
| decoration = new BoxDecoration(backgroundColor: const Color(0xFFFF0000));
|
|
|