aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSan Jacobs2025-09-11 18:25:02 +0200
committerSan Jacobs2025-09-11 18:25:02 +0200
commitfefe11c52d98045f3e9b02580eb3e27819657934 (patch)
tree7823036b76709483f6e81022b786db4953a4dc59 /src
parent87e307d082a3f360981785d9e2f34243c8cfd231 (diff)
downloadtafl-fefe11c52d98045f3e9b02580eb3e27819657934.tar.gz
tafl-fefe11c52d98045f3e9b02580eb3e27819657934.tar.bz2
tafl-fefe11c52d98045f3e9b02580eb3e27819657934.zip
Grow pass seems to work now!
Diffstat (limited to 'src')
-rw-r--r--src/main.odin8
-rw-r--r--src/tafl/tafl.odin34
2 files changed, 25 insertions, 17 deletions
diff --git a/src/main.odin b/src/main.odin
index ce57985..4ff1038 100644
--- a/src/main.odin
+++ b/src/main.odin
@@ -21,7 +21,7 @@ main :: proc() {
sizing_height=t.FIXED(int(height)),
layout=.LEFT_TO_RIGHT,
color={1,.0,.0, 1},
- padding={16,16,16,16},
+ padding={300,300,300,300},
child_gap=30,
)
{ // Blue left bar
@@ -59,11 +59,11 @@ main :: proc() {
{
{t.tafl(color={.5, .5, .5, 1},
- sizing_height=t.FIXED(100),
+ sizing_height=t.FIXED(50),
sizing_width=t.GROW,
)}
{t.tafl(color={.5, .5, .5, 1},
- sizing_height=t.FIXED(100),
+ sizing_height=t.FIXED(50),
sizing_width=t.GROW,
)}
{t.tafl(color={.5, .5, .8, 1},
@@ -71,7 +71,7 @@ main :: proc() {
sizing_width=t.GROW,
)}
{t.tafl(color={.5, .5, .5, 1},
- sizing_height=t.FIXED(100),
+ sizing_height=t.FIXED(50),
sizing_width=t.GROW,
)}
}
diff --git a/src/tafl/tafl.odin b/src/tafl/tafl.odin
index 38beb67..adcb11d 100644
--- a/src/tafl/tafl.odin
+++ b/src/tafl/tafl.odin
@@ -160,19 +160,21 @@ grow_children_width :: proc(parent : ^Tafl) {
for child in children_of(parent) {
remaining_width -= child.width
}
+ remaining_width -= max(parent.children.len - 1, 0) * parent.child_gap
+
+ for child in children_of(parent) {
+ if child.sizing.width.type == .GROW {
+ child.width += remaining_width
+ }
+ }
case .TOP_TO_BOTTOM:
for child in children_of(parent) {
- remaining_width = min(child.width, parent.sizing.width.max)
+ if child.sizing.width.type == .GROW {
+ child.width = remaining_width
+ }
}
}
- remaining_width -= max(parent.children.len - 1, 0) * parent.child_gap
-
- for child_again in children_of(parent) {
- if child_again.sizing.width.type == .GROW {
- child_again.width += remaining_width
- }
- }
}
grow_children_height :: proc(parent : ^Tafl) {
parent_height : int = parent.height
@@ -182,18 +184,24 @@ grow_children_height :: proc(parent : ^Tafl) {
switch parent.layout {
case .LEFT_TO_RIGHT:
+ for child in children_of(parent) {
+ if child.sizing.height.type == .GROW {
+ child.height = remaining_height
+ }
+ }
case .TOP_TO_BOTTOM:
for child in children_of(parent) {
remaining_height -= child.height
}
remaining_height -= max(parent.children.len - 1, 0) * parent.child_gap
+
+ for child in children_of(parent) {
+ if child.sizing.height.type == .GROW {
+ child.height += remaining_height
+ }
+ }
}
- for child_again in children_of(parent) {
- if child_again.sizing.height.type == .GROW {
- child_again.height += remaining_height
- }
- }
}