mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
Added SetWindowPos(), SetWindowSize(), SetWindowCollaposed() given a wnidow name.
This commit is contained in:
parent
6927d5872e
commit
ebe363c951
47
imgui.cpp
47
imgui.cpp
@ -3386,10 +3386,8 @@ ImVec2 ImGui::GetWindowPos()
|
||||
return window->Pos;
|
||||
}
|
||||
|
||||
void ImGui::SetWindowPos(const ImVec2& pos, ImGuiSetCondition cond)
|
||||
static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiSetCondition cond)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
|
||||
// Test condition (NB: bit 0 is always true) and clear flags for next time
|
||||
if (cond && (window->SetWindowPosAllowFlags & cond) == 0)
|
||||
return;
|
||||
@ -3402,16 +3400,27 @@ void ImGui::SetWindowPos(const ImVec2& pos, ImGuiSetCondition cond)
|
||||
window->DC.CursorPos += (window->Pos - old_pos); // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor
|
||||
}
|
||||
|
||||
void ImGui::SetWindowPos(const ImVec2& pos, ImGuiSetCondition cond)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
SetWindowPos(window, pos, cond);
|
||||
}
|
||||
|
||||
void ImGui::SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCondition cond)
|
||||
{
|
||||
ImGuiWindow* window = FindWindowByName(name);
|
||||
if (window)
|
||||
SetWindowPos(window, pos, cond);
|
||||
}
|
||||
|
||||
ImVec2 ImGui::GetWindowSize()
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
return window->Size;
|
||||
}
|
||||
|
||||
void ImGui::SetWindowSize(const ImVec2& size, ImGuiSetCondition cond)
|
||||
static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiSetCondition cond)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
|
||||
// Test condition (NB: bit 0 is always true) and clear flags for next time
|
||||
if (cond && (window->SetWindowSizeAllowFlags & cond) == 0)
|
||||
return;
|
||||
@ -3431,10 +3440,21 @@ void ImGui::SetWindowSize(const ImVec2& size, ImGuiSetCondition cond)
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui::SetWindowCollapsed(bool collapsed, ImGuiSetCondition cond)
|
||||
void ImGui::SetWindowSize(const ImVec2& size, ImGuiSetCondition cond)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
SetWindowSize(window, size, cond);
|
||||
}
|
||||
|
||||
void ImGui::SetWindowSize(const char* name, const ImVec2& size, ImGuiSetCondition cond)
|
||||
{
|
||||
ImGuiWindow* window = FindWindowByName(name);
|
||||
if (window)
|
||||
SetWindowSize(window, size, cond);
|
||||
}
|
||||
|
||||
static void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiSetCondition cond)
|
||||
{
|
||||
// Test condition (NB: bit 0 is always true) and clear flags for next time
|
||||
if (cond && (window->SetWindowCollapsedAllowFlags & cond) == 0)
|
||||
return;
|
||||
@ -3444,6 +3464,19 @@ void ImGui::SetWindowCollapsed(bool collapsed, ImGuiSetCondition cond)
|
||||
window->Collapsed = collapsed;
|
||||
}
|
||||
|
||||
void ImGui::SetWindowCollapsed(bool collapsed, ImGuiSetCondition cond)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
SetWindowCollapsed(window);
|
||||
}
|
||||
|
||||
void ImGui::SetWindowCollapsed(const char* name, bool collapsed, ImGuiSetCondition cond)
|
||||
{
|
||||
ImGuiWindow* window = FindWindowByName(name);
|
||||
if (window)
|
||||
SetWindowCollapsed(window);
|
||||
}
|
||||
|
||||
void ImGui::SetWindowFocus()
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
|
3
imgui.h
3
imgui.h
@ -186,6 +186,9 @@ namespace ImGui
|
||||
IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiSetCondition cond = 0); // set current window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing.
|
||||
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiSetCondition cond = 0); // set current window collapsed state.
|
||||
IMGUI_API void SetWindowFocus(); // set current window to be focused / front-most
|
||||
IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCondition cond = 0); // set named window position - call within Begin()/End(). may incur tearing.
|
||||
IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiSetCondition cond = 0); // set named window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing.
|
||||
IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiSetCondition cond = 0); // set named window collapsed state.
|
||||
IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / front-most
|
||||
|
||||
IMGUI_API void SetScrollPosHere(); // adjust scrolling position to center into the current cursor position.
|
||||
|
Loading…
Reference in New Issue
Block a user