Make the override panel prettier and prevent the default extruder setting from being deleted since it can't be readded manually
This commit is contained in:
parent
bf8c388568
commit
d75417601e
@ -50,6 +50,8 @@ has 'on_change' => (is => 'ro', default => sub { sub {} });
|
||||
has 'no_labels' => (is => 'ro', default => sub { 0 });
|
||||
has 'label_width' => (is => 'ro', default => sub { 180 });
|
||||
has 'extra_column' => (is => 'ro');
|
||||
has 'label_font' => (is => 'ro');
|
||||
has 'sidetext_font' => (is => 'ro', default => sub { Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) });
|
||||
|
||||
has 'sizer' => (is => 'rw');
|
||||
has '_triggers' => (is => 'ro', default => sub { {} });
|
||||
@ -73,8 +75,6 @@ sub BUILD {
|
||||
# TODO: border size may be related to wxWidgets 2.8.x vs. 2.9.x instead of wxMAC specific
|
||||
$self->sizer->Add($grid_sizer, 0, wxEXPAND | wxALL, &Wx::wxMAC ? 0 : 5);
|
||||
|
||||
$self->{sidetext_font} = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
|
||||
foreach my $line (@{$self->lines}) {
|
||||
if ($line->{widget}) {
|
||||
my $window = $line->{widget}->GetWindow($self->parent);
|
||||
@ -117,12 +117,17 @@ sub _build_line {
|
||||
my ($line, $grid_sizer) = @_;
|
||||
|
||||
if ($self->extra_column) {
|
||||
$grid_sizer->Add($self->extra_column->($line), 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
if (defined my $item = $self->extra_column->($line)) {
|
||||
$grid_sizer->Add($item, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
} else {
|
||||
$grid_sizer->AddSpacer(1);
|
||||
}
|
||||
}
|
||||
|
||||
my $label;
|
||||
if (!$self->no_labels) {
|
||||
$label = Wx::StaticText->new($self->parent, -1, $line->{label} ? "$line->{label}:" : "", wxDefaultPosition, [$self->label_width, -1]);
|
||||
$label->SetFont($self->label_font) if $self->label_font;
|
||||
$label->Wrap($self->label_width) ; # needed to avoid Linux/GTK bug
|
||||
$grid_sizer->Add($label, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
$label->SetToolTipString($line->{tooltip}) if $line->{tooltip};
|
||||
@ -140,14 +145,14 @@ sub _build_line {
|
||||
for my $i (0 .. $#fields) {
|
||||
if (@fields > 1 && $field_labels[$i]) {
|
||||
my $field_label = Wx::StaticText->new($self->parent, -1, "$field_labels[$i]:", wxDefaultPosition, wxDefaultSize);
|
||||
$field_label->SetFont($self->{sidetext_font});
|
||||
$field_label->SetFont($self->sidetext_font);
|
||||
$sizer->Add($field_label, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
}
|
||||
$sizer->Add($fields[$i], 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
}
|
||||
if ($line->{sidetext}) {
|
||||
my $sidetext = Wx::StaticText->new($self->parent, -1, $line->{sidetext}, wxDefaultPosition, wxDefaultSize);
|
||||
$sidetext->SetFont($self->{sidetext_font});
|
||||
$sidetext->SetFont($self->sidetext_font);
|
||||
$sizer->Add($sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL , 4);
|
||||
}
|
||||
$grid_sizer->Add($sizer);
|
||||
|
@ -3,7 +3,7 @@ use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
|
||||
use File::Basename qw(basename);
|
||||
use List::Util qw(first);
|
||||
use Wx qw(:misc :sizer :button wxTAB_TRAVERSAL wxSUNKEN_BORDER wxBITMAP_TYPE_PNG);
|
||||
use Wx::Event qw(EVT_BUTTON EVT_LEFT_DOWN EVT_MENU);
|
||||
use base 'Wx::ScrolledWindow';
|
||||
@ -20,10 +20,14 @@ sub new {
|
||||
|
||||
$self->{sizer} = Wx::BoxSizer->new(wxVERTICAL);
|
||||
|
||||
$self->{options_sizer} = Wx::BoxSizer->new(wxVERTICAL);
|
||||
$self->{sizer}->Add($self->{options_sizer}, 0, wxEXPAND | wxALL, 0);
|
||||
|
||||
# option selector
|
||||
{
|
||||
# create the button
|
||||
my $btn = $self->{btn_add} = 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),
|
||||
wxDefaultPosition, wxDefaultSize, Wx::wxBORDER_NONE);
|
||||
EVT_LEFT_DOWN($btn, sub {
|
||||
my $menu = Wx::Menu->new;
|
||||
foreach my $opt_key (@{$self->{options}}) {
|
||||
@ -39,13 +43,10 @@ sub new {
|
||||
});
|
||||
|
||||
my $h_sizer = Wx::BoxSizer->new(wxHORIZONTAL);
|
||||
$h_sizer->Add($btn, 0, wxEXPAND | wxLEFT, 10);
|
||||
$h_sizer->Add($btn, 0, wxALL, 0);
|
||||
$self->{sizer}->Add($h_sizer, 0, wxEXPAND | wxBOTTOM, 10);
|
||||
}
|
||||
|
||||
$self->{options_sizer} = Wx::BoxSizer->new(wxVERTICAL);
|
||||
$self->{sizer}->Add($self->{options_sizer}, 0, wxEXPAND | wxALL, 0);
|
||||
|
||||
$self->SetSizer($self->{sizer});
|
||||
$self->SetScrollbars(0, 1, 0, 1);
|
||||
|
||||
@ -90,10 +91,18 @@ sub update_optgroup {
|
||||
config => $self->{config},
|
||||
options => [ sort @{$categories{$category}} ],
|
||||
full_labels => 1,
|
||||
label_font => $Slic3r::GUI::small_font,
|
||||
sidetest_font => $Slic3r::GUI::small_font,
|
||||
label_width => 120,
|
||||
extra_column => sub {
|
||||
my ($line) = @_;
|
||||
my ($opt_key) = @{$line->{options}}; # we assume that we have one option per line
|
||||
my $btn = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new("$Slic3r::var/delete.png", wxBITMAP_TYPE_PNG));
|
||||
|
||||
# if this option is not listed in the ones the user can add, disallow deleting it
|
||||
return undef if !first { $_ eq $opt_key } @{$self->{options}};
|
||||
|
||||
my $btn = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new("$Slic3r::var/delete.png", wxBITMAP_TYPE_PNG),
|
||||
wxDefaultPosition, wxDefaultSize, Wx::wxBORDER_NONE);
|
||||
EVT_BUTTON($self, $btn, sub {
|
||||
$self->{config}->erase($opt_key);
|
||||
Slic3r::GUI->CallAfter(sub { $self->update_optgroup });
|
||||
@ -101,7 +110,7 @@ sub update_optgroup {
|
||||
return $btn;
|
||||
},
|
||||
);
|
||||
$self->{options_sizer}->Add($optgroup->sizer, 0, wxEXPAND | wxBOTTOM, 10);
|
||||
$self->{options_sizer}->Add($optgroup->sizer, 0, wxEXPAND | wxBOTTOM, 0);
|
||||
}
|
||||
$self->Layout;
|
||||
}
|
||||
|
@ -173,6 +173,8 @@ class PrintConfigDef
|
||||
|
||||
Options["extruder"].type = coInt;
|
||||
Options["extruder"].label = "Default extruder";
|
||||
Options["extruder"].category = "Extruders";
|
||||
Options["extruder"].tooltip = "The extruder to use (unless more specific extruder settings are specified).";
|
||||
Options["extruder"].cli = "extruder=i";
|
||||
Options["extruder"].min = 1;
|
||||
Options["extruder"].shortcut.push_back("infill_extruder");
|
||||
|
Loading…
Reference in New Issue
Block a user