« get me outta code hell

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/presentation/HorizontalBox.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/presentation/HorizontalBox.js')
-rw-r--r--ui/presentation/HorizontalBox.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/ui/presentation/HorizontalBox.js b/ui/presentation/HorizontalBox.js
new file mode 100644
index 0000000..d396ec3
--- /dev/null
+++ b/ui/presentation/HorizontalBox.js
@@ -0,0 +1,13 @@
+import {DisplayElement} from 'tui-lib/ui/primitives'
+
+export default class HorizontalBox extends DisplayElement {
+  // A box that will automatically lay out its children in a horizontal row.
+
+  fixLayout() {
+    let nextX = 0
+    for (const child of this.children) {
+      child.x = nextX
+      nextX = child.right + 1
+    }
+  }
+}