|
|
@@ -647,7 +647,6 @@
|
|
|
static bool IsKeyPressedMap(ImGuiKey key, bool repeat = true);
|
|
|
|
|
|
static ImFont* GetDefaultFont();
|
|
|
-static void SetCurrentFont(ImFont* font);
|
|
|
static void SetCurrentWindow(ImGuiWindow* window);
|
|
|
static void SetWindowScrollX(ImGuiWindow* window, float new_scroll_x);
|
|
|
static void SetWindowScrollY(ImGuiWindow* window, float new_scroll_y);
|
|
|
@@ -4807,8 +4806,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- // Window background, Default Alpha
|
|
|
+ // Window background
|
|
|
ImU32 bg_col = GetColorU32(GetWindowBgColorIdxFromFlags(flags));
|
|
|
+ if (g.NextWindowData.BgAlphaCond != 0)
|
|
|
+ bg_col = (bg_col & ~IM_COL32_A_MASK) | (IM_F32_TO_INT8_SAT(g.NextWindowData.BgAlphaVal) << IM_COL32_A_SHIFT);
|
|
|
window->DrawList->AddRectFilled(window->Pos+ImVec2(0,window->TitleBarHeight()), window->Pos+window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Bot);
|
|
|
|
|
|
// Title bar
|
|
|
@@ -5008,29 +5009,18 @@ 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.
|
|
|
+// Old Begin() API with 5 parameters, avoid calling this version directly! Use SetNextWindowSize()/SetNextWindowBgAlpha() + 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)
|
|
|
+bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_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 pass the initial window size as a parameter. This was misleading because it only had an effect if the window didn't have data in the .ini file.
|
|
|
+ if (size_first_use.x != 0.0f || size_first_use.y != 0.0f)
|
|
|
+ ImGui::SetNextWindowSize(size_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);
|
|
|
+ // Old API feature: override the window background alpha with a parameter.
|
|
|
+ ImGui::SetNextWindowBgAlpha(bg_alpha_override);
|
|
|
|
|
|
- if (bg_alpha_override >= 0.0f)
|
|
|
- g.Style.Colors[bg_color_idx] = bg_color_backup;
|
|
|
- return ret;
|
|
|
+ return ImGui::Begin(name, p_open, flags);
|
|
|
}
|
|
|
#endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
|
|
|
|
|
@@ -5279,7 +5269,7 @@ static ImFont* GetDefaultFont()
|
|
|
return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0];
|
|
|
}
|
|
|
|
|
|
-static void SetCurrentFont(ImFont* font)
|
|
|
+void ImGui::SetCurrentFont(ImFont* font)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
IM_ASSERT(font && font->IsLoaded()); // Font Atlas not created. Did you call io.Fonts->GetTexDataAsRGBA32 / GetTexDataAsAlpha8 ?
|
|
|
@@ -5403,13 +5393,14 @@ struct ImGuiStyleVarInfo
|
|
|
void* GetVarPtr(ImGuiStyle* style) const { return (void*)((unsigned char*)style + Offset); }
|
|
|
};
|
|
|
|
|
|
-static const ImGuiStyleVarInfo GStyleVarInfo[ImGuiStyleVar_Count_] =
|
|
|
+static const ImGuiStyleVarInfo GStyleVarInfo[] =
|
|
|
{
|
|
|
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, Alpha) }, // ImGuiStyleVar_Alpha
|
|
|
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding
|
|
|
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowRounding) }, // ImGuiStyleVar_WindowRounding
|
|
|
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowBorderSize) }, // ImGuiStyleVar_WindowBorderSize
|
|
|
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowMinSize) }, // ImGuiStyleVar_WindowMinSize
|
|
|
+ { ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowTitleAlign) }, // ImGuiStyleVar_WindowTitleAlign
|
|
|
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildRounding) }, // ImGuiStyleVar_ChildRounding
|
|
|
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildBorderSize) }, // ImGuiStyleVar_ChildBorderSize
|
|
|
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupRounding) }, // ImGuiStyleVar_PopupRounding
|
|
|
@@ -5420,7 +5411,10 @@ static const ImGuiStyleVarInfo GStyleVarInfo[ImGuiStyleVar_Count_] =
|
|
|
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing
|
|
|
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing
|
|
|
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing) }, // ImGuiStyleVar_IndentSpacing
|
|
|
+ { ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarSize) }, // ImGuiStyleVar_ScrollbarSize
|
|
|
+ { ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarRounding) }, // ImGuiStyleVar_ScrollbarRounding
|
|
|
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize
|
|
|
+ { ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding
|
|
|
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign
|
|
|
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ViewId) },
|
|
|
};
|
|
|
@@ -5428,6 +5422,7 @@ static const ImGuiStyleVarInfo GStyleVarInfo[ImGuiStyleVar_Count_] =
|
|
|
static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx)
|
|
|
{
|
|
|
IM_ASSERT(idx >= 0 && idx < ImGuiStyleVar_Count_);
|
|
|
+ IM_ASSERT(IM_ARRAYSIZE(GStyleVarInfo) == ImGuiStyleVar_Count_);
|
|
|
return &GStyleVarInfo[idx];
|
|
|
}
|
|
|
|
|
|
@@ -5803,7 +5798,14 @@ void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond)
|
|
|
void ImGui::SetNextWindowFocus()
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
- g.NextWindowData.FocusCond = ImGuiCond_Always;
|
|
|
+ g.NextWindowData.FocusCond = ImGuiCond_Always; // Using a Cond member for consistency (may transition all of them to single flag set for fast Clear() op)
|
|
|
+}
|
|
|
+
|
|
|
+void ImGui::SetNextWindowBgAlpha(float alpha)
|
|
|
+{
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+ g.NextWindowData.BgAlphaVal = alpha;
|
|
|
+ g.NextWindowData.BgAlphaCond = ImGuiCond_Always; // Using a Cond member for consistency (may transition all of them to single flag set for fast Clear() op)
|
|
|
}
|
|
|
|
|
|
// In window space (not screen space!)
|