From 2eaf722fd77cc7745d6af9f3f134e64651ad8f12 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 7 Sep 2018 17:23:55 +0200 Subject: [PATCH 01/15] Fixed calling DestroyContext() always saving .ini data with the current context instead of the supplied context pointer. (#2066) --- docs/CHANGELOG.txt | 5 +++++ imgui.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 91c5b5de..b2c6a204 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -33,6 +33,11 @@ HOW TO UPDATE? VERSION 1.66 (In Progress) ----------------------------------------------------------------------- +Other Changes: + +- Fixed calling DestroyContext() always saving .ini data with the current context instead + of the supplied context pointer. (#2066) + ----------------------------------------------------------------------- VERSION 1.65 (Released 2018-09-06) diff --git a/imgui.cpp b/imgui.cpp index f14dfc50..f5f19df0 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3281,7 +3281,12 @@ void ImGui::Shutdown(ImGuiContext* context) // Save settings (unless we haven't attempted to load them: CreateContext/DestroyContext without a call to NewFrame shouldn't save an empty file) if (g.SettingsLoaded && g.IO.IniFilename != NULL) + { + ImGuiContext* backup_context = GImGui; + SetCurrentContext(context); SaveIniSettingsToDisk(g.IO.IniFilename); + SetCurrentContext(backup_context); + } // Clear everything else for (int i = 0; i < g.Windows.Size; i++) From 062b1f0463f6689f55e1599f5ea0f16a5edd99a9 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 7 Sep 2018 22:30:46 +0200 Subject: [PATCH 02/15] Fixed calling SetNextWindowSize()/SetWindowSize() with non-integer values leading to accidental alteration of window position. We now round the provided size. (#2067) --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index b2c6a204..184a4b98 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -37,6 +37,8 @@ Other Changes: - Fixed calling DestroyContext() always saving .ini data with the current context instead of the supplied context pointer. (#2066) +- Fixed calling SetNextWindowSize()/SetWindowSize() with non-integer values leading to + accidental alteration of window position. We now round the provided size. (#2067) ----------------------------------------------------------------------- diff --git a/imgui.cpp b/imgui.cpp index f5f19df0..a2dbc4d4 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4187,7 +4187,7 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl if (ImLengthSqr(settings->Size) > 0.00001f) size = ImFloor(settings->Size); } - window->Size = window->SizeFull = window->SizeFullAtLastBegin = size; + window->Size = window->SizeFull = window->SizeFullAtLastBegin = ImFloor(size); window->DC.CursorMaxPos = window->Pos; // So first call to CalcSizeContents() doesn't return crazy values if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0) @@ -5659,7 +5659,7 @@ static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond con if (size.x > 0.0f) { window->AutoFitFramesX = 0; - window->SizeFull.x = size.x; + window->SizeFull.x = ImFloor(size.x); } else { @@ -5669,7 +5669,7 @@ static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond con if (size.y > 0.0f) { window->AutoFitFramesY = 0; - window->SizeFull.y = size.y; + window->SizeFull.y = ImFloor(size.y); } else { From 7eadcf7d7dbb3cfffc0efece650560e6531a30de Mon Sep 17 00:00:00 2001 From: MindSpunk Date: Sun, 9 Sep 2018 22:32:57 +1000 Subject: [PATCH 03/15] example_glfw_vulkan was missing a reference to imgui_widgets.cpp (#2071, #2036) --- examples/example_glfw_vulkan/CMakeLists.txt | 2 +- examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj | 3 ++- .../example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/example_glfw_vulkan/CMakeLists.txt b/examples/example_glfw_vulkan/CMakeLists.txt index 60fe5718..82d7ab47 100644 --- a/examples/example_glfw_vulkan/CMakeLists.txt +++ b/examples/example_glfw_vulkan/CMakeLists.txt @@ -32,5 +32,5 @@ include_directories(${GLFW_DIR}/deps) file(GLOB sources *.cpp) -add_executable(example_glfw_vulkan ${sources} ${IMGUI_DIR}/examples/imgui_impl_glfw.cpp ${IMGUI_DIR}/examples/imgui_impl_vulkan.cpp ${IMGUI_DIR}/imgui.cpp ${IMGUI_DIR}/imgui_draw.cpp ${IMGUI_DIR}/imgui_demo.cpp) +add_executable(example_glfw_vulkan ${sources} ${IMGUI_DIR}/examples/imgui_impl_glfw.cpp ${IMGUI_DIR}/examples/imgui_impl_vulkan.cpp ${IMGUI_DIR}/imgui.cpp ${IMGUI_DIR}/imgui_draw.cpp ${IMGUI_DIR}/imgui_demo.cpp ${IMGUI_DIR}/imgui_widgets.cpp) target_link_libraries(example_glfw_vulkan ${LIBRARIES}) diff --git a/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj b/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj index 04b55082..b0305e8f 100644 --- a/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj +++ b/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj @@ -1,4 +1,4 @@ - + @@ -153,6 +153,7 @@ + diff --git a/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters b/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters index 0fa42d7f..98a445d4 100644 --- a/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters +++ b/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters @@ -28,6 +28,9 @@ sources + + imgui + From e2436ca625a949c8ecd27d289b5ddbcc41c67042 Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 10 Sep 2018 20:30:14 +0200 Subject: [PATCH 04/15] Nav, Focus: Fixed ImGuiWindowFlags_NoBringToFrontOnFocus windows not being restoring focus properly after the main menu bar or last focused window is deactivated. --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 73 +++++++++++++++++++++++++++++----------------- imgui_demo.cpp | 23 ++++++++------- imgui_internal.h | 10 ++++--- imgui_widgets.cpp | 2 +- 5 files changed, 69 insertions(+), 41 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 184a4b98..1d7d3e4b 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -39,6 +39,8 @@ Other Changes: of the supplied context pointer. (#2066) - Fixed calling SetNextWindowSize()/SetWindowSize() with non-integer values leading to accidental alteration of window position. We now round the provided size. (#2067) +- Nav, Focus: Fixed ImGuiWindowFlags_NoBringToFrontOnFocus windows not being restoring focus + properly after the main menu bar or last focused window is deactivated. ----------------------------------------------------------------------- diff --git a/imgui.cpp b/imgui.cpp index a2dbc4d4..ffe5b407 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -906,7 +906,7 @@ static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* wind static void AddDrawListToDrawData(ImVector* out_list, ImDrawList* draw_list); static void AddWindowToDrawData(ImVector* out_list, ImGuiWindow* window); -static void AddWindowToSortedBuffer(ImVector* out_sorted_windows, ImGuiWindow* window); +static void AddWindowToSortBuffer(ImVector* out_sorted_windows, ImGuiWindow* window); static ImRect GetViewportRect(); @@ -3225,6 +3225,7 @@ void ImGui::NewFrame() g.NavIdTabCounter = INT_MAX; // Mark all windows as not visible + IM_ASSERT(g.WindowsFocusOrder.Size == g.Windows.Size); for (int i = 0; i != g.Windows.Size; i++) { ImGuiWindow* window = g.Windows[i]; @@ -3235,7 +3236,7 @@ void ImGui::NewFrame() // Closing the focused window restore focus to the first active root window in descending z-order if (g.NavWindow && !g.NavWindow->WasActive) - FocusFrontMostActiveWindowIgnoringOne(NULL); + FocusPreviousWindowIgnoringOne(NULL); // No window should be open at the beginning of the frame. // But in order to allow the user to call NewFrame() multiple times without calling Render(), we are doing an explicit clear. @@ -3292,6 +3293,7 @@ void ImGui::Shutdown(ImGuiContext* context) for (int i = 0; i < g.Windows.Size; i++) IM_DELETE(g.Windows[i]); g.Windows.clear(); + g.WindowsFocusOrder.clear(); g.WindowsSortBuffer.clear(); g.CurrentWindow = NULL; g.CurrentWindowStack.clear(); @@ -3340,7 +3342,7 @@ static int IMGUI_CDECL ChildWindowComparer(const void* lhs, const void* rhs) return (a->BeginOrderWithinParent - b->BeginOrderWithinParent); } -static void AddWindowToSortedBuffer(ImVector* out_sorted_windows, ImGuiWindow* window) +static void AddWindowToSortBuffer(ImVector* out_sorted_windows, ImGuiWindow* window) { out_sorted_windows->push_back(window); if (window->Active) @@ -3352,7 +3354,7 @@ static void AddWindowToSortedBuffer(ImVector* out_sorted_windows, { ImGuiWindow* child = window->DC.ChildWindows[i]; if (child->Active) - AddWindowToSortedBuffer(out_sorted_windows, child); + AddWindowToSortBuffer(out_sorted_windows, child); } } } @@ -3550,7 +3552,7 @@ void ImGui::EndFrame() ImGuiWindow* window = g.Windows[i]; if (window->Active && (window->Flags & ImGuiWindowFlags_ChildWindow)) // if a child is active its parent will add it continue; - AddWindowToSortedBuffer(&g.WindowsSortBuffer, window); + AddWindowToSortBuffer(&g.WindowsSortBuffer, window); } IM_ASSERT(g.Windows.Size == g.WindowsSortBuffer.Size); // we done something wrong @@ -4204,8 +4206,9 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl window->AutoFitOnlyGrows = (window->AutoFitFramesX > 0) || (window->AutoFitFramesY > 0); } + g.WindowsFocusOrder.push_back(window); if (flags & ImGuiWindowFlags_NoBringToFrontOnFocus) - g.Windows.insert(g.Windows.begin(), window); // Quite slow but rare and only once + g.Windows.push_front(window); // Quite slow but rare and only once else g.Windows.push_back(window); return window; @@ -5125,7 +5128,21 @@ void ImGui::End() SetCurrentWindow(g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back()); } -void ImGui::BringWindowToFront(ImGuiWindow* window) +void ImGui::BringWindowToFocusFront(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + if (g.WindowsFocusOrder.back() == window) + return; + for (int i = g.WindowsFocusOrder.Size - 2; i >= 0; i--) // We can ignore the front most window + if (g.WindowsFocusOrder[i] == window) + { + memmove(&g.WindowsFocusOrder[i], &g.WindowsFocusOrder[i + 1], (size_t)(g.WindowsFocusOrder.Size - i - 1) * sizeof(ImGuiWindow*)); + g.WindowsFocusOrder[g.WindowsFocusOrder.Size - 1] = window; + break; + } +} + +void ImGui::BringWindowToDisplayFront(ImGuiWindow* window) { ImGuiContext& g = *GImGui; ImGuiWindow* current_front_window = g.Windows.back(); @@ -5134,13 +5151,13 @@ void ImGui::BringWindowToFront(ImGuiWindow* window) for (int i = g.Windows.Size - 2; i >= 0; i--) // We can ignore the front most window if (g.Windows[i] == window) { - g.Windows.erase(g.Windows.Data + i); - g.Windows.push_back(window); + memmove(&g.Windows[i], &g.Windows[i + 1], (size_t)(g.Windows.Size - i - 1) * sizeof(ImGuiWindow*)); + g.Windows[g.Windows.Size - 1] = window; break; } } -void ImGui::BringWindowToBack(ImGuiWindow* window) +void ImGui::BringWindowToDisplayBack(ImGuiWindow* window) { ImGuiContext& g = *GImGui; if (g.Windows[0] == window) @@ -5185,20 +5202,24 @@ void ImGui::FocusWindow(ImGuiWindow* window) ClearActiveID(); // Bring to front + BringWindowToFocusFront(window); if (!(window->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) - BringWindowToFront(window); + BringWindowToDisplayFront(window); } -void ImGui::FocusFrontMostActiveWindowIgnoringOne(ImGuiWindow* ignore_window) +void ImGui::FocusPreviousWindowIgnoringOne(ImGuiWindow* ignore_window) { ImGuiContext& g = *GImGui; - for (int i = g.Windows.Size - 1; i >= 0; i--) - if (g.Windows[i] != ignore_window && g.Windows[i]->WasActive && !(g.Windows[i]->Flags & ImGuiWindowFlags_ChildWindow)) + for (int i = g.WindowsFocusOrder.Size - 1; i >= 0; i--) + { + ImGuiWindow* window = g.WindowsFocusOrder[i]; + if (window != ignore_window && window->WasActive && !(window->Flags & ImGuiWindowFlags_ChildWindow)) { - ImGuiWindow* focus_window = NavRestoreLastChildNavWindow(g.Windows[i]); + ImGuiWindow* focus_window = NavRestoreLastChildNavWindow(window); FocusWindow(focus_window); return; } + } } void ImGui::PushItemWidth(float item_width) @@ -7436,11 +7457,11 @@ static float ImGui::NavUpdatePageUpPageDown(int allowed_dir_flags) return 0.0f; } -static int FindWindowIndex(ImGuiWindow* window) // FIXME-OPT O(N) +static int FindWindowFocusIndex(ImGuiWindow* window) // FIXME-OPT O(N) { ImGuiContext& g = *GImGui; - for (int i = g.Windows.Size-1; i >= 0; i--) - if (g.Windows[i] == window) + for (int i = g.WindowsFocusOrder.Size-1; i >= 0; i--) + if (g.WindowsFocusOrder[i] == window) return i; return -1; } @@ -7448,9 +7469,9 @@ static int FindWindowIndex(ImGuiWindow* window) // FIXME-OPT O(N) static ImGuiWindow* FindWindowNavFocusable(int i_start, int i_stop, int dir) // FIXME-OPT O(N) { ImGuiContext& g = *GImGui; - for (int i = i_start; i >= 0 && i < g.Windows.Size && i != i_stop; i += dir) - if (ImGui::IsWindowNavFocusable(g.Windows[i])) - return g.Windows[i]; + for (int i = i_start; i >= 0 && i < g.WindowsFocusOrder.Size && i != i_stop; i += dir) + if (ImGui::IsWindowNavFocusable(g.WindowsFocusOrder[i])) + return g.WindowsFocusOrder[i]; return NULL; } @@ -7461,10 +7482,10 @@ static void NavUpdateWindowingHighlightWindow(int focus_change_dir) if (g.NavWindowingTarget->Flags & ImGuiWindowFlags_Modal) return; - const int i_current = FindWindowIndex(g.NavWindowingTarget); + const int i_current = FindWindowFocusIndex(g.NavWindowingTarget); ImGuiWindow* window_target = FindWindowNavFocusable(i_current + focus_change_dir, -INT_MAX, focus_change_dir); if (!window_target) - window_target = FindWindowNavFocusable((focus_change_dir < 0) ? (g.Windows.Size - 1) : 0, i_current, focus_change_dir); + window_target = FindWindowNavFocusable((focus_change_dir < 0) ? (g.WindowsFocusOrder.Size - 1) : 0, i_current, focus_change_dir); if (window_target) // Don't reset windowing target if there's a single window in the list g.NavWindowingTarget = g.NavWindowingTargetAnim = window_target; g.NavWindowingToggleLayer = false; @@ -7496,7 +7517,7 @@ static void ImGui::NavUpdateWindowing() bool start_windowing_with_gamepad = !g.NavWindowingTarget && IsNavInputPressed(ImGuiNavInput_Menu, ImGuiInputReadMode_Pressed); bool start_windowing_with_keyboard = !g.NavWindowingTarget && g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab) && (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard); if (start_windowing_with_gamepad || start_windowing_with_keyboard) - if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.Windows.Size - 1, -INT_MAX, -1)) + if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1)) { g.NavWindowingTarget = g.NavWindowingTargetAnim = window; g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f; @@ -7628,9 +7649,9 @@ void ImGui::NavUpdateWindowingList() SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f)); PushStyleVar(ImGuiStyleVar_WindowPadding, g.Style.WindowPadding * 2.0f); Begin("###NavWindowingList", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings); - for (int n = g.Windows.Size - 1; n >= 0; n--) + for (int n = g.WindowsFocusOrder.Size - 1; n >= 0; n--) { - ImGuiWindow* window = g.Windows[n]; + ImGuiWindow* window = g.WindowsFocusOrder[n]; if (!IsWindowNavFocusable(window)) continue; const char* label = window->Name; diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 2cce0dd9..c5f00616 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -207,16 +207,18 @@ void ImGui::ShowDemoWindow(bool* p_open) static bool no_collapse = false; static bool no_close = false; static bool no_nav = false; - + static bool no_bring_to_front = false; + ImGuiWindowFlags window_flags = 0; - if (no_titlebar) window_flags |= ImGuiWindowFlags_NoTitleBar; - if (no_scrollbar) window_flags |= ImGuiWindowFlags_NoScrollbar; - if (!no_menu) window_flags |= ImGuiWindowFlags_MenuBar; - if (no_move) window_flags |= ImGuiWindowFlags_NoMove; - if (no_resize) window_flags |= ImGuiWindowFlags_NoResize; - if (no_collapse) window_flags |= ImGuiWindowFlags_NoCollapse; - if (no_nav) window_flags |= ImGuiWindowFlags_NoNav; - if (no_close) p_open = NULL; // Don't pass our bool* to Begin + if (no_titlebar) window_flags |= ImGuiWindowFlags_NoTitleBar; + if (no_scrollbar) window_flags |= ImGuiWindowFlags_NoScrollbar; + if (!no_menu) window_flags |= ImGuiWindowFlags_MenuBar; + if (no_move) window_flags |= ImGuiWindowFlags_NoMove; + if (no_resize) window_flags |= ImGuiWindowFlags_NoResize; + if (no_collapse) window_flags |= ImGuiWindowFlags_NoCollapse; + if (no_nav) window_flags |= ImGuiWindowFlags_NoNav; + if (no_bring_to_front) window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus; + if (no_close) p_open = NULL; // Don't pass our bool* to Begin // We specify a default position/size in case there's no data in the .ini file. Typically this isn't required! We only do it to make the Demo applications a little more welcoming. ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); @@ -359,7 +361,8 @@ void ImGui::ShowDemoWindow(bool* p_open) ImGui::Checkbox("No resize", &no_resize); ImGui::SameLine(300); ImGui::Checkbox("No collapse", &no_collapse); ImGui::Checkbox("No close", &no_close); ImGui::SameLine(150); - ImGui::Checkbox("No nav", &no_nav); + ImGui::Checkbox("No nav", &no_nav); ImGui::SameLine(300); + ImGui::Checkbox("No bring to front", &no_bring_to_front); } if (ImGui::CollapsingHeader("Widgets")) diff --git a/imgui_internal.h b/imgui_internal.h index cedf1c32..70c6bbdd 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -649,7 +649,8 @@ struct ImGuiContext int FrameCount; int FrameCountEnded; int FrameCountRendered; - ImVector Windows; + ImVector Windows; // Windows, sorted in display order, back to front + ImVector WindowsFocusOrder; // Windows, sorted in focus order, back to front ImVector WindowsSortBuffer; ImVector CurrentWindowStack; ImGuiStorage WindowsById; @@ -1113,9 +1114,10 @@ namespace ImGui inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; } IMGUI_API ImGuiWindow* FindWindowByName(const char* name); IMGUI_API void FocusWindow(ImGuiWindow* window); - IMGUI_API void FocusFrontMostActiveWindowIgnoringOne(ImGuiWindow* ignore_window); - IMGUI_API void BringWindowToFront(ImGuiWindow* window); - IMGUI_API void BringWindowToBack(ImGuiWindow* window); + IMGUI_API void FocusPreviousWindowIgnoringOne(ImGuiWindow* ignore_window); + IMGUI_API void BringWindowToFocusFront(ImGuiWindow* window); + IMGUI_API void BringWindowToDisplayFront(ImGuiWindow* window); + IMGUI_API void BringWindowToDisplayBack(ImGuiWindow* window); IMGUI_API void UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window); IMGUI_API ImVec2 CalcWindowExpectedSize(ImGuiWindow* window); IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent); diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index f264396e..7fe4c16e 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -5448,7 +5448,7 @@ void ImGui::EndMainMenuBar() // When the user has left the menu layer (typically: closed menus through activation of an item), we restore focus to the previous window ImGuiContext& g = *GImGui; if (g.CurrentWindow == g.NavWindow && g.NavLayer == 0) - FocusFrontMostActiveWindowIgnoringOne(g.NavWindow); + FocusPreviousWindowIgnoringOne(g.NavWindow); End(); } From af6cf25255b1e88258c5fb2b47e770037de0e111 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 11 Sep 2018 10:55:52 +0200 Subject: [PATCH 05/15] DragFloat: Fixed a situation where dragging with value rounding enabled or with a power curve erroneously wrapped the value to one of the min/max edge. (#2024, #708, #320, #2075). --- docs/CHANGELOG.txt | 2 ++ imgui_widgets.cpp | 17 +++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 1d7d3e4b..d2493daf 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -41,6 +41,8 @@ Other Changes: accidental alteration of window position. We now round the provided size. (#2067) - Nav, Focus: Fixed ImGuiWindowFlags_NoBringToFrontOnFocus windows not being restoring focus properly after the main menu bar or last focused window is deactivated. +- DragFloat: Fixed a situation where dragging with value rounding enabled or with a power curve + erroneously wrapped the value to one of the min/max edge. (#2024, #708, #320, #2075). ----------------------------------------------------------------------- diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 7fe4c16e..0d9a576c 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1708,9 +1708,10 @@ template bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const TYPE v_min, const TYPE v_max, const char* format, float power) { ImGuiContext& g = *GImGui; + const bool is_decimal = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double); + const bool has_min_max = (v_min != v_max) && (v_max - v_max < FLT_MAX); // Default tweak speed - bool has_min_max = (v_min != v_max) && (v_max - v_max < FLT_MAX); if (v_speed == 0.0f && has_min_max) v_speed = (float)((v_max - v_min) * g.DragSpeedDefaultRatio); @@ -1720,14 +1721,14 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const { adjust_delta = g.IO.MouseDelta.x; if (g.IO.KeyAlt) - adjust_delta *= 1.0f/100.0f; + adjust_delta *= 1.0f / 100.0f; if (g.IO.KeyShift) adjust_delta *= 10.0f; } else if (g.ActiveIdSource == ImGuiInputSource_Nav) { - int decimal_precision = (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) ? ImParseFormatPrecision(format, 3) : 0; - adjust_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard|ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 1.0f/10.0f, 10.0f).x; + int decimal_precision = is_decimal ? ImParseFormatPrecision(format, 3) : 0; + adjust_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard | ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 1.0f / 10.0f, 10.0f).x; v_speed = ImMax(v_speed, GetMinimumStepAtDecimalPrecision(decimal_precision)); } adjust_delta *= v_speed; @@ -1753,7 +1754,7 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const TYPE v_cur = *v; FLOATTYPE v_old_ref_for_accum_remainder = (FLOATTYPE)0.0f; - const bool is_power = (power != 1.0f && (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) && has_min_max); + const bool is_power = (power != 1.0f && is_decimal && has_min_max); if (is_power) { // Offset + round to user desired precision, with a curve on the v_min..v_max range to get more precision on one side of the range @@ -1786,12 +1787,12 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const if (v_cur == (TYPE)-0) v_cur = (TYPE)0; - // Clamp values (handle overflow/wrap-around) + // Clamp values (+ handle overflow/wrap-around for integer types) if (*v != v_cur && has_min_max) { - if (v_cur < v_min || (v_cur > *v && adjust_delta < 0.0f)) + if (v_cur < v_min || (v_cur > *v && adjust_delta < 0.0f && !is_decimal)) v_cur = v_min; - if (v_cur > v_max || (v_cur < *v && adjust_delta > 0.0f)) + if (v_cur > v_max || (v_cur < *v && adjust_delta > 0.0f && !is_decimal)) v_cur = v_max; } From d014d0285a74e6749ffbb5acc403686e3a267cd8 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 11 Sep 2018 11:15:06 +0200 Subject: [PATCH 06/15] DragFloat: Disabled using power curve when one edge is FLT_MAX (broken in 1.61). Disabled setting a default drag speed when one edge is FLT_MAX. (#2024) --- docs/CHANGELOG.txt | 2 ++ imgui_demo.cpp | 4 ++-- imgui_widgets.cpp | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index d2493daf..36040548 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -43,6 +43,8 @@ Other Changes: properly after the main menu bar or last focused window is deactivated. - DragFloat: Fixed a situation where dragging with value rounding enabled or with a power curve erroneously wrapped the value to one of the min/max edge. (#2024, #708, #320, #2075). +- DragFloat: Disabled using power curve when one edge is FLT_MAX (broken in 1.61). (#2024) +- DragFloat: Disabled setting a default drag speed when one edge is FLT_MAX. (#2024) ----------------------------------------------------------------------- diff --git a/imgui_demo.cpp b/imgui_demo.cpp index c5f00616..c3aa63a3 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -2477,8 +2477,8 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref) ImGui::Checkbox("Anti-aliased lines", &style.AntiAliasedLines); ImGui::SameLine(); ShowHelpMarker("When disabling anti-aliasing lines, you'll probably want to disable borders in your style as well."); ImGui::Checkbox("Anti-aliased fill", &style.AntiAliasedFill); ImGui::PushItemWidth(100); - ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, FLT_MAX, NULL, 2.0f); - if (style.CurveTessellationTol < 0.0f) style.CurveTessellationTol = 0.10f; + ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, FLT_MAX, "%.2f", 2.0f); + if (style.CurveTessellationTol < 0.10f) style.CurveTessellationTol = 0.10f; ImGui::DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero. ImGui::PopItemWidth(); ImGui::TreePop(); diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 0d9a576c..44e7d022 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1709,10 +1709,10 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const { ImGuiContext& g = *GImGui; const bool is_decimal = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double); - const bool has_min_max = (v_min != v_max) && (v_max - v_max < FLT_MAX); + const bool has_min_max = (v_min != v_max); // Default tweak speed - if (v_speed == 0.0f && has_min_max) + if (v_speed == 0.0f && has_min_max && (v_max - v_min < FLT_MAX)) v_speed = (float)((v_max - v_min) * g.DragSpeedDefaultRatio); // Inputs accumulates into g.DragCurrentAccum, which is flushed into the current value as soon as it makes a difference with our precision settings @@ -1754,7 +1754,7 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const TYPE v_cur = *v; FLOATTYPE v_old_ref_for_accum_remainder = (FLOATTYPE)0.0f; - const bool is_power = (power != 1.0f && is_decimal && has_min_max); + const bool is_power = (power != 1.0f && is_decimal && has_min_max && (v_max - v_min < FLT_MAX)); if (is_power) { // Offset + round to user desired precision, with a curve on the v_min..v_max range to get more precision on one side of the range From f29b3b40339d7143f97bd3f7753a6eecb2f4786c Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 10 Sep 2018 22:19:54 +0200 Subject: [PATCH 07/15] Nav: Added a way for code to cancel Alt for menu toggle (ImGuiNavInput_KeyMenu_). Cancelling out on platform window. close request. (#1542, #787) --- imgui.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index aaa7eccb..d727048a 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5296,6 +5296,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) if (p_open != NULL && window->Viewport->PlatformRequestClose && window->Viewport != GetMainViewport()) { window->Viewport->PlatformRequestClose = false; + g.NavWindowingToggleLayer = false; // Assume user mapped PlatformRequestClose on ALT-F4 so we disable ALT for menu toggle. False positive not an issue. *p_open = false; } @@ -8572,7 +8573,9 @@ static void ImGui::NavUpdateWindowing() // Keyboard: Press and Release ALT to toggle menu layer // FIXME: We lack an explicit IO variable for "is the imgui window focused", so compare mouse validity to detect the common case of back-end clearing releases all keys on ALT-TAB - if ((g.ActiveId == 0 || g.ActiveIdAllowOverlap) && IsNavInputPressed(ImGuiNavInput_KeyMenu_, ImGuiInputReadMode_Released)) + if (IsNavInputPressed(ImGuiNavInput_KeyMenu_, ImGuiInputReadMode_Pressed)) + g.NavWindowingToggleLayer = true; + if ((g.ActiveId == 0 || g.ActiveIdAllowOverlap) && g.NavWindowingToggleLayer && IsNavInputPressed(ImGuiNavInput_KeyMenu_, ImGuiInputReadMode_Released)) if (IsMousePosValid(&g.IO.MousePos) == IsMousePosValid(&g.IO.MousePosPrev)) apply_toggle_layer = true; From 201fcfd2e52b4c7c03de8448e03f09fb7fd0ec26 Mon Sep 17 00:00:00 2001 From: ice1000 Date: Tue, 11 Sep 2018 12:04:45 -0400 Subject: [PATCH 08/15] Internals: Replace unsigned short with ImWchar when dealing with character storage. (#2078) --- imgui.h | 4 ++-- imgui_draw.cpp | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/imgui.h b/imgui.h index 991c20fc..3372e80f 100644 --- a/imgui.h +++ b/imgui.h @@ -1920,7 +1920,7 @@ struct ImFont ImVec2 DisplayOffset; // = (0.f,0.f) // Offset font rendering by xx pixels ImVector Glyphs; // // All glyphs. ImVector IndexAdvanceX; // // Sparse. Glyphs->AdvanceX in a directly indexable way (more cache-friendly, for CalcTextSize functions which are often bottleneck in large UI). - ImVector IndexLookup; // // Sparse. Index glyphs by Unicode code-point. + ImVector IndexLookup; // // Sparse. Index glyphs by Unicode code-point. const ImFontGlyph* FallbackGlyph; // == FindGlyph(FontFallbackChar) float FallbackAdvanceX; // == FallbackGlyph->AdvanceX ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar() @@ -1949,7 +1949,7 @@ struct ImFont // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable. IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8 IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const; - IMGUI_API void RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, unsigned short c) const; + IMGUI_API void RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const; IMGUI_API void RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, bool cpu_fine_clip = false) const; // [Internal] diff --git a/imgui_draw.cpp b/imgui_draw.cpp index dd30b476..12f094db 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1894,7 +1894,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas) continue; const int codepoint = range.first_unicode_codepoint_in_range + char_idx; - if (cfg.MergeMode && dst_font->FindGlyphNoFallback((unsigned short)codepoint)) + if (cfg.MergeMode && dst_font->FindGlyphNoFallback((ImWchar)codepoint)) continue; float char_advance_x_org = pc.xadvance; @@ -2316,21 +2316,21 @@ void ImFont::BuildLookupTable() { int codepoint = (int)Glyphs[i].Codepoint; IndexAdvanceX[codepoint] = Glyphs[i].AdvanceX; - IndexLookup[codepoint] = (unsigned short)i; + IndexLookup[codepoint] = (ImWchar)i; } // Create a glyph to handle TAB // FIXME: Needs proper TAB handling but it needs to be contextualized (or we could arbitrary say that each string starts at "column 0" ?) - if (FindGlyph((unsigned short)' ')) + if (FindGlyph((ImWchar)' ')) { if (Glyphs.back().Codepoint != '\t') // So we can call this function multiple times Glyphs.resize(Glyphs.Size + 1); ImFontGlyph& tab_glyph = Glyphs.back(); - tab_glyph = *FindGlyph((unsigned short)' '); + tab_glyph = *FindGlyph((ImWchar)' '); tab_glyph.Codepoint = '\t'; tab_glyph.AdvanceX *= 4; IndexAdvanceX[(int)tab_glyph.Codepoint] = (float)tab_glyph.AdvanceX; - IndexLookup[(int)tab_glyph.Codepoint] = (unsigned short)(Glyphs.Size-1); + IndexLookup[(int)tab_glyph.Codepoint] = (ImWchar)(Glyphs.Size-1); } FallbackGlyph = FindGlyphNoFallback(FallbackChar); @@ -2352,7 +2352,7 @@ void ImFont::GrowIndex(int new_size) if (new_size <= IndexLookup.Size) return; IndexAdvanceX.resize(new_size, -1.0f); - IndexLookup.resize(new_size, (unsigned short)-1); + IndexLookup.resize(new_size, (ImWchar)-1); } // x0/y0/x1/y1 are offset from the character upper-left layout position, in pixels. Therefore x0/y0 are often fairly close to zero. @@ -2385,13 +2385,13 @@ void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst) IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function. int index_size = IndexLookup.Size; - if (dst < index_size && IndexLookup.Data[dst] == (unsigned short)-1 && !overwrite_dst) // 'dst' already exists + if (dst < index_size && IndexLookup.Data[dst] == (ImWchar)-1 && !overwrite_dst) // 'dst' already exists return; if (src >= index_size && dst >= index_size) // both 'dst' and 'src' don't exist -> no-op return; GrowIndex(dst + 1); - IndexLookup[dst] = (src < index_size) ? IndexLookup.Data[src] : (unsigned short)-1; + IndexLookup[dst] = (src < index_size) ? IndexLookup.Data[src] : (ImWchar)-1; IndexAdvanceX[dst] = (src < index_size) ? IndexAdvanceX.Data[src] : 1.0f; } @@ -2399,8 +2399,8 @@ const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const { if (c >= IndexLookup.Size) return FallbackGlyph; - const unsigned short i = IndexLookup[c]; - if (i == (unsigned short)-1) + const ImWchar i = IndexLookup[c]; + if (i == (ImWchar)-1) return FallbackGlyph; return &Glyphs.Data[i]; } @@ -2409,8 +2409,8 @@ const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const { if (c >= IndexLookup.Size) return NULL; - const unsigned short i = IndexLookup[c]; - if (i == (unsigned short)-1) + const ImWchar i = IndexLookup[c]; + if (i == (ImWchar)-1) return NULL; return &Glyphs.Data[i]; } @@ -2608,7 +2608,7 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons return text_size; } -void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, unsigned short c) const +void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const { if (c == ' ' || c == '\t' || c == '\n' || c == '\r') // Match behavior of RenderText(), those 4 codepoints are hard-coded. return; @@ -2733,7 +2733,7 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col } float char_width = 0.0f; - if (const ImFontGlyph* glyph = FindGlyph((unsigned short)c)) + if (const ImFontGlyph* glyph = FindGlyph((ImWchar)c)) { char_width = glyph->AdvanceX * scale; From 9cc63ba27970f360380c9a5fa846172aba4c726a Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 11 Sep 2018 22:00:39 +0200 Subject: [PATCH 09/15] Internals: Replace unsigned short with ImWchar when dealing with character storage (missing cases) + in imgui_impl_ file keep using neutral type everywhere, added missing explicit cast in three bindings. (#2078) --- examples/imgui_impl_freeglut.cpp | 2 +- examples/imgui_impl_osx.mm | 2 +- imgui_widgets.cpp | 4 ++-- misc/freetype/imgui_freetype.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/imgui_impl_freeglut.cpp b/examples/imgui_impl_freeglut.cpp index b265226b..8884905d 100644 --- a/examples/imgui_impl_freeglut.cpp +++ b/examples/imgui_impl_freeglut.cpp @@ -97,7 +97,7 @@ void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y) //printf("char_down_func %d '%c'\n", c, c); ImGuiIO& io = ImGui::GetIO(); if (c >= 32) - io.AddInputCharacter(c); + io.AddInputCharacter((unsigned short)c); // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26. // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here. diff --git a/examples/imgui_impl_osx.mm b/examples/imgui_impl_osx.mm index 07494d6d..edfd4547 100644 --- a/examples/imgui_impl_osx.mm +++ b/examples/imgui_impl_osx.mm @@ -188,7 +188,7 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view) { int c = [str characterAtIndex:i]; if (c < 0xF700 && !io.KeyCtrl) - io.AddInputCharacter(c); + io.AddInputCharacter((unsigned short)c); // We must reset in case we're pressing a sequence of special keys while keeping the command pressed int key = mapCharacterToKey(c); diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 44e7d022..56cbf33d 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -2844,7 +2844,7 @@ static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* t if (c == '\r') continue; - const float char_width = font->GetCharAdvance((unsigned short)c) * scale; + const float char_width = font->GetCharAdvance((ImWchar)c) * scale; line_width += char_width; } @@ -3697,7 +3697,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2 else { ImVec2 rect_size = InputTextCalcTextSizeW(p, text_selected_end, &p, NULL, true); - if (rect_size.x <= 0.0f) rect_size.x = (float)(int)(g.Font->GetCharAdvance((unsigned short)' ') * 0.50f); // So we can see selected empty lines + if (rect_size.x <= 0.0f) rect_size.x = (float)(int)(g.Font->GetCharAdvance((ImWchar)' ') * 0.50f); // So we can see selected empty lines ImRect rect(rect_pos + ImVec2(0.0f, bg_offy_up - g.FontSize), rect_pos +ImVec2(rect_size.x, bg_offy_dn)); rect.ClipWith(clip_rect); if (rect.Overlaps(clip_rect)) diff --git a/misc/freetype/imgui_freetype.cpp b/misc/freetype/imgui_freetype.cpp index 89aa23f5..33bdb140 100644 --- a/misc/freetype/imgui_freetype.cpp +++ b/misc/freetype/imgui_freetype.cpp @@ -337,7 +337,7 @@ bool ImGuiFreeType::BuildFontAtlas(ImFontAtlas* atlas, unsigned int extra_flags) { for (uint32_t codepoint = in_range[0]; codepoint <= in_range[1]; ++codepoint) { - if (cfg.MergeMode && dst_font->FindGlyphNoFallback((unsigned short)codepoint)) + if (cfg.MergeMode && dst_font->FindGlyphNoFallback((ImWchar)codepoint)) continue; FT_Glyph ft_glyph = NULL; From ec04e8bb050ef42f25aee6e5748f4e0e153266bf Mon Sep 17 00:00:00 2001 From: Elias Daler Date: Wed, 12 Sep 2018 23:58:45 +0300 Subject: [PATCH 10/15] Fix MSVC's C4312 warning about casting user texture type to void* in ImageButton (#2080) --- imgui_widgets.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 56cbf33d..89e6f10d 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -838,7 +838,7 @@ bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const I // Default to using texture ID as ID. User can still push string/integer prefixes. // We could hash the size/uv to create a unique ID but that would prevent the user from animating UV. - PushID((void*)user_texture_id); + PushID((void*)(intptr_t)user_texture_id); const ImGuiID id = window->GetID("#image"); PopID(); From 1afd29d382407ac693fa226c4e4c1a04578e3c27 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 13 Sep 2018 16:44:08 +0200 Subject: [PATCH 11/15] Examples: Using "dear imgui" terminology in all examples headers/comments + fix minor typo. --- examples/README.txt | 6 +++--- examples/example_allegro5/main.cpp | 4 ++-- examples/example_apple_metal/Shared/ViewController.mm | 6 +++--- examples/example_apple_opengl2/main.mm | 4 ++-- examples/example_freeglut_opengl2/main.cpp | 8 ++++---- examples/example_glfw_opengl2/main.cpp | 4 ++-- examples/example_glfw_opengl3/main.cpp | 4 ++-- examples/example_glfw_vulkan/main.cpp | 4 ++-- examples/example_marmalade/main.cpp | 6 +++--- examples/example_null/main.cpp | 2 +- examples/example_sdl_opengl2/main.cpp | 4 ++-- examples/example_sdl_opengl3/main.cpp | 4 ++-- examples/example_sdl_vulkan/main.cpp | 6 +++--- examples/example_win32_directx10/main.cpp | 4 ++-- examples/example_win32_directx11/main.cpp | 4 ++-- examples/example_win32_directx12/main.cpp | 4 ++-- examples/example_win32_directx9/main.cpp | 4 ++-- examples/imgui_impl_allegro5.cpp | 6 +++--- examples/imgui_impl_allegro5.h | 2 +- examples/imgui_impl_dx10.cpp | 2 +- examples/imgui_impl_dx10.h | 2 +- examples/imgui_impl_dx11.cpp | 2 +- examples/imgui_impl_dx11.h | 2 +- examples/imgui_impl_dx12.cpp | 2 +- examples/imgui_impl_dx12.h | 2 +- examples/imgui_impl_dx9.cpp | 4 ++-- examples/imgui_impl_dx9.h | 2 +- examples/imgui_impl_freeglut.cpp | 2 +- examples/imgui_impl_freeglut.h | 2 +- examples/imgui_impl_glfw.cpp | 2 +- examples/imgui_impl_glfw.h | 2 +- examples/imgui_impl_marmalade.cpp | 4 ++-- examples/imgui_impl_marmalade.h | 6 ++---- examples/imgui_impl_metal.h | 2 +- examples/imgui_impl_metal.mm | 4 ++-- examples/imgui_impl_opengl2.cpp | 4 ++-- examples/imgui_impl_opengl2.h | 2 +- examples/imgui_impl_opengl3.cpp | 4 ++-- examples/imgui_impl_opengl3.h | 2 +- examples/imgui_impl_osx.h | 2 +- examples/imgui_impl_osx.mm | 2 +- examples/imgui_impl_sdl.cpp | 2 +- examples/imgui_impl_sdl.h | 2 +- examples/imgui_impl_vulkan.cpp | 4 ++-- examples/imgui_impl_vulkan.h | 2 +- examples/imgui_impl_win32.cpp | 2 +- examples/imgui_impl_win32.h | 2 +- 47 files changed, 78 insertions(+), 80 deletions(-) diff --git a/examples/README.txt b/examples/README.txt index a3fb441c..1ee91492 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -44,7 +44,7 @@ You can find binaries of some of those example applications at: - Dear ImGui has 0 to 1 frame of lag for most behaviors, at 60 FPS your experience should be pleasant. However, consider that OS mouse cursors are typically drawn through a specific hardware accelerated path and will feel smoother than common GPU rendered contents (including Dear ImGui windows). - You may experiment with the io.MouseDrawCursor flag to request ImGui to draw a mouse cursor itself, + You may experiment with the io.MouseDrawCursor flag to request Dear ImGui to draw a mouse cursor itself, to visualize the lag between a hardware cursor and a software cursor. However, rendering a mouse cursor at 60 FPS will feel slow. It might be beneficial to the user experience to switch to a software rendered cursor only when an interactive drag is in progress. @@ -179,7 +179,7 @@ example_glfw_opengl2/ **DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** **Prefer using OPENGL3 code (with gl3w/glew/glad, you can replace the OpenGL function loader)** GLFW + OpenGL2 example (legacy, fixed pipeline). - This code is mostly provided as a reference to learn about ImGui integration, because it is shorter. + This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter. If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to make things more complicated, will require your code to reset many OpenGL attributes to their initial state, and might confuse your GPU driver. One star, not recommended. @@ -200,7 +200,7 @@ example_sdl_opengl2/ **DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** **Prefer using OPENGL3 code (with gl3w/glew/glad, you can replace the OpenGL function loader)** SDL2 (Win32, Mac, Linux etc.) + OpenGL example (legacy, fixed pipeline). - This code is mostly provided as a reference to learn about ImGui integration, because it is shorter. + This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter. If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to make things more complicated, will require your code to reset many OpenGL attributes to their initial state, and might confuse your GPU driver. One star, not recommended. diff --git a/examples/example_allegro5/main.cpp b/examples/example_allegro5/main.cpp index 18a429f6..a5998b64 100644 --- a/examples/example_allegro5/main.cpp +++ b/examples/example_allegro5/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for Allegro 5 -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for Allegro 5 +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. #include #include diff --git a/examples/example_apple_metal/Shared/ViewController.mm b/examples/example_apple_metal/Shared/ViewController.mm index 6a9236c4..427c0928 100644 --- a/examples/example_apple_metal/Shared/ViewController.mm +++ b/examples/example_apple_metal/Shared/ViewController.mm @@ -45,9 +45,9 @@ // If we want to receive key events, we either need to be in the responder chain of the key view, // or else we can install a local monitor. The consequence of this heavy-handed approach is that - // we receive events for all controls, not just ImGui widgets. If we had native controls in our - // window, we'd want to be much more careful than just ingesting the complete event stream, though - // we do make an effort to be good citizens by passing along events when ImGui doesn't want to capture. + // we receive events for all controls, not just Dear ImGui widgets. If we had native controls in our + // window, we'd want to be much more careful than just ingesting the complete event stream, though we + // do make an effort to be good citizens by passing along events when Dear ImGui doesn't want to capture. NSEventMask eventMask = NSEventMaskKeyDown | NSEventMaskKeyUp | NSEventMaskFlagsChanged | NSEventTypeScrollWheel; [NSEvent addLocalMonitorForEventsMatchingMask:eventMask handler:^NSEvent * _Nullable(NSEvent *event) { BOOL wantsCapture = ImGui_ImplOSX_HandleEvent(event, self.view); diff --git a/examples/example_apple_opengl2/main.mm b/examples/example_apple_opengl2/main.mm index cd5dd941..5eb8b19b 100644 --- a/examples/example_apple_opengl2/main.mm +++ b/examples/example_apple_opengl2/main.mm @@ -1,5 +1,5 @@ -// ImGui - standalone example application for OSX + OpenGL2, using legacy fixed pipeline -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for OSX + OpenGL2, using legacy fixed pipeline +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. #include "imgui.h" #include "../imgui_impl_osx.h" diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp index 8b489dd6..d57ee07f 100644 --- a/examples/example_freeglut_opengl2/main.cpp +++ b/examples/example_freeglut_opengl2/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. // (Using GLUT or FreeGLUT is not recommended unless you really miss the 90's) #include "imgui.h" @@ -57,7 +57,7 @@ void my_display_code() void glut_display_func() { - // Start the ImGui frame + // Start the Dear ImGui frame ImGui_ImplOpenGL2_NewFrame(); ImGui_ImplFreeGLUT_NewFrame(); @@ -95,7 +95,7 @@ int main(int argc, char** argv) // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves. glutDisplayFunc(glut_display_func); - // Setup ImGui binding + // Setup Dear ImGui binding ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io; //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls diff --git a/examples/example_glfw_opengl2/main.cpp b/examples/example_glfw_opengl2/main.cpp index db99c8d0..e6e53c82 100644 --- a/examples/example_glfw_opengl2/main.cpp +++ b/examples/example_glfw_opengl2/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for GLFW + OpenGL2, using legacy fixed pipeline -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for GLFW + OpenGL2, using legacy fixed pipeline +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. // (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) // **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** diff --git a/examples/example_glfw_opengl3/main.cpp b/examples/example_glfw_opengl3/main.cpp index 2795ff49..f9b9b643 100644 --- a/examples/example_glfw_opengl3/main.cpp +++ b/examples/example_glfw_opengl3/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for GLFW + OpenGL 3, using programmable pipeline -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for GLFW + OpenGL 3, using programmable pipeline +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. // (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) #include "imgui.h" diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp index 5ca9e9c9..8e875fe1 100644 --- a/examples/example_glfw_vulkan/main.cpp +++ b/examples/example_glfw_vulkan/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for Glfw + Vulkan -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for Glfw + Vulkan +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. #include "imgui.h" #include "imgui_impl_glfw.h" diff --git a/examples/example_marmalade/main.cpp b/examples/example_marmalade/main.cpp index 41c65953..92316a67 100644 --- a/examples/example_marmalade/main.cpp +++ b/examples/example_marmalade/main.cpp @@ -1,8 +1,8 @@ -// ImGui - standalone example application for Marmalade -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for Marmalade +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. // Copyright (C) 2015 by Giovanni Zito -// This file is part of ImGui +// This file is part of Dear ImGui #include "imgui.h" #include "imgui_impl_marmalade.h" diff --git a/examples/example_null/main.cpp b/examples/example_null/main.cpp index 547ed3c1..90521f9b 100644 --- a/examples/example_null/main.cpp +++ b/examples/example_null/main.cpp @@ -1,4 +1,4 @@ -// ImGui - null/dummy example application (compile and link imgui with no inputs, no outputs) +// dear imgui: null/dummy example application (compile and link imgui with no inputs, no outputs) #include "imgui.h" #include diff --git a/examples/example_sdl_opengl2/main.cpp b/examples/example_sdl_opengl2/main.cpp index 1a1079b7..7e92b853 100644 --- a/examples/example_sdl_opengl2/main.cpp +++ b/examples/example_sdl_opengl2/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for SDL2 + OpenGL -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for SDL2 + OpenGL +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. // (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) // **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** diff --git a/examples/example_sdl_opengl3/main.cpp b/examples/example_sdl_opengl3/main.cpp index 156520f7..577e84c4 100644 --- a/examples/example_sdl_opengl3/main.cpp +++ b/examples/example_sdl_opengl3/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for SDL2 + OpenGL -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for SDL2 + OpenGL +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. // (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) // (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.) diff --git a/examples/example_sdl_vulkan/main.cpp b/examples/example_sdl_vulkan/main.cpp index 29ad434e..0af71bec 100644 --- a/examples/example_sdl_vulkan/main.cpp +++ b/examples/example_sdl_vulkan/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for SDL2 + Vulkan -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for SDL2 + Vulkan +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. #include "imgui.h" #include "imgui_impl_sdl.h" @@ -332,7 +332,7 @@ int main(int, char**) ImGui_ImplVulkanH_WindowData* wd = &g_WindowData; SetupVulkanWindowData(wd, surface, w, h); - // Setup ImGui binding + // Setup Dear ImGui binding ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io; //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls diff --git a/examples/example_win32_directx10/main.cpp b/examples/example_win32_directx10/main.cpp index 29d25fca..bc688c9c 100644 --- a/examples/example_win32_directx10/main.cpp +++ b/examples/example_win32_directx10/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for DirectX 10 -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for DirectX 10 +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. #include "imgui.h" #include "imgui_impl_win32.h" diff --git a/examples/example_win32_directx11/main.cpp b/examples/example_win32_directx11/main.cpp index c98e6392..446ad62b 100644 --- a/examples/example_win32_directx11/main.cpp +++ b/examples/example_win32_directx11/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for DirectX 11 -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui - standalone example application for DirectX 11 +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. #include "imgui.h" #include "imgui_impl_win32.h" diff --git a/examples/example_win32_directx12/main.cpp b/examples/example_win32_directx12/main.cpp index a4ce237e..50cb3777 100644 --- a/examples/example_win32_directx12/main.cpp +++ b/examples/example_win32_directx12/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for DirectX 12 -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for DirectX 12 +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. // FIXME: 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*)) #include "imgui.h" diff --git a/examples/example_win32_directx9/main.cpp b/examples/example_win32_directx9/main.cpp index 6731b571..7e5b957a 100644 --- a/examples/example_win32_directx9/main.cpp +++ b/examples/example_win32_directx9/main.cpp @@ -1,5 +1,5 @@ -// ImGui - standalone example application for DirectX 9 -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// dear imgui: standalone example application for DirectX 9 +// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. #include "imgui.h" #include "imgui_impl_dx9.h" diff --git a/examples/imgui_impl_allegro5.cpp b/examples/imgui_impl_allegro5.cpp index b1e96325..ef99bf15 100644 --- a/examples/imgui_impl_allegro5.cpp +++ b/examples/imgui_impl_allegro5.cpp @@ -1,4 +1,4 @@ -// ImGui Renderer + Platform Binding for: Allegro 5 +// dear imgui: Renderer + Platform Binding for Allegro 5 // (Info: Allegro 5 is a cross-platform general purpose library for handling windows, inputs, graphics, etc.) // Implemented features: @@ -74,7 +74,7 @@ void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data) al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA); // Setup orthographic projection matrix - // Our visible imgui space lies from draw_data->DisplayPps (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). + // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). { float L = draw_data->DisplayPos.x; float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x; @@ -108,7 +108,7 @@ void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data) const int* indices = NULL; if (sizeof(ImDrawIdx) == 2) { - // FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices.. You can '#define ImDrawIdx int' in imconfig.h to request ImGui to output 32-bit indices. + // FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices.. You can '#define ImDrawIdx int' in imconfig.h to request Dear ImGui to output 32-bit indices. // Otherwise, we convert them from 16-bit to 32-bit at runtime here, which works perfectly but is a little wasteful. static ImVector indices_converted; indices_converted.resize(cmd_list->IdxBuffer.Size); diff --git a/examples/imgui_impl_allegro5.h b/examples/imgui_impl_allegro5.h index 053f87fa..a7792bcc 100644 --- a/examples/imgui_impl_allegro5.h +++ b/examples/imgui_impl_allegro5.h @@ -1,4 +1,4 @@ -// ImGui Renderer + Platform Binding for: Allegro 5 +// dear imgui: Renderer + Platform Binding for Allegro 5 // (Info: Allegro 5 is a cross-platform general purpose library for handling windows, inputs, graphics, etc.) // Implemented features: diff --git a/examples/imgui_impl_dx10.cpp b/examples/imgui_impl_dx10.cpp index d0734efc..f8fdef82 100644 --- a/examples/imgui_impl_dx10.cpp +++ b/examples/imgui_impl_dx10.cpp @@ -1,4 +1,4 @@ -// ImGui Renderer for: DirectX10 +// dear imgui: Renderer for DirectX10 // This needs to be used along with a Platform Binding (e.g. Win32) // Implemented features: diff --git a/examples/imgui_impl_dx10.h b/examples/imgui_impl_dx10.h index 424d7182..263073ef 100644 --- a/examples/imgui_impl_dx10.h +++ b/examples/imgui_impl_dx10.h @@ -1,4 +1,4 @@ -// ImGui Renderer for: DirectX10 +// dear imgui: Renderer for DirectX10 // This needs to be used along with a Platform Binding (e.g. Win32) // Implemented features: diff --git a/examples/imgui_impl_dx11.cpp b/examples/imgui_impl_dx11.cpp index 2f6f5a79..052f484f 100644 --- a/examples/imgui_impl_dx11.cpp +++ b/examples/imgui_impl_dx11.cpp @@ -1,4 +1,4 @@ -// ImGui Renderer for: DirectX11 +// dear imgui: Renderer for DirectX11 // This needs to be used along with a Platform Binding (e.g. Win32) // Implemented features: diff --git a/examples/imgui_impl_dx11.h b/examples/imgui_impl_dx11.h index 38dae30d..724b4696 100644 --- a/examples/imgui_impl_dx11.h +++ b/examples/imgui_impl_dx11.h @@ -1,4 +1,4 @@ -// ImGui Renderer for: DirectX11 +// dear imgui: Renderer for DirectX11 // This needs to be used along with a Platform Binding (e.g. Win32) // Implemented features: diff --git a/examples/imgui_impl_dx12.cpp b/examples/imgui_impl_dx12.cpp index a8b1c708..a59939e0 100644 --- a/examples/imgui_impl_dx12.cpp +++ b/examples/imgui_impl_dx12.cpp @@ -1,4 +1,4 @@ -// ImGui Renderer for: DirectX12 +// dear imgui: Renderer for DirectX12 // This needs to be used along with a Platform Binding (e.g. Win32) // Implemented features: diff --git a/examples/imgui_impl_dx12.h b/examples/imgui_impl_dx12.h index 823ac324..8c462547 100644 --- a/examples/imgui_impl_dx12.h +++ b/examples/imgui_impl_dx12.h @@ -1,4 +1,4 @@ -// ImGui Renderer for: DirectX12 +// dear imgui: Renderer for DirectX12 // This needs to be used along with a Platform Binding (e.g. Win32) // Implemented features: diff --git a/examples/imgui_impl_dx9.cpp b/examples/imgui_impl_dx9.cpp index d5bbc280..4aa139d4 100644 --- a/examples/imgui_impl_dx9.cpp +++ b/examples/imgui_impl_dx9.cpp @@ -1,4 +1,4 @@ -// ImGui Renderer for: DirectX9 +// dear imgui: Renderer for DirectX9 // This needs to be used along with a Platform Binding (e.g. Win32) // Implemented features: @@ -140,7 +140,7 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data) g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); // Setup orthographic projection matrix - // Our visible imgui space lies from draw_data->DisplayPps (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). + // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). // Being agnostic of whether or can be used, we aren't relying on D3DXMatrixIdentity()/D3DXMatrixOrthoOffCenterLH() or DirectX::XMMatrixIdentity()/DirectX::XMMatrixOrthographicOffCenterLH() { float L = draw_data->DisplayPos.x + 0.5f; diff --git a/examples/imgui_impl_dx9.h b/examples/imgui_impl_dx9.h index 8c91364d..03da1bda 100644 --- a/examples/imgui_impl_dx9.h +++ b/examples/imgui_impl_dx9.h @@ -1,4 +1,4 @@ -// ImGui Renderer for: DirectX9 +// dear imgui: Renderer for DirectX9 // This needs to be used along with a Platform Binding (e.g. Win32) // Implemented features: diff --git a/examples/imgui_impl_freeglut.cpp b/examples/imgui_impl_freeglut.cpp index 8884905d..983bfd68 100644 --- a/examples/imgui_impl_freeglut.cpp +++ b/examples/imgui_impl_freeglut.cpp @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: FreeGLUT +// dear imgui: Platform Binding for FreeGLUT // This needs to be used along with a Renderer (e.g. OpenGL2) // Issues: diff --git a/examples/imgui_impl_freeglut.h b/examples/imgui_impl_freeglut.h index b6b88973..fc030bb9 100644 --- a/examples/imgui_impl_freeglut.h +++ b/examples/imgui_impl_freeglut.h @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: FreeGLUT +// dear imgui: Platform Binding for FreeGLUT // This needs to be used along with a Renderer (e.g. OpenGL2) // Issues: diff --git a/examples/imgui_impl_glfw.cpp b/examples/imgui_impl_glfw.cpp index fe7a2191..82ccb7a2 100644 --- a/examples/imgui_impl_glfw.cpp +++ b/examples/imgui_impl_glfw.cpp @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: GLFW +// dear imgui: Platform Binding for GLFW // This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..) // (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) diff --git a/examples/imgui_impl_glfw.h b/examples/imgui_impl_glfw.h index 8a68f447..0b5bc89e 100644 --- a/examples/imgui_impl_glfw.h +++ b/examples/imgui_impl_glfw.h @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: GLFW +// dear imgui: Platform Binding for GLFW // This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..) // (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) diff --git a/examples/imgui_impl_marmalade.cpp b/examples/imgui_impl_marmalade.cpp index 23ced8ff..d3aa6983 100644 --- a/examples/imgui_impl_marmalade.cpp +++ b/examples/imgui_impl_marmalade.cpp @@ -1,5 +1,5 @@ -// ImGui Renderer + Platform Binding for: Marmalade + IwGx -// Marmalade code: Copyright (C) 2015 by Giovanni Zito (this file is part of ImGui) +// dear imgui: Renderer + Platform Binding for Marmalade + IwGx +// Marmalade code: Copyright (C) 2015 by Giovanni Zito (this file is part of Dear ImGui) // Implemented features: // [X] Renderer: User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. diff --git a/examples/imgui_impl_marmalade.h b/examples/imgui_impl_marmalade.h index 01769b94..96c43337 100644 --- a/examples/imgui_impl_marmalade.h +++ b/examples/imgui_impl_marmalade.h @@ -1,4 +1,5 @@ -// ImGui Renderer + Platform Binding for: Marmalade + IwGx +// dear imgui: Renderer + Platform Binding for Marmalade + IwGx +// Marmalade code: Copyright (C) 2015 by Giovanni Zito (this file is part of Dear ImGui) // Implemented features: // [X] Renderer: User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. @@ -7,9 +8,6 @@ // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui -// Copyright (C) 2015 by Giovanni Zito -// This file is part of ImGui - IMGUI_IMPL_API bool ImGui_Marmalade_Init(bool install_callbacks); IMGUI_IMPL_API void ImGui_Marmalade_Shutdown(); IMGUI_IMPL_API void ImGui_Marmalade_NewFrame(); diff --git a/examples/imgui_impl_metal.h b/examples/imgui_impl_metal.h index c4f958b4..f6846851 100644 --- a/examples/imgui_impl_metal.h +++ b/examples/imgui_impl_metal.h @@ -1,4 +1,4 @@ -// ImGui Renderer for: Metal +// dear imgui: Renderer for Metal // This needs to be used along with a Platform Binding (e.g. OSX) // Implemented features: diff --git a/examples/imgui_impl_metal.mm b/examples/imgui_impl_metal.mm index 678cd269..fc6254c0 100644 --- a/examples/imgui_impl_metal.mm +++ b/examples/imgui_impl_metal.mm @@ -1,4 +1,4 @@ -// ImGui Renderer for: Metal +// dear imgui: Renderer for Metal // This needs to be used along with a Platform Binding (e.g. OSX) // Implemented features: @@ -408,7 +408,7 @@ void ImGui_ImplMetal_DestroyDeviceObjects() [commandEncoder setDepthStencilState:g_sharedMetalContext.depthStencilState]; // Setup viewport, orthographic projection matrix - // Our visible imgui space lies from draw_data->DisplayPps (top left) to + // Our visible imgui space lies from draw_data->DisplayPos (top left) to // draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is typically (0,0) for single viewport apps. MTLViewport viewport = { diff --git a/examples/imgui_impl_opengl2.cpp b/examples/imgui_impl_opengl2.cpp index 3ff1cf72..5acf12f1 100644 --- a/examples/imgui_impl_opengl2.cpp +++ b/examples/imgui_impl_opengl2.cpp @@ -1,4 +1,4 @@ -// ImGui Renderer for: OpenGL2 (legacy OpenGL, fixed pipeline) +// dear imgui: Renderer for OpenGL2 (legacy OpenGL, fixed pipeline) // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) // Implemented features: @@ -102,7 +102,7 @@ void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data) //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound // Setup viewport, orthographic projection matrix - // Our visible imgui space lies from draw_data->DisplayPps (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is typically (0,0) for single viewport apps. + // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is typically (0,0) for single viewport apps. glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height); glMatrixMode(GL_PROJECTION); glPushMatrix(); diff --git a/examples/imgui_impl_opengl2.h b/examples/imgui_impl_opengl2.h index 930d449c..911447a4 100644 --- a/examples/imgui_impl_opengl2.h +++ b/examples/imgui_impl_opengl2.h @@ -1,4 +1,4 @@ -// ImGui Renderer for: OpenGL2 (legacy OpenGL, fixed pipeline) +// dear imgui: Renderer for OpenGL2 (legacy OpenGL, fixed pipeline) // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) // Implemented features: diff --git a/examples/imgui_impl_opengl3.cpp b/examples/imgui_impl_opengl3.cpp index 73fa3da5..04a56e07 100644 --- a/examples/imgui_impl_opengl3.cpp +++ b/examples/imgui_impl_opengl3.cpp @@ -1,4 +1,4 @@ -// ImGui Renderer for: OpenGL3 / OpenGL ES2 / OpenGL ES3 (modern OpenGL with shaders / programmatic pipeline) +// dear imgui: Renderer for OpenGL3 / OpenGL ES2 / OpenGL ES3 (modern OpenGL with shaders / programmatic pipeline) // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) // (Note: We are using GL3W as a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc..) @@ -175,7 +175,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data) #endif // Setup viewport, orthographic projection matrix - // Our visible imgui space lies from draw_data->DisplayPps (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is typically (0,0) for single viewport apps. + // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is typically (0,0) for single viewport apps. glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height); float L = draw_data->DisplayPos.x; float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x; diff --git a/examples/imgui_impl_opengl3.h b/examples/imgui_impl_opengl3.h index 2812dac5..4c3321fc 100644 --- a/examples/imgui_impl_opengl3.h +++ b/examples/imgui_impl_opengl3.h @@ -1,4 +1,4 @@ -// ImGui Renderer for: OpenGL3 / OpenGL ES2 / OpenGL ES3 (modern OpenGL with shaders / programmatic pipeline) +// dear imgui: Renderer for OpenGL3 / OpenGL ES2 / OpenGL ES3 (modern OpenGL with shaders / programmatic pipeline) // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) // (Note: We are using GL3W as a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc..) diff --git a/examples/imgui_impl_osx.h b/examples/imgui_impl_osx.h index 1ae2cc01..b7f41cbc 100644 --- a/examples/imgui_impl_osx.h +++ b/examples/imgui_impl_osx.h @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: OSX / Cocoa +// dear imgui: Platform Binding for OSX / Cocoa // This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan, Metal..) // [BETA] Beta bindings, not well tested. If you want a portable application, prefer using the Glfw or SDL platform bindings on Mac. diff --git a/examples/imgui_impl_osx.mm b/examples/imgui_impl_osx.mm index edfd4547..b1dbe7c4 100644 --- a/examples/imgui_impl_osx.mm +++ b/examples/imgui_impl_osx.mm @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: OSX / Cocoa +// dear imgui: Platform Binding for OSX / Cocoa // This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan, Metal..) // [BETA] Beta bindings, not well tested. If you want a portable application, prefer using the Glfw or SDL platform bindings on Mac. diff --git a/examples/imgui_impl_sdl.cpp b/examples/imgui_impl_sdl.cpp index 0885ce58..0189468c 100644 --- a/examples/imgui_impl_sdl.cpp +++ b/examples/imgui_impl_sdl.cpp @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: SDL2 +// dear imgui: Platform Binding for SDL2 // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) // (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.) diff --git a/examples/imgui_impl_sdl.h b/examples/imgui_impl_sdl.h index d723bf42..ec75af42 100644 --- a/examples/imgui_impl_sdl.h +++ b/examples/imgui_impl_sdl.h @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: SDL2 +// dear imgui: Platform Binding for SDL2 // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) // (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.) diff --git a/examples/imgui_impl_vulkan.cpp b/examples/imgui_impl_vulkan.cpp index 36639632..c1d10301 100644 --- a/examples/imgui_impl_vulkan.cpp +++ b/examples/imgui_impl_vulkan.cpp @@ -1,4 +1,4 @@ -// ImGui Renderer for: Vulkan +// dear imgui: Renderer for Vulkan // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) // Missing features: @@ -273,7 +273,7 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm } // Setup scale and translation: - // Our visible imgui space lies from draw_data->DisplayPps (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is typically (0,0) for single viewport apps. + // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is typically (0,0) for single viewport apps. { float scale[2]; scale[0] = 2.0f / draw_data->DisplaySize.x; diff --git a/examples/imgui_impl_vulkan.h b/examples/imgui_impl_vulkan.h index 7690ff2e..ca0c2b50 100644 --- a/examples/imgui_impl_vulkan.h +++ b/examples/imgui_impl_vulkan.h @@ -1,4 +1,4 @@ -// ImGui Renderer for: Vulkan +// dear imgui: Renderer for Vulkan // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) // Missing features: diff --git a/examples/imgui_impl_win32.cpp b/examples/imgui_impl_win32.cpp index e713b8d3..d6935a4b 100644 --- a/examples/imgui_impl_win32.cpp +++ b/examples/imgui_impl_win32.cpp @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: Windows (standard windows API for 32 and 64 bits applications) +// dear imgui: Platform Binding for Windows (standard windows API for 32 and 64 bits applications) // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) // Implemented features: diff --git a/examples/imgui_impl_win32.h b/examples/imgui_impl_win32.h index f50e6542..6b91f48b 100644 --- a/examples/imgui_impl_win32.h +++ b/examples/imgui_impl_win32.h @@ -1,4 +1,4 @@ -// ImGui Platform Binding for: Windows (standard windows API for 32 and 64 bits applications) +// dear imgui: Platform Binding for Windows (standard windows API for 32 and 64 bits applications) // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) // Implemented features: From 85a3fb3bef7261fd5ccd247c36c0edeb4a1005ec Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 13 Sep 2018 17:11:06 +0200 Subject: [PATCH 12/15] Viewport: Fix an issue introduced on ~August 16, which would assert when viewport are disabled. Also made the DestroyPlatformWindow process more sturdy. (#1542) --- imgui.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index d727048a..86f41189 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7656,17 +7656,20 @@ void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport) g.PlatformIO.Renderer_DestroyWindow(viewport); if (viewport->CreatedPlatformWindow && g.PlatformIO.Platform_DestroyWindow) g.PlatformIO.Platform_DestroyWindow(viewport); - viewport->CreatedPlatformWindow = false; IM_ASSERT(viewport->RendererUserData == NULL); - IM_ASSERT(viewport->PlatformUserData == NULL && viewport->PlatformHandle == NULL); + IM_ASSERT(viewport->PlatformUserData == NULL); + viewport->PlatformHandle = NULL; + viewport->RendererUserData = viewport->PlatformHandle = NULL; + viewport->CreatedPlatformWindow = false; } void ImGui::DestroyPlatformWindows() { // We call the destroy window on the main viewport (index 0) to give a chance to the back-end to clear any data - // have stored in e.g. PlatformHandle. - // It is expected that the back-end stored a flag to remember that it doesn't own the window created for the - // main viewport, and won't destroy the underlying platform/renderer data. + // have stored in e.g. PlatformUserData, RendererUserData. It can be convenient for the platform back-end code to + // store something in the main viewport, in order for e.g. the mouse handling code to work in a more generic manner. + // It is expected that the back-end can handle calls to Renderer_DestroyWindow/Platform_DestroyWindow without + // crashing if it doesn't have data stored. ImGuiContext& g = *GImGui; for (int i = 0; i < g.Viewports.Size; i++) if (g.Viewports[i]->CreatedPlatformWindow) From ca5dc0c019cea6dfec5c32a2825b16dac49ad1e3 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 14 Sep 2018 10:05:53 +0200 Subject: [PATCH 13/15] ColorPicker: Replaced the Separator with a Spacing call. (#2068) --- imgui_widgets.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 89e6f10d..9668e443 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -3922,7 +3922,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag if (label != label_display_end) { TextUnformatted(label, label_display_end); - Separator(); + Spacing(); } ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar; ImGuiColorEditFlags picker_flags = (flags_untouched & picker_flags_to_forward) | ImGuiColorEditFlags__InputsMask | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf; From c12da2a60798d2b71b3804063c4de4d0653ef1a0 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 14 Sep 2018 11:27:18 +0200 Subject: [PATCH 14/15] BeginMenu(): Fixed menu popup horizontal offset being off the item in the menu bar when WindowPadding=0.0f. --- docs/CHANGELOG.txt | 1 + imgui_widgets.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 36040548..fc378283 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -45,6 +45,7 @@ Other Changes: erroneously wrapped the value to one of the min/max edge. (#2024, #708, #320, #2075). - DragFloat: Disabled using power curve when one edge is FLT_MAX (broken in 1.61). (#2024) - DragFloat: Disabled setting a default drag speed when one edge is FLT_MAX. (#2024) +- BeginMenu(): Fixed menu popup horizontal offset being off the item in the menu bar when WindowPadding=0.0f. ----------------------------------------------------------------------- diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 9668e443..2f559579 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -5548,7 +5548,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled) // Menu inside an horizontal menu bar // Selectable extend their highlight by half ItemSpacing in each direction. // For ChildMenu, the popup position will be overwritten by the call to FindBestWindowPosForPopup() in Begin() - popup_pos = ImVec2(pos.x - window->WindowPadding.x, pos.y - style.FramePadding.y + window->MenuBarHeight()); + popup_pos = ImVec2(pos.x - 1.0f - (float)(int)(style.ItemSpacing.x * 0.5f), pos.y - style.FramePadding.y + window->MenuBarHeight()); window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * 0.5f); PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing * 2.0f); float w = label_size.x; From 132d8c5a9943cb9d4b92860b4dca1c7540c4b156 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 14 Sep 2018 11:37:17 +0200 Subject: [PATCH 15/15] Viewport: Increased threshold for setting ImGuiViewportFlags_NoFocusOnAppearing. (#1542), 2 doesn't seem enough with some docking setup. --- imgui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 86f41189..31bd521c 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7552,7 +7552,7 @@ void ImGui::UpdatePlatformWindows() // Show window. On startup ensure platform window don't get focus if (is_new_window) { - if (g.FrameCount < 2) + if (g.FrameCount < 3) // Give a few frames for the application to stabilize (nested contents may lead to viewport being created a few frames late) viewport->Flags |= ImGuiViewportFlags_NoFocusOnAppearing; g.PlatformIO.Platform_ShowWindow(viewport); }