From ce19cb465f7b509b9bde9347cc1094bfabfae1e7 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 2 May 2019 16:29:40 +0200 Subject: [PATCH 1/9] Internals: Rename GetContentRegionMaxScreen() -> GetWorkRectMax(). At this point this is mostly useful to facilitate merge of other branches. --- imgui.cpp | 10 +++++----- imgui_internal.h | 2 +- imgui_widgets.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index e5448882..96f2caec 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2983,7 +2983,7 @@ float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x) ImGuiWindow* window = GImGui->CurrentWindow; if (wrap_pos_x == 0.0f) - wrap_pos_x = GetContentRegionMaxScreen().x; + wrap_pos_x = GetWorkRectMax().x; else if (wrap_pos_x > 0.0f) wrap_pos_x += window->Pos.x - window->Scroll.x; // wrap_pos_x is provided is window local space @@ -5808,7 +5808,7 @@ float ImGui::GetNextItemWidth() } if (w < 0.0f) { - float region_max_x = GetContentRegionMaxScreen().x; + float region_max_x = GetWorkRectMax().x; w = ImMax(1.0f, region_max_x - window->DC.CursorPos.x + w); } w = (float)(int)w; @@ -5836,7 +5836,7 @@ ImVec2 ImGui::CalcItemSize(ImVec2 size, float default_w, float default_h) ImVec2 region_max; if (size.x < 0.0f || size.y < 0.0f) - region_max = GetContentRegionMaxScreen(); + region_max = GetWorkRectMax(); if (size.x == 0.0f) size.x = default_w; @@ -6424,7 +6424,7 @@ ImVec2 ImGui::GetContentRegionMax() } // [Internal] Absolute coordinate. Saner. This is not exposed until we finishing refactoring work rect features. -ImVec2 ImGui::GetContentRegionMaxScreen() +ImVec2 ImGui::GetWorkRectMax() { ImGuiWindow* window = GImGui->CurrentWindow; ImVec2 mx = window->ContentsRegionRect.Max; @@ -6436,7 +6436,7 @@ ImVec2 ImGui::GetContentRegionMaxScreen() ImVec2 ImGui::GetContentRegionAvail() { ImGuiWindow* window = GImGui->CurrentWindow; - return GetContentRegionMaxScreen() - window->DC.CursorPos; + return GetWorkRectMax() - window->DC.CursorPos; } // In window space (not screen space!) diff --git a/imgui_internal.h b/imgui_internal.h index 23b95257..0aacd0fd 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1458,7 +1458,7 @@ namespace ImGui IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled); IMGUI_API void PopItemFlag(); IMGUI_API bool IsItemToggledSelection(); // was the last item selection toggled? (after Selectable(), TreeNode() etc. We only returns toggle _event_ in order to handle clipping correctly) - IMGUI_API ImVec2 GetContentRegionMaxScreen(); + IMGUI_API ImVec2 GetWorkRectMax(); // Logging/Capture IMGUI_API void LogBegin(ImGuiLogType type, int auto_open_depth); // -> BeginCapture() when we design v2 api, for now stay under the radar by using the old name. diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 874b038a..894da543 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -5044,7 +5044,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l // We vertically grow up to current line height up the typical widget height. const float text_base_offset_y = ImMax(padding.y, window->DC.CurrentLineTextBaseOffset); // Latch before ItemSize changes it const float frame_height = ImMax(ImMin(window->DC.CurrentLineSize.y, g.FontSize + style.FramePadding.y*2), label_size.y + padding.y*2); - ImRect frame_bb = ImRect(window->DC.CursorPos, ImVec2(GetContentRegionMaxScreen().x, window->DC.CursorPos.y + frame_height)); + ImRect frame_bb = ImRect(window->DC.CursorPos, ImVec2(GetWorkRectMax().x, window->DC.CursorPos.y + frame_height)); if (display_frame) { // Framed header expand a little outside the default padding From 86f92fe75605021a7440d72131a6aa7e27ca13a9 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 2 May 2019 20:19:53 +0200 Subject: [PATCH 2/9] Demo: Improved trees in columns demo. (#2136) --- docs/CHANGELOG.txt | 1 + imgui_demo.cpp | 39 +++++++++++++++++++++++++++++++-------- imgui_internal.h | 2 +- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 86fd1a90..d808f4c2 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -89,6 +89,7 @@ Other Changes: - Misc: Added IM_MALLOC/IM_FREE macros mimicking IM_NEW/IM_DELETE so user doesn't need to revert to using the ImGui::MemAlloc()/MemFree() calls directly. - Metrics: Added "Show windows rectangles" tool to visualize the different rectangles. +- Demo: Improved trees in columns demo. - Examples: OpenGL: Added a dummy GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized GL function loaders early, and help users understand what they are missing. (#2421) - Examples: Emscripten: Added Emscripten+SDL+GLES2 example. (#2494, #2492, #2351, #336) [@nicolasnoble, @redblobgames] diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 75f690ce..0d9c50a1 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -2545,16 +2545,39 @@ static void ShowDemoWindowColumns() ImGui::TreePop(); } - bool node_open = ImGui::TreeNode("Tree within single cell"); - ImGui::SameLine(); HelpMarker("NB: Tree node must be poped before ending the cell. There's no storage of state per-cell."); - if (node_open) + if (ImGui::TreeNode("Tree")) { - ImGui::Columns(2, "tree items"); - ImGui::Separator(); - if (ImGui::TreeNode("Hello")) { ImGui::BulletText("Sailor"); ImGui::TreePop(); } ImGui::NextColumn(); - if (ImGui::TreeNode("Bonjour")) { ImGui::BulletText("Marin"); ImGui::TreePop(); } ImGui::NextColumn(); + ImGui::Columns(2, "tree", true); + for (int x = 0; x < 3; x++) + { + bool open1 = ImGui::TreeNode((void*)(intptr_t)x, "Node%d", x); + ImGui::NextColumn(); + ImGui::Text("Node contents"); + ImGui::NextColumn(); + if (open1) + { + for (int y = 0; y < 5; y++) + { + bool open2 = ImGui::TreeNode((void*)(intptr_t)y, "Node%d.%d", x, y); + ImGui::NextColumn(); + ImGui::Text("Node contents"); + if (open2) + { + ImGui::Text("Even more contents"); + if (ImGui::TreeNode("Tree in column")) + { + ImGui::Text("The quick brown fox jumps over the lazy dog"); + ImGui::TreePop(); + } + } + ImGui::NextColumn(); + if (open2) + ImGui::TreePop(); + } + ImGui::TreePop(); + } + } ImGui::Columns(1); - ImGui::Separator(); ImGui::TreePop(); } diff --git a/imgui_internal.h b/imgui_internal.h index 0aacd0fd..4130ab8a 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -346,7 +346,7 @@ enum ImGuiSelectableFlagsPrivate_ ImGuiSelectableFlags_NoHoldingActiveID = 1 << 10, ImGuiSelectableFlags_PressedOnClick = 1 << 11, ImGuiSelectableFlags_PressedOnRelease = 1 << 12, - ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 13, + ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 13, // FIXME: We may be able to remove this (added in 6251d379 for menus) ImGuiSelectableFlags_AllowItemOverlap = 1 << 14 }; From 2dc81057ec4e5fbd97d06044967550b5c41b5387 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 3 May 2019 14:28:57 +0200 Subject: [PATCH 3/9] Selectable: With ImGuiSelectableFlags_AllowDoubleClick doesn't return true on the mouse button releas efollowing the double-click. Only first mouse release + second mouse down (double-click) returns true. Likewise for internal ButtonBehavior() with both _PressedOnClickRelease | _PressedOnDoubleClick. (#2503) --- docs/CHANGELOG.txt | 3 +++ imgui.cpp | 3 +++ imgui.h | 3 ++- imgui_widgets.cpp | 15 +++++++++++---- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index d808f4c2..045df875 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -74,6 +74,9 @@ Other Changes: clear the focus again. - Popups: Fixed right-click from closing all popups instead of aiming at the hovered popup level (regression in 1.67). +- Selectable: With ImGuiSelectableFlags_AllowDoubleClick doesn't return true on the mouse button release + following the double-click. Only first mouse release + second mouse down (double-click) returns true. + Likewise for internal ButtonBehavior() with both _PressedOnClickRelease | _PressedOnDoubleClick. (#2503) - GetMouseDragDelta(): also returns the delta on the mouse button released frame. (#2419) - GetMouseDragDelta(): verify that mouse positions are valid otherwise returns zero. - Inputs: Also add support for horizontal scroll with Shift+Mouse Wheel. (#2424, #1463) [@LucaRood] diff --git a/imgui.cpp b/imgui.cpp index 96f2caec..43afd235 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3282,6 +3282,7 @@ static void ImGui::UpdateMouseInputs() g.IO.MouseClickedTime[i] = g.Time; } g.IO.MouseClickedPos[i] = g.IO.MousePos; + g.IO.MouseDownWasDoubleClick[i] = g.IO.MouseDoubleClicked[i]; g.IO.MouseDragMaxDistanceAbs[i] = ImVec2(0.0f, 0.0f); g.IO.MouseDragMaxDistanceSqr[i] = 0.0f; } @@ -3293,6 +3294,8 @@ static void ImGui::UpdateMouseInputs() g.IO.MouseDragMaxDistanceAbs[i].x = ImMax(g.IO.MouseDragMaxDistanceAbs[i].x, delta_from_click_pos.x < 0.0f ? -delta_from_click_pos.x : delta_from_click_pos.x); g.IO.MouseDragMaxDistanceAbs[i].y = ImMax(g.IO.MouseDragMaxDistanceAbs[i].y, delta_from_click_pos.y < 0.0f ? -delta_from_click_pos.y : delta_from_click_pos.y); } + if (!g.IO.MouseDown[i] && !g.IO.MouseReleased[i]) + g.IO.MouseDownWasDoubleClick[i] = false; if (g.IO.MouseClicked[i]) // Clicking any mouse button reactivate mouse hovering which may have been deactivated by gamepad/keyboard navigation g.NavDisableMouseHover = false; } diff --git a/imgui.h b/imgui.h index f2c44e69..78e4c3d6 100644 --- a/imgui.h +++ b/imgui.h @@ -1435,7 +1435,8 @@ struct ImGuiIO bool MouseClicked[5]; // Mouse button went from !Down to Down bool MouseDoubleClicked[5]; // Has mouse button been double-clicked? bool MouseReleased[5]; // Mouse button went from Down to !Down - bool MouseDownOwned[5]; // Track if button was clicked inside a window. We don't request mouse capture from the application if click started outside ImGui bounds. + bool MouseDownOwned[5]; // Track if button was clicked inside an imgui window. We don't request mouse capture from the application if click started outside ImGui bounds. + bool MouseDownWasDoubleClick[5]; // Track if button down was a double-click float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked) float MouseDownDurationPrev[5]; // Previous time the mouse button has been down ImVec2 MouseDragMaxDistanceAbs[5]; // Maximum distance, absolute, on each axis, of how much mouse has traveled from the clicking point diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 894da543..f146920d 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -429,6 +429,10 @@ void ImGui::BulletTextV(const char* fmt, va_list args) // Frame N+6 (mouse button is released) - true - - true - // Frame N+7 (mouse button is released) - true - - - - //------------------------------------------------------------------------------------------------------------------------------------------------ +// Note that some combinations are supported, +// - PressedOnDragDropHold can generally be associated with any flag. +// - PressedOnDoubleClick can be associated by PressedOnClickRelease/PressedOnRelease, in which case the second release event won't be reported. +//------------------------------------------------------------------------------------------------------------------------------------------------ // The behavior of the return-value changes when ImGuiButtonFlags_Repeat is set: // Repeat+ Repeat+ Repeat+ Repeat+ // PressedOnClickRelease PressedOnClick PressedOnRelease PressedOnDoubleClick @@ -569,10 +573,13 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool } else { - if (hovered && (flags & ImGuiButtonFlags_PressedOnClickRelease)) - if (!((flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[0] >= g.IO.KeyRepeatDelay)) // Repeat mode trumps - if (!g.DragDropActive) - pressed = true; + if (hovered && (flags & ImGuiButtonFlags_PressedOnClickRelease) && !g.DragDropActive) + { + bool is_double_click_release = (flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDownWasDoubleClick[0]; + bool is_repeating_already = (flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[0] >= g.IO.KeyRepeatDelay; // Repeat mode trumps + if (!is_double_click_release && !is_repeating_already) + pressed = true; + } ClearActiveID(); } if (!(flags & ImGuiButtonFlags_NoNavFocus)) From e2166db282140867d96f24326897a2b04d99ed14 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 3 May 2019 15:06:06 +0200 Subject: [PATCH 4/9] Internals: Fixed incorrect repeat delay/rate calculation in IsMouseClicked() with repeat flag leading to involontary but thankfully doubling the rate. Using our standard function, making the multiplicator explicit. --- imgui.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 43afd235..361fa076 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4195,8 +4195,9 @@ bool ImGui::IsMouseClicked(int button, bool repeat) if (repeat && t > g.IO.KeyRepeatDelay) { - float delay = g.IO.KeyRepeatDelay, rate = g.IO.KeyRepeatRate; - if ((ImFmod(t - delay, rate) > rate*0.5f) != (ImFmod(t - delay - g.IO.DeltaTime, rate) > rate*0.5f)) + // FIXME: 2019/05/03: Our old repeat code was wrong here and led to doubling the repeat rate, which made it an ok rate for repeat on mouse hold. + int amount = CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, g.IO.KeyRepeatDelay, g.IO.KeyRepeatRate * 0.5f); + if (amount > 0) return true; } From 9c1f02a42c402cd18af10fbc73985f5237d3f9da Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 3 May 2019 18:40:36 +0200 Subject: [PATCH 5/9] Misc: Made IMGUI_CHECKVERSION() macro also check for matching size of ImDrawIdx. --- docs/CHANGELOG.txt | 1 + imgui.cpp | 10 +++++++--- imgui.h | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 045df875..8b26cab7 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -91,6 +91,7 @@ Other Changes: angles, also faster to output. (#2518) [@rmitton] - Misc: Added IM_MALLOC/IM_FREE macros mimicking IM_NEW/IM_DELETE so user doesn't need to revert to using the ImGui::MemAlloc()/MemFree() calls directly. +- Misc: Made IMGUI_CHECKVERSION() macro also check for matching size of ImDrawIdx. - Metrics: Added "Show windows rectangles" tool to visualize the different rectangles. - Demo: Improved trees in columns demo. - Examples: OpenGL: Added a dummy GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized diff --git a/imgui.cpp b/imgui.cpp index 361fa076..19c0906b 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3039,9 +3039,12 @@ void ImGui::SetCurrentContext(ImGuiContext* ctx) #endif } -// Helper function to verify that the type sizes are matching between the calling file's compilation unit and imgui.cpp's compilation unit -// If the user has inconsistent compilation settings, imgui configuration #define, packing pragma, etc. you may see different structures from what imgui.cpp sees which is highly problematic. -bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_vert) +// Helper function to verify ABI compatibility between caller code and compiled version of Dear ImGui. +// Verify that the type sizes are matching between the calling file's compilation unit and imgui.cpp's compilation unit +// If the user has inconsistent compilation settings, imgui configuration #define, packing pragma, etc. your user code +// may see different structures thanwhat imgui.cpp sees, which is problematic. +// We usually require settings to be in imconfig.h to make sure that they are accessible to all compilation units involved with Dear ImGui. +bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_vert, size_t sz_idx) { bool error = false; if (strcmp(version, IMGUI_VERSION)!=0) { error = true; IM_ASSERT(strcmp(version,IMGUI_VERSION)==0 && "Mismatched version string!"); } @@ -3050,6 +3053,7 @@ bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, si if (sz_vec2 != sizeof(ImVec2)) { error = true; IM_ASSERT(sz_vec2 == sizeof(ImVec2) && "Mismatched struct layout!"); } if (sz_vec4 != sizeof(ImVec4)) { error = true; IM_ASSERT(sz_vec4 == sizeof(ImVec4) && "Mismatched struct layout!"); } if (sz_vert != sizeof(ImDrawVert)) { error = true; IM_ASSERT(sz_vert == sizeof(ImDrawVert) && "Mismatched struct layout!"); } + if (sz_idx != sizeof(ImDrawIdx)) { error = true; IM_ASSERT(sz_idx == sizeof(ImDrawIdx) && "Mismatched struct layout!"); } return !error; } diff --git a/imgui.h b/imgui.h index 78e4c3d6..17d9d4c3 100644 --- a/imgui.h +++ b/imgui.h @@ -48,7 +48,7 @@ Index of this file: // (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.70 WIP" #define IMGUI_VERSION_NUM 16991 -#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert)) +#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) // IMGUI_API is used for core imgui functions, IMGUI_IMPL_API is used for the default bindings files (imgui_impl_xxx.h) @@ -207,7 +207,7 @@ namespace ImGui IMGUI_API void DestroyContext(ImGuiContext* ctx = NULL); // NULL = destroy current context IMGUI_API ImGuiContext* GetCurrentContext(); IMGUI_API void SetCurrentContext(ImGuiContext* ctx); - IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert); + IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert, size_t sz_drawidx); // Main IMGUI_API ImGuiIO& GetIO(); // access the IO structure (mouse/keyboard/gamepad inputs, time, various configuration options/flags) From 526e2303bc1bfec7ca98e1328c15ce835cb47bc5 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 3 May 2019 19:09:44 +0200 Subject: [PATCH 6/9] Window: Fixed SetNextWindowSizeConstraints() with non-rounded positions making windows drift. (#2067, #2530) --- docs/CHANGELOG.txt | 1 + imgui.cpp | 2 ++ imgui.h | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 8b26cab7..514c5d3c 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -68,6 +68,7 @@ Other Changes: highlight from parent menu items earlier than necessary while approaching the child menu. - Window: Close button is horizontally aligned with style.FramePadding.x. - Window: Fixed contents region being off by WindowBorderSize amount on the right when scrollbar is active. +- Window: Fixed SetNextWindowSizeConstraints() with non-rounded positions making windows drift. (#2067, 2530) - Popups: Closing a popup restores the focused/nav window in place at the time of the popup opening, instead of restoring the window that was in the window stack at the time of the OpenPopup call. (#2517) Among other things, this allows opening a popup while no window are focused, and pressing Escape to diff --git a/imgui.cpp b/imgui.cpp index 19c0906b..68ac63ac 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4648,6 +4648,8 @@ static ImVec2 CalcSizeAfterConstraint(ImGuiWindow* window, ImVec2 new_size) g.NextWindowData.SizeCallback(&data); new_size = data.DesiredSize; } + new_size.x = ImFloor(new_size.x); + new_size.y = ImFloor(new_size.y); } // Minimum size diff --git a/imgui.h b/imgui.h index 17d9d4c3..774c1b51 100644 --- a/imgui.h +++ b/imgui.h @@ -269,7 +269,7 @@ namespace ImGui // Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after Begin). IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0, const ImVec2& pivot = ImVec2(0,0)); // set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc. IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin() - IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Use callback to apply non-trivial programmatic constraints. + IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Sizes will be rounded down. Use callback to apply non-trivial programmatic constraints. IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (~ enforce the range of scrollbars). not including window decorations (title bar, menu bar, etc.). set an axis to 0.0f to leave it automatic. call before Begin() IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // set next window collapsed state. call before Begin() IMGUI_API void SetNextWindowFocus(); // set next window to be focused / front-most. call before Begin() From 5ecc9d58654c73bef446be2fead03cfbcb13d728 Mon Sep 17 00:00:00 2001 From: Max Thrun Date: Wed, 1 May 2019 18:31:42 -0700 Subject: [PATCH 7/9] Examples: Metal: Add GLFW+Metal example --- examples/example_glfw_metal/Makefile | 44 +++++++ examples/example_glfw_metal/main.mm | 166 +++++++++++++++++++++++++++ 2 files changed, 210 insertions(+) create mode 100644 examples/example_glfw_metal/Makefile create mode 100644 examples/example_glfw_metal/main.mm diff --git a/examples/example_glfw_metal/Makefile b/examples/example_glfw_metal/Makefile new file mode 100644 index 00000000..35f17737 --- /dev/null +++ b/examples/example_glfw_metal/Makefile @@ -0,0 +1,44 @@ +# +# You will need GLFW (http://www.glfw.org): +# brew install glfw +# + +#CXX = g++ +#CXX = clang++ + +EXE = example_glfw_metal +SOURCES = main.mm +SOURCES += ../imgui_impl_glfw.cpp ../imgui_impl_metal.mm +SOURCES += ../../imgui.cpp ../../imgui_widgets.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp +OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) + +LIBS = -framework Metal -framework MetalKit -framework Cocoa -framework IOKit -framework CoreVideo -framework QuartzCore +LIBS += -L/usr/local/lib -lglfw + +CXXFLAGS = -I../ -I../../ -I/usr/local/include +CXXFLAGS += -Wall -Wformat +CFLAGS = $(CXXFLAGS) + +%.o:%.cpp + $(CXX) $(CXXFLAGS) -c -o $@ $< + +%.o:../%.cpp + $(CXX) $(CXXFLAGS) -c -o $@ $< + +%.o:../../%.cpp + $(CXX) $(CXXFLAGS) -c -o $@ $< + +%.o:../%.mm + $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $< + +%.o:%.mm + $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $< + +all: $(EXE) + @echo Build complete + +$(EXE): $(OBJS) + $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) + +clean: + rm -f $(EXE) $(OBJS) diff --git a/examples/example_glfw_metal/main.mm b/examples/example_glfw_metal/main.mm new file mode 100644 index 00000000..3b162afb --- /dev/null +++ b/examples/example_glfw_metal/main.mm @@ -0,0 +1,166 @@ +// ImGui - standalone example application for GLFW + Metal, using programmable pipeline +// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. + +#include "imgui.h" +#include "imgui_impl_glfw.h" +#include "imgui_impl_metal.h" + +#define GLFW_INCLUDE_NONE +#define GLFW_EXPOSE_NATIVE_COCOA +#include +#include + +#import +#import + +#include + +static void glfw_error_callback(int error, const char* description) +{ + fprintf(stderr, "Glfw Error %d: %s\n", error, description); +} + +int main(int, char**) +{ + // Setup Dear ImGui binding + IMGUI_CHECKVERSION(); + ImGui::CreateContext(); + ImGuiIO& io = ImGui::GetIO(); (void)io; + //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls + //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls + + // Setup style + ImGui::StyleColorsDark(); + //ImGui::StyleColorsClassic(); + + // Load Fonts + // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. + // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. + // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). + // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. + // - Read 'misc/fonts/README.txt' for more instructions and details. + // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! + //io.Fonts->AddFontDefault(); + //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); + //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); + //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); + //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); + //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); + //IM_ASSERT(font != NULL); + + // Setup window + glfwSetErrorCallback(glfw_error_callback); + if (!glfwInit()) + return 1; + + // Create window with graphics context + glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); + GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+Metal example", NULL, NULL); + if (window == NULL) + return 1; + + id device = MTLCreateSystemDefaultDevice();; + id commandQueue = [device newCommandQueue]; + + ImGui_ImplGlfw_InitForOpenGL(window, true); + ImGui_ImplMetal_Init(device); + + NSWindow *nswin = glfwGetCocoaWindow(window); + CAMetalLayer *layer = [CAMetalLayer layer]; + layer.device = device; + layer.pixelFormat = MTLPixelFormatBGRA8Unorm; + nswin.contentView.layer = layer; + nswin.contentView.wantsLayer = YES; + + MTLRenderPassDescriptor *renderPassDescriptor = [MTLRenderPassDescriptor new]; + + bool show_demo_window = true; + bool show_another_window = false; + float clear_color[4] = {0.45f, 0.55f, 0.60f, 1.00f}; + + // Main loop + while (!glfwWindowShouldClose(window)) + { + // Poll and handle events (inputs, window resize, etc.) + // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. + // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. + // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. + // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. + glfwPollEvents(); + + int width, height; + glfwGetFramebufferSize(window, &width, &height); + layer.drawableSize = CGSizeMake(width, height); + id drawable = [layer nextDrawable]; + + id commandBuffer = [commandQueue commandBuffer]; + renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color[0], clear_color[1], clear_color[2], clear_color[3]); + renderPassDescriptor.colorAttachments[0].texture = drawable.texture; + renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear; + renderPassDescriptor.colorAttachments[0].storeAction = MTLStoreActionStore; + id renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor]; + [renderEncoder pushDebugGroup:@"ImGui demo"]; + + // Start the Dear ImGui frame + ImGui_ImplMetal_NewFrame(renderPassDescriptor); + ImGui_ImplGlfw_NewFrame(); + ImGui::NewFrame(); + + // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). + if (show_demo_window) + ImGui::ShowDemoWindow(&show_demo_window); + + // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. + { + static float f = 0.0f; + static int counter = 0; + + ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. + + ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) + ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state + ImGui::Checkbox("Another Window", &show_another_window); + + ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f + ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color + + if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) + counter++; + ImGui::SameLine(); + ImGui::Text("counter = %d", counter); + + ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); + ImGui::End(); + } + + // 3. Show another simple window. + if (show_another_window) + { + ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) + ImGui::Text("Hello from another window!"); + if (ImGui::Button("Close Me")) + show_another_window = false; + ImGui::End(); + } + + // Rendering + ImGui::Render(); + ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder); + + [renderEncoder popDebugGroup]; + [renderEncoder endEncoding]; + + [commandBuffer presentDrawable:drawable]; + [commandBuffer commit]; + } + + // Cleanup + ImGui_ImplMetal_Shutdown(); + ImGui_ImplGlfw_Shutdown(); + ImGui::DestroyContext(); + + glfwDestroyWindow(window); + glfwTerminate(); + + return 0; +} From 6c196cf4324cd1bba483031373af425fed4af25a Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 6 May 2019 10:02:59 +0200 Subject: [PATCH 8/9] Examples Readme and Changelog tweaks, added #2527, re-ordered examples/README alphabetically. --- docs/CHANGELOG.txt | 14 ++--- examples/README.txt | 75 +++++++++++++++----------- examples/example_glut_opengl2/main.cpp | 1 + examples/imgui_impl_glut.cpp | 1 + examples/imgui_impl_glut.h | 1 + imgui.cpp | 2 +- 6 files changed, 56 insertions(+), 38 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 514c5d3c..1e4d8a23 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -34,8 +34,9 @@ HOW TO UPDATE? ----------------------------------------------------------------------- Breaking Changes: -- ImDrawList: Fixed rectangles with thick lines (>1.0f) not being as thick as requested. (#2518) - If you have custom rendering using thick lines, they will appear thicker now. +- ImDrawList: Improved algorithm for mitre joints on thick lines, preserving correct thickness + up to 90 degrees angles (e.g. rectangles). If you have custom rendering using thick lines, + they will appear a little thicker now. (#2518) [@rmitton] - Obsoleted GetContentRegionAvailWidth(), use GetContentRegionAvail().x instead. Kept inline redirection function. - Examples: Vulkan: Added MinImageCount/ImageCount fields in ImGui_ImplVulkan_InitInfo, required @@ -50,8 +51,8 @@ Other Changes: Examples: Added support for ImDrawCallback_ResetRenderState in all renderer back-ends. Each renderer code setting up initial render state has been moved to a function so it could be called at the start of rendering and when a ResetRenderState is requested. [@ocornut, @bear24rw] -- InputText: Fixed selection background starts rendering one frame after the cursor movement - when first transitioning from no-selection to has-selection. (Bug in 1.69) (#2436) [@Nazg-Gul] +- InputText: Fixed selection background rendering one frame after the cursor movement when + first transitioning from no-selection to has-selection. (Bug in 1.69) (#2436) [@Nazg-Gul] - InputText: Work-around for buggy standard libraries where isprint('\t') returns true. (#2467, #1336) - InputText: Fixed ImGuiInputTextFlags_AllowTabInput leading to two tabs characters being inserted if the back-end provided both Key and Character input. (#2467, #1336) @@ -68,7 +69,7 @@ Other Changes: highlight from parent menu items earlier than necessary while approaching the child menu. - Window: Close button is horizontally aligned with style.FramePadding.x. - Window: Fixed contents region being off by WindowBorderSize amount on the right when scrollbar is active. -- Window: Fixed SetNextWindowSizeConstraints() with non-rounded positions making windows drift. (#2067, 2530) +- Window: Fixed SetNextWindowSizeConstraints() with non-rounded positions making windows drift. (#2067, #2530) - Popups: Closing a popup restores the focused/nav window in place at the time of the popup opening, instead of restoring the window that was in the window stack at the time of the OpenPopup call. (#2517) Among other things, this allows opening a popup while no window are focused, and pressing Escape to @@ -97,8 +98,9 @@ Other Changes: - Demo: Improved trees in columns demo. - Examples: OpenGL: Added a dummy GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized GL function loaders early, and help users understand what they are missing. (#2421) -- Examples: Emscripten: Added Emscripten+SDL+GLES2 example. (#2494, #2492, #2351, #336) [@nicolasnoble, @redblobgames] - Examples: SDL: Added support for SDL_GameController gamepads (enable with ImGuiConfigFlags_NavEnableGamepad). (#2509) [@DJLink] +- Examples: Emscripten: Added Emscripten+SDL+GLES2 example. (#2494, #2492, #2351, #336) [@nicolasnoble, @redblobgames] +- Examples: Metal: Added Glfw+Metal example. (#2527) [@bear24rw] - Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop. - Examples: Vulkan: Fixed in-flight buffers issues when using multi-viewports. (#2461, #2348, #2378, #2097) - Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int). diff --git a/examples/README.txt b/examples/README.txt index cd60733c..6a34c076 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -91,7 +91,7 @@ Most the example bindings are split in 2 parts: This is counter-intuitive, but this will get you running faster! Once you better understand how imgui works and is bound, you can rewrite the code using your own systems. - - Road-map: Dear ImGui 1.70 (WIP currently in the "viewport" branch) will allows imgui windows to be + - Road-map: Dear ImGui 1.80 (WIP currently in the "docking" branch) will allows imgui windows to be seamlessly detached from the main application window. This is achieved using an extra layer to the platform and renderer bindings, which allows imgui to communicate platform-specific requests. If you decide to use unmodified imgui_impl_xxxx.cpp files, you will automatically benefit from @@ -101,7 +101,7 @@ Most the example bindings are split in 2 parts: List of Platforms Bindings in this repository: imgui_impl_glfw.cpp ; GLFW (Windows, macOS, Linux, etc.) http://www.glfw.org/ - imgui_impl_osx.mm ; macOS native API + imgui_impl_osx.mm ; macOS native API (not as feature complete as glfw/sdl back-ends) imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org imgui_impl_win32.cpp ; Win32 native API (Windows) imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's) @@ -122,7 +122,7 @@ List of high-level Frameworks Bindings in this repository: (combine Platform + R imgui_impl_allegro5.cpp imgui_impl_marmalade.cpp -Note that Dear ImGui works with Emscripten. +Note that Dear ImGui works with Emscripten. The examples_emscripten/ app uses sdl.cpp + opengl3.cpp but other combinations are possible. Third-party framework, graphics API and languages bindings are listed at: @@ -151,40 +151,33 @@ Building: directly with a command-line compiler. -example_win32_directx9/ - DirectX9 example, Windows only. - = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx9.cpp - -example_win32_directx10/ - DirectX10 example, Windows only. - = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx10.cpp - -example_win32_directx11/ - DirectX11 example, Windows only. - = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx11.cpp - -example_win32_directx12/ - DirectX12 example, Windows only. - = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx12.cpp - This is quite long and tedious, because: DirectX12. +example_allegro5/ + Allegro 5 example. + = main.cpp + imgui_impl_allegro5.cpp example_apple_metal/ OSX & iOS + Metal. = main.m + imgui_impl_osx.mm + imgui_impl_metal.mm It is based on the "cross-platform" game template provided with Xcode as of Xcode 9. - (NB: you may still want to use GLFW or SDL which will also support Windows, Linux along with OSX.) + (NB: imgui_impl_osx.mm is currently not as feature complete as other platforms back-ends. + You may prefer to use the GLFW Or SDL back-ends, which will also support Windows and Linux.) example_apple_opengl2/ OSX + OpenGL2. = main.mm + imgui_impl_osx.mm + imgui_impl_opengl2.cpp - (NB: you may still want to use GLFW or SDL which will also support Windows, Linux along with OSX.) + (NB: imgui_impl_osx.mm is currently not as feature complete as other platforms back-ends. + You may prefer to use the GLFW Or SDL back-ends, which will also support Windows and Linux.) example_empscripten: Emcripten + SDL2 + OpenGL3+/ES2/ES3 example. = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp - Note that other examples based on SDL or GLFW + GL could easily be modified to work with Emscripten. + Note that other examples based on SDL or GLFW + OpenGL could easily be modified to work with Emscripten. We provide this to make the Emscripten differences obvious, and have them not pollute all other examples. +example_glfw_metal/ + GLFW (Mac) + Vulkan example. + = main.mm + imgui_impl_glfw.cpp + imgui_impl_metal.mm. + example_glfw_opengl2/ GLFW + OpenGL2 example (legacy, fixed pipeline). = main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp @@ -200,12 +193,24 @@ example_glfw_opengl3/ = main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp This uses more modern OpenGL calls and custom shaders. Prefer using that if you are using modern OpenGL in your application (anything with shaders). + (Please be mindful that accessing OpenGL3+ functions requires a function loader, which are a frequent + source for confusion for new users. We use a loader in imgui_impl_opengl3.cpp which may be different + from the one your app normally use. Read imgui_impl_opengl3.h for details and how to change it.) example_glfw_vulkan/ GLFW (Win32, Mac, Linux) + Vulkan example. = main.cpp + imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp This is quite long and tedious, because: Vulkan. +example_glut_opengl2/ + GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2. + = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp + Note that GLUT/FreeGLUT is largely obsolete software, prefer using GLFW or SDL. + +example_marmalade/ + Marmalade example using IwGx. + = main.cpp + imgui_impl_marmalade.cpp + example_sdl_opengl2/ SDL2 (Win32, Mac, Linux etc.) + OpenGL example (legacy, fixed pipeline). = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl2.cpp @@ -221,20 +226,28 @@ example_sdl_opengl3/ = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp This uses more modern OpenGL calls and custom shaders. Prefer using that if you are using modern OpenGL in your application (anything with shaders). + (Please be mindful that accessing OpenGL3+ functions requires a function loader, which are a frequent + source for confusion for new users. We use a loader in imgui_impl_opengl3.cpp which may be different + from the one your app normally use. Read imgui_impl_opengl3.h for details and how to change it.) example_sdl_vulkan/ SDL2 (Win32, Mac, Linux, etc.) + Vulkan example. = main.cpp + imgui_impl_sdl.cpp + imgui_impl_vulkan.cpp This is quite long and tedious, because: Vulkan. -example_allegro5/ - Allegro 5 example. - = main.cpp + imgui_impl_allegro5.cpp +example_win32_directx9/ + DirectX9 example, Windows only. + = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx9.cpp -example_glut_opengl2/ - GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2. - = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp +example_win32_directx10/ + DirectX10 example, Windows only. + = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx10.cpp -example_marmalade/ - Marmalade example using IwGx. - = main.cpp + imgui_impl_marmalade.cpp +example_win32_directx11/ + DirectX11 example, Windows only. + = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx11.cpp + +example_win32_directx12/ + DirectX12 example, Windows only. + = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx12.cpp + This is quite long and tedious, because: DirectX12. diff --git a/examples/example_glut_opengl2/main.cpp b/examples/example_glut_opengl2/main.cpp index 1089baee..e9fc1068 100644 --- a/examples/example_glut_opengl2/main.cpp +++ b/examples/example_glut_opengl2/main.cpp @@ -3,6 +3,7 @@ // !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!! // !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!! +// !!! Prefer using GLFW Or SDL instead! #include "imgui.h" #include "../imgui_impl_glut.h" diff --git a/examples/imgui_impl_glut.cpp b/examples/imgui_impl_glut.cpp index 546a7b85..af42d4ae 100644 --- a/examples/imgui_impl_glut.cpp +++ b/examples/imgui_impl_glut.cpp @@ -3,6 +3,7 @@ // !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!! // !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!! +// !!! Prefer using GLFW or SDL instead! // Issues: // [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I diff --git a/examples/imgui_impl_glut.h b/examples/imgui_impl_glut.h index 89be9993..c6fcfd07 100644 --- a/examples/imgui_impl_glut.h +++ b/examples/imgui_impl_glut.h @@ -3,6 +3,7 @@ // !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!! // !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!! +// !!! Prefer using GLFW or SDL instead! // Issues: // [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I diff --git a/imgui.cpp b/imgui.cpp index 68ac63ac..1351d285 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -369,7 +369,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. - - 2019/04/29 (1.70) - fixed ImDrawList rectangles with thick lines (>1.0f) not being as thick as requested. If you have custom rendering using rectangles with thick lines, they will appear thicker now. + - 2019/04/29 (1.70) - improved ImDrawList thick strokes (>1.0f) preserving correct thickness up to 90 degrees angles (e.g. rectangles). If you have custom rendering using thick lines, they will appear thicker now. - 2019/04/29 (1.70) - removed GetContentRegionAvailWidth(), use GetContentRegionAvail().x instead. Kept inline redirection function (will obsolete). - 2019/03/04 (1.69) - renamed GetOverlayDrawList() to GetForegroundDrawList(). Kept redirection function (will obsolete). - 2019/02/26 (1.69) - renamed ImGuiColorEditFlags_RGB/ImGuiColorEditFlags_HSV/ImGuiColorEditFlags_HEX to ImGuiColorEditFlags_DisplayRGB/ImGuiColorEditFlags_DisplayHSV/ImGuiColorEditFlags_DisplayHex. Kept redirection enums (will obsolete). From d88121ff5b90013647d1b27ee7d5012f1d85a452 Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 6 May 2019 10:11:02 +0200 Subject: [PATCH 9/9] Examples: DirectX9/10/11: Taking reference to device + subsequent merge of this in docking will fix DX9 issue #2524 --- examples/imgui_impl_dx10.cpp | 3 ++- examples/imgui_impl_dx11.cpp | 6 ++++-- examples/imgui_impl_dx9.cpp | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/imgui_impl_dx10.cpp b/examples/imgui_impl_dx10.cpp index 8d2c647d..235428fc 100644 --- a/examples/imgui_impl_dx10.cpp +++ b/examples/imgui_impl_dx10.cpp @@ -500,6 +500,7 @@ bool ImGui_ImplDX10_Init(ID3D10Device* device) } if (pDXGIDevice) pDXGIDevice->Release(); if (pDXGIAdapter) pDXGIAdapter->Release(); + g_pd3dDevice->AddRef(); return true; } @@ -508,7 +509,7 @@ void ImGui_ImplDX10_Shutdown() { ImGui_ImplDX10_InvalidateDeviceObjects(); if (g_pFactory) { g_pFactory->Release(); g_pFactory = NULL; } - g_pd3dDevice = NULL; + if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } } void ImGui_ImplDX10_NewFrame() diff --git a/examples/imgui_impl_dx11.cpp b/examples/imgui_impl_dx11.cpp index 9a44d6ae..18c32e6c 100644 --- a/examples/imgui_impl_dx11.cpp +++ b/examples/imgui_impl_dx11.cpp @@ -508,6 +508,8 @@ bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_co } if (pDXGIDevice) pDXGIDevice->Release(); if (pDXGIAdapter) pDXGIAdapter->Release(); + g_pd3dDevice->AddRef(); + g_pd3dDeviceContext->AddRef(); return true; } @@ -516,8 +518,8 @@ void ImGui_ImplDX11_Shutdown() { ImGui_ImplDX11_InvalidateDeviceObjects(); if (g_pFactory) { g_pFactory->Release(); g_pFactory = NULL; } - g_pd3dDevice = NULL; - g_pd3dDeviceContext = NULL; + if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } + if (g_pd3dDeviceContext) { g_pd3dDeviceContext->Release(); g_pd3dDeviceContext = NULL; } } void ImGui_ImplDX11_NewFrame() diff --git a/examples/imgui_impl_dx9.cpp b/examples/imgui_impl_dx9.cpp index f375c390..fd4522cd 100644 --- a/examples/imgui_impl_dx9.cpp +++ b/examples/imgui_impl_dx9.cpp @@ -219,13 +219,14 @@ bool ImGui_ImplDX9_Init(IDirect3DDevice9* device) io.BackendRendererName = "imgui_impl_dx9"; g_pd3dDevice = device; + g_pd3dDevice->AddRef(); return true; } void ImGui_ImplDX9_Shutdown() { ImGui_ImplDX9_InvalidateDeviceObjects(); - g_pd3dDevice = NULL; + if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } } static bool ImGui_ImplDX9_CreateFontsTexture()