Skip to content

Commit 6327b63

Browse files
committed
Merge branch 'master' into docking
# Conflicts: # imgui.cpp # imgui_internal.h
2 parents 8e67fe1 + fa4b47c commit 6327b63

File tree

7 files changed

+117
-42
lines changed

7 files changed

+117
-42
lines changed

docs/CHANGELOG.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,23 @@ Other Changes:
6464
between hard minimum window size and table minimum size).
6565
- Fixed an issue where submitting non-integer row heights would eventually
6666
advance table parent layout by +0/+1 depending on its visibility.
67+
- ColorEdit:
68+
- Added R/G/B/A color markers next to each component (enabled by default).
69+
- Added ImGuiColorEditFlags_NoColorMarkers to disable them.
70+
- Added style.ColorMarkerSize to configure width of color component markers.
71+
- Sliders, Drags:
72+
- Added ImGuiSliderFlags_ColorMarkers to opt-in adding R/G/B/A color markers
73+
next to each components, in multi-components functions.
74+
- Added a way to select a specific marker color.
75+
- Text:
76+
- Fixed low-level word-wrapping function reading from *text_end when passed
77+
a string range. (#9107) [@achabense]
6778
- Scrollbar: fixed a codepath leading to a divide-by-zero (which would not be
6879
noticeable by user but detected by sanitizers). (#9089) [@judicaelclair]
6980
- Debug Tools:
7081
- Debug Log: fixed incorrectly printing characters in IO log when submitting
7182
non-ASCII values to io.AddInputCharacter(). (#9099)
83+
- Debug Log: can output to debugger on Windows. (#5855)
7284
- Backends:
7385
- SDL_GPU3: macOS version can use MSL shaders in order to support macOS 10.14+
7486
(vs Metallib shaders requiring macOS 14+). Requires application calling

imgui.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,6 +1482,7 @@ ImGuiStyle::ImGuiStyle()
14821482
DragDropTargetRounding = 0.0f; // Radius of the drag and drop target frame.
14831483
DragDropTargetBorderSize = 2.0f; // Thickness of the drag and drop target border.
14841484
DragDropTargetPadding = 3.0f; // Size to expand the drag and drop target from actual target item size.
1485+
ColorMarkerSize = 3.0f; // Size of R/G/B/A color markers for ColorEdit4() and for Drags/Sliders when using ImGuiSliderFlags_ColorMarkers.
14851486
ColorButtonPosition = ImGuiDir_Right; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
14861487
ButtonTextAlign = ImVec2(0.5f,0.5f);// Alignment of button text when button is larger than text.
14871488
SelectableTextAlign = ImVec2(0.0f,0.0f);// Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line.
@@ -1551,6 +1552,7 @@ void ImGuiStyle::ScaleAllSizes(float scale_factor)
15511552
DragDropTargetRounding = ImTrunc(DragDropTargetRounding * scale_factor);
15521553
DragDropTargetBorderSize = ImTrunc(DragDropTargetBorderSize * scale_factor);
15531554
DragDropTargetPadding = ImTrunc(DragDropTargetPadding * scale_factor);
1555+
ColorMarkerSize = ImTrunc(ColorMarkerSize * scale_factor);
15541556
SeparatorTextPadding = ImTrunc(SeparatorTextPadding * scale_factor);
15551557
DockingSeparatorSize = ImTrunc(DockingSeparatorSize * scale_factor);
15561558
DisplayWindowPadding = ImTrunc(DisplayWindowPadding * scale_factor);
@@ -3998,6 +4000,18 @@ void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding)
39984000
}
39994001
}
40004002

4003+
// FIXME: Might move those to style if there is a real need.
4004+
static const ImU32 GColorMarkers[4] = { IM_COL32(240,20,20,255), IM_COL32(20,240,20,255), IM_COL32(20,20,240,255), IM_COL32(140,140,140,255) };
4005+
4006+
void ImGui::RenderColorComponentMarker(int component_idx, const ImRect& bb, float rounding)
4007+
{
4008+
if (!(component_idx >= 0 && component_idx < 4) || (bb.Min.x + 1 >= bb.Max.x))
4009+
return;
4010+
ImGuiContext& g = *GImGui;
4011+
ImGuiWindow* window = g.CurrentWindow;
4012+
RenderRectFilledInRangeH(window->DrawList, bb, GetColorU32(GColorMarkers[component_idx]), bb.Min.x, ImMin(bb.Min.x + g.Style.ColorMarkerSize, bb.Max.x), rounding);
4013+
}
4014+
40014015
void ImGui::RenderNavCursor(const ImRect& bb, ImGuiID id, ImGuiNavRenderCursorFlags flags)
40024016
{
40034017
ImGuiContext& g = *GImGui;
@@ -15281,13 +15295,12 @@ void ImGui::NavUpdateWindowingOverlay()
1528115295
if (g.NavWindowingTimer < NAV_WINDOWING_LIST_APPEAR_DELAY)
1528215296
return;
1528315297

15284-
if (g.NavWindowingListWindow == NULL)
15285-
g.NavWindowingListWindow = FindWindowByName("##NavWindowingOverlay");
1528615298
const ImGuiViewport* viewport = /*g.NavWindow ? g.NavWindow->Viewport :*/ GetMainViewport();
1528715299
SetNextWindowSizeConstraints(ImVec2(viewport->Size.x * 0.20f, viewport->Size.y * 0.20f), ImVec2(FLT_MAX, FLT_MAX));
1528815300
SetNextWindowPos(viewport->GetCenter(), ImGuiCond_Always, ImVec2(0.5f, 0.5f));
1528915301
PushStyleVar(ImGuiStyleVar_WindowPadding, g.Style.WindowPadding * 2.0f);
1529015302
Begin("##NavWindowingOverlay", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings);
15303+
g.NavWindowingListWindow = g.CurrentWindow;
1529115304
if (g.ContextName[0] != 0)
1529215305
SeparatorText(g.ContextName);
1529315306
for (int n = g.WindowsFocusOrder.Size - 1; n >= 0; n--)
@@ -23522,14 +23535,23 @@ void ImGui::DebugLogV(const char* fmt, va_list args)
2352223535
g.DebugLogBuf.appendf("[%05d] ", g.FrameCount);
2352323536
g.DebugLogBuf.appendfv(fmt, args);
2352423537
g.DebugLogIndex.append(g.DebugLogBuf.c_str(), old_size, g.DebugLogBuf.size());
23538+
23539+
const char* str = g.DebugLogBuf.begin() + old_size;
2352523540
if (g.DebugLogFlags & ImGuiDebugLogFlags_OutputToTTY)
23526-
IMGUI_DEBUG_PRINTF("%s", g.DebugLogBuf.begin() + old_size);
23541+
IMGUI_DEBUG_PRINTF("%s", str);
23542+
#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
23543+
if (g.DebugLogFlags & ImGuiDebugLogFlags_OutputToDebugger)
23544+
{
23545+
::OutputDebugStringA("[imgui] ");
23546+
::OutputDebugStringA(str);
23547+
}
23548+
#endif
2352723549
#ifdef IMGUI_ENABLE_TEST_ENGINE
2352823550
// IMGUI_TEST_ENGINE_LOG() adds a trailing \n automatically
2352923551
const int new_size = g.DebugLogBuf.size();
2353023552
const bool trailing_carriage_return = (g.DebugLogBuf[new_size - 1] == '\n');
2353123553
if (g.DebugLogFlags & ImGuiDebugLogFlags_OutputToTestEngine)
23532-
IMGUI_TEST_ENGINE_LOG("%.*s", new_size - old_size - (trailing_carriage_return ? 1 : 0), g.DebugLogBuf.begin() + old_size);
23554+
IMGUI_TEST_ENGINE_LOG("%.*s", new_size - old_size - (trailing_carriage_return ? 1 : 0), str);
2353323555
#endif
2353423556
}
2353523557

@@ -23611,6 +23633,7 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
2361123633
if (BeginPopup("Outputs"))
2361223634
{
2361323635
CheckboxFlags("OutputToTTY", &g.DebugLogFlags, ImGuiDebugLogFlags_OutputToTTY);
23636+
CheckboxFlags("OutputToDebugger", &g.DebugLogFlags, ImGuiDebugLogFlags_OutputToDebugger);
2361423637
#ifndef IMGUI_ENABLE_TEST_ENGINE
2361523638
BeginDisabled();
2361623639
#endif

imgui.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
// Library Version
3131
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
3232
#define IMGUI_VERSION "1.92.6 WIP"
33-
#define IMGUI_VERSION_NUM 19252
33+
#define IMGUI_VERSION_NUM 19253
3434
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
3535
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198
3636
#define IMGUI_HAS_VIEWPORT // In 'docking' WIP branch.
@@ -1957,17 +1957,18 @@ enum ImGuiColorEditFlags_
19571957
ImGuiColorEditFlags_NoSidePreview = 1 << 8, // // ColorPicker: disable bigger color preview on right side of the picker, use small color square preview instead.
19581958
ImGuiColorEditFlags_NoDragDrop = 1 << 9, // // ColorEdit: disable drag and drop target. ColorButton: disable drag and drop source.
19591959
ImGuiColorEditFlags_NoBorder = 1 << 10, // // ColorButton: disable border (which is enforced by default)
1960+
ImGuiColorEditFlags_NoColorMarkers = 1 << 11, // // ColorEdit: disable rendering R/G/B/A color marker. May also be disabled globally by setting style.ColorMarkerSize = 0.
19601961

19611962
// Alpha preview
19621963
// - Prior to 1.91.8 (2025/01/21): alpha was made opaque in the preview by default using old name ImGuiColorEditFlags_AlphaPreview.
19631964
// - We now display the preview as transparent by default. You can use ImGuiColorEditFlags_AlphaOpaque to use old behavior.
19641965
// - The new flags may be combined better and allow finer controls.
1965-
ImGuiColorEditFlags_AlphaOpaque = 1 << 11, // // ColorEdit, ColorPicker, ColorButton: disable alpha in the preview,. Contrary to _NoAlpha it may still be edited when calling ColorEdit4()/ColorPicker4(). For ColorButton() this does the same as _NoAlpha.
1966-
ImGuiColorEditFlags_AlphaNoBg = 1 << 12, // // ColorEdit, ColorPicker, ColorButton: disable rendering a checkerboard background behind transparent color.
1967-
ImGuiColorEditFlags_AlphaPreviewHalf= 1 << 13, // // ColorEdit, ColorPicker, ColorButton: display half opaque / half transparent preview.
1966+
ImGuiColorEditFlags_AlphaOpaque = 1 << 12, // // ColorEdit, ColorPicker, ColorButton: disable alpha in the preview,. Contrary to _NoAlpha it may still be edited when calling ColorEdit4()/ColorPicker4(). For ColorButton() this does the same as _NoAlpha.
1967+
ImGuiColorEditFlags_AlphaNoBg = 1 << 13, // // ColorEdit, ColorPicker, ColorButton: disable rendering a checkerboard background behind transparent color.
1968+
ImGuiColorEditFlags_AlphaPreviewHalf= 1 << 14, // // ColorEdit, ColorPicker, ColorButton: display half opaque / half transparent preview.
19681969

19691970
// User Options (right-click on widget to change some of them).
1970-
ImGuiColorEditFlags_AlphaBar = 1 << 16, // // ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker.
1971+
ImGuiColorEditFlags_AlphaBar = 1 << 18, // // ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker.
19711972
ImGuiColorEditFlags_HDR = 1 << 19, // // (WIP) ColorEdit: Currently only disable 0.0f..1.0f limits in RGBA edition (note: you probably want to use ImGuiColorEditFlags_Float flag as well).
19721973
ImGuiColorEditFlags_DisplayRGB = 1 << 20, // [Display] // ColorEdit: override _display_ type among RGB/HSV/Hex. ColorPicker: select any combination using one or more of RGB/HSV/Hex.
19731974
ImGuiColorEditFlags_DisplayHSV = 1 << 21, // [Display] // "
@@ -2011,7 +2012,12 @@ enum ImGuiSliderFlags_
20112012
ImGuiSliderFlags_ClampZeroRange = 1 << 10, // Clamp even if min==max==0.0f. Otherwise due to legacy reason DragXXX functions don't clamp with those values. When your clamping limits are dynamic you almost always want to use it.
20122013
ImGuiSliderFlags_NoSpeedTweaks = 1 << 11, // Disable keyboard modifiers altering tweak speed. Useful if you want to alter tweak speed yourself based on your own logic.
20132014
ImGuiSliderFlags_AlwaysClamp = ImGuiSliderFlags_ClampOnInput | ImGuiSliderFlags_ClampZeroRange,
2014-
ImGuiSliderFlags_InvalidMask_ = 0x7000000F, // [Internal] We treat using those bits as being potentially a 'float power' argument from the previous API that has got miscast to this enum, and will trigger an assert if needed.
2015+
2016+
// Color Markers
2017+
ImGuiSliderFlags_ColorMarkers = 1 << 12, // DragScalarN(), SliderScalarN(): Draw R/G/B/A color markers on each component.
2018+
ImGuiSliderFlags_ColorMarkersIndexShift_ = 13, // [Internal] DragScalar(), SliderScalar(): Pass ([0..3] << ImGuiSliderFlags_ColorMarkersIndexShift_) along with ImGuiSliderFlags_ColorMarkers to select an individual R/G/B/A color.
2019+
2020+
ImGuiSliderFlags_InvalidMask_ = 0x7000000F, // [Internal] We treat using those bits as being potentially a 'float power' argument from legacy API (obsoleted 2020-08) that has got miscast to this enum, and will trigger an assert if needed.
20152021
};
20162022

20172023
// Identify a mouse button.
@@ -2398,6 +2404,7 @@ struct ImGuiStyle
23982404
float DragDropTargetRounding; // Radius of the drag and drop target frame.
23992405
float DragDropTargetBorderSize; // Thickness of the drag and drop target border.
24002406
float DragDropTargetPadding; // Size to expand the drag and drop target from actual target item size.
2407+
float ColorMarkerSize; // Size of R/G/B/A color markers for ColorEdit4() and for Drags/Sliders when using ImGuiSliderFlags_ColorMarkers.
24012408
ImGuiDir ColorButtonPosition; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
24022409
ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered).
24032410
ImVec2 SelectableTextAlign; // Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line.

imgui_demo.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,8 +1167,9 @@ static void DemoWindowWidgetsColorAndPickers()
11671167
ImGui::CheckboxFlags("ImGuiColorEditFlags_AlphaOpaque", &base_flags, ImGuiColorEditFlags_AlphaOpaque);
11681168
ImGui::CheckboxFlags("ImGuiColorEditFlags_AlphaNoBg", &base_flags, ImGuiColorEditFlags_AlphaNoBg);
11691169
ImGui::CheckboxFlags("ImGuiColorEditFlags_AlphaPreviewHalf", &base_flags, ImGuiColorEditFlags_AlphaPreviewHalf);
1170-
ImGui::CheckboxFlags("ImGuiColorEditFlags_NoDragDrop", &base_flags, ImGuiColorEditFlags_NoDragDrop);
11711170
ImGui::CheckboxFlags("ImGuiColorEditFlags_NoOptions", &base_flags, ImGuiColorEditFlags_NoOptions); ImGui::SameLine(); HelpMarker("Right-click on the individual color widget to show options.");
1171+
ImGui::CheckboxFlags("ImGuiColorEditFlags_NoDragDrop", &base_flags, ImGuiColorEditFlags_NoDragDrop);
1172+
ImGui::CheckboxFlags("ImGuiColorEditFlags_NoColorMarkers", &base_flags, ImGuiColorEditFlags_NoColorMarkers);
11721173
ImGui::CheckboxFlags("ImGuiColorEditFlags_HDR", &base_flags, ImGuiColorEditFlags_HDR); ImGui::SameLine(); HelpMarker("Currently all this does is to lift the 0..1 limits on dragging widgets.");
11731174

11741175
IMGUI_DEMO_MARKER("Widgets/Color/ColorEdit");
@@ -1781,9 +1782,12 @@ static void DemoWindowWidgetsDragsAndSliders()
17811782
ImGui::SameLine(); HelpMarker("Disable keyboard modifiers altering tweak speed. Useful if you want to alter tweak speed yourself based on your own logic.");
17821783
ImGui::CheckboxFlags("ImGuiSliderFlags_WrapAround", &flags, ImGuiSliderFlags_WrapAround);
17831784
ImGui::SameLine(); HelpMarker("Enable wrapping around from max to min and from min to max (only supported by DragXXX() functions)");
1785+
ImGui::CheckboxFlags("ImGuiSliderFlags_ColorMarkers", &flags, ImGuiSliderFlags_ColorMarkers);
1786+
//ImGui::CheckboxFlags("ImGuiSliderFlags_ColorMarkersG", &flags, 1 << ImGuiSliderFlags_ColorMarkersIndexShift_); // Not explicitly documented but possible.
17841787

17851788
// Drags
17861789
static float drag_f = 0.5f;
1790+
static float drag_f4[4];
17871791
static int drag_i = 50;
17881792
ImGui::Text("Underlying float value: %f", drag_f);
17891793
ImGui::DragFloat("DragFloat (0 -> 1)", &drag_f, 0.005f, 0.0f, 1.0f, "%.3f", flags);
@@ -1793,14 +1797,17 @@ static void DemoWindowWidgetsDragsAndSliders()
17931797
//ImGui::DragFloat("DragFloat (0 -> 0)", &drag_f, 0.005f, 0.0f, 0.0f, "%.3f", flags); // To test ClampZeroRange
17941798
//ImGui::DragFloat("DragFloat (100 -> 100)", &drag_f, 0.005f, 100.0f, 100.0f, "%.3f", flags);
17951799
ImGui::DragInt("DragInt (0 -> 100)", &drag_i, 0.5f, 0, 100, "%d", flags);
1800+
ImGui::DragFloat4("DragFloat4 (0 -> 1)", drag_f4, 0.005f, 0.0f, 1.0f, "%.3f", flags); // Multi-component item, mostly here to document the effect of ImGuiSliderFlags_ColorMarkers.
17961801

17971802
// Sliders
17981803
static float slider_f = 0.5f;
1804+
static float slider_f4[4];
17991805
static int slider_i = 50;
1800-
const ImGuiSliderFlags flags_for_sliders = flags & ~ImGuiSliderFlags_WrapAround;
1806+
const ImGuiSliderFlags flags_for_sliders = (flags & ~ImGuiSliderFlags_WrapAround);
18011807
ImGui::Text("Underlying float value: %f", slider_f);
18021808
ImGui::SliderFloat("SliderFloat (0 -> 1)", &slider_f, 0.0f, 1.0f, "%.3f", flags_for_sliders);
18031809
ImGui::SliderInt("SliderInt (0 -> 100)", &slider_i, 0, 100, "%d", flags_for_sliders);
1810+
ImGui::SliderFloat4("SliderFloat4 (0 -> 1)", slider_f4, 0.0f, 1.0f, "%.3f", flags); // Multi-component item, mostly here to document the effect of ImGuiSliderFlags_ColorMarkers.
18041811

18051812
ImGui::TreePop();
18061813
}
@@ -2116,20 +2123,21 @@ static void DemoWindowWidgetsProgressBars()
21162123
if (ImGui::TreeNode("Progress Bars"))
21172124
{
21182125
// Animate a simple progress bar
2119-
static float progress = 0.0f, progress_dir = 1.0f;
2120-
progress += progress_dir * 0.4f * ImGui::GetIO().DeltaTime;
2121-
if (progress >= +1.1f) { progress = +1.1f; progress_dir *= -1.0f; }
2122-
if (progress <= -0.1f) { progress = -0.1f; progress_dir *= -1.0f; }
2126+
static float progress_accum = 0.0f, progress_dir = 1.0f;
2127+
progress_accum += progress_dir * 0.4f * ImGui::GetIO().DeltaTime;
2128+
if (progress_accum >= +1.1f) { progress_accum = +1.1f; progress_dir *= -1.0f; }
2129+
if (progress_accum <= -0.1f) { progress_accum = -0.1f; progress_dir *= -1.0f; }
2130+
2131+
const float progress = IM_CLAMP(progress_accum, 0.0f, 1.0f);
21232132

21242133
// Typically we would use ImVec2(-1.0f,0.0f) or ImVec2(-FLT_MIN,0.0f) to use all available width,
21252134
// or ImVec2(width,0.0f) for a specified width. ImVec2(0.0f,0.0f) uses ItemWidth.
21262135
ImGui::ProgressBar(progress, ImVec2(0.0f, 0.0f));
21272136
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
21282137
ImGui::Text("Progress Bar");
21292138

2130-
float progress_saturated = IM_CLAMP(progress, 0.0f, 1.0f);
21312139
char buf[32];
2132-
sprintf(buf, "%d/%d", (int)(progress_saturated * 1753), 1753);
2140+
sprintf(buf, "%d/%d", (int)(progress * 1753), 1753);
21332141
ImGui::ProgressBar(progress, ImVec2(0.f, 0.f), buf);
21342142

21352143
// Pass an animated negative value, e.g. -1.0f * (float)ImGui::GetTime() is the recommended value.
@@ -8552,6 +8560,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
85528560
style.WindowMenuButtonPosition = (ImGuiDir)(window_menu_button_position - 1);
85538561

85548562
SeparatorText("Widgets");
8563+
SliderFloat("ColorMarkerSize", &style.ColorMarkerSize, 0.0f, 8.0f, "%.0f");
85558564
Combo("ColorButtonPosition", (int*)&style.ColorButtonPosition, "Left\0Right\0");
85568565
SliderFloat2("ButtonTextAlign", (float*)&style.ButtonTextAlign, 0.0f, 1.0f, "%.2f");
85578566
SameLine(); HelpMarker("Alignment applies when a button is larger than its text content.");

0 commit comments

Comments
 (0)