From 30aa255bb5cf0037179c16284b29b5ed586e3473 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 21 Mar 2014 22:15:33 +0100 Subject: [PATCH] Correctly disable and reset the override settings panel --- lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm | 5 +++-- .../GUI/Plater/OverrideSettingsPanel.pm | 21 +++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm index 0b02e89cc..2ba7e41ab 100644 --- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm +++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm @@ -144,7 +144,8 @@ sub selection_changed { # disable things as if nothing is selected $self->{btn_delete}->Disable; - $self->{settings_panel}->Disable; + $self->{settings_panel}->disable; + $self->{settings_panel}->set_config(undef); my $itemData = $self->get_selection; if ($itemData && $itemData->{type} eq 'volume') { @@ -156,7 +157,7 @@ sub selection_changed { my $volume = $self->{model_object}->volumes->[ $itemData->{volume_id} ]; my $material = $self->{model_object}->model->materials->{ $volume->material_id // '_' }; $material //= $volume->assign_unique_material; - $self->{settings_panel}->Enable; + $self->{settings_panel}->enable; $self->{settings_panel}->set_config($material->config); } diff --git a/lib/Slic3r/GUI/Plater/OverrideSettingsPanel.pm b/lib/Slic3r/GUI/Plater/OverrideSettingsPanel.pm index 5bbe05198..8518b8320 100644 --- a/lib/Slic3r/GUI/Plater/OverrideSettingsPanel.pm +++ b/lib/Slic3r/GUI/Plater/OverrideSettingsPanel.pm @@ -26,10 +26,10 @@ sub new { # get all options with object scope and sort them by category+label my %settings = map { $_ => sprintf('%s > %s', $Slic3r::Config::Options->{$_}{category}, $Slic3r::Config::Options->{$_}{full_label} // $Slic3r::Config::Options->{$_}{label}) } @opt_keys; $self->{options} = [ sort { $settings{$a} cmp $settings{$b} } keys %settings ]; - my $choice = Wx::Choice->new($self, -1, wxDefaultPosition, [150, -1], [ map $settings{$_}, @{$self->{options}} ]); + my $choice = $self->{choice} = Wx::Choice->new($self, -1, wxDefaultPosition, [150, -1], [ map $settings{$_}, @{$self->{options}} ]); # create the button - my $btn = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new("$Slic3r::var/add.png", wxBITMAP_TYPE_PNG)); + my $btn = $self->{btn_add} = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new("$Slic3r::var/add.png", wxBITMAP_TYPE_PNG)); EVT_BUTTON($self, $btn, sub { my $idx = $choice->GetSelection; return if $idx == -1; # lack of selected item, can happen on Windows @@ -96,4 +96,21 @@ sub update_optgroup { $self->Layout; } +# work around a wxMAC bug causing controls not being disabled when calling Disable() on a Window +sub enable { + my ($self) = @_; + + $self->{choice}->Enable; + $self->{btn_add}->Enable; + $self->Enable; +} + +sub disable { + my ($self) = @_; + + $self->{choice}->Disable; + $self->{btn_add}->Disable; + $self->Disable; +} + 1;