From cc5e1daa5c7f2335a9460ae79c829011dc5cef2d Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 26 Jun 2023 18:25:53 +0200 Subject: [PATCH] Fixes for 1.89.7 + new ImGuiButtonFlags_AllowOverlap behavior handled by ButtonBehavior() fixes other items from hovering while dragging plot. --- implot.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/implot.cpp b/implot.cpp index 2b9dacea..9b2293cf 100644 --- a/implot.cpp +++ b/implot.cpp @@ -133,6 +133,11 @@ You can read releases logs https://github.com/epezent/implot/releases for more d #define ImDrawFlags_RoundCornersAll ImDrawCornerFlags_All #endif +// Support for pre-1.89.7 versions. +#if (IMGUI_VERSION_NUM < 18966) +#define ImGuiButtonFlags_AllowOverlap ImGuiButtonFlags_AllowItemOverlap +#endif + // Visual Studio warnings #ifdef _MSC_VER #pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen @@ -1808,7 +1813,7 @@ bool UpdateInput(ImPlotPlot& plot) { // BUTTON STATE ----------------------------------------------------------- - const ImGuiButtonFlags plot_button_flags = ImGuiButtonFlags_AllowItemOverlap + const ImGuiButtonFlags plot_button_flags = ImGuiButtonFlags_AllowOverlap | ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_MouseButtonLeft @@ -1818,7 +1823,9 @@ bool UpdateInput(ImPlotPlot& plot) { | plot_button_flags; const bool plot_clicked = ImGui::ButtonBehavior(plot.PlotRect,plot.ID,&plot.Hovered,&plot.Held,plot_button_flags); - ImGui::SetItemAllowOverlap(); +#if (IMGUI_VERSION_NUM < 18966) + ImGui::SetItemAllowOverlap(); // Handled by ButtonBehavior() +#endif if (plot_clicked) { if (!ImHasFlag(plot.Flags, ImPlotFlags_NoBoxSelect) && IO.MouseClicked[gp.InputMap.Select] && ImHasFlag(IO.KeyMods, gp.InputMap.SelectMod)) {