Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 library layout; | 1 library layout; |
| 2 | 2 |
| 3 // This version of layout.dart is an update to the other one, this one using new APIs. | 3 // This version of layout.dart is an update to the other one, this one using new APIs. |
| 4 // It will not work in a stock Sky setup currently. | 4 // It will not work in a stock Sky setup currently. |
| 5 | 5 |
| 6 import 'node.dart'; | 6 import 'node.dart'; |
| 7 | 7 |
| 8 import 'dart:sky' as sky; | 8 import 'dart:sky' as sky; |
| 9 | 9 |
| 10 // ABSTRACT LAYOUT | 10 // ABSTRACT LAYOUT |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 // override this if you have children, to hand it to the appropriate child | 218 // override this if you have children, to hand it to the appropriate child |
| 219 // override this if you want to do anything with the pointer event | 219 // override this if you want to do anything with the pointer event |
| 220 } | 220 } |
| 221 | 221 |
| 222 | 222 |
| 223 // PAINTING | 223 // PAINTING |
| 224 | 224 |
| 225 static bool _debugDoingPaint = false; | 225 static bool _debugDoingPaint = false; |
| 226 void markNeedsPaint() { | 226 void markNeedsPaint() { |
| 227 assert(!_debugDoingPaint); | 227 assert(!_debugDoingPaint); |
| 228 var ancestor = this; | |
| 229 while (ancestor.parent != null) | |
| 230 ancestor = ancestor.parent; | |
| 231 assert(ancestor is RenderView); | |
| 232 ancestor.paintFrame(); | |
| 233 } | 228 } |
| 234 void paint(RenderNodeDisplayList canvas) { } | 229 void paint(RenderNodeDisplayList canvas) { } |
| 235 | 230 |
| 236 } | 231 } |
| 237 | 232 |
| 238 | 233 |
| 239 // GENERIC MIXIN FOR RENDER NODES THAT TAKE A LIST OF CHILDREN | 234 // GENERIC MIXIN FOR RENDER NODES THAT TAKE A LIST OF CHILDREN |
| 240 | 235 |
| 241 abstract class ContainerParentDataMixin<ChildType extends RenderNode> { | 236 abstract class ContainerParentDataMixin<ChildType extends RenderNode> { |
| 242 ChildType previousSibling; | 237 ChildType previousSibling; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 assert(child.parentData is ParentDataType); | 379 assert(child.parentData is ParentDataType); |
| 385 return child.parentData.nextSibling; | 380 return child.parentData.nextSibling; |
| 386 } | 381 } |
| 387 | 382 |
| 388 } | 383 } |
| 389 | 384 |
| 390 | 385 |
| 391 // GENERIC BOX RENDERING | 386 // GENERIC BOX RENDERING |
| 392 // Anything that has a concept of x, y, width, height is going to derive from th is | 387 // Anything that has a concept of x, y, width, height is going to derive from th is |
| 393 | 388 |
| 389 class BoxConstraints { | |
| 390 const BoxConstraints({ | |
| 391 this.minWidth: 0.0, | |
| 392 this.maxWidth: double.INFINITY, | |
| 393 this.minHeight: 0.0, | |
| 394 this.maxHeight: double.INFINITY}); | |
| 395 | |
| 396 final double minWidth; | |
| 397 final double maxWidth; | |
| 398 final double minHeight; | |
| 399 final double maxHeight; | |
| 400 } | |
| 401 | |
| 394 class BoxDimensions { | 402 class BoxDimensions { |
| 395 const BoxDimensions({this.width, this.height}); | 403 const BoxDimensions({this.width, this.height}); |
| 404 | |
| 405 BoxDimensions.withConstraints( | |
| 406 BoxConstraints constraints, {double width, double height}) { | |
|
abarth-chromium
2015/05/21 02:43:58
width and height should have default values of 0.0
| |
| 407 this.width = clamp(min: minWidth, max: maxWidth, value: width); | |
| 408 this.height = clamp(min: minHeight, max: maxHeight, value: height); | |
| 409 } | |
| 410 | |
| 396 final double width; | 411 final double width; |
| 397 final double height; | 412 final double height; |
| 398 } | 413 } |
| 399 | 414 |
| 400 class BoxParentData extends ParentData { | 415 class BoxParentData extends ParentData { |
| 401 double x = 0.0; | 416 double x = 0.0; |
| 402 double y = 0.0; | 417 double y = 0.0; |
| 403 } | 418 } |
| 404 | 419 |
| 405 abstract class RenderBox extends RenderNode { | 420 abstract class RenderBox extends RenderNode { |
| 406 | 421 |
| 407 void setParentData(RenderNode child) { | 422 void setParentData(RenderNode child) { |
| 408 if (child.parentData is! BoxParentData) | 423 if (child.parentData is! BoxParentData) |
| 409 child.parentData = new BoxParentData(); | 424 child.parentData = new BoxParentData(); |
| 410 } | 425 } |
| 411 | 426 |
| 412 // override this to report what dimensions you would have if you | 427 // override this to report what dimensions you would have if you |
| 413 // were laid out with the given constraints this can walk the tree | 428 // were laid out with the given constraints this can walk the tree |
| 414 // if it must, but it should be as cheap as possible; just get the | 429 // if it must, but it should be as cheap as possible; just get the |
| 415 // dimensions and nothing else (e.g. don't calculate hypothetical | 430 // dimensions and nothing else (e.g. don't calculate hypothetical |
| 416 // child positions if they're not needed to determine dimensions) | 431 // child positions if they're not needed to determine dimensions) |
| 417 BoxDimensions getIntrinsicDimensions({ | 432 BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) { |
| 418 double minWidth: 0.0, | 433 return new BoxDimensions.withConstraints(constraints); |
| 419 double maxWidth: double.INFINITY, | |
| 420 double minHeight: 0.0, | |
| 421 double maxHeight: double.INFINITY | |
| 422 }) { | |
| 423 return new BoxDimensions( | |
| 424 width: clamp(min: minWidth, max: maxWidth), | |
| 425 height: clamp(min: minHeight, max: maxHeight) | |
| 426 ); | |
| 427 } | 434 } |
| 428 | 435 |
| 429 void layout({ | 436 void layout(BoxConstraints constraints, { RenderNode relayoutSubtreeRoot }) { |
| 430 double minWidth: 0.0, | 437 width = clamp(min: constraints.minWidth, max: constraints.maxWidth); |
| 431 double maxWidth: double.INFINITY, | 438 height = clamp(min: constraints.minHeight, max: constraints.maxHeight); |
| 432 double minHeight: 0.0, | |
| 433 double maxHeight: double.INFINITY, | |
| 434 RenderNode relayoutSubtreeRoot | |
| 435 }) { | |
| 436 width = clamp(min: minWidth, max: maxWidth); | |
| 437 height = clamp(min: minHeight, max: maxHeight); | |
| 438 layoutDone(); | 439 layoutDone(); |
| 439 } | 440 } |
| 440 | 441 |
| 441 double width; | 442 double width; |
| 442 double height; | 443 double height; |
| 443 | 444 |
| 444 void rotate({ | 445 void rotate({ |
| 445 int oldAngle, // 0..3 | 446 int oldAngle, // 0..3 |
| 446 int newAngle, // 0..3 | 447 int newAngle, // 0..3 |
| 447 Duration time | 448 Duration time |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 } | 494 } |
| 494 if ((newWidth != width) || (newHeight != height)) { | 495 if ((newWidth != width) || (newHeight != height)) { |
| 495 _width = newWidth; | 496 _width = newWidth; |
| 496 _height = newHeight; | 497 _height = newHeight; |
| 497 relayout(); | 498 relayout(); |
| 498 } | 499 } |
| 499 } | 500 } |
| 500 | 501 |
| 501 void relayout() { | 502 void relayout() { |
| 502 assert(root != null); | 503 assert(root != null); |
| 503 root.layout( | 504 root.layout(new BoxConstraints( |
| 504 minWidth: width, | 505 minWidth: width, maxWidth: width, minHeight: height, maxHeight: height)) ; |
| 505 maxWidth: width, | |
| 506 minHeight: height, | |
| 507 maxHeight: height | |
| 508 ); | |
| 509 assert(root.width == width); | 506 assert(root.width == width); |
| 510 assert(root.height == height); | 507 assert(root.height == height); |
| 511 } | 508 } |
| 512 | 509 |
| 513 void rotate({ int oldAngle, int newAngle, Duration time }) { | 510 void rotate({ int oldAngle, int newAngle, Duration time }) { |
| 514 assert(false); // nobody tells the screen to rotate, the whole rotate() danc e is started from our layout() | 511 assert(false); // nobody tells the screen to rotate, the whole rotate() danc e is started from our layout() |
| 515 } | 512 } |
| 516 | 513 |
| 517 void paint(RenderNodeDisplayList canvas) { | 514 void paint(RenderNodeDisplayList canvas) { |
| 518 canvas.paintChild(root, 0.0, 0.0); | 515 canvas.paintChild(root, 0.0, 0.0); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 538 final double top; | 535 final double top; |
| 539 final double right; | 536 final double right; |
| 540 final double bottom; | 537 final double bottom; |
| 541 final double left; | 538 final double left; |
| 542 operator ==(EdgeDims other) => (top == other.top) || | 539 operator ==(EdgeDims other) => (top == other.top) || |
| 543 (right == other.right) || | 540 (right == other.right) || |
| 544 (bottom == other.bottom) || | 541 (bottom == other.bottom) || |
| 545 (left == other.left); | 542 (left == other.left); |
| 546 } | 543 } |
| 547 | 544 |
| 545 class BoxDecoration { | |
| 546 BoxDecoration({ | |
| 547 this.backgroundColor | |
| 548 }); | |
| 549 | |
| 550 final int backgroundColor; | |
| 551 } | |
| 552 | |
| 553 class RenderDecoratedBox extends RenderBox { | |
| 554 BoxDecoration decoration; | |
| 555 | |
| 556 RenderDecoratedBox(this.decoration); | |
| 557 | |
| 558 void paint(RenderNodeDisplayList canvas) { | |
| 559 assert(width != null); | |
| 560 assert(height != null); | |
| 561 | |
| 562 if (decoration == null) | |
| 563 return; | |
| 564 | |
| 565 if (decoration.backgroundColor != null) { | |
| 566 sky.Paint paint = new sky.Paint()..color = decoration.backgroundColor; | |
| 567 canvas.drawRect(new sky.Rect()..setLTRB(0.0, 0.0, width, height), paint); | |
| 568 } | |
| 569 } | |
| 570 } | |
| 571 | |
| 548 class BlockParentData extends BoxParentData with ContainerParentDataMixin<Render Box> { } | 572 class BlockParentData extends BoxParentData with ContainerParentDataMixin<Render Box> { } |
| 549 | 573 |
| 550 class RenderBlock extends RenderBox with ContainerRenderNodeMixin<RenderBox, Blo ckParentData> { | 574 class RenderBlock extends RenderDecoratedBox with ContainerRenderNodeMixin<Rende rBox, BlockParentData> { |
| 551 // lays out RenderBox children in a vertical stack | 575 // lays out RenderBox children in a vertical stack |
| 552 // uses the maximum width provided by the parent | 576 // uses the maximum width provided by the parent |
| 553 // sizes itself to the height of its child stack | 577 // sizes itself to the height of its child stack |
| 554 | 578 |
| 555 RenderBlock({ | 579 RenderBlock({ |
| 580 BoxDecoration decoration, | |
| 556 EdgeDims padding: const EdgeDims(0.0, 0.0, 0.0, 0.0) | 581 EdgeDims padding: const EdgeDims(0.0, 0.0, 0.0, 0.0) |
| 557 }) { | 582 }) : super(decoration) { |
| 558 _padding = padding; | 583 _padding = padding; |
| 559 } | 584 } |
| 560 | 585 |
| 561 EdgeDims _padding; | 586 EdgeDims _padding; |
| 562 EdgeDims get padding => _padding; | 587 EdgeDims get padding => _padding; |
| 563 void set padding(EdgeDims value) { | 588 void set padding(EdgeDims value) { |
| 564 assert(value != null); | 589 assert(value != null); |
| 565 if (_padding != value) { | 590 if (_padding != value) { |
| 566 _padding = value; | 591 _padding = value; |
| 567 markNeedsLayout(); | 592 markNeedsLayout(); |
| 568 } | 593 } |
| 569 } | 594 } |
| 570 | 595 |
| 571 void setParentData(RenderBox child) { | 596 void setParentData(RenderBox child) { |
| 572 if (child.parentData is! BlockParentData) | 597 if (child.parentData is! BlockParentData) |
| 573 child.parentData = new BlockParentData(); | 598 child.parentData = new BlockParentData(); |
| 574 } | 599 } |
| 575 | 600 |
| 576 // override this to report what dimensions you would have if you | 601 // override this to report what dimensions you would have if you |
| 577 // were laid out with the given constraints this can walk the tree | 602 // were laid out with the given constraints this can walk the tree |
| 578 // if it must, but it should be as cheap as possible; just get the | 603 // if it must, but it should be as cheap as possible; just get the |
| 579 // dimensions and nothing else (e.g. don't calculate hypothetical | 604 // dimensions and nothing else (e.g. don't calculate hypothetical |
| 580 // child positions if they're not needed to determine dimensions) | 605 // child positions if they're not needed to determine dimensions) |
| 581 BoxDimensions getIntrinsicDimensions({ | 606 BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) { |
| 582 double minWidth: 0.0, | |
| 583 double maxWidth: double.INFINITY, | |
| 584 double minHeight: 0.0, | |
| 585 double maxHeight: double.INFINITY | |
| 586 }) { | |
| 587 double outerHeight = _padding.top + _padding.bottom; | 607 double outerHeight = _padding.top + _padding.bottom; |
| 588 double outerWidth = clamp(min: minWidth, max: maxWidth); | 608 double outerWidth = clamp(min: constraints.minWidth, |
| 609 max: constraints.maxWidth); | |
| 589 double innerWidth = outerWidth - (_padding.left + _padding.right); | 610 double innerWidth = outerWidth - (_padding.left + _padding.right); |
| 590 RenderBox child = _firstChild; | 611 RenderBox child = _firstChild; |
| 612 BoxConstraints constraints = new BoxConstraints(minWidth: innerWidth, | |
| 613 maxWidth: innerWidth); | |
| 591 while (child != null) { | 614 while (child != null) { |
| 592 outerHeight += child.getIntrinsicDimensions(minWidth: innerWidth, maxWidth : innerWidth).height; | 615 outerHeight += child.getIntrinsicDimensions(constraints).height; |
| 593 assert(child.parentData is BlockParentData); | 616 assert(child.parentData is BlockParentData); |
| 594 child = child.parentData.nextSibling; | 617 child = child.parentData.nextSibling; |
| 595 } | 618 } |
| 619 | |
| 596 return new BoxDimensions( | 620 return new BoxDimensions( |
| 597 width: outerWidth, | 621 width: outerWidth, |
| 598 height: clamp(min: minHeight, max: maxHeight, value: outerHeight) | 622 height: clamp(min: constraints.minHeight, |
| 623 max: constraints.maxHeight, | |
| 624 value: outerHeight) | |
| 599 ); | 625 ); |
| 600 } | 626 } |
| 601 | 627 |
| 602 double _minHeight; // value cached from parent for relayout call | 628 double _minHeight; // value cached from parent for relayout call |
| 603 double _maxHeight; // value cached from parent for relayout call | 629 double _maxHeight; // value cached from parent for relayout call |
| 604 void layout({ | 630 void layout(BoxConstraints constraints, { RenderNode relayoutSubtreeRoot }) { |
| 605 double minWidth: 0.0, | |
| 606 double maxWidth: double.INFINITY, | |
| 607 double minHeight: 0.0, | |
| 608 double maxHeight: double.INFINITY, | |
| 609 RenderNode relayoutSubtreeRoot | |
| 610 }) { | |
| 611 if (relayoutSubtreeRoot != null) | 631 if (relayoutSubtreeRoot != null) |
| 612 saveRelayoutSubtreeRoot(relayoutSubtreeRoot); | 632 saveRelayoutSubtreeRoot(relayoutSubtreeRoot); |
| 613 relayoutSubtreeRoot = relayoutSubtreeRoot == null ? this : relayoutSubtreeRo ot; | 633 relayoutSubtreeRoot = relayoutSubtreeRoot == null ? this : relayoutSubtreeRo ot; |
| 614 width = clamp(min: minWidth, max: maxWidth); | 634 width = clamp(min: constraints.minWidth, max: constraints.maxWidth); |
| 615 _minHeight = minHeight; | 635 _minHeight = constraints.minHeight; |
| 616 _maxHeight = maxHeight; | 636 _maxHeight = constraints.maxHeight; |
| 617 internalLayout(relayoutSubtreeRoot); | 637 internalLayout(relayoutSubtreeRoot); |
| 618 } | 638 } |
| 619 | 639 |
| 620 void relayout() { | 640 void relayout() { |
| 621 internalLayout(this); | 641 internalLayout(this); |
| 622 } | 642 } |
| 623 | 643 |
| 624 void internalLayout(RenderNode relayoutSubtreeRoot) { | 644 void internalLayout(RenderNode relayoutSubtreeRoot) { |
| 625 assert(_minHeight != null); | 645 assert(_minHeight != null); |
| 626 assert(_maxHeight != null); | 646 assert(_maxHeight != null); |
| 627 double y = _padding.top; | 647 double y = _padding.top; |
| 628 double innerWidth = width - (_padding.left + _padding.right); | 648 double innerWidth = width - (_padding.left + _padding.right); |
| 629 RenderBox child = _firstChild; | 649 RenderBox child = _firstChild; |
| 630 while (child != null) { | 650 while (child != null) { |
| 631 child.layout(minWidth: innerWidth, maxWidth: innerWidth, relayoutSubtreeRo ot: relayoutSubtreeRoot); | 651 child.layout(new BoxConstraints(minWidth: innerWidth, maxWidth: innerWidth ), |
| 652 relayoutSubtreeRoot: relayoutSubtreeRoot); | |
| 632 assert(child.parentData is BlockParentData); | 653 assert(child.parentData is BlockParentData); |
| 633 child.parentData.x = 0.0; | 654 child.parentData.x = 0.0; |
| 634 child.parentData.y = y; | 655 child.parentData.y = y; |
| 635 y += child.height; | 656 y += child.height; |
| 636 child = child.parentData.nextSibling; | 657 child = child.parentData.nextSibling; |
| 637 } | 658 } |
| 638 height = clamp(min: _minHeight, value: y + _padding.bottom, max: _maxHeight) ; | 659 height = clamp(min: _minHeight, value: y + _padding.bottom, max: _maxHeight) ; |
| 639 layoutDone(); | 660 layoutDone(); |
| 640 } | 661 } |
| 641 | 662 |
| 642 void handlePointer(sky.PointerEvent event, { double x: 0.0, double y: 0.0 }) { | 663 void handlePointer(sky.PointerEvent event, { double x: 0.0, double y: 0.0 }) { |
| 643 // the x, y parameters have the top left of the node's box as the origin | 664 // the x, y parameters have the top left of the node's box as the origin |
| 644 RenderBox child = _lastChild; | 665 RenderBox child = _lastChild; |
| 645 while (child != null) { | 666 while (child != null) { |
| 646 assert(child.parentData is BlockParentData); | 667 assert(child.parentData is BlockParentData); |
| 647 if ((x >= child.parentData.x) && (x < child.parentData.x + child.width) && | 668 if ((x >= child.parentData.x) && (x < child.parentData.x + child.width) && |
| 648 (y >= child.parentData.y) && (y < child.parentData.y + child.height)) { | 669 (y >= child.parentData.y) && (y < child.parentData.y + child.height)) { |
| 649 child.handlePointer(event, x: x-child.parentData.x, y: y-child.parentDat a.y); | 670 child.handlePointer(event, x: x-child.parentData.x, y: y-child.parentDat a.y); |
| 650 break; | 671 break; |
| 651 } | 672 } |
| 652 child = child.parentData.previousSibling; | 673 child = child.parentData.previousSibling; |
| 653 } | 674 } |
| 654 super.handlePointer(event); | 675 super.handlePointer(event); |
| 655 } | 676 } |
| 656 | 677 |
| 657 void paint(RenderNodeDisplayList canvas) { | 678 void paint(RenderNodeDisplayList canvas) { |
| 679 super.paint(canvas); | |
| 658 RenderBox child = _firstChild; | 680 RenderBox child = _firstChild; |
| 659 while (child != null) { | 681 while (child != null) { |
| 660 assert(child.parentData is BlockParentData); | 682 assert(child.parentData is BlockParentData); |
| 661 canvas.paintChild(child, child.parentData.x, child.parentData.y); | 683 canvas.paintChild(child, child.parentData.x, child.parentData.y); |
| 662 child = child.parentData.nextSibling; | 684 child = child.parentData.nextSibling; |
| 663 } | 685 } |
| 664 } | 686 } |
| 665 | 687 |
| 666 } | 688 } |
| 667 | 689 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 687 | 709 |
| 688 ScaffoldBox(this.toolbar, this.body, this.statusbar, this.drawer) { | 710 ScaffoldBox(this.toolbar, this.body, this.statusbar, this.drawer) { |
| 689 assert(body != null); | 711 assert(body != null); |
| 690 } | 712 } |
| 691 | 713 |
| 692 final RenderBox toolbar; | 714 final RenderBox toolbar; |
| 693 final RenderBox body; | 715 final RenderBox body; |
| 694 final RenderBox statusbar; | 716 final RenderBox statusbar; |
| 695 final RenderBox drawer; | 717 final RenderBox drawer; |
| 696 | 718 |
| 697 void layout({ | 719 void layout(BoxConstraints constraints, { RenderNode relayoutSubtreeRoot }) { |
| 698 double minWidth: 0.0, | 720 width = clamp(min: constraints.minWidth, max: constraints.maxWidth); |
| 699 double maxWidth: double.INFINITY, | 721 height = clamp(min: constraints.minHeight, max: constraints.maxHeight); |
| 700 double minHeight: 0.0, | |
| 701 double maxHeight: double.INFINITY, | |
| 702 RenderNode relayoutSubtreeRoot | |
| 703 }) { | |
| 704 width = clamp(min: minWidth, max: maxWidth); | |
| 705 height = clamp(min: minHeight, max: maxHeight); | |
| 706 relayout(); | 722 relayout(); |
| 707 } | 723 } |
| 708 | 724 |
| 709 static const kToolbarHeight = 100.0; | 725 static const kToolbarHeight = 100.0; |
| 710 static const kStatusbarHeight = 50.0; | 726 static const kStatusbarHeight = 50.0; |
| 711 | 727 |
| 712 void relayout() { | 728 void relayout() { |
| 713 double bodyHeight = height; | 729 double bodyHeight = height; |
| 714 if (toolbar != null) { | 730 if (toolbar != null) { |
| 715 toolbar.layout(minWidth: width, maxWidth: width, minHeight: kToolbarHeight , maxHeight: kToolbarHeight); | 731 toolbar.layout(new BoxConstraints(minWidth: width, maxWidth: width, minHei ght: kToolbarHeight, maxHeight: kToolbarHeight)); |
| 716 assert(toolbar.parentData is BoxParentData); | 732 assert(toolbar.parentData is BoxParentData); |
| 717 toolbar.parentData.x = 0.0; | 733 toolbar.parentData.x = 0.0; |
| 718 toolbar.parentData.y = 0.0; | 734 toolbar.parentData.y = 0.0; |
| 719 bodyHeight -= kToolbarHeight; | 735 bodyHeight -= kToolbarHeight; |
| 720 } | 736 } |
| 721 if (statusbar != null) { | 737 if (statusbar != null) { |
| 722 statusbar.layout(minWidth: width, maxWidth: width, minHeight: kStatusbarHe ight, maxHeight: kStatusbarHeight); | 738 statusbar.layout(new BoxConstraints(minWidth: width, maxWidth: width, minH eight: kStatusbarHeight, maxHeight: kStatusbarHeight)); |
| 723 assert(statusbar.parentData is BoxParentData); | 739 assert(statusbar.parentData is BoxParentData); |
| 724 statusbar.parentData.x = 0.0; | 740 statusbar.parentData.x = 0.0; |
| 725 statusbar.parentData.y = height - kStatusbarHeight; | 741 statusbar.parentData.y = height - kStatusbarHeight; |
| 726 bodyHeight -= kStatusbarHeight; | 742 bodyHeight -= kStatusbarHeight; |
| 727 } | 743 } |
| 728 body.layout(minWidth: width, maxWidth: width, minHeight: bodyHeight, maxHeig ht: bodyHeight); | 744 body.layout(new BoxConstraints(minWidth: width, maxWidth: width, minHeight: bodyHeight, maxHeight: bodyHeight)); |
| 729 if (drawer != null) | 745 if (drawer != null) |
| 730 drawer.layout(minWidth: 0.0, maxWidth: width, minHeight: height, maxHeight : height); | 746 drawer.layout(new BoxConstraints(minWidth: 0.0, maxWidth: width, minHeight : height, maxHeight: height)); |
| 731 layoutDone(); | 747 layoutDone(); |
| 732 } | 748 } |
| 733 | 749 |
| 734 void handlePointer(sky.PointerEvent event, { double x: 0.0, double y: 0.0 }) { | 750 void handlePointer(sky.PointerEvent event, { double x: 0.0, double y: 0.0 }) { |
| 735 if ((drawer != null) && (x < drawer.width)) { | 751 if ((drawer != null) && (x < drawer.width)) { |
| 736 drawer.handlePointer(event, x: x, y: y); | 752 drawer.handlePointer(event, x: x, y: y); |
| 737 } else if ((toolbar != null) && (y < toolbar.height)) { | 753 } else if ((toolbar != null) && (y < toolbar.height)) { |
| 738 toolbar.handlePointer(event, x: x, y: y); | 754 toolbar.handlePointer(event, x: x, y: y); |
| 739 } else if ((statusbar != null) && (y > (statusbar.parentData as BoxParentDat a).y)) { | 755 } else if ((statusbar != null) && (y > (statusbar.parentData as BoxParentDat a).y)) { |
| 740 statusbar.handlePointer(event, x: x, y: y-(statusbar.parentData as BoxPare ntData).y); | 756 statusbar.handlePointer(event, x: x, y: y-(statusbar.parentData as BoxPare ntData).y); |
| 741 } else { | 757 } else { |
| 742 body.handlePointer(event, x: x, y: y-(body.parentData as BoxParentData).y) ; | 758 body.handlePointer(event, x: x, y: y-(body.parentData as BoxParentData).y) ; |
| 743 } | 759 } |
| 744 super.handlePointer(event, x: x, y: y); | 760 super.handlePointer(event, x: x, y: y); |
| 745 } | 761 } |
| 746 | 762 |
| 747 void paint(RenderNodeDisplayList canvas) { | 763 void paint(RenderNodeDisplayList canvas) { |
| 748 canvas.paintChild(body, (body.parentData as BoxParentData).x, (body.parentDa ta as BoxParentData).y); | 764 canvas.paintChild(body, (body.parentData as BoxParentData).x, (body.parentDa ta as BoxParentData).y); |
| 749 if (statusbar != null) | 765 if (statusbar != null) |
| 750 canvas.paintChild(statusbar, (statusbar.parentData as BoxParentData).x, (s tatusbar.parentData as BoxParentData).y); | 766 canvas.paintChild(statusbar, (statusbar.parentData as BoxParentData).x, (s tatusbar.parentData as BoxParentData).y); |
| 751 if (toolbar != null) | 767 if (toolbar != null) |
| 752 canvas.paintChild(toolbar, (toolbar.parentData as BoxParentData).x, (toolb ar.parentData as BoxParentData).y); | 768 canvas.paintChild(toolbar, (toolbar.parentData as BoxParentData).x, (toolb ar.parentData as BoxParentData).y); |
| 753 if (drawer != null) | 769 if (drawer != null) |
| 754 canvas.paintChild(drawer, (drawer.parentData as BoxParentData).x, (drawer. parentData as BoxParentData).y); | 770 canvas.paintChild(drawer, (drawer.parentData as BoxParentData).x, (drawer. parentData as BoxParentData).y); |
| 755 } | 771 } |
| 756 | 772 |
| 757 } | 773 } |
| OLD | NEW |