Skip to content

Commit

Permalink
example_03_layout_container: add WidthMode_Fill
Browse files Browse the repository at this point in the history
  • Loading branch information
simonkrauter committed Jan 31, 2023
1 parent 331bcc2 commit da59243
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions examples/example_03_layout_container.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit da59243

Please sign in to comment.