Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more window management functions #58

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions imgui/api/imgui.script_api
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,59 @@
type: number
optional: true

#*****************************************************************************************************

- name: set_next_window_focus
type: function

#*****************************************************************************************************

- name: set_window_focus
type: function

parameters:
- name: name
type: string
optional: true

#*****************************************************************************************************

- name: set_next_window_collapsed
type: function

parameters:
- name: collapsed
type: boolean
- name: cond
type: number
optional: true

#*****************************************************************************************************

- name: set_window_collapsed
type: function

parameters:
- name: collapsed
type: boolean
- name: cond
type: number
optional: true

#*****************************************************************************************************

- name: set_window_collapsed
type: function

parameters:
- name: name
type: string
- name: collapsed
type: boolean
- name: cond
type: number
optional: true

#*****************************************************************************************************

- name: get_window_size
Expand Down
78 changes: 78 additions & 0 deletions imgui/src/extension_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,80 @@ static int imgui_SetNextWindowPos(lua_State* L)
ImGui::SetNextWindowPos(ImVec2(x, y), cond);
return 0;
}
static int imgui_SetNextWindowFocus(lua_State* L)
{
DM_LUA_STACK_CHECK(L, 0);
imgui_NewFrame();
ImGui::SetNextWindowFocus();
return 0;
}
static int imgui_SetWindowFocus(lua_State* L)
{
DM_LUA_STACK_CHECK(L, 0);
imgui_NewFrame();
if (lua_isstring(L, 1))
{
const char* name = luaL_checkstring(L, 1);
ImGui::SetWindowFocus(name);
}
else
{
ImGui::SetWindowFocus();
}
return 0;
}
static int imgui_SetNextWindowCollapsed(lua_State* L)
{
DM_LUA_STACK_CHECK(L, 0);
imgui_NewFrame();
bool collapsed = false;
if (lua_isboolean(L, 1))
{
collapsed = lua_toboolean(L, 1);
}
uint32_t cond = ImGuiCond_None;
if (lua_isnumber(L, 2))
{
cond = luaL_checkint(L, 2);
}
ImGui::SetNextWindowCollapsed(collapsed, cond);
return 0;
}
static int imgui_SetWindowCollapsed(lua_State* L)
{
DM_LUA_STACK_CHECK(L, 0);
imgui_NewFrame();
if (lua_isstring(L, 1))
{
const char* name = luaL_checkstring(L, 1);
bool collapsed = false;
if (lua_isboolean(L, 2))
{
collapsed = lua_toboolean(L, 2);
}
uint32_t cond = ImGuiCond_None;
if (lua_isnumber(L, 3))
{
cond = luaL_checkint(L, 3);
}
ImGui::SetWindowCollapsed(name, collapsed, cond);
}
else
{
bool collapsed = false;
if (lua_isboolean(L, 1))
{
collapsed = lua_toboolean(L, 1);
}
uint32_t cond = ImGuiCond_None;
if (lua_isnumber(L, 2))
{
cond = luaL_checkint(L, 2);
}
ImGui::SetWindowCollapsed(collapsed, cond);
}
return 0;
}
static int imgui_GetWindowSize(lua_State* L)
{
DM_LUA_STACK_CHECK(L, 2);
Expand Down Expand Up @@ -2633,6 +2707,10 @@ static const luaL_reg Module_methods[] =

{"set_next_window_size", imgui_SetNextWindowSize},
{"set_next_window_pos", imgui_SetNextWindowPos},
{"set_next_window_focus", imgui_SetNextWindowFocus},
{"set_window_focus", imgui_SetWindowFocus},
{"set_next_window_collapsed", imgui_SetNextWindowCollapsed},
{"set_window_collapsed", imgui_SetWindowCollapsed},
{"get_window_size", imgui_GetWindowSize},
{"get_window_pos", imgui_GetWindowPos},
{"begin_window", imgui_Begin},
Expand Down