Lilica is a lightweight C++ application that lets you define interactive graphical user interfaces using Lua scripting through the ImGui framework. It is ideal for tools, prototypes, or any GUI-based workflow where live scripting and flexibility are key.
- Create and modify GUI elements using Lua scripts
- Reload Lua scripts at runtime via a built-in debug interface
- Uses Dear ImGui with OpenGL and GLFW
- Modular C++ codebase
lilica/
├── CMakeLists.txt
├── script.lua # Example Lua UI script
├── src/
│ ├── main.cpp # Entry point
│ ├── gui_manager.{h,cpp} # Window & rendering loop
│ ├── lua_helper.{h,cpp} # Lua context and error handling
│ ├── imgui_binding.{h,cpp} # Exposes ImGui to Lua
└── imgui/ # Dear ImGui and backend sources
- CMake 3.20+
- A C++17 compiler
- Lua development files
- GLFW
- OpenGL
mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build .
- Ensure
script.luais available in the root directory. - Run the
lilicabinary. - The GUI defined in the Lua script will appear.
- Use the built-in debug panel to reload or change scripts.
function render_ui()
imgui.Begin("Lua Window")
imgui.Text("Hello from Lua!")
if imgui.Button("Click Me") then
print("You clicked the button!")
end
imgui.End()
endThe application includes a built-in debug window that allows:
- Viewing the currently loaded script
- Changing the script path
- Reloading scripts
- Viewing Lua error messages
The following functions are available from Lua and map directly to ImGui features:
-
imgui.Begin(name)/imgui.End()
Creates a window. CallEnd()to close it. -
imgui.Text(text)
Displays static text. -
imgui.Button(label)
Returnstruewhen clicked. -
imgui.SameLine()
Places next widget on the same horizontal line.
-
changed, new_value = imgui.Checkbox(label, current_value)
Toggle a boolean value. -
changed, new_value = imgui.SliderFloat(label, value, min, max)
Float slider control. -
changed, text = imgui.InputText(label, initial_text)
Input box for strings. -
changed, int_val = imgui.InputInt(label, initial_int)
Input box for integers.
-
changed, index = imgui.Combo(label, current_index, item_list)
Dropdown menu. -
changed, index = imgui.ListBox(label, current_index, item_list)
Scrollable list box.
-
changed, r, g, b = imgui.ColorEdit3(label, r, g, b)
Color picker (RGB). -
imgui.ProgressBar(fraction)
Display a progress bar from 0.0 to 1.0. -
open = imgui.TreeNode(label)
Collapsible tree node. Useimgui.TreePop()to close. -
imgui.BeginChild(id, width, height)/imgui.EndChild()
Nested scrolling region or frame.
-
open = imgui.BeginMenuBar()/imgui.EndMenuBar()
Begin and end a menu bar (must be inside a window). -
open = imgui.BeginMenu(label)/imgui.EndMenu()
Dropdown menu. -
selected = imgui.MenuItem(label)
Menu item inside a menu.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Lilica uses:
- Dear ImGui
- Lua
- GLFW
- OpenGL