From 8f907bc9a22a00e38d5f9bf5e04bd134c2861ace Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 24 Jan 2023 15:59:01 +0100 Subject: [PATCH 01/20] imgui_freetype: fix warnings (#6104), fix typos. (#6079) --- misc/freetype/README.md | 2 +- misc/freetype/imgui_freetype.cpp | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/misc/freetype/README.md b/misc/freetype/README.md index 5fcfc2d7..140ae225 100644 --- a/misc/freetype/README.md +++ b/misc/freetype/README.md @@ -24,7 +24,7 @@ See https://gist.github.com/ocornut/b3a9ecf13502fd818799a452969649ad - Oversampling settins are ignored but also not so much necessary with the higher quality rendering. -### Comparaison +### Comparison Small, thin anti-aliased fonts typically benefit a lot from FreeType's hinting: ![comparing_font_rasterizers](https://user-images.githubusercontent.com/8225057/107550178-fef87f00-6bd0-11eb-8d09-e2edb2f0ccfc.gif) diff --git a/misc/freetype/imgui_freetype.cpp b/misc/freetype/imgui_freetype.cpp index 78ef2939..7361566e 100644 --- a/misc/freetype/imgui_freetype.cpp +++ b/misc/freetype/imgui_freetype.cpp @@ -43,13 +43,16 @@ #include FT_SYNTHESIS_H // #ifdef _MSC_VER +#pragma warning (push) #pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff) #pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). #endif -#if defined(__GNUC__) +#ifdef __GNUC__ +#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind #pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used +#pragma GCC diagnostic ignored "-Wsubobject-linkage" // warning: 'xxxx' has a field ‘xxxx’ whose type uses the anonymous namespace #endif //------------------------------------------------------------------------- @@ -348,7 +351,7 @@ namespace IM_ASSERT(0 && "FreeTypeFont::BlitGlyph(): Unknown bitmap pixel mode!"); } } -} +} // namespace #ifndef STB_RECT_PACK_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds) #ifndef IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION @@ -779,3 +782,11 @@ void ImGuiFreeType::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* u GImGuiFreeTypeFreeFunc = free_func; GImGuiFreeTypeAllocatorUserData = user_data; } + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + +#ifdef _MSC_VER +#pragma warning (pop) +#endif From e8421de23c23037f358bcaca396816b7bf7df7aa Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 24 Jan 2023 16:04:55 +0100 Subject: [PATCH 02/20] imgui_single_file: include imgui_freetype.cpp if the define is set. .h not often needed but doesn't cost much to include. --- misc/single_file/imgui_single_file.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/misc/single_file/imgui_single_file.h b/misc/single_file/imgui_single_file.h index 6c1fb369..e9ba2477 100644 --- a/misc/single_file/imgui_single_file.h +++ b/misc/single_file/imgui_single_file.h @@ -8,6 +8,9 @@ // Before you include this file in *one* C++ file to create the implementation. // Using this in your project will leak the contents of imgui_internal.h and ImVec2 operators in this compilation unit. #include "../../imgui.h" +#ifdef IMGUI_ENABLE_FREETYPE +#include "../../misc/freetype/imgui_freetype.h" +#endif #ifdef IMGUI_IMPLEMENTATION #include "../../imgui.cpp" @@ -15,4 +18,7 @@ #include "../../imgui_draw.cpp" #include "../../imgui_tables.cpp" #include "../../imgui_widgets.cpp" +#ifdef IMGUI_ENABLE_FREETYPE +#include "../../misc/freetype/imgui_freetype.cpp" +#endif #endif From f6db9e2f39b65ced9a45d3f03fcb6b6502687998 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 24 Jan 2023 16:11:38 +0100 Subject: [PATCH 03/20] Menus: Fixed layout of MenuItem()/BeginMenu() when label contains a '\n'. (#6116) --- docs/CHANGELOG.txt | 1 + imgui_widgets.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index abe897f3..794db3aa 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -46,6 +46,7 @@ All changes: is scaled. Scaling wasn't taken into account, leading to ellipsis character straying slightly out of its expected boundaries. (#2775) - Text: Tweaked rendering of three-dots "..." ellipsis variant. (#2775, #4269) +- Menus: Fixed layout of MenuItem()/BeginMenu() when label contains a '\n'. (#6116) [@imkcy9] - PlotHistogram, PlotLines: Passing negative sizes honor alignment like other widgets. diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 278ab3c7..3c12ef00 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -7022,7 +7022,7 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled) PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y)); float w = label_size.x; ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset); - pressed = Selectable("", menu_is_open, selectable_flags, ImVec2(w, 0.0f)); + pressed = Selectable("", menu_is_open, selectable_flags, ImVec2(w, label_size.y)); RenderText(text_pos, label); PopStyleVar(); window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar(). @@ -7038,7 +7038,7 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled) float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, 0.0f, checkmark_w); // Feedback to next frame float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w); ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset); - pressed = Selectable("", menu_is_open, selectable_flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, 0.0f)); + pressed = Selectable("", menu_is_open, selectable_flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, label_size.y)); RenderText(text_pos, label); if (icon_w > 0.0f) RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon); @@ -7230,7 +7230,7 @@ bool ImGui::MenuItemEx(const char* label, const char* icon, const char* shortcut float checkmark_w = IM_FLOOR(g.FontSize * 1.20f); float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, shortcut_w, checkmark_w); // Feedback for next frame float stretch_w = ImMax(0.0f, GetContentRegionAvail().x - min_w); - pressed = Selectable("", false, selectable_flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, 0.0f)); + pressed = Selectable("", false, selectable_flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, label_size.y)); if (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_Visible) { RenderText(pos + ImVec2(offsets->OffsetLabel, 0.0f), label); From 739a79b1e9ba33afa5c2bd040dd6f1357d00d3f5 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 24 Jan 2023 17:30:22 +0100 Subject: [PATCH 04/20] ImDrawList: Added missing early-out in AddPolyline() and AddConvexPolyFilled() when color alpha is zero. Window: Avoid rendering shapes for hidden resize grips. --- docs/CHANGELOG.txt | 5 ++++- imgui.cpp | 5 ++++- imgui_draw.cpp | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 794db3aa..36fcb3b1 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -37,17 +37,20 @@ HOW TO UPDATE? All changes: +- Window: Avoid rendering shapes for hidden resize grips. - 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. - Text: Fixed layouting of wrapped-text block skipping successive empty lines, regression from the fix in 1.89.2. (#5720, #5919) -- Text: Fix 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 is scaled. Scaling wasn't taken into account, leading to ellipsis character straying slightly out of its expected boundaries. (#2775) - Text: Tweaked rendering of three-dots "..." ellipsis variant. (#2775, #4269) - Menus: Fixed layout of MenuItem()/BeginMenu() when label contains a '\n'. (#6116) [@imkcy9] - PlotHistogram, PlotLines: Passing negative sizes honor alignment like other widgets. +- ImDrawList: Added missing early-out in AddPolyline() and AddConvexPolyFilled() when + color alpha is zero. ----------------------------------------------------------------------- diff --git a/imgui.cpp b/imgui.cpp index 29bf8aee..e1e645e9 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5810,12 +5810,15 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar { for (int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++) { + const ImU32 col = resize_grip_col[resize_grip_n]; + if ((col & IM_COL32_A_MASK) == 0) + continue; const ImGuiResizeGripDef& grip = resize_grip_def[resize_grip_n]; const ImVec2 corner = ImLerp(window->Pos, window->Pos + window->Size, grip.CornerPosN); window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(window_border_size, resize_grip_draw_size) : ImVec2(resize_grip_draw_size, window_border_size))); window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(resize_grip_draw_size, window_border_size) : ImVec2(window_border_size, resize_grip_draw_size))); window->DrawList->PathArcToFast(ImVec2(corner.x + grip.InnerDir.x * (window_rounding + window_border_size), corner.y + grip.InnerDir.y * (window_rounding + window_border_size)), window_rounding, grip.AngleMin12, grip.AngleMax12); - window->DrawList->PathFillConvex(resize_grip_col[resize_grip_n]); + window->DrawList->PathFillConvex(col); } } diff --git a/imgui_draw.cpp b/imgui_draw.cpp index b942e6e7..540dc11a 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -706,7 +706,7 @@ void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, c // We avoid using the ImVec2 math operators here to reduce cost to a minimum for debug/non-inlined builds. void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 col, ImDrawFlags flags, float thickness) { - if (points_count < 2) + if (points_count < 2 || (col & IM_COL32_A_MASK) == 0) return; const bool closed = (flags & ImDrawFlags_Closed) != 0; @@ -964,7 +964,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 // - Filled shapes must always use clockwise winding order. The anti-aliasing fringe depends on it. Counter-clockwise shapes will have "inward" anti-aliasing. void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_count, ImU32 col) { - if (points_count < 3) + if (points_count < 3 || (col & IM_COL32_A_MASK) == 0) return; const ImVec2 uv = _Data->TexUvWhitePixel; From 3d8885cbbdda27fb5e2d1b41c1e1f50cdb2dd6ab Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 24 Jan 2023 19:16:12 +0100 Subject: [PATCH 05/20] TabBar: Internals: add GetCurrentTabBar(), TabBarFindTabByOrder(), TabBarGetCurrentTab(), TabBarGetTabOrder(), TabBarGetTabName(), TabBarQueueFocus() + clear LastTabItemIdx on EndTabBar(). (#5853, #5997) ImGuiTabBar::GetTabOrder() -> TabBarGetTabOrder(). ImGuiTabBar::GetTabName() -> TabBarGetTabName() --- imgui.cpp | 6 ++--- imgui_internal.h | 18 ++++++------- imgui_widgets.cpp | 65 +++++++++++++++++++++++++++++++++++------------ 3 files changed, 61 insertions(+), 28 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index e1e645e9..df8b1dc4 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -13938,7 +13938,7 @@ void ImGui::DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label) { ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; p += ImFormatString(p, buf_end - p, "%s'%s'", - tab_n > 0 ? ", " : "", (tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "???"); + tab_n > 0 ? ", " : "", (tab->NameOffset != -1) ? TabBarGetTabName(tab_bar, tab) : "???"); } p += ImFormatString(p, buf_end - p, (tab_bar->Tabs.Size > 3) ? " ... }" : " } "); if (!is_active) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); } @@ -13955,12 +13955,12 @@ void ImGui::DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label) { for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++) { - const ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; + ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; PushID(tab); if (SmallButton("<")) { TabBarQueueReorder(tab_bar, tab, -1); } SameLine(0, 2); if (SmallButton(">")) { TabBarQueueReorder(tab_bar, tab, +1); } SameLine(); Text("%02d%c Tab 0x%08X '%s' Offset: %.2f, Width: %.2f/%.2f", - tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID, (tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "???", tab->Offset, tab->Width, tab->ContentWidth); + tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID, (tab->NameOffset != -1) ? TabBarGetTabName(tab_bar, tab) : "???", tab->Offset, tab->Width, tab->ContentWidth); PopID(); } TreePop(); diff --git a/imgui_internal.h b/imgui_internal.h index 9debe0d3..99c2dc2c 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -2390,7 +2390,7 @@ struct ImGuiTabItem float RequestedWidth; // Width optionally requested by caller, -1.0f is unused ImS32 NameOffset; // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames ImS16 BeginOrder; // BeginTabItem() order, used to re-order tabs after toggling ImGuiTabBarFlags_Reorderable - ImS16 IndexDuringLayout; // Index only used during TabBarLayout() + ImS16 IndexDuringLayout; // Index only used during TabBarLayout(). Tabs gets reordered so 'Tabs[n].IndexDuringLayout == n' but may mismatch during additions. bool WantClose; // Marked as closed by SetTabItemClosed() ImGuiTabItem() { memset(this, 0, sizeof(*this)); LastFrameVisible = LastFrameSelected = -1; RequestedWidth = -1.0f; NameOffset = -1; BeginOrder = IndexDuringLayout = -1; } @@ -2432,12 +2432,6 @@ struct IMGUI_API ImGuiTabBar ImGuiTextBuffer TabsNames; // For non-docking tab bar we re-append names in a contiguous buffer. ImGuiTabBar(); - int GetTabOrder(const ImGuiTabItem* tab) const { return Tabs.index_from_ptr(tab); } - const char* GetTabName(const ImGuiTabItem* tab) const - { - IM_ASSERT(tab->NameOffset != -1 && tab->NameOffset < TabsNames.Buf.Size); - return TabsNames.Buf.Data + tab->NameOffset; - } }; //----------------------------------------------------------------------------- @@ -3038,12 +3032,18 @@ namespace ImGui IMGUI_API ImGuiTableSettings* TableSettingsFindByID(ImGuiID id); // Tab Bars + inline ImGuiTabBar* GetCurrentTabBar() { ImGuiContext& g = *GImGui; return g.CurrentTabBar; } IMGUI_API bool BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& bb, ImGuiTabBarFlags flags); IMGUI_API ImGuiTabItem* TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id); + IMGUI_API ImGuiTabItem* TabBarFindTabByOrder(ImGuiTabBar* tab_bar, int order); + IMGUI_API ImGuiTabItem* TabBarGetCurrentTab(ImGuiTabBar* tab_bar); + inline int TabBarGetTabOrder(ImGuiTabBar* tab_bar, ImGuiTabItem* tab) { return tab_bar->Tabs.index_from_ptr(tab); } + IMGUI_API const char* TabBarGetTabName(ImGuiTabBar* tab_bar, ImGuiTabItem* tab); IMGUI_API void TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id); IMGUI_API void TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab); - IMGUI_API void TabBarQueueReorder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int offset); - IMGUI_API void TabBarQueueReorderFromMousePos(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, ImVec2 mouse_pos); + IMGUI_API void TabBarQueueFocus(ImGuiTabBar* tab_bar, ImGuiTabItem* tab); + IMGUI_API void TabBarQueueReorder(ImGuiTabBar* tab_bar, ImGuiTabItem* tab, int offset); + IMGUI_API void TabBarQueueReorderFromMousePos(ImGuiTabBar* tab_bar, ImGuiTabItem* tab, ImVec2 mouse_pos); IMGUI_API bool TabBarProcessReorder(ImGuiTabBar* tab_bar); IMGUI_API bool TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags, ImGuiWindow* docked_window); IMGUI_API ImVec2 TabItemCalcSize(const char* label, bool has_close_button_or_unsaved_marker); diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 3c12ef00..d2d0c00d 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -7282,11 +7282,17 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool* p_selected, // - TabBarCalcTabID() [Internal] // - TabBarCalcMaxTabWidth() [Internal] // - TabBarFindTabById() [Internal] +// - TabBarFindTabByOrder() [Internal] +// - TabBarGetCurrentTab() [Internal] +// - TabBarGetTabName() [Internal] // - TabBarRemoveTab() [Internal] // - TabBarCloseTab() [Internal] // - TabBarScrollClamp() [Internal] // - TabBarScrollToTab() [Internal] -// - TabBarQueueChangeTabOrder() [Internal] +// - TabBarQueueFocus() [Internal] +// - TabBarQueueReorder() [Internal] +// - TabBarProcessReorderFromMousePos() [Internal] +// - TabBarProcessReorder() [Internal] // - TabBarScrollingButtons() [Internal] // - TabBarTabListPopupButton() [Internal] //------------------------------------------------------------------------- @@ -7411,6 +7417,7 @@ bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImG tab_bar->ItemSpacingY = g.Style.ItemSpacing.y; tab_bar->FramePadding = g.Style.FramePadding; tab_bar->TabsActiveCount = 0; + tab_bar->LastTabItemIdx = -1; tab_bar->BeginCount = 1; // Set cursor pos in a way which only be used in the off-chance the user erroneously submits item before BeginTabItem(): items will overlap @@ -7459,6 +7466,7 @@ void ImGui::EndTabBar() if (tab_bar->BeginCount > 1) window->DC.CursorPos = tab_bar->BackupCursorPos; + tab_bar->LastTabItemIdx = -1; if ((tab_bar->Flags & ImGuiTabBarFlags_DockNode) == 0) PopID(); @@ -7568,7 +7576,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar) // Refresh tab width immediately, otherwise changes of style e.g. style.FramePadding.x would noticeably lag in the tab bar. // Additionally, when using TabBarAddTab() to manipulate tab bar order we occasionally insert new tabs that don't have a width yet, // and we cannot wait for the next BeginTabItem() call. We cannot compute this width within TabBarAddTab() because font size depends on the active window. - const char* tab_name = tab_bar->GetTabName(tab); + const char* tab_name = TabBarGetTabName(tab_bar, tab); const bool has_close_button_or_unsaved_marker = (tab->Flags & ImGuiTabItemFlags_NoCloseButton) == 0 || (tab->Flags & ImGuiTabItemFlags_UnsavedDocument); tab->ContentWidth = (tab->RequestedWidth >= 0.0f) ? tab->RequestedWidth : TabItemCalcSize(tab_name, has_close_button_or_unsaved_marker).x; @@ -7729,7 +7737,28 @@ ImGuiTabItem* ImGui::TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id) return NULL; } -// The *TabId fields be already set by the docking system _before_ the actual TabItem was created, so we clear them regardless. +// Order = visible order, not submission order! (which is tab->BeginOrder) +ImGuiTabItem* ImGui::TabBarFindTabByOrder(ImGuiTabBar* tab_bar, int order) +{ + if (order < 0 || order >= tab_bar->Tabs.Size) + return NULL; + return &tab_bar->Tabs[order]; +} + +ImGuiTabItem* ImGui::TabBarGetCurrentTab(ImGuiTabBar* tab_bar) +{ + if (tab_bar->LastTabItemIdx <= 0 || tab_bar->LastTabItemIdx >= tab_bar->Tabs.Size) + return NULL; + return &tab_bar->Tabs[tab_bar->LastTabItemIdx]; +} + +const char* ImGui::TabBarGetTabName(ImGuiTabBar* tab_bar, ImGuiTabItem* tab) +{ + IM_ASSERT(tab->NameOffset != -1 && tab->NameOffset < tab_bar->TabsNames.Buf.Size); + return tab_bar->TabsNames.Buf.Data + tab->NameOffset; +} + +// The *TabId fields are already set by the docking system _before_ the actual TabItem was created, so we clear them regardless. void ImGui::TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id) { if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_id)) @@ -7760,7 +7789,7 @@ void ImGui::TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab) { // Actually select before expecting closure attempt (on an UnsavedDocument tab user is expect to e.g. show a popup) if (tab_bar->VisibleTabId != tab->ID) - tab_bar->NextSelectedTabId = tab->ID; + TabBarQueueFocus(tab_bar, tab); } } @@ -7781,7 +7810,7 @@ static void ImGui::TabBarScrollToTab(ImGuiTabBar* tab_bar, ImGuiID tab_id, ImGui ImGuiContext& g = *GImGui; float margin = g.FontSize * 1.0f; // When to scroll to make Tab N+1 visible always make a bit of N visible to suggest more scrolling area (since we don't have a scrollbar) - int order = tab_bar->GetTabOrder(tab); + int order = TabBarGetTabOrder(tab_bar, tab); // Scrolling happens only in the central section (leading/trailing sections are not scrolling) // FIXME: This is all confusing. @@ -7805,7 +7834,12 @@ static void ImGui::TabBarScrollToTab(ImGuiTabBar* tab_bar, ImGuiID tab_id, ImGui } } -void ImGui::TabBarQueueReorder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int offset) +void ImGui::TabBarQueueFocus(ImGuiTabBar* tab_bar, ImGuiTabItem* tab) +{ + tab_bar->NextSelectedTabId = tab->ID; +} + +void ImGui::TabBarQueueReorder(ImGuiTabBar* tab_bar, ImGuiTabItem* tab, int offset) { IM_ASSERT(offset != 0); IM_ASSERT(tab_bar->ReorderRequestTabId == 0); @@ -7813,7 +7847,7 @@ void ImGui::TabBarQueueReorder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, in tab_bar->ReorderRequestOffset = (ImS16)offset; } -void ImGui::TabBarQueueReorderFromMousePos(ImGuiTabBar* tab_bar, const ImGuiTabItem* src_tab, ImVec2 mouse_pos) +void ImGui::TabBarQueueReorderFromMousePos(ImGuiTabBar* tab_bar, ImGuiTabItem* src_tab, ImVec2 mouse_pos) { ImGuiContext& g = *GImGui; IM_ASSERT(tab_bar->ReorderRequestTabId == 0); @@ -7856,7 +7890,7 @@ bool ImGui::TabBarProcessReorder(ImGuiTabBar* tab_bar) return false; //IM_ASSERT(tab_bar->Flags & ImGuiTabBarFlags_Reorderable); // <- this may happen when using debug tools - int tab2_order = tab_bar->GetTabOrder(tab1) + tab_bar->ReorderRequestOffset; + int tab2_order = TabBarGetTabOrder(tab_bar, tab1) + tab_bar->ReorderRequestOffset; if (tab2_order < 0 || tab2_order >= tab_bar->Tabs.Size) return false; @@ -7916,7 +7950,7 @@ static ImGuiTabItem* ImGui::TabBarScrollingButtons(ImGuiTabBar* tab_bar) if (select_dir != 0) if (ImGuiTabItem* tab_item = TabBarFindTabByID(tab_bar, tab_bar->SelectedTabId)) { - int selected_order = tab_bar->GetTabOrder(tab_item); + int selected_order = TabBarGetTabOrder(tab_bar, tab_item); int target_order = selected_order + select_dir; // Skip tab item buttons until another tab item is found or end is reached @@ -7968,7 +8002,7 @@ static ImGuiTabItem* ImGui::TabBarTabListPopupButton(ImGuiTabBar* tab_bar) if (tab->Flags & ImGuiTabItemFlags_Button) continue; - const char* tab_name = tab_bar->GetTabName(tab); + const char* tab_name = TabBarGetTabName(tab_bar, tab); if (Selectable(tab_name, tab_bar->SelectedTabId == tab->ID)) tab_to_select = tab; } @@ -8132,9 +8166,9 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, { if (tab_appearing && (tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs) && tab_bar->NextSelectedTabId == 0) if (!tab_bar_appearing || tab_bar->SelectedTabId == 0) - tab_bar->NextSelectedTabId = id; // New tabs gets activated + TabBarQueueFocus(tab_bar, tab); // New tabs gets activated if ((flags & ImGuiTabItemFlags_SetSelected) && (tab_bar->SelectedTabId != id)) // _SetSelected can only be passed on explicit tab bar - tab_bar->NextSelectedTabId = id; + TabBarQueueFocus(tab_bar, tab); } // Lock visibility @@ -8198,7 +8232,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, bool hovered, held; bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags); if (pressed && !is_tab_button) - tab_bar->NextSelectedTabId = id; + TabBarQueueFocus(tab_bar, tab); // Allow the close button to overlap unless we are dragging (in which case we don't want any overlapping tabs to be hovered) if (g.ActiveId != id) @@ -8239,9 +8273,8 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, // Select with right mouse button. This is so the common idiom for context menu automatically highlight the current widget. const bool hovered_unblocked = IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup); - if (hovered_unblocked && (IsMouseClicked(1) || IsMouseReleased(1))) - if (!is_tab_button) - tab_bar->NextSelectedTabId = id; + if (hovered_unblocked && (IsMouseClicked(1) || IsMouseReleased(1)) && !is_tab_button) + TabBarQueueFocus(tab_bar, tab); if (tab_bar->Flags & ImGuiTabBarFlags_NoCloseWithMiddleMouseButton) flags |= ImGuiTabItemFlags_NoCloseWithMiddleMouseButton; From fe0a24f38a3501906bd304b381e3510fce9b8891 Mon Sep 17 00:00:00 2001 From: Mark Reid Date: Tue, 6 Dec 2022 13:33:53 -0800 Subject: [PATCH 06/20] Examples: Win32: Fixed examples using RegisterClassW() since 1.89 to also call DefWindowProcW(). (#5725, #5961, #5975) Fixes the window title from being truncated on calls to Platform_SetWindowTitle. Stops the WM_SETTEXT message that happens when calling setWindowTextW from being interpreted as ascii. --- docs/CHANGELOG.txt | 3 +++ examples/example_win32_directx10/main.cpp | 2 +- examples/example_win32_directx11/main.cpp | 2 +- examples/example_win32_directx12/main.cpp | 2 +- examples/example_win32_directx9/main.cpp | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 36fcb3b1..6c19b78a 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -51,6 +51,9 @@ All changes: - PlotHistogram, PlotLines: Passing negative sizes honor alignment like other widgets. - ImDrawList: Added missing early-out in AddPolyline() and AddConvexPolyFilled() when color alpha is zero. +- Examples: Win32: Fixed examples using RegisterClassW() since 1.89 to also call + DefWindowProcW() instead of DefWindowProc() so that title text are correctly converted + when application is compiled without /DUNICODE. (#5725, #5961, #5975) [@markreidvfx] ----------------------------------------------------------------------- diff --git a/examples/example_win32_directx10/main.cpp b/examples/example_win32_directx10/main.cpp index 03af619e..4fcc76cb 100644 --- a/examples/example_win32_directx10/main.cpp +++ b/examples/example_win32_directx10/main.cpp @@ -243,5 +243,5 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) ::PostQuitMessage(0); return 0; } - return ::DefWindowProc(hWnd, msg, wParam, lParam); + return ::DefWindowProcW(hWnd, msg, wParam, lParam); } diff --git a/examples/example_win32_directx11/main.cpp b/examples/example_win32_directx11/main.cpp index d7e5738d..f1a03354 100644 --- a/examples/example_win32_directx11/main.cpp +++ b/examples/example_win32_directx11/main.cpp @@ -247,5 +247,5 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) ::PostQuitMessage(0); return 0; } - return ::DefWindowProc(hWnd, msg, wParam, lParam); + return ::DefWindowProcW(hWnd, msg, wParam, lParam); } diff --git a/examples/example_win32_directx12/main.cpp b/examples/example_win32_directx12/main.cpp index 4de6246e..961d3435 100644 --- a/examples/example_win32_directx12/main.cpp +++ b/examples/example_win32_directx12/main.cpp @@ -462,5 +462,5 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) ::PostQuitMessage(0); return 0; } - return ::DefWindowProc(hWnd, msg, wParam, lParam); + return ::DefWindowProcW(hWnd, msg, wParam, lParam); } diff --git a/examples/example_win32_directx9/main.cpp b/examples/example_win32_directx9/main.cpp index 4c38768f..494a94bd 100644 --- a/examples/example_win32_directx9/main.cpp +++ b/examples/example_win32_directx9/main.cpp @@ -234,5 +234,5 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) ::PostQuitMessage(0); return 0; } - return ::DefWindowProc(hWnd, msg, wParam, lParam); + return ::DefWindowProcW(hWnd, msg, wParam, lParam); } From 07490618ae47fdb9f625565fbb183593170a6a72 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 25 Jan 2023 14:13:12 +0100 Subject: [PATCH 07/20] Misc: Tolerate zero delta-time under Emscripten. (#6114, #3644) --- docs/CHANGELOG.txt | 3 +++ imgui.cpp | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 6c19b78a..df9f554e 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -51,6 +51,9 @@ All changes: - PlotHistogram, PlotLines: Passing negative sizes honor alignment like other widgets. - ImDrawList: Added missing early-out in AddPolyline() and AddConvexPolyFilled() when color alpha is zero. +- Misc: Tolerate zero delta-time under Emscripten as backends are imprecise in their + values for io.DeltaTime, and browser features such as "privacy.resistFingerprinting=true" + can exacerbate that. (#6114, #3644) - Examples: Win32: Fixed examples using RegisterClassW() since 1.89 to also call DefWindowProcW() instead of DefWindowProc() so that title text are correctly converted when application is compiled without /DUNICODE. (#5725, #5961, #5975) [@markreidvfx] diff --git a/imgui.cpp b/imgui.cpp index df8b1dc4..da04669e 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -8852,6 +8852,13 @@ static void ImGui::ErrorCheckNewFrameSanityChecks() // #define IM_ASSERT(EXPR) do { if (SomeCode(EXPR)) SomeMoreCode(); } while (0) // Correct! if (true) IM_ASSERT(1); else IM_ASSERT(0); + // Emscripten backends are often imprecise in their submission of DeltaTime. (#6114, #3644) + // Ideally the Emscripten app/backend should aim to fix or smooth this value and avoid feeding zero, but we tolerate it. +#ifdef __EMSCRIPTEN__ + if (g.IO.DeltaTime <= 0.0f && g.FrameCount > 0) + g.IO.DeltaTime = 0.00001f; +#endif + // Check user data // (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument) IM_ASSERT(g.Initialized); From f4ef420c011dbb80626d103e40424f7697cda88d Mon Sep 17 00:00:00 2001 From: AJ Weeks Date: Tue, 10 Jan 2023 16:20:20 +0100 Subject: [PATCH 08/20] InputText: Added support for Ctrl+Delete to delete up to end of word. (#6067) --- docs/CHANGELOG.txt | 2 ++ imgui_widgets.cpp | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index df9f554e..9a9cdd5c 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -47,6 +47,8 @@ All changes: is scaled. Scaling wasn't taken into account, leading to ellipsis character straying slightly out of its expected boundaries. (#2775) - Text: Tweaked rendering of three-dots "..." ellipsis variant. (#2775, #4269) +- InputText: Added support for Ctrl+Delete to delete up to end-of-word. (#6067) [@ajweeks] + (Not adding Super+Delete to delete to up to end-of-line on OSX, as OSX doesn't have it) - Menus: Fixed layout of MenuItem()/BeginMenu() when label contains a '\n'. (#6116) [@imkcy9] - PlotHistogram, PlotLines: Passing negative sizes honor alignment like other widgets. - ImDrawList: Added missing early-out in AddPolyline() and AddConvexPolyFilled() when diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index d2d0c00d..041c141d 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -4317,7 +4317,16 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ else if (IsKeyPressed(ImGuiKey_PageDown) && is_multiline) { state->OnKeyPressed(STB_TEXTEDIT_K_PGDOWN | k_mask); scroll_y += row_count_per_page * g.FontSize; } else if (IsKeyPressed(ImGuiKey_Home)) { state->OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTSTART | k_mask : STB_TEXTEDIT_K_LINESTART | k_mask); } else if (IsKeyPressed(ImGuiKey_End)) { state->OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTEND | k_mask : STB_TEXTEDIT_K_LINEEND | k_mask); } - else if (IsKeyPressed(ImGuiKey_Delete) && !is_readonly && !is_cut) { state->OnKeyPressed(STB_TEXTEDIT_K_DELETE | k_mask); } + else if (IsKeyPressed(ImGuiKey_Delete) && !is_readonly && !is_cut) + { + if (!state->HasSelection()) + { + // OSX doesn't seem to have Super+Delete to delete until end-of-line, so we don't emulate that (as opposed to Super+Backspace) + if (is_wordmove_key_down) + state->OnKeyPressed(STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT); + } + state->OnKeyPressed(STB_TEXTEDIT_K_DELETE | k_mask); + } else if (IsKeyPressed(ImGuiKey_Backspace) && !is_readonly) { if (!state->HasSelection()) From 5741cbae45b66b0d74c3744a1d002e4b9a7c61ed Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 25 Jan 2023 20:04:19 +0100 Subject: [PATCH 09/20] Internals: ImFileOpen: fixed misleading use of ImWchar (would allocate more when ImWchar=ImWchar32) + update version for previous changes namely tab bar ones. --- docs/FAQ.md | 4 ++-- docs/README.md | 4 ++-- imgui.cpp | 4 ++-- imgui.h | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/FAQ.md b/docs/FAQ.md index 9e13d7cf..9effe3b9 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -644,7 +644,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) - [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors) -- [Gallery](https://github.com/ocornut/imgui/issues/5243) +- [Gallery](https://github.com/ocornut/imgui/issues/5886) ##### [Return to Index](#index) @@ -690,7 +690,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 [GitHub Issues](https://github.com/ocornut/imgui/issues), [GitHub Discussions](https://github.com/ocornut/imgui/discussions), 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 screenshots or links in the [gallery threads](https://github.com/ocornut/imgui/issues/5243). Visuals are ideal as they inspire other programmers. Disclosing your use of Dear ImGui helps the library grow credibility, and helps other teams and programmers with taking decisions. +You may post screenshots or links in the [gallery threads](https://github.com/ocornut/imgui/issues/5886). Visuals are ideal as they inspire other programmers. Disclosing your use of Dear ImGui helps the library grow credibility, and helps 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 e45652ba..c2ee34c0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -135,7 +135,7 @@ Also see [Wiki](https://github.com/ocornut/imgui/wiki) for more links and ideas. ### Gallery -For more user-submitted screenshots of projects using Dear ImGui, check out the [Gallery Threads](https://github.com/ocornut/imgui/issues/5243)! +For more user-submitted screenshots of projects using Dear ImGui, check out the [Gallery Threads](https://github.com/ocornut/imgui/issues/5886)! For a list of third-party widgets and extensions, check out the [Useful Extensions/Widgets](https://github.com/ocornut/imgui/wiki/Useful-Extensions) wiki page. @@ -166,7 +166,7 @@ We occasionally tag [Releases](https://github.com/ocornut/imgui/releases) (with **Who uses Dear ImGui?** -See the [Quotes](https://github.com/ocornut/imgui/wiki/Quotes), [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors), and [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/5243)! +See the [Quotes](https://github.com/ocornut/imgui/wiki/Quotes), [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors), and [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/5886)! How to help ----------- diff --git a/imgui.cpp b/imgui.cpp index da04669e..d1f34852 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/5243 (please post your screenshots/video there!) +// - Gallery https://github.com/ocornut/imgui/issues/5886 (please post your screenshots/video there!) // - Wiki https://github.com/ocornut/imgui/wiki (lots of good stuff there) // - Glossary https://github.com/ocornut/imgui/wiki/Glossary // - Issues & support https://github.com/ocornut/imgui/issues @@ -1903,7 +1903,7 @@ ImFileHandle ImFileOpen(const char* filename, const char* mode) // Previously we used ImTextCountCharsFromUtf8/ImTextStrFromUtf8 here but we now need to support ImWchar16 and ImWchar32! const int filename_wsize = ::MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0); const int mode_wsize = ::MultiByteToWideChar(CP_UTF8, 0, mode, -1, NULL, 0); - ImVector buf; + ImVector buf; buf.resize(filename_wsize + mode_wsize); ::MultiByteToWideChar(CP_UTF8, 0, filename, -1, (wchar_t*)&buf[0], filename_wsize); ::MultiByteToWideChar(CP_UTF8, 0, mode, -1, (wchar_t*)&buf[filename_wsize], mode_wsize); diff --git a/imgui.h b/imgui.h index 438d1464..4676f397 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/5243 (please post your screenshots/video there!) +// - Gallery https://github.com/ocornut/imgui/issues/5886 (please post your screenshots/video there!) // - Wiki https://github.com/ocornut/imgui/wiki (lots of good stuff there) // - Glossary https://github.com/ocornut/imgui/wiki/Glossary // - Issues & support https://github.com/ocornut/imgui/issues @@ -23,7 +23,7 @@ // Library Version // (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_NUM 18923 +#define IMGUI_VERSION_NUM 18924 #define IMGUI_HAS_TABLE /* From fc505322134b9a5a71cd23d5086276ed25313f90 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 25 Jan 2023 21:44:25 +0100 Subject: [PATCH 10/20] InputText: On OSX, inhibit usage of Alt key to toggle menu when active (used for work skip). --- docs/CHANGELOG.txt | 1 + imgui_widgets.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 9a9cdd5c..7bbafa7e 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -49,6 +49,7 @@ All changes: - Text: Tweaked rendering of three-dots "..." ellipsis variant. (#2775, #4269) - InputText: Added support for Ctrl+Delete to delete up to end-of-word. (#6067) [@ajweeks] (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). - Menus: Fixed layout of MenuItem()/BeginMenu() when label contains a '\n'. (#6116) [@imkcy9] - PlotHistogram, PlotLines: Passing negative sizes honor alignment like other widgets. - ImDrawList: Added missing early-out in AddPolyline() and AddConvexPolyFilled() when diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 041c141d..e6ae647d 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -4096,6 +4096,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ state->Stb.insert_mode = 1; // stb field name is indeed incorrect (see #2863) } + const bool is_osx = io.ConfigMacOSXBehaviors; if (g.ActiveId != id && init_make_active) { IM_ASSERT(state && state->ID == id); @@ -4118,6 +4119,8 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ SetKeyOwner(ImGuiKey_PageUp, id); SetKeyOwner(ImGuiKey_PageDown, id); } + if (is_osx) + SetKeyOwner(ImGuiMod_Alt, id); if (flags & (ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_AllowTabInput)) // Disable keyboard tabbing out as we will use the \t character. SetKeyOwner(ImGuiKey_Tab, id); } @@ -4187,7 +4190,6 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ const float mouse_x = (io.MousePos.x - frame_bb.Min.x - style.FramePadding.x) + state->ScrollX; const float mouse_y = (is_multiline ? (io.MousePos.y - draw_window->DC.CursorPos.y) : (g.FontSize * 0.5f)); - const bool is_osx = io.ConfigMacOSXBehaviors; if (select_all) { state->SelectAll(); @@ -4288,7 +4290,6 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ state->Stb.row_count_per_page = row_count_per_page; const int k_mask = (io.KeyShift ? STB_TEXTEDIT_K_SHIFT : 0); - const bool is_osx = io.ConfigMacOSXBehaviors; const bool is_wordmove_key_down = is_osx ? io.KeyAlt : io.KeyCtrl; // OS X style: Text editing cursor movement using Alt instead of Ctrl const bool is_startend_key_down = is_osx && io.KeySuper && !io.KeyCtrl && !io.KeyAlt; // OS X style: Line/Text Start and End using Cmd+Arrows instead of Home/End From d73e3285dea2bb352f3a9c0696120091f0b95f0e Mon Sep 17 00:00:00 2001 From: Basil Fierz Date: Wed, 25 Jan 2023 21:45:03 +0100 Subject: [PATCH 11/20] Backends: WebGU: Revert the implicit render pipeline layout generation as introduced in 83bdfef (#6117, #4116, #3632) The feature was removed from WebGPU (https://github.com/gpuweb/gpuweb/issues/2470) --- backends/imgui_impl_wgpu.cpp | 38 +++++++++++++++++++++++++++++++----- docs/CHANGELOG.txt | 2 ++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/backends/imgui_impl_wgpu.cpp b/backends/imgui_impl_wgpu.cpp index 3282cf36..11c1a376 100644 --- a/backends/imgui_impl_wgpu.cpp +++ b/backends/imgui_impl_wgpu.cpp @@ -13,6 +13,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2023-01-25: Revert automatic pipeline layout generation (see https://github.com/gpuweb/gpuweb/issues/2470) // 2022-11-24: Fixed validation error with default depth buffer settings. // 2022-11-10: Fixed rendering when a depth buffer is enabled. Added 'WGPUTextureFormat depth_format' parameter to ImGui_ImplWGPU_Init(). // 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11. @@ -554,7 +555,38 @@ bool ImGui_ImplWGPU_CreateDeviceObjects() graphics_pipeline_desc.multisample.count = 1; graphics_pipeline_desc.multisample.mask = UINT_MAX; graphics_pipeline_desc.multisample.alphaToCoverageEnabled = false; - graphics_pipeline_desc.layout = nullptr; // Use automatic layout generation + + // Bind group layouts + WGPUBindGroupLayoutEntry common_bg_layout_entries[2] = {}; + common_bg_layout_entries[0].binding = 0; + common_bg_layout_entries[0].visibility = WGPUShaderStage_Vertex; + common_bg_layout_entries[0].buffer.type = WGPUBufferBindingType_Uniform; + common_bg_layout_entries[1].binding = 1; + common_bg_layout_entries[1].visibility = WGPUShaderStage_Fragment; + common_bg_layout_entries[1].sampler.type = WGPUSamplerBindingType_Filtering; + + WGPUBindGroupLayoutEntry image_bg_layout_entries[1] = {}; + image_bg_layout_entries[0].binding = 0; + image_bg_layout_entries[0].visibility = WGPUShaderStage_Fragment; + image_bg_layout_entries[0].texture.sampleType = WGPUTextureSampleType_Float; + image_bg_layout_entries[0].texture.viewDimension = WGPUTextureViewDimension_2D; + + WGPUBindGroupLayoutDescriptor common_bg_layout_desc = {}; + common_bg_layout_desc.entryCount = 2; + common_bg_layout_desc.entries = common_bg_layout_entries; + + WGPUBindGroupLayoutDescriptor image_bg_layout_desc = {}; + image_bg_layout_desc.entryCount = 1; + image_bg_layout_desc.entries = image_bg_layout_entries; + + WGPUBindGroupLayout bg_layouts[2]; + bg_layouts[0] = wgpuDeviceCreateBindGroupLayout(g_wgpuDevice, &common_bg_layout_desc); + bg_layouts[1] = wgpuDeviceCreateBindGroupLayout(g_wgpuDevice, &image_bg_layout_desc); + + WGPUPipelineLayoutDescriptor layout_desc = {}; + layout_desc.bindGroupLayoutCount = 2; + layout_desc.bindGroupLayouts = bg_layouts; + graphics_pipeline_desc.layout = wgpuDeviceCreatePipelineLayout(g_wgpuDevice, &layout_desc); // Create the vertex shader WGPUProgrammableStageDescriptor vertex_shader_desc = ImGui_ImplWGPU_CreateShaderModule(__glsl_shader_vert_spv, sizeof(__glsl_shader_vert_spv) / sizeof(uint32_t)); @@ -620,10 +652,6 @@ bool ImGui_ImplWGPU_CreateDeviceObjects() ImGui_ImplWGPU_CreateUniformBuffer(); // Create resource bind group - WGPUBindGroupLayout bg_layouts[2]; - bg_layouts[0] = wgpuRenderPipelineGetBindGroupLayout(g_pipelineState, 0); - bg_layouts[1] = wgpuRenderPipelineGetBindGroupLayout(g_pipelineState, 1); - WGPUBindGroupEntry common_bg_entries[] = { { nullptr, 0, g_resources.Uniforms, 0, sizeof(Uniforms), 0, 0 }, diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 7bbafa7e..6d8fabe0 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -57,6 +57,8 @@ All changes: - Misc: Tolerate zero delta-time under Emscripten as backends are imprecise in their values for io.DeltaTime, and browser features such as "privacy.resistFingerprinting=true" can exacerbate that. (#6114, #3644) +- Backend: WebGPU: Fix building for latest WebGPU specs (remove implicit layout generation). + (#6117, #4116, #3632) [@tonygrue, @bfierz] - Examples: Win32: Fixed examples using RegisterClassW() since 1.89 to also call DefWindowProcW() instead of DefWindowProc() so that title text are correctly converted when application is compiled without /DUNICODE. (#5725, #5961, #5975) [@markreidvfx] From 27f2dd56d637d721561e469a7b0b598acdaad341 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 27 Jan 2023 15:24:23 +0100 Subject: [PATCH 12/20] Internals: move "%s" skip-formatting logic to ImFormatStringToTempBuffer() function, meaning Text() and all the *V() functions can also benefit from it. (#3466) Amend 645a6e0 and 23a785a. --- docs/CHANGELOG.txt | 1 + imgui.cpp | 30 ++++++++++++++++++++++++------ imgui_widgets.cpp | 18 ++++-------------- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 6d8fabe0..1e2278b0 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -54,6 +54,7 @@ All changes: - PlotHistogram, PlotLines: Passing negative sizes honor alignment like other widgets. - ImDrawList: Added missing early-out in AddPolyline() and AddConvexPolyFilled() when color alpha is zero. +- Misc: Most text functions treat "%s" as a shortcut to no-formatting. (#3466) - Misc: Tolerate zero delta-time under Emscripten as backends are imprecise in their values for io.DeltaTime, and browser features such as "privacy.resistFingerprinting=true" can exacerbate that. (#6114, #3644) diff --git a/imgui.cpp b/imgui.cpp index d1f34852..29bcd659 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1805,18 +1805,36 @@ void ImFormatStringToTempBuffer(const char** out_buf, const char** out_buf_end, ImGuiContext& g = *GImGui; va_list args; va_start(args, fmt); - int buf_len = ImFormatStringV(g.TempBuffer.Data, g.TempBuffer.Size, fmt, args); - *out_buf = g.TempBuffer.Data; - if (out_buf_end) { *out_buf_end = g.TempBuffer.Data + buf_len; } + if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0) + { + const char* buf = va_arg(args, const char*); // Skip formatting when using "%s" + *out_buf = buf; + if (out_buf_end) { *out_buf_end = buf + strlen(buf); } + } + else + { + int buf_len = ImFormatStringV(g.TempBuffer.Data, g.TempBuffer.Size, fmt, args); + *out_buf = g.TempBuffer.Data; + if (out_buf_end) { *out_buf_end = g.TempBuffer.Data + buf_len; } + } va_end(args); } void ImFormatStringToTempBufferV(const char** out_buf, const char** out_buf_end, const char* fmt, va_list args) { ImGuiContext& g = *GImGui; - int buf_len = ImFormatStringV(g.TempBuffer.Data, g.TempBuffer.Size, fmt, args); - *out_buf = g.TempBuffer.Data; - if (out_buf_end) { *out_buf_end = g.TempBuffer.Data + buf_len; } + if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0) + { + const char* buf = va_arg(args, const char*); // Skip formatting when using "%s" + *out_buf = buf; + if (out_buf_end) { *out_buf_end = buf + strlen(buf); } + } + else + { + int buf_len = ImFormatStringV(g.TempBuffer.Data, g.TempBuffer.Size, fmt, args); + *out_buf = g.TempBuffer.Data; + if (out_buf_end) { *out_buf_end = g.TempBuffer.Data + buf_len; } + } } // CRC32 needs a 1KB lookup table (not cache friendly) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index e6ae647d..4e80c9d0 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -274,7 +274,6 @@ void ImGui::TextV(const char* fmt, va_list args) if (window->SkipItems) return; - // FIXME-OPT: Handle the %s shortcut? const char* text, *text_end; ImFormatStringToTempBufferV(&text, &text_end, fmt, args); TextEx(text, text_end, ImGuiTextFlags_NoWidthForLargeClippedText); @@ -291,10 +290,7 @@ void ImGui::TextColored(const ImVec4& col, const char* fmt, ...) void ImGui::TextColoredV(const ImVec4& col, const char* fmt, va_list args) { PushStyleColor(ImGuiCol_Text, col); - if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0) - TextEx(va_arg(args, const char*), NULL, ImGuiTextFlags_NoWidthForLargeClippedText); // Skip formatting - else - TextV(fmt, args); + TextV(fmt, args); PopStyleColor(); } @@ -310,10 +306,7 @@ void ImGui::TextDisabledV(const char* fmt, va_list args) { ImGuiContext& g = *GImGui; PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]); - if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0) - TextEx(va_arg(args, const char*), NULL, ImGuiTextFlags_NoWidthForLargeClippedText); // Skip formatting - else - TextV(fmt, args); + TextV(fmt, args); PopStyleColor(); } @@ -328,13 +321,10 @@ void ImGui::TextWrapped(const char* fmt, ...) void ImGui::TextWrappedV(const char* fmt, va_list args) { ImGuiContext& g = *GImGui; - bool need_backup = (g.CurrentWindow->DC.TextWrapPos < 0.0f); // Keep existing wrap position if one is already set + const bool need_backup = (g.CurrentWindow->DC.TextWrapPos < 0.0f); // Keep existing wrap position if one is already set if (need_backup) PushTextWrapPos(0.0f); - if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0) - TextEx(va_arg(args, const char*), NULL, ImGuiTextFlags_NoWidthForLargeClippedText); // Skip formatting - else - TextV(fmt, args); + TextV(fmt, args); if (need_backup) PopTextWrapPos(); } From 259560aa26476566801ed46006480b7f1d59c557 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 27 Jan 2023 19:01:30 +0100 Subject: [PATCH 13/20] Demo: moved sections around in prevision for adding nicer separators. --- imgui_demo.cpp | 90 ++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 46 deletions(-) diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 4827e694..b761cb5c 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -610,20 +610,41 @@ static void ShowDemoWindowWidgets() ImGui::SameLine(); ImGui::Text("%d", counter); - ImGui::Separator(); - ImGui::LabelText("label", "Value"); - { - // Using the _simplified_ one-liner Combo() api here - // See "Combo" section for examples of how to use the more flexible BeginCombo()/EndCombo() api. - IMGUI_DEMO_MARKER("Widgets/Basic/Combo"); - const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIIIIII", "JJJJ", "KKKKKKK" }; - static int item_current = 0; - ImGui::Combo("combo", &item_current, items, IM_ARRAYSIZE(items)); - ImGui::SameLine(); HelpMarker( - "Using the simplified one-liner Combo API here.\nRefer to the \"Combo\" section below for an explanation of how to use the more flexible and general BeginCombo/EndCombo API."); + // Tooltips + IMGUI_DEMO_MARKER("Widgets/Basic/Tooltips"); + //ImGui::AlignTextToFramePadding(); + ImGui::Text("Tooltips:"); + + ImGui::SameLine(); + ImGui::SmallButton("Button"); + if (ImGui::IsItemHovered()) + ImGui::SetTooltip("I am a tooltip"); + + ImGui::SameLine(); + ImGui::SmallButton("Fancy"); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("I am a fancy tooltip"); + static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f }; + ImGui::PlotLines("Curve", arr, IM_ARRAYSIZE(arr)); + ImGui::Text("Sin(time) = %f", sinf((float)ImGui::GetTime())); + ImGui::EndTooltip(); + } + + ImGui::SameLine(); + ImGui::SmallButton("Delayed"); + if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal)) // With a delay + ImGui::SetTooltip("I am a tooltip with a delay."); + + ImGui::SameLine(); + HelpMarker( + "Tooltip are created by using the IsItemHovered() function over any kind of item."); } + ImGui::LabelText("label", "Value"); + { // To wire InputText() with std::string or any other custom string type, // see the "Text Input > Resize Callback" section of this demo, and the misc/cpp/imgui_stdlib.h file. @@ -722,6 +743,17 @@ static void ShowDemoWindowWidgets() ImGui::ColorEdit4("color 2", col2); } + { + // Using the _simplified_ one-liner Combo() api here + // See "Combo" section for examples of how to use the more flexible BeginCombo()/EndCombo() api. + IMGUI_DEMO_MARKER("Widgets/Basic/Combo"); + const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIIIIII", "JJJJ", "KKKKKKK" }; + static int item_current = 0; + ImGui::Combo("combo", &item_current, items, IM_ARRAYSIZE(items)); + ImGui::SameLine(); HelpMarker( + "Using the simplified one-liner Combo API here.\nRefer to the \"Combo\" section below for an explanation of how to use the more flexible and general BeginCombo/EndCombo API."); + } + { // Using the _simplified_ one-liner ListBox() api here // See "List boxes" section for examples of how to use the more flexible BeginListBox()/EndListBox() api. @@ -733,40 +765,6 @@ static void ShowDemoWindowWidgets() "Using the simplified one-liner ListBox API here.\nRefer to the \"List boxes\" section below for an explanation of how to use the more flexible and general BeginListBox/EndListBox API."); } - { - // Tooltips - IMGUI_DEMO_MARKER("Widgets/Basic/Tooltips"); - ImGui::AlignTextToFramePadding(); - ImGui::Text("Tooltips:"); - - ImGui::SameLine(); - ImGui::Button("Button"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("I am a tooltip"); - - ImGui::SameLine(); - ImGui::Button("Fancy"); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("I am a fancy tooltip"); - static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f }; - ImGui::PlotLines("Curve", arr, IM_ARRAYSIZE(arr)); - ImGui::Text("Sin(time) = %f", sinf((float)ImGui::GetTime())); - ImGui::EndTooltip(); - } - - ImGui::SameLine(); - ImGui::Button("Delayed"); - if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal)) // Delay best used on items that highlight on hover, so this not a great example! - ImGui::SetTooltip("I am a tooltip with a delay."); - - ImGui::SameLine(); - HelpMarker( - "Tooltip are created by using the IsItemHovered() function over any kind of item."); - - } - ImGui::TreePop(); } @@ -6165,7 +6163,6 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref) ImGui::SliderFloat("PopupRounding", &style.PopupRounding, 0.0f, 12.0f, "%.0f"); ImGui::SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f"); ImGui::SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f"); ImGui::SliderFloat("TabRounding", &style.TabRounding, 0.0f, 12.0f, "%.0f"); ImGui::Text("Alignment"); ImGui::SliderFloat2("WindowTitleAlign", (float*)&style.WindowTitleAlign, 0.0f, 1.0f, "%.2f"); @@ -6180,6 +6177,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref) ImGui::Text("Safe Area Padding"); ImGui::SameLine(); HelpMarker("Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured)."); ImGui::SliderFloat2("DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f"); + ImGui::SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f"); ImGui::EndTabItem(); } From f142887088c9e94f17aa5a5b263b30add5d6a10a Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 31 Jan 2023 11:23:24 +0100 Subject: [PATCH 14/20] Combo: Allow SetNextWindowSize() to alter combo popup size. (#6130) Amend a5e939214 --- docs/CHANGELOG.txt | 1 + imgui_widgets.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 1e2278b0..31f1fee6 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -52,6 +52,7 @@ All changes: - 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] - PlotHistogram, PlotLines: Passing negative sizes honor alignment like other widgets. +- Combo: Allow SetNextWindowSize() to alter combo popup size. (#6130) - ImDrawList: Added missing early-out in AddPolyline() and AddConvexPolyFilled() when color alpha is zero. - Misc: Most text functions treat "%s" as a shortcut to no-formatting. (#3466) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 4e80c9d0..9fcf9718 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1695,7 +1695,12 @@ bool ImGui::BeginComboPopup(ImGuiID popup_id, const ImRect& bb, ImGuiComboFlags if (flags & ImGuiComboFlags_HeightRegular) popup_max_height_in_items = 8; else if (flags & ImGuiComboFlags_HeightSmall) popup_max_height_in_items = 4; else if (flags & ImGuiComboFlags_HeightLarge) popup_max_height_in_items = 20; - SetNextWindowSizeConstraints(ImVec2(w, 0.0f), ImVec2(FLT_MAX, CalcMaxPopupHeightFromItemCount(popup_max_height_in_items))); + ImVec2 constraint_min(0.0f, 0.0f), constraint_max(FLT_MAX, FLT_MAX); + if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize) == 0 || g.NextWindowData.SizeVal.x <= 0.0f) // Don't apply constraints if user specified a size + constraint_min.x = w; + if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize) == 0 || g.NextWindowData.SizeVal.y <= 0.0f) + constraint_max.y = CalcMaxPopupHeightFromItemCount(popup_max_height_in_items); + SetNextWindowSizeConstraints(constraint_min, constraint_max); } // This is essentially a specialized version of BeginPopupEx() From d71977646032cf22a75ff22c616c03fae70b7062 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 31 Jan 2023 11:30:27 +0100 Subject: [PATCH 15/20] Internals: added 'ImGuiButtonFlags flags' to ImageButtonEx(). (#6126) --- imgui_internal.h | 2 +- imgui_widgets.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imgui_internal.h b/imgui_internal.h index 99c2dc2c..a80840f2 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -3078,7 +3078,7 @@ namespace ImGui IMGUI_API void TextEx(const char* text, const char* text_end = NULL, ImGuiTextFlags flags = 0); IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0); IMGUI_API bool ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags = 0); - IMGUI_API bool ImageButtonEx(ImGuiID id, ImTextureID texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& bg_col, const ImVec4& tint_col); + IMGUI_API bool ImageButtonEx(ImGuiID id, ImTextureID texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& bg_col, const ImVec4& tint_col, ImGuiButtonFlags flags = 0); IMGUI_API void SeparatorEx(ImGuiSeparatorFlags flags); IMGUI_API bool CheckboxFlags(const char* label, ImS64* flags, ImS64 flags_value); IMGUI_API bool CheckboxFlags(const char* label, ImU64* flags, ImU64 flags_value); diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 9fcf9718..285e4fb2 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1032,7 +1032,7 @@ void ImGui::Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& // ImageButton() is flawed as 'id' is always derived from 'texture_id' (see #2464 #1390) // We provide this internal helper to write your own variant while we figure out how to redesign the public ImageButton() API. -bool ImGui::ImageButtonEx(ImGuiID id, ImTextureID texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& bg_col, const ImVec4& tint_col) +bool ImGui::ImageButtonEx(ImGuiID id, ImTextureID texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& bg_col, const ImVec4& tint_col, ImGuiButtonFlags flags) { ImGuiContext& g = *GImGui; ImGuiWindow* window = GetCurrentWindow(); @@ -1046,7 +1046,7 @@ bool ImGui::ImageButtonEx(ImGuiID id, ImTextureID texture_id, const ImVec2& size return false; bool hovered, held; - bool pressed = ButtonBehavior(bb, id, &hovered, &held); + bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags); // Render const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); From 867bdbecb3dbc3d27c807fc7cd744a14d9ed2041 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 31 Jan 2023 14:39:45 +0100 Subject: [PATCH 16/20] Text: fixed issue in RenderText() leading to IM_ASSERT_PARANOID() triggering if enabled. (#6132, #5720, #5919) Amend 3482d4ec, bd96f6e --- imgui.h | 2 +- imgui_draw.cpp | 6 ++---- imgui_internal.h | 10 ++++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/imgui.h b/imgui.h index 4676f397..6eef5766 100644 --- a/imgui.h +++ b/imgui.h @@ -23,7 +23,7 @@ // Library Version // (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_NUM 18924 +#define IMGUI_VERSION_NUM 18925 #define IMGUI_HAS_TABLE /* diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 540dc11a..09db1c6b 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -3573,19 +3573,17 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, Im while (y + line_height < clip_rect.y && s < text_end) { const char* line_end = (const char*)memchr(s, '\n', text_end - s); - if (!line_end) - line_end = text_end; if (word_wrap_enabled) { // FIXME-OPT: This is not optimal as do first do a search for \n before calling CalcWordWrapPositionA(). // If the specs for CalcWordWrapPositionA() were reworked to optionally return on \n we could combine both. // However it is still better than nothing performing the fast-forward! - s = CalcWordWrapPositionA(scale, s, line_end, wrap_width); + s = CalcWordWrapPositionA(scale, s, line_end ? line_end : text_end, wrap_width); s = CalcWordWrapNextLineStartA(s, text_end); } else { - s = line_end + 1; + s = line_end ? line_end + 1 : text_end; } y += line_height; } diff --git a/imgui_internal.h b/imgui_internal.h index a80840f2..56f8a4fd 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1,10 +1,12 @@ // dear imgui, v1.89.3 WIP // (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! -// Set: -// #define IMGUI_DEFINE_MATH_OPERATORS -// To implement maths operators for ImVec2 (disabled by default to not collide with using IM_VEC2_CLASS_EXTRA along with your own math types+operators) +// You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility. +// To implement maths operators for ImVec2 (disabled by default to not conflict with using IM_VEC2_CLASS_EXTRA with your own math types+operators), use: +/* +#define IMGUI_DEFINE_MATH_OPERATORS +#include "imgui_internal.h" +*/ /* From 5a3f82e2f4f30e529f765d38aaa76866653b245a Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 31 Jan 2023 15:49:54 +0100 Subject: [PATCH 17/20] Examples: SDL+SDL_Renderer: Added call to SDL_RenderSetScale() to display is correct on a Retina display (albeit lower-res as our other unmodified examples). (#6121, #6065, #5931). --- docs/CHANGELOG.txt | 2 ++ examples/example_sdl_sdlrenderer/main.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 31f1fee6..4a84eb02 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -64,6 +64,8 @@ All changes: - Examples: Win32: Fixed examples using RegisterClassW() since 1.89 to also call DefWindowProcW() instead of DefWindowProc() so that title text are correctly converted when application is compiled without /DUNICODE. (#5725, #5961, #5975) [@markreidvfx] +- Examples: SDL+SDL_Renderer: Added call to SDL_RenderSetScale() to display is correct on a + Retina display (albeit lower-res as our other unmodified examples). (#6121, #6065, #5931). ----------------------------------------------------------------------- diff --git a/examples/example_sdl_sdlrenderer/main.cpp b/examples/example_sdl_sdlrenderer/main.cpp index 736e7c6f..2ba7ec23 100644 --- a/examples/example_sdl_sdlrenderer/main.cpp +++ b/examples/example_sdl_sdlrenderer/main.cpp @@ -143,6 +143,7 @@ int main(int, char**) // Rendering ImGui::Render(); + SDL_RenderSetScale(renderer, io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y); SDL_SetRenderDrawColor(renderer, (Uint8)(clear_color.x * 255), (Uint8)(clear_color.y * 255), (Uint8)(clear_color.z * 255), (Uint8)(clear_color.w * 255)); SDL_RenderClear(renderer); ImGui_ImplSDLRenderer_RenderDrawData(ImGui::GetDrawData()); From 2efebe331547a31b34ebf4049545df241cd04e50 Mon Sep 17 00:00:00 2001 From: nahkhiir Date: Tue, 31 Jan 2023 18:05:30 +0100 Subject: [PATCH 18/20] ShowFontAtlas, Demo: optionally use style text color for tint. (#6129) --- imgui.cpp | 9 ++++++--- imgui_demo.cpp | 6 ++++-- imgui_internal.h | 27 ++++++++++----------------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 29bcd659..7d230947 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -13168,10 +13168,13 @@ void ImGui::ShowFontAtlas(ImFontAtlas* atlas) DebugNodeFont(font); PopID(); } - if (TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight)) + if (TreeNode("Font Atlas", "Font Atlas (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight)) { - ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); - ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f); + ImGuiContext& g = *GImGui; + ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig; + Checkbox("Tint with Text Color", &cfg->ShowAtlasTintedWithTextColor); // Using text color ensure visibility of core atlas data, but will alter custom colored icons + ImVec4 tint_col = cfg->ShowAtlasTintedWithTextColor ? GetStyleColorVec4(ImGuiCol_Text) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f); + ImVec4 border_col = GetStyleColorVec4(ImGuiCol_Border); Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), tint_col, border_col); TreePop(); } diff --git a/imgui_demo.cpp b/imgui_demo.cpp index b761cb5c..12e94a28 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1024,12 +1024,14 @@ static void ShowDemoWindowWidgets() float my_tex_w = (float)io.Fonts->TexWidth; float my_tex_h = (float)io.Fonts->TexHeight; { + static bool use_text_color_for_tint = false; + ImGui::Checkbox("Use Text Color for Tint", &use_text_color_for_tint); ImGui::Text("%.0fx%.0f", my_tex_w, my_tex_h); ImVec2 pos = ImGui::GetCursorScreenPos(); ImVec2 uv_min = ImVec2(0.0f, 0.0f); // Top-left ImVec2 uv_max = ImVec2(1.0f, 1.0f); // Lower-right - ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint - ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f); // 50% opaque white + ImVec4 tint_col = use_text_color_for_tint ? ImGui::GetStyleColorVec4(ImGuiCol_Text) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint + ImVec4 border_col = ImGui::GetStyleColorVec4(ImGuiCol_Border); ImGui::Image(my_tex_id, ImVec2(my_tex_w, my_tex_h), uv_min, uv_max, tint_col, border_col); if (ImGui::IsItemHovered()) { diff --git a/imgui_internal.h b/imgui_internal.h index 56f8a4fd..571b1598 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1671,23 +1671,16 @@ enum ImGuiDebugLogFlags_ struct ImGuiMetricsConfig { - bool ShowDebugLog; - bool ShowStackTool; - bool ShowWindowsRects; - bool ShowWindowsBeginOrder; - bool ShowTablesRects; - bool ShowDrawCmdMesh; - bool ShowDrawCmdBoundingBoxes; - int ShowWindowsRectsType; - int ShowTablesRectsType; - - ImGuiMetricsConfig() - { - ShowDebugLog = ShowStackTool = ShowWindowsRects = ShowWindowsBeginOrder = ShowTablesRects = false; - ShowDrawCmdMesh = true; - ShowDrawCmdBoundingBoxes = true; - ShowWindowsRectsType = ShowTablesRectsType = -1; - } + bool ShowDebugLog = false; + bool ShowStackTool = false; + bool ShowWindowsRects = false; + bool ShowWindowsBeginOrder = false; + bool ShowTablesRects = false; + bool ShowDrawCmdMesh = true; + bool ShowDrawCmdBoundingBoxes = true; + bool ShowAtlasTintedWithTextColor = false; + int ShowWindowsRectsType = -1; + int ShowTablesRectsType = -1; }; struct ImGuiStackLevelInfo From 8d29665ae1dcb73772e2c90404d638700a643795 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 1 Feb 2023 19:42:22 +0100 Subject: [PATCH 19/20] Backends: OSX: Fixed scroll wheel scaling for devices emitting events with hasPreciseScrollingDeltas==false (e.g. non-Apple mices). Ref #4019 for details provided in .XLS sheet, although not strictly related to main issue topic. + Rename Emscripten demo titles to make SDL visible. --- backends/imgui_impl_glut.cpp | 1 + backends/imgui_impl_glut.h | 1 + backends/imgui_impl_osx.mm | 11 ++++++----- docs/CHANGELOG.txt | 2 ++ examples/example_emscripten_opengl3/Makefile | 2 +- examples/example_emscripten_opengl3/main.cpp | 2 +- .../example_emscripten_opengl3/shell_minimal.html | 2 +- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/backends/imgui_impl_glut.cpp b/backends/imgui_impl_glut.cpp index 7a9a32a6..4734e492 100644 --- a/backends/imgui_impl_glut.cpp +++ b/backends/imgui_impl_glut.cpp @@ -9,6 +9,7 @@ // [X] Platform: Partial keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLUT values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] // Issues: // [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I +// [ ] Platform: Missing horizontal mouse wheel support. // [ ] Platform: Missing mouse cursor shape/visibility support. // [ ] Platform: Missing clipboard support (not supported by Glut). // [ ] Platform: Missing gamepad support. diff --git a/backends/imgui_impl_glut.h b/backends/imgui_impl_glut.h index 98d4e598..545cd8dd 100644 --- a/backends/imgui_impl_glut.h +++ b/backends/imgui_impl_glut.h @@ -9,6 +9,7 @@ // [X] Platform: Partial keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLUT values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] // Issues: // [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I +// [ ] Platform: Missing horizontal mouse wheel support. // [ ] Platform: Missing mouse cursor shape/visibility support. // [ ] Platform: Missing clipboard support (not supported by Glut). // [ ] Platform: Missing gamepad support. diff --git a/backends/imgui_impl_osx.mm b/backends/imgui_impl_osx.mm index aa65d713..6b34b39a 100644 --- a/backends/imgui_impl_osx.mm +++ b/backends/imgui_impl_osx.mm @@ -24,6 +24,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2023-02-01: Fixed scroll wheel scaling for devices emitting events with hasPreciseScrollingDeltas==false (e.g. non-Apple mices). // 2022-11-02: Fixed mouse coordinates before clicking the host window. // 2022-10-06: Fixed mouse inputs on flipped views. // 2022-09-26: Inputs: Renamed ImGuiKey_ModXXX introduced in 1.87 to ImGuiMod_XXX (old names still supported). @@ -671,18 +672,18 @@ static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view) wheel_dy = [event scrollingDeltaY]; if ([event hasPreciseScrollingDeltas]) { - wheel_dx *= 0.1; - wheel_dy *= 0.1; + wheel_dx *= 0.01; + wheel_dy *= 0.01; } } else #endif // MAC_OS_X_VERSION_MAX_ALLOWED { - wheel_dx = [event deltaX]; - wheel_dy = [event deltaY]; + wheel_dx = [event deltaX] * 0.1; + wheel_dy = [event deltaY] * 0.1; } if (wheel_dx != 0.0 || wheel_dy != 0.0) - io.AddMouseWheelEvent((float)wheel_dx * 0.1f, (float)wheel_dy * 0.1f); + io.AddMouseWheelEvent((float)wheel_dx, (float)wheel_dy); return io.WantCaptureMouse; } diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 4a84eb02..13f918af 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -59,6 +59,8 @@ All changes: - Misc: Tolerate zero delta-time under Emscripten as backends are imprecise in their values for io.DeltaTime, and browser features such as "privacy.resistFingerprinting=true" can exacerbate that. (#6114, #3644) +- Backends: OSX: Fixed scroll/wheel scaling for devices emitting events with + hasPreciseScrollingDeltas==false (e.g. non-Apple mices). - Backend: WebGPU: Fix building for latest WebGPU specs (remove implicit layout generation). (#6117, #4116, #3632) [@tonygrue, @bfierz] - Examples: Win32: Fixed examples using RegisterClassW() since 1.89 to also call diff --git a/examples/example_emscripten_opengl3/Makefile b/examples/example_emscripten_opengl3/Makefile index b2933e10..db8e582f 100644 --- a/examples/example_emscripten_opengl3/Makefile +++ b/examples/example_emscripten_opengl3/Makefile @@ -1,5 +1,5 @@ # -# Makefile to use with emscripten +# Makefile to use with SDL+emscripten # See https://emscripten.org/docs/getting_started/downloads.html # for installation instructions. # diff --git a/examples/example_emscripten_opengl3/main.cpp b/examples/example_emscripten_opengl3/main.cpp index a0a8d70c..5e31d895 100644 --- a/examples/example_emscripten_opengl3/main.cpp +++ b/examples/example_emscripten_opengl3/main.cpp @@ -49,7 +49,7 @@ int main(int, char**) SDL_DisplayMode current; SDL_GetCurrentDisplayMode(0, ¤t); SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); - g_Window = SDL_CreateWindow("Dear ImGui Emscripten example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags); + g_Window = SDL_CreateWindow("Dear ImGui SDL+Emscripten example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags); g_GLContext = SDL_GL_CreateContext(g_Window); if (!g_GLContext) { diff --git a/examples/example_emscripten_opengl3/shell_minimal.html b/examples/example_emscripten_opengl3/shell_minimal.html index 514385d7..6cb61bd7 100644 --- a/examples/example_emscripten_opengl3/shell_minimal.html +++ b/examples/example_emscripten_opengl3/shell_minimal.html @@ -3,7 +3,7 @@ - Dear ImGui Emscripten example + Dear ImGui SDL+Emscripten example + + + + + {{{ SCRIPT }}} + + diff --git a/imgui.cpp b/imgui.cpp index 7d230947..b729f66d 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1467,7 +1467,7 @@ void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down) g.InputEventsQueue.push_back(e); } -// Queue a mouse wheel event (most mouse/API will only have a Y component) +// Queue a mouse wheel event (some mouse/API may only have a Y component) void ImGuiIO::AddMouseWheelEvent(float wheel_x, float wheel_y) { ImGuiContext& g = *GImGui; @@ -8488,7 +8488,8 @@ void ImGui::UpdateMouseWheel() // Mouse wheel scrolling // As a standard behavior holding SHIFT while using Vertical Mouse Wheel triggers Horizontal scroll instead - // (we avoid doing it on OSX as it the OS input layer handles this already) + // - We avoid doing it on OSX as it the OS input layer handles this already. + // - However this means when running on OSX over Emcripten, Shift+WheelY will incur two swappings (1 in OS, 1 here), cancelling the feature. const bool swap_axis = g.IO.KeyShift && !g.IO.ConfigMacOSXBehaviors; if (swap_axis) { diff --git a/imgui.h b/imgui.h index 6eef5766..39879eea 100644 --- a/imgui.h +++ b/imgui.h @@ -23,7 +23,7 @@ // Library Version // (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_NUM 18925 +#define IMGUI_VERSION_NUM 18926 #define IMGUI_HAS_TABLE /* @@ -1968,7 +1968,7 @@ struct ImGuiIO IMGUI_API void AddKeyAnalogEvent(ImGuiKey key, bool down, float v); // Queue a new key down/up event for analog values (e.g. ImGuiKey_Gamepad_ values). Dead-zones should be handled by the backend. IMGUI_API void AddMousePosEvent(float x, float y); // Queue a mouse position update. Use -FLT_MAX,-FLT_MAX to signify no mouse (e.g. app not focused and not hovered) IMGUI_API void AddMouseButtonEvent(int button, bool down); // Queue a mouse button change - IMGUI_API void AddMouseWheelEvent(float wh_x, float wh_y); // Queue a mouse wheel update + IMGUI_API void AddMouseWheelEvent(float wheel_x, float wheel_y); // Queue a mouse wheel update. wheel_y<0: scroll down, wheel_y>0: scroll up, wheel_x<0: scroll right, wheel_x>0: scroll left. IMGUI_API void AddFocusEvent(bool focused); // Queue a gain/loss of focus for the application (generally based on OS/platform focus of your window) IMGUI_API void AddInputCharacter(unsigned int c); // Queue a new character input IMGUI_API void AddInputCharacterUTF16(ImWchar16 c); // Queue a new character input from a UTF-16 character, it can be a surrogate @@ -2018,8 +2018,8 @@ struct ImGuiIO // (reading from those variables is fair game, as they are extremely unlikely to be moving anywhere) ImVec2 MousePos; // Mouse position, in pixels. Set to ImVec2(-FLT_MAX, -FLT_MAX) if mouse is unavailable (on another screen, etc.) bool MouseDown[5]; // Mouse buttons: 0=left, 1=right, 2=middle + extras (ImGuiMouseButton_COUNT == 5). Dear ImGui mostly uses left and right buttons. Other buttons allow us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API. - float MouseWheel; // Mouse wheel Vertical: 1 unit scrolls about 5 lines text. - float MouseWheelH; // Mouse wheel Horizontal. Most users don't have a mouse with a horizontal wheel, may not be filled by all backends. + float MouseWheel; // Mouse wheel Vertical: 1 unit scrolls about 5 lines text. >0 scrolls Up, <0 scrolls Down. Hold SHIFT to turn vertical scroll into horizontal scroll. + float MouseWheelH; // Mouse wheel Horizontal. >0 scrolls Left, <0 scrolls Right. Most users don't have a mouse with a horizontal wheel, may not be filled by all backends. bool KeyCtrl; // Keyboard modifier down: Control bool KeyShift; // Keyboard modifier down: Shift bool KeyAlt; // Keyboard modifier down: Alt diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 12e94a28..a9bc1bb6 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -457,6 +457,7 @@ void ImGui::ShowDemoWindow(bool* p_open) ImGui::Checkbox("io.ConfigWindowsResizeFromEdges", &io.ConfigWindowsResizeFromEdges); ImGui::SameLine(); HelpMarker("Enable resizing of windows from their edges and from the lower-left corner.\nThis requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback."); ImGui::Checkbox("io.ConfigWindowsMoveFromTitleBarOnly", &io.ConfigWindowsMoveFromTitleBarOnly); + ImGui::Checkbox("io.ConfigMacOSXBehaviors", &io.ConfigMacOSXBehaviors); ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor); ImGui::SameLine(); HelpMarker("Instruct Dear ImGui to render a mouse cursor itself. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something)."); ImGui::Text("Also see Style->Rendering for rendering options.");