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

Unified Diff: sky/examples/style/hex-layout.sky

Issue 745863002: Specs: update the layout and paint schemes to match discussions better (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/block-layout.sky ('k') | sky/examples/style/toolbar-layout.sky » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/style/hex-layout.sky
diff --git a/sky/examples/style/hex-layout.sky b/sky/examples/style/hex-layout.sky
index 139e5b4905994c6d6f0d20b601c3e09a50065d10..2633c0f38c8c9a75c9c4bb8db76c9bd5d428312c 100644
--- a/sky/examples/style/hex-layout.sky
+++ b/sky/examples/style/hex-layout.sky
@@ -20,7 +20,7 @@
let y = 0;
while (!loop.done) {
let child = loop.value;
- if (child.needsLayout) {
+ if (child.needsLayout || child.descendantNeedsLayout) {
child.layoutManager.layout(cellDim, cellDim);
// we ignore the size the child reported from layout(), and force it to the cell dimensions
this.setChildSize(child, cellDim, cellDim);
@@ -40,30 +40,6 @@
height: height,
}
}
- function getIntrinsicWidth() {
- // this is the logic that LayoutManager.getIntrinsicWidth() has by default
- // shown here because I wrote it before realising it should be the default
- let width = this.node.getProperty('width');
- if (typeof width != 'number')
- width = 0;
- let minWidth = this.node.getProperty('min-width');
- if (typeof width != 'number')
- minWidth = 0;
- let maxWidth = this.node.getProperty('max-width');
- if (typeof width != 'number')
- maxWidth = Infinity;
- if (maxWidth < minWidth)
- maxWidth = minWidth;
- if (width > maxWidth)
- width = maxWidth;
- if (width < minWidth)
- width = minWidth;
- return {
- minimum: minWidth,
- value: width,
- maximum: maxWidth,
- };
- }
function getIntrinsicHeight() {
let height = this.node.getProperty('height');
if (typeof height != 'number') {
@@ -93,20 +69,19 @@
let loop = children.next();
while (!loop.done) {
let child = loop.value;
- if (child.needsPaint) {
+ if (child.needsPaint || child.descendantNeedsPaint) {
canvas.save();
try {
canvas.beginPath();
- canvas.translate(child.x, child.y);
- canvas.moveTo(0, cellDim/4);
- canvas.lineTo(cellDim/2, 0);
- canvas.lineTo(cellDim, cellDim/4);
- canvas.lineTo(cellDim, 3*cellDim/4);
- canvas.lineTo(cellDim/2, cellDim);
- canvas.moveTo(0, 3*cellDim/4);
+ canvas.moveTo(child.x, child.y + cellDim/4);
+ canvas.lineTo(child.x + cellDim/2, child.y);
+ canvas.lineTo(child.x + cellDim, child.y + cellDim/4);
+ canvas.lineTo(child.x + cellDim, child.y + 3*cellDim/4);
+ canvas.lineTo(child.x + cellDim/2, child.y + cellDim);
+ canvas.moveTo(child.x, child.y + 3*cellDim/4);
canvas.closePath();
canvas.clip();
- child.paint(canvas);
+ this.paintChild(child);
} finally {
canvas.restore();
}
« no previous file with comments | « sky/examples/style/block-layout.sky ('k') | sky/examples/style/toolbar-layout.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698