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

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

Issue 980323003: Clean up examples directory (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months 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/shell/sensor.sky ('k') | sky/examples/style/hex-layout.sky » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/style/block-layout.sky
diff --git a/sky/examples/style/block-layout.sky b/sky/examples/style/block-layout.sky
deleted file mode 100644
index 7076685fb39d84466fe44c66871230c542c6be4f..0000000000000000000000000000000000000000
--- a/sky/examples/style/block-layout.sky
+++ /dev/null
@@ -1,78 +0,0 @@
-SKY MODULE
-<import src="sky:core" as="sky"/>
-<!--
- ! this module provides trivial vertical block layout
- ! no margins, padding, borders, etc
- !-->
-<script>
- module.exports.BlockLayoutManager = class BlockLayoutManager extends sky.LayoutManager {
- function layout(width, height) {
- if (width == null)
- width = this.getIntrinsicWidth().value;
- let autoHeight = false;
- if (height == null) {
- height = 0;
- autoHeight = true;
- }
- this.assumeDimensions(width, height);
- let children = this.walkChildren();
- let loop = children.next();
- let y = 0;
- while (!loop.done) {
- let child = loop.value;
- if (child.needsLayout || child.descendantNeedsLayout) {
- let dims = child.layoutManager.layout(width, null);
- this.setChildSize(child, dims.width, dims.height);
- }
- this.setChildPosition(child, 0, y);
- y += child.height;
- loop = children.next();
- }
- if (autoHeight)
- height = y;
- this.markAsLaidOut();
- return {
- width: width,
- height: height,
- }
- }
- function layoutDescendants() {
- this.layout(node.width, node.height);
- }
- function getIntrinsicWidth() {
- let width = this.node.getProperty('width');
- if (typeof width != 'number') {
- // e.g. width: auto
- width = 0;
- let children = this.walkChildren();
- let loop = children.next();
- while (!loop.done) {
- let child = loop.value;
- let childWidth = child.layoutManager.getIntrinsicWidth();
- if (width < childWidth.value)
- width = childWidth.value;
- loop = children.next();
- }
- }
- return super(width); // applies and provides our own min-width/max-width rules
- }
- function getIntrinsicHeight() {
- let height = this.node.getProperty('height');
- if (typeof height != 'number') {
- // e.g. height: auto
- height = 0;
- let children = this.walkChildren();
- let loop = children.next();
- while (!loop.done) {
- let child = loop.value;
- let childHeight = child.layoutManager.getIntrinsicHeight();
- if (height < childHeight.value)
- height = childHeight.value;
- loop = children.next();
- }
- }
- return super(height); // applies and provides our own min-height/max-height rules
- }
- }
- sky.registerLayoutManager('block', module.exports.BlockLayoutManager);
-</script>
« no previous file with comments | « sky/examples/shell/sensor.sky ('k') | sky/examples/style/hex-layout.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698