From ce79420146ba088978a9a9a103163326b6cc20db Mon Sep 17 00:00:00 2001 From: Jaap Suter Date: Mon, 15 Jun 2020 09:55:30 -0700 Subject: [PATCH] Switched from in-class initialization to setting the default input mapping in a constructor in the .cpp file. --- implot.cpp | 24 ++++++++++++++++++++++++ implot.h | 39 +++++++++++++++++++++------------------ 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/implot.cpp b/implot.cpp index 496b2c6..f1ecfac 100644 --- a/implot.cpp +++ b/implot.cpp @@ -133,6 +133,30 @@ bool ImPlotLimits::Contains(double x, double y) const { return X.Contains(x) && Y.Contains(y); } +ImPlotInputMap::ImPlotInputMap() { + + PanButton = ImGuiMouseButton_Left; + PanMod = ImGuiKeyModFlags_None; + + BoxSelectButton = ImGuiMouseButton_Right; + BoxSelectMod = ImGuiKeyModFlags_None; + + BoxCancelButton = ImGuiMouseButton_Left; + + QueryClickButton = ImGuiMouseButton_Left; + QueryClickMod = ImGuiKeyModFlags_Ctrl; + + QueryDragButton = ImGuiMouseButton_Middle; + QueryDragMod = ImGuiKeyModFlags_None; + + QueryDragButton2 = ImGuiMouseButton_Right; + QueryDragMod2 = ImGuiKeyModFlags_Ctrl; + + HorizontalSizeMod = ImGuiKeyModFlags_Alt; + VerticalSizeMod = ImGuiKeyModFlags_Shift; +} + + namespace ImPlot { namespace { diff --git a/implot.h b/implot.h index c042ccb..2174fca 100644 --- a/implot.h +++ b/implot.h @@ -172,27 +172,30 @@ struct ImPlotStyle { ImPlotStyle(); }; -// Input mapping structure, and their default values. +// Input mapping structure, default values listed in the comments. struct ImPlotInputMap { - ImGuiMouseButton PanButton = ImGuiMouseButton_Left; - ImGuiKeyModFlags PanMod = ImGuiKeyModFlags_None; - ImGuiMouseButton BoxSelectButton = ImGuiMouseButton_Right; - ImGuiKeyModFlags BoxSelectMod = ImGuiKeyModFlags_None; + ImPlotInputMap(); - ImGuiMouseButton BoxCancelButton = ImGuiMouseButton_Left; - - ImGuiMouseButton QueryClickButton = ImGuiMouseButton_Left; - ImGuiKeyModFlags QueryClickMod = ImGuiKeyModFlags_Ctrl; - - ImGuiMouseButton QueryDragButton = ImGuiMouseButton_Middle; - ImGuiKeyModFlags QueryDragMod = ImGuiKeyModFlags_None; - - ImGuiMouseButton QueryDragButton2 = ImGuiMouseButton_Right; - ImGuiKeyModFlags QueryDragMod2 = ImGuiKeyModFlags_Ctrl; - - ImGuiKeyModFlags HorizontalSizeMod = ImGuiKeyModFlags_Alt; - ImGuiKeyModFlags VerticalSizeMod = ImGuiKeyModFlags_Shift; + ImGuiMouseButton PanButton; // left mouse + ImGuiKeyModFlags PanMod; // none + + ImGuiMouseButton BoxSelectButton; // right mouse + ImGuiKeyModFlags BoxSelectMod; // none + + ImGuiMouseButton BoxCancelButton; // left mouse + + ImGuiMouseButton QueryClickButton; // left mouse + ImGuiKeyModFlags QueryClickMod; // ctrl + + ImGuiMouseButton QueryDragButton; // middle mouse + ImGuiKeyModFlags QueryDragMod; // none + + ImGuiMouseButton QueryDragButton2; // right mouse, alternative way to query drag, useful when middle mouse is not available + ImGuiKeyModFlags QueryDragMod2; // ctrl + + ImGuiKeyModFlags HorizontalSizeMod; // alt + ImGuiKeyModFlags VerticalSizeMod; // shift }; //-----------------------------------------------------------------------------