mirror of https://github.com/ocornut/imgui
Style: removed WindowFillAlphaDefault which was confusing and redundant, baked into WindowBg color. Renamed TooltipBg > PopupBG. (#337)
bg_alpha parameter of 5-parameters version of Begin() is an override, however that function may become obsolete someday.
This commit is contained in:
parent
947171dcef
commit
e808b7cfca
55
imgui.cpp
55
imgui.cpp
|
@ -152,6 +152,8 @@
|
|||
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.
|
||||
|
||||
- 2016/04/03 (1.48) - removed style.WindowFillAlphaDefault setting which was redundant. Bake default BG alpha inside style.Colors[ImGuiCol_WindowBg] and all other Bg color values. (ref github issue #337).
|
||||
- 2016/04/03 (1.48) - renamed ImGuiCol_TooltipBg to ImGuiCol_PopupBg, used by popups/menus and tooltips. popups/menus were previously using ImGuiCol_WindowBg. (ref github issue #337)
|
||||
- 2016/03/21 (1.48) - renamed GetWindowFont() to GetFont(), GetWindowFontSize() to GetFontSize(). Kept inline redirection function (will obsolete).
|
||||
- 2016/03/02 (1.48) - InputText() completion/history/always callbacks: if you modify the text buffer manually (without using DeleteChars()/InsertChars() helper) you need to maintain the BufTextLen field. added an assert.
|
||||
- 2016/01/23 (1.48) - fixed not honoring exact width passed to PushItemWidth(), previously it would add extra FramePadding.x*2 over that width. if you had manual pixel-perfect alignment in place it might affect you.
|
||||
|
@ -699,7 +701,6 @@ ImGuiStyle::ImGuiStyle()
|
|||
ItemSpacing = ImVec2(8,4); // Horizontal and vertical spacing between widgets/lines
|
||||
ItemInnerSpacing = ImVec2(4,4); // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
|
||||
TouchExtraPadding = ImVec2(0,0); // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much!
|
||||
WindowFillAlphaDefault = 0.70f; // Default alpha of window background, if not specified in ImGui::Begin()
|
||||
IndentSpacing = 22.0f; // Horizontal spacing when e.g. entering a tree node
|
||||
ColumnsMinSpacing = 6.0f; // Minimum horizontal spacing between two columns
|
||||
ScrollbarSize = 16.0f; // Width of the vertical scrollbar, Height of the horizontal scrollbar
|
||||
|
@ -714,8 +715,9 @@ ImGuiStyle::ImGuiStyle()
|
|||
|
||||
Colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
|
||||
Colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
|
||||
Colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
|
||||
Colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.70f);
|
||||
Colors[ImGuiCol_ChildWindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
Colors[ImGuiCol_PopupBg] = ImVec4(0.05f, 0.05f, 0.10f, 0.90f);
|
||||
Colors[ImGuiCol_Border] = ImVec4(0.70f, 0.70f, 0.70f, 0.65f);
|
||||
Colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
Colors[ImGuiCol_FrameBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.30f); // Background of checkbox, radio button, plot, slider, text input
|
||||
|
@ -753,7 +755,6 @@ ImGuiStyle::ImGuiStyle()
|
|||
Colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||
Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
|
||||
Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f);
|
||||
Colors[ImGuiCol_TooltipBg] = ImVec4(0.05f, 0.05f, 0.10f, 0.90f);
|
||||
Colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
|
||||
}
|
||||
|
||||
|
@ -3138,9 +3139,8 @@ static ImRect GetVisibleRect()
|
|||
|
||||
void ImGui::BeginTooltip()
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_AlwaysAutoResize;
|
||||
ImGui::Begin("##Tooltip", NULL, ImVec2(0,0), g.Style.Colors[ImGuiCol_TooltipBg].w, flags);
|
||||
ImGui::Begin("##Tooltip", NULL, flags);
|
||||
}
|
||||
|
||||
void ImGui::EndTooltip()
|
||||
|
@ -3278,9 +3278,8 @@ static bool BeginPopupEx(const char* str_id, ImGuiWindowFlags extra_flags)
|
|||
ImFormatString(name, 20, "##menu_%d", g.CurrentPopupStack.Size); // Recycle windows based on depth
|
||||
else
|
||||
ImFormatString(name, 20, "##popup_%08x", id); // Not recycling, so we can close/open during the same frame
|
||||
float alpha = 1.0f;
|
||||
|
||||
bool opened = ImGui::Begin(name, NULL, ImVec2(0.0f, 0.0f), alpha, flags);
|
||||
bool opened = ImGui::Begin(name, NULL, flags);
|
||||
if (!(window->Flags & ImGuiWindowFlags_ShowBorders))
|
||||
g.CurrentWindow->Flags &= ~ImGuiWindowFlags_ShowBorders;
|
||||
if (!opened) // opened can be 'false' when the popup is completely clipped (e.g. zero size display)
|
||||
|
@ -3311,7 +3310,7 @@ bool ImGui::BeginPopupModal(const char* name, bool* p_opened, ImGuiWindowFlags e
|
|||
}
|
||||
|
||||
ImGuiWindowFlags flags = extra_flags|ImGuiWindowFlags_Popup|ImGuiWindowFlags_Modal|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoSavedSettings;
|
||||
bool opened = ImGui::Begin(name, p_opened, ImVec2(0.0f, 0.0f), -1.0f, flags);
|
||||
bool opened = ImGui::Begin(name, p_opened, flags);
|
||||
if (!opened || (p_opened && !*p_opened)) // Opened can be 'false' when the popup is completely clipped (e.g. zero size display)
|
||||
{
|
||||
ImGui::EndPopup();
|
||||
|
@ -3391,8 +3390,7 @@ bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border,
|
|||
char title[256];
|
||||
ImFormatString(title, IM_ARRAYSIZE(title), "%s.%s", window->Name, str_id);
|
||||
|
||||
const float alpha = 1.0f;
|
||||
bool ret = ImGui::Begin(title, NULL, size, alpha, flags);
|
||||
bool ret = ImGui::Begin(title, NULL, size, -1.0f, flags);
|
||||
|
||||
if (!(window->Flags & ImGuiWindowFlags_ShowBorders))
|
||||
GetCurrentWindow()->Flags &= ~ImGuiWindowFlags_ShowBorders;
|
||||
|
@ -3692,10 +3690,6 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
|
|||
window->RootWindow = g.CurrentWindowStack[root_idx];
|
||||
window->RootNonPopupWindow = g.CurrentWindowStack[root_non_popup_idx]; // This is merely for displaying the TitleBgActive color.
|
||||
|
||||
// Default alpha
|
||||
if (bg_alpha < 0.0f)
|
||||
bg_alpha = style.WindowFillAlphaDefault;
|
||||
|
||||
// When reusing window again multiple times a frame, just append content (don't need to setup again)
|
||||
if (first_begin_of_the_frame)
|
||||
{
|
||||
|
@ -3987,21 +3981,20 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
|
|||
window->BorderSize = (flags & ImGuiWindowFlags_ShowBorders) ? 1.0f : 0.0f;
|
||||
|
||||
// Window background
|
||||
if (bg_alpha > 0.0f)
|
||||
{
|
||||
ImGuiCol col_idx;
|
||||
if ((flags & ImGuiWindowFlags_ComboBox) != 0)
|
||||
col_idx = ImGuiCol_ComboBg;
|
||||
else if ((flags & ImGuiWindowFlags_Tooltip) != 0)
|
||||
col_idx = ImGuiCol_TooltipBg;
|
||||
else if ((flags & ImGuiWindowFlags_Popup) != 0)
|
||||
col_idx = ImGuiCol_WindowBg;
|
||||
else if ((flags & ImGuiWindowFlags_ChildWindow) != 0)
|
||||
col_idx = ImGuiCol_ChildWindowBg;
|
||||
else
|
||||
col_idx = ImGuiCol_WindowBg;
|
||||
window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, GetColorU32(col_idx, bg_alpha), window_rounding);
|
||||
}
|
||||
// Default alpha
|
||||
ImGuiCol bg_color_idx = ImGuiCol_WindowBg;
|
||||
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];
|
||||
if (bg_alpha >= 0.0f)
|
||||
bg_color.w = bg_alpha;
|
||||
bg_color.w *= style.Alpha;
|
||||
if (bg_color.w > 0.0f)
|
||||
window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, ColorConvertFloat4ToU32(bg_color), window_rounding);
|
||||
|
||||
// Title bar
|
||||
if (!(flags & ImGuiWindowFlags_NoTitleBar))
|
||||
|
@ -4522,6 +4515,7 @@ const char* ImGui::GetStyleColName(ImGuiCol idx)
|
|||
case ImGuiCol_TextDisabled: return "TextDisabled";
|
||||
case ImGuiCol_WindowBg: return "WindowBg";
|
||||
case ImGuiCol_ChildWindowBg: return "ChildWindowBg";
|
||||
case ImGuiCol_PopupBg: return "PopupBg";
|
||||
case ImGuiCol_Border: return "Border";
|
||||
case ImGuiCol_BorderShadow: return "BorderShadow";
|
||||
case ImGuiCol_FrameBg: return "FrameBg";
|
||||
|
@ -4559,7 +4553,6 @@ const char* ImGui::GetStyleColName(ImGuiCol idx)
|
|||
case ImGuiCol_PlotHistogram: return "PlotHistogram";
|
||||
case ImGuiCol_PlotHistogramHovered: return "PlotHistogramHovered";
|
||||
case ImGuiCol_TextSelectedBg: return "TextSelectedBg";
|
||||
case ImGuiCol_TooltipBg: return "TooltipBg";
|
||||
case ImGuiCol_ModalWindowDarkening: return "ModalWindowDarkening";
|
||||
}
|
||||
IM_ASSERT(0);
|
||||
|
@ -8501,7 +8494,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
|||
bool want_open = false, want_close = false;
|
||||
if (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu))
|
||||
{
|
||||
// Implement http://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown to avoid using timers so menus feel more reactive.
|
||||
// Implement http://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown to avoid using timers, so menus feels more reactive.
|
||||
bool moving_within_opened_triangle = false;
|
||||
if (g.HoveredWindow == window && g.OpenedPopupStack.Size > g.CurrentPopupStack.Size && g.OpenedPopupStack[g.CurrentPopupStack.Size].ParentWindow == window)
|
||||
{
|
||||
|
|
9
imgui.h
9
imgui.h
|
@ -114,7 +114,7 @@ namespace ImGui
|
|||
|
||||
// Window
|
||||
IMGUI_API bool Begin(const char* name, bool* p_opened = NULL, ImGuiWindowFlags flags = 0); // push window to the stack and start appending to it. see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_opened' creates a widget on the upper-right to close the window (which sets your bool to false).
|
||||
IMGUI_API bool Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_use, float bg_alpha = -1.0f, ImGuiWindowFlags flags = 0); // ". this is the older/longer API. the extra parameters aren't very relevant. call SetNextWindowSize() instead if you want to set a window size. For regular windows, 'size_on_first_use' only applies to the first time EVER the window is created and probably not what you want! might obsolete this API eventually.
|
||||
IMGUI_API bool Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_use, float bg_alpha = -1.0f, ImGuiWindowFlags flags = 0); // OBSOLETE. this is the older/longer API. the extra parameters aren't very relevant. call SetNextWindowSize() instead if you want to set a window size. For regular windows, 'size_on_first_use' only applies to the first time EVER the window is created and probably not what you want! might obsolete this API eventually.
|
||||
IMGUI_API void End(); // finish appending to current window, pop it off the window stack.
|
||||
IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // begin a scrolling region. size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). size>0.0f: fixed size. each axis can use a different mode, e.g. ImVec2(0,400).
|
||||
IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // "
|
||||
|
@ -546,8 +546,9 @@ enum ImGuiCol_
|
|||
{
|
||||
ImGuiCol_Text,
|
||||
ImGuiCol_TextDisabled,
|
||||
ImGuiCol_WindowBg,
|
||||
ImGuiCol_ChildWindowBg,
|
||||
ImGuiCol_WindowBg, // Background of normal windows
|
||||
ImGuiCol_ChildWindowBg, // Background of child windows
|
||||
ImGuiCol_PopupBg, // Background of popups, menus, tooltips windows
|
||||
ImGuiCol_Border,
|
||||
ImGuiCol_BorderShadow,
|
||||
ImGuiCol_FrameBg, // Background of checkbox, radio button, plot, slider, text input
|
||||
|
@ -585,7 +586,6 @@ enum ImGuiCol_
|
|||
ImGuiCol_PlotHistogram,
|
||||
ImGuiCol_PlotHistogramHovered,
|
||||
ImGuiCol_TextSelectedBg,
|
||||
ImGuiCol_TooltipBg,
|
||||
ImGuiCol_ModalWindowDarkening, // darken entire screen when a modal window is active
|
||||
ImGuiCol_COUNT
|
||||
};
|
||||
|
@ -663,7 +663,6 @@ struct ImGuiStyle
|
|||
ImVec2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines
|
||||
ImVec2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
|
||||
ImVec2 TouchExtraPadding; // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much!
|
||||
float WindowFillAlphaDefault; // Default alpha of window background, if not specified in ImGui::Begin()
|
||||
float IndentSpacing; // Horizontal indentation when e.g. entering a tree node
|
||||
float ColumnsMinSpacing; // Minimum horizontal spacing between two columns
|
||||
float ScrollbarSize; // Width of the vertical scrollbar, Height of the horizontal scrollbar
|
||||
|
|
|
@ -139,7 +139,6 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
|||
static bool no_scrollbar = false;
|
||||
static bool no_collapse = false;
|
||||
static bool no_menu = false;
|
||||
static float bg_alpha = -0.01f; // <0: default
|
||||
|
||||
// Demonstrate the various window flags. Typically you would just use the default.
|
||||
ImGuiWindowFlags window_flags = 0;
|
||||
|
@ -150,7 +149,8 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
|||
if (no_scrollbar) window_flags |= ImGuiWindowFlags_NoScrollbar;
|
||||
if (no_collapse) window_flags |= ImGuiWindowFlags_NoCollapse;
|
||||
if (!no_menu) window_flags |= ImGuiWindowFlags_MenuBar;
|
||||
if (!ImGui::Begin("ImGui Demo", p_opened, ImVec2(550,680), bg_alpha, window_flags))
|
||||
ImGui::SetNextWindowSize(ImVec2(550,680), ImGuiSetCond_FirstUseEver);
|
||||
if (!ImGui::Begin("ImGui Demo", p_opened, window_flags))
|
||||
{
|
||||
// Early out if the window is collapsed, as an optimization.
|
||||
ImGui::End();
|
||||
|
@ -211,10 +211,6 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
|||
ImGui::Checkbox("No collapse", &no_collapse);
|
||||
ImGui::Checkbox("No menu", &no_menu);
|
||||
|
||||
ImGui::PushItemWidth(100);
|
||||
ImGui::DragFloat("Window Fill Alpha", &bg_alpha, 0.005f, -0.01f, 1.0f, bg_alpha < 0.0f ? "(default)" : "%.3f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero.
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
if (ImGui::TreeNode("Style"))
|
||||
{
|
||||
ImGui::ShowStyleEditor();
|
||||
|
@ -1561,7 +1557,6 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||
ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, FLT_MAX, NULL, 2.0f);
|
||||
if (style.CurveTessellationTol < 0.0f) style.CurveTessellationTol = 0.10f;
|
||||
ImGui::DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero.
|
||||
ImGui::DragFloat("Window Fill Alpha Default", &style.WindowFillAlphaDefault, 0.005f, 0.0f, 1.0f, "%.2f");
|
||||
ImGui::PopItemWidth();
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
@ -1618,7 +1613,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||
static ImGuiTextFilter filter;
|
||||
filter.Draw("Filter colors", 200);
|
||||
|
||||
ImGui::BeginChild("#colors", ImVec2(0, 300), true);
|
||||
ImGui::BeginChild("#colors", ImVec2(0, 300), true, ImGuiWindowFlags_AlwaysVerticalScrollbar);
|
||||
ImGui::PushItemWidth(-160);
|
||||
ImGui::ColorEditMode(edit_mode);
|
||||
for (int i = 0; i < ImGuiCol_COUNT; i++)
|
||||
|
|
Loading…
Reference in New Issue