mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Begin: Marked 5 parameters version of Begin() as obsolete. Now waiting for a riot to happen!
This commit is contained in:
52
imgui.cpp
52
imgui.cpp
@ -204,6 +204,7 @@
|
||||
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
|
||||
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2017/10/17 (1.52) - marked the old 5-parameters version of Begin() as obsolete (still available). Use SetNextWindowSize()+Begin() instead!
|
||||
- 2017/10/11 (1.52) - renamed AlignFirstTextHeightToWidgets() to AlignTextToFramePadding(). Kept inline redirection function (will obsolete).
|
||||
- 2017/09/25 (1.52) - removed SetNextWindowPosCenter() because SetNextWindowPos() now has the optional pivot information to do the same and more. Kept redirection function (will obsolete).
|
||||
- 2017/08/25 (1.52) - io.MousePos needs to be set to ImVec2(-FLT_MAX,-FLT_MAX) when mouse is unavailable/missing. Previously ImVec2(-1,-1) was enough but we now accept negative mouse coordinates. In your binding if you need to support unavailable mouse, make sure to replace "io.MousePos = ImVec2(-1,-1)" with "io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX)".
|
||||
@ -4022,31 +4023,6 @@ static ImGuiCol GetWindowBgColorIdxFromFlags(ImGuiWindowFlags flags)
|
||||
return ImGuiCol_WindowBg;
|
||||
}
|
||||
|
||||
// FIXME-OBSOLETE: Old Begin() API, avoid calling this version directly!
|
||||
bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha_override, ImGuiWindowFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
||||
// Old API feature: we could pass the initial window size as a parameter, however this was very misleading because in most cases it would only affect the window when it didn't have storage in the .ini file.
|
||||
if (size_on_first_use.x != 0.0f || size_on_first_use.y != 0.0f)
|
||||
SetNextWindowSize(size_on_first_use, ImGuiCond_FirstUseEver);
|
||||
|
||||
// Old API feature: we could override the window background alpha with a parameter. This is actually tricky to reproduce manually because:
|
||||
// (1) there are multiple variants of WindowBg (popup, tooltip, etc.) and (2) you can't call PushStyleColor before Begin and PopStyleColor just after Begin() because of how CheckStackSizes() behave.
|
||||
// The user-side solution is to do backup = GetStyleColorVec4(ImGuiCol_xxxBG), PushStyleColor(ImGuiCol_xxxBg), Begin, PushStyleColor(ImGuiCol_xxxBg, backup), [...], PopStyleColor(), End(); PopStyleColor() - which is super awkward.
|
||||
// The alpha override was rarely used but for now we'll leave the Begin() variant around for a bit. We may either lift the constraint on CheckStackSizes() either add a SetNextWindowBgAlpha() helper that does it magically.
|
||||
const ImGuiCol bg_color_idx = GetWindowBgColorIdxFromFlags(flags);
|
||||
const ImVec4 bg_color_backup = g.Style.Colors[bg_color_idx];
|
||||
if (bg_alpha_override >= 0.0f)
|
||||
g.Style.Colors[bg_color_idx].w = bg_alpha_override;
|
||||
|
||||
bool ret = Begin(name, p_open, flags);
|
||||
|
||||
if (bg_alpha_override >= 0.0f)
|
||||
g.Style.Colors[bg_color_idx] = bg_color_backup;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// 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.
|
||||
// - Begin/End can be called multiple times during the frame with the same window name to append content.
|
||||
@ -4589,6 +4565,32 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
return !window->SkipItems;
|
||||
}
|
||||
|
||||
// Old Begin() API with 5 parameters, avoid calling this version directly! Use SetNextWindowSize()+Begin() instead.
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha_override, ImGuiWindowFlags flags)
|
||||
{
|
||||
// Old API feature: we could pass the initial window size as a parameter, however this was very misleading because in most cases it would only affect the window when it didn't have storage in the .ini file.
|
||||
if (size_on_first_use.x != 0.0f || size_on_first_use.y != 0.0f)
|
||||
SetNextWindowSize(size_on_first_use, ImGuiCond_FirstUseEver);
|
||||
|
||||
// Old API feature: we could override the window background alpha with a parameter. This is actually tricky to reproduce manually because:
|
||||
// (1) there are multiple variants of WindowBg (popup, tooltip, etc.) and (2) you can't call PushStyleColor before Begin and PopStyleColor just after Begin() because of how CheckStackSizes() behave.
|
||||
// The user-side solution is to do backup = GetStyleColorVec4(ImGuiCol_xxxBG), PushStyleColor(ImGuiCol_xxxBg), Begin, PushStyleColor(ImGuiCol_xxxBg, backup), [...], PopStyleColor(), End(); PopStyleColor() - which is super awkward.
|
||||
// The alpha override was rarely used but for now we'll leave the Begin() variant around for a bit. We may either lift the constraint on CheckStackSizes() either add a SetNextWindowBgAlpha() helper that does it magically.
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiCol bg_color_idx = GetWindowBgColorIdxFromFlags(flags);
|
||||
const ImVec4 bg_color_backup = g.Style.Colors[bg_color_idx];
|
||||
if (bg_alpha_override >= 0.0f)
|
||||
g.Style.Colors[bg_color_idx].w = bg_alpha_override;
|
||||
|
||||
bool ret = Begin(name, p_open, flags);
|
||||
|
||||
if (bg_alpha_override >= 0.0f)
|
||||
g.Style.Colors[bg_color_idx] = bg_color_backup;
|
||||
return ret;
|
||||
}
|
||||
#endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
|
||||
void ImGui::End()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
Reference in New Issue
Block a user