|
@@ -432,6 +432,8 @@ CODE
|
|
|
- likewise io.MousePos and GetMousePos() will use OS coordinates.
|
|
|
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
|
|
|
|
|
|
+ - 2023/11/07 (1.90.0) - removed BeginChildFrame()/EndChildFrame() in favor of using BeginChild() with the ImGuiChildFlags_FrameStyle flag. kept inline redirection function (will obsolete).
|
|
|
+ those functions were merely PushStyle/PopStyle helpers, the removal isn't so much motivated by needing to add the feature in BeginChild(), but by the necessity to avoid BeginChildFrame() signature mismatching BeginChild() signature and features.
|
|
|
- 2023/11/02 (1.90.0) - BeginChild: upgraded 'bool border = true' parameter to 'ImGuiChildFlags flags' type, added ImGuiChildFlags_Border equivalent. As with our prior "bool-to-flags" API updates, the ImGuiChildFlags_Border value is guaranteed to be == true forever to ensure a smoother transition, meaning all existing calls will still work.
|
|
|
- old: BeginChild("Name", size, true)
|
|
|
- new: BeginChild("Name", size, ImGuiChildFlags_Border)
|
|
@@ -5716,22 +5718,43 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, I
|
|
|
IM_ASSERT(id != 0);
|
|
|
|
|
|
// Sanity check as it is likely that some user will accidentally pass ImGuiWindowFlags into the ImGuiChildFlags argument.
|
|
|
- const ImGuiChildFlags ImGuiChildFlags_SupportedMask_ = ImGuiChildFlags_Border | ImGuiChildFlags_AlwaysUseWindowPadding | ImGuiChildFlags_ResizeX | ImGuiChildFlags_ResizeY;
|
|
|
+ const ImGuiChildFlags ImGuiChildFlags_SupportedMask_ = ImGuiChildFlags_Border | ImGuiChildFlags_AlwaysUseWindowPadding | ImGuiChildFlags_ResizeX | ImGuiChildFlags_ResizeY | ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY | ImGuiChildFlags_AlwaysAutoResize | ImGuiChildFlags_FrameStyle;
|
|
|
IM_UNUSED(ImGuiChildFlags_SupportedMask_);
|
|
|
IM_ASSERT((child_flags & ~ImGuiChildFlags_SupportedMask_) == 0 && "Illegal ImGuiChildFlags value. Did you pass ImGuiWindowFlags values instead of ImGuiChildFlags?");
|
|
|
- if (window_flags & ImGuiWindowFlags_AlwaysAutoResize)
|
|
|
- IM_ASSERT((child_flags & (ImGuiChildFlags_ResizeX | ImGuiChildFlags_ResizeY)) == 0 && "Cannot combine ImGuiChildFlags_ResizeX/ImGuiChildFlags_ResizeY with ImGuiWindowFlags_AlwaysAutoResize.");
|
|
|
+ IM_ASSERT((window_flags & ImGuiWindowFlags_AlwaysAutoResize) == 0 && "Cannot specify ImGuiWindowFlags_AlwaysAutoResize for BeginChild(). Use ImGuiChildFlags_AlwaysAutoResize!");
|
|
|
+ if (child_flags & ImGuiChildFlags_AlwaysAutoResize)
|
|
|
+ {
|
|
|
+ IM_ASSERT((child_flags & (ImGuiChildFlags_ResizeX | ImGuiChildFlags_ResizeY)) == 0 && "Cannot use ImGuiChildFlags_ResizeX or ImGuiChildFlags_ResizeY with ImGuiChildFlags_AlwaysAutoResize!");
|
|
|
+ IM_ASSERT((child_flags & (ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY)) != 0 && "Must use ImGuiChildFlags_AutoResizeX or ImGuiChildFlags_AutoResizeY with ImGuiChildFlags_AlwaysAutoResize!");
|
|
|
+ }
|
|
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
|
|
if (window_flags & ImGuiWindowFlags_AlwaysUseWindowPadding)
|
|
|
child_flags |= ImGuiChildFlags_AlwaysUseWindowPadding;
|
|
|
#endif
|
|
|
+ if (child_flags & ImGuiChildFlags_AutoResizeX)
|
|
|
+ child_flags &= ~ImGuiChildFlags_ResizeX;
|
|
|
+ if (child_flags & ImGuiChildFlags_AutoResizeY)
|
|
|
+ child_flags &= ~ImGuiChildFlags_ResizeY;
|
|
|
|
|
|
+ // Set window flags
|
|
|
window_flags |= ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDocking;
|
|
|
window_flags |= (parent_window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag
|
|
|
-
|
|
|
+ if (child_flags & (ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY | ImGuiChildFlags_AlwaysAutoResize))
|
|
|
+ window_flags |= ImGuiWindowFlags_AlwaysAutoResize;
|
|
|
if ((child_flags & (ImGuiChildFlags_ResizeX | ImGuiChildFlags_ResizeY)) == 0)
|
|
|
window_flags |= ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings;
|
|
|
|
|
|
+ // Special framed style
|
|
|
+ if (child_flags & ImGuiChildFlags_FrameStyle)
|
|
|
+ {
|
|
|
+ PushStyleColor(ImGuiCol_ChildBg, g.Style.Colors[ImGuiCol_FrameBg]);
|
|
|
+ PushStyleVar(ImGuiStyleVar_ChildRounding, g.Style.FrameRounding);
|
|
|
+ PushStyleVar(ImGuiStyleVar_ChildBorderSize, g.Style.FrameBorderSize);
|
|
|
+ PushStyleVar(ImGuiStyleVar_WindowPadding, g.Style.FramePadding);
|
|
|
+ child_flags |= ImGuiChildFlags_Border | ImGuiChildFlags_AlwaysUseWindowPadding;
|
|
|
+ window_flags |= ImGuiWindowFlags_NoMove;
|
|
|
+ }
|
|
|
+
|
|
|
// Forward child flags
|
|
|
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasChildFlags;
|
|
|
g.NextWindowData.ChildFlags = child_flags;
|
|
@@ -5739,12 +5762,9 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, I
|
|
|
// Forward size
|
|
|
// Important: Begin() has special processing to switch condition to ImGuiCond_FirstUseEver for a given axis when ImGuiChildFlags_ResizeXXX is set.
|
|
|
// (the alternative would to store conditional flags per axis, which is possible but more code)
|
|
|
- const ImVec2 content_avail = GetContentRegionAvail();
|
|
|
- ImVec2 size = ImTrunc(size_arg);
|
|
|
- if (size.x <= 0.0f)
|
|
|
- size.x = ImMax(content_avail.x + size.x, 4.0f); // Arbitrary minimum child size (0.0f causing too many issues)
|
|
|
- if (size.y <= 0.0f)
|
|
|
- size.y = ImMax(content_avail.y + size.y, 4.0f);
|
|
|
+ const ImVec2 size_avail = GetContentRegionAvail();
|
|
|
+ const ImVec2 size_default((child_flags & ImGuiChildFlags_AutoResizeX) ? 0.0f : size_avail.x, (child_flags & ImGuiChildFlags_AutoResizeY) ? 0.0f : size_avail.y);
|
|
|
+ const ImVec2 size = CalcItemSize(size_arg, size_default.x, size_default.y);
|
|
|
SetNextWindowSize(size);
|
|
|
|
|
|
// Build up name. If you need to append to a same child from multiple location in the ID stack, use BeginChild(ImGuiID id) with a stable value.
|
|
@@ -5756,13 +5776,21 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, I
|
|
|
else
|
|
|
ImFormatStringToTempBuffer(&temp_window_name, NULL, "%s/%08X", parent_window->Name, id);
|
|
|
|
|
|
+ // Set style
|
|
|
const float backup_border_size = g.Style.ChildBorderSize;
|
|
|
if ((child_flags & ImGuiChildFlags_Border) == 0)
|
|
|
g.Style.ChildBorderSize = 0.0f;
|
|
|
|
|
|
// Begin into window
|
|
|
const bool ret = Begin(temp_window_name, NULL, window_flags);
|
|
|
+
|
|
|
+ // Restore style
|
|
|
g.Style.ChildBorderSize = backup_border_size;
|
|
|
+ if (child_flags & ImGuiChildFlags_FrameStyle)
|
|
|
+ {
|
|
|
+ PopStyleVar(3);
|
|
|
+ PopStyleColor();
|
|
|
+ }
|
|
|
|
|
|
ImGuiWindow* child_window = g.CurrentWindow;
|
|
|
child_window->ChildId = id;
|
|
@@ -5828,26 +5856,6 @@ void ImGui::EndChild()
|
|
|
g.LogLinePosY = -FLT_MAX; // To enforce a carriage return
|
|
|
}
|
|
|
|
|
|
-// Helper to create a child window / scrolling region that looks like a normal widget frame.
|
|
|
-bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags)
|
|
|
-{
|
|
|
- ImGuiContext& g = *GImGui;
|
|
|
- const ImGuiStyle& style = g.Style;
|
|
|
- PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]);
|
|
|
- PushStyleVar(ImGuiStyleVar_ChildRounding, style.FrameRounding);
|
|
|
- PushStyleVar(ImGuiStyleVar_ChildBorderSize, style.FrameBorderSize);
|
|
|
- PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding);
|
|
|
- bool ret = BeginChild(id, size, ImGuiChildFlags_Border | ImGuiChildFlags_AlwaysUseWindowPadding, ImGuiWindowFlags_NoMove | extra_flags);
|
|
|
- PopStyleVar(3);
|
|
|
- PopStyleColor();
|
|
|
- return ret;
|
|
|
-}
|
|
|
-
|
|
|
-void ImGui::EndChildFrame()
|
|
|
-{
|
|
|
- EndChild();
|
|
|
-}
|
|
|
-
|
|
|
static void SetWindowConditionAllowFlags(ImGuiWindow* window, ImGuiCond flags, bool enabled)
|
|
|
{
|
|
|
window->SetWindowPosAllowFlags = enabled ? (window->SetWindowPosAllowFlags | flags) : (window->SetWindowPosAllowFlags & ~flags);
|
|
@@ -6327,8 +6335,13 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& si
|
|
|
ImVec2 clamp_min(border_n == ImGuiDir_Right ? clamp_rect.Min.x : -FLT_MAX, border_n == ImGuiDir_Down || (border_n == ImGuiDir_Up && window_move_from_title_bar) ? clamp_rect.Min.y : -FLT_MAX);
|
|
|
ImVec2 clamp_max(border_n == ImGuiDir_Left ? clamp_rect.Max.x : +FLT_MAX, border_n == ImGuiDir_Up ? clamp_rect.Max.y : +FLT_MAX);
|
|
|
border_target = ImClamp(border_target, clamp_min, clamp_max);
|
|
|
- if (window->Flags & ImGuiWindowFlags_ChildWindow) // Clamp resizing of childs within parent
|
|
|
- border_target = ImClamp(border_target, window->ParentWindow->InnerClipRect.Min, window->ParentWindow->InnerClipRect.Max);
|
|
|
+ if (flags & ImGuiWindowFlags_ChildWindow) // Clamp resizing of childs within parent
|
|
|
+ {
|
|
|
+ if ((flags & (ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar)) == 0 || (flags & ImGuiWindowFlags_NoScrollbar))
|
|
|
+ border_target.x = ImClamp(border_target.x, window->ParentWindow->InnerClipRect.Min.x, window->ParentWindow->InnerClipRect.Max.x);
|
|
|
+ if (flags & ImGuiWindowFlags_NoScrollbar)
|
|
|
+ border_target.y = ImClamp(border_target.y, window->ParentWindow->InnerClipRect.Min.y, window->ParentWindow->InnerClipRect.Max.y);
|
|
|
+ }
|
|
|
if (!ignore_resize)
|
|
|
CalcResizePosSizeFromAnyCorner(window, border_target, ImMin(def.SegmentN1, def.SegmentN2), &pos_target, &size_target);
|
|
|
}
|
|
@@ -7520,7 +7533,12 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
const bool nav_request = (flags & ImGuiWindowFlags_NavFlattened) && (g.NavAnyRequest && g.NavWindow && g.NavWindow->RootWindowForNav == window->RootWindowForNav);
|
|
|
if (!g.LogEnabled && !nav_request)
|
|
|
if (window->OuterRectClipped.Min.x >= window->OuterRectClipped.Max.x || window->OuterRectClipped.Min.y >= window->OuterRectClipped.Max.y)
|
|
|
- window->HiddenFramesCanSkipItems = 1;
|
|
|
+ {
|
|
|
+ if (window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0)
|
|
|
+ window->HiddenFramesCannotSkipItems = 1;
|
|
|
+ else
|
|
|
+ window->HiddenFramesCanSkipItems = 1;
|
|
|
+ }
|
|
|
|
|
|
// Hide along with parent or if parent is collapsed
|
|
|
if (parent_window && (parent_window->Collapsed || parent_window->HiddenFramesCanSkipItems > 0))
|
|
@@ -8151,10 +8169,14 @@ void ImGui::SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond con
|
|
|
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
|
|
|
window->SetWindowSizeAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
|
|
|
|
|
|
+ // Enable auto-fit (not done in BeginChild() path unless appearing or combined with ImGuiChildFlags_AlwaysAutoResize)
|
|
|
+ if ((window->Flags & ImGuiWindowFlags_ChildWindow) == 0 || window->Appearing || (window->ChildFlags & ImGuiChildFlags_AlwaysAutoResize) != 0)
|
|
|
+ window->AutoFitFramesX = (size.x <= 0.0f) ? 2 : 0;
|
|
|
+ if ((window->Flags & ImGuiWindowFlags_ChildWindow) == 0 || window->Appearing || (window->ChildFlags & ImGuiChildFlags_AlwaysAutoResize) != 0)
|
|
|
+ window->AutoFitFramesY = (size.y <= 0.0f) ? 2 : 0;
|
|
|
+
|
|
|
// Set
|
|
|
ImVec2 old_size = window->SizeFull;
|
|
|
- window->AutoFitFramesX = (size.x <= 0.0f) ? 2 : 0;
|
|
|
- window->AutoFitFramesY = (size.y <= 0.0f) ? 2 : 0;
|
|
|
if (size.x <= 0.0f)
|
|
|
window->AutoFitOnlyGrows = false;
|
|
|
else
|
|
@@ -9093,6 +9115,13 @@ bool ImGui::IsMouseDoubleClicked(ImGuiMouseButton button)
|
|
|
return g.IO.MouseClickedCount[button] == 2 && TestKeyOwner(MouseButtonToKey(button), ImGuiKeyOwner_Any);
|
|
|
}
|
|
|
|
|
|
+bool ImGui::IsMouseDoubleClicked(ImGuiMouseButton button, ImGuiID owner_id)
|
|
|
+{
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+ IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
|
|
|
+ return g.IO.MouseClickedCount[button] == 2 && TestKeyOwner(MouseButtonToKey(button), owner_id);
|
|
|
+}
|
|
|
+
|
|
|
int ImGui::GetMouseClickedCount(ImGuiMouseButton button)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
@@ -12025,7 +12054,7 @@ void ImGui::NavMoveRequestSubmit(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavM
|
|
|
g.NavMoveFlags = move_flags;
|
|
|
g.NavMoveScrollFlags = scroll_flags;
|
|
|
g.NavMoveForwardToNextFrame = false;
|
|
|
- g.NavMoveKeyMods = g.IO.KeyMods;
|
|
|
+ g.NavMoveKeyMods = (move_flags & ImGuiNavMoveFlags_FocusApi) ? 0 : g.IO.KeyMods;
|
|
|
g.NavMoveResultLocal.Clear();
|
|
|
g.NavMoveResultLocalVisible.Clear();
|
|
|
g.NavMoveResultOther.Clear();
|
|
@@ -19946,8 +19975,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
Text("KEY OWNERS");
|
|
|
{
|
|
|
Indent();
|
|
|
- if (BeginListBox("##owners", ImVec2(-FLT_MIN, GetTextLineHeightWithSpacing() * 6)))
|
|
|
- {
|
|
|
+ if (BeginChild("##owners", ImVec2(-FLT_MIN, GetTextLineHeightWithSpacing() * 6), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY, ImGuiWindowFlags_NoSavedSettings))
|
|
|
for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1))
|
|
|
{
|
|
|
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
|
|
@@ -19957,15 +19985,13 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
owner_data->LockUntilRelease ? " LockUntilRelease" : owner_data->LockThisFrame ? " LockThisFrame" : "");
|
|
|
DebugLocateItemOnHover(owner_data->OwnerCurr);
|
|
|
}
|
|
|
- EndListBox();
|
|
|
- }
|
|
|
+ EndChild();
|
|
|
Unindent();
|
|
|
}
|
|
|
Text("SHORTCUT ROUTING");
|
|
|
{
|
|
|
Indent();
|
|
|
- if (BeginListBox("##routes", ImVec2(-FLT_MIN, GetTextLineHeightWithSpacing() * 6)))
|
|
|
- {
|
|
|
+ if (BeginChild("##routes", ImVec2(-FLT_MIN, GetTextLineHeightWithSpacing() * 6), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY, ImGuiWindowFlags_NoSavedSettings))
|
|
|
for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1))
|
|
|
{
|
|
|
ImGuiKeyRoutingTable* rt = &g.KeysRoutingTable;
|
|
@@ -19979,8 +20005,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
idx = routing_data->NextEntryIndex;
|
|
|
}
|
|
|
}
|
|
|
- EndListBox();
|
|
|
- }
|
|
|
+ EndChild();
|
|
|
Text("(ActiveIdUsing: AllKeyboardKeys: %d, NavDirMask: 0x%X)", g.ActiveIdUsingAllKeyboardKeys, g.ActiveIdUsingNavDirMask);
|
|
|
Unindent();
|
|
|
}
|