diff --git a/example/example.script b/example/example.script index 7ab719c..4836315 100644 --- a/example/example.script +++ b/example/example.script @@ -59,6 +59,7 @@ function init(self) self.show_demo_window = false self.show_close_window = false self.show_live_data = false + self.dockspace = false imgui.set_ini_filename() set_style() @@ -112,6 +113,11 @@ local function update_tab1(self) self.show_demo_window = checked end + changed, checked = imgui.checkbox("Docking", self.dockspace) + if changed then + self.dockspace = checked + end + imgui.separator() if imgui.radio_button("Option 1", self.radio == 1) then @@ -494,6 +500,12 @@ end function update(self, dt) main_menu_bar(self) + if self.dockspace then + local viewport = imgui.get_main_viewport() + local dockspace = imgui.dock_space_over_viewport(viewport) + print() + end + if self.show_demo_window then imgui.demo() end diff --git a/imgui/src/extension_imgui.cpp b/imgui/src/extension_imgui.cpp index 15b8d8d..727a5b9 100644 --- a/imgui/src/extension_imgui.cpp +++ b/imgui/src/extension_imgui.cpp @@ -1868,6 +1868,30 @@ static int imgui_SetScrollHereY(lua_State *L) return 0; } +// ---------------------------- +// ----- DOCKING -------------- +// ---------------------------- + +static int imgui_DockSpaceOverViewport(lua_State *L) +{ + ImGuiIO& io = ImGui::GetIO(); + io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; + + DM_LUA_STACK_CHECK(L, 1); + ImGuiViewport* viewport = (ImGuiViewport*)lua_touserdata(L, 1); + ImGuiID dockspace_id = ImGui::DockSpaceOverViewport(viewport); + + lua_pushnumber(L, dockspace_id); + return 1; +} + +static int imgui_GetMainViewport(lua_State *L) +{ + DM_LUA_STACK_CHECK(L, 1); + void* viewport = (void*)ImGui::GetMainViewport(); + lua_pushlightuserdata(L, viewport); + return 1; +} // ---------------------------- // ----- FONT ----------------- @@ -2355,6 +2379,9 @@ static const luaL_reg Module_methods[] = {"get_frame_height", imgui_GetFrameHeight}, {"set_scroll_here_y", imgui_SetScrollHereY}, + + {"dock_space_over_viewport", imgui_DockSpaceOverViewport}, + {"get_main_viewport", imgui_GetMainViewport}, {0, 0} };