From da592433f89183ba255684df64885d070aef1d3e Mon Sep 17 00:00:00 2001 From: simonkrauter Date: Tue, 31 Jan 2023 14:53:12 -0300 Subject: [PATCH] example_03_layout_container: add WidthMode_Fill --- examples/example_03_layout_container.nim | 46 ++++++++++++++---------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/examples/example_03_layout_container.nim b/examples/example_03_layout_container.nim index 7f651e7..dc85ed4 100755 --- a/examples/example_03_layout_container.nim +++ b/examples/example_03_layout_container.nim @@ -27,46 +27,55 @@ for i in 1..3: var control = newButton("Button " & $i) innerContainer3.add(control) -# Row 4: Controls expanded: +# Row 4: Controls with WidthMode_Fill: var innerContainer4 = newLayoutContainer(Layout_Horizontal) -innerContainer4.frame = newFrame("Row 4: Controls expanded") +innerContainer4.frame = newFrame("Row 4: Controls with WidthMode_Fill") +innerContainer4.width = 600 for i in 1..3: var control = newButton("Button " & $i) - control.widthMode = WidthMode_Expand + control.widthMode = WidthMode_Fill innerContainer4.add(control) -# Row 5: Controls centered: +# Row 5: Controls with WidthMode_Expand: var innerContainer5 = newLayoutContainer(Layout_Horizontal) -innerContainer5.widthMode = WidthMode_Expand -innerContainer5.height = 80 # problem -innerContainer5.xAlign = XAlign_Center -innerContainer5.yAlign = YAlign_Center -innerContainer5.frame = newFrame("Row 5: Controls centered") +innerContainer5.frame = newFrame("Row 5: Controls with WidthMode_Expand") for i in 1..3: var control = newButton("Button " & $i) + control.widthMode = WidthMode_Expand innerContainer5.add(control) -# Row 6: Container expanded, spread: +# Row 6: Controls centered: var innerContainer6 = newLayoutContainer(Layout_Horizontal) -# innerContainer.height = 80 innerContainer6.widthMode = WidthMode_Expand -innerContainer6.xAlign = XAlign_Spread -innerContainer6.frame = newFrame("Row 6: Container expanded, spread") +innerContainer6.height = 80 # problem +innerContainer6.xAlign = XAlign_Center +innerContainer6.yAlign = YAlign_Center +innerContainer6.frame = newFrame("Row 6: Controls centered") for i in 1..3: var control = newButton("Button " & $i) innerContainer6.add(control) -# Row 7: Static size: +# Row 7: Container expanded, spread: var innerContainer7 = newLayoutContainer(Layout_Horizontal) +# innerContainer.height = 80 innerContainer7.widthMode = WidthMode_Expand -innerContainer7.xAlign = XAlign_Center -innerContainer7.yAlign = YAlign_Center -innerContainer7.frame = newFrame("Row 7: Static size") +innerContainer7.xAlign = XAlign_Spread +innerContainer7.frame = newFrame("Row 7: Container expanded, spread") +for i in 1..3: + var control = newButton("Button " & $i) + innerContainer7.add(control) + +# Row 8: Static size: +var innerContainer8 = newLayoutContainer(Layout_Horizontal) +innerContainer8.widthMode = WidthMode_Expand +innerContainer8.xAlign = XAlign_Center +innerContainer8.yAlign = YAlign_Center +innerContainer8.frame = newFrame("Row 8: Static size") for i in 1..3: var control = newButton("Button " & $i) control.width = 90 * i control.height = 15 * i - innerContainer7.add(control) + innerContainer8.add(control) var mainContainer = newLayoutContainer(Layout_Vertical) mainContainer.add(innerContainer1) @@ -76,6 +85,7 @@ mainContainer.add(innerContainer4) mainContainer.add(innerContainer5) mainContainer.add(innerContainer6) mainContainer.add(innerContainer7) +mainContainer.add(innerContainer8) var window = newWindow() window.width = 800