mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 20:07:01 +00:00
Inputs, IO: record MouseWheelRequestAxisSwap information. Apply in UpdateMouseWheel() before legacy ctrl+wheel.
This commit is contained in:
parent
a38e3c222f
commit
84fd0c7ff4
19
imgui.cpp
19
imgui.cpp
@ -8436,6 +8436,13 @@ static void ImGui::UpdateMouseInputs()
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiIO& io = g.IO;
|
ImGuiIO& io = g.IO;
|
||||||
|
|
||||||
|
// Mouse Wheel swapping flag
|
||||||
|
// As a standard behavior holding SHIFT while using Vertical Mouse Wheel triggers Horizontal scroll instead
|
||||||
|
// - We avoid doing it on OSX as it the OS input layer handles this already.
|
||||||
|
// - FIXME: However this means when running on OSX over Emscripten, Shift+WheelY will incur two swapping (1 in OS, 1 here), canceling the feature.
|
||||||
|
// - FIXME: When we can distinguish e.g. touchpad scroll events from mouse ones, we'll set this accordingly based on input source.
|
||||||
|
io.MouseWheelRequestAxisSwap = io.KeyShift && !io.ConfigMacOSXBehaviors;
|
||||||
|
|
||||||
// Round mouse position to avoid spreading non-rounded position (e.g. UpdateManualResize doesn't support them well)
|
// Round mouse position to avoid spreading non-rounded position (e.g. UpdateManualResize doesn't support them well)
|
||||||
if (IsMousePosValid(&io.MousePos))
|
if (IsMousePosValid(&io.MousePos))
|
||||||
io.MousePos = g.MouseLastValidPos = ImFloorSigned(io.MousePos);
|
io.MousePos = g.MouseLastValidPos = ImFloorSigned(io.MousePos);
|
||||||
@ -8596,15 +8603,9 @@ void ImGui::UpdateMouseWheel()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Mouse wheel scrolling
|
// Mouse wheel scrolling
|
||||||
// As a standard behavior holding SHIFT while using Vertical Mouse Wheel triggers Horizontal scroll instead
|
// Read about io.MouseWheelRequestAxisSwap and its issue on Mac+Emscripten in UpdateMouseInputs()
|
||||||
// - We avoid doing it on OSX as it the OS input layer handles this already.
|
if (g.IO.MouseWheelRequestAxisSwap)
|
||||||
// - However this means when running on OSX over Emcripten, Shift+WheelY will incur two swappings (1 in OS, 1 here), cancelling the feature.
|
wheel = ImVec2(wheel.y, 0.0f);
|
||||||
const bool swap_axis = g.IO.KeyShift && !g.IO.ConfigMacOSXBehaviors;
|
|
||||||
if (swap_axis)
|
|
||||||
{
|
|
||||||
wheel.x = wheel.y;
|
|
||||||
wheel.y = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Maintain a rough average of moving magnitude on both axises
|
// Maintain a rough average of moving magnitude on both axises
|
||||||
// FIXME: should by based on wall clock time rather than frame-counter
|
// FIXME: should by based on wall clock time rather than frame-counter
|
||||||
|
3
imgui.h
3
imgui.h
@ -23,7 +23,7 @@
|
|||||||
// Library Version
|
// Library Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345')
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345')
|
||||||
#define IMGUI_VERSION "1.89.5 WIP"
|
#define IMGUI_VERSION "1.89.5 WIP"
|
||||||
#define IMGUI_VERSION_NUM 18945
|
#define IMGUI_VERSION_NUM 18946
|
||||||
#define IMGUI_HAS_TABLE
|
#define IMGUI_HAS_TABLE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2054,6 +2054,7 @@ struct ImGuiIO
|
|||||||
bool MouseReleased[5]; // Mouse button went from Down to !Down
|
bool MouseReleased[5]; // Mouse button went from Down to !Down
|
||||||
bool MouseDownOwned[5]; // Track if button was clicked inside a dear imgui window or over void blocked by a popup. We don't request mouse capture from the application if click started outside ImGui bounds.
|
bool MouseDownOwned[5]; // Track if button was clicked inside a dear imgui window or over void blocked by a popup. We don't request mouse capture from the application if click started outside ImGui bounds.
|
||||||
bool MouseDownOwnedUnlessPopupClose[5]; // Track if button was clicked inside a dear imgui window.
|
bool MouseDownOwnedUnlessPopupClose[5]; // Track if button was clicked inside a dear imgui window.
|
||||||
|
bool MouseWheelRequestAxisSwap; // On a non-Mac system, holding SHIFT requests WheelY to perform the equivalent of a WheelX event. On a Mac system this is already enforced by the system.
|
||||||
float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked)
|
float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked)
|
||||||
float MouseDownDurationPrev[5]; // Previous time the mouse button has been down
|
float MouseDownDurationPrev[5]; // Previous time the mouse button has been down
|
||||||
float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the clicking point (used for moving thresholds)
|
float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the clicking point (used for moving thresholds)
|
||||||
|
Loading…
Reference in New Issue
Block a user