mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Correctly disable and reset the override settings panel
This commit is contained in:
		
							parent
							
								
									bf352de224
								
							
						
					
					
						commit
						30aa255bb5
					
				
					 2 changed files with 22 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -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);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue