@@ -889,8 +889,12 @@ CODE
889
889
#endif
890
890
891
891
// When using CTRL+TAB (or Gamepad Square+L/R) we delay the visual a little in order to reduce visual noise doing a fast switch.
892
- static const float NAV_WINDOWING_HIGHLIGHT_DELAY = 0 .20f ; // Time before the highlight and screen dimming starts fading in
893
- static const float NAV_WINDOWING_LIST_APPEAR_DELAY = 0 .15f ; // Time before the window list starts to appear
892
+ static const float NAV_WINDOWING_HIGHLIGHT_DELAY = 0 .20f ; // Time before the highlight and screen dimming starts fading in
893
+ static const float NAV_WINDOWING_LIST_APPEAR_DELAY = 0 .15f ; // Time before the window list starts to appear
894
+
895
+ // Window resizing from edges (when io.ConfigResizeWindowsFromEdges = true)
896
+ static const float RESIZE_WINDOWS_FROM_EDGES_HALF_THICKNESS = 4 .0f ; // Extend outside and inside windows. Affect FindHoveredWindow().
897
+ static const float RESIZE_WINDOWS_FROM_EDGES_FEEDBACK_TIMER = 0 .04f ; // Reduce visual noise by only highlighting the border after a certain time.
894
898
895
899
// -------------------------------------------------------------------------
896
900
// [SECTION] FORWARD DECLARATIONS
@@ -3698,6 +3702,8 @@ static void FindHoveredWindow()
3698
3702
if (g.MovingWindow && !(g.MovingWindow ->Flags & ImGuiWindowFlags_NoInputs))
3699
3703
hovered_window = g.MovingWindow ;
3700
3704
3705
+ ImVec2 padding_regular = g.Style .TouchExtraPadding ;
3706
+ ImVec2 padding_for_resize_from_edges = g.IO .ConfigResizeWindowsFromEdges ? ImMax (g.Style .TouchExtraPadding , ImVec2 (RESIZE_WINDOWS_FROM_EDGES_HALF_THICKNESS, RESIZE_WINDOWS_FROM_EDGES_HALF_THICKNESS)) : padding_regular;
3701
3707
for (int i = g.Windows .Size - 1 ; i >= 0 && hovered_window == NULL ; i--)
3702
3708
{
3703
3709
ImGuiWindow* window = g.Windows [i];
@@ -3707,14 +3713,19 @@ static void FindHoveredWindow()
3707
3713
continue ;
3708
3714
3709
3715
// Using the clipped AABB, a child window will typically be clipped by its parent (not always)
3710
- ImRect bb (window->OuterRectClipped .Min - g.Style .TouchExtraPadding , window->OuterRectClipped .Max + g.Style .TouchExtraPadding );
3711
- if (bb.Contains (g.IO .MousePos ))
3712
- {
3713
- if (hovered_window == NULL )
3714
- hovered_window = window;
3715
- if (hovered_window)
3716
- break ;
3717
- }
3716
+ ImRect bb (window->OuterRectClipped );
3717
+ if ((window->Flags & ImGuiWindowFlags_ChildWindow) || (window->Flags & ImGuiWindowFlags_NoResize))
3718
+ bb.Expand (padding_regular);
3719
+ else
3720
+ bb.Expand (padding_for_resize_from_edges);
3721
+ if (!bb.Contains (g.IO .MousePos ))
3722
+ continue ;
3723
+
3724
+ // Those seemingly unnecessary extra tests are because the code here is a little different in viewport/docking branches.
3725
+ if (hovered_window == NULL )
3726
+ hovered_window = window;
3727
+ if (hovered_window)
3728
+ break ;
3718
3729
}
3719
3730
3720
3731
g.HoveredWindow = hovered_window;
@@ -4367,10 +4378,10 @@ static ImRect GetResizeBorderRect(ImGuiWindow* window, int border_n, float perp_
4367
4378
{
4368
4379
ImRect rect = window->Rect ();
4369
4380
if (thickness == 0 .0f ) rect.Max -= ImVec2 (1 ,1 );
4370
- if (border_n == 0 ) return ImRect (rect.Min .x + perp_padding, rect.Min .y , rect.Max .x - perp_padding, rect.Min .y + thickness);
4371
- if (border_n == 1 ) return ImRect (rect.Max .x - thickness, rect.Min .y + perp_padding, rect.Max .x , rect.Max .y - perp_padding);
4372
- if (border_n == 2 ) return ImRect (rect.Min .x + perp_padding, rect.Max .y - thickness, rect.Max .x - perp_padding, rect.Max .y );
4373
- if (border_n == 3 ) return ImRect (rect.Min .x , rect.Min .y + perp_padding, rect.Min .x + thickness, rect.Max .y - perp_padding);
4381
+ if (border_n == 0 ) return ImRect (rect.Min .x + perp_padding, rect.Min .y - thickness, rect.Max .x - perp_padding, rect.Min .y + thickness);
4382
+ if (border_n == 1 ) return ImRect (rect.Max .x - thickness, rect.Min .y + perp_padding, rect.Max .x + thickness, rect.Max .y - perp_padding);
4383
+ if (border_n == 2 ) return ImRect (rect.Min .x + perp_padding, rect.Max .y - thickness, rect.Max .x - perp_padding, rect.Max .y + thickness );
4384
+ if (border_n == 3 ) return ImRect (rect.Min .x - thickness, rect.Min .y + perp_padding, rect.Min .x + thickness, rect.Max .y - perp_padding);
4374
4385
IM_ASSERT (0 );
4375
4386
return ImRect ();
4376
4387
}
@@ -4382,10 +4393,13 @@ static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
4382
4393
ImGuiWindowFlags flags = window->Flags ;
4383
4394
if ((flags & ImGuiWindowFlags_NoResize) || (flags & ImGuiWindowFlags_AlwaysAutoResize) || window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0 )
4384
4395
return ;
4396
+ if (window->WasActive == false ) // Early out to avoid running this code for e.g. an hidden implicit Debug window.
4397
+ return ;
4385
4398
4386
4399
const int resize_border_count = g.IO .ConfigResizeWindowsFromEdges ? 4 : 0 ;
4387
4400
const float grip_draw_size = (float )(int )ImMax (g.FontSize * 1 .35f , window->WindowRounding + 1 .0f + g.FontSize * 0 .2f );
4388
- const float grip_hover_size = (float )(int )(grip_draw_size * 0 .75f );
4401
+ const float grip_hover_inner_size = (float )(int )(grip_draw_size * 0 .75f );
4402
+ const float grip_hover_outer_size = g.IO .ConfigResizeWindowsFromEdges ? RESIZE_WINDOWS_FROM_EDGES_HALF_THICKNESS : 0 .0f ;
4389
4403
4390
4404
ImVec2 pos_target (FLT_MAX, FLT_MAX);
4391
4405
ImVec2 size_target (FLT_MAX, FLT_MAX);
@@ -4398,11 +4412,12 @@ static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
4398
4412
const ImVec2 corner = ImLerp (window->Pos , window->Pos + window->Size , grip.CornerPos );
4399
4413
4400
4414
// Using the FlattenChilds button flag we make the resize button accessible even if we are hovering over a child window
4401
- ImRect resize_rect (corner, corner + grip.InnerDir * grip_hover_size );
4415
+ ImRect resize_rect (corner - grip. InnerDir * grip_hover_outer_size , corner + grip.InnerDir * grip_hover_inner_size );
4402
4416
if (resize_rect.Min .x > resize_rect.Max .x ) ImSwap (resize_rect.Min .x , resize_rect.Max .x );
4403
4417
if (resize_rect.Min .y > resize_rect.Max .y ) ImSwap (resize_rect.Min .y , resize_rect.Max .y );
4404
4418
bool hovered, held;
4405
4419
ButtonBehavior (resize_rect, window->GetID ((void *)(intptr_t )resize_grip_n), &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus);
4420
+ // GetOverlayDrawList()->AddRect(resize_rect.Min, resize_rect.Max, IM_COL32(255, 255, 0, 255));
4406
4421
if (hovered || held)
4407
4422
g.MouseCursor = (resize_grip_n & 1 ) ? ImGuiMouseCursor_ResizeNESW : ImGuiMouseCursor_ResizeNWSE;
4408
4423
@@ -4416,20 +4431,19 @@ static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
4416
4431
{
4417
4432
// Resize from any of the four corners
4418
4433
// We don't use an incremental MouseDelta but rather compute an absolute target size based on mouse position
4419
- ImVec2 corner_target = g.IO .MousePos - g.ActiveIdClickOffset + resize_rect. GetSize () * grip.CornerPos ; // Corner of the window corresponding to our corner grip
4434
+ ImVec2 corner_target = g.IO .MousePos - g.ActiveIdClickOffset + ImLerp (grip. InnerDir * grip_hover_outer_size, grip.InnerDir * -grip_hover_inner_size, grip. CornerPos ) ; // Corner of the window corresponding to our corner grip
4420
4435
CalcResizePosSizeFromAnyCorner (window, corner_target, grip.CornerPos , &pos_target, &size_target);
4421
4436
}
4422
4437
if (resize_grip_n == 0 || held || hovered)
4423
4438
resize_grip_col[resize_grip_n] = GetColorU32 (held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered : ImGuiCol_ResizeGrip);
4424
4439
}
4425
4440
for (int border_n = 0 ; border_n < resize_border_count; border_n++)
4426
4441
{
4427
- const float BORDER_SIZE = 5 .0f ; // FIXME: Only works _inside_ window because of HoveredWindow check.
4428
- const float BORDER_APPEAR_TIMER = 0 .05f ; // Reduce visual noise
4429
4442
bool hovered, held;
4430
- ImRect border_rect = GetResizeBorderRect (window, border_n, grip_hover_size, BORDER_SIZE );
4443
+ ImRect border_rect = GetResizeBorderRect (window, border_n, grip_hover_inner_size, RESIZE_WINDOWS_FROM_EDGES_HALF_THICKNESS );
4431
4444
ButtonBehavior (border_rect, window->GetID ((void *)(intptr_t )(border_n + 4 )), &hovered, &held, ImGuiButtonFlags_FlattenChildren);
4432
- if ((hovered && g.HoveredIdTimer > BORDER_APPEAR_TIMER) || held)
4445
+ // GetOverlayDrawList()->AddRect(border_rect.Min, border_rect.Max, IM_COL32(255, 255, 0, 255));
4446
+ if ((hovered && g.HoveredIdTimer > RESIZE_WINDOWS_FROM_EDGES_FEEDBACK_TIMER) || held)
4433
4447
{
4434
4448
g.MouseCursor = (border_n & 1 ) ? ImGuiMouseCursor_ResizeEW : ImGuiMouseCursor_ResizeNS;
4435
4449
if (held) *border_held = border_n;
@@ -4438,10 +4452,10 @@ static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
4438
4452
{
4439
4453
ImVec2 border_target = window->Pos ;
4440
4454
ImVec2 border_posn;
4441
- if (border_n == 0 ) { border_posn = ImVec2 (0 , 0 ); border_target.y = (g.IO .MousePos .y - g.ActiveIdClickOffset .y ); }
4442
- if (border_n == 1 ) { border_posn = ImVec2 (1 , 0 ); border_target.x = (g.IO .MousePos .x - g.ActiveIdClickOffset .x + BORDER_SIZE ); }
4443
- if (border_n == 2 ) { border_posn = ImVec2 (0 , 1 ); border_target.y = (g.IO .MousePos .y - g.ActiveIdClickOffset .y + BORDER_SIZE ); }
4444
- if (border_n == 3 ) { border_posn = ImVec2 (0 , 0 ); border_target.x = (g.IO .MousePos .x - g.ActiveIdClickOffset .x ); }
4455
+ if (border_n == 0 ) { border_posn = ImVec2 (0 , 0 ); border_target.y = (g.IO .MousePos .y - g.ActiveIdClickOffset .y + RESIZE_WINDOWS_FROM_EDGES_HALF_THICKNESS ); }
4456
+ if (border_n == 1 ) { border_posn = ImVec2 (1 , 0 ); border_target.x = (g.IO .MousePos .x - g.ActiveIdClickOffset .x + RESIZE_WINDOWS_FROM_EDGES_HALF_THICKNESS ); }
4457
+ if (border_n == 2 ) { border_posn = ImVec2 (0 , 1 ); border_target.y = (g.IO .MousePos .y - g.ActiveIdClickOffset .y + RESIZE_WINDOWS_FROM_EDGES_HALF_THICKNESS ); }
4458
+ if (border_n == 3 ) { border_posn = ImVec2 (0 , 0 ); border_target.x = (g.IO .MousePos .x - g.ActiveIdClickOffset .x + RESIZE_WINDOWS_FROM_EDGES_HALF_THICKNESS ); }
4445
4459
CalcResizePosSizeFromAnyCorner (window, border_target, border_posn, &pos_target, &size_target);
4446
4460
}
4447
4461
}
0 commit comments