« get me outta code hell

Initial commit - tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
path: root/ui/HorizontalBox.js
diff options
context:
space:
mode:
authorLiam <towerofnix@gmail.com>2017-01-07 18:26:02 -0400
committerLiam <towerofnix@gmail.com>2017-01-07 18:26:02 -0400
commit16da7fb310198851c2e4b02abedfb24979287242 (patch)
treed7546f7c1a3c3833e6450ea1e10af388f8848bb5 /ui/HorizontalBox.js
Initial commit
Diffstat (limited to 'ui/HorizontalBox.js')
-rw-r--r--ui/HorizontalBox.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/ui/HorizontalBox.js b/ui/HorizontalBox.js
new file mode 100644
index 0000000..fd43f8e
--- /dev/null
+++ b/ui/HorizontalBox.js
@@ -0,0 +1,13 @@
+const DisplayElement = require('./DisplayElement')
+
+module.exports = class HorizontalBox extends DisplayElement {
+  // A box that will automatically lay out its children in a horizontal row.
+
+  fixLayout() {
+    let nextX = 0
+    for (let child of this.children) {
+      child.x = nextX
+      nextX = child.right + 1
+    }
+  }
+}