diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index ae2b31de0..74008f73c 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -35,6 +35,35 @@ HOW TO UPDATE?
and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users.
- Please report any issue!
+-----------------------------------------------------------------------
+ VERSION 1.93.2 WIP (In Progress)
+-----------------------------------------------------------------------
+
+Breaking Changes:
+
+Other Changes:
+
+- Windows:
+ - Added `ImGuiSizeCallbackData::ResizeAxisMask` hint identifying which
+ axis drives a resize request, allowing custom constraints to prioritize
+ a single axis. (#6210, #8028)
+ - Fixed window positioning when a size constraint changes the other axis
+ during border dragging: left/right border drags keep the top edge fixed,
+ and top/bottom border drags keep the left edge fixed. (#6210)
+ - Fixed auto-fit when double-clicking a window's right or bottom border
+ ignoring size constraint changes to the other axis (e.g. when enforcing
+ a square or fixed aspect ratio). (#6210)
+- ColorEdit:
+ - Made setting `io.ConfigColorEditFlags` accepting of missing flags, to match
+ legacy `SetColorEditOptions()` filling in those bits for you. (#9640)
+- Demo:
+ - Fixed "Examples->Constrained-resizing window" using newly added `ResizeAxisMask`
+ hint: allow shrinking the Square example from borders; allow resizing the Aspect Ratio
+ example from top/bottom borders and by dragging corners vertically. (#6210, #8028)
+ - Fixed "Color/Picker Widgets -> Overwrite default: XXXX" buttons from leading
+ to an assert due to missing flags. (Regression in 1.92.9). (#9640) [@sequpt]
+
+
-----------------------------------------------------------------------
VERSION 1.93.1 (Released 2026-11-26)
-----------------------------------------------------------------------
@@ -608,8 +637,8 @@ Breaking Changes:
Read below for details.
- TreeNode: commented out legacy name `ImGuiTreeNodeFlags_SpanTextWidth` which
was obsoleted in 1.90.7 (May 2024). Use `ImGuiTreeNodeFlags_SpanLabelWidth`.
-- ColorEdit: obsoleted SetColorEditOptions() function added in 1.51 (June 2017) in favor
- of directly poking to io.ConfigColorEditFlags. More consistent and easier to discover.
+- ColorEdit: obsoleted `SetColorEditOptions()` function added in 1.51 (June 2017) in favor
+ of directly poking to `io.ConfigColorEditFlags`. More consistent and easier to discover.
- Drag and Drop: commented out legacy name `ImGuiDragDropFlags_SourceAutoExpirePayload`
which obsoleted in 1.90.9 (July 2024). Use `ImGuiDragDropFlags_PayloadAutoExpire`.
- ImDrawData: marked `CmdListsCount` as obsolete (technically was obsoleted in 1.89.8).
diff --git a/docs/README.md b/docs/README.md
index c6d7afc85..45ea90ddb 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -55,8 +55,7 @@ if (ImGui::Button("Save"))
ImGui::InputText("string", buf, IM_COUNTOF(buf));
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
```
-
-
+
```cpp
// Create a window called "My First Tool", with a menu bar.
diff --git a/imgui.cpp b/imgui.cpp
index a6130a1ac..0151abff3 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -1,4 +1,4 @@
-// dear imgui, v1.93.1
+// dear imgui, v1.93.2 WIP
// (main code and documentation)
// Help:
@@ -6935,7 +6935,7 @@ static inline ImVec2 CalcWindowMinSize(ImGuiWindow* window)
return size_min;
}
-static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, const ImVec2& size_desired)
+static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, const ImVec2& size_desired, int resize_axis_mask)
{
ImGuiContext& g = *GImGui;
ImVec2 new_size = size_desired;
@@ -6952,6 +6952,7 @@ static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, const ImVec2& s
data.Pos = window->Pos;
data.CurrentSize = window->SizeFull;
data.DesiredSize = new_size;
+ data.ResizeAxisMask = resize_axis_mask & 0x03;
g.NextWindowData.SizeCallback(&data);
new_size = data.DesiredSize;
}
@@ -7011,7 +7012,7 @@ static ImVec2 CalcWindowAutoFitSize(ImGuiWindow* window, const ImVec2& size_cont
// When the window cannot fit all contents (either because of constraints, either because screen is too small),
// we are growing the size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than ViewportSize-WindowPadding.
- ImVec2 size_auto_fit_after_constraint = CalcWindowSizeAfterConstraint(window, size_auto_fit);
+ ImVec2 size_auto_fit_after_constraint = CalcWindowSizeAfterConstraint(window, size_auto_fit, axis_mask);
float size_contents_for_scrollbar_x = (axis_mask & 1) ? size_contents.x : window->ContentSize.x; // See #9352. In theory this should use same logic as `window->ScrollbarY = ...` codepath in Begin(). Needs some plumbling.
float size_contents_for_scrollbar_y = (axis_mask & 2) ? size_contents.y : window->ContentSize.y;
bool will_have_scrollbar_x = (size_auto_fit_after_constraint.x < size_contents_for_scrollbar_x + size_pad.x + decoration_w_without_scrollbars && !(window->Flags & ImGuiWindowFlags_NoScrollbar) && (window->Flags & ImGuiWindowFlags_HorizontalScrollbar)) || (window->Flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar);
@@ -7029,8 +7030,8 @@ ImVec2 ImGui::CalcWindowNextAutoFitSize(ImGuiWindow* window)
ImVec2 size_contents_current;
ImVec2 size_contents_ideal;
CalcWindowContentSizes(window, &size_contents_current, &size_contents_ideal);
- ImVec2 size_auto_fit = CalcWindowAutoFitSize(window, size_contents_ideal, ~0);
- ImVec2 size_final = CalcWindowSizeAfterConstraint(window, size_auto_fit);
+ ImVec2 size_auto_fit = CalcWindowAutoFitSize(window, size_contents_ideal, 0x03);
+ ImVec2 size_final = CalcWindowSizeAfterConstraint(window, size_auto_fit, 0x03);
return size_final;
}
@@ -7043,9 +7044,12 @@ static ImGuiCol GetWindowBgColorIdx(ImGuiWindow* window)
return ImGuiCol_WindowBg;
}
-static void CalcResizePosSizeFromAnyCorner(ImGuiWindow* window, const ImVec2& corner_target_arg, const ImVec2& corner_norm, ImVec2* out_pos, ImVec2* out_size)
+// Originally written for resize grips, hence using "corner" terminology, but also used for borders.
+// - corner_norm selects the target corner/border.
+// - corner_pivot selects which side moves when applying size constraints.
+static void CalcResizePosSizeForLocation(ImGuiWindow* window, const ImVec2& target_pos_arg, const ImVec2& corner_norm, const ImVec2& corner_pivot, int resize_axis_mask, ImVec2* out_pos, ImVec2* out_size)
{
- ImVec2 corner_target = corner_target_arg;
+ ImVec2 target_pos = target_pos_arg;
if (window->Flags & ImGuiWindowFlags_ChildWindow) // Clamp resizing of childs within parent
{
ImGuiWindow* parent_window = window->ParentWindow;
@@ -7053,18 +7057,18 @@ static void CalcResizePosSizeFromAnyCorner(ImGuiWindow* window, const ImVec2& co
ImRect limit_rect = parent_window->InnerRect;
limit_rect.Expand(ImVec2(-ImMax(parent_window->WindowPadding.x, parent_window->WindowBorderSize), -ImMax(parent_window->WindowPadding.y, parent_window->WindowBorderSize)));
if ((parent_flags & (ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar)) == 0 || (parent_flags & ImGuiWindowFlags_NoScrollbar))
- corner_target.x = ImClamp(corner_target.x, limit_rect.Min.x, limit_rect.Max.x);
+ target_pos.x = ImClamp(target_pos.x, limit_rect.Min.x, limit_rect.Max.x);
if (parent_flags & ImGuiWindowFlags_NoScrollbar)
- corner_target.y = ImClamp(corner_target.y, limit_rect.Min.y, limit_rect.Max.y);
+ target_pos.y = ImClamp(target_pos.y, limit_rect.Min.y, limit_rect.Max.y);
}
- ImVec2 pos_min = ImLerp(corner_target, window->Pos, corner_norm); // Expected window upper-left
- ImVec2 pos_max = ImLerp(window->Pos + window->Size, corner_target, corner_norm); // Expected window lower-right
+ ImVec2 pos_min = ImLerp(target_pos, window->Pos, corner_norm); // Expected window upper-left
+ ImVec2 pos_max = ImLerp(window->Pos + window->Size, target_pos, corner_norm); // Expected window lower-right
ImVec2 size_expected = pos_max - pos_min;
- ImVec2 size_constrained = CalcWindowSizeAfterConstraint(window, size_expected);
+ ImVec2 size_constrained = CalcWindowSizeAfterConstraint(window, size_expected, resize_axis_mask);
*out_pos = pos_min;
- if (corner_norm.x == 0.0f)
+ if (corner_pivot.x == 0.0f)
out_pos->x -= (size_constrained.x - size_expected.x);
- if (corner_norm.y == 0.0f)
+ if (corner_pivot.y == 0.0f)
out_pos->y -= (size_constrained.y - size_expected.y);
*out_size = size_constrained;
}
@@ -7089,14 +7093,15 @@ struct ImGuiResizeBorderDef
{
ImVec2 InnerDir; // Normal toward inside
ImVec2 SegmentN1, SegmentN2; // End positions, normalized (0,0: upper left)
+ ImVec2 ResizePivotN; // 0 or 1 on resize axis, 1 on other axis
float OuterAngle; // Angle toward outside
};
static const ImGuiResizeBorderDef resize_border_def[4] =
{
- { ImVec2(+1, 0), ImVec2(0, 1), ImVec2(0, 0), IM_PI * 1.00f }, // Left
- { ImVec2(-1, 0), ImVec2(1, 0), ImVec2(1, 1), IM_PI * 0.00f }, // Right
- { ImVec2(0, +1), ImVec2(0, 0), ImVec2(1, 0), IM_PI * 1.50f }, // Up
- { ImVec2(0, -1), ImVec2(1, 1), ImVec2(0, 1), IM_PI * 0.50f } // Down
+ { ImVec2(+1, 0), ImVec2(0, 1), ImVec2(0, 0), ImVec2(0, 1), IM_PI * 1.00f }, // Left border
+ { ImVec2(-1, 0), ImVec2(1, 0), ImVec2(1, 1), ImVec2(1, 1), IM_PI * 0.00f }, // Right border
+ { ImVec2(0, +1), ImVec2(0, 0), ImVec2(1, 0), ImVec2(1, 0), IM_PI * 1.50f }, // Upper border
+ { ImVec2(0, -1), ImVec2(1, 1), ImVec2(0, 1), ImVec2(1, 1), IM_PI * 0.50f } // Lower border
};
static ImRect GetResizeBorderRect(ImGuiWindow* window, int border_n, float perp_padding, float thickness)
@@ -7185,8 +7190,8 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, int* border_hove
if (held && g.IO.MouseDoubleClicked[0])
{
// Auto-fit when double-clicking
- ImVec2 size_auto_fit = CalcWindowAutoFitSize(window, window->ContentSizeIdeal, ~0);
- size_target = CalcWindowSizeAfterConstraint(window, size_auto_fit);
+ ImVec2 size_auto_fit = CalcWindowAutoFitSize(window, window->ContentSizeIdeal, 0x03);
+ size_target = CalcWindowSizeAfterConstraint(window, size_auto_fit, 0x03);
ret_auto_fit_mask = 0x03; // Both axes
ClearActiveID();
}
@@ -7198,7 +7203,7 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, int* border_hove
ImVec2 clamp_max = ImVec2(def.CornerPosN.x == 0.0f ? clamp_rect.Max.x : +FLT_MAX, def.CornerPosN.y == 0.0f ? clamp_rect.Max.y : +FLT_MAX);
ImVec2 corner_target = g.IO.MousePos - g.ActiveIdClickOffset + ImLerp(def.InnerDir * grip_hover_outer_size, def.InnerDir * -grip_hover_inner_size, def.CornerPosN); // Corner of the window corresponding to our corner grip
corner_target = ImClamp(corner_target, clamp_min, clamp_max);
- CalcResizePosSizeFromAnyCorner(window, corner_target, def.CornerPosN, &pos_target, &size_target);
+ CalcResizePosSizeForLocation(window, corner_target, def.CornerPosN, def.CornerPosN, 0x03, &pos_target, &size_target);
}
// Only lower-left grip is visible before hovering/activating
@@ -7207,6 +7212,7 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, int* border_hove
resize_grip_col[resize_grip_n] = GetColorU32(held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered : ImGuiCol_ResizeGrip);
}
+ // Resize borders
int resize_border_mask = 0x00;
if (window->Flags & ImGuiWindowFlags_ChildWindow)
resize_border_mask |= ((window->ChildFlags & ImGuiChildFlags_ResizeX) ? 0x02 : 0) | ((window->ChildFlags & ImGuiChildFlags_ResizeY) ? 0x08 : 0);
@@ -7233,11 +7239,15 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, int* border_hove
{
// Double-clicking bottom or right border auto-fit on this axis
// FIXME: Support top and right borders: rework CalcResizePosSizeFromAnyCorner() to be reusable in both cases.
- if (border_n == 1 || border_n == 3) // Right and bottom border
+ if (border_n == ImGuiDir_Right || border_n == ImGuiDir_Down) // Right and bottom border
{
ImVec2 size_auto_fit = CalcWindowAutoFitSize(window, window->ContentSizeIdeal, 1 << axis);
- size_target[axis] = CalcWindowSizeAfterConstraint(window, size_auto_fit)[axis];
+ ImVec2 size_desired = window->SizeFull;
+ size_desired[axis] = size_auto_fit[axis];
+ size_target = CalcWindowSizeAfterConstraint(window, size_desired, 1 << axis);
ret_auto_fit_mask |= (1 << axis);
+ if (size_target[axis ^ 1] != window->SizeFull[axis ^ 1])
+ ret_auto_fit_mask |= (1 << (axis ^ 1));
hovered = held = false; // So border doesn't show highlighted at new position
}
ClearActiveID();
@@ -7256,7 +7266,7 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, int* border_hove
if ((window->Flags & ImGuiWindowFlags_ChildWindow) && memcmp(&g.WindowResizeBorderExpectedRect, &border_rect, sizeof(ImRect)) != 0)
g.WindowResizeRelativeMode = true;
- const ImVec2 border_curr = (window->Pos + ImMin(def.SegmentN1, def.SegmentN2) * window->Size);
+ const ImVec2 border_curr = (window->Pos + def.ResizePivotN * window->Size);
const float border_target_rel_mode_for_axis = border_curr[axis] + g.IO.MouseDelta[axis];
const float border_target_abs_mode_for_axis = g.IO.MousePos[axis] - g.ActiveIdClickOffset[axis] + g.WindowsBorderHoverPadding; // Match ButtonBehavior() padding above.
@@ -7279,7 +7289,7 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, int* border_hove
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 (!ignore_resize)
- CalcResizePosSizeFromAnyCorner(window, border_target, ImMin(def.SegmentN1, def.SegmentN2), &pos_target, &size_target);
+ CalcResizePosSizeForLocation(window, border_target, ImMin(def.SegmentN1, def.SegmentN2), def.ResizePivotN, 1 << axis, &pos_target, &size_target);
}
if (hovered)
*border_hovered = border_n;
@@ -7314,7 +7324,8 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, int* border_hove
if (accum_floored.x != 0.0f || accum_floored.y != 0.0f)
{
// FIXME-NAV: Should store and accumulate into a separate size buffer to handle sizing constraints properly, right now a constraint will make us stuck.
- size_target = CalcWindowSizeAfterConstraint(window, window->SizeFull + accum_floored);
+ const int resize_axis_mask = (accum_floored.x != 0.0f ? 0x01 : 0x00) | (accum_floored.y != 0.0f ? 0x02 : 0x00);
+ size_target = CalcWindowSizeAfterConstraint(window, window->SizeFull + accum_floored, resize_axis_mask);
g.NavWindowingAccumDeltaSize -= accum_floored;
}
}
@@ -7947,12 +7958,12 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// - Using SetNextWindowSize() overrides ImGuiWindowFlags_AlwaysAutoResize, so it can be used on tooltips/popups, etc.
// - We still process initial auto-fit on collapsed windows to get a window width, but otherwise don't honor ImGuiWindowFlags_AlwaysAutoResize when collapsed.
// - Auto-fit may only grow window during the first few frames.
+ int size_auto_fit_mask = 0x00;
{
const bool size_auto_fit_x_always = !window_size_x_set_by_api && (flags & ImGuiWindowFlags_AlwaysAutoResize) && !window->Collapsed;
const bool size_auto_fit_y_always = !window_size_y_set_by_api && (flags & ImGuiWindowFlags_AlwaysAutoResize) && !window->Collapsed;
const bool size_auto_fit_x_current = !window_size_x_set_by_api && (window->AutoFitFramesX > 0);
const bool size_auto_fit_y_current = !window_size_y_set_by_api && (window->AutoFitFramesY > 0);
- int size_auto_fit_mask = 0;
if (size_auto_fit_x_always || size_auto_fit_x_current)
size_auto_fit_mask |= (1 << ImGuiAxis_X);
if (size_auto_fit_y_always || size_auto_fit_y_current)
@@ -7981,7 +7992,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
}
// Apply minimum/maximum window size constraints and final size
- window->SizeFull = CalcWindowSizeAfterConstraint(window, window->SizeFull);
+ window->SizeFull = CalcWindowSizeAfterConstraint(window, window->SizeFull, size_auto_fit_mask);
window->Size = window->Collapsed && !(flags & ImGuiWindowFlags_ChildWindow) ? window->TitleBarRect().GetSize() : window->SizeFull;
// POSITION
@@ -11257,10 +11268,10 @@ static void ImGui::ErrorCheckNewFrameSanityChecks()
IM_ASSERT(g.Style.WindowBorderHoverPadding > 0.0f && "Invalid style setting!"); // Required otherwise cannot resize from borders.
IM_ASSERT(g.Style.WindowMenuButtonPosition == ImGuiDir_None || g.Style.WindowMenuButtonPosition == ImGuiDir_Left || g.Style.WindowMenuButtonPosition == ImGuiDir_Right);
IM_ASSERT(g.Style.ColorButtonPosition == ImGuiDir_Left || g.Style.ColorButtonPosition == ImGuiDir_Right);
- IM_ASSERT(ImIsPowerOfTwo(g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_DisplayMask_)); // Check only 1 option is selected
- IM_ASSERT(ImIsPowerOfTwo(g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_DataTypeMask_)); // "
- IM_ASSERT(ImIsPowerOfTwo(g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_PickerMask_)); // "
- IM_ASSERT(ImIsPowerOfTwo(g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_InputMask_)); // "
+ IM_ASSERT(ImIsPowerOfTwoOrZero(g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_DisplayMask_)); // Check 0 or 1 option selected, not more.
+ IM_ASSERT(ImIsPowerOfTwoOrZero(g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_DataTypeMask_)); // "
+ IM_ASSERT(ImIsPowerOfTwoOrZero(g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_PickerMask_)); // "
+ IM_ASSERT(ImIsPowerOfTwoOrZero(g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_InputMask_)); // "
IM_ASSERT(g.Style.TreeLinesFlags == ImGuiTreeNodeFlags_DrawLinesNone || g.Style.TreeLinesFlags == ImGuiTreeNodeFlags_DrawLinesFull || g.Style.TreeLinesFlags == ImGuiTreeNodeFlags_DrawLinesToNodes);
IM_ASSERT(g.IO.MouseSingleClickDelay > g.IO.MouseDoubleClickTime);
@@ -12215,8 +12226,8 @@ ImVec2 ImGui::ScrollToRectEx(ImGuiWindow* window, const ImRect& item_rect, ImGui
//GetForegroundDrawList(window)->AddRect(scroll_rect.Min, scroll_rect.Max, IM_COL32_WHITE); // [DEBUG]
// Check that only one behavior is selected per axis
- IM_ASSERT((flags & ImGuiScrollFlags_MaskX_) == 0 || ImIsPowerOfTwo(flags & ImGuiScrollFlags_MaskX_));
- IM_ASSERT((flags & ImGuiScrollFlags_MaskY_) == 0 || ImIsPowerOfTwo(flags & ImGuiScrollFlags_MaskY_));
+ IM_ASSERT(ImIsPowerOfTwoOrZero(flags & ImGuiScrollFlags_MaskX_));
+ IM_ASSERT(ImIsPowerOfTwoOrZero(flags & ImGuiScrollFlags_MaskY_));
// Defaults
ImGuiScrollFlags in_flags = flags;
diff --git a/imgui.h b/imgui.h
index a21ef47d2..996fceadb 100644
--- a/imgui.h
+++ b/imgui.h
@@ -1,4 +1,4 @@
-// dear imgui, v1.93.1
+// dear imgui, v1.93.2 WIP
// (headers)
// Help:
@@ -29,8 +29,8 @@
// Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
-#define IMGUI_VERSION "1.93.1"
-#define IMGUI_VERSION_NUM 19310
+#define IMGUI_VERSION "1.93.2 WIP"
+#define IMGUI_VERSION_NUM 19311
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198
@@ -2753,6 +2753,7 @@ struct ImGuiSizeCallbackData
ImVec2 Pos; // Read-only. Window position, for reference.
ImVec2 CurrentSize; // Read-only. Current window size.
ImVec2 DesiredSize; // Read-write. Desired size, based on user's mouse position. Write to this field to restrain resizing.
+ int ResizeAxisMask; // Read-only. Axes driving the resizing request. 0=unspecified, 1=X axis only, 2=Y axis only, 3=both axises. Does not restrict which output dimensions may change.
};
// Data payload for Drag and Drop operations: AcceptDragDropPayload(), GetDragDropPayload()
diff --git a/imgui_demo.cpp b/imgui_demo.cpp
index e24697ea1..2e3e6e62f 100644
--- a/imgui_demo.cpp
+++ b/imgui_demo.cpp
@@ -1,4 +1,4 @@
-// dear imgui, v1.93.1
+// dear imgui, v1.93.2 WIP
// (demo code)
// Help:
@@ -1362,9 +1362,9 @@ static void DemoWindowWidgetsColorAndPickers()
"We don't have Push/Pop functions because you can force options on a per-widget basis if needed, "
"and the user can change non-forced ones with the options menu.\nWe don't have a getter to avoid "
"encouraging you to persistently save values that aren't forward-compatible.");
- if (ImGui::Button("Overwrite default: Uint8 + HSV + Hue Bar"))
+ if (ImGui::Button("Overwrite default: Uint8 + HSV + Hue Bar", ImVec2(-FLT_MIN, 0.0f)))
ImGui::GetIO().ConfigColorEditFlags = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_PickerHueBar;
- if (ImGui::Button("Overwrite default: Float + HDR + Hue Wheel"))
+ if (ImGui::Button("Overwrite default: Float + HDR + Hue Wheel", ImVec2(-FLT_MIN, 0.0f)))
ImGui::GetIO().ConfigColorEditFlags = ImGuiColorEditFlags_Float | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_PickerHueWheel;
// Always display a small version of both types of pickers
@@ -10174,15 +10174,25 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
{
// Helper functions to demonstrate programmatic constraints
// FIXME: This doesn't take account of decoration size (e.g. title bar), library should make this easier.
- // FIXME: None of the three demos works consistently when resizing from borders.
static void AspectRatio(ImGuiSizeCallbackData* data)
{
float aspect_ratio = *(float*)data->UserData;
- data->DesiredSize.y = (float)(int)(data->DesiredSize.x / aspect_ratio);
+ if (data->ResizeAxisMask == 2)
+ data->DesiredSize.x = (float)(int)(data->DesiredSize.y * aspect_ratio);
+ else if (data->ResizeAxisMask == 1 || data->DesiredSize.x / aspect_ratio > data->DesiredSize.y)
+ data->DesiredSize.y = (float)(int)(data->DesiredSize.x / aspect_ratio);
+ else
+ data->DesiredSize.x = (float)(int)(data->DesiredSize.y * aspect_ratio);
}
static void Square(ImGuiSizeCallbackData* data)
{
- data->DesiredSize.x = data->DesiredSize.y = IM_MAX(data->DesiredSize.x, data->DesiredSize.y);
+ // A single-axis request drives both dimensions. Otherwise, fit the requested rectangle.
+ if (data->ResizeAxisMask == 1)
+ data->DesiredSize.y = data->DesiredSize.x;
+ else if (data->ResizeAxisMask == 2)
+ data->DesiredSize.x = data->DesiredSize.y;
+ else
+ data->DesiredSize.x = data->DesiredSize.y = IM_MAX(data->DesiredSize.x, data->DesiredSize.y);
}
static void Step(ImGuiSizeCallbackData* data)
{
@@ -10207,7 +10217,7 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
// Options
static bool auto_resize = false;
static bool window_padding = true;
- static int type = 6; // Aspect Ratio
+ static int type = 7; // Aspect Ratio
static int display_lines = 10;
// Submit constraint
@@ -10217,8 +10227,8 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
if (type == 1) ImGui::SetNextWindowSizeConstraints(ImVec2(100, 100), ImVec2(FLT_MAX, FLT_MAX)); // Width > 100, Height > 100
if (type == 2) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 0), ImVec2(-1, FLT_MAX)); // Resize vertical + lock current width
if (type == 3) ImGui::SetNextWindowSizeConstraints(ImVec2(0, -1), ImVec2(FLT_MAX, -1)); // Resize horizontal + lock current height
- if (type == 4) ImGui::SetNextWindowSizeConstraints(ImVec2(400, -1), ImVec2(500, -1)); // Width Between and 400 and 500
- if (type == 5) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 400), ImVec2(-1, FLT_MAX)); // Height at least 400
+ if (type == 4) ImGui::SetNextWindowSizeConstraints(ImVec2(400, 0), ImVec2(500, FLT_MAX)); // Width Between and 400 and 500
+ if (type == 5) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 400), ImVec2(FLT_MAX, FLT_MAX)); // Height at least 400
if (type == 6) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::AspectRatio, (void*)&aspect_ratio); // Aspect ratio
if (type == 7) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Square); // Always Square
if (type == 8) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Step, (void*)&fixed_step); // Fixed Step
diff --git a/imgui_draw.cpp b/imgui_draw.cpp
index ccf9de99b..64fc5f0a0 100644
--- a/imgui_draw.cpp
+++ b/imgui_draw.cpp
@@ -1,4 +1,4 @@
-// dear imgui, v1.93.1
+// dear imgui, v1.93.2 WIP
// (drawing and font code)
/*
diff --git a/imgui_internal.h b/imgui_internal.h
index 6df2192fd..d251ae6b2 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -1,4 +1,4 @@
-// dear imgui, v1.93.1
+// dear imgui, v1.93.2 WIP
// (internal structures/api)
// You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility.
@@ -387,6 +387,7 @@ IMGUI_API ImU32 ImAlphaBlendColors(ImU32 col_a, ImU32 col_b);
// Helpers: Bit manipulation
inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; }
+inline bool ImIsPowerOfTwoOrZero(int v) { return (v & (v - 1)) == 0; }
inline bool ImIsPowerOfTwo(ImU64 v) { return v != 0 && (v & (v - 1)) == 0; }
inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
inline unsigned int ImCountSetBits(unsigned int v) { unsigned int count = 0; while (v > 0) { v = v & (v - 1); count++; } return count; }
diff --git a/imgui_tables.cpp b/imgui_tables.cpp
index ff181847a..adc164f00 100644
--- a/imgui_tables.cpp
+++ b/imgui_tables.cpp
@@ -1,4 +1,4 @@
-// dear imgui, v1.93.1
+// dear imgui, v1.93.2 WIP
// (tables and columns code)
/*
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp
index a6826002d..15f7d6a6e 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -1,4 +1,4 @@
-// dear imgui, v1.93.1
+// dear imgui, v1.93.2 WIP
// (widgets code)
/*
@@ -5948,18 +5948,17 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
if (!(flags & ImGuiColorEditFlags_NoOptions))
ColorEditOptionsPopup(col, flags);
- // Read stored options
- if (!(flags & ImGuiColorEditFlags_DisplayMask_))
- flags |= (g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_DisplayMask_);
- if (!(flags & ImGuiColorEditFlags_DataTypeMask_))
- flags |= (g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_DataTypeMask_);
- if (!(flags & ImGuiColorEditFlags_PickerMask_))
- flags |= (g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_PickerMask_);
- if (!(flags & ImGuiColorEditFlags_InputMask_))
- flags |= (g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_InputMask_);
- flags |= (g.IO.ConfigColorEditFlags & ~(ImGuiColorEditFlags_DisplayMask_ | ImGuiColorEditFlags_DataTypeMask_ | ImGuiColorEditFlags_PickerMask_ | ImGuiColorEditFlags_InputMask_));
- IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags_DisplayMask_)); // Check that only 1 is selected
- IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags_InputMask_)); // Check that only 1 is selected
+ // Apply stored/default options
+ ImGuiColorEditFlags flags_cfg = g.IO.ConfigColorEditFlags;
+ if ((flags & ImGuiColorEditFlags_DisplayMask_) == 0)
+ flags |= ((flags_cfg & ImGuiColorEditFlags_DisplayMask_) ? flags_cfg : ImGuiColorEditFlags_DefaultOptions_) & ImGuiColorEditFlags_DisplayMask_;
+ if ((flags & ImGuiColorEditFlags_DataTypeMask_) == 0)
+ flags |= ((flags_cfg & ImGuiColorEditFlags_DataTypeMask_) ? flags_cfg : ImGuiColorEditFlags_DefaultOptions_) & ImGuiColorEditFlags_DataTypeMask_;
+ if ((flags & ImGuiColorEditFlags_PickerMask_) == 0)
+ flags |= ((flags_cfg & ImGuiColorEditFlags_PickerMask_) ? flags_cfg : ImGuiColorEditFlags_DefaultOptions_) & ImGuiColorEditFlags_PickerMask_;
+ if ((flags & ImGuiColorEditFlags_InputMask_) == 0)
+ flags |= ((flags_cfg & ImGuiColorEditFlags_InputMask_) ? flags_cfg : ImGuiColorEditFlags_DefaultOptions_) & ImGuiColorEditFlags_InputMask_;
+ flags |= (flags_cfg & ~(ImGuiColorEditFlags_DisplayMask_ | ImGuiColorEditFlags_DataTypeMask_ | ImGuiColorEditFlags_PickerMask_ | ImGuiColorEditFlags_InputMask_));
const bool alpha = (flags & ImGuiColorEditFlags_NoAlpha) == 0;
const bool hdr = (flags & ImGuiColorEditFlags_HDR) != 0;
@@ -6240,14 +6239,12 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
if (!(flags & ImGuiColorEditFlags_NoOptions))
ColorPickerOptionsPopup(col, flags);
- // Read stored options
- if (!(flags & ImGuiColorEditFlags_PickerMask_))
+ // Apply stored/default options
+ if ((flags & ImGuiColorEditFlags_PickerMask_) == 0)
flags |= ((g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_PickerMask_) ? g.IO.ConfigColorEditFlags : ImGuiColorEditFlags_DefaultOptions_) & ImGuiColorEditFlags_PickerMask_;
- if (!(flags & ImGuiColorEditFlags_InputMask_))
+ if ((flags & ImGuiColorEditFlags_InputMask_) == 0)
flags |= ((g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_InputMask_) ? g.IO.ConfigColorEditFlags : ImGuiColorEditFlags_DefaultOptions_) & ImGuiColorEditFlags_InputMask_;
- IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags_PickerMask_)); // Check that only 1 is selected
- IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags_InputMask_)); // Check that only 1 is selected
- if (!(flags & ImGuiColorEditFlags_NoOptions))
+ if ((flags & ImGuiColorEditFlags_NoOptions) == 0)
flags |= (g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_AlphaBar);
// Setup