Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1447)

Unified Diff: sky/specs/style.md

Issue 725203007: Specs: make sure all layout/paint/hitTest APIs are relative to the right coordinate space (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/examples/style/toolbar-layout.sky ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/specs/style.md
diff --git a/sky/specs/style.md b/sky/specs/style.md
index 2f87160174b54a275d6fed23095fa5c141d84490..c3d6c8c4ea521cd892312d1387e332fa3e103603 100644
--- a/sky/specs/style.md
+++ b/sky/specs/style.md
@@ -345,8 +345,8 @@ node's layoutManager and ownerLayoutManager attributes to null.
readonly attribute Boolean needsPaint; // means that either needsLayout is true or a property with needsPaint:true has changed on this node or one of its descendants
// only the ownerLayoutManager can change these
- readonly attribute Float x;
- readonly attribute Float y;
+ readonly attribute Float x; // relative to left edge of ownerLayoutManager
+ readonly attribute Float y; // relative to top edge of ownerLayoutManager
readonly attribute Float width;
readonly attribute Float height;
}
@@ -436,13 +436,14 @@ Layout managers inherit from the following API:
// TODO(ianh): should we just grab the width and height from assumeDimensions()?
void paint(RenderingSurface canvas);
- // set a clip rect on the canvas
+ // set a clip rect on the canvas for rect(0,0,this.width,this.height)
// call the painter of each property, in order they were registered, which on this element has a painter
// call this.paintChildren()
// unset the clip
virtual void paintChildren(RenderingSurface canvas);
- // just calls paint() for each child returned by walkChildren() whose needsPaint is true
+ // just calls paint() for each child returned by walkChildren() whose needsPaint is true,
+ // after transforming the coordinate space by translate(child.x,child.y)
virtual Node hitTest(Float x, Float y);
// default implementation uses the node's children nodes' x, y,
@@ -453,6 +454,7 @@ Layout managers inherit from the following API:
// override this if you changed your children's z-order, or if you used take() to
// hoist some descendants up to be your responsibility, or if your children aren't
// rectangular (e.g. you lay them out in a hex grid)
+ // make sure to offset the value you pass your children: child.layoutManager.hitTest(x-child.x, y-child.y)
}
@@ -486,6 +488,10 @@ Paint
// ...
}
+The convention is that the layout manager who calls your paint will
+have transformed the coordinate space so that you should assume that
+your top-left pixel is at 0,0.
+
Default Styles
--------------
« no previous file with comments | « sky/examples/style/toolbar-layout.sky ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698