-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_grid.cr
More file actions
46 lines (36 loc) · 1.06 KB
/
basic_grid.cr
File metadata and controls
46 lines (36 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require "../../src/uing"
UIng.init
window = UIng::Window.new("Grid Example", 300, 200, margined: true)
window.on_closing do
UIng.quit
true
end
grid = UIng::Grid.new(padded: true)
# Create a simple 3x3 grid layout
labels = [
"Top Left", "Top Center", "Top Right",
"Middle Left", "Center", "Middle Right",
"Bottom Left", "Bottom Center", "Bottom Right",
]
labels.each_with_index do |text, index|
row = index // 3
col = index % 3
label = UIng::Label.new(text)
grid.append(label, col, row, 1, 1, true, :fill, true, :fill)
end
# Add a button that spans 2 columns at the bottom
button = UIng::Button.new("Span Button")
button.on_clicked do
window.msg_box("Grid Demo", "This button spans 2 columns!")
end
grid.append(button, 0, 3, 2, 1, true, :fill, false, :fill)
# Add another button in the remaining space
another_button = UIng::Button.new("Single")
another_button.on_clicked do
window.msg_box("Grid Demo", "Single column button!")
end
grid.append(another_button, 2, 3, 1, 1, true, :fill, false, :fill)
window.child = grid
window.show
UIng.main
UIng.uninit