Finished implementing bed shape configuration within wizard

This commit is contained in:
Alessandro Ranellucci 2014-06-16 22:45:13 +02:00
parent db031a6210
commit d6d796fdd4
3 changed files with 21 additions and 6 deletions

View File

@ -551,13 +551,13 @@ sub config_wizard {
my $self = shift;
return unless $self->check_unsaved_changes;
if (my $config = Slic3r::GUI::ConfigWizard->new($self)->run) {use XXX; YYY $config->bed_shape;
if (my $config = Slic3r::GUI::ConfigWizard->new($self)->run) {
if ($self->{mode} eq 'expert') {
for my $tab (values %{$self->{options_tabs}}) {
$tab->select_default_preset;
}
}
$self->load_config($config);use XXX; YYY $self->config->bed_shape;
$self->load_config($config);
if ($self->{mode} eq 'expert') {
for my $tab (values %{$self->{options_tabs}}) {
$tab->save_preset('My Settings');

View File

@ -80,6 +80,13 @@ sub BUILD {
$self->sizer->Add($grid_sizer, 0, wxEXPAND | wxALL, &Wx::wxMAC ? 0 : 5);
foreach my $line (@{$self->lines}) {
# build default callbacks in case we don't call _build_line() below
foreach my $opt_key (@{$line->{options}}) {
my $opt = first { $_->{opt_key} eq $opt_key } @{$self->options};
$self->_setters->{$opt_key} //= sub {};
$self->_triggers->{$opt_key} = $opt->{on_change} || sub { return 1 };
}
if ($line->{sizer}) {
$self->sizer->Add($line->{sizer}, 0, wxEXPAND | wxALL, &Wx::wxMAC ? 0 : 15);
} elsif ($line->{widget} && $line->{full_width}) {
@ -143,7 +150,7 @@ sub _build_line {
my @field_labels = ();
foreach my $opt_key (@{$line->{options}}) {
my $opt = first { $_->{opt_key} eq $opt_key } @{$self->options};
push @fields, $self->_build_field($opt);
push @fields, $self->_build_field($opt) unless $line->{widget};
push @field_labels, $opt->{label};
}
if (@fields > 1 || $line->{widget} || $line->{sidetext}) {
@ -175,7 +182,6 @@ sub _build_field {
my ($opt) = @_;
my $opt_key = $opt->{opt_key};
$self->_triggers->{$opt_key} = $opt->{on_change} || sub { return 1 };
my $on_kill_focus = sub {
my ($s, $event) = @_;
@ -369,6 +375,7 @@ has '+ignore_on_change_return' => (is => 'ro', default => sub { 0 });
sub _trigger_options {
my $self = shift;
$self->SUPER::_trigger_options;
@{$self->options} = map {
my $opt = $_;
if (ref $opt ne 'HASH') {
@ -414,10 +421,17 @@ sub set_value {
if ($key eq $opt_key) {
$self->config->set($key, $value);
$self->SUPER::set_value($full_key, $self->_get_config($key, $index));
$changed = 1;
return 1;
}
}
return $changed;
# if we're here, we know this option but we found no setter, so we just propagate it
if ($self->config->has($opt_key)) {
$self->config->set($opt_key, $value);
$self->SUPER::set_value($opt_key, $value);
return 1;
}
return 0;
}
sub on_kill_focus {

View File

@ -709,6 +709,7 @@ sub build {
{
label => 'Bed shape',
widget => $bed_shape_widget,
options => ['bed_shape'],
},
Slic3r::GUI::OptionsGroup->single_option_line('print_center'),
Slic3r::GUI::OptionsGroup->single_option_line('z_offset'),