From 7fd805497a5291c7adb6a77fc7fb564422e34344 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 26 Dec 2017 20:30:22 +0100 Subject: [PATCH 1/9] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6ababf5b..60846832 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ Languages: - ChaiScript: https://github.com/JuJuBoSc/imgui-chaiscript - D (DerelictImgui): https://github.com/Extrawurst/DerelictImgui - Go (go-imgui): https://github.com/Armored-Dragon/go-imgui +- Haxe/hxcpp (linc_imgui): https://github.com/Aidan63/linc_imgui - Lua: https://github.com/patrickriordan/imgui_lua_bindings - Odin: https://github.com/ThisDrunkDane/odin-dear_imgui - Pascal (imgui-pas): https://github.com/dpethes/imgui-pas From 6e30c33642f06e77f6f38c8f15e4447a745c6645 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 26 Dec 2017 21:04:17 +0100 Subject: [PATCH 2/9] Demo dinaries update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 60846832..bf309946 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Binaries/Demo ------------- You should be able to build the examples from sources (tested on Windows/Mac/Linux). If you don't, let me know! If you want to have a quick look at some Dear ImGui features, you can download Windows binaries of the demo app here: -- [imgui-demo-binaries-20171013.zip](http://www.miracleworld.net/imgui/binaries/imgui-demo-binaries-20171013.zip) (Windows binaries, Dear ImGui 1.52 WIP built 2017/10/13, 5 executables) +- [imgui-demo-binaries-20171226.zip](http://www.miracleworld.net/imgui/binaries/imgui-demo-binaries-20171226.zip) (Windows binaries, Dear ImGui 1.53 built 2017/12/26, 5 executables) Bindings -------- From 49eed6e2d132e8fb27af3760061b8558e8bbb654 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 28 Dec 2017 15:17:35 +0100 Subject: [PATCH 3/9] Version 1.54 WIP --- imgui.cpp | 2 +- imgui.h | 4 ++-- imgui_demo.cpp | 2 +- imgui_draw.cpp | 2 +- imgui_internal.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index dee18b4e..e0f1af4b 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.53 +// dear imgui, v1.54 WIP // (main code and documentation) // Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code. diff --git a/imgui.h b/imgui.h index 1b1e92b3..711e0271 100644 --- a/imgui.h +++ b/imgui.h @@ -1,4 +1,4 @@ -// dear imgui, v1.53 +// dear imgui, v1.54 WIP // (headers) // See imgui.cpp file for documentation. @@ -16,7 +16,7 @@ #include // ptrdiff_t, NULL #include // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp -#define IMGUI_VERSION "1.53" +#define IMGUI_VERSION "1.54 WIP" // Define attributes of all API symbols declarations, e.g. for DLL under Windows. #ifndef IMGUI_API diff --git a/imgui_demo.cpp b/imgui_demo.cpp index a5864fef..94531a10 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.53 +// dear imgui, v1.54 WIP // (demo code) // Message to the person tempted to delete this file when integrating ImGui into their code base: diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 6efb6bc6..b56d90cf 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.53 +// dear imgui, v1.54 WIP // (drawing and font code) // Contains implementation for diff --git a/imgui_internal.h b/imgui_internal.h index 80435390..797d66d6 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1,4 +1,4 @@ -// dear imgui, v1.53 +// dear imgui, v1.54 WIP // (internals) // You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility! From 563d04fdb118c72a9add2d2f8e98639eae6d1feb Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 28 Dec 2017 15:29:06 +0100 Subject: [PATCH 4/9] TreeNode: node with the ImGuiTreeNodeFlags_Leaf flag correctly disable highlight when DragDrop is active. (#143, #581) --- imgui.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index e0f1af4b..50059632 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6702,7 +6702,8 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l // - OpenOnArrow .................... single-click on arrow to open // - OpenOnDoubleClick|OpenOnArrow .. single-click on arrow or double-click anywhere to open ImGuiButtonFlags button_flags = ImGuiButtonFlags_NoKeyModifiers | ((flags & ImGuiTreeNodeFlags_AllowItemOverlap) ? ImGuiButtonFlags_AllowItemOverlap : 0); - button_flags |= ImGuiButtonFlags_PressedOnDragDropHold; + if (!(flags & ImGuiTreeNodeFlags_Leaf)) + button_flags |= ImGuiButtonFlags_PressedOnDragDropHold; if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick) button_flags |= ImGuiButtonFlags_PressedOnDoubleClick | ((flags & ImGuiTreeNodeFlags_OpenOnArrow) ? ImGuiButtonFlags_PressedOnClickRelease : 0); From 06bea369c0ce977c1cb71e085d860a6644330297 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 28 Dec 2017 16:54:16 +0100 Subject: [PATCH 5/9] DragDrop: Added IsDragDropActive() helper which is useful for binding to decide how to handle mouse inputs. --- imgui.cpp | 6 ++++++ imgui.h | 1 + 2 files changed, 7 insertions(+) diff --git a/imgui.cpp b/imgui.cpp index 50059632..45ed8ad8 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -11478,6 +11478,12 @@ void ImGui::EndDragDropTarget() IM_ASSERT(g.DragDropActive); } +bool ImGui::IsDragDropActive() +{ + ImGuiContext& g = *GImGui; + return g.DragDropActive; +} + //----------------------------------------------------------------------------- // PLATFORM DEPENDENT HELPERS //----------------------------------------------------------------------------- diff --git a/imgui.h b/imgui.h index 711e0271..4972443a 100644 --- a/imgui.h +++ b/imgui.h @@ -433,6 +433,7 @@ namespace ImGui IMGUI_API bool BeginDragDropTarget(); // call after submitting an item that may receive an item. If this returns true, you can call AcceptDragDropPayload() + EndDragDropTarget() IMGUI_API const ImGuiPayload* AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags = 0); // accept contents of a given type. If ImGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released. IMGUI_API void EndDragDropTarget(); + IMGUI_API bool IsDragDropActive(); // Clipping IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect); From e985baa35ddda960b48d87e9d384cdc77a691913 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 28 Dec 2017 17:05:52 +0100 Subject: [PATCH 6/9] Combo: When peeking into the popup window for alignment we check if the window was active, which is more correct. (no known issue in current codebase, but we'll need that change for later) --- imgui.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 45ed8ad8..3c6df701 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -9230,14 +9230,15 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboF // Peak into expected window size so we can position it if (ImGuiWindow* popup_window = FindWindowByName(name)) - { - ImVec2 size_contents = CalcSizeContents(popup_window); - ImVec2 size_expected = CalcSizeAfterConstraint(popup_window, CalcSizeAutoFit(popup_window, size_contents)); - if (flags & ImGuiComboFlags_PopupAlignLeft) - popup_window->AutoPosLastDirection = ImGuiDir_Left; - ImVec2 pos = FindBestWindowPosForPopup(frame_bb.GetBL(), size_expected, &popup_window->AutoPosLastDirection, frame_bb, ImGuiPopupPositionPolicy_ComboBox); - SetNextWindowPos(pos); - } + if (popup_window->WasActive) + { + ImVec2 size_contents = CalcSizeContents(popup_window); + ImVec2 size_expected = CalcSizeAfterConstraint(popup_window, CalcSizeAutoFit(popup_window, size_contents)); + if (flags & ImGuiComboFlags_PopupAlignLeft) + popup_window->AutoPosLastDirection = ImGuiDir_Left; + ImVec2 pos = FindBestWindowPosForPopup(frame_bb.GetBL(), size_expected, &popup_window->AutoPosLastDirection, frame_bb, ImGuiPopupPositionPolicy_ComboBox); + SetNextWindowPos(pos); + } ImGuiWindowFlags window_flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_Popup | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings; if (!Begin(name, NULL, window_flags)) From 90ff4ae5d16c2200cf6fdad2825ebb473d906899 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 28 Dec 2017 23:08:48 +0100 Subject: [PATCH 7/9] BeginPopupModal(): the conditional test for SetNextWindowPos() was polling the wrong window, which in practice made the test succeed all the time. --- imgui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 3c6df701..10ef65be 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3885,7 +3885,7 @@ bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags ext } // Center modal windows by default - if ((window->SetWindowPosAllowFlags & g.SetNextWindowPosCond) == 0) + if (g.SetNextWindowPosCond == 0) SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f)); ImGuiWindowFlags flags = extra_flags|ImGuiWindowFlags_Popup|ImGuiWindowFlags_Modal|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoSavedSettings; From 4ba2e8574433b049ce643eb13fc2fbfb3d222d33 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 28 Dec 2017 23:50:37 +0100 Subject: [PATCH 8/9] Demo: Tweak. Comments. Metrics: Added some Drag and Drop info. --- imgui.cpp | 9 +++++---- imgui_demo.cpp | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 10ef65be..2e16fb3f 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2914,7 +2914,7 @@ void ImGui::EndFrame() IM_ASSERT(g.CurrentWindowStack.Size == 1); // Mismatched Begin()/End() calls if (g.CurrentWindow && !g.CurrentWindow->WriteAccessed) g.CurrentWindow->Active = false; - ImGui::End(); + End(); if (g.ActiveId == 0 && g.HoveredId == 0) { @@ -3715,7 +3715,7 @@ void ImGui::BeginTooltip() void ImGui::EndTooltip() { IM_ASSERT(GetCurrentWindowRead()->Flags & ImGuiWindowFlags_Tooltip); // Mismatched BeginTooltip()/EndTooltip() calls - ImGui::End(); + End(); } // Mark popup as open (toggle toward open state). @@ -4011,7 +4011,7 @@ void ImGui::EndChild() IM_ASSERT(window->Flags & ImGuiWindowFlags_ChildWindow); // Mismatched BeginChild()/EndChild() callss if (window->BeginCount > 1) { - ImGui::End(); + End(); } else { @@ -4021,7 +4021,7 @@ void ImGui::EndChild() sz.x = ImMax(4.0f, sz.x); if (window->AutoFitChildAxises & (1 << ImGuiAxis_Y)) sz.y = ImMax(4.0f, sz.y); - ImGui::End(); + End(); ImGuiWindow* parent_window = GetCurrentWindow(); ImRect bb(parent_window->DC.CursorPos, parent_window->DC.CursorPos + sz); @@ -11730,6 +11730,7 @@ void ImGui::ShowMetricsWindow(bool* p_open) ImGui::Text("ActiveId: 0x%08X/0x%08X (%.2f sec)", g.ActiveId, g.ActiveIdPreviousFrame, g.ActiveIdTimer); ImGui::Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL"); ImGui::Text("NavWindow: '%s'", g.NavWindow ? g.NavWindow->Name : "NULL"); + ImGui::Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize); ImGui::TreePop(); } } diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 94531a10..1ccc2990 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -2365,6 +2365,7 @@ static void ShowExampleAppFixedOverlay(bool* p_open) if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1; if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2; if (ImGui::MenuItem("Bottom-right", NULL, corner == 3)) corner = 3; + if (p_open && ImGui::MenuItem("Close")) *p_open = false; ImGui::EndPopup(); } ImGui::End(); From 4fbdb50dca435741531d775f2ea6239ccf13e151 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 28 Dec 2017 23:51:58 +0100 Subject: [PATCH 9/9] MenuBar: Fixed menu bar pushing a clipping rect outside of its allocated bound (usually unnoticeable). --- imgui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 2e16fb3f..479e8eaf 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -9632,7 +9632,7 @@ bool ImGui::BeginMenuBar() // We remove 1 worth of rounding to Max.x to that text in long menus don't tend to display over the lower-right rounded area, which looks particularly glitchy. ImRect bar_rect = window->MenuBarRect(); ImRect clip_rect(ImFloor(bar_rect.Min.x + 0.5f), ImFloor(bar_rect.Min.y + window->WindowBorderSize + 0.5f), ImFloor(ImMax(bar_rect.Min.x, bar_rect.Max.x - window->WindowRounding) + 0.5f), ImFloor(bar_rect.Max.y + 0.5f)); - clip_rect.ClipWith(window->Rect()); + clip_rect.ClipWith(window->WindowRectClipped); PushClipRect(clip_rect.Min, clip_rect.Max, false); window->DC.CursorPos = ImVec2(bar_rect.Min.x + window->DC.MenuBarOffsetX, bar_rect.Min.y);// + g.Style.FramePadding.y);