1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-11-26 12:18:52 -05:00

check for HoveredIdPreviousFrame incase there is another widget on top of us added via SetItemAllowOverlap, if the previously hovered id does not match our id set our hover flags to false

This commit is contained in:
Max Thrun 2020-09-16 21:46:33 -07:00 committed by Max Thrun
parent 04cc84ece0
commit 2ac10e73b0

View File

@ -1262,11 +1262,13 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons
frame_size.y = gp.Style.PlotMinSize.y; frame_size.y = gp.Style.PlotMinSize.y;
gp.BB_Frame = ImRect(Window->DC.CursorPos, Window->DC.CursorPos + frame_size); gp.BB_Frame = ImRect(Window->DC.CursorPos, Window->DC.CursorPos + frame_size);
ImGui::ItemSize(gp.BB_Frame); ImGui::ItemSize(gp.BB_Frame);
if (!ImGui::ItemAdd(gp.BB_Frame, 0, &gp.BB_Frame)) { if (!ImGui::ItemAdd(gp.BB_Frame, ID, &gp.BB_Frame)) {
Reset(GImPlot); Reset(GImPlot);
return false; return false;
} }
gp.Hov_Frame = ImGui::ItemHoverable(gp.BB_Frame, ID); gp.Hov_Frame = ImGui::ItemHoverable(gp.BB_Frame, ID);
if (G.HoveredIdPreviousFrame != 0 && G.HoveredIdPreviousFrame != ID)
gp.Hov_Frame = false;
ImGui::RenderFrame(gp.BB_Frame.Min, gp.BB_Frame.Max, GetStyleColorU32(ImPlotCol_FrameBg), true, Style.FrameRounding); ImGui::RenderFrame(gp.BB_Frame.Min, gp.BB_Frame.Max, GetStyleColorU32(ImPlotCol_FrameBg), true, Style.FrameRounding);
// canvas bb // canvas bb
@ -1325,7 +1327,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons
// (5) calc plot bb // (5) calc plot bb
gp.BB_Plot = ImRect(gp.BB_Canvas.Min + ImVec2(pad_left, pad_top), gp.BB_Canvas.Max - ImVec2(pad_right, pad_bot)); gp.BB_Plot = ImRect(gp.BB_Canvas.Min + ImVec2(pad_left, pad_top), gp.BB_Canvas.Max - ImVec2(pad_right, pad_bot));
gp.Hov_Plot = gp.BB_Plot.Contains(IO.MousePos); gp.Hov_Plot = gp.BB_Plot.Contains(IO.MousePos) && gp.Hov_Frame;
// x axis region bb and hover // x axis region bb and hover
const ImRect xAxisRegion_bb(gp.BB_Plot.GetBL(), ImVec2(gp.BB_Plot.Max.x, gp.BB_Frame.Max.y)); const ImRect xAxisRegion_bb(gp.BB_Plot.GetBL(), ImVec2(gp.BB_Plot.Max.x, gp.BB_Frame.Max.y));