Skip to content

Commit da3baeb

Browse files
committed
Fixed lower-right resize grip hit box not scaling along with its rendered size (ocornut#287)
1 parent 3ccbdc8 commit da3baeb

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

imgui.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3972,10 +3972,12 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
39723972
else
39733973
{
39743974
ImU32 resize_col = 0;
3975+
const float resize_corner_size = ImMax(g.FontSize * 1.35f, window_rounding + 1.0f + g.FontSize * 0.2f);
39753976
if (!(flags & ImGuiWindowFlags_AlwaysAutoResize) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0 && !(flags & ImGuiWindowFlags_NoResize))
39763977
{
39773978
// Manual resize
3978-
const ImRect resize_rect(window->Rect().GetBR()-ImVec2(14,14), window->Rect().GetBR());
3979+
const ImVec2 br = window->Rect().GetBR();
3980+
const ImRect resize_rect(br - ImVec2(resize_corner_size * 0.75f, resize_corner_size * 0.75f), br);
39793981
const ImGuiID resize_id = window->GetID("#RESIZE");
39803982
bool hovered, held;
39813983
ButtonBehavior(resize_rect, resize_id, &hovered, &held, true, ImGuiButtonFlags_FlattenChilds);
@@ -4049,12 +4051,9 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
40494051
// (after the input handling so we don't have a frame of latency)
40504052
if (!(flags & ImGuiWindowFlags_NoResize))
40514053
{
4052-
const float base_size = g.FontSize * 1.35f;
4053-
const float min_size = window_rounding + 1.0f + g.FontSize * 0.2f;
4054-
const float corner_size = ImMax(base_size, min_size);
40554054
const ImVec2 br = window->Rect().GetBR();
4056-
window->DrawList->PathLineTo(br + ImVec2(-corner_size, 0.0f));
4057-
window->DrawList->PathLineTo(br + ImVec2(0.0f, -corner_size));
4055+
window->DrawList->PathLineTo(br + ImVec2(-resize_corner_size, 0.0f));
4056+
window->DrawList->PathLineTo(br + ImVec2(0.0f, -resize_corner_size));
40584057
window->DrawList->PathArcToFast(ImVec2(br.x - window_rounding, br.y - window_rounding), window_rounding, 0, 3);
40594058
window->DrawList->PathFill(resize_col);
40604059
}

0 commit comments

Comments
 (0)