Major UI refactor.
This commit is contained in:
45
lib/ui.ks
45
lib/ui.ks
@ -1,14 +1,53 @@
|
||||
|
||||
function makeRow {
|
||||
function MakeRow {
|
||||
parameter p.
|
||||
return p:AddHLayout().
|
||||
}
|
||||
|
||||
function makeButton {
|
||||
function MakeButton {
|
||||
parameter p.
|
||||
parameter l.
|
||||
parameter f.
|
||||
parameter f is {}.
|
||||
local b is p:AddButton(l).
|
||||
set b:onClick to f.
|
||||
return b.
|
||||
}
|
||||
|
||||
function MakeMenu {
|
||||
parameter stack. // the stack where menu stuff goes
|
||||
parameter btn. // the button that should show this menu
|
||||
parameter options.
|
||||
parameter execLabel.
|
||||
parameter callback.
|
||||
parameter preback is { parameter nil. }.
|
||||
|
||||
local top is stack:AddVLayout().
|
||||
local sbox is top:AddScrollBox().
|
||||
|
||||
local optionList is Lex().
|
||||
for option in options {
|
||||
local row is MakeRow(sbox).
|
||||
local name is option[0].
|
||||
local type is option[1].
|
||||
local field is 0.
|
||||
if type = "SCALAR" {
|
||||
row:AddLabel(name).
|
||||
set field to row:AddTextField(option[2]).
|
||||
} else if type = "BOOL" {
|
||||
set field to row:AddCheckBox(name, option[2]).
|
||||
} else if type = "RO" {
|
||||
row:AddLabel(name).
|
||||
set field to row:AddLabel(option[2]).
|
||||
} else {
|
||||
print "WARNING: Unsupported type passed to MakeMenu".
|
||||
}
|
||||
optionList:Add(name, field).
|
||||
}
|
||||
|
||||
set btn:onClick to {
|
||||
preback(optionList).
|
||||
stack:ShowOnly(top).
|
||||
}.
|
||||
|
||||
set top:AddButton(execLabel):onClick to callback:Bind(optionList).
|
||||
}
|
||||
|
Reference in New Issue
Block a user