From 25bcff3656c911e26904e7cf846aefb2a4eaa5b4 Mon Sep 17 00:00:00 2001 From: Len Trigg Date: Sat, 11 Mar 2017 18:37:17 +1300 Subject: [PATCH] Fix #2861, provide consistent mouse-wheel zoom direction, plus a GUI preference to invert (#3749) * Make mouse-wheel in 2D toolpath zoom in the same direction as it does in 3D and 3D-preview * Add a GUI preference setting for whether to invert the direction that mouse-wheel scrolling will zoom in the 2D and 3D panels. --- lib/Slic3r/GUI.pm | 2 ++ lib/Slic3r/GUI/3DScene.pm | 3 +++ lib/Slic3r/GUI/Plater/2DToolpaths.pm | 5 ++++- lib/Slic3r/GUI/Preferences.pm | 7 +++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index b3c306850..c4fe92a04 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -67,6 +67,7 @@ our $Settings = { mode => 'simple', version_check => 1, autocenter => 1, + invert_zoom => 0, background_processing => 0, # If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden. # By default, Prusa has the controller hidden. @@ -124,6 +125,7 @@ sub OnInit { $last_version = $Settings->{_}{version}; $Settings->{_}{mode} ||= 'expert'; $Settings->{_}{autocenter} //= 1; + $Settings->{_}{invert_zoom} //= 0; $Settings->{_}{background_processing} //= 1; # If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden. $Settings->{_}{no_controller} //= 1; diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 2a37a9b75..56875acc9 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -127,6 +127,9 @@ sub new { # Calculate the zoom delta and apply it to the current zoom factor my $zoom = $e->GetWheelRotation() / $e->GetWheelDelta(); + if ($Slic3r::GUI::Settings->{_}{invert_zoom}) { + $zoom *= -1; + } $zoom = max(min($zoom, 4), -4); $zoom /= 10; $self->_zoom($self->_zoom / (1-$zoom)); diff --git a/lib/Slic3r/GUI/Plater/2DToolpaths.pm b/lib/Slic3r/GUI/Plater/2DToolpaths.pm index bc3d4e605..d39c53179 100644 --- a/lib/Slic3r/GUI/Plater/2DToolpaths.pm +++ b/lib/Slic3r/GUI/Plater/2DToolpaths.pm @@ -179,7 +179,10 @@ sub new { my $old_zoom = $self->_zoom; # Calculate the zoom delta and apply it to the current zoom factor - my $zoom = $e->GetWheelRotation() / $e->GetWheelDelta(); + my $zoom = -$e->GetWheelRotation() / $e->GetWheelDelta(); + if ($Slic3r::GUI::Settings->{_}{invert_zoom}) { + $zoom *= -1; + } $zoom = max(min($zoom, 4), -4); $zoom /= 10; $self->_zoom($self->_zoom / (1-$zoom)); diff --git a/lib/Slic3r/GUI/Preferences.pm b/lib/Slic3r/GUI/Preferences.pm index 431f642d6..91465fa64 100644 --- a/lib/Slic3r/GUI/Preferences.pm +++ b/lib/Slic3r/GUI/Preferences.pm @@ -52,6 +52,13 @@ sub new { tooltip => 'If this is enabled, Slic3r will auto-center objects around the print bed center.', default => $Slic3r::GUI::Settings->{_}{autocenter}, )); + $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( + opt_id => 'invert_zoom', + type => 'bool', + label => 'Invert zoom in previews', + tooltip => 'If this is enabled, Slic3r will invert the direction of mouse-wheel zoom in preview panes.', + default => $Slic3r::GUI::Settings->{_}{invert_zoom}, + )); $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( opt_id => 'background_processing', type => 'bool',