Skip to content

Commit 1810b3f

Browse files
committed
Added ImGuiCorner enum to clarify some internal code
1 parent d567595 commit 1810b3f

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

imgui.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4192,8 +4192,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
41924192
window->ScrollbarSizes = ImVec2(window->ScrollbarY ? style.ScrollbarSize : 0.0f, window->ScrollbarX ? style.ScrollbarSize : 0.0f);
41934193
window->BorderSize = (flags & ImGuiWindowFlags_ShowBorders) ? 1.0f : 0.0f;
41944194

4195-
// Window background
4196-
// Default alpha
4195+
// Window background, Default Alpha
41974196
ImGuiCol bg_color_idx = ImGuiCol_WindowBg;
41984197
if ((flags & ImGuiWindowFlags_ComboBox) != 0)
41994198
bg_color_idx = ImGuiCol_ComboBg;
@@ -4206,19 +4205,19 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
42064205
bg_color.w = bg_alpha;
42074206
bg_color.w *= style.Alpha;
42084207
if (bg_color.w > 0.0f)
4209-
window->DrawList->AddRectFilled(window->Pos+ImVec2(0,window->TitleBarHeight()), window->Pos+window->Size, ColorConvertFloat4ToU32(bg_color), window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? 15 : 4|8);
4208+
window->DrawList->AddRectFilled(window->Pos+ImVec2(0,window->TitleBarHeight()), window->Pos+window->Size, ColorConvertFloat4ToU32(bg_color), window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? ImGuiCorner_All : ImGuiCorner_BottomLeft|ImGuiCorner_BottomRight);
42104209

42114210
// Title bar
42124211
if (!(flags & ImGuiWindowFlags_NoTitleBar))
4213-
window->DrawList->AddRectFilled(title_bar_rect.GetTL(), title_bar_rect.GetBR(), GetColorU32((g.FocusedWindow && window->RootNonPopupWindow == g.FocusedWindow->RootNonPopupWindow) ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg), window_rounding, 1|2);
4212+
window->DrawList->AddRectFilled(title_bar_rect.GetTL(), title_bar_rect.GetBR(), GetColorU32((g.FocusedWindow && window->RootNonPopupWindow == g.FocusedWindow->RootNonPopupWindow) ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg), window_rounding, ImGuiCorner_TopLeft|ImGuiCorner_TopRight);
42144213

42154214
// Menu bar
42164215
if (flags & ImGuiWindowFlags_MenuBar)
42174216
{
42184217
ImRect menu_bar_rect = window->MenuBarRect();
4219-
window->DrawList->AddRectFilled(menu_bar_rect.GetTL(), menu_bar_rect.GetBR(), GetColorU32(ImGuiCol_MenuBarBg), (flags & ImGuiWindowFlags_NoTitleBar) ? window_rounding : 0.0f, 1|2);
42204218
if (flags & ImGuiWindowFlags_ShowBorders)
42214219
window->DrawList->AddLine(menu_bar_rect.GetBL()-ImVec2(0,0), menu_bar_rect.GetBR()-ImVec2(0,0), GetColorU32(ImGuiCol_Border));
4220+
window->DrawList->AddRectFilled(menu_bar_rect.GetTL(), menu_bar_rect.GetBR(), GetColorU32(ImGuiCol_MenuBarBg), (flags & ImGuiWindowFlags_NoTitleBar) ? window_rounding : 0.0f, ImGuiCorner_TopLeft|ImGuiCorner_TopRight);
42224221
}
42234222

42244223
// Scrollbars
@@ -4426,9 +4425,9 @@ static void Scrollbar(ImGuiWindow* window, bool horizontal)
44264425
float window_rounding = (window->Flags & ImGuiWindowFlags_ChildWindow) ? style.ChildWindowRounding : style.WindowRounding;
44274426
int window_rounding_corners;
44284427
if (horizontal)
4429-
window_rounding_corners = 8 | (other_scrollbar ? 0 : 4);
4428+
window_rounding_corners = ImGuiCorner_BottomLeft | (other_scrollbar ? 0 : ImGuiCorner_BottomRight);
44304429
else
4431-
window_rounding_corners = (((window->Flags & ImGuiWindowFlags_NoTitleBar) && !(window->Flags & ImGuiWindowFlags_MenuBar)) ? 2 : 0) | (other_scrollbar ? 0 : 4);
4430+
window_rounding_corners = (((window->Flags & ImGuiWindowFlags_NoTitleBar) && !(window->Flags & ImGuiWindowFlags_MenuBar)) ? ImGuiCorner_TopRight : 0) | (other_scrollbar ? 0 : ImGuiCorner_BottomRight);
44324431
window->DrawList->AddRectFilled(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_ScrollbarBg), window_rounding, window_rounding_corners);
44334432
bb.Reduce(ImVec2(ImClamp((float)(int)((bb.Max.x - bb.Min.x - 2.0f) * 0.5f), 0.0f, 3.0f), ImClamp((float)(int)((bb.Max.y - bb.Min.y - 2.0f) * 0.5f), 0.0f, 3.0f)));
44344433

imgui_internal.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,15 @@ enum ImGuiDataType
197197
ImGuiDataType_Float2,
198198
};
199199

200+
enum ImGuiCorner
201+
{
202+
ImGuiCorner_TopLeft = 1 << 0, // 1
203+
ImGuiCorner_TopRight = 1 << 1, // 2
204+
ImGuiCorner_BottomRight = 1 << 2, // 4
205+
ImGuiCorner_BottomLeft = 1 << 3, // 8
206+
ImGuiCorner_All = 0x0F
207+
};
208+
200209
// 2D axis aligned bounding-box
201210
// NB: we can't rely on ImVec2 math operators being available here
202211
struct IMGUI_API ImRect

0 commit comments

Comments
 (0)