1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-10-09 23:57:26 -04:00

fixed dragging issue where plots that were not mouse-clicked would be dragged

This commit is contained in:
Evan Pezent 2020-06-06 17:54:46 -05:00
parent 4be885bf57
commit 523ae3aef4
2 changed files with 14 additions and 11 deletions

View File

@ -1143,19 +1143,23 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons
break;
}
}
if (IO.MouseDragMaxDistanceSqr[0] > 5) {
if (direction == 0) {
ImGui::SetMouseCursor(ImGuiMouseCursor_NotAllowed);
} else if (direction == (1 << 1)) {
}
else if (direction == (1 << 1)) {
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW);
} else if (direction == (1 << 2)) {
}
else if (direction == (1 << 2)) {
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeNS);
} else {
}
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;
}

View File

@ -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) {