I am working on gui library. The main idea that i have 2 types of object:actors and stage. Actor is a gui element(label/button and etc).
Stage is handle all input and change actor status(pressed/unpressed/over).
One of the main features is skin.You can describe how you elements shoould look. And also you can change skin in runtime.
Skin example
local skin= {}
skin.default_button_style={normal="button_normal",pressed="button_pressed",over="radio_normal"}
skin.default_label_style={font="system_font",font_scale=1}
The library is still in development.It contains only label and button.But i will add more gui elements in future.Source can be found on github
The code look like:
local stage_ui=require("stageUI.stage_ui")
local styles=require("stageUI.styles")
function init(self)
msg.post(".", "acquire_input_focus")
self.stage=stage_ui.Stage:new(styles)
local label=stage_ui.Label:new("label","default")
label:set_text("test text")
--add actor to stage
self.stage:add(label)
self.stage:add(stage_ui.Button:new("button","default",function() print("callback") end))
self.stage:add(stage_ui.Button:new("button1","default"))
end
function final(self)
msg.post(".", "release_input_focus")
end
function on_input(self, action_id, action)
--stage handle all input
self.stage:on_input(action_id,action)
end
This could at some point be a valid contender with Dirty Larry! Please keep us updated of your progress.
Personally I’m not very fond of the type of skinning that is done in code. I prefer if as much skinning as possible is done using Gui templates and any changes to the style can be seen immediately without running any code. This also makes it more approachable to non-coders.
I love skins. It is very cool when you can change one line, for example title font, and then it will be changed for all your titles. Skinning throw gui is very poor. It is hard to set different state for button(pressed/over/unpressed). In my library you can use skining from gui, if send to constructor no_style
stage_ui.Button:new("button1","no_style")
But you will not have pressed/over/unpressed states.
I make little refactoring. Add posibility to use table from gui.clone_tree(). Add some more elements. Now library contains:label,button,text_button,checkbox,radio.
That’s enough. You do not need to do anything else. I added the project and a dependency and selected Fetch Libraries and everything seems to be working: