From 7b1ab5b27586a3b297aac336d6a97873b11d4078 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 1 Oct 2020 14:07:20 +0200 Subject: [PATCH 01/10] ImVector: Stricter bound-checking asserts. Fix warnings: trailing comma (old compilers), zealous preprocessor warnings. --- examples/example_glfw_opengl3/main.cpp | 2 +- examples/example_sdl_opengl3/main.cpp | 2 +- imgui.h | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/example_glfw_opengl3/main.cpp b/examples/example_glfw_opengl3/main.cpp index 30943301..aa43471a 100644 --- a/examples/example_glfw_opengl3/main.cpp +++ b/examples/example_glfw_opengl3/main.cpp @@ -56,7 +56,7 @@ int main(int, char**) return 1; // Decide GL+GLSL versions -#if __APPLE__ +#ifdef __APPLE__ // GL 3.2 + GLSL 150 const char* glsl_version = "#version 150"; glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); diff --git a/examples/example_sdl_opengl3/main.cpp b/examples/example_sdl_opengl3/main.cpp index 92d03138..c61bc544 100644 --- a/examples/example_sdl_opengl3/main.cpp +++ b/examples/example_sdl_opengl3/main.cpp @@ -48,7 +48,7 @@ int main(int, char**) } // Decide GL+GLSL versions -#if __APPLE__ +#ifdef __APPLE__ // GL 3.2 Core + GLSL 150 const char* glsl_version = "#version 150"; SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG); // Always required on Mac diff --git a/imgui.h b/imgui.h index 67516adc..9bf7ff35 100644 --- a/imgui.h +++ b/imgui.h @@ -1310,7 +1310,7 @@ enum ImGuiSliderFlags_ // Obsolete names (will be removed) #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - , ImGuiSliderFlags_ClampOnInput = ImGuiSliderFlags_AlwaysClamp, // [renamed in 1.79] + , ImGuiSliderFlags_ClampOnInput = ImGuiSliderFlags_AlwaysClamp // [renamed in 1.79] #endif }; @@ -1408,8 +1408,8 @@ struct ImVector inline int size_in_bytes() const { return Size * (int)sizeof(T); } inline int max_size() const { return 0x7FFFFFFF / (int)sizeof(T); } inline int capacity() const { return Capacity; } - inline T& operator[](int i) { IM_ASSERT(i < Size); return Data[i]; } - inline const T& operator[](int i) const { IM_ASSERT(i < Size); return Data[i]; } + inline T& operator[](int i) { IM_ASSERT(i >= 0 && i < Size); return Data[i]; } + inline const T& operator[](int i) const { IM_ASSERT(i >= 0 && i < Size); return Data[i]; } inline void clear() { if (Data) { Size = Capacity = 0; IM_FREE(Data); Data = NULL; } } inline T* begin() { return Data; } From 6469b94304e5c6e521054a654d3172f47b2d0019 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 2 Oct 2020 19:12:53 +0200 Subject: [PATCH 02/10] Silence memset warning. (#3505) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compiling the code as-is results in the following warning: -->8-- imgui_freetype.cpp:341:72: warning: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct ImFontBuildSrcDataFT’ with no trivial copy-assignment; use assignment or value-initialization instead [-Wclass-memaccess] 341 | memset(src_tmp_array.Data, 0, (size_t)src_tmp_array.size_in_bytes()); | ^ imgui_freetype.cpp:302:8: note: ‘struct ImFontBuildSrcDataFT’ declared here 302 | struct ImFontBuildSrcDataFT | ^~~~~~~~~~~~~~~~~~~~ --8<-- This is caused by presence of ImVector<> directly in ImFontBuildSrcDataFT data structure, as well as in the child ImBitVector. Since ImVector<> has a constructor, the compiler infers that initialization by memset is not valid. Such initialization is not a bug, however, as the default ImVector<> ctor just sets the structure data members to 0, which is exactly what the memset does. Casting the data structure address to void* pointer silences this warning. --- misc/freetype/imgui_freetype.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/freetype/imgui_freetype.cpp b/misc/freetype/imgui_freetype.cpp index 3d62dc4b..412411a9 100644 --- a/misc/freetype/imgui_freetype.cpp +++ b/misc/freetype/imgui_freetype.cpp @@ -338,8 +338,8 @@ bool ImFontAtlasBuildWithFreeType(FT_Library ft_library, ImFontAtlas* atlas, uns ImVector dst_tmp_array; src_tmp_array.resize(atlas->ConfigData.Size); dst_tmp_array.resize(atlas->Fonts.Size); - memset(src_tmp_array.Data, 0, (size_t)src_tmp_array.size_in_bytes()); - memset(dst_tmp_array.Data, 0, (size_t)dst_tmp_array.size_in_bytes()); + memset((void*)src_tmp_array.Data, 0, (size_t)src_tmp_array.size_in_bytes()); + memset((void*)dst_tmp_array.Data, 0, (size_t)dst_tmp_array.size_in_bytes()); // 1. Initialize font loading structure, check font data validity for (int src_i = 0; src_i < atlas->ConfigData.Size; src_i++) From 01cc6660395032714e7a991eba679a9c69b00c5b Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 5 Oct 2020 12:28:28 +0200 Subject: [PATCH 03/10] ImGuiListClipper: Renamed constructor parameters which created an ambiguous alternative to using the ImGuiListClipper::Begin() function, with misleading edge cases. --- docs/CHANGELOG.txt | 6 +++++- imgui.cpp | 8 +++----- imgui.h | 39 +++++++++++++++++++++++---------------- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index d3dad8a0..633293f7 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -42,10 +42,14 @@ Breaking Changes: It was also getting in the way of better font scaling, so let's get rid of it now! If you used DisplayOffset it was probably in association to rasterizing a font at a specific size, in which case the corresponding offset may be reported into GlyphOffset. (#1619) +- ImGuiListClipper: Renamed constructor parameters which created an ambiguous alternative to using + the ImGuiListClipper::Begin() function, with misleading edge cases. Always use ImGuiListClipper::Begin()! + Kept inline redirection function (will obsolete). + (note: imgui_memory_editor <0.40 from imgui_club/ used this old clipper API. Update your copy if needed). - Style: Renamed style.TabMinWidthForUnselectedCloseButton to style.TabMinWidthForCloseButton. - Renamed ImGuiSliderFlags_ClampOnInput to ImGuiSliderFlags_AlwaysClamp. Kept redirection enum (will obsolete). - Renamed OpenPopupContextItem() back to OpenPopupOnItemClick(), REVERTED CHANGE FROM 1.77. - For variety of reason this is more self-explanatory. + For variety of reason this is more self-explanatory. Kept inline redirection function. - Removed return value from OpenPopupOnItemClick() - returned true on mouse release on item - because it is inconsistent with other popups API and makes others misleading. It's also and unnecessary: you can use IsWindowAppearing() after BeginPopup() for a similar result. diff --git a/imgui.cpp b/imgui.cpp index dac97c99..429dbb1a 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -372,6 +372,7 @@ CODE When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files. You can read releases logs https://github.com/ocornut/imgui/releases for more details. + - 2020/10/05 (1.79) - removed ImGuiListClipper: Renamed constructor parameters which created an ambiguous alternative to using the ImGuiListClipper::Begin() function, with misleading edge cases (note: imgui_memory_editor <0.40 from imgui_club/ used this old clipper API. Update your copy if needed). - 2020/09/25 (1.79) - renamed ImGuiSliderFlags_ClampOnInput to ImGuiSliderFlags_AlwaysClamp. Kept redirection enum (will obsolete sooner because previous name was added recently). - 2020/09/25 (1.79) - renamed style.TabMinWidthForUnselectedCloseButton to style.TabMinWidthForCloseButton. - 2020/09/21 (1.79) - renamed OpenPopupContextItem() back to OpenPopupOnItemClick(), reverting the change from 1.77. For varieties of reason this is more self-explanatory. @@ -2192,13 +2193,10 @@ static void SetCursorPosYAndSetupForPrevLine(float pos_y, float line_height) columns->LineMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly } -ImGuiListClipper::ImGuiListClipper(int items_count, float items_height) +ImGuiListClipper::ImGuiListClipper() { - DisplayStart = DisplayEnd = 0; + memset(this, 0, sizeof(*this)); ItemsCount = -1; - StepNo = 0; - ItemsHeight = StartPosY = 0.0f; - Begin(items_count, items_height); } ImGuiListClipper::~ImGuiListClipper() diff --git a/imgui.h b/imgui.h index 9bf7ff35..d72243e4 100644 --- a/imgui.h +++ b/imgui.h @@ -1886,38 +1886,45 @@ struct ImGuiStorage }; // Helper: Manually clip large list of items. -// If you are submitting lots of evenly spaced items and you have a random access to the list, you can perform coarse clipping based on visibility to save yourself from processing those items at all. +// If you are submitting lots of evenly spaced items and you have a random access to the list, you can perform coarse +// clipping based on visibility to save yourself from processing those items at all. // The clipper calculates the range of visible items and advance the cursor to compensate for the non-visible items we have skipped. -// ImGui already clip items based on their bounds but it needs to measure text size to do so. Coarse clipping before submission makes this cost and your own data fetching/submission cost null. +// (Dear ImGui already clip items based on their bounds but it needs to measure text size to do so, whereas manual coarse clipping before submission makes this cost and your own data fetching/submission cost almost null) // Usage: -// ImGuiListClipper clipper(1000); // we have 1000 elements, evenly spaced. -// while (clipper.Step()) -// for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) -// ImGui::Text("line number %d", i); -// - Step 0: the clipper let you process the first element, regardless of it being visible or not, so we can measure the element height (step skipped if we passed a known height as second arg to constructor). -// - Step 1: the clipper infer height from first element, calculate the actual range of elements to display, and position the cursor before the first element. -// - (Step 2: empty step only required if an explicit items_height was passed to constructor or Begin() and user call Step(). Does nothing and switch to Step 3.) -// - Step 3: the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd), advance the cursor to the end of the list and then returns 'false' to end the loop. +// ImGuiListClipper clipper; +// clipper.Begin(1000); // We have 1000 elements, evenly spaced. +// while (clipper.Step()) +// for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) +// ImGui::Text("line number %d", i); +// Generally what happens is: +// - Clipper lets you process the first element (DisplayStart = 0, DisplayEnd = 1) regardless of it being visible or not. +// - User code submit one element. +// - Clipper can measure the height of the first element +// - Clipper calculate the actual range of elements to display based on the current clipping rectangle, position the cursor before the first visible element. +// - User code submit visible elements. struct ImGuiListClipper { int DisplayStart; int DisplayEnd; - int ItemsCount; // [Internal] + int ItemsCount; int StepNo; float ItemsHeight; float StartPosY; - // items_count: Use -1 to ignore (you can call Begin later). Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step). - // items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing(). - // If you don't specify an items_height, you NEED to call Step(). If you specify items_height you may call the old Begin()/End() api directly, but prefer calling Step(). - ImGuiListClipper(int items_count = -1, float items_height = -1.0f); - ~ImGuiListClipper(); + IMGUI_API ImGuiListClipper(); + IMGUI_API ~ImGuiListClipper(); + // items_count: Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step) + // items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing(). IMGUI_API void Begin(int items_count, float items_height = -1.0f); // Automatically called by constructor if you passed 'items_count' or by Step() in Step 1. IMGUI_API void End(); // Automatically called on the last call of Step() that returns false. IMGUI_API bool Step(); // Call until it returns false. The DisplayStart/DisplayEnd fields will be set and you can process/draw those items. + +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + inline ImGuiListClipper(int items_count, float items_height = -1.0f) { memset(this, 0, sizeof(*this)); ItemsCount = -1; Begin(items_count, items_height); } // [removed in 1.79] +#endif }; // Helpers macros to generate 32-bit encoded colors From 014e5078a86a18ad91ef852d22a294a57e4ef6a3 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 5 Oct 2020 12:57:05 +0200 Subject: [PATCH 04/10] Demo: add a small easter egg when the 4x4 board of Selectable is filled + tweaked the demo. --- imgui_demo.cpp | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 96c0034e..eb7e24b9 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1088,27 +1088,34 @@ static void ShowDemoWindowWidgets() } if (ImGui::TreeNode("Grid")) { - static int selected[4 * 4] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; - for (int i = 0; i < 4 * 4; i++) - { - ImGui::PushID(i); - if (ImGui::Selectable("Sailor", selected[i] != 0, 0, ImVec2(50, 50))) - { - // Toggle - selected[i] = !selected[i]; + static char selected[4][4] = { { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } }; - // Note: We _unnecessarily_ test for both x/y and i here only to silence some static analyzer. - // The second part of each test is unnecessary. - int x = i % 4; - int y = i / 4; - if (x > 0) { selected[i - 1] ^= 1; } - if (x < 3 && i < 15) { selected[i + 1] ^= 1; } - if (y > 0 && i > 3) { selected[i - 4] ^= 1; } - if (y < 3 && i < 12) { selected[i + 4] ^= 1; } + // Add in a bit of silly fun... + const float time = (float)ImGui::GetTime(); + const bool winning_state = memchr(selected, 0, sizeof(selected)) == NULL; // If all cells are selected... + if (winning_state) + ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, ImVec2(0.5f + 0.5f * cosf(time * 2.0f), 0.5f + 0.5f * sinf(time * 3.0f))); + + for (int y = 0; y < 4; y++) + for (int x = 0; x < 4; x++) + { + if (x > 0) + ImGui::SameLine(); + ImGui::PushID(y * 4 + x); + if (ImGui::Selectable("Sailor", selected[y][x] != 0, 0, ImVec2(50, 50))) + { + // Toggle clicked cell + toggle neighbors + selected[y][x] ^= 1; + if (x > 0) { selected[y][x - 1] ^= 1; } + if (x < 3) { selected[y][x + 1] ^= 1; } + if (y > 0) { selected[y - 1][x] ^= 1; } + if (y < 3) { selected[y + 1][x] ^= 1; } + } + ImGui::PopID(); } - if ((i % 4) < 3) ImGui::SameLine(); - ImGui::PopID(); - } + + if (winning_state) + ImGui::PopStyleVar(); ImGui::TreePop(); } if (ImGui::TreeNode("Alignment")) From 4fd43a8b64155d9c01c615afd5b0831a60b47c0f Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 5 Oct 2020 14:52:18 +0200 Subject: [PATCH 05/10] Internals: removed NavLayerCurrentMask (redundant, add extra shift in ItemAdd(). --- imgui.cpp | 7 +------ imgui_internal.h | 6 ++---- imgui_widgets.cpp | 4 +--- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 429dbb1a..c825d16e 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5142,7 +5142,6 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s // Resize grips and borders are on layer 1 window->DC.NavLayerCurrent = ImGuiNavLayer_Menu; - window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Menu); // Manual resize grips PushID("#RESIZE"); @@ -5211,7 +5210,6 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s // Restore nav layer window->DC.NavLayerCurrent = ImGuiNavLayer_Main; - window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main); // Navigation resize (keyboard/gamepad) if (g.NavWindowingTarget && g.NavWindowingTarget->RootWindow == window) @@ -5382,7 +5380,6 @@ void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& titl const ImGuiItemFlags item_flags_backup = window->DC.ItemFlags; window->DC.ItemFlags |= ImGuiItemFlags_NoNavDefaultFocus; window->DC.NavLayerCurrent = ImGuiNavLayer_Menu; - window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Menu); // Layout buttons // FIXME: Would be nice to generalize the subtleties expressed here into reusable code. @@ -5418,7 +5415,6 @@ void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& titl *p_open = false; window->DC.NavLayerCurrent = ImGuiNavLayer_Main; - window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main); window->DC.ItemFlags = item_flags_backup; // Title bar text (with: horizontal alignment, avoiding collapse/close button, optional "unsaved document" marker) @@ -5994,7 +5990,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) window->DC.CurrLineTextBaseOffset = window->DC.PrevLineTextBaseOffset = 0.0f; window->DC.NavLayerCurrent = ImGuiNavLayer_Main; - window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main); window->DC.NavLayerActiveMask = window->DC.NavLayerActiveMaskNext; window->DC.NavLayerActiveMaskNext = 0x00; window->DC.NavFocusScopeIdCurrent = (flags & ImGuiWindowFlags_ChildWindow) ? parent_window->DC.NavFocusScopeIdCurrent : 0; // -V595 @@ -7035,7 +7030,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg) // to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick). // We intentionally don't check if g.NavWindow != NULL because g.NavAnyRequest should only be set when it is non null. // If we crash on a NULL g.NavWindow we need to fix the bug elsewhere. - window->DC.NavLayerActiveMaskNext |= window->DC.NavLayerCurrentMask; + window->DC.NavLayerActiveMaskNext |= (1 << window->DC.NavLayerCurrent); if (g.NavId == id || g.NavAnyRequest) if (g.NavWindow->RootWindowForNav == window->RootWindowForNav) if (window == g.NavWindow || ((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened)) diff --git a/imgui_internal.h b/imgui_internal.h index 856b2a63..896a8ae5 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1497,9 +1497,8 @@ struct IMGUI_API ImGuiWindowTempData // Keyboard/Gamepad navigation ImGuiNavLayer NavLayerCurrent; // Current layer, 0..31 (we currently only use 0..1) - int NavLayerCurrentMask; // = (1 << NavLayerCurrent) used by ItemAdd prior to clipping. - int NavLayerActiveMask; // Which layer have been written to (result from previous frame) - int NavLayerActiveMaskNext; // Which layer have been written to (buffer for current frame) + int NavLayerActiveMask; // Which layers have been written to (result from previous frame) + int NavLayerActiveMaskNext; // Which layers have been written to (accumulator for current frame) ImGuiID NavFocusScopeIdCurrent; // Current focus scope ID while appending bool NavHideHighlightOneFrame; bool NavHasScroll; // Set when scrolling can be used (ScrollMax > 0.0f) @@ -1544,7 +1543,6 @@ struct IMGUI_API ImGuiWindowTempData NavLayerActiveMask = NavLayerActiveMaskNext = 0x00; NavLayerCurrent = ImGuiNavLayer_Main; - NavLayerCurrentMask = (1 << ImGuiNavLayer_Main); NavFocusScopeIdCurrent = 0; NavHideHighlightOneFrame = false; NavHasScroll = false; diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 33ddb376..1f3ba21b 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -3833,7 +3833,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ return false; } draw_window = g.CurrentWindow; // Child window - draw_window->DC.NavLayerActiveMaskNext |= draw_window->DC.NavLayerCurrentMask; // This is to ensure that EndChild() will display a navigation highlight so we can "enter" into it. + draw_window->DC.NavLayerActiveMaskNext |= (1 << draw_window->DC.NavLayerCurrent); // This is to ensure that EndChild() will display a navigation highlight so we can "enter" into it. inner_size.x -= draw_window->ScrollbarSizes.x; } else @@ -6462,7 +6462,6 @@ bool ImGui::BeginMenuBar() window->DC.CursorPos = window->DC.CursorMaxPos = ImVec2(bar_rect.Min.x + window->DC.MenuBarOffset.x, bar_rect.Min.y + window->DC.MenuBarOffset.y); window->DC.LayoutType = ImGuiLayoutType_Horizontal; window->DC.NavLayerCurrent = ImGuiNavLayer_Menu; - window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Menu); window->DC.MenuBarAppending = true; AlignTextToFramePadding(); return true; @@ -6505,7 +6504,6 @@ void ImGui::EndMenuBar() EndGroup(); // Restore position on layer 0 window->DC.LayoutType = ImGuiLayoutType_Vertical; window->DC.NavLayerCurrent = ImGuiNavLayer_Main; - window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main); window->DC.MenuBarAppending = false; } From 12d95055347e452c48bf663a9aa02e8338bec154 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 7 Oct 2020 15:13:04 +0200 Subject: [PATCH 06/10] CheckboxFlags: Display mixed-value/tristate marker when passed flags that have multiple bits set and stored value matches neither zero neither the full set. --- docs/CHANGELOG.txt | 14 ++++++++------ imgui_widgets.cpp | 21 ++++++++++++++++++--- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 633293f7..220fef30 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -39,12 +39,12 @@ Breaking Changes: - Fonts: Removed ImFont::DisplayOffset in favor of ImFontConfig::GlyphOffset. DisplayOffset was applied after scaling and not very meaningful/useful outside of being needed by the default ProggyClean font. - It was also getting in the way of better font scaling, so let's get rid of it now! + It was also getting in the way of better font scaling, so let's get rid of it now! If you used DisplayOffset it was probably in association to rasterizing a font at a specific size, in which case the corresponding offset may be reported into GlyphOffset. (#1619) -- ImGuiListClipper: Renamed constructor parameters which created an ambiguous alternative to using +- ImGuiListClipper: Renamed constructor parameters which created an ambiguous alternative to using the ImGuiListClipper::Begin() function, with misleading edge cases. Always use ImGuiListClipper::Begin()! - Kept inline redirection function (will obsolete). + Kept inline redirection function (will obsolete). (note: imgui_memory_editor <0.40 from imgui_club/ used this old clipper API. Update your copy if needed). - Style: Renamed style.TabMinWidthForUnselectedCloseButton to style.TabMinWidthForCloseButton. - Renamed ImGuiSliderFlags_ClampOnInput to ImGuiSliderFlags_AlwaysClamp. Kept redirection enum (will obsolete). @@ -72,7 +72,7 @@ Other Changes: - InputText: Fixed cursor being partially covered after using Ctrl+End key. - InputText: Fixed callback's helper DeleteChars() function when cursor is inside the deleted block. (#3454) - InputText: Made pressing Down arrow on the last line when it doesn't have a carriage return not move to - the end of the line (so it is consistent with Up arrow, and behave same as Notepad and Visual Studio. + the end of the line (so it is consistent with Up arrow, and behave same as Notepad and Visual Studio. Note that some other text editors instead would move the crusor to the end of the line). [@Xipiryon] - DragFloat, DragScalar: Fixed ImGuiSliderFlags_ClampOnInput not being honored in the special case where v_min == v_max. (#3361) @@ -80,6 +80,8 @@ Other Changes: with signed and unsigned types. Added reverse Sliders to Demo. (#3432, #3449) [@rokups] - Text: Bypass unnecessary formatting when using the TextColored()/TextWrapped()/TextDisabled() helpers with a "%s" format string. (#3466) +- CheckboxFlags: Display mixed-value/tristate marker when passed flags that have multiple bits set and + stored value matches neither zero neither the full set. - BeginMenuBar: Fixed minor bug where CursorPosMax gets pushed to CursorPos prior to calling BeginMenuBar(), so e.g. calling the function at the end of a window would often add +ItemSpacing.y to scrolling range. - TreeNode, CollapsingHeader: Made clicking on arrow toggle toggle the open state on the Mouse Down event @@ -87,7 +89,7 @@ Other Changes: and amends the change done in 1.76 which only affected cases were _OpenOnArrow flag was set. (This is also necessary to support full multi/range-select/drag and drop operations.) - Tab Bar: Added TabItemButton() to submit tab that behave like a button. (#3291) [@Xipiryon] -- Tab Bar: Added ImGuiTabItemFlags_Leading and ImGuiTabItemFlags_Trailing flags to position tabs or button +- Tab Bar: Added ImGuiTabItemFlags_Leading and ImGuiTabItemFlags_Trailing flags to position tabs or button at either end of the tab bar. Those tabs won't be part of the scrolling region, and when reordering cannot be moving outside of their section. Most often used with TabItemButton(). (#3291) [@Xipiryon] - Tab Bar: Added ImGuiTabItemFlags_NoReorder flag to disable reordering a given tab. @@ -104,7 +106,7 @@ Other Changes: - Fonts: AddFontDefault() adjust its vertical offset based on floor(size/13) instead of always +1. - Metrics: Various tweaks, listing windows front-to-back, greying inactive items when possible. - Demo: Add simple InputText() callbacks demo (aside from the more elaborate ones in 'Examples->Console'). -- Backends: OpenGL3: Fix to avoid compiling/calling glBindSampler() on ES or pre 3.3 contexts which have +- Backends: OpenGL3: Fix to avoid compiling/calling glBindSampler() on ES or pre 3.3 contexts which have the defines set by a loader. (#3467, #1985) [@jjwebb] - Backends: Vulkan: Some internal refactor aimed at allowing multi-viewport feature to create their own render pass. (#3455, #3459) [@FunMiles] diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 1f3ba21b..1214523a 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1071,7 +1071,8 @@ bool ImGui::Checkbox(const char* label, bool* v) RenderNavHighlight(total_bb, id); RenderFrame(check_bb.Min, check_bb.Max, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding); ImU32 check_col = GetColorU32(ImGuiCol_CheckMark); - if (window->DC.ItemFlags & ImGuiItemFlags_MixedValue) + bool mixed_value = (window->DC.ItemFlags & ImGuiItemFlags_MixedValue) != 0; + if (mixed_value) { // Undocumented tristate/mixed/indeterminate checkbox (#2644) ImVec2 pad(ImMax(1.0f, IM_FLOOR(square_sz / 3.6f)), ImMax(1.0f, IM_FLOOR(square_sz / 3.6f))); @@ -1084,7 +1085,7 @@ bool ImGui::Checkbox(const char* label, bool* v) } if (g.LogEnabled) - LogRenderedText(&total_bb.Min, *v ? "[x]" : "[ ]"); + LogRenderedText(&total_bb.Min, mixed_value ? "[~]" : *v ? "[x]" : "[ ]"); if (label_size.x > 0.0f) RenderText(ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y), label); @@ -1095,7 +1096,21 @@ bool ImGui::Checkbox(const char* label, bool* v) bool ImGui::CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value) { bool v = ((*flags & flags_value) == flags_value); - bool pressed = Checkbox(label, &v); + bool pressed; + if (v == false && (*flags & flags_value) != 0) + { + // Mixed value (FIXME: find a way to expose neatly to Checkbox?) + ImGuiWindow* window = GetCurrentWindow(); + const ImGuiItemFlags backup_item_flags = window->DC.ItemFlags; + window->DC.ItemFlags |= ImGuiItemFlags_MixedValue; + pressed = Checkbox(label, &v); + window->DC.ItemFlags = backup_item_flags; + } + else + { + // Regular checkbox + pressed = Checkbox(label, &v); + } if (pressed) { if (v) From 03b1e643b48768db7c47b8b52553738c69361beb Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 8 Oct 2020 10:47:10 +0200 Subject: [PATCH 07/10] Docs: Funding link, Tweaks, Gallery links. --- .github/FUNDING.yml | 1 + imgui_widgets.cpp | 1 + 2 files changed, 2 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..2aa08b44 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: ['https://github.com/ocornut/imgui/wiki/Sponsors'] diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 1214523a..d0cc5b2f 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -7841,6 +7841,7 @@ bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, text_pixel_clip_bb.Max.x -= close_button_sz; } + // FIXME: if FramePadding is noticeably large, ellipsis_max_x will be wrong here (e.g. #3497), maybe for consistency that parameter of RenderTextEllipsis() shouldn't exist.. float ellipsis_max_x = close_button_visible ? text_pixel_clip_bb.Max.x : bb.Max.x - 1.0f; RenderTextEllipsis(draw_list, text_ellipsis_clip_bb.Min, text_ellipsis_clip_bb.Max, text_pixel_clip_bb.Max.x, ellipsis_max_x, label, NULL, &label_size); From ae5b4991be80cb516162703e6ea51976ae929763 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 8 Oct 2020 13:56:05 +0200 Subject: [PATCH 08/10] Docs: update gallery links. (#3514) --- docs/FAQ.md | 4 ++-- docs/README.md | 4 ++-- imgui.cpp | 4 ++-- imgui.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/FAQ.md b/docs/FAQ.md index 2745b122..acc99ede 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -600,7 +600,7 @@ You may take a look at: - [Quotes](https://github.com/ocornut/imgui/wiki/Quotes) - [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) -- [Gallery](https://github.com/ocornut/imgui/issues/3075) +- [Gallery](https://github.com/ocornut/imgui/issues/3488) ##### [Return to Index](#index) @@ -646,7 +646,7 @@ There is an auto-generated [c-api for Dear ImGui (cimgui)](https://github.com/ci - Individuals: you can support continued maintenance and development via PayPal donations. See [README](https://github.com/ocornut/imgui/blob/master/docs/README.md). - If you are experienced with Dear ImGui and C++, look at the [GitHub Issues](https://github.com/ocornut/imgui/issues), look at the [Wiki](https://github.com/ocornut/imgui/wiki), read [docs/TODO.txt](https://github.com/ocornut/imgui/blob/master/docs/TODO.txt) and see how you want to help and can help! - Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere etc. -You may post screenshot or links in the [gallery threads](https://github.com/ocornut/imgui/issues/3075). Visuals are ideal as they inspire other programmers. Disclosing your use of dear imgui help the library grow credibility, and help other teams and programmers with taking decisions. +You may post screenshot or links in the [gallery threads](https://github.com/ocornut/imgui/issues/3488). Visuals are ideal as they inspire other programmers. Disclosing your use of dear imgui help the library grow credibility, and help other teams and programmers with taking decisions. - If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues or sometimes incomplete PR. ##### [Return to Index](#index) diff --git a/docs/README.md b/docs/README.md index f696b274..81c92b3c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -132,7 +132,7 @@ Some of the goals for 2020 are: ### Gallery -For more user-submitted screenshots of projects using Dear ImGui, check out the [Gallery Threads](https://github.com/ocornut/imgui/issues/3075)! +For more user-submitted screenshots of projects using Dear ImGui, check out the [Gallery Threads](https://github.com/ocornut/imgui/issues/3488)! Custom engine [![screenshot game](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v149/gallery_TheDragonsTrap-01-thumb.jpg)](https://cloud.githubusercontent.com/assets/8225057/20628927/33e14cac-b329-11e6-80f6-9524e93b048a.png) @@ -165,7 +165,7 @@ Advanced users may want to use the `docking` branch with [Multi-Viewport](https: **Who uses Dear ImGui?** -See the [Quotes](https://github.com/ocornut/imgui/wiki/Quotes), [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors), [Software using dear imgui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) Wiki pages for an idea of who is using Dear ImGui. Please add your game/software if you can! Also see the [Gallery Threads](https://github.com/ocornut/imgui/issues/3075)! +See the [Quotes](https://github.com/ocornut/imgui/wiki/Quotes), [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors), [Software using dear imgui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) Wiki pages for an idea of who is using Dear ImGui. Please add your game/software if you can! Also see the [Gallery Threads](https://github.com/ocornut/imgui/issues/3488)! How to help ----------- diff --git a/imgui.cpp b/imgui.cpp index c825d16e..2425cf2c 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -11,7 +11,7 @@ // - FAQ http://dearimgui.org/faq // - Homepage & latest https://github.com/ocornut/imgui // - Releases & changelog https://github.com/ocornut/imgui/releases -// - Gallery https://github.com/ocornut/imgui/issues/3075 (please post your screenshots/video there!) +// - Gallery https://github.com/ocornut/imgui/issues/3488 (please post your screenshots/video there!) // - Glossary https://github.com/ocornut/imgui/wiki/Glossary // - Wiki https://github.com/ocornut/imgui/wiki // - Issues & support https://github.com/ocornut/imgui/issues @@ -703,7 +703,7 @@ CODE - If you are experienced with Dear ImGui and C++, look at the github issues, look at the Wiki, read docs/TODO.txt and see how you want to help and can help! - Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere etc. - You may post screenshot or links in the gallery threads (github.com/ocornut/imgui/issues/3075). Visuals are ideal as they inspire other programmers. + You may post screenshot or links in the gallery threads (github.com/ocornut/imgui/issues/3488). Visuals are ideal as they inspire other programmers. But even without visuals, disclosing your use of dear imgui help the library grow credibility, and help other teams and programmers with taking decisions. - If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues (on github or privately). diff --git a/imgui.h b/imgui.h index d72243e4..7fe14c4e 100644 --- a/imgui.h +++ b/imgui.h @@ -11,7 +11,7 @@ // - FAQ http://dearimgui.org/faq // - Homepage & latest https://github.com/ocornut/imgui // - Releases & changelog https://github.com/ocornut/imgui/releases -// - Gallery https://github.com/ocornut/imgui/issues/3075 (please post your screenshots/video there!) +// - Gallery https://github.com/ocornut/imgui/issues/3488 (please post your screenshots/video there!) // - Glossary https://github.com/ocornut/imgui/wiki/Glossary // - Wiki https://github.com/ocornut/imgui/wiki // - Issues & support https://github.com/ocornut/imgui/issues From c6f9c558ec53fba6862625bda0f222939428a180 Mon Sep 17 00:00:00 2001 From: Rokas Kupstys Date: Thu, 8 Oct 2020 15:06:46 +0300 Subject: [PATCH 09/10] CI: Use our own discord notifier. --- .github/workflows/build.yml | 71 +++++++++++---------------- .github/workflows/static-analysis.yml | 37 +++++++++++--- 2 files changed, 59 insertions(+), 49 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a15d5e23..a8db3199 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -179,14 +179,6 @@ jobs: shell: cmd run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx12/example_win32_directx12.vcxproj /p:Platform=x64 /p:Configuration=Release' - - uses: sarisia/actions-status-discord@v1 - if: failure() - with: - webhook: ${{ secrets.DISCORD_CI_WEBHOOK }} - username: GitHub Actions - color: 0xFF0000 - title: ${{ github.job }} - Linux: runs-on: ubuntu-20.04 steps: @@ -318,15 +310,6 @@ jobs: - name: Build example_sdl_opengl3 run: make -C examples/example_sdl_opengl3 - # Use https://github.com/marketplace/actions/actions-status-discord to send status to Discord - - uses: sarisia/actions-status-discord@v1 - if: failure() - with: - webhook: ${{ secrets.DISCORD_CI_WEBHOOK }} - username: GitHub Actions - color: 0xFF0000 - title: ${{ github.job }} - MacOS: runs-on: macOS-latest steps: @@ -382,15 +365,6 @@ jobs: - name: Build example_apple_opengl2 run: xcodebuild -project examples/example_apple_opengl2/example_apple_opengl2.xcodeproj -target example_osx_opengl2 - # Use https://github.com/marketplace/actions/actions-status-discord to send status to Discord - - uses: sarisia/actions-status-discord@v1 - if: failure() - with: - webhook: ${{ secrets.DISCORD_CI_WEBHOOK }} - username: GitHub Actions - color: 0xFF0000 - title: ${{ github.job }} - iOS: runs-on: macOS-latest steps: @@ -403,15 +377,6 @@ jobs: # Code signing is required, but we disable it because it is irrelevant for CI builds. xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_ios CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO - # Use https://github.com/marketplace/actions/actions-status-discord to send status to Discord - - uses: sarisia/actions-status-discord@v1 - if: failure() - with: - webhook: ${{ secrets.DISCORD_CI_WEBHOOK }} - username: GitHub Actions - color: 0xFF0000 - title: ${{ github.job }} - Emscripten: runs-on: ubuntu-18.04 steps: @@ -434,11 +399,33 @@ jobs: popd make -C examples/example_emscripten - # Use https://github.com/marketplace/actions/actions-status-discord to send status to Discord - - uses: sarisia/actions-status-discord@v1 - if: failure() + Discord-CI: + runs-on: ubuntu-18.04 + if: always() + needs: [Windows, Linux, MacOS, iOS, Emscripten] + steps: + - uses: dearimgui/github_discord_notifier@latest with: - webhook: ${{ secrets.DISCORD_CI_WEBHOOK }} - username: GitHub Actions - color: 0xFF0000 - title: ${{ github.job }} + discord-webhook: ${{ secrets.DISCORD_CI_WEBHOOK }} + github-token: ${{ github.token }} + action-task: discord-jobs + discord-filter: "'{{ github.branch }}'.match(/master|docking|tables/g) != null && '{{ run.conclusion }}' != '{{ last_run.conclusion }}'" + discord-username: GitHub Actions + discord-job-new-failure-message: '' + discord-job-fixed-failure-message: '' + discord-job-new-failure-embed: | + { + "title": "`{{ job.name }}` job is failing on `{{ github.branch }}`!", + "description": "Commit [{{ github.context.payload.head_commit.title }}]({{ github.context.payload.head_commit.url }}) pushed to [{{ github.branch }}]({{ github.branch_url }}) broke [{{ job.name }}]({{ job.url }}) build job.\nFailing steps: {{ failing_steps }}", + "url": "{{ job.url }}", + "color": "0xFF0000", + "timestamp": "{{ run.updated_at }}" + } + discord-job-fixed-failure-embed: | + { + "title": "`{{ github.branch }}` branch is no longer failing!", + "description": "Build failures were fixed on [{{ github.branch }}]({{ github.branch_url }}) branch.", + "color": "0x00FF00", + "url": "{{ github.context.payload.head_commit.url }}", + "timestamp": "{{ run.completed_at }}" + } diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 3681ecb2..868b5740 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -42,10 +42,33 @@ jobs: pvs-studio-analyzer analyze -e ../../imstb_rectpack.h -e ../../imstb_textedit.h -e ../../imstb_truetype.h -l ../../pvs-studio.lic -o pvs-studio.log plog-converter -a 'GA:1,2;OP:1' -t errorfile -w pvs-studio.log - - uses: sarisia/actions-status-discord@v1 - if: failure() - with: - webhook: ${{ secrets.DISCORD_CI_WEBHOOK }} - username: GitHub Actions - color: 0xFF0000 - title: ${{ github.job }} + Discord-CI: + runs-on: ubuntu-18.04 + needs: [PVS-Studio] + if: always() + steps: + - uses: dearimgui/github_discord_notifier@latest + with: + discord-webhook: ${{ secrets.DISCORD_CI_WEBHOOK }} + github-token: ${{ github.token }} + action-task: discord-jobs + discord-filter: "'{{ github.branch }}'.match(/master|docking|tables/g) != null && '{{ run.conclusion }}' != '{{ last_run.conclusion }}'" + discord-username: GitHub Actions + discord-job-new-failure-message: '' + discord-job-fixed-failure-message: '' + discord-job-new-failure-embed: | + { + "title": "`{{ job.name }}` job is failing on `{{ github.branch }}`!", + "description": "Commit [{{ github.context.payload.head_commit.title }}]({{ github.context.payload.head_commit.url }}) pushed to [{{ github.branch }}]({{ github.branch_url }}) broke static analysis [{{ job.name }}]({{ job.url }}) job.\nFailing steps: {{ failing_steps }}", + "url": "{{ job.url }}", + "color": "0xFF0000", + "timestamp": "{{ run.updated_at }}" + } + discord-job-fixed-failure-embed: | + { + "title": "`{{ github.branch }}` branch is no longer failing!", + "description": "Staic analysis failures were fixed on [{{ github.branch }}]({{ github.branch_url }}) branch.", + "color": "0x00FF00", + "url": "{{ github.context.payload.head_commit.url }}", + "timestamp": "{{ run.completed_at }}" + } From e5cb04b132cba94f902beb6186cb58b864777012 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 8 Oct 2020 13:55:25 +0200 Subject: [PATCH 10/10] Version 1.79 + Update readme and mission statement. Removed "Minimize screen reel-estate usage", removed details on memory consumption (still very valid, just too much noise in a mission statement) --- .github/workflows/static-analysis.yml | 2 +- docs/CHANGELOG.txt | 10 ++++++---- docs/README.md | 25 +++++++++++++------------ examples/README.txt | 2 +- imgui.cpp | 11 +++++------ imgui.h | 6 +++--- imgui_demo.cpp | 2 +- imgui_draw.cpp | 2 +- imgui_internal.h | 2 +- imgui_widgets.cpp | 2 +- 10 files changed, 33 insertions(+), 31 deletions(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 868b5740..0b7ef361 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -67,7 +67,7 @@ jobs: discord-job-fixed-failure-embed: | { "title": "`{{ github.branch }}` branch is no longer failing!", - "description": "Staic analysis failures were fixed on [{{ github.branch }}]({{ github.branch_url }}) branch.", + "description": "Static analysis failures were fixed on [{{ github.branch }}]({{ github.branch_url }}) branch.", "color": "0x00FF00", "url": "{{ github.context.payload.head_commit.url }}", "timestamp": "{{ run.completed_at }}" diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 220fef30..729f0b88 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -32,7 +32,7 @@ HOW TO UPDATE? ----------------------------------------------------------------------- - VERSION 1.79 WIP (In Progress) + VERSION 1.79 (Released 2020-10-08) ----------------------------------------------------------------------- Breaking Changes: @@ -42,6 +42,7 @@ Breaking Changes: It was also getting in the way of better font scaling, so let's get rid of it now! If you used DisplayOffset it was probably in association to rasterizing a font at a specific size, in which case the corresponding offset may be reported into GlyphOffset. (#1619) + If you scaled this value after calling AddFontDefault(), this is now done automatically. - ImGuiListClipper: Renamed constructor parameters which created an ambiguous alternative to using the ImGuiListClipper::Begin() function, with misleading edge cases. Always use ImGuiListClipper::Begin()! Kept inline redirection function (will obsolete). @@ -49,7 +50,7 @@ Breaking Changes: - Style: Renamed style.TabMinWidthForUnselectedCloseButton to style.TabMinWidthForCloseButton. - Renamed ImGuiSliderFlags_ClampOnInput to ImGuiSliderFlags_AlwaysClamp. Kept redirection enum (will obsolete). - Renamed OpenPopupContextItem() back to OpenPopupOnItemClick(), REVERTED CHANGE FROM 1.77. - For variety of reason this is more self-explanatory. Kept inline redirection function. + For variety of reason this is more self-explanatory and less error-prone. Kept inline redirection function. - Removed return value from OpenPopupOnItemClick() - returned true on mouse release on item - because it is inconsistent with other popups API and makes others misleading. It's also and unnecessary: you can use IsWindowAppearing() after BeginPopup() for a similar result. @@ -59,8 +60,8 @@ Other Changes: - Window: Fixed using non-zero pivot in SetNextWindowPos() when the window is collapsed. (#3433) - Nav: Fixed navigation resuming on first visible item when using gamepad. [@rokups] - Nav: Fixed using Alt to toggle the Menu layer when inside a Modal window. (#787) -- Scrolling: Fixed SetScrollHere functions edge snapping when called during a frame where ContentSize - is changing (issue introduced in 1.78). (#3452). +- Scrolling: Fixed SetScrollHere(0) functions edge snapping when called during a frame where + ContentSize is changing (issue introduced in 1.78). (#3452). - InputText: Added support for Page Up/Down in InputTextMultiline(). (#3430) [@Xipiryon] - InputText: Added selection helpers in ImGuiInputTextCallbackData(). - InputText: Added ImGuiInputTextFlags_CallbackEdit to modify internally owned buffer after an edit. @@ -104,6 +105,7 @@ Other Changes: - Popups, Tooltips: Fix edge cases issues with positionning popups and tooltips when they are larger than viewport on either or both axises. [@Rokups] - Fonts: AddFontDefault() adjust its vertical offset based on floor(size/13) instead of always +1. + Was previously done by altering DisplayOffset.y but wouldn't work for DPI scaled font. - Metrics: Various tweaks, listing windows front-to-back, greying inactive items when possible. - Demo: Add simple InputText() callbacks demo (aside from the more elaborate ones in 'Examples->Console'). - Backends: OpenGL3: Fix to avoid compiling/calling glBindSampler() on ES or pre 3.3 contexts which have diff --git a/docs/README.md b/docs/README.md index 81c92b3c..476540de 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,10 +5,12 @@ Dear ImGui (This library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using Dear ImGui, please consider reaching out.) -Businesses: support continued development via invoiced technical support, maintenance, sponsoring contracts: +Businesses: support continued development and maintenance via invoiced technical support, maintenance, sponsoring contracts:
  _E-mail: contact @ dearimgui dot com_ -Individuals: support continued maintenance and development with [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S). +Individuals: support continued development and maintenance [here](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S). + +Also see [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors) page. ---- @@ -18,7 +20,7 @@ Dear ImGui is designed to **enable fast iterations** and to **empower programmer Dear ImGui is particularly suited to integration in games engine (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on consoles platforms where operating system features are non-standard. -| [Usage](#usage) - [How it works](#how-it-works) - [Demo](#demo) - [Integration](#integration) | +| [Usage](#usage) - [How it works](#how-it-works) - [Releases](#releases) - [Demo](#demo) - [Integration](#integration) | :----------------------------------------------------------: | | [Upcoming changes](#upcoming-changes) - [Gallery](#gallery) - [Support, FAQ](#support-frequently-asked-questions-faq) - [How to help](#how-to-help) - [Sponsors](#sponsors) - [Credits](#credits) - [License](#license) | | [Wiki](https://github.com/ocornut/imgui/wiki) - [Language & frameworks bindings](https://github.com/ocornut/imgui/wiki/Bindings) - [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) - [User quotes](https://github.com/ocornut/imgui/wiki/Quotes) | @@ -36,7 +38,7 @@ You will need a backend to integrate Dear ImGui in your app. The backend passes After Dear ImGui is setup in your application, you can use it from \_anywhere\_ in your program loop: Code: -```cp +```cpp ImGui::Text("Hello, world %d", 123); if (ImGui::Button("Save")) MySaveFunction(); @@ -45,7 +47,7 @@ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); ``` Result:
![sample code output (dark)](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v175/capture_readme_styles_0001.png) ![sample code output (light)](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v175/capture_readme_styles_0002.png) -
_(settings: Dark style (left), Light style (right) / Font: Roboto-Medium, 16px / Rounding: 5)_ +
_(settings: Dark style (left), Light style (right) / Font: Roboto-Medium, 16px)_ Code: ```cpp @@ -91,6 +93,10 @@ Dear ImGui outputs vertex buffers and command lists that you can easily render i _A common misunderstanding is to mistake immediate mode gui for immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes as the gui functions are called. This is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are decently optimal and you can render them later, in your app or even remotely._ +### Releases + +See [Releases](https://github.com/ocornut/imgui/releases) page. + ### Demo Calling the `ImGui::ShowDemoWindow()` function will create a demo window showcasing variety of features and examples. The code is always available for reference in `imgui_demo.cpp`. @@ -179,12 +185,7 @@ How to help **How can I help financing further development of Dear ImGui?** -Your contributions are keeping this project alive. The library is available under a free and permissive license, but continued maintenance and development are a full-time endeavor and I would like to grow the team. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using Dear ImGui, please consider reaching out for invoiced technical support and maintenance contracts. Thank you! - -Businesses: support continued development via invoiced technical support, maintenance, sponsoring contracts: -
  _E-mail: contact @ dearimgui.com_ - -Individuals: support continued maintenance and development with [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S). +See [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors) page. Sponsors -------- @@ -214,7 +215,7 @@ Developed by [Omar Cornut](http://www.miracleworld.net) and every direct or indi Recurring contributors (2020): Omar Cornut [@ocornut](https://github.com/ocornut), Rokas Kupstys [@rokups](https://github.com/rokups), Ben Carter [@ShironekoBen](https://github.com/ShironekoBen). A large portion of work on automation systems, regression tests and other features are currently unpublished. -"I first discovered the IMGUI paradigm at [Q-Games](http://www.q-games.com) where Atman Binstock had dropped his own simple implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating and improving it." +Omar: "I first discovered the IMGUI paradigm at [Q-Games](http://www.q-games.com) where Atman Binstock had dropped his own simple implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating and improving it." Embeds [ProggyClean.ttf](http://upperbounds.net) font by Tristan Grimmer (MIT license). diff --git a/examples/README.txt b/examples/README.txt index e2577edb..68b6c104 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -1,5 +1,5 @@ ----------------------------------------------------------------------- - dear imgui, v1.79 WIP + dear imgui, v1.79 ----------------------------------------------------------------------- examples/README.txt (This is the README file for the examples/ folder. See docs/ for more documentation) diff --git a/imgui.cpp b/imgui.cpp index 2425cf2c..6e6d65d7 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.79 WIP +// dear imgui, v1.79 // (main code and documentation) // Help: @@ -92,14 +92,13 @@ CODE - Easy to use to create code-driven and data-driven tools. - Easy to use to create ad hoc short-lived tools and long-lived, more elaborate tools. - Easy to hack and improve. - - Minimize screen real-estate usage. - Minimize setup and maintenance. - Minimize state storage on user side. - Portable, minimize dependencies, run on target (consoles, phones, etc.). - - Efficient runtime and memory consumption (NB- we do allocate when "growing" content e.g. creating a window,. - opening a tree node for the first time, etc. but a typical frame should not allocate anything). + - Efficient runtime and memory consumption. + + Designed for developers and content-creators, not the typical end-user! Some of the current weaknesses includes: - Designed for developers and content-creators, not the typical end-user! Some of the weaknesses includes: - Doesn't look fancy, doesn't animate. - Limited layout features, intricate layouts are typically crafted in code. @@ -377,7 +376,7 @@ CODE - 2020/09/25 (1.79) - renamed style.TabMinWidthForUnselectedCloseButton to style.TabMinWidthForCloseButton. - 2020/09/21 (1.79) - renamed OpenPopupContextItem() back to OpenPopupOnItemClick(), reverting the change from 1.77. For varieties of reason this is more self-explanatory. - 2020/09/21 (1.79) - removed return value from OpenPopupOnItemClick() - returned true on mouse release on item - because it is inconsistent with other popup APIs and makes others misleading. It's also and unnecessary: you can use IsWindowAppearing() after BeginPopup() for a similar result. - - 2020/09/17 (1.79) - removed ImFont::DisplayOffset in favor of ImFontConfig::GlyphOffset. DisplayOffset was applied after scaling and not very meaningful/useful outside of being needed by the default ProggyClean font. It was also getting in the way of better font scaling, so let's get rid of it now! + - 2020/09/17 (1.79) - removed ImFont::DisplayOffset in favor of ImFontConfig::GlyphOffset. DisplayOffset was applied after scaling and not very meaningful/useful outside of being needed by the default ProggyClean font. If you scaled this value after calling AddFontDefault(), this is now done automatically. It was also getting in the way of better font scaling, so let's get rid of it now! - 2020/08/17 (1.78) - obsoleted use of the trailing 'float power=1.0f' parameter for DragFloat(), DragFloat2(), DragFloat3(), DragFloat4(), DragFloatRange2(), DragScalar(), DragScalarN(), SliderFloat(), SliderFloat2(), SliderFloat3(), SliderFloat4(), SliderScalar(), SliderScalarN(), VSliderFloat() and VSliderScalar(). replaced the 'float power=1.0f' argument with integer-based flags defaulting to 0 (as with all our flags). worked out a backward-compatibility scheme so hopefully most C++ codebase should not be affected. in short, when calling those functions: diff --git a/imgui.h b/imgui.h index 7fe14c4e..798ae065 100644 --- a/imgui.h +++ b/imgui.h @@ -1,4 +1,4 @@ -// dear imgui, v1.79 WIP +// dear imgui, v1.79 // (headers) // Help: @@ -59,8 +59,8 @@ Index of this file: // Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens) -#define IMGUI_VERSION "1.79 WIP" -#define IMGUI_VERSION_NUM 17803 +#define IMGUI_VERSION "1.79" +#define IMGUI_VERSION_NUM 17900 #define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx)) // Define attributes of all API symbols declarations (e.g. for DLL under Windows) diff --git a/imgui_demo.cpp b/imgui_demo.cpp index eb7e24b9..60be4b2f 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.79 WIP +// dear imgui, v1.79 // (demo code) // Help: diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 3f666698..c491cd25 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.79 WIP +// dear imgui, v1.79 // (drawing and font code) /* diff --git a/imgui_internal.h b/imgui_internal.h index 896a8ae5..470bf4e9 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1,4 +1,4 @@ -// dear imgui, v1.79 WIP +// dear imgui, v1.79 // (internal structures/api) // You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility! diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index d0cc5b2f..fe5d2ba3 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.79 WIP +// dear imgui, v1.79 // (widgets code) /*