Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Upbolt/Lua-ImGui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Lua-ImGui

Object-oriented Lua bindings for ImGui

This has been attempted naively, so you may encounter my strange code structuring. Feel free to contribute better solutions!

Example

#include "Lua-ImGui/lib.hpp"

std::vector<lib::window> windows;
lua_State *l_G = luaL_newstate();

#include "Lua-ImGui/helper.hpp"
#include "Lua-ImGui/bind.hpp"

int main() {
  lua_bind::init(); // Initializes the "ImGui" global
  
  /* 
  lua_close(l_G); 
  -- Lua state is not closed, since element callback functions are stored in the registry
  -- If you have a better solution, feel free to make a pull request!
  */
}

Lua API

-- Main window
local Window = ImGui.new("Window", "example title")

-- Inner elements
local Label = ImGui.new("Label", Window)
local TabSelector = ImGui.new("TabSelector", Window)

local Tab1 = TabSelector:AddTab("Tab1")
local Tab2 = TabSelector:AddTab("Tab2")

local Button = ImGui.new("Button", Tab1)
local Slider = ImGui.new("Slider", Tab1, true) -- (boolean: 3) aligns it side-by-side !
local ColorPicker = ImGui.new("ColorPicker", Tab2)

Label.Text = "Lua-ImGui Example"
Slider.Text = "Slider Example"
Button.Text = "Button Example"
ColorPicker.Text = "Color Picker Example"

Slider.Min = -10
Slider.Max = 10

Button.Callback = function()
  ImGui.new("Label", Tab1).Text = "Hello world"
end

Releases

No releases published

Packages

No packages published

Languages