Merge branch 'master' into docking

This commit is contained in:
omar 2019-09-22 22:16:11 +02:00
commit 3233d85d2f
8 changed files with 58 additions and 38 deletions

View File

@ -104,15 +104,17 @@ Other changes:
Other Changes: Other Changes:
- Nav, Scrolling: Added support for Home/End key. (#787) - Nav, Scrolling: Added support for Home/End key. (#787)
- ColorEdit: Disable Hue edit when Saturation==0 instead of letting Hue values jump around.
- ColorEdit, ColorPicker: In HSV display of a RGB stored value, attempt to locally preserve Hue
when Saturation==0, which reduces accidentally lossy interactions. (#2722, 2770) [@rokups]
- ColorPicker: Made rendering aware of global style alpha of the picker can be faded out. (#2711) - ColorPicker: Made rendering aware of global style alpha of the picker can be faded out. (#2711)
Note that some elements won't accurately fade down with the same intensity, and the color wheel Note that some elements won't accurately fade down with the same intensity, and the color wheel
when enabled will have small overlap glitches with (style.Alpha < 1.0). when enabled will have small overlap glitches with (style.Alpha < 1.0).
- ColorEdit: Disable Hue edit when Saturation==0 instead of letting Hue values jump around. - TabBar: Fixed ScrollToBar request creating bouncing loop when tab is larger than available space.
- TabBar: fixed ScrollToBar request creating bouncing loop when tab is larger than available space. - TabBar: Fixed single-tab not shrinking their width down.
- TabBar: fixed single-tab not shrinking their width down. - TabBar: Feed desired width (sum of unclipped tabs width) into layout system to allow for auto-resize. (#2768)
- TabBar: feed desired width (sum of unclipped tabs width) into layout system to allow for auto-resize. (#2768)
(before 1.71 tab bars fed the sum of current width which created feedback loops in certain situations). (before 1.71 tab bars fed the sum of current width which created feedback loops in certain situations).
- TabBar: improved shrinking for large number of tabs to avoid leaving extraneous space on the right side. - TabBar: Improved shrinking for large number of tabs to avoid leaving extraneous space on the right side.
Individuals tabs are given integer-rounded width and remainder is spread between tabs left-to-right. Individuals tabs are given integer-rounded width and remainder is spread between tabs left-to-right.
- Columns, Separator: Fixed a bug where non-visible separators within columns would alter the next row position - Columns, Separator: Fixed a bug where non-visible separators within columns would alter the next row position
differently than visible ones. differently than visible ones.
@ -126,14 +128,16 @@ Other Changes:
and then we will be able to make this the default.) and then we will be able to make this the default.)
- TreeNode: Added ImGuiTreeNodeFlags_SpanFullWidth flag. This extends the hit-box to both the left-most and - TreeNode: Added ImGuiTreeNodeFlags_SpanFullWidth flag. This extends the hit-box to both the left-most and
right-most edge of the working area, bypassing indentation. right-most edge of the working area, bypassing indentation.
- Selectable: Added ImGuiSelectableFlags_AllowItemOverlap flag in public api (was previously internal only).
- Style: Allow style.WindowMenuButtonPosition to be set to ImGuiDir_None to hide the collapse button. (#2634, #2639) - Style: Allow style.WindowMenuButtonPosition to be set to ImGuiDir_None to hide the collapse button. (#2634, #2639)
- Font: Better ellipsis drawing implementation. Instead of drawing three pixel-ey dots (which was glaringly - Font: Better ellipsis drawing implementation. Instead of drawing three pixel-ey dots (which was glaringly
unfitting with many types of fonts) we first attempt to find a standard ellipsis glyphs within the loaded set. unfitting with many types of fonts) we first attempt to find a standard ellipsis glyphs within the loaded set.
Otherwise we render ellipsis using '.' from the font from where we trim excessive spacing to make it as narrow Otherwise we render ellipsis using '.' from the font from where we trim excessive spacing to make it as narrow
as possible. (#2775) [@rokups] as possible. (#2775) [@rokups]
- ImDrawList: clarified the name of many parameters so reading the code is a little easier. (#2740) - ImDrawList: Clarified the name of many parameters so reading the code is a little easier. (#2740)
- ImDrawListSplitter: fixed an issue merging channels if the last submitted draw command used a different texture. (#2506) - ImDrawListSplitter: fixed an issue merging channels if the last submitted draw command used a different texture. (#2506)
- Using offsetof() when available in C++11. Avoids Clang sanitizer complaining about old-style macros. (#94) - Using offsetof() when available in C++11. Avoids Clang sanitizer complaining about old-style macros. (#94)
- ImVector: Added find(), find_erase(), find_erase_unsorted() helpers.
- Added a mechanism to compact/free the larger allocations of unused windows (buffers are compacted when - Added a mechanism to compact/free the larger allocations of unused windows (buffers are compacted when
a window is unused for 60 seconds, as per io.ConfigWindowsMemoryCompactTimer = 60.0f). Note that memory a window is unused for 60 seconds, as per io.ConfigWindowsMemoryCompactTimer = 60.0f). Note that memory
usage has never been reported as a problem, so this is merely a touch of overzealous luxury. (#2636) usage has never been reported as a problem, so this is merely a touch of overzealous luxury. (#2636)
@ -144,6 +148,8 @@ Other Changes:
- Backends: Vulkan: Added support for specifying multisample count. - Backends: Vulkan: Added support for specifying multisample count.
Set ImGui_ImplVulkan_InitInfo::MSAASamples to one of the VkSampleCountFlagBits values Set ImGui_ImplVulkan_InitInfo::MSAASamples to one of the VkSampleCountFlagBits values
to use, default is non-multisampled as before. (#2705, #2706) [@vilya] to use, default is non-multisampled as before. (#2705, #2706) [@vilya]
- Examples: OSX: Fix example_apple_opengl2/main.mm not forwarding mouse clicks and drags correctly. (#1961, #2710)
[@intonarumori, @ElectricMagic]
- Misc: Updated stb_rect_pack from 0.99 to 1.00 (fixes by @rygorous: off-by-1 bug in best-fit heuristic, - Misc: Updated stb_rect_pack from 0.99 to 1.00 (fixes by @rygorous: off-by-1 bug in best-fit heuristic,
fix handling of rectangles too large to fit inside texture). (#2762) [@tido64] fix handling of rectangles too large to fit inside texture). (#2762) [@tido64]

View File

@ -244,13 +244,13 @@ See the [Quotes](https://github.com/ocornut/imgui/wiki/Quotes) and [Software usi
The library started its life as "ImGui" due to the fact that I didn't give it a proper name when I released 1.0 and had no particular expectation that it would take off. However, the term IMGUI (immediate-mode graphical user interface) was coined before and is being used in variety of other situations (e.g. Unity uses it own implementation of the IMGUI paradigm). To reduce this ambiguity without affecting existing codebases, I have decided on an alternate, longer name "Dear ImGui" that people can use to refer to this specific library. Please try to refer to this library as "Dear ImGui". The library started its life as "ImGui" due to the fact that I didn't give it a proper name when I released 1.0 and had no particular expectation that it would take off. However, the term IMGUI (immediate-mode graphical user interface) was coined before and is being used in variety of other situations (e.g. Unity uses it own implementation of the IMGUI paradigm). To reduce this ambiguity without affecting existing codebases, I have decided on an alternate, longer name "Dear ImGui" that people can use to refer to this specific library. Please try to refer to this library as "Dear ImGui".
**How can I tell whether to dispatch mouse/keyboard to Dear ImGui or to my application?** **How can I tell whether to dispatch mouse/keyboard to Dear ImGui or to my application?**
<br>**How can I display an image? What is ImTextureID, how does it works?** <br>**How can I display an image? What is ImTextureID, how does it works?** ([examples](https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples))
<br>**Why are multiple widgets reacting when I interact with a single one? How can I have multiple widgets with the same label or with an empty label? A primer on labels and the ID Stack...** <br>**Why are multiple widgets reacting when I interact with a single one? How can I have multiple widgets with the same label or with an empty label? A primer on labels and the ID Stack...**
<br>**How can I use my own math types instead of ImVec2/ImVec4?** <br>**How can I use my own math types instead of ImVec2/ImVec4?**
<br>**How can I load a different font than the default?** <br>**How can I load a different font than the default?**
<br>**How can I easily use icons in my application?** <br>**How can I easily use icons in my application?**
<br>**How can I load multiple fonts?** <br>**How can I load multiple fonts?**
<br>**How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?** ([example](https://github.com/ocornut/imgui/wiki/Loading-Font-Example)) <br>**How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?** ([examples](https://github.com/ocornut/imgui/wiki/Loading-Font-Example))
<br>**How can I interact with standard C++ types (such as std::string and std::vector)?** <br>**How can I interact with standard C++ types (such as std::string and std::vector)?**
<br>**How can I use the drawing facilities without a Dear ImGui window? (using ImDrawList API)** <br>**How can I use the drawing facilities without a Dear ImGui window? (using ImDrawList API)**
<br>**How can I use this without a mouse, without a keyboard or without a screen? (gamepad, input share, remote display)** <br>**How can I use this without a mouse, without a keyboard or without a screen? (gamepad, input share, remote display)**

View File

@ -93,6 +93,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
- input text: a side bar that could e.g. preview where errors are. probably left to the user to draw but we'd need to give them the info there. - input text: a side bar that could e.g. preview where errors are. probably left to the user to draw but we'd need to give them the info there.
- input text: a way for the user to provide syntax coloring. - input text: a way for the user to provide syntax coloring.
- input text: Shift+TAB with ImGuiInputTextFlags_AllowTabInput could eat preceding blanks, up to tab_count. - input text: Shift+TAB with ImGuiInputTextFlags_AllowTabInput could eat preceding blanks, up to tab_count.
- input text: facilitate patterns like if (InputText(..., obj.get_string_ref()) { obj.set_string(...); } relying on internally held buffer.
- input text multi-line: don't directly call AddText() which does an unnecessary vertex reserve for character count prior to clipping. and/or more line-based clipping to AddText(). and/or reorganize TextUnformatted/RenderText for more efficiency for large text (e.g TextUnformatted could clip and log separately, etc). - input text multi-line: don't directly call AddText() which does an unnecessary vertex reserve for character count prior to clipping. and/or more line-based clipping to AddText(). and/or reorganize TextUnformatted/RenderText for more efficiency for large text (e.g TextUnformatted could clip and log separately, etc).
- input text multi-line: support for cut/paste without selection (cut/paste the current line) - input text multi-line: support for cut/paste without selection (cut/paste the current line)
- input text multi-line: line numbers? status bar? (follow up on #200) - input text multi-line: line numbers? status bar? (follow up on #200)
@ -111,6 +112,9 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
- layout: more generic alignment state (left/right/centered) for single items? - layout: more generic alignment state (left/right/centered) for single items?
- layout: clean up the InputFloatN/SliderFloatN/ColorEdit4 layout code. item width should include frame padding. - layout: clean up the InputFloatN/SliderFloatN/ColorEdit4 layout code. item width should include frame padding.
- layout: vertical alignment of mixed height items (e.g. buttons) within a same line (#1284) - layout: vertical alignment of mixed height items (e.g. buttons) within a same line (#1284)
- layout: null layout mode were items are not rendered but user can query GetItemRectMin()/Max/Size.
- layout: (R&D) local multi-pass layout mode.
- layout: (R&D) bind authored layout data (created by an off-line tool), items fetch their pos/size at submission, self-optimize data structures to stable linear access.
- group: BeginGroup() needs a border option. (~#1496) - group: BeginGroup() needs a border option. (~#1496)
- group: IsHovered() after EndGroup() covers whole aabb rather than the intersection of individual items. Is that desirable? - group: IsHovered() after EndGroup() covers whole aabb rather than the intersection of individual items. Is that desirable?

View File

@ -133,12 +133,6 @@
return (YES); return (YES);
} }
// Flip coordinate system upside down on Y
-(BOOL)isFlipped
{
return (YES);
}
-(void)dealloc -(void)dealloc
{ {
animationTimer = nil; animationTimer = nil;
@ -150,6 +144,8 @@
-(void)flagsChanged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } -(void)flagsChanged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
-(void)mouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } -(void)mouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
-(void)mouseUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } -(void)mouseUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
-(void)mouseMoved:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
-(void)mouseDragged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
-(void)scrollWheel:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } -(void)scrollWheel:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
@end @end
@ -179,6 +175,7 @@
_window = [[NSWindow alloc] initWithContentRect:viewRect styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskResizable|NSWindowStyleMaskClosable backing:NSBackingStoreBuffered defer:YES]; _window = [[NSWindow alloc] initWithContentRect:viewRect styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskResizable|NSWindowStyleMaskClosable backing:NSBackingStoreBuffered defer:YES];
[_window setTitle:@"Dear ImGui OSX+OpenGL2 Example"]; [_window setTitle:@"Dear ImGui OSX+OpenGL2 Example"];
[_window setAcceptsMouseMovedEvents:YES];
[_window setOpaque:YES]; [_window setOpaque:YES];
[_window makeKeyAndOrderFront:NSApp]; [_window makeKeyAndOrderFront:NSApp];

View File

@ -633,6 +633,7 @@ CODE
Q: How can I display an image? What is ImTextureID, how does it works? Q: How can I display an image? What is ImTextureID, how does it works?
A: Short explanation: A: Short explanation:
- Please read Wiki entry for examples: https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples
- You may use functions such as ImGui::Image(), ImGui::ImageButton() or lower-level ImDrawList::AddImage() to emit draw calls that will use your own textures. - You may use functions such as ImGui::Image(), ImGui::ImageButton() or lower-level ImDrawList::AddImage() to emit draw calls that will use your own textures.
- Actual textures are identified in a way that is up to the user/engine. Those identifiers are stored and passed as ImTextureID (void*) value. - Actual textures are identified in a way that is up to the user/engine. Those identifiers are stored and passed as ImTextureID (void*) value.
- Loading image files from the disk and turning them into a texture is not within the scope of Dear ImGui (for a good reason). - Loading image files from the disk and turning them into a texture is not within the scope of Dear ImGui (for a good reason).
@ -680,26 +681,9 @@ CODE
This is by design and is actually a good thing, because it means your code has full control over your data types and how you display them. This is by design and is actually a good thing, because it means your code has full control over your data types and how you display them.
If you want to display an image file (e.g. PNG file) into the screen, please refer to documentation and tutorials for the graphics API you are using. If you want to display an image file (e.g. PNG file) into the screen, please refer to documentation and tutorials for the graphics API you are using.
Here's a simplified OpenGL example using stb_image.h: Refer to the Wiki to find simplified examples for loading textures with OpenGL, DirectX9 and DirectX11:
// Use stb_image.h to load a PNG from disk and turn it into raw RGBA pixel data: https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
[...]
int my_image_width, my_image_height;
unsigned char* my_image_data = stbi_load("my_image.png", &my_image_width, &my_image_height, NULL, 4);
// Turn the RGBA pixel data into an OpenGL texture:
GLuint my_opengl_texture;
glGenTextures(1, &my_opengl_texture);
glBindTexture(GL_TEXTURE_2D, my_opengl_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image_width, image_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data);
// Now that we have an OpenGL texture, assuming our imgui rendering function (imgui_impl_xxx.cpp file) takes GLuint as ImTextureID, we can display it:
ImGui::Image((void*)(intptr_t)my_opengl_texture, ImVec2(my_image_width, my_image_height));
C/C++ tip: a void* is pointer-sized storage. You may safely store any pointer or integer into it by casting your value to ImTextureID / void*, and vice-versa. C/C++ tip: a void* is pointer-sized storage. You may safely store any pointer or integer into it by casting your value to ImTextureID / void*, and vice-versa.
Because both end-points (user code and rendering function) are under your control, you know exactly what is stored inside the ImTextureID / void*. Because both end-points (user code and rendering function) are under your control, you know exactly what is stored inside the ImTextureID / void*.

View File

@ -851,7 +851,8 @@ enum ImGuiSelectableFlags_
ImGuiSelectableFlags_DontClosePopups = 1 << 0, // Clicking this don't close parent popup window ImGuiSelectableFlags_DontClosePopups = 1 << 0, // Clicking this don't close parent popup window
ImGuiSelectableFlags_SpanAllColumns = 1 << 1, // Selectable frame can span all columns (text will still fit in current column) ImGuiSelectableFlags_SpanAllColumns = 1 << 1, // Selectable frame can span all columns (text will still fit in current column)
ImGuiSelectableFlags_AllowDoubleClick = 1 << 2, // Generate press events on double clicks too ImGuiSelectableFlags_AllowDoubleClick = 1 << 2, // Generate press events on double clicks too
ImGuiSelectableFlags_Disabled = 1 << 3 // Cannot be selected, display grayed out text ImGuiSelectableFlags_Disabled = 1 << 3, // Cannot be selected, display grayed out text
ImGuiSelectableFlags_AllowItemOverlap = 1 << 4 // (WIP) Hit testing to allow subsequent widgets to overlap this one
}; };
// Flags for ImGui::BeginCombo() // Flags for ImGui::BeginCombo()
@ -1344,6 +1345,10 @@ struct ImVector
inline T* erase_unsorted(const T* it) { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; if (it < Data+Size-1) memcpy(Data + off, Data + Size - 1, sizeof(T)); Size--; return Data + off; } inline T* erase_unsorted(const T* it) { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; if (it < Data+Size-1) memcpy(Data + off, Data + Size - 1, sizeof(T)); Size--; return Data + off; }
inline T* insert(const T* it, const T& v) { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(_grow_capacity(Size + 1)); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(T)); memcpy(&Data[off], &v, sizeof(v)); Size++; return Data + off; } inline T* insert(const T* it, const T& v) { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(_grow_capacity(Size + 1)); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(T)); memcpy(&Data[off], &v, sizeof(v)); Size++; return Data + off; }
inline bool contains(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data++ == v) return true; return false; } inline bool contains(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data++ == v) return true; return false; }
inline T* find(const T& v) { T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; }
inline const T* find(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; }
inline bool find_erase(const T& v) { const T* it = find(v); if (it < Data + Size) { erase(it); return true; } return false; }
inline bool find_erase_unsorted(const T& v) { const T* it = find(v); if (it < Data + Size) { erase_unsorted(it); return true; } return false; }
inline int index_from_ptr(const T* it) const { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; return (int)off; } inline int index_from_ptr(const T* it) const { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; return (int)off; }
}; };

View File

@ -373,9 +373,8 @@ enum ImGuiSelectableFlagsPrivate_
ImGuiSelectableFlags_PressedOnClick = 1 << 21, ImGuiSelectableFlags_PressedOnClick = 1 << 21,
ImGuiSelectableFlags_PressedOnRelease = 1 << 22, ImGuiSelectableFlags_PressedOnRelease = 1 << 22,
ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 23, // FIXME: We may be able to remove this (added in 6251d379 for menus) ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 23, // FIXME: We may be able to remove this (added in 6251d379 for menus)
ImGuiSelectableFlags_AllowItemOverlap = 1 << 24, ImGuiSelectableFlags_DrawHoveredWhenHeld= 1 << 24, // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow.
ImGuiSelectableFlags_DrawHoveredWhenHeld= 1 << 25, // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow. ImGuiSelectableFlags_SetNavIdOnHover = 1 << 25
ImGuiSelectableFlags_SetNavIdOnHover = 1 << 26
}; };
// Extend ImGuiTreeNodeFlags_ // Extend ImGuiTreeNodeFlags_
@ -1166,6 +1165,8 @@ struct ImGuiContext
ImFont InputTextPasswordFont; ImFont InputTextPasswordFont;
ImGuiID TempInputTextId; // Temporary text input when CTRL+clicking on a slider, etc. ImGuiID TempInputTextId; // 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;
float ColorEditLastColor[3];
ImVec4 ColorPickerRef; ImVec4 ColorPickerRef;
bool DragCurrentAccumDirty; bool DragCurrentAccumDirty;
float DragCurrentAccum; // Accumulator for dragging modification. Always high-precision, not rounded by end-user precision settings float DragCurrentAccum; // Accumulator for dragging modification. Always high-precision, not rounded by end-user precision settings
@ -1320,6 +1321,8 @@ struct ImGuiContext
LastValidMousePos = ImVec2(0.0f, 0.0f); LastValidMousePos = ImVec2(0.0f, 0.0f);
TempInputTextId = 0; TempInputTextId = 0;
ColorEditOptions = ImGuiColorEditFlags__OptionsDefault; ColorEditOptions = ImGuiColorEditFlags__OptionsDefault;
ColorEditLastHue = 0.0f;
ColorEditLastColor[0] = ColorEditLastColor[1] = ColorEditLastColor[2] = FLT_MAX;
DragCurrentAccumDirty = false; DragCurrentAccumDirty = false;
DragCurrentAccum = 0.0f; DragCurrentAccum = 0.0f;
DragSpeedDefaultRatio = 1.0f / 100.0f; DragSpeedDefaultRatio = 1.0f / 100.0f;

View File

@ -1373,7 +1373,7 @@ void ImGui::ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_exc
{ {
if (count == 1) if (count == 1)
{ {
items[0].Width -= width_excess; items[0].Width = ImMax(items[0].Width - width_excess, 1.0f);
return; return;
} }
ImQsort(items, (size_t)count, sizeof(ImGuiShrinkWidthItem), ShrinkWidthItemComparer); ImQsort(items, (size_t)count, sizeof(ImGuiShrinkWidthItem), ShrinkWidthItemComparer);
@ -4210,7 +4210,12 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
if ((flags & ImGuiColorEditFlags_InputHSV) && (flags & ImGuiColorEditFlags_DisplayRGB)) if ((flags & ImGuiColorEditFlags_InputHSV) && (flags & ImGuiColorEditFlags_DisplayRGB))
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.
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]);
if (f[1] == 0 && memcmp(g.ColorEditLastColor, col, sizeof(float) * 3) == 0)
f[0] = g.ColorEditLastHue;
}
int i[4] = { IM_F32_TO_INT8_UNBOUND(f[0]), IM_F32_TO_INT8_UNBOUND(f[1]), IM_F32_TO_INT8_UNBOUND(f[2]), IM_F32_TO_INT8_UNBOUND(f[3]) }; int i[4] = { IM_F32_TO_INT8_UNBOUND(f[0]), IM_F32_TO_INT8_UNBOUND(f[1]), IM_F32_TO_INT8_UNBOUND(f[2]), IM_F32_TO_INT8_UNBOUND(f[3]) };
bool value_changed = false; bool value_changed = false;
@ -4337,7 +4342,11 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
for (int n = 0; n < 4; n++) for (int n = 0; n < 4; n++)
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];
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]);
memcpy(g.ColorEditLastColor, f, sizeof(float) * 3);
}
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]);
@ -4514,9 +4523,16 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
float H = col[0], S = col[1], V = col[2]; float H = col[0], S = col[1], V = col[2];
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.
ColorConvertRGBtoHSV(R, G, B, H, S, V); ColorConvertRGBtoHSV(R, G, B, H, S, V);
if (S == 0 && memcmp(g.ColorEditLastColor, col, sizeof(float) * 3) == 0)
H = g.ColorEditLastHue;
}
else if (flags & ImGuiColorEditFlags_InputHSV) else if (flags & ImGuiColorEditFlags_InputHSV)
{
ColorConvertHSVtoRGB(H, S, V, R, G, B); ColorConvertHSVtoRGB(H, S, V, R, G, B);
}
bool value_changed = false, value_changed_h = false, value_changed_sv = false; bool value_changed = false, value_changed_h = false, value_changed_sv = false;
@ -4638,6 +4654,8 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
if (flags & ImGuiColorEditFlags_InputRGB) if (flags & ImGuiColorEditFlags_InputRGB)
{ {
ColorConvertHSVtoRGB(H >= 1.0f ? H - 10 * 1e-6f : H, S > 0.0f ? S : 10*1e-6f, V > 0.0f ? V : 1e-6f, col[0], col[1], col[2]); ColorConvertHSVtoRGB(H >= 1.0f ? H - 10 * 1e-6f : H, S > 0.0f ? S : 10*1e-6f, V > 0.0f ? V : 1e-6f, col[0], col[1], col[2]);
g.ColorEditLastHue = H;
memcpy(g.ColorEditLastColor, col, sizeof(float) * 3);
} }
else if (flags & ImGuiColorEditFlags_InputHSV) else if (flags & ImGuiColorEditFlags_InputHSV)
{ {
@ -4691,6 +4709,8 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
G = col[1]; G = col[1];
B = col[2]; B = col[2];
ColorConvertRGBtoHSV(R, G, B, H, S, V); ColorConvertRGBtoHSV(R, G, B, H, S, V);
if (S == 0 && memcmp(g.ColorEditLastColor, col, sizeof(float) * 3) == 0) // Fix local Hue as display below will use it immediately.
H = g.ColorEditLastHue;
} }
else if (flags & ImGuiColorEditFlags_InputHSV) else if (flags & ImGuiColorEditFlags_InputHSV)
{ {
@ -6561,6 +6581,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
{ {
ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
tab->Width = ImMin(tab->WidthContents, tab_max_width); tab->Width = ImMin(tab->WidthContents, tab_max_width);
IM_ASSERT(tab->Width > 0.0f);
} }
} }