Merge branch 'master' into docking

# Conflicts:
#	docs/CHANGELOG.txt
This commit is contained in:
ocornut 2023-02-14 16:01:11 +01:00
commit 192196711a
10 changed files with 97 additions and 59 deletions

View File

@ -685,7 +685,13 @@ static int parse_version(void)
return GL3W_ERROR_INIT; return GL3W_ERROR_INIT;
glGetIntegerv(GL_MAJOR_VERSION, &version.major); glGetIntegerv(GL_MAJOR_VERSION, &version.major);
glGetIntegerv(GL_MINOR_VERSION, &version.minor); glGetIntegerv(GL_MINOR_VERSION, &version.minor);
if (version.major < 3) if (version.major == 0 && version.minor == 0)
{
// Query GL_VERSION in desktop GL 2.x, the string will start with "<major>.<minor>"
const char* gl_version = (const char*)glGetString(GL_VERSION);
sscanf(gl_version, "%d.%d", &version.major, &version.minor);
}
if (version.major < 2)
return GL3W_ERROR_OPENGL_VERSION; return GL3W_ERROR_OPENGL_VERSION;
return GL3W_OK; return GL3W_OK;
} }
@ -709,7 +715,7 @@ int imgl3wInit2(GL3WGetProcAddressProc proc)
int imgl3wIsSupported(int major, int minor) int imgl3wIsSupported(int major, int minor)
{ {
if (major < 3) if (major < 2)
return 0; return 0;
if (version.major == major) if (version.major == major)
return version.minor >= minor; return version.minor >= minor;

View File

@ -99,29 +99,39 @@ Other changes:
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.89.3 (In Progress) VERSION 1.89.3 (Released 2023-02-14)
----------------------------------------------------------------------- -----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.89.3
Breaking Changes: Breaking Changes:
- Backends+Examples: SDL2: renamed all unnumbered references to "sdl" to "sdl2". - Backends+Examples: SDL2: renamed all unnumbered references to "sdl" to "sdl2".
This is in prevision for the future release of SDL3 (#6146) This is in prevision for the future release of SDL3 and its associated backend. (#6146)
- imgui_impl_sdl.cpp -> imgui_impl_sdl2.cpp - imgui_impl_sdl.cpp -> imgui_impl_sdl2.cpp
- imgui_impl_sdl.h -> imgui_impl_sdl2.h - imgui_impl_sdl.h -> imgui_impl_sdl2.h
- example_sdl_xxxx/ -> example_sdl2_xxxx/ (folders and projects) - example_sdl_xxxx/ -> example_sdl2_xxxx/ (folders and projects)
All changes: All changes:
- SeparatorText(): Added SeparatorText() widget. (#1643) [@phed, @ocornut]
- Added to style: float SeparatorTextBorderSize.
- Added to style: ImVec2 SeparatorTextAlign, SeparatorTextPadding.
- Tables: Raised max Columns count from 64 to 512. (#6094, #5305, #4876, #3572)
The previous limit was due to using 64-bit integers but we moved to bits-array
and tweaked the system enough to ensure no performance loss.
- Tables: Solved an ID conflict issue with multiple-instances of a same table,
due to how unique table instance id was generated. (#6140) [@ocornut, @rodrigorc]
- Inputs, Scrolling: Made horizontal scroll wheel and horizontal scroll direction consistent - Inputs, Scrolling: Made horizontal scroll wheel and horizontal scroll direction consistent
accross backends/os. (#4019, #6096, #1463) [@PathogenDavid, @ocornut, @rokups] across backends/os. (#4019, #6096, #1463) [@PathogenDavid, @ocornut, @rokups]
- Clarified that 'wheel_y > 0.0f' scrolls Up, 'wheel_y > 0.0f' scrolls Down. - Clarified that 'wheel_y > 0.0f' scrolls Up, 'wheel_y > 0.0f' scrolls Down.
Clarified that 'wheel_x > 0.0f' scrolls Left, 'wheel_x > 0.0f' scrolls Right. Clarified that 'wheel_x > 0.0f' scrolls Left, 'wheel_x > 0.0f' scrolls Right.
- Backends: Fixed horizontal scroll direction for Win32 and SDL backends. (#4019) - Backends: Fixed horizontal scroll direction for Win32 and SDL backends. (#4019)
- Shift+WheelY support on non-OSX machines was already correct. (#2424, #1463) - Shift+WheelY support on non-OSX machines was already correct. (#2424, #1463)
(whereaas on OSX machines Shift+WheelY turns into WheelX at the OS level). (whereas on OSX machines Shift+WheelY turns into WheelX at the OS level).
- If you use a custom-backend, you should verify horizontal wheel direction. - If you use a custom backend, you should verify horizontal wheel direction.
- Axises are flipped by OSX for mouse & touchpad when 'Natural Scrolling' is on. - Axises are flipped by OSX for mouse & touch-pad when 'Natural Scrolling' is on.
- Axises are flipped by Windows for touchpad when 'Settings->Touchpad->Down motion scrolls up' is on. - Axises are flipped by Windows for touch-pad when 'Settings->Touchpad->Down motion scrolls up' is on.
- You can use 'Demo->Tools->Debug Log->IO" to visualize values submitted to Dear ImGui. - You can use 'Demo->Tools->Debug Log->IO" to visualize values submitted to Dear ImGui.
- Known issues remaining with Emscripten: - Known issues remaining with Emscripten:
- The magnitude of wheeling values on Emscripten was improved but isn't perfect. (#6096) - The magnitude of wheeling values on Emscripten was improved but isn't perfect. (#6096)
@ -131,14 +141,6 @@ All changes:
to find a way to detect this and set io.ConfigMacOSXBehaviors manually (if you know a way to find a way to detect this and set io.ConfigMacOSXBehaviors manually (if you know a way
let us know!), or offer the "OSX-style behavior" option to their user. let us know!), or offer the "OSX-style behavior" option to their user.
- Window: Avoid rendering shapes for hidden resize grips. - Window: Avoid rendering shapes for hidden resize grips.
- SeparatorText(): Added SeparatorText() widget. (#1643) [@phed, @ocornut]
- Added to style: float SeparatorTextBorderSize.
- Added to style: ImVec2 SeparatorTextAlign, SeparatorTextPadding.
- Tables: Raised max Columns count from 64 to 512. (#6094, #5305, #4876, #3572)
The previous limit was due to using 64-bit integers but we moved to bits-array
and tweaked the system enough to ensure no performance loss.
- Tables: Solved an ID conflict issue with multiple-instances of a same table,
due to how unique table instance id was generated. (#6140) [@ocornut, @rodrigorc]
- Text: Fixed layouting of wrapped-text block skipping successive empty lines, - Text: Fixed layouting of wrapped-text block skipping successive empty lines,
regression from the fix in 1.89.2. (#5720, #5919) regression from the fix in 1.89.2. (#5720, #5919)
- Text: Fixed clipping of single-character "..." ellipsis (U+2026 or U+0085) when font - Text: Fixed clipping of single-character "..." ellipsis (U+2026 or U+0085) when font
@ -149,8 +151,11 @@ All changes:
(Not adding Super+Delete to delete to up to end-of-line on OSX, as OSX doesn't have it) (Not adding Super+Delete to delete to up to end-of-line on OSX, as OSX doesn't have it)
- InputText: On OSX, inhibit usage of Alt key to toggle menu when active (used for work skip). - InputText: On OSX, inhibit usage of Alt key to toggle menu when active (used for work skip).
- Menus: Fixed layout of MenuItem()/BeginMenu() when label contains a '\n'. (#6116) [@imkcy9] - Menus: Fixed layout of MenuItem()/BeginMenu() when label contains a '\n'. (#6116) [@imkcy9]
- ColorEdit, ColorPicker: Fixed hue/saturation preservation logic from interfering with
the displayed value (but not stored value) of others widgets instances. (#6155)
- PlotHistogram, PlotLines: Passing negative sizes honor alignment like other widgets. - PlotHistogram, PlotLines: Passing negative sizes honor alignment like other widgets.
- Combo: Allow SetNextWindowSize() to alter combo popup size. (#6130) - Combo: Allow SetNextWindowSize() to alter combo popup size. (#6130)
- Fonts: Assert that in each GlyphRanges[] pairs first is <= second.
- ImDrawList: Added missing early-out in AddPolyline() and AddConvexPolyFilled() when - ImDrawList: Added missing early-out in AddPolyline() and AddConvexPolyFilled() when
color alpha is zero. color alpha is zero.
- Misc: Most text functions treat "%s" as a shortcut to no-formatting. (#3466) - Misc: Most text functions treat "%s" as a shortcut to no-formatting. (#3466)
@ -159,15 +164,15 @@ All changes:
can exacerbate that. (#6114, #3644) can exacerbate that. (#6114, #3644)
- Backends: OSX: Fixed scroll/wheel scaling for devices emitting events with - Backends: OSX: Fixed scroll/wheel scaling for devices emitting events with
hasPreciseScrollingDeltas==false (e.g. non-Apple mices). hasPreciseScrollingDeltas==false (e.g. non-Apple mices).
- Backends: Win32: flipping WM_MOUSEHWHEEL value to match other backends and - Backends: Win32: flipping WM_MOUSEHWHEEL horizontal value to match other backends and
offer consistent horizontal scrolling direction. (#4019) offer consistent horizontal scrolling direction. (#4019)
- Backends: SDL2: flipping SDL_MOUSEWHEEL 'wheel.x' value to match other backends and - Backends: SDL2: flipping SDL_MOUSEWHEEL horizontal value to match other backends and
offer consistent horizontal scrolling direction. (#4019) offer consistent horizontal scrolling direction. (#4019)
- Backends: SDL2: Removed SDL_MOUSEWHEEL value clamping. (#4019, #6096, #6081) - Backends: SDL2: Removed SDL_MOUSEWHEEL value clamping. (#4019, #6096, #6081)
- Backends: SDL2: Added support for SDL 2.0.18+ preciseX/preciseY mouse wheel data - Backends: SDL2: Added support for SDL 2.0.18+ preciseX/preciseY mouse wheel data
for smooth scrolling as reported by SDL. (#4019, #6096) for smooth scrolling as reported by SDL. (#4019, #6096)
- Backends: SDL2: Avoid calling SDL_SetCursor() when cursor has not changed, as the function - Backends: SDL2: Avoid calling SDL_SetCursor() when cursor has not changed, as the function
is surprisingly costly on Mac with latest SDL (may be fixed in next SDL version). (#6113) is surprisingly costly on Mac with latest SDL (already fixed in SDL latest trunk). (#6113)
- Backends: SDL2: Implement IME handler to call SDL_SetTextInputRect()/SDL_StartTextInput(). - Backends: SDL2: Implement IME handler to call SDL_SetTextInputRect()/SDL_StartTextInput().
It will only works with SDL 2.0.18+ if your code calls 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1")' It will only works with SDL 2.0.18+ if your code calls 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1")'
prior to calling SDL_CreateWindow(). Updated all examples accordingly. (#6071, #1953) prior to calling SDL_CreateWindow(). Updated all examples accordingly. (#6071, #1953)
@ -180,7 +185,8 @@ All changes:
- Backends: GLFW: Added ImGui_ImplGlfw_SetCallbacksChainForAllWindows() to instruct backend - Backends: GLFW: Added ImGui_ImplGlfw_SetCallbacksChainForAllWindows() to instruct backend
to chain callbacks even for secondary viewports/windows. User callbacks may need to test to chain callbacks even for secondary viewports/windows. User callbacks may need to test
the 'window' parameter. (#6142) the 'window' parameter. (#6142)
- Backends: WebGPU: Fix building for latest WebGPU specs (remove implicit layout generation). - Backends: OpenGL3: Fixed GL loader compatibility with 2.x profiles. (#6154, #4445, #3530) [@grauw]
- Backends: WebGPU: Fixed building for latest WebGPU specs (remove implicit layout generation).
(#6117, #4116, #3632) [@tonygrue, @bfierz] (#6117, #4116, #3632) [@tonygrue, @bfierz]
- Examples: refactored SDL2+GL and GLFW+GL examples to compile with Emscripten. - Examples: refactored SDL2+GL and GLFW+GL examples to compile with Emscripten.
(#2492, #2494, #3699, #3705) [@ocornut, @nicolasnoble] (#2492, #2494, #3699, #3705) [@ocornut, @nicolasnoble]
@ -189,7 +195,7 @@ All changes:
- Examples: Win32: Fixed examples using RegisterClassW() since 1.89 to also call - Examples: Win32: Fixed examples using RegisterClassW() since 1.89 to also call
DefWindowProcW() instead of DefWindowProc() so that title text are correctly converted DefWindowProcW() instead of DefWindowProc() so that title text are correctly converted
when application is compiled without /DUNICODE. (#5725, #5961, #5975) [@markreidvfx] when application is compiled without /DUNICODE. (#5725, #5961, #5975) [@markreidvfx]
- Examples: SDL2+SDL_Renderer: Added call to SDL_RenderSetScale() to display is correct on a - Examples: SDL2+SDL_Renderer: Added call to SDL_RenderSetScale() to fix display on a
Retina display (albeit lower-res as our other unmodified examples). (#6121, #6065, #5931). Retina display (albeit lower-res as our other unmodified examples). (#6121, #6065, #5931).
Docking+Viewports Branch: Docking+Viewports Branch:

View File

@ -1,4 +1,4 @@
// dear imgui, v1.89.3 WIP // dear imgui, v1.89.3
// (main code and documentation) // (main code and documentation)
// Help: // Help:

View File

@ -1,4 +1,4 @@
// dear imgui, v1.89.3 WIP // dear imgui, v1.89.3
// (headers) // (headers)
// Help: // Help:
@ -22,8 +22,8 @@
// Library Version // Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345') // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345')
#define IMGUI_VERSION "1.89.3 WIP" #define IMGUI_VERSION "1.89.3"
#define IMGUI_VERSION_NUM 18928 #define IMGUI_VERSION_NUM 18930
#define IMGUI_HAS_TABLE #define IMGUI_HAS_TABLE
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch #define IMGUI_HAS_VIEWPORT // Viewport WIP branch
#define IMGUI_HAS_DOCK // Docking WIP branch #define IMGUI_HAS_DOCK // Docking WIP branch
@ -2776,7 +2776,7 @@ struct ImFontConfig
bool PixelSnapH; // false // Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font. If enabled, you can set OversampleH/V to 1. bool PixelSnapH; // false // Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font. If enabled, you can set OversampleH/V to 1.
ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs. Only X axis is supported for now. ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs. Only X axis is supported for now.
ImVec2 GlyphOffset; // 0, 0 // Offset all glyphs from this font input. ImVec2 GlyphOffset; // 0, 0 // Offset all glyphs from this font input.
const ImWchar* GlyphRanges; // NULL // Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list). THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE. const ImWchar* GlyphRanges; // NULL // THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE. Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list).
float GlyphMinAdvanceX; // 0 // Minimum AdvanceX for glyphs, set Min to align font icons, set both Min/Max to enforce mono-space font float GlyphMinAdvanceX; // 0 // Minimum AdvanceX for glyphs, set Min to align font icons, set both Min/Max to enforce mono-space font
float GlyphMaxAdvanceX; // FLT_MAX // Maximum AdvanceX for glyphs float GlyphMaxAdvanceX; // FLT_MAX // Maximum AdvanceX for glyphs
bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs). You may want to use GlyphOffset.y when merge font of different heights. bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs). You may want to use GlyphOffset.y when merge font of different heights.

View File

@ -1,4 +1,4 @@
// dear imgui, v1.89.3 WIP // dear imgui, v1.89.3
// (demo code) // (demo code)
// Help: // Help:

View File

@ -1,4 +1,4 @@
// dear imgui, v1.89.3 WIP // dear imgui, v1.89.3
// (drawing and font code) // (drawing and font code)
/* /*
@ -2390,7 +2390,12 @@ static bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
ImFontBuildDstData& dst_tmp = dst_tmp_array[src_tmp.DstIndex]; ImFontBuildDstData& dst_tmp = dst_tmp_array[src_tmp.DstIndex];
src_tmp.SrcRanges = cfg.GlyphRanges ? cfg.GlyphRanges : atlas->GetGlyphRangesDefault(); src_tmp.SrcRanges = cfg.GlyphRanges ? cfg.GlyphRanges : atlas->GetGlyphRangesDefault();
for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2) for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2)
{
// Check for valid range. This may also help detect *some* dangling pointers, because a common
// user error is to setup ImFontConfig::GlyphRanges with a pointer to data that isn't persistent.
IM_ASSERT(src_range[0] <= src_range[1]);
src_tmp.GlyphsHighest = ImMax(src_tmp.GlyphsHighest, (int)src_range[1]); src_tmp.GlyphsHighest = ImMax(src_tmp.GlyphsHighest, (int)src_range[1]);
}
dst_tmp.SrcCount++; dst_tmp.SrcCount++;
dst_tmp.GlyphsHighest = ImMax(dst_tmp.GlyphsHighest, src_tmp.GlyphsHighest); dst_tmp.GlyphsHighest = ImMax(dst_tmp.GlyphsHighest, src_tmp.GlyphsHighest);
} }

View File

@ -1,4 +1,4 @@
// dear imgui, v1.89.3 WIP // dear imgui, v1.89.3
// (internal structures/api) // (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. // You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility.
@ -2134,9 +2134,11 @@ struct ImGuiContext
ImFont InputTextPasswordFont; ImFont InputTextPasswordFont;
ImGuiID TempInputId; // Temporary text input when CTRL+clicking on a slider, etc. ImGuiID TempInputId; // Temporary text input when CTRL+clicking on a slider, etc.
ImGuiColorEditFlags ColorEditOptions; // Store user options for color edit widgets ImGuiColorEditFlags ColorEditOptions; // Store user options for color edit widgets
float ColorEditLastHue; // Backup of last Hue associated to LastColor, so we can restore Hue in lossy RGB<>HSV round trips ImGuiID ColorEditCurrentID; // Set temporarily while inside of the parent-most ColorEdit4/ColorPicker4 (because they call each others).
float ColorEditLastSat; // Backup of last Saturation associated to LastColor, so we can restore Saturation in lossy RGB<>HSV round trips ImGuiID ColorEditSavedID; // ID we are saving/restoring HS for
ImU32 ColorEditLastColor; // RGB value with alpha set to 0. float ColorEditSavedHue; // Backup of last Hue associated to LastColor, so we can restore Hue in lossy RGB<>HSV round trips
float ColorEditSavedSat; // Backup of last Saturation associated to LastColor, so we can restore Saturation in lossy RGB<>HSV round trips
ImU32 ColorEditSavedColor; // RGB value with alpha set to 0.
ImVec4 ColorPickerRef; // Initial/reference color at the time of opening the color picker. ImVec4 ColorPickerRef; // Initial/reference color at the time of opening the color picker.
ImGuiComboPreviewData ComboPreviewData; ImGuiComboPreviewData ComboPreviewData;
float SliderGrabClickOffset; float SliderGrabClickOffset;
@ -2335,8 +2337,9 @@ struct ImGuiContext
TempInputId = 0; TempInputId = 0;
ColorEditOptions = ImGuiColorEditFlags_DefaultOptions_; ColorEditOptions = ImGuiColorEditFlags_DefaultOptions_;
ColorEditLastHue = ColorEditLastSat = 0.0f; ColorEditCurrentID = ColorEditSavedID = 0;
ColorEditLastColor = 0; ColorEditSavedHue = ColorEditSavedSat = 0.0f;
ColorEditSavedColor = 0;
SliderGrabClickOffset = 0.0f; SliderGrabClickOffset = 0.0f;
SliderCurrentAccum = 0.0f; SliderCurrentAccum = 0.0f;
SliderCurrentAccumDirty = false; SliderCurrentAccumDirty = false;

View File

@ -1,4 +1,4 @@
// dear imgui, v1.89.3 WIP // dear imgui, v1.89.3
// (tables and columns code) // (tables and columns code)
/* /*

View File

@ -1,4 +1,4 @@
// dear imgui, v1.89.3 WIP // dear imgui, v1.89.3
// (widgets code) // (widgets code)
/* /*
@ -4985,28 +4985,32 @@ bool ImGui::ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flag
return ColorEdit4(label, col, flags | ImGuiColorEditFlags_NoAlpha); return ColorEdit4(label, col, flags | ImGuiColorEditFlags_NoAlpha);
} }
static void ColorEditRestoreH(const float* col, float* H)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.ColorEditCurrentID != 0);
if (g.ColorEditSavedID != g.ColorEditCurrentID || g.ColorEditSavedColor != ImGui::ColorConvertFloat4ToU32(ImVec4(col[0], col[1], col[2], 0)))
return;
*H = g.ColorEditSavedHue;
}
// ColorEdit supports RGB and HSV inputs. In case of RGB input resulting color may have undefined hue and/or saturation. // ColorEdit supports RGB and HSV inputs. In case of RGB input resulting color may have undefined hue and/or saturation.
// Since widget displays both RGB and HSV values we must preserve hue and saturation to prevent these values resetting. // Since widget displays both RGB and HSV values we must preserve hue and saturation to prevent these values resetting.
static void ColorEditRestoreHS(const float* col, float* H, float* S, float* V) static void ColorEditRestoreHS(const float* col, float* H, float* S, float* V)
{ {
// This check is optional. Suppose we have two color widgets side by side, both widgets display different colors, but both colors have hue and/or saturation undefined.
// With color check: hue/saturation is preserved in one widget. Editing color in one widget would reset hue/saturation in another one.
// Without color check: common hue/saturation would be displayed in all widgets that have hue/saturation undefined.
// g.ColorEditLastColor is stored as ImU32 RGB value: this essentially gives us color equality check with reduced precision.
// Tiny external color changes would not be detected and this check would still pass. This is OK, since we only restore hue/saturation _only_ if they are undefined,
// therefore this change flipping hue/saturation from undefined to a very tiny value would still be represented in color picker.
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
if (g.ColorEditLastColor != ImGui::ColorConvertFloat4ToU32(ImVec4(col[0], col[1], col[2], 0))) IM_ASSERT(g.ColorEditCurrentID != 0);
if (g.ColorEditSavedID != g.ColorEditCurrentID || g.ColorEditSavedColor != ImGui::ColorConvertFloat4ToU32(ImVec4(col[0], col[1], col[2], 0)))
return; return;
// When S == 0, H is undefined. // When S == 0, H is undefined.
// When H == 1 it wraps around to 0. // When H == 1 it wraps around to 0.
if (*S == 0.0f || (*H == 0.0f && g.ColorEditLastHue == 1)) if (*S == 0.0f || (*H == 0.0f && g.ColorEditSavedHue == 1))
*H = g.ColorEditLastHue; *H = g.ColorEditSavedHue;
// When V == 0, S is undefined. // When V == 0, S is undefined.
if (*V == 0.0f) if (*V == 0.0f)
*S = g.ColorEditLastSat; *S = g.ColorEditSavedSat;
} }
// Edit colors components (each component in 0.0f..1.0f range). // Edit colors components (each component in 0.0f..1.0f range).
@ -5029,6 +5033,9 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
BeginGroup(); BeginGroup();
PushID(label); PushID(label);
const bool set_current_color_edit_id = (g.ColorEditCurrentID == 0);
if (set_current_color_edit_id)
g.ColorEditCurrentID = window->IDStack.back();
// If we're not showing any slider there's no point in doing any HSV conversions // If we're not showing any slider there's no point in doing any HSV conversions
const ImGuiColorEditFlags flags_untouched = flags; const ImGuiColorEditFlags flags_untouched = flags;
@ -5062,7 +5069,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
ColorConvertHSVtoRGB(f[0], f[1], f[2], f[0], f[1], f[2]); ColorConvertHSVtoRGB(f[0], f[1], f[2], f[0], f[1], f[2]);
else if ((flags & ImGuiColorEditFlags_InputRGB) && (flags & ImGuiColorEditFlags_DisplayHSV)) else if ((flags & ImGuiColorEditFlags_InputRGB) && (flags & ImGuiColorEditFlags_DisplayHSV))
{ {
// Hue is lost when converting from greyscale rgb (saturation=0). Restore it. // Hue is lost when converting from grayscale rgb (saturation=0). Restore it.
ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]); ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]);
ColorEditRestoreHS(col, &f[0], &f[1], &f[2]); ColorEditRestoreHS(col, &f[0], &f[1], &f[2]);
} }
@ -5201,10 +5208,11 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
f[n] = i[n] / 255.0f; f[n] = i[n] / 255.0f;
if ((flags & ImGuiColorEditFlags_DisplayHSV) && (flags & ImGuiColorEditFlags_InputRGB)) if ((flags & ImGuiColorEditFlags_DisplayHSV) && (flags & ImGuiColorEditFlags_InputRGB))
{ {
g.ColorEditLastHue = f[0]; g.ColorEditSavedHue = f[0];
g.ColorEditLastSat = f[1]; g.ColorEditSavedSat = f[1];
ColorConvertHSVtoRGB(f[0], f[1], f[2], f[0], f[1], f[2]); ColorConvertHSVtoRGB(f[0], f[1], f[2], f[0], f[1], f[2]);
g.ColorEditLastColor = ColorConvertFloat4ToU32(ImVec4(f[0], f[1], f[2], 0)); g.ColorEditSavedID = g.ColorEditCurrentID;
g.ColorEditSavedColor = ColorConvertFloat4ToU32(ImVec4(f[0], f[1], f[2], 0));
} }
if ((flags & ImGuiColorEditFlags_DisplayRGB) && (flags & ImGuiColorEditFlags_InputHSV)) if ((flags & ImGuiColorEditFlags_DisplayRGB) && (flags & ImGuiColorEditFlags_InputHSV))
ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]); ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]);
@ -5216,6 +5224,8 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
col[3] = f[3]; col[3] = f[3];
} }
if (set_current_color_edit_id)
g.ColorEditCurrentID = 0;
PopID(); PopID();
EndGroup(); EndGroup();
@ -5289,6 +5299,9 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
g.NextItemData.ClearFlags(); g.NextItemData.ClearFlags();
PushID(label); PushID(label);
const bool set_current_color_edit_id = (g.ColorEditCurrentID == 0);
if (set_current_color_edit_id)
g.ColorEditCurrentID = window->IDStack.back();
BeginGroup(); BeginGroup();
if (!(flags & ImGuiColorEditFlags_NoSidePreview)) if (!(flags & ImGuiColorEditFlags_NoSidePreview))
@ -5337,7 +5350,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
float R = col[0], G = col[1], B = col[2]; float R = col[0], G = col[1], B = col[2];
if (flags & ImGuiColorEditFlags_InputRGB) if (flags & ImGuiColorEditFlags_InputRGB)
{ {
// Hue is lost when converting from greyscale rgb (saturation=0). Restore it. // Hue is lost when converting from grayscale rgb (saturation=0). Restore it.
ColorConvertRGBtoHSV(R, G, B, H, S, V); ColorConvertRGBtoHSV(R, G, B, H, S, V);
ColorEditRestoreHS(col, &H, &S, &V); ColorEditRestoreHS(col, &H, &S, &V);
} }
@ -5392,10 +5405,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
{ {
S = ImSaturate((io.MousePos.x - picker_pos.x) / (sv_picker_size - 1)); S = ImSaturate((io.MousePos.x - picker_pos.x) / (sv_picker_size - 1));
V = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size - 1)); V = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size - 1));
ColorEditRestoreH(col, &H); // Greatly reduces hue jitter and reset to 0 when hue == 255 and color is rapidly modified using SV square.
// Greatly reduces hue jitter and reset to 0 when hue == 255 and color is rapidly modified using SV square.
if (g.ColorEditLastColor == ColorConvertFloat4ToU32(ImVec4(col[0], col[1], col[2], 0)))
H = g.ColorEditLastHue;
value_changed = value_changed_sv = true; value_changed = value_changed_sv = true;
} }
if (!(flags & ImGuiColorEditFlags_NoOptions)) if (!(flags & ImGuiColorEditFlags_NoOptions))
@ -5470,9 +5480,10 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
if (flags & ImGuiColorEditFlags_InputRGB) if (flags & ImGuiColorEditFlags_InputRGB)
{ {
ColorConvertHSVtoRGB(H, S, V, col[0], col[1], col[2]); ColorConvertHSVtoRGB(H, S, V, col[0], col[1], col[2]);
g.ColorEditLastHue = H; g.ColorEditSavedHue = H;
g.ColorEditLastSat = S; g.ColorEditSavedSat = S;
g.ColorEditLastColor = ColorConvertFloat4ToU32(ImVec4(col[0], col[1], col[2], 0)); g.ColorEditSavedID = g.ColorEditCurrentID;
g.ColorEditSavedColor = ColorConvertFloat4ToU32(ImVec4(col[0], col[1], col[2], 0));
} }
else if (flags & ImGuiColorEditFlags_InputHSV) else if (flags & ImGuiColorEditFlags_InputHSV)
{ {
@ -5636,6 +5647,8 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
if (value_changed && g.LastItemData.ID != 0) // In case of ID collision, the second EndGroup() won't catch g.ActiveId if (value_changed && g.LastItemData.ID != 0) // In case of ID collision, the second EndGroup() won't catch g.ActiveId
MarkItemEdited(g.LastItemData.ID); MarkItemEdited(g.LastItemData.ID);
if (set_current_color_edit_id)
g.ColorEditCurrentID = 0;
PopID(); PopID();
return value_changed; return value_changed;

View File

@ -444,7 +444,12 @@ bool ImFontAtlasBuildWithFreeTypeEx(FT_Library ft_library, ImFontAtlas* atlas, u
ImFontBuildDstDataFT& dst_tmp = dst_tmp_array[src_tmp.DstIndex]; ImFontBuildDstDataFT& dst_tmp = dst_tmp_array[src_tmp.DstIndex];
src_tmp.SrcRanges = cfg.GlyphRanges ? cfg.GlyphRanges : atlas->GetGlyphRangesDefault(); src_tmp.SrcRanges = cfg.GlyphRanges ? cfg.GlyphRanges : atlas->GetGlyphRangesDefault();
for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2) for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2)
{
// Check for valid range. This may also help detect *some* dangling pointers, because a common
// user error is to setup ImFontConfig::GlyphRanges with a pointer to data that isn't persistent.
IM_ASSERT(src_range[0] <= src_range[1]);
src_tmp.GlyphsHighest = ImMax(src_tmp.GlyphsHighest, (int)src_range[1]); src_tmp.GlyphsHighest = ImMax(src_tmp.GlyphsHighest, (int)src_range[1]);
}
dst_tmp.SrcCount++; dst_tmp.SrcCount++;
dst_tmp.GlyphsHighest = ImMax(dst_tmp.GlyphsHighest, src_tmp.GlyphsHighest); dst_tmp.GlyphsHighest = ImMax(dst_tmp.GlyphsHighest, src_tmp.GlyphsHighest);
} }