Correctly disable and reset the override settings panel
This commit is contained in:
parent
bf352de224
commit
30aa255bb5
@ -144,7 +144,8 @@ sub selection_changed {
|
|||||||
|
|
||||||
# disable things as if nothing is selected
|
# disable things as if nothing is selected
|
||||||
$self->{btn_delete}->Disable;
|
$self->{btn_delete}->Disable;
|
||||||
$self->{settings_panel}->Disable;
|
$self->{settings_panel}->disable;
|
||||||
|
$self->{settings_panel}->set_config(undef);
|
||||||
|
|
||||||
my $itemData = $self->get_selection;
|
my $itemData = $self->get_selection;
|
||||||
if ($itemData && $itemData->{type} eq 'volume') {
|
if ($itemData && $itemData->{type} eq 'volume') {
|
||||||
@ -156,7 +157,7 @@ sub selection_changed {
|
|||||||
my $volume = $self->{model_object}->volumes->[ $itemData->{volume_id} ];
|
my $volume = $self->{model_object}->volumes->[ $itemData->{volume_id} ];
|
||||||
my $material = $self->{model_object}->model->materials->{ $volume->material_id // '_' };
|
my $material = $self->{model_object}->model->materials->{ $volume->material_id // '_' };
|
||||||
$material //= $volume->assign_unique_material;
|
$material //= $volume->assign_unique_material;
|
||||||
$self->{settings_panel}->Enable;
|
$self->{settings_panel}->enable;
|
||||||
$self->{settings_panel}->set_config($material->config);
|
$self->{settings_panel}->set_config($material->config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,10 +26,10 @@ sub new {
|
|||||||
# get all options with object scope and sort them by category+label
|
# 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;
|
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 ];
|
$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
|
# 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 {
|
EVT_BUTTON($self, $btn, sub {
|
||||||
my $idx = $choice->GetSelection;
|
my $idx = $choice->GetSelection;
|
||||||
return if $idx == -1; # lack of selected item, can happen on Windows
|
return if $idx == -1; # lack of selected item, can happen on Windows
|
||||||
@ -96,4 +96,21 @@ sub update_optgroup {
|
|||||||
$self->Layout;
|
$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;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user