Simplified the code base by requiring wxWidgets >= 3.0

This commit is contained in:
bubnikv 2017-08-03 17:47:18 +02:00
parent 1385018724
commit ed46cfa19d
11 changed files with 58 additions and 110 deletions

View File

@ -34,7 +34,7 @@ my $xs_only = grep { $_ eq '--xs' } @ARGV;
if ($gui) { if ($gui) {
%prereqs = qw( %prereqs = qw(
Class::Accessor 0 Class::Accessor 0
Wx 0.9918 Wx 3.0
Socket 2.016 Socket 2.016
); );
%recommends = qw( %recommends = qw(

View File

@ -74,7 +74,6 @@ our $Settings = {
}, },
}; };
our $have_button_icons = &Wx::wxVERSION_STRING =~ m" (?:2\.9\.[1-9]|3\.)";
our $small_font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); our $small_font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
$small_font->SetPointSize(11) if &Wx::wxMAC; $small_font->SetPointSize(11) if &Wx::wxMAC;
our $small_bold_font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); our $small_bold_font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
@ -92,7 +91,7 @@ sub OnInit {
my ($self) = @_; my ($self) = @_;
$self->SetAppName('Slic3r'); $self->SetAppName('Slic3r');
$self->SetAppDisplayName('Slic3r Prusa Edition') if (Wx::wxVERSION >= 3.000000); $self->SetAppDisplayName('Slic3r Prusa Edition');
Slic3r::debugf "wxWidgets version %s, Wx version %s\n", &Wx::wxVERSION_STRING, $Wx::VERSION; Slic3r::debugf "wxWidgets version %s, Wx version %s\n", &Wx::wxVERSION_STRING, $Wx::VERSION;
$self->{notifier} = Slic3r::GUI::Notifier->new; $self->{notifier} = Slic3r::GUI::Notifier->new;

View File

@ -943,22 +943,12 @@ sub mouse_to_3d {
sub GetContext { sub GetContext {
my ($self) = @_; my ($self) = @_;
if (Wx::wxVERSION >= 2.009) {
return $self->{context} ||= Wx::GLContext->new($self); return $self->{context} ||= Wx::GLContext->new($self);
} else {
return $self->SUPER::GetContext;
}
} }
sub SetCurrent { sub SetCurrent {
my ($self, $context) = @_; my ($self, $context) = @_;
if (Wx::wxVERSION >= 2.009) {
return $self->SUPER::SetCurrent($context); return $self->SUPER::SetCurrent($context);
} else {
return $self->SUPER::SetCurrent;
}
} }
sub UseVBOs { sub UseVBOs {

View File

@ -34,10 +34,8 @@ sub new {
my $btn = Wx::Button->new($self, -1, $label, wxDefaultPosition, wxDefaultSize, my $btn = Wx::Button->new($self, -1, $label, wxDefaultPosition, wxDefaultSize,
wxBU_LEFT | wxBU_EXACTFIT); wxBU_LEFT | wxBU_EXACTFIT);
$btn->SetFont($bold ? $Slic3r::GUI::small_bold_font : $Slic3r::GUI::small_font); $btn->SetFont($bold ? $Slic3r::GUI::small_bold_font : $Slic3r::GUI::small_font);
if ($Slic3r::GUI::have_button_icons) {
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("$icon.png"), wxBITMAP_TYPE_PNG)); $btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("$icon.png"), wxBITMAP_TYPE_PNG));
$btn->SetBitmapPosition($pos); $btn->SetBitmapPosition($pos);
}
EVT_BUTTON($self, $btn, $handler); EVT_BUTTON($self, $btn, $handler);
$sizer->Add($btn, 1, wxEXPAND | wxALL, 0); $sizer->Add($btn, 1, wxEXPAND | wxALL, 0);
}; };

View File

@ -127,9 +127,7 @@ sub new {
{ {
$self->{btn_disconnect} = my $btn = Wx::Button->new($box, -1, "Disconnect", wxDefaultPosition, wxDefaultSize); $self->{btn_disconnect} = my $btn = Wx::Button->new($box, -1, "Disconnect", wxDefaultPosition, wxDefaultSize);
$btn->SetFont($Slic3r::GUI::small_font); $btn->SetFont($Slic3r::GUI::small_font);
if ($Slic3r::GUI::have_button_icons) {
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("delete.png"), wxBITMAP_TYPE_PNG)); $btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("delete.png"), wxBITMAP_TYPE_PNG));
}
$serial_speed_sizer->Add($btn, 0, wxLEFT, 5); $serial_speed_sizer->Add($btn, 0, wxLEFT, 5);
EVT_BUTTON($self, $btn, \&disconnect); EVT_BUTTON($self, $btn, \&disconnect);
} }
@ -142,9 +140,7 @@ sub new {
my $font = $btn->GetFont; my $font = $btn->GetFont;
$font->SetPointSize($font->GetPointSize + 2); $font->SetPointSize($font->GetPointSize + 2);
$btn->SetFont($font); $btn->SetFont($font);
if ($Slic3r::GUI::have_button_icons) {
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("arrow_up.png"), wxBITMAP_TYPE_PNG)); $btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("arrow_up.png"), wxBITMAP_TYPE_PNG));
}
$left_sizer->Add($btn, 0, wxTOP, 15); $left_sizer->Add($btn, 0, wxTOP, 15);
EVT_BUTTON($self, $btn, \&connect); EVT_BUTTON($self, $btn, \&connect);
} }
@ -164,9 +160,7 @@ sub new {
{ {
$self->{btn_manual_control} = my $btn = Wx::Button->new($box, -1, "Manual control", wxDefaultPosition, wxDefaultSize); $self->{btn_manual_control} = my $btn = Wx::Button->new($box, -1, "Manual control", wxDefaultPosition, wxDefaultSize);
$btn->SetFont($Slic3r::GUI::small_font); $btn->SetFont($Slic3r::GUI::small_font);
if ($Slic3r::GUI::have_button_icons) {
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("cog.png"), wxBITMAP_TYPE_PNG)); $btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("cog.png"), wxBITMAP_TYPE_PNG));
}
$btn->Hide; $btn->Hide;
$left_sizer->Add($btn, 0, wxTOP, 15); $left_sizer->Add($btn, 0, wxTOP, 15);
EVT_BUTTON($self, $btn, sub { EVT_BUTTON($self, $btn, sub {
@ -583,9 +577,7 @@ sub new {
$btn->SetToolTipString("Delete this job from print queue") $btn->SetToolTipString("Delete this job from print queue")
if $btn->can('SetToolTipString'); if $btn->can('SetToolTipString');
$btn->SetFont($Slic3r::GUI::small_font); $btn->SetFont($Slic3r::GUI::small_font);
if ($Slic3r::GUI::have_button_icons) {
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("delete.png"), wxBITMAP_TYPE_PNG)); $btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("delete.png"), wxBITMAP_TYPE_PNG));
}
if ($job->printing) { if ($job->printing) {
$btn->Hide; $btn->Hide;
} }
@ -605,11 +597,9 @@ sub new {
my $btn = $self->{btn_print} = Wx::Button->new($self, -1, $label, wxDefaultPosition, wxDefaultSize, my $btn = $self->{btn_print} = Wx::Button->new($self, -1, $label, wxDefaultPosition, wxDefaultSize,
$button_style); $button_style);
$btn->SetFont($Slic3r::GUI::small_bold_font); $btn->SetFont($Slic3r::GUI::small_bold_font);
if ($Slic3r::GUI::have_button_icons) {
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("control_play.png"), wxBITMAP_TYPE_PNG)); $btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("control_play.png"), wxBITMAP_TYPE_PNG));
$btn->SetBitmapCurrent(Wx::Bitmap->new($Slic3r::var->("control_play_blue.png"), wxBITMAP_TYPE_PNG)); $btn->SetBitmapCurrent(Wx::Bitmap->new($Slic3r::var->("control_play_blue.png"), wxBITMAP_TYPE_PNG));
#$btn->SetBitmapPosition(wxRIGHT); #$btn->SetBitmapPosition(wxRIGHT);
}
$btn->Hide; $btn->Hide;
$buttons_sizer->Add($btn, 0, wxBOTTOM, 2); $buttons_sizer->Add($btn, 0, wxBOTTOM, 2);
@ -626,10 +616,8 @@ sub new {
if (!$job->printing || $job->paused) { if (!$job->printing || $job->paused) {
$btn->Hide; $btn->Hide;
} }
if ($Slic3r::GUI::have_button_icons) {
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("control_pause.png"), wxBITMAP_TYPE_PNG)); $btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("control_pause.png"), wxBITMAP_TYPE_PNG));
$btn->SetBitmapCurrent(Wx::Bitmap->new($Slic3r::var->("control_pause_blue.png"), wxBITMAP_TYPE_PNG)); $btn->SetBitmapCurrent(Wx::Bitmap->new($Slic3r::var->("control_pause_blue.png"), wxBITMAP_TYPE_PNG));
}
$buttons_sizer->Add($btn, 0, wxBOTTOM, 2); $buttons_sizer->Add($btn, 0, wxBOTTOM, 2);
EVT_BUTTON($self, $btn, sub { EVT_BUTTON($self, $btn, sub {
@ -645,10 +633,8 @@ sub new {
if (!$job->printing || !$job->paused) { if (!$job->printing || !$job->paused) {
$btn->Hide; $btn->Hide;
} }
if ($Slic3r::GUI::have_button_icons) {
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("control_play.png"), wxBITMAP_TYPE_PNG)); $btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("control_play.png"), wxBITMAP_TYPE_PNG));
$btn->SetBitmapCurrent(Wx::Bitmap->new($Slic3r::var->("control_play_blue.png"), wxBITMAP_TYPE_PNG)); $btn->SetBitmapCurrent(Wx::Bitmap->new($Slic3r::var->("control_play_blue.png"), wxBITMAP_TYPE_PNG));
}
$buttons_sizer->Add($btn, 0, wxBOTTOM, 2); $buttons_sizer->Add($btn, 0, wxBOTTOM, 2);
EVT_BUTTON($self, $btn, sub { EVT_BUTTON($self, $btn, sub {
@ -664,10 +650,8 @@ sub new {
if (!$job->printing) { if (!$job->printing) {
$btn->Hide; $btn->Hide;
} }
if ($Slic3r::GUI::have_button_icons) {
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("control_stop.png"), wxBITMAP_TYPE_PNG)); $btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("control_stop.png"), wxBITMAP_TYPE_PNG));
$btn->SetBitmapCurrent(Wx::Bitmap->new($Slic3r::var->("control_stop_blue.png"), wxBITMAP_TYPE_PNG)); $btn->SetBitmapCurrent(Wx::Bitmap->new($Slic3r::var->("control_stop_blue.png"), wxBITMAP_TYPE_PNG));
}
$buttons_sizer->Add($btn, 0, wxBOTTOM, 2); $buttons_sizer->Add($btn, 0, wxBOTTOM, 2);
EVT_BUTTON($self, $btn, sub { EVT_BUTTON($self, $btn, sub {

View File

@ -398,7 +398,6 @@ sub quick_slice {
print_center => $print_center, print_center => $print_center,
status_cb => sub { status_cb => sub {
my ($percent, $message) = @_; my ($percent, $message) = @_;
return if &Wx::wxVERSION_STRING !~ m" 2\.(8\.|9\.[2-9])";
$progress_dialog->Update($percent, "$message…"); $progress_dialog->Update($percent, "$message…");
}, },
); );

View File

@ -235,7 +235,6 @@ sub new {
$self->{btn_print}->Hide; $self->{btn_print}->Hide;
$self->{btn_send_gcode}->Hide; $self->{btn_send_gcode}->Hide;
if ($Slic3r::GUI::have_button_icons) {
my %icons = qw( my %icons = qw(
add brick_add.png add brick_add.png
remove brick_delete.png remove brick_delete.png
@ -259,7 +258,6 @@ sub new {
for (grep $self->{"btn_$_"}, keys %icons) { for (grep $self->{"btn_$_"}, keys %icons) {
$self->{"btn_$_"}->SetBitmap(Wx::Bitmap->new($Slic3r::var->($icons{$_}), wxBITMAP_TYPE_PNG)); $self->{"btn_$_"}->SetBitmap(Wx::Bitmap->new($Slic3r::var->($icons{$_}), wxBITMAP_TYPE_PNG));
} }
}
$self->selection_changed(0); $self->selection_changed(0);
$self->object_list_changed; $self->object_list_changed;
EVT_BUTTON($self, $self->{btn_export_gcode}, sub { EVT_BUTTON($self, $self->{btn_export_gcode}, sub {
@ -1401,7 +1399,7 @@ sub export_gcode {
if ($output_file) { if ($output_file) {
$self->{export_gcode_output_file} = $self->{print}->output_filepath($output_file); $self->{export_gcode_output_file} = $self->{print}->output_filepath($output_file);
} else { } else {
my $default_output_file = $self->{print}->output_filepath($main::opt{output}); my $default_output_file = $self->{print}->output_filepath($main::opt{output} // '');
my $dlg = Wx::FileDialog->new($self, 'Save G-code file as:', wxTheApp->output_path(dirname($default_output_file)), my $dlg = Wx::FileDialog->new($self, 'Save G-code file as:', wxTheApp->output_path(dirname($default_output_file)),
basename($default_output_file), &Slic3r::GUI::FILE_WILDCARDS->{gcode}, wxFD_SAVE | wxFD_OVERWRITE_PROMPT); basename($default_output_file), &Slic3r::GUI::FILE_WILDCARDS->{gcode}, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
if ($dlg->ShowModal != wxID_OK) { if ($dlg->ShowModal != wxID_OK) {

View File

@ -583,22 +583,12 @@ sub InitGL {
sub GetContext { sub GetContext {
my ($self) = @_; my ($self) = @_;
if (Wx::wxVERSION >= 2.009) {
return $self->{context} ||= Wx::GLContext->new($self); return $self->{context} ||= Wx::GLContext->new($self);
} else {
return $self->SUPER::GetContext;
}
} }
sub SetCurrent { sub SetCurrent {
my ($self, $context) = @_; my ($self, $context) = @_;
if (Wx::wxVERSION >= 2.009) {
return $self->SUPER::SetCurrent($context); return $self->SUPER::SetCurrent($context);
} else {
return $self->SUPER::SetCurrent;
}
} }
sub Resize { sub Resize {

View File

@ -57,9 +57,8 @@ sub new {
$self->{btn_load_lambda_modifier} = Wx::Button->new($self, -1, "Load generic…", wxDefaultPosition, wxDefaultSize, wxBU_LEFT); $self->{btn_load_lambda_modifier} = Wx::Button->new($self, -1, "Load generic…", wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
$self->{btn_delete} = Wx::Button->new($self, -1, "Delete part", wxDefaultPosition, wxDefaultSize, wxBU_LEFT); $self->{btn_delete} = Wx::Button->new($self, -1, "Delete part", wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
$self->{btn_split} = Wx::Button->new($self, -1, "Split part", wxDefaultPosition, wxDefaultSize, wxBU_LEFT); $self->{btn_split} = Wx::Button->new($self, -1, "Split part", wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
$self->{btn_move_up} = Wx::Button->new($self, -1, $Slic3r::GUI::have_button_icons ? "" : "Up", wxDefaultPosition, [40, -1], wxBU_LEFT); $self->{btn_move_up} = Wx::Button->new($self, -1, "", wxDefaultPosition, [40, -1], wxBU_LEFT);
$self->{btn_move_down} = Wx::Button->new($self, -1, $Slic3r::GUI::have_button_icons ? "" : "Down", wxDefaultPosition, [40, -1], wxBU_LEFT); $self->{btn_move_down} = Wx::Button->new($self, -1, "", wxDefaultPosition, [40, -1], wxBU_LEFT);
if ($Slic3r::GUI::have_button_icons) {
$self->{btn_load_part}->SetBitmap(Wx::Bitmap->new($Slic3r::var->("brick_add.png"), wxBITMAP_TYPE_PNG)); $self->{btn_load_part}->SetBitmap(Wx::Bitmap->new($Slic3r::var->("brick_add.png"), wxBITMAP_TYPE_PNG));
$self->{btn_load_modifier}->SetBitmap(Wx::Bitmap->new($Slic3r::var->("brick_add.png"), wxBITMAP_TYPE_PNG)); $self->{btn_load_modifier}->SetBitmap(Wx::Bitmap->new($Slic3r::var->("brick_add.png"), wxBITMAP_TYPE_PNG));
$self->{btn_load_lambda_modifier}->SetBitmap(Wx::Bitmap->new($Slic3r::var->("brick_add.png"), wxBITMAP_TYPE_PNG)); $self->{btn_load_lambda_modifier}->SetBitmap(Wx::Bitmap->new($Slic3r::var->("brick_add.png"), wxBITMAP_TYPE_PNG));
@ -67,7 +66,6 @@ sub new {
$self->{btn_split}->SetBitmap(Wx::Bitmap->new($Slic3r::var->("shape_ungroup.png"), wxBITMAP_TYPE_PNG)); $self->{btn_split}->SetBitmap(Wx::Bitmap->new($Slic3r::var->("shape_ungroup.png"), wxBITMAP_TYPE_PNG));
$self->{btn_move_up}->SetBitmap(Wx::Bitmap->new($Slic3r::var->("bullet_arrow_up.png"), wxBITMAP_TYPE_PNG)); $self->{btn_move_up}->SetBitmap(Wx::Bitmap->new($Slic3r::var->("bullet_arrow_up.png"), wxBITMAP_TYPE_PNG));
$self->{btn_move_down}->SetBitmap(Wx::Bitmap->new($Slic3r::var->("bullet_arrow_down.png"), wxBITMAP_TYPE_PNG)); $self->{btn_move_down}->SetBitmap(Wx::Bitmap->new($Slic3r::var->("bullet_arrow_down.png"), wxBITMAP_TYPE_PNG));
}
# buttons sizer # buttons sizer
my $buttons_sizer = Wx::GridSizer->new(2, 3); my $buttons_sizer = Wx::GridSizer->new(2, 3);

View File

@ -90,7 +90,7 @@ sub new {
$sizer->Add($grid, 1, wxEXPAND | wxALL, 10); $sizer->Add($grid, 1, wxEXPAND | wxALL, 10);
$grid->CreateGrid(0, 3); $grid->CreateGrid(0, 3);
$grid->DisableDragRowSize; $grid->DisableDragRowSize;
$grid->HideRowLabels if &Wx::wxVERSION_STRING !~ / 2\.8\./; $grid->HideRowLabels;
$grid->SetColLabelValue(0, "Min Z (mm)"); $grid->SetColLabelValue(0, "Min Z (mm)");
$grid->SetColLabelValue(1, "Max Z (mm)"); $grid->SetColLabelValue(1, "Max Z (mm)");
$grid->SetColLabelValue(2, "Layer height (mm)"); $grid->SetColLabelValue(2, "Layer height (mm)");

View File

@ -1252,9 +1252,7 @@ sub build {
my $btn = Wx::Button->new($parent, -1, "Set…", wxDefaultPosition, wxDefaultSize, my $btn = Wx::Button->new($parent, -1, "Set…", wxDefaultPosition, wxDefaultSize,
wxBU_LEFT | wxBU_EXACTFIT); wxBU_LEFT | wxBU_EXACTFIT);
$btn->SetFont($Slic3r::GUI::small_font); $btn->SetFont($Slic3r::GUI::small_font);
if ($Slic3r::GUI::have_button_icons) {
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("cog.png"), wxBITMAP_TYPE_PNG)); $btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("cog.png"), wxBITMAP_TYPE_PNG));
}
my $sizer = Wx::BoxSizer->new(wxHORIZONTAL); my $sizer = Wx::BoxSizer->new(wxHORIZONTAL);
$sizer->Add($btn); $sizer->Add($btn);
@ -1335,9 +1333,7 @@ sub build {
my $btn = $self->{serial_test_btn} = Wx::Button->new($parent, -1, my $btn = $self->{serial_test_btn} = Wx::Button->new($parent, -1,
"Test", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); "Test", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
$btn->SetFont($Slic3r::GUI::small_font); $btn->SetFont($Slic3r::GUI::small_font);
if ($Slic3r::GUI::have_button_icons) {
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("wrench.png"), wxBITMAP_TYPE_PNG)); $btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("wrench.png"), wxBITMAP_TYPE_PNG));
}
EVT_BUTTON($self, $btn, sub { EVT_BUTTON($self, $btn, sub {
my $sender = Slic3r::GCode::Sender->new; my $sender = Slic3r::GCode::Sender->new;
@ -1367,9 +1363,7 @@ sub build {
my $btn = Wx::Button->new($parent, -1, "Browse…", wxDefaultPosition, wxDefaultSize, wxBU_LEFT); my $btn = Wx::Button->new($parent, -1, "Browse…", wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
$btn->SetFont($Slic3r::GUI::small_font); $btn->SetFont($Slic3r::GUI::small_font);
if ($Slic3r::GUI::have_button_icons) {
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("zoom.png"), wxBITMAP_TYPE_PNG)); $btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("zoom.png"), wxBITMAP_TYPE_PNG));
}
if (!eval "use Net::Bonjour; 1") { if (!eval "use Net::Bonjour; 1") {
$btn->Disable; $btn->Disable;
@ -1405,9 +1399,7 @@ sub build {
my $btn = $self->{octoprint_host_test_btn} = Wx::Button->new($parent, -1, my $btn = $self->{octoprint_host_test_btn} = Wx::Button->new($parent, -1,
"Test", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); "Test", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
$btn->SetFont($Slic3r::GUI::small_font); $btn->SetFont($Slic3r::GUI::small_font);
if ($Slic3r::GUI::have_button_icons) {
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("wrench.png"), wxBITMAP_TYPE_PNG)); $btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("wrench.png"), wxBITMAP_TYPE_PNG));
}
EVT_BUTTON($self, $btn, sub { EVT_BUTTON($self, $btn, sub {
my $ua = LWP::UserAgent->new; my $ua = LWP::UserAgent->new;