-
Notifications
You must be signed in to change notification settings - Fork 53
Feat: Custom Input Map #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am unsure of a couple of things. I tried adding most of the functionality after the Style
blocks of code.
@brenocq if you could please just provide some feedback I would really appreciate it.
@@ -1974,7 +1977,8 @@ void HandleInput(ImPlot3DPlot& plot) { | |||
} | |||
|
|||
// If the user is no longer pressing the translation/zoom buttons, set axes as not held | |||
if (!ImGui::IsMouseDown(ImGuiMouseButton_Left) && !ImGui::IsMouseDown(ImGuiMouseButton_Middle)) { | |||
if (!(ImPlot3D::ImHasFlag(IO.KeyMods, gp.InputMap.PanMod) && ImGui::IsMouseDown(gp.InputMap.Pan)) && | |||
!(ImPlot3D::ImHasFlag(IO.KeyMods, gp.InputMap.ZoomMod) && ImGui::IsMouseDown(ImGuiMouseButton_Middle))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Should
gp.InputMap.ZoomMod
also be applied here and later on for theImGui::IsMouseDown(ImGuiMouseButton_Middle)
andImGui::IsMouseDoubleClicked(ImGuiMouseButton_Middle)
checks? - Should we add
ImGuiMouseButton_Middle
as a option forZoom
together withZoomMod
or should we just keep it as it since it is previous behaviour?Zoom
might not make a lot of sense though since it does not use it for zoom ad is for fit(already have option forFit
though), maybe call it something else?
@@ -2014,7 +2018,8 @@ void HandleInput(ImPlot3DPlot& plot) { | |||
ImPlot3DPoint mouse_pos_plot = PixelsToPlotPlane(mouse_pos, mouse_plane, false); | |||
|
|||
// Handle translation/zoom fit with double click | |||
if (plot_clicked && (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left) || ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Middle))) { | |||
if (plot_clicked && (ImGui::IsMouseDoubleClicked(gp.InputMap.Fit) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add support for FitMod
? This is not in ImPlot and I think it might be because it is only triggered on double click which does not happen very often.
@@ -2027,8 +2032,12 @@ void HandleInput(ImPlot3DPlot& plot) { | |||
plot.Axes[i].FitThisFrame = true; | |||
} | |||
|
|||
// cancel due to DND activity | |||
if (GImGui->DragDropActive || ImPlot3D::ImHasFlag(IO.KeyMods, gp.InputMap.OverrideMod)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure where to put this? I put it here after the FitThisFrame
has been set for the plot which means that the auto fit can be applied to the plot. ImPlot
has similar behavior. Should the data be fitted to the plot if OverrideMod
is valid?
map.ResetRotate = ImGuiMouseButton_Right; | ||
map.Rotate = ImGuiMouseButton_Right; | ||
map.RotateMod = ImGuiMod_None; | ||
map.Menu = ImGuiMouseButton_Right; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add MenuMod
and FitMod
as well?
Add small overhead for some more control.
ImGuiMouseButton Pan; // LMB enables panning when held, | ||
int PanMod; // none optional modifier that must be held for panning/fitting | ||
ImGuiMouseButton Fit; // LMB initiates fit when double clicked | ||
ImGuiMouseButton ResetRotate; // RMB initiates reset of the rotate when double clicked. When double clicked over the axis change to 2D view of the axis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure of the name ResetRotate
here. Open to suggestions for a better name?
@@ -890,6 +941,7 @@ void ShowAllDemos() { | |||
if (ImGui::BeginTabItem("Custom")) { | |||
DemoHeader("Custom Styles", DemoCustomStyles); | |||
DemoHeader("Custom Rendering", DemoCustomRendering); | |||
DemoHeader("Show Input Mapping", ShowInputMapping); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure where to put this? I put it here for now and this will affect all the plots. Open to moving/changing this
float delta = ImGui::IsMouseDown(ImGuiMouseButton_Middle) ? (-0.01f * IO.MouseDelta.y) : (-0.1f * IO.MouseWheel); | ||
const bool middle_mouse_button_down = ImGui::IsMouseDown(ImGuiMouseButton_Middle); | ||
if (middle_mouse_button_down || IO.MouseWheel != 0.0f) { | ||
float delta = middle_mouse_button_down ? (-0.01f * IO.MouseDelta.y) : (-gp.InputMap.ZoomRate * IO.MouseWheel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When middle_mouse_button_down
is true should the delta be a function of the ZoomRate
? Maybe (-gp.InputMap.ZoomRate * IO.MouseDelta.y / 10.0f)
instead of (-0.01f * IO.MouseDelta.y)
?
Can always create a new variable specifically just for zoom rate with button press(MouseDelta.y) which is separate from the ZoomRate
(MouseWheel) ?
Closes #97
Added Input Map support for #97 . @brenocq if you get a chance can you maybe take a look and let me know if I am going in the right direction.
This is not done yet and requires some more work:
ImGuiMouseButton_Middle
button. Should still work like before where theImGuiMouseButton_Middle
does what it did previously so that it can be used to reset the plotOverrideMod
affects. InImPlot
it comes after theFitThisFrame
andHovered
which is what I tried replicating