mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-03 22:51:06 +01:00 
			
		
		
		
	Inputs, IO: record MouseWheelRequestAxisSwap information. Apply in UpdateMouseWheel() before legacy ctrl+wheel.
This commit is contained in:
		
							
								
								
									
										19
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -8436,6 +8436,13 @@ static void ImGui::UpdateMouseInputs()
 | 
			
		||||
    ImGuiContext& g = *GImGui;
 | 
			
		||||
    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)
 | 
			
		||||
    if (IsMousePosValid(&io.MousePos))
 | 
			
		||||
        io.MousePos = g.MouseLastValidPos = ImFloorSigned(io.MousePos);
 | 
			
		||||
@@ -8596,15 +8603,9 @@ void ImGui::UpdateMouseWheel()
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    // Mouse wheel scrolling
 | 
			
		||||
    // 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.
 | 
			
		||||
    // - However this means when running on OSX over Emcripten, Shift+WheelY will incur two swappings (1 in OS, 1 here), cancelling the feature.
 | 
			
		||||
    const bool swap_axis = g.IO.KeyShift && !g.IO.ConfigMacOSXBehaviors;
 | 
			
		||||
    if (swap_axis)
 | 
			
		||||
    {
 | 
			
		||||
        wheel.x = wheel.y;
 | 
			
		||||
        wheel.y = 0.0f;
 | 
			
		||||
    }
 | 
			
		||||
    // Read about io.MouseWheelRequestAxisSwap and its issue on Mac+Emscripten in UpdateMouseInputs()
 | 
			
		||||
    if (g.IO.MouseWheelRequestAxisSwap)
 | 
			
		||||
        wheel = ImVec2(wheel.y, 0.0f);
 | 
			
		||||
 | 
			
		||||
    // Maintain a rough average of moving magnitude on both axises
 | 
			
		||||
    // FIXME: should by based on wall clock time rather than frame-counter
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user