Skip to content

Commit

Permalink
fixed dragging issue where plots that were not mouse-clicked would be…
Browse files Browse the repository at this point in the history
… dragged
  • Loading branch information
epezent committed Jun 6, 2020
1 parent 4be885b commit 523ae3a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
24 changes: 14 additions & 10 deletions implot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,19 +1143,23 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons
break;
}
}

if (direction == 0) {
ImGui::SetMouseCursor(ImGuiMouseCursor_NotAllowed);
} else if (direction == (1 << 1)) {
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW);
} else if (direction == (1 << 2)) {
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeNS);
} else {
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeAll);
if (IO.MouseDragMaxDistanceSqr[0] > 5) {
if (direction == 0) {
ImGui::SetMouseCursor(ImGuiMouseCursor_NotAllowed);
}
else if (direction == (1 << 1)) {
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW);
}
else if (direction == (1 << 2)) {
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeNS);
}
else {
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeAll);
}
}
}
// start drag
if (!drag_in_progress && gp.Hov_Frame && IO.MouseDragMaxDistanceSqr[0] > 5 && !plot.Selecting && !hov_legend && !hov_query && !plot.DraggingQuery) {
if (!drag_in_progress && gp.Hov_Frame && IO.MouseClicked[0] && !plot.Selecting && !hov_legend && !hov_query && !plot.DraggingQuery) {
if (hov_x_axis_region) {
plot.XAxis.Dragging = true;
}
Expand Down
1 change: 0 additions & 1 deletion implot_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,6 @@ void ShowDemoWindow(bool* p_open) {
static BenchmarkItem items[n_items];
ImGui::BulletText("Make sure VSync is disabled.");
ImGui::BulletText("%d lines with %d points each @ %.3f FPS.",n_items,1000,ImGui::GetIO().Framerate);
SetNextPlotLimits(0,1,0,1, ImGuiCond_Always);
if (ImPlot::BeginPlot("##Bench",NULL,NULL,ImVec2(-1,0),ImPlotFlags_Default | ImPlotFlags_NoChild)) {
char buff[16];
for (int i = 0; i < 100; ++i) {
Expand Down

0 comments on commit 523ae3a

Please sign in to comment.