7
-----------------------------------------------
ORION - IMMEDIATE MODE GUI V1.0
Orion is a simple immediate mode GUI library written with the objective of making user interfaces for tools and interactive demos as simple as possible and offer a nice looking set of widgets.
In the code you can find the minified version of the library that you can copy and paste on your cart instead of the full code.
Because it is an immediate mode GUI library, the widgets are updated and drawn every frame, so the GUI() function have to be called at the top of your TIC function, ex:
function TIC()
cls(13)
GUI()
GUI.Button{
text="I'm a button",
x=120,
y=68
}
end
-----------------------------------------------
BUTTON:
GUI.Button{text, x, y, [width=50], [height=10], [halign='left'], [valign='top']} -> clicked, pressed
PARAMETERS:
-text: text shown on the button
-x, y: screen coordinates to draw the widget
-width, height: widget size, the button will have a minimum size set to it's text width and height
-halign: horizontal alignment (left/center/right)
-valign: vertical alignment (top/middle/bottom)
RETURNS:
-clicked: returns true if the button was clicked in the current frame
-pressed: return true if the button is currently pressed down
EXAMPLE:
function TIC()
cls(13)
GUI()
clicked = GUI.Button{
text="I'm a button",
x=120,
y=68
}
if clicked then
trace("I just got clicked!!!", 2)
end
end
-----------------------------------------------
SLIDER:
GUI.Slider{value, min, max, x, y, [step=false], [label=false], [width=50], [halign='left'], [valign='top']} -> value
PARAMETERS:
-value: set the value of the slider
-min, max: minimum and maximum values
-x, y: screen coordinates to draw the widget
-step: step of the slider
-label: show the current value while dragging the slider
-width: widget width, with a minimum value of 10
-halign: horizontal alignment (left/center/right)
-valign: vertical alignment (top/middle/bottom)
RETURNS:
-value: returns the value set in the slider
EXAMPLE:
radius = 25
function TIC()
cls(13)
GUI()
radius = GUI.Slider{
value=radius,
min=1,
max=50,
x=10,
y=10,
label=true,
}
circ(120, 68, radius, 2)
end
-----------------------------------------------
CHECKBOX:
GUI.Checkbox{value, x, y, [text], [halign='left'], [valign='top']} -> checked
PARAMETERS:
-value: set the value of the checkbox
-x, y: screen coordinates to draw the widget
-text: label shown next to the checkbox
-halign: horizontal alignment (left/center/right)
-valign: vertical alignment (top/middle/bottom)
RETURNS:
-checked: returns whether the checkbox is checked or not
EXAMPLE:
checked=0
function TIC()
cls(13)
GUI()
checked = GUI.Checkbox{
value=checked,
x=10,
y=10,
text=checked and 'ON' or 'OFF'
}
end
-----------------------------------------------
PROGRESS BAR:
GUI.Progress{value, min, max, x, y, [step], [width=50], [halign='left'], [valign='top']}
PARAMETERS:
-value: set the value of the progress bar
-min, max: minimum and maximum values
-x, y: screen coordinates to draw the widget
-step: step of the progress bar
-width: widget width, with a minimum value of 10
-halign: horizontal alignment (left/center/right)
-valign: vertical alignment (top/middle/bottom)
EXAMPLE:
progress=0
function TIC()
cls(13)
GUI()
GUI.Progress{
value=progress,
min=0,
max=100,
x=10,
y=10
}
progress=(progress+1)%100
end
-----------------------------------------------
LIST:
GUI.List{value, options, x, y, [width=50], [height=50], [halign='left'], [valign='top']} -> option, hovered
PARAMETERS:
-value: currently selected option of the list
-options: table with values to be selected
-x, y: screen coordinates to draw the widget
-width, height: widget size, with a minimum value of 10
-halign: horizontal alignment (left/center/right)
-valign: vertical alignment (top/middle/bottom)
RETURNS:
-option: returns the selected option
-hovered: returns the currently hovered option
EXAMPLE:
continent='Antarctica'
continent_list={
'Asia', 'Africa', 'Europe',
'North America', 'South America',
'Oceania', 'Antarctica'
}
function TIC()
cls(13)
GUI()
continent = GUI.List{
value=continent,
options=continent_list,
x=10,
y=10,
width=75,
height=75
}
end
-----------------------------------------------
TOGGLE BUTTON:
GUI.Toggle{value, x, y, [text=(true, false)], [before], [after], [width=50], [height=10], [halign='left'], [valign='top']} -> value
PARAMETERS:
-value: set the value of the toggle
-x, y: screen coordinates to draw the widget
-text: text shown in the center of the button, by default will show true or false
-before: text show on the left side of the button
-after: text show on the right side of the button
-width, height: widget size, with a minimum value of the button label
-halign: horizontal alignment (left/center/right)
-valign: vertical alignment (top/middle/bottom)
RETURNS:
-value: returns whether the button is set to true or false
EXAMPLE:
expanded=false
function TIC()
cls(13)
GUI()
expanded = GUI.Toggle{
value=expanded,
text='',
before='Click me!',
after=expanded and '-' or '+',
x=10,
y=10,
width=50,
}
if expanded then
print('Hello World!', 10, 25, 2)
end
end
-----------------------------------------------
TEXT INPUT:
GUI.Text{value, x, y, [placeholder], [width=50], [height=10], [halign='left'], [valign='top']} -> value
PARAMETERS:
-value: set the value of the input
-x, y: screen coordinates to draw the widget
-placeholder: hint text shown when the field is empty
-width, height: widget size
-halign: horizontal alignment (left/center/right)
-valign: vertical alignment (top/middle/bottom)
RETURNS:
-value: returns the text typed in the input
EXAMPLE:
name=''
function TIC()
cls(13)
GUI()
name = GUI.Text{
value=name,
x=10,
y=10,
placeholder='Your name'
}
print("Hello "..name, 10,25,2)
end
-----------------------------------------------