mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 12:11:15 -06:00 
			
		
		
		
	Added a cancel button, and rewrote initial option code to reuse OptionGroup.
This commit is contained in:
		
							parent
							
								
									3109a9bc1f
								
							
						
					
					
						commit
						a0548898f3
					
				
					 2 changed files with 64 additions and 58 deletions
				
			
		|  | @ -25,7 +25,10 @@ sub new { | |||
| 
 | ||||
|     $self->{sizer} = Wx::BoxSizer->new(wxVERTICAL); | ||||
|     my $button_sizer = Wx::BoxSizer->new(wxHORIZONTAL); | ||||
|     my $buttons = $self->CreateStdDialogButtonSizer(wxOK); | ||||
|     my $button_ok = $self->CreateStdDialogButtonSizer(wxOK); | ||||
|     my $button_cancel = $self->CreateStdDialogButtonSizer(wxCANCEL); | ||||
|     $button_sizer->Add($button_ok); | ||||
|     $button_sizer->Add($button_cancel); | ||||
|     EVT_BUTTON($self, wxID_OK, sub { | ||||
|         # validate user input | ||||
|         return if !$self->CanClose; | ||||
|  | @ -33,66 +36,67 @@ sub new { | |||
|         $self->EndModal(wxID_OK); | ||||
|         $self->Destroy; | ||||
|     }); | ||||
|     $button_sizer->Add($buttons, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); | ||||
| 
 | ||||
|     EVT_BUTTON($self, wxID_CANCEL, sub { | ||||
|         # validate user input | ||||
|         return if !$self->CanClose; | ||||
|          | ||||
|         $self->EndModal(wxID_CANCEL); | ||||
|         $self->Destroy; | ||||
|     }); | ||||
|      | ||||
|     my $optgroup; | ||||
|     $optgroup = $self->{optgroup} = Slic3r::GUI::OptionsGroup->new( | ||||
|         parent      => $self, | ||||
|         title       => 'Add Generic...', | ||||
|         on_change   => sub { | ||||
|             # Do validation | ||||
|             my ($opt_id) = @_; | ||||
|             if ($opt_id == 0 || $opt_id == 1 || $opt_id == 2) { | ||||
|                 if (!looks_like_number($optgroup->get_value($opt_id))) { | ||||
|                     return 0; | ||||
|                 } | ||||
|             } | ||||
|             $self->{object_parameters}->{dim}[$opt_id] = $optgroup->get_value($opt_id); | ||||
|         }, | ||||
|         label_width => 100, | ||||
|     ); | ||||
|     my @options = ("box"); | ||||
|     $self->{type} = Wx::ComboBox->new($self, 1, "box", wxDefaultPosition, wxDefaultSize, \@options, wxCB_READONLY); | ||||
| 
 | ||||
|     my $sbox = Wx::StaticBox->new($self, -1, '', wxDefaultPosition, wxDefaultSize, 0, 'sbox'); | ||||
|     my $cube_dim_sizer = Wx::StaticBoxSizer->new($sbox, wxVERTICAL); | ||||
|     { | ||||
|         my $opt_sizer = Wx::BoxSizer->new(wxHORIZONTAL); | ||||
|         { | ||||
|             my $lbl = Wx::StaticText->new($self, 2, "X", wxDefaultPosition, Wx::Size->new(10,-1)); | ||||
|             $self->{dim_x} = Wx::TextCtrl->new($self, 2, "1", wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_TAB); | ||||
|             $opt_sizer->Add($lbl, 1, wxRIGHT , 8); | ||||
|             $opt_sizer->Add($self->{dim_x}); | ||||
| 
 | ||||
|         } | ||||
|         $cube_dim_sizer->Add($opt_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 10); | ||||
|         $opt_sizer = Wx::BoxSizer->new(wxHORIZONTAL); | ||||
|         { | ||||
|             my $lbl = Wx::StaticText->new($self, -1, "Y", wxDefaultPosition, Wx::Size->new(10,-1)); | ||||
|             $self->{dim_y} = Wx::TextCtrl->new($self, 2, "1", wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_TAB); | ||||
|             $opt_sizer->Add($lbl, 1, wxRIGHT , 8); | ||||
|             $opt_sizer->Add($self->{dim_y}); | ||||
|         } | ||||
|         $cube_dim_sizer->Add($opt_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 10); | ||||
|         $opt_sizer = Wx::BoxSizer->new(wxHORIZONTAL); | ||||
|         { | ||||
|             my $lbl = Wx::StaticText->new($self, -1, "Z", wxDefaultPosition, Wx::Size->new(10,-1)); | ||||
|             $self->{dim_z} = Wx::TextCtrl->new($self, 2, "1", wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_TAB); | ||||
|             $opt_sizer->Add($lbl, 1, wxRIGHT , 8); | ||||
|             $opt_sizer->Add($self->{dim_z}); | ||||
|         } | ||||
|         $cube_dim_sizer->Add($opt_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 10); | ||||
|         EVT_TEXT($self, 2, sub {  | ||||
|                 if (!looks_like_number($self->{dim_x}->GetValue)) { | ||||
|                 return 0; | ||||
|                 } | ||||
|                 if (!looks_like_number($self->{dim_y}->GetValue)) { | ||||
|                 return 0; | ||||
|                 } | ||||
|                 if (!looks_like_number($self->{dim_z}->GetValue)) { | ||||
|                 return 0; | ||||
|                 } | ||||
|                 if ($self->{dim_x}->GetValue() > 0) { | ||||
|                 $self->{object_parameters}->{dim}[0] = $self->{dim_x}->GetValue; | ||||
|                 } | ||||
|                 if ($self->{dim_y}->GetValue() > 0) { | ||||
|                 $self->{object_parameters}->{dim}[1] = $self->{dim_y}->GetValue; | ||||
|                 } | ||||
|                 if ($self->{dim_z}->GetValue() > 0) { | ||||
|                 $self->{object_parameters}->{dim}[2] = $self->{dim_z}->GetValue; | ||||
|                 } | ||||
|         }); | ||||
|     } | ||||
|     #my @types = ("box");  | ||||
|     #$optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( | ||||
|     #    opt_id  =>  'type', | ||||
|     #    label   =>  'Type', | ||||
|     #    type    =>  'select', | ||||
|     #    values  =>  \@types, | ||||
|     #    default =>  'box', | ||||
|     #)); | ||||
|     $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( | ||||
|         opt_id  =>  0, | ||||
|         label   =>  'L', | ||||
|         type    =>  'f', | ||||
|         default =>  '1', | ||||
|     )); | ||||
|     $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( | ||||
|         opt_id  =>  1, | ||||
|         label   =>  'W', | ||||
|         type    =>  'f', | ||||
|         default =>  '1', | ||||
|     )); | ||||
|     $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new( | ||||
|         opt_id  =>  2, | ||||
|         label   =>  'H', | ||||
|         type    =>  'f', | ||||
|         default =>  '1', | ||||
|     )); | ||||
|     EVT_COMBOBOX($self, 1, sub{  | ||||
|         $self->{object_parameters}->{type} = $self->{type}->GetValue(); | ||||
|     }); | ||||
|     $self->{sizer}->Add($self->{type}, 0, wxEXPAND, 3); | ||||
|     $self->{sizer}->Add($cube_dim_sizer, 0, wxEXPAND, 10); | ||||
|     $self->{sizer}->Add($button_sizer); | ||||
| 
 | ||||
| 
 | ||||
|     $optgroup->sizer->Add($self->{type}, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); | ||||
|     $self->{sizer}->Add($optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); | ||||
|     $self->{sizer}->Add($button_sizer,0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); | ||||
| 
 | ||||
|     $self->SetSizer($self->{sizer}); | ||||
|     $self->{sizer}->Fit($self); | ||||
|     $self->{sizer}->SetSizeHints($self); | ||||
|  |  | |||
|  | @ -7,7 +7,7 @@ use warnings; | |||
| use utf8; | ||||
| 
 | ||||
| use File::Basename qw(basename); | ||||
| use Wx qw(:misc :sizer :treectrl :button wxTAB_TRAVERSAL wxSUNKEN_BORDER wxBITMAP_TYPE_PNG | ||||
| use Wx qw(:misc :sizer :treectrl :button wxTAB_TRAVERSAL wxSUNKEN_BORDER wxBITMAP_TYPE_PNG wxID_CANCEL | ||||
|     wxTheApp); | ||||
| use Wx::Event qw(EVT_BUTTON EVT_TREE_ITEM_COLLAPSING EVT_TREE_SEL_CHANGED); | ||||
| use base 'Wx::Panel'; | ||||
|  | @ -337,7 +337,9 @@ sub on_btn_lambda { | |||
|     my ($self, $is_modifier) = @_; | ||||
|      | ||||
|     my $dlg = Slic3r::GUI::Plater::LambdaObjectDialog->new($self); | ||||
|     $dlg->ShowModal(); | ||||
|     if ($dlg->ShowModal() == wxID_CANCEL) { | ||||
|         return; | ||||
|     } | ||||
|     my $params = $dlg->ObjectParameter; | ||||
|     my $name = "lambda-".$params->{"type"}; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Joseph Lenox
						Joseph Lenox