-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathgenuiusg3.nim
More file actions
104 lines (84 loc) · 3.63 KB
/
genuiusg3.nim
File metadata and controls
104 lines (84 loc) · 3.63 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# example of genui macro with the same ui as controllgallery3.nim
import std/sugar
import uing/genui
import uing
proc main =
const
MsgBoxTitle = "This is a normal message box."
MsgBoxDesc = "More detailed information can be shown here."
ErrorMsgBoxTitle = "This message box describes an error."
var
spin: Spinbox
slide: Slider
progress: ProgressBar
proc update(sender: Spinbox or Slider) =
spin.value = sender.value
slide.value = sender.value
progress.value = sender.value
genui:
window%Window("libui-ng Control Gallery", 800, 600):
tab%Tab:
# Basic Controls
VerticalBox(padded = true)[name = "Basic Controls"]:
HorizontalBox(padded = true):
Button("Button")
Checkbox("Checkbox")
Label("This is a label\nLabels can span muliple lines.")
HorizontalSeparator()
Group("Entries", margined = true)[stretchy = true]:
Form(padded = true):
Entry[label = "Entry"]
PasswordEntry[label = "Password Entry"]
SearchEntry[label = "Search Entry"]
MultilineEntry[label = "Multiline Entry", stretchy = true]
NonWrappingMultilineEntry[label = "Multiline Entry No Wrap", stretchy = true]
# Numbers and Lists
HorizontalBox(padded = true)[name = "Numbers and Lists"]:
Group("Numbers", margined = true)[stretchy = true]:
VerticalBox(padded = true):
spin%Spinbox(0..100, onchanged = update)
slide%Slider(0..100, onchanged = update)
progress%ProgressBar
ProgressBar(indeterminate = true)
Group("Lists", margined = true)[stretchy = true]:
VerticalBox(padded = true):
Combobox:
"Combobox Item 1"
"Combobox Item 2"
"Combobox Item 3"
EditableCombobox:
"Editable Item 1"
"Editable Item 2"
"Editable Item 3"
RadioButtons:
"Radio Button 1"
"Radio Button 2"
"Radio Button 3"
# Data Choosers
HorizontalBox(padded = true)[name = "Data Choosers"]:
VerticalBox(padded = true):
DatePicker()
TimePicker()
DateTimePicker()
FontButton()
ColorButton()
VerticalSeparator()
Grid(padded = true)[stretchy = true]:
openFileEntry%Entry[1, 0, 1, 1, true, AlignFill, false, AlignFill]
openFolderEntry%Entry[1, 1, 1, 1, true, AlignFill, false, AlignFill]
saveFileEntry%Entry[1, 2, 1, 1, true, AlignFill, false, AlignFill]
Button("Open File", onclick = (_: Button) => (openFileEntry.text = window.openFile()))[0, 0, 1, 1, false, AlignFill, false, AlignFill]
Button("Open Folder", onclick = (_: Button) => (openFileEntry.text = window.openFolder()))[0, 1, 1, 1, false, AlignFill, false, AlignFill]
Button("Save File", onclick = (_: Button) => (openFileEntry.text = window.saveFile()))[0, 2, 1, 1, false, AlignFill, false, AlignFill]
HorizontalBox(padded = true)[0, 3, 2, 1, false, AlignCenter, false, AlignStart]:
Button("Message Box", onclick = (_: Button) => window.msgBox(MsgBoxTitle, MsgBoxDesc))
Button("Error Box", onclick = (_: Button) => window.error(ErrorMsgBoxTitle, MsgBoxDesc))
for entry in [openFileEntry, openFolderEntry, saveFileEntry]:
entry.readOnly = true
for i in 0 ..< tab.tabs.len:
tab.setMargined i, true
window.margined = true
show window
mainLoop()
init()
main()