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 '../painting/box_painter.dart'; | 9 import '../painting/box_painter.dart'; |
10 import 'package:vector_math/vector_math.dart'; | 10 import 'package:vector_math/vector_math.dart'; |
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 void performLayout() { | 804 void performLayout() { |
805 Size oldSize = size; | 805 Size oldSize = size; |
806 | 806 |
807 super.performLayout(); | 807 super.performLayout(); |
808 | 808 |
809 if (oldSize != size) | 809 if (oldSize != size) |
810 callback(size); | 810 callback(size); |
811 } | 811 } |
812 } | 812 } |
813 | 813 |
814 typedef void CustomPaintCallback(sky.Canvas canvas); | 814 typedef void CustomPaintCallback(sky.Canvas canvas, Size size); |
815 | 815 |
816 class RenderCustomPaint extends RenderProxyBox { | 816 class RenderCustomPaint extends RenderProxyBox { |
817 | 817 |
818 RenderCustomPaint({ | 818 RenderCustomPaint({ |
819 CustomPaintCallback callback, | 819 CustomPaintCallback callback, |
820 RenderBox child | 820 RenderBox child |
821 }) : super(child) { | 821 }) : super(child) { |
822 assert(callback != null); | 822 assert(callback != null); |
823 _callback = callback; | 823 _callback = callback; |
824 } | 824 } |
825 | 825 |
826 CustomPaintCallback _callback; | 826 CustomPaintCallback _callback; |
827 void set callback (CustomPaintCallback value) { | 827 void set callback (CustomPaintCallback value) { |
828 assert(value != null || !attached); | 828 assert(value != null || !attached); |
829 if (_callback == value) | 829 if (_callback == value) |
830 return; | 830 return; |
831 _callback = value; | 831 _callback = value; |
832 markNeedsPaint(); | 832 markNeedsPaint(); |
833 } | 833 } |
834 | 834 |
835 void attach() { | 835 void attach() { |
836 assert(_callback != null); | 836 assert(_callback != null); |
837 super.attach(); | 837 super.attach(); |
838 } | 838 } |
839 | 839 |
840 void paint(RenderObjectDisplayList canvas) { | 840 void paint(RenderObjectDisplayList canvas) { |
841 assert(_callback != null); | 841 assert(_callback != null); |
842 _callback(canvas); | 842 _callback(canvas, size); |
843 super.paint(canvas); | 843 super.paint(canvas); |
844 } | 844 } |
845 } | 845 } |
846 | 846 |
847 // RENDER VIEW LAYOUT MANAGER | 847 // RENDER VIEW LAYOUT MANAGER |
848 | 848 |
849 class ViewConstraints { | 849 class ViewConstraints { |
850 | 850 |
851 const ViewConstraints({ | 851 const ViewConstraints({ |
852 this.width: 0.0, this.height: 0.0, this.orientation: null | 852 this.width: 0.0, this.height: 0.0, this.orientation: null |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 | 950 |
951 void defaultPaint(RenderObjectDisplayList canvas) { | 951 void defaultPaint(RenderObjectDisplayList canvas) { |
952 RenderBox child = firstChild; | 952 RenderBox child = firstChild; |
953 while (child != null) { | 953 while (child != null) { |
954 assert(child.parentData is ParentDataType); | 954 assert(child.parentData is ParentDataType); |
955 canvas.paintChild(child, child.parentData.position); | 955 canvas.paintChild(child, child.parentData.position); |
956 child = child.parentData.nextSibling; | 956 child = child.parentData.nextSibling; |
957 } | 957 } |
958 } | 958 } |
959 } | 959 } |
OLD | NEW |