@@ -5249,7 +5249,7 @@ static void FindHoveredWindow()
5249
5249
continue;
5250
5250
5251
5251
// Using the clipped AABB, a child window will typically be clipped by its parent (not always)
5252
- ImVec2 hit_padding = (window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize)) ? padding_regular : padding_for_resize;
5252
+ ImVec2 hit_padding = (window->Flags & (ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize)) ? padding_regular : padding_for_resize;
5253
5253
if (!window->OuterRectClipped.ContainsWithPad(g.IO.MousePos, hit_padding))
5254
5254
continue;
5255
5255
@@ -5442,22 +5442,29 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, I
5442
5442
IM_ASSERT(id != 0);
5443
5443
5444
5444
// Sanity check as it is likely that some user will accidentally pass ImGuiWindowFlags into the ImGuiChildFlags argument.
5445
- const ImGuiChildFlags ImGuiChildFlags_SupportedMask_ = ImGuiChildFlags_Border | ImGuiChildFlags_AlwaysUseWindowPadding;
5445
+ const ImGuiChildFlags ImGuiChildFlags_SupportedMask_ = ImGuiChildFlags_Border | ImGuiChildFlags_AlwaysUseWindowPadding | ImGuiChildFlags_ResizeX | ImGuiChildFlags_ResizeY ;
5446
5446
IM_UNUSED(ImGuiChildFlags_SupportedMask_);
5447
5447
IM_ASSERT((child_flags & ~ImGuiChildFlags_SupportedMask_) == 0 && "Illegal ImGuiChildFlags value. Did you pass ImGuiWindowFlags values instead of ImGuiChildFlags?");
5448
+ if (window_flags & ImGuiWindowFlags_AlwaysAutoResize)
5449
+ IM_ASSERT((child_flags & (ImGuiChildFlags_ResizeX | ImGuiChildFlags_ResizeY)) == 0 && "Cannot combine ImGuiChildFlags_ResizeX/ImGuiChildFlags_ResizeY with ImGuiWindowFlags_AlwaysAutoResize.");
5448
5450
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
5449
5451
if (window_flags & ImGuiWindowFlags_AlwaysUseWindowPadding)
5450
5452
child_flags |= ImGuiChildFlags_AlwaysUseWindowPadding;
5451
5453
#endif
5452
5454
5453
- window_flags |= ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings ;
5455
+ window_flags |= ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoTitleBar;
5454
5456
window_flags |= (parent_window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag
5455
5457
5458
+ if ((child_flags & (ImGuiChildFlags_ResizeX | ImGuiChildFlags_ResizeY)) == 0)
5459
+ window_flags |= ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings;
5460
+
5456
5461
// Forward child flags
5457
5462
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasChildFlags;
5458
5463
g.NextWindowData.ChildFlags = child_flags;
5459
5464
5460
5465
// Forward size
5466
+ // Important: Begin() has special processing to switch condition to ImGuiCond_FirstUseEver for a given axis when ImGuiChildFlags_ResizeXXX is set.
5467
+ // (the alternative would to store conditional flags per axis, which is possible but more code)
5461
5468
const ImVec2 content_avail = GetContentRegionAvail();
5462
5469
ImVec2 size = ImTrunc(size_arg);
5463
5470
if (size.x <= 0.0f)
@@ -5679,7 +5686,8 @@ static inline ImVec2 CalcWindowMinSize(ImGuiWindow* window)
5679
5686
ImVec2 size_min;
5680
5687
if (window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_ChildWindow))
5681
5688
{
5682
- size_min = ImVec2(4.0f, 4.0f);
5689
+ size_min.x = (window->ChildFlags & ImGuiChildFlags_ResizeX) ? g.Style.WindowMinSize.x : 4.0f;
5690
+ size_min.y = (window->ChildFlags & ImGuiChildFlags_ResizeY) ? g.Style.WindowMinSize.y : 4.0f;
5683
5691
}
5684
5692
else
5685
5693
{
@@ -5939,7 +5947,11 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& si
5939
5947
resize_grip_col[resize_grip_n] = GetColorU32(held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered : ImGuiCol_ResizeGrip);
5940
5948
}
5941
5949
5942
- const int resize_border_mask = g.IO.ConfigWindowsResizeFromEdges ? 0x0F : 0x00;
5950
+ int resize_border_mask = 0x00;
5951
+ if (window->Flags & ImGuiWindowFlags_ChildWindow)
5952
+ resize_border_mask |= ((window->ChildFlags & ImGuiChildFlags_ResizeX) ? 0x02 : 0) | ((window->ChildFlags & ImGuiChildFlags_ResizeY) ? 0x08 : 0);
5953
+ else
5954
+ resize_border_mask = g.IO.ConfigWindowsResizeFromEdges ? 0x0F : 0x00;
5943
5955
for (int border_n = 0; border_n < 4; border_n++)
5944
5956
{
5945
5957
if ((resize_border_mask & (1 << border_n)) == 0)
@@ -5976,6 +5988,8 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& si
5976
5988
ImVec2 border_target = window->Pos;
5977
5989
border_target[axis] = g.IO.MousePos[axis] - g.ActiveIdClickOffset[axis] + WINDOWS_HOVER_PADDING;
5978
5990
border_target = ImClamp(border_target, clamp_min, clamp_max);
5991
+ if (window->Flags & ImGuiWindowFlags_ChildWindow) // Clamp resizing of childs within parent
5992
+ border_target = ImClamp(border_target, window->ParentWindow->InnerClipRect.Min, window->ParentWindow->InnerClipRect.Max);
5979
5993
CalcResizePosSizeFromAnyCorner(window, border_target, ImMin(def.SegmentN1, def.SegmentN2), &pos_target, &size_target);
5980
5994
}
5981
5995
if (hovered)
@@ -6423,6 +6437,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
6423
6437
{
6424
6438
window_size_x_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.x > 0.0f);
6425
6439
window_size_y_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.y > 0.0f);
6440
+ if ((window->ChildFlags & ImGuiChildFlags_ResizeX) && (window->SetWindowSizeAllowFlags & ImGuiCond_FirstUseEver) == 0) // Axis-specific conditions for BeginChild()
6441
+ g.NextWindowData.SizeVal.x = window->SizeFull.x;
6442
+ if ((window->ChildFlags & ImGuiChildFlags_ResizeY) && (window->SetWindowSizeAllowFlags & ImGuiCond_FirstUseEver) == 0)
6443
+ g.NextWindowData.SizeVal.y = window->SizeFull.y;
6426
6444
SetWindowSize(window, g.NextWindowData.SizeVal, g.NextWindowData.SizeCond);
6427
6445
}
6428
6446
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasScroll)
@@ -6680,7 +6698,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
6680
6698
// Handle manual resize: Resize Grips, Borders, Gamepad
6681
6699
int border_hovered = -1, border_held = -1;
6682
6700
ImU32 resize_grip_col[4] = {};
6683
- const int resize_grip_count = g.IO.ConfigWindowsResizeFromEdges ? 2 : 1; // Allow resize from lower-left if we have the mouse cursor feedback for it.
6701
+ const int resize_grip_count = (window->Flags & ImGuiWindowFlags_ChildWindow) ? 0 : g.IO.ConfigWindowsResizeFromEdges ? 2 : 1; // Allow resize from lower-left if we have the mouse cursor feedback for it.
6684
6702
const float resize_grip_draw_size = IM_TRUNC(ImMax(g.FontSize * 1.10f, window->WindowRounding + 1.0f + g.FontSize * 0.2f));
6685
6703
if (!window->Collapsed)
6686
6704
if (int auto_fit_mask = UpdateWindowManualResize(window, size_auto_fit, &border_hovered, &border_held, resize_grip_count, &resize_grip_col[0], visibility_rect))
@@ -13327,6 +13345,7 @@ static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*,
13327
13345
if (sscanf(line, "Pos=%i,%i", &x, &y) == 2) { settings->Pos = ImVec2ih((short)x, (short)y); }
13328
13346
else if (sscanf(line, "Size=%i,%i", &x, &y) == 2) { settings->Size = ImVec2ih((short)x, (short)y); }
13329
13347
else if (sscanf(line, "Collapsed=%d", &i) == 1) { settings->Collapsed = (i != 0); }
13348
+ else if (sscanf(line, "IsChild=%d", &i) == 1) { settings->IsChild = (i != 0); }
13330
13349
}
13331
13350
13332
13351
// Apply to existing windows (if any)
@@ -13361,7 +13380,7 @@ static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandl
13361
13380
IM_ASSERT(settings->ID == window->ID);
13362
13381
settings->Pos = ImVec2ih(window->Pos);
13363
13382
settings->Size = ImVec2ih(window->SizeFull);
13364
-
13383
+ settings->IsChild = (window->Flags & ImGuiWindowFlags_ChildWindow) != 0;
13365
13384
settings->Collapsed = window->Collapsed;
13366
13385
settings->WantDelete = false;
13367
13386
}
@@ -13374,10 +13393,18 @@ static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandl
13374
13393
continue;
13375
13394
const char* settings_name = settings->GetName();
13376
13395
buf->appendf("[%s][%s]\n", handler->TypeName, settings_name);
13377
- buf->appendf("Pos=%d,%d\n", settings->Pos.x, settings->Pos.y);
13378
- buf->appendf("Size=%d,%d\n", settings->Size.x, settings->Size.y);
13379
- if (settings->Collapsed)
13380
- buf->appendf("Collapsed=1\n");
13396
+ if (settings->IsChild)
13397
+ {
13398
+ buf->appendf("IsChild=1\n");
13399
+ buf->appendf("Size=%d,%d\n", settings->Size.x, settings->Size.y);
13400
+ }
13401
+ else
13402
+ {
13403
+ buf->appendf("Pos=%d,%d\n", settings->Pos.x, settings->Pos.y);
13404
+ buf->appendf("Size=%d,%d\n", settings->Size.x, settings->Size.y);
13405
+ if (settings->Collapsed)
13406
+ buf->appendf("Collapsed=1\n");
13407
+ }
13381
13408
buf->append("\n");
13382
13409
}
13383
13410
}
0 commit comments