Split Size into Size and Offset.

Added a OffsetBase class that Size now inherits from, and added a new
Offset class that also inherits from OffsetBase.

Offset has:
 - dx and dy members
 - zero and infinite static constants
 - a method that returns a new Offset that's the existing one scaled
   by a scalar
 - a unary minus operator
 - operators overloads such that subtracting or adding two Offsets
   gives another Offset
 - a toPoint() method

Added Offset and Size to the dart bindings, so they can be used from C++.

Changed the Canvas API to use Point, Size, and Offset where appropriate:
 - drawLine uses Points now
 - drawCircle uses a Point now
 - drawImage uses a Paint now
 - the constructor uses a Size

Changed Point as follows:
 - added a unary minus
 - Point difference now gives an Offset rather than a Size
 - You can add an Offset to a Point to get a new Point
 - toSize() has been replaced by toOffset()

Changed Rect as follows:
 - renamed upperLeft and lowerRight to topLeft and bottomRight for
   consistency with our other APIs
 - added bottomLeft and topRight for completeness

Changed Size as follows:
 - now inherits from OffsetBase
 - added *, /, ~/, and % operators for scaling sizes
 - subtracting a Size from a Size gives an Offset
 - subtracting an Offset from a Size gives a Size
 - changed the + operator to take an Offset instead of a Size
 - added topLeft, bottomLeft, topRight, bottomRight to match Rect
 - added center for the same reason
 - added shortestSide getter since that was a common pattern
 - removed toPoint()

Changed DrawLooperLayerInfo as follows:
 - setOffset member takes an Offset instead of a Point

Changed BoxConstraints as follows:
 - added biggest getter since it was a common pattern
 - added smallest getter for symmetry

Changed BoxShadow as follows:
 - offset member is an Offset rather than a Size

Changed ViewConstraints as follows:
 - replaced height and width members by a single size member

I did some minor code cleanup in nearby files while I was there,
including sorting sky/engine/core/core.gni alphabetically, and fixing
some warnings in the examples.

BUG=
R=abarth@chromium.org, chinmaygarde@google.com

Review URL: https://codereview.chromium.org/1214833004.
This commit is contained in:
Hixie 2015-06-26 15:21:29 -07:00
parent 9adb7943f3
commit 952dbc73e4
2 changed files with 3 additions and 3 deletions

View File

@ -44,7 +44,7 @@ PAINT FOR FRAME #2 ----------------------------------------------
2 | | | | | | | | TestRenderCanvas() constructor: 800.0 x 600.0
2 | | | paintChild RenderDecoratedBox at Point(728.0, 528.0)
2 | | | | TestRenderCanvas() constructor: 800.0 x 600.0
2 | | | | drawCircle(28.0, 28.0, 28.0, Paint(color:Color(0xffff5252), drawLooper:true))
2 | | | | drawCircle(Point(28.0, 28.0), 28.0, Paint(color:Color(0xffff5252), drawLooper:true))
2 | | | | saveLayer(Rect.fromLTRB(0.0, 0.0, 56.0, 56.0), Paint(color:Color(0xff000000)))
2 | | | | clipPath(Instance of 'Path')
2 | | | | paintChild RenderImage at Point(16.0, 16.0)
@ -92,7 +92,7 @@ PAINT FOR FRAME #3 ----------------------------------------------
3 | | | | | | | | TestRenderCanvas() constructor: 800.0 x 600.0
3 | | | paintChild RenderDecoratedBox at Point(728.0, 528.0)
3 | | | | TestRenderCanvas() constructor: 800.0 x 600.0
3 | | | | drawCircle(28.0, 28.0, 28.0, Paint(color:Color(0xffff5252), drawLooper:true))
3 | | | | drawCircle(Point(28.0, 28.0), 28.0, Paint(color:Color(0xffff5252), drawLooper:true))
3 | | | | saveLayer(Rect.fromLTRB(0.0, 0.0, 56.0, 56.0), Paint(color:Color(0xff000000)))
3 | | | | clipPath(Instance of 'Path')
3 | | | | paintChild RenderImage at Point(16.0, 16.0)

View File

@ -40,7 +40,7 @@ PAINT FOR FRAME #4 ----------------------------------------------
4 | | TestRenderCanvas() constructor: 800.0 x 600.0
4 | | paintChild RenderDecoratedBox at Point(372.0, 272.0)
4 | | | TestRenderCanvas() constructor: 800.0 x 600.0
4 | | | drawCircle(28.0, 28.0, 28.0, Paint(color:Color(0xffff4081), drawLooper:true))
4 | | | drawCircle(Point(28.0, 28.0), 28.0, Paint(color:Color(0xffff4081), drawLooper:true))
4 | | | saveLayer(Rect.fromLTRB(0.0, 0.0, 56.0, 56.0), Paint(color:Color(0xff000000)))
4 | | | clipPath(Instance of 'Path')
4 | | | paintChild RenderParagraph at Point(22.0, 20.0)