Skip to content

Commit 5e9ae92

Browse files
committed
Begin: Handle manual resize (grip, border, gamepad) before setting up window DrawList main clipping rectangle. Sane (and required for viewport code). (#822, #1542)
1 parent 6a1011c commit 5e9ae92

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

imgui.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ static bool DataTypeApplyOpFromText(const char* buf, const char* ini
677677

678678
namespace ImGui
679679
{
680-
static void UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, ImU32 resize_grip_col[4]);
680+
static void UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]);
681681
static void FocusFrontMostActiveWindow(ImGuiWindow* ignore_window);
682682
}
683683

@@ -4338,14 +4338,13 @@ static ImRect GetBorderRect(ImGuiWindow* window, int border_n, float perp_paddin
43384338
}
43394339

43404340
// Handle resize for: Resize Grips, Borders, Gamepad
4341-
static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, ImU32 resize_grip_col[4])
4341+
static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4])
43424342
{
43434343
ImGuiContext& g = *GImGui;
43444344
ImGuiWindowFlags flags = window->Flags;
43454345
if ((flags & ImGuiWindowFlags_NoResize) || (flags & ImGuiWindowFlags_AlwaysAutoResize) || window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0)
43464346
return;
43474347

4348-
const int resize_grip_count = (flags & ImGuiWindowFlags_ResizeFromAnySide) ? 2 : 1; // 4
43494348
const int resize_border_count = (flags & ImGuiWindowFlags_ResizeFromAnySide) ? 4 : 0;
43504349
const float grip_draw_size = (float)(int)ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f);
43514350
const float grip_hover_size = (float)(int)(grip_draw_size * 0.75f);
@@ -4746,6 +4745,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
47464745
if (!(flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Tooltip)) || (flags & ImGuiWindowFlags_Popup))
47474746
want_focus = true;
47484747

4748+
// Handle manual resize: Resize Grips, Borders, Gamepad
4749+
int border_held = -1;
4750+
ImU32 resize_grip_col[4] = { 0 };
4751+
const int resize_grip_count = (flags & ImGuiWindowFlags_ResizeFromAnySide) ? 2 : 1; // 4
4752+
const float grip_draw_size = (float)(int)ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f);
4753+
UpdateManualResize(window, size_auto_fit, &border_held, resize_grip_count, &resize_grip_col[0]);
4754+
47494755
// DRAWING
47504756

47514757
// Setup draw list and outer clipping rectangle
@@ -4776,14 +4782,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
47764782
}
47774783
else
47784784
{
4779-
// Handle resize for: Resize Grips, Borders, Gamepad
4780-
int border_held = -1;
4781-
ImU32 resize_grip_col[4] = { 0 };
4782-
const int resize_grip_count = (flags & ImGuiWindowFlags_ResizeFromAnySide) ? 2 : 1; // 4
4783-
const float grip_draw_size = (float)(int)ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f);
4784-
UpdateManualResize(window, size_auto_fit, &border_held, &resize_grip_col[0]);
4785-
title_bar_rect = window->TitleBarRect();
4786-
47874785
// Window background, Default Alpha
47884786
ImU32 bg_col = GetColorU32(GetWindowBgColorIdxFromFlags(flags));
47894787
window->DrawList->AddRectFilled(window->Pos+ImVec2(0,window->TitleBarHeight()), window->Pos+window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Bot);

0 commit comments

Comments
 (0)