A simple UI framework for the Lua language.
• Pure Lua, utilising FFI for best performance with SDL2.
• Simple hierarchical GUIs, with no overhead bloat.
○ No need for external window managers, SDL handles it!
- Requirements
LuaJIT
SDL2 Runtime Binary (.dll):
- Windows: Place
sdl2.dllin your root folder - macOS / Linux: Ensure
SDL2is installed globally.
• Make a file called main.lua:
local SunUI = require("sunui")
local Background = require("sunui.widgets.bg")
-- Initialize a window via the SunUI framework engine
SunUI:init("SunUI Application Workspace", 800, 600)
-- Create an interactive panel element
local interactive_panel = Background:new({
x = 300, y = 220, w = 200, h = 160,
color = {70, 130, 180, 255} -- Slate Blue
})
-- Handle Hover & Mouse Interact States
function interactive_panel:on_mouseenter()
self.color = {100, 149, 237, 255} -- Light Cornflower Blue
end
function interactive_panel:on_mouseleave()
self.color = {70, 130, 180, 255} -- Back to Blue
end
function interactive_panel:on_click()
print("UI Element Clicked!")
self.color = {220, 20, 60, 255} -- Flash Crimson
end
-- Start the application lifecycle main thread loop
SunUI:run(interactive_panel)• Run the app:
Execute in the terminal using LuaJIT:
luajit main.luaThis project is open-source and available under the Apache License Version 2.0