Difference between revisions of "UI"
From GiderosMobile
Line 4: | Line 4: | ||
=== Description === | === Description === | ||
− | A UI Library for Gideros. | + | A UI Library for Gideros made of a plethora of widgets. |
In order to use Gideros UI Library, you have to link or include the two following folders to your project: | In order to use Gideros UI Library, you have to link or include the two following folders to your project: | ||
Line 75: | Line 75: | ||
{|- | {|- | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
+ | |||
+ | === Widgets === | ||
UI.Accordion '''WIP''' ''creates a UI accordion''<br/> | UI.Accordion '''WIP''' ''creates a UI accordion''<br/> | ||
[[UI.Animation]] ''creates UI animations''<br/> | [[UI.Animation]] ''creates UI animations''<br/> |
Revision as of 11:39, 13 October 2023
Supported platforms:
Available since: Gideros 2023.1
Description
A UI Library for Gideros made of a plethora of widgets.
In order to use Gideros UI Library, you have to link or include the two following folders to your project:
- Library/ui
- Library/luashaders
The folders are available in your Gideros installation folder. The UI Library depends on luashaders.
Examples
In init.lua
UI=UI or {}
local fontfilebold = "fonts/OpenSans-Bold.ttf"
UI.Default = {
TTF=fontfilebold,
}
In your game
--UI.Style:setDefault(UI.Theme.PointCore_Base)
--UI.Style:setDefault(UI.Theme.PointCore_Red)
UI.Style:setDefault(UI.Theme.PointCore_Pink)
-- a Button
local button=UI.Button.new()
button:setDimensions(64, 48)
button:setPosition(50,50)
button:setText("Button")
function button:onWidgetAction()
print("Hello Gideros UI")
end
stage:addChild(button)
Sliders
--Sliders give value from 0 to 1
local sliderA=UI.Slider.new()
sliderA:setDimensions(200,50)
sliderA:setPosition(250,50)
sliderA.name="Slider A"
local sliderB=UI.Slider.new()
sliderB:setDimensions(200,50)
sliderB:setPosition(250,150)
--This slider center is in the middle of the range
sliderB:setCenter(.5)
--Initial value is .6
sliderB:setKnobPosition(.6)
--Discrete steps of .1
sliderB:setResolution(.1)
sliderB.name="Slider B"
stage:addChild(sliderA)
stage:addChild(sliderB)
--Here we put the WidgetAction listener on stage.
--It will be propagated from each button up to stage through the sprite tree
--First parameter of event listeners are always the source widget of the event
function stage:onWidgetChange(w,v)
print(w.name.." value is "..v)
end
WidgetsUI.Accordion WIP creates a UI accordion |