mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Added SetWindowFocus(), SetWindowFocus(const char*), SetNextWindowFocus() (#146)
This commit is contained in:
parent
7591252607
commit
6d89285f59
26
imgui.cpp
26
imgui.cpp
@ -1005,6 +1005,7 @@ struct ImGuiState
|
|||||||
ImGuiSetCondition SetNextWindowSizeCond;
|
ImGuiSetCondition SetNextWindowSizeCond;
|
||||||
bool SetNextWindowCollapsedVal;
|
bool SetNextWindowCollapsedVal;
|
||||||
ImGuiSetCondition SetNextWindowCollapsedCond;
|
ImGuiSetCondition SetNextWindowCollapsedCond;
|
||||||
|
bool SetNextWindowFocus;
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
ImVector<ImDrawList*> RenderDrawLists;
|
ImVector<ImDrawList*> RenderDrawLists;
|
||||||
@ -1056,6 +1057,7 @@ struct ImGuiState
|
|||||||
SetNextWindowSizeCond = 0;
|
SetNextWindowSizeCond = 0;
|
||||||
SetNextWindowCollapsedVal = false;
|
SetNextWindowCollapsedVal = false;
|
||||||
SetNextWindowCollapsedCond = 0;
|
SetNextWindowCollapsedCond = 0;
|
||||||
|
SetNextWindowFocus = false;
|
||||||
|
|
||||||
SliderAsInputTextId = 0;
|
SliderAsInputTextId = 0;
|
||||||
ActiveComboID = 0;
|
ActiveComboID = 0;
|
||||||
@ -2704,6 +2706,11 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size, float bg
|
|||||||
ImGui::SetWindowCollapsed(g.SetNextWindowCollapsedVal, g.SetNextWindowCollapsedCond);
|
ImGui::SetWindowCollapsed(g.SetNextWindowCollapsedVal, g.SetNextWindowCollapsedCond);
|
||||||
g.SetNextWindowCollapsedCond = 0;
|
g.SetNextWindowCollapsedCond = 0;
|
||||||
}
|
}
|
||||||
|
if (g.SetNextWindowFocus)
|
||||||
|
{
|
||||||
|
ImGui::SetWindowFocus();
|
||||||
|
g.SetNextWindowFocus = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Find parent
|
// Find parent
|
||||||
ImGuiWindow* parent_window = (flags & ImGuiWindowFlags_ChildWindow) != 0 ? g.CurrentWindowStack[g.CurrentWindowStack.size()-2] : NULL;
|
ImGuiWindow* parent_window = (flags & ImGuiWindowFlags_ChildWindow) != 0 ? g.CurrentWindowStack[g.CurrentWindowStack.size()-2] : NULL;
|
||||||
@ -3437,6 +3444,19 @@ void ImGui::SetWindowCollapsed(bool collapsed, ImGuiSetCondition cond)
|
|||||||
window->Collapsed = collapsed;
|
window->Collapsed = collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGui::SetWindowFocus()
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
|
FocusWindow(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui::SetWindowFocus(const char* name)
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = FindWindowByName(name);
|
||||||
|
if (window)
|
||||||
|
FocusWindow(window);
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiSetCondition cond)
|
void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiSetCondition cond)
|
||||||
{
|
{
|
||||||
ImGuiState& g = *GImGui;
|
ImGuiState& g = *GImGui;
|
||||||
@ -3458,6 +3478,12 @@ void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiSetCondition cond)
|
|||||||
g.SetNextWindowCollapsedCond = cond ? cond : ImGuiSetCondition_Always;
|
g.SetNextWindowCollapsedCond = cond ? cond : ImGuiSetCondition_Always;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGui::SetNextWindowFocus()
|
||||||
|
{
|
||||||
|
ImGuiState& g = *GImGui;
|
||||||
|
g.SetNextWindowFocus = true;
|
||||||
|
}
|
||||||
|
|
||||||
ImVec2 ImGui::GetContentRegionMax()
|
ImVec2 ImGui::GetContentRegionMax()
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
|
4
imgui.h
4
imgui.h
@ -177,12 +177,16 @@ namespace ImGui
|
|||||||
IMGUI_API ImVec2 GetWindowSize(); // get current window position.
|
IMGUI_API ImVec2 GetWindowSize(); // get current window position.
|
||||||
IMGUI_API float GetWindowWidth();
|
IMGUI_API float GetWindowWidth();
|
||||||
IMGUI_API bool GetWindowCollapsed();
|
IMGUI_API bool GetWindowCollapsed();
|
||||||
|
|
||||||
IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiSetCondition cond = 0); // set next window position - call before Begin().
|
IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiSetCondition cond = 0); // set next window position - call before Begin().
|
||||||
IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiSetCondition cond = 0); // set next window size. set to ImVec2(0,0) to force an auto-fit.
|
IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiSetCondition cond = 0); // set next window size. set to ImVec2(0,0) to force an auto-fit.
|
||||||
IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiSetCondition cond = 0); // set next window collapsed state.
|
IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiSetCondition cond = 0); // set next window collapsed state.
|
||||||
|
IMGUI_API void SetNextWindowFocus(); // set next window to be focused / front-most
|
||||||
IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiSetCondition cond = 0); // set current window position - call within Begin()/End(). may incur tearing.
|
IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiSetCondition cond = 0); // set current window position - call within Begin()/End(). may incur tearing.
|
||||||
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 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 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 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.
|
IMGUI_API void SetScrollPosHere(); // adjust scrolling position to center into the current cursor position.
|
||||||
IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget.
|
IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget.
|
||||||
|
Loading…
Reference in New Issue
Block a user