mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 20:07:01 +00:00
Begin: Work toward obsoleting the 5-arguments Begin() overload. (1)
This commit is contained in:
parent
1a35766356
commit
55d873875e
29
imgui.cpp
29
imgui.cpp
@ -4010,6 +4010,17 @@ static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window)
|
|||||||
return scroll;
|
return scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ImGuiCol GetWindowBgColorIdxFromFlags(ImGuiWindowFlags flags)
|
||||||
|
{
|
||||||
|
if (flags & ImGuiWindowFlags_ComboBox)
|
||||||
|
return ImGuiCol_ComboBg;
|
||||||
|
if (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup))
|
||||||
|
return ImGuiCol_PopupBg;
|
||||||
|
if (flags & ImGuiWindowFlags_ChildWindow)
|
||||||
|
return ImGuiCol_ChildWindowBg;
|
||||||
|
return ImGuiCol_WindowBg;
|
||||||
|
}
|
||||||
|
|
||||||
// Push a new ImGui window to add widgets to.
|
// Push a new ImGui window to add widgets to.
|
||||||
// - A default window called "Debug" is automatically stacked at the beginning of every frame so you can use widgets without explicitly calling a Begin/End pair.
|
// - A default window called "Debug" is automatically stacked at the beginning of every frame so you can use widgets without explicitly calling a Begin/End pair.
|
||||||
// - Begin/End can be called multiple times during the frame with the same window name to append content.
|
// - Begin/End can be called multiple times during the frame with the same window name to append content.
|
||||||
@ -4021,10 +4032,15 @@ static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window)
|
|||||||
// - Passing non-zero 'size' is roughly equivalent to calling SetNextWindowSize(size, ImGuiCond_FirstUseEver) prior to calling Begin().
|
// - Passing non-zero 'size' is roughly equivalent to calling SetNextWindowSize(size, ImGuiCond_FirstUseEver) prior to calling Begin().
|
||||||
bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||||
{
|
{
|
||||||
return ImGui::Begin(name, p_open, ImVec2(0.f, 0.f), -1.0f, flags);
|
return BeginEx(name, p_open, ImVec2(0.f, 0.f), -1.0f, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha, ImGuiWindowFlags flags)
|
bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha, ImGuiWindowFlags flags)
|
||||||
|
{
|
||||||
|
return BeginEx(name, p_open, size_on_first_use, bg_alpha, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ImGui::BeginEx(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha, ImGuiWindowFlags flags)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
const ImGuiStyle& style = g.Style;
|
const ImGuiStyle& style = g.Style;
|
||||||
@ -4371,13 +4387,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
|||||||
window->BorderSize = (flags & ImGuiWindowFlags_ShowBorders) ? 1.0f : 0.0f;
|
window->BorderSize = (flags & ImGuiWindowFlags_ShowBorders) ? 1.0f : 0.0f;
|
||||||
|
|
||||||
// Window background, Default Alpha
|
// Window background, Default Alpha
|
||||||
ImGuiCol bg_color_idx = ImGuiCol_WindowBg;
|
ImGuiCol bg_color_idx = GetWindowBgColorIdxFromFlags(flags);
|
||||||
if ((flags & ImGuiWindowFlags_ComboBox) != 0)
|
|
||||||
bg_color_idx = ImGuiCol_ComboBg;
|
|
||||||
else if ((flags & ImGuiWindowFlags_Tooltip) != 0 || (flags & ImGuiWindowFlags_Popup) != 0)
|
|
||||||
bg_color_idx = ImGuiCol_PopupBg;
|
|
||||||
else if ((flags & ImGuiWindowFlags_ChildWindow) != 0)
|
|
||||||
bg_color_idx = ImGuiCol_ChildWindowBg;
|
|
||||||
ImVec4 bg_color = style.Colors[bg_color_idx]; // We don't use GetColorU32() because bg_alpha is assigned (not multiplied) below
|
ImVec4 bg_color = style.Colors[bg_color_idx]; // We don't use GetColorU32() because bg_alpha is assigned (not multiplied) below
|
||||||
if (bg_alpha >= 0.0f)
|
if (bg_alpha >= 0.0f)
|
||||||
bg_color.w = bg_alpha;
|
bg_color.w = bg_alpha;
|
||||||
@ -5151,8 +5161,7 @@ void ImGui::SetWindowSize(const ImVec2& size, ImGuiCond cond)
|
|||||||
|
|
||||||
void ImGui::SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond)
|
void ImGui::SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = FindWindowByName(name);
|
if (ImGuiWindow* window = FindWindowByName(name))
|
||||||
if (window)
|
|
||||||
SetWindowSize(window, size, cond);
|
SetWindowSize(window, size, cond);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -782,6 +782,8 @@ namespace ImGui
|
|||||||
IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled);
|
IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled);
|
||||||
IMGUI_API void PopItemFlag();
|
IMGUI_API void PopItemFlag();
|
||||||
|
|
||||||
|
IMGUI_API bool BeginEx(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha, ImGuiWindowFlags flags);
|
||||||
|
|
||||||
IMGUI_API void OpenPopupEx(ImGuiID id, bool reopen_existing);
|
IMGUI_API void OpenPopupEx(ImGuiID id, bool reopen_existing);
|
||||||
IMGUI_API void ClosePopup(ImGuiID id);
|
IMGUI_API void ClosePopup(ImGuiID id);
|
||||||
IMGUI_API bool IsPopupOpen(ImGuiID id);
|
IMGUI_API bool IsPopupOpen(ImGuiID id);
|
||||||
|
Loading…
Reference in New Issue
Block a user