Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Invert Zoom does not invert scrolling of ImGui windows; Zoom Gain can be negative - #7381

Open
Grantim wants to merge 6 commits into
masterfrom
agent/mlib-invert-zoom-only
Open

Grantim wants to merge 6 commits into
masterfrom
agent/mlib-invert-zoom-only

Conversation

@Grantim

@Grantim Grantim commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor
  • Invert Zoom (MouseController::setZoomInverted: option to reverse the mouse wheel zoom direction #6972) negates the wheel delta before the scroll signal, so with it on, ImGui windows (scene tree, settings) scrolled backwards too. ImGuiMenu::onMouseScroll_ now negates it back before passing it to ImGui; the zoom and all other scroll handling stay as they are. Scroll that does not go through the inverting wheel path (touchpad pinch, MCP scroll) is now reversed over ImGui windows when Invert Zoom is on.
  • The Zoom Gain field in Viewer Settings accepts -3..3 instead of 0.2..3. A negative scrollForce set from code or the config was clamped back to 0.2 whenever the field was drawn. The gain still applies to every scroll event as before, so a negative gain also reverses scrolling of ImGui windows.

Testing

  • MeshViewer Debug, wheel messages posted to the window: with Invert Zoom on, wheel up zooms out and the scene tree scrolls in the normal direction (on master it scrolled backwards); with it off, both are unchanged.
  • Zoom Gain -1 and -3 stay set after the settings window redraws, and wheel up zooms out (view angle 24.8° -> 26.0° at -1, -> 28.7° at -3).

Generated with Claude Code

Grantim and others added 3 commits November 5, 2026 16:21
The wheel delta was negated before the scroll signal, so with Invert Zoom on, ImGui panels and tool scroll handlers scrolled backwards too. Now MouseController negates it only when zooming.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A negative gain (set from code or the config) was clamped back to 0.2 whenever the settings drew the field; the range is now -3..3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pinch updates moved the camera toward an absolute view angle computed from the gesture start, so negating or scaling the wheel delta made it run away from that target. Each update now passes the scale change since the last applied update as a wheel delta; skipped updates are still caught up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Grantim Grantim changed the title Invert Zoom affects only the zoom; Zoom Gain can be negative Invert Zoom affects only the zoom, touchpad pinch included; Zoom Gain can be negative Nov 5, 2026
Restores master's Invert Zoom, touchpad and Zoom Gain code; ImGuiMenu negates the inverted wheel delta back before giving it to ImGui, so with Invert Zoom on, ImGui windows scroll in the normal direction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Grantim Grantim changed the title Invert Zoom affects only the zoom, touchpad pinch included; Zoom Gain can be negative Invert Zoom does not invert scrolling of ImGui windows Nov 5, 2026
A negative gain (set from code or the config) was clamped back to 0.2 whenever the settings drew the field; the range is now -3..3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Grantim Grantim changed the title Invert Zoom does not invert scrolling of ImGui windows Invert Zoom does not invert scrolling of ImGui windows; Zoom Gain can be negative Nov 5, 2026

@Fedr Fedr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, older than this PR but from the same cause: scrollForce is applied in Viewer::mouseScroll, so Zoom Gain also scales ImGui scroll speed and every other mouseScrollSignal listener. It could move into MouseController::mouseScroll_ together with the inversion (see the inline comment).

// allow ImGui to process the scroll exclusively
ImGui_ImplGlfw_ScrollCallback( viewer->window, 0.f, delta_y );
// allow ImGui to process the scroll exclusively; Invert Zoom must not invert scrolling of ImGui windows
ImGui_ImplGlfw_ScrollCallback( viewer->window, 0.f, viewer->mouseController().isZoomInverted() ? -delta_y : delta_y );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This undoes the flip for one listener only. The flip happens where the events come in (glfw_mouse_scroll in MRViewer.cpp and TouchpadController::Handler::mouseScroll), so every mouseScrollSignal listener gets the inverted delta:

  • other listeners that use the wheel for something besides zoom (e.g. a tool changing a brush radius on Ctrl+wheel) are still reversed with Invert Zoom on;
  • inputs that never went through the flip (touchpad pinch via TouchpadController::touchpadZoomGestureUpdate_, MCP mouseScroll) now scroll ImGui windows backwards when Invert Zoom is on.

Suggest instead: apply the inversion in MouseController::mouseScroll_, the only listener that zooms, and remove it from glfw_mouse_scroll and TouchpadController::Handler::mouseScroll. Then this hunk is not needed. Pinch would become inverted too; if that is unwanted, touchpadZoomGestureUpdate_ can compensate, or call the zoom directly instead of going through viewer.mouseScroll.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept on purpose: the tested touchpad code stays as it is, and Invert Zoom only needs to leave ImGui windows alone, not change other wheel handlers. Moving the flip into MouseController::mouseScroll_ was the first version of this PR. It also inverts pinch, and since touchpadZoomGestureUpdate_ steers toward an absolute view angle, a negated delta runs the angle to the 179.99° limit, so pinch would need rework too. Pinch and MCP scroll over ImGui windows being reversed with Invert Zoom on is noted in the description.

@Grantim

Grantim commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

scrollForce is applied in Viewer::mouseScroll, so Zoom Gain also scales ImGui scroll speed and every other mouseScrollSignal listener.

Zoom Gain keeps applying to every scroll event as before; changing its scope is outside this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants