From d1acc511b35216b9d0cd251b9d563361cd3f7240 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 10 Mar 2013 12:46:54 +0100 Subject: [PATCH] Refactor ObjectDialog into a tab panel --- lib/Slic3r/GUI/Plater/ObjectDialog.pm | 63 ++++++++++++++++++--------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/lib/Slic3r/GUI/Plater/ObjectDialog.pm b/lib/Slic3r/GUI/Plater/ObjectDialog.pm index d55b36a81..3f0dd5615 100644 --- a/lib/Slic3r/GUI/Plater/ObjectDialog.pm +++ b/lib/Slic3r/GUI/Plater/ObjectDialog.pm @@ -1,17 +1,44 @@ 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 base 'Wx::Dialog'; sub new { my $class = shift; 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->{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; +} - my $properties_box = Wx::StaticBox->new($self, -1, "Info", wxDefaultPosition, [400,200]); +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); - $properties_box->SetSizer($grid_sizer); $grid_sizer->SetFlexibleDirection(wxHORIZONTAL); $grid_sizer->AddGrowableCol(1); @@ -20,22 +47,15 @@ sub new { my $properties = $self->get_properties; foreach my $property (@$properties) { - my $label = Wx::StaticText->new($properties_box, -1, $property->[0] . ":"); - my $value = Wx::StaticText->new($properties_box, -1, $property->[1]); + my $label = Wx::StaticText->new($self, -1, $property->[0] . ":"); + my $value = Wx::StaticText->new($self, -1, $property->[1]); $label->SetFont($label_font); $grid_sizer->Add($label, 1, wxALIGN_BOTTOM); $grid_sizer->Add($value, 0); } - my $buttons = $self->CreateStdDialogButtonSizer(wxOK); - EVT_BUTTON($self, wxID_OK, sub { $self->EndModal(wxID_OK); }); - - 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); + $self->SetSizer($grid_sizer); + $grid_sizer->SetSizeHints($self); return $self; } @@ -43,13 +63,14 @@ sub new { sub get_properties { my $self = shift; + my $object = $self->GetParent->GetParent->{object}; return [ - ['Name' => $self->{object}->name], - ['Size' => sprintf "%.2f x %.2f x %.2f", @{$self->{object}->size}], - ['Facets' => $self->{object}->facets], - ['Vertices' => $self->{object}->vertices], - ['Materials' => $self->{object}->materials], - ['Two-Manifold' => $self->{object}->is_manifold ? 'Yes' : 'No'], + ['Name' => $object->name], + ['Size' => sprintf "%.2f x %.2f x %.2f", @{$object->size}], + ['Facets' => $object->facets], + ['Vertices' => $object->vertices], + ['Materials' => $object->materials], + ['Two-Manifold' => $object->is_manifold ? 'Yes' : 'No'], ]; }