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.
This commit is contained in:
Len Trigg 2017-03-11 18:37:17 +13:00 committed by Joseph Lenox
parent 0741ecc2aa
commit 25bcff3656
4 changed files with 16 additions and 1 deletions

View File

@ -67,6 +67,7 @@ our $Settings = {
mode => 'simple', mode => 'simple',
version_check => 1, version_check => 1,
autocenter => 1, autocenter => 1,
invert_zoom => 0,
background_processing => 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. # 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. # By default, Prusa has the controller hidden.
@ -124,6 +125,7 @@ sub OnInit {
$last_version = $Settings->{_}{version}; $last_version = $Settings->{_}{version};
$Settings->{_}{mode} ||= 'expert'; $Settings->{_}{mode} ||= 'expert';
$Settings->{_}{autocenter} //= 1; $Settings->{_}{autocenter} //= 1;
$Settings->{_}{invert_zoom} //= 0;
$Settings->{_}{background_processing} //= 1; $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. # 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; $Settings->{_}{no_controller} //= 1;

View File

@ -127,6 +127,9 @@ sub new {
# Calculate the zoom delta and apply it to the current zoom factor # 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 = max(min($zoom, 4), -4);
$zoom /= 10; $zoom /= 10;
$self->_zoom($self->_zoom / (1-$zoom)); $self->_zoom($self->_zoom / (1-$zoom));

View File

@ -179,7 +179,10 @@ sub new {
my $old_zoom = $self->_zoom; my $old_zoom = $self->_zoom;
# Calculate the zoom delta and apply it to the current zoom factor # 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 = max(min($zoom, 4), -4);
$zoom /= 10; $zoom /= 10;
$self->_zoom($self->_zoom / (1-$zoom)); $self->_zoom($self->_zoom / (1-$zoom));

View File

@ -52,6 +52,13 @@ sub new {
tooltip => 'If this is enabled, Slic3r will auto-center objects around the print bed center.', tooltip => 'If this is enabled, Slic3r will auto-center objects around the print bed center.',
default => $Slic3r::GUI::Settings->{_}{autocenter}, 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( $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
opt_id => 'background_processing', opt_id => 'background_processing',
type => 'bool', type => 'bool',