| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:math' as math; | 5 import 'dart:math' as math; |
| 6 import 'dart:sky' as sky; | 6 import 'dart:sky' as sky; |
| 7 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
| 8 import 'object.dart'; | 8 import 'object.dart'; |
| 9 import 'package:vector_math/vector_math.dart'; | 9 import 'package:vector_math/vector_math.dart'; |
| 10 import 'package:sky/framework/net/image_cache.dart' as image_cache; | 10 import 'package:sky/framework/net/image_cache.dart' as image_cache; |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 final double blur; | 642 final double blur; |
| 643 | 643 |
| 644 String toString() => 'BoxShadow($color, $offset, $blur)'; | 644 String toString() => 'BoxShadow($color, $offset, $blur)'; |
| 645 } | 645 } |
| 646 | 646 |
| 647 // This must be immutable, because we won't notice when it changes | 647 // This must be immutable, because we won't notice when it changes |
| 648 class BoxDecoration { | 648 class BoxDecoration { |
| 649 const BoxDecoration({ | 649 const BoxDecoration({ |
| 650 this.backgroundColor, | 650 this.backgroundColor, |
| 651 this.border, | 651 this.border, |
| 652 this.borderRadius, |
| 652 this.boxShadow | 653 this.boxShadow |
| 653 }); | 654 }); |
| 654 | 655 |
| 655 final Color backgroundColor; | 656 final Color backgroundColor; |
| 657 final double borderRadius; |
| 656 final Border border; | 658 final Border border; |
| 657 final List<BoxShadow> boxShadow; | 659 final List<BoxShadow> boxShadow; |
| 658 | 660 |
| 659 String toString([String prefix = '']) { | 661 String toString([String prefix = '']) { |
| 660 List<String> result = []; | 662 List<String> result = []; |
| 661 if (backgroundColor != null) | 663 if (backgroundColor != null) |
| 662 result.add('${prefix}backgroundColor: $backgroundColor'); | 664 result.add('${prefix}backgroundColor: $backgroundColor'); |
| 663 if (border != null) | 665 if (border != null) |
| 664 result.add('${prefix}border: $border'); | 666 result.add('${prefix}border: $border'); |
| 665 if (boxShadow != null) { | 667 if (borderRadius != null) |
| 666 for (BoxShadow shadow in boxShadow) | 668 result.add('${prefix}borderRadius: $borderRadius'); |
| 667 result.add('${prefix}boxShadow: $shadow'); | 669 if (boxShadow != null) |
| 668 } | 670 result.add('${prefix}boxShadow: ${boxShadow.map((shadow) => shadow.toStrin
g())}'); |
| 669 if (result.isEmpty) | 671 if (result.isEmpty) |
| 670 return '${prefix}<no decorations specified>'; | 672 return '${prefix}<no decorations specified>'; |
| 671 return result.join('\n'); | 673 return result.join('\n'); |
| 672 } | 674 } |
| 673 } | 675 } |
| 674 | 676 |
| 675 class RenderDecoratedBox extends RenderProxyBox { | 677 class RenderDecoratedBox extends RenderProxyBox { |
| 676 | 678 |
| 677 RenderDecoratedBox({ | 679 RenderDecoratedBox({ |
| 678 BoxDecoration decoration, | 680 BoxDecoration decoration, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 _cachedBackgroundPaint = paint; | 725 _cachedBackgroundPaint = paint; |
| 724 } | 726 } |
| 725 | 727 |
| 726 return _cachedBackgroundPaint; | 728 return _cachedBackgroundPaint; |
| 727 } | 729 } |
| 728 | 730 |
| 729 void paint(RenderObjectDisplayList canvas) { | 731 void paint(RenderObjectDisplayList canvas) { |
| 730 assert(size.width != null); | 732 assert(size.width != null); |
| 731 assert(size.height != null); | 733 assert(size.height != null); |
| 732 | 734 |
| 733 if (_decoration.backgroundColor != null || _decoration.boxShadow != null) | 735 if (_decoration.backgroundColor != null || _decoration.boxShadow != null) { |
| 734 canvas.drawRect(new Rect.fromLTRB(0.0, 0.0, size.width, size.height), _bac
kgroundPaint); | 736 Rect rect = new Rect.fromLTRB(0.0, 0.0, size.width, size.height); |
| 737 if (_decoration.borderRadius == null) |
| 738 canvas.drawRect(rect, _backgroundPaint); |
| 739 else |
| 740 canvas.drawRRect(new sky.RRect()..setRectXY(rect, _decoration.borderRadi
us, _decoration.borderRadius), _backgroundPaint); |
| 741 } |
| 735 | 742 |
| 736 if (_decoration.border != null) { | 743 if (_decoration.border != null) { |
| 744 assert(_decoration.borderRadius == null); // TODO(abarth): Implement borde
rs with border radius. |
| 745 |
| 737 assert(_decoration.border.top != null); | 746 assert(_decoration.border.top != null); |
| 738 assert(_decoration.border.right != null); | 747 assert(_decoration.border.right != null); |
| 739 assert(_decoration.border.bottom != null); | 748 assert(_decoration.border.bottom != null); |
| 740 assert(_decoration.border.left != null); | 749 assert(_decoration.border.left != null); |
| 741 | 750 |
| 742 Paint paint = new Paint(); | 751 Paint paint = new Paint(); |
| 743 Path path; | 752 Path path; |
| 744 | 753 |
| 745 paint.color = _decoration.border.top.color; | 754 paint.color = _decoration.border.top.color; |
| 746 path = new Path(); | 755 path = new Path(); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 | 1018 |
| 1010 void defaultPaint(RenderObjectDisplayList canvas) { | 1019 void defaultPaint(RenderObjectDisplayList canvas) { |
| 1011 RenderBox child = firstChild; | 1020 RenderBox child = firstChild; |
| 1012 while (child != null) { | 1021 while (child != null) { |
| 1013 assert(child.parentData is ParentDataType); | 1022 assert(child.parentData is ParentDataType); |
| 1014 canvas.paintChild(child, child.parentData.position); | 1023 canvas.paintChild(child, child.parentData.position); |
| 1015 child = child.parentData.nextSibling; | 1024 child = child.parentData.nextSibling; |
| 1016 } | 1025 } |
| 1017 } | 1026 } |
| 1018 } | 1027 } |
| OLD | NEW |