Refactor ObjectDialog into a tab panel
This commit is contained in:
parent
6a0ba97f0e
commit
d1acc511b3
@ -1,17 +1,44 @@
|
|||||||
package Slic3r::GUI::Plater::ObjectDialog;
|
package Slic3r::GUI::Plater::ObjectDialog;
|
||||||
use Wx qw(:dialog :id :misc :sizer :systemsettings);
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use utf8;
|
||||||
|
|
||||||
|
use Wx qw(:dialog :id :misc :sizer :systemsettings :notebook wxTAB_TRAVERSAL);
|
||||||
use Wx::Event qw(EVT_BUTTON EVT_TEXT_ENTER);
|
use Wx::Event qw(EVT_BUTTON EVT_TEXT_ENTER);
|
||||||
use base 'Wx::Dialog';
|
use base 'Wx::Dialog';
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my ($parent, %params) = @_;
|
my ($parent, %params) = @_;
|
||||||
my $self = $class->SUPER::new($parent, -1, "Object Info", wxDefaultPosition, wxDefaultSize);
|
my $self = $class->SUPER::new($parent, -1, "Object", wxDefaultPosition, [500,350]);
|
||||||
$self->{object} = $params{object};
|
$self->{object} = $params{object};
|
||||||
|
|
||||||
my $properties_box = Wx::StaticBox->new($self, -1, "Info", wxDefaultPosition, [400,200]);
|
$self->{tabpanel} = Wx::Notebook->new($self, -1, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL);
|
||||||
|
$self->{tabpanel}->AddPage($self->{info} = Slic3r::GUI::Plater::ObjectDialog::InfoTab->new($self->{tabpanel}), "Info");
|
||||||
|
|
||||||
|
my $buttons = $self->CreateStdDialogButtonSizer(wxOK);
|
||||||
|
EVT_BUTTON($self, wxID_OK, sub { $self->EndModal(wxID_OK); });
|
||||||
|
|
||||||
|
my $sizer = Wx::BoxSizer->new(wxVERTICAL);
|
||||||
|
$sizer->Add($self->{tabpanel}, 1, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 10);
|
||||||
|
$sizer->Add($buttons, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
|
||||||
|
|
||||||
|
$self->SetSizer($sizer);
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
package Slic3r::GUI::Plater::ObjectDialog::InfoTab;
|
||||||
|
use Wx qw(:dialog :id :misc :sizer :systemsettings);
|
||||||
|
use Wx::Event qw(EVT_BUTTON EVT_TEXT_ENTER);
|
||||||
|
use base 'Wx::Panel';
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my $class = shift;
|
||||||
|
my ($parent, %params) = @_;
|
||||||
|
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize);
|
||||||
|
|
||||||
my $grid_sizer = Wx::FlexGridSizer->new(3, 2, 10, 5);
|
my $grid_sizer = Wx::FlexGridSizer->new(3, 2, 10, 5);
|
||||||
$properties_box->SetSizer($grid_sizer);
|
|
||||||
$grid_sizer->SetFlexibleDirection(wxHORIZONTAL);
|
$grid_sizer->SetFlexibleDirection(wxHORIZONTAL);
|
||||||
$grid_sizer->AddGrowableCol(1);
|
$grid_sizer->AddGrowableCol(1);
|
||||||
|
|
||||||
@ -20,22 +47,15 @@ sub new {
|
|||||||
|
|
||||||
my $properties = $self->get_properties;
|
my $properties = $self->get_properties;
|
||||||
foreach my $property (@$properties) {
|
foreach my $property (@$properties) {
|
||||||
my $label = Wx::StaticText->new($properties_box, -1, $property->[0] . ":");
|
my $label = Wx::StaticText->new($self, -1, $property->[0] . ":");
|
||||||
my $value = Wx::StaticText->new($properties_box, -1, $property->[1]);
|
my $value = Wx::StaticText->new($self, -1, $property->[1]);
|
||||||
$label->SetFont($label_font);
|
$label->SetFont($label_font);
|
||||||
$grid_sizer->Add($label, 1, wxALIGN_BOTTOM);
|
$grid_sizer->Add($label, 1, wxALIGN_BOTTOM);
|
||||||
$grid_sizer->Add($value, 0);
|
$grid_sizer->Add($value, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $buttons = $self->CreateStdDialogButtonSizer(wxOK);
|
$self->SetSizer($grid_sizer);
|
||||||
EVT_BUTTON($self, wxID_OK, sub { $self->EndModal(wxID_OK); });
|
$grid_sizer->SetSizeHints($self);
|
||||||
|
|
||||||
my $sizer = Wx::BoxSizer->new(wxVERTICAL);
|
|
||||||
$sizer->Add($properties_box, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 10);
|
|
||||||
$sizer->Add($buttons, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
|
|
||||||
|
|
||||||
$self->SetSizer($sizer);
|
|
||||||
$sizer->SetSizeHints($self);
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
@ -43,13 +63,14 @@ sub new {
|
|||||||
sub get_properties {
|
sub get_properties {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
|
my $object = $self->GetParent->GetParent->{object};
|
||||||
return [
|
return [
|
||||||
['Name' => $self->{object}->name],
|
['Name' => $object->name],
|
||||||
['Size' => sprintf "%.2f x %.2f x %.2f", @{$self->{object}->size}],
|
['Size' => sprintf "%.2f x %.2f x %.2f", @{$object->size}],
|
||||||
['Facets' => $self->{object}->facets],
|
['Facets' => $object->facets],
|
||||||
['Vertices' => $self->{object}->vertices],
|
['Vertices' => $object->vertices],
|
||||||
['Materials' => $self->{object}->materials],
|
['Materials' => $object->materials],
|
||||||
['Two-Manifold' => $self->{object}->is_manifold ? 'Yes' : 'No'],
|
['Two-Manifold' => $object->is_manifold ? 'Yes' : 'No'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user