Custom Treebook implementation
This commit is contained in:
parent
e810f9b898
commit
9e6e3bd269
@ -22,26 +22,10 @@ sub new {
|
|||||||
my $self = $class->SUPER::new($parent, -1);
|
my $self = $class->SUPER::new($parent, -1);
|
||||||
|
|
||||||
my $tabpanel = Wx::Notebook->new($self, -1, Wx::wxDefaultPosition, Wx::wxDefaultSize, &Wx::wxNB_TOP);
|
my $tabpanel = Wx::Notebook->new($self, -1, Wx::wxDefaultPosition, Wx::wxDefaultSize, &Wx::wxNB_TOP);
|
||||||
my $make_treebook_tab = sub {
|
|
||||||
my $class = shift;
|
|
||||||
|
|
||||||
my $tab = Wx::Panel->new($tabpanel, -1);
|
|
||||||
my $sizer = Wx::BoxSizer->new(&Wx::wxVERTICAL);
|
|
||||||
$sizer->Add($class->new($tab), 1, &Wx::wxALL | &Wx::wxEXPAND, 5);
|
|
||||||
$tab->SetSizer($sizer);
|
|
||||||
return $tab;
|
|
||||||
};
|
|
||||||
|
|
||||||
my @tabs = (
|
|
||||||
$make_treebook_tab->('Slic3r::GUI::Tab::Print'),
|
|
||||||
$make_treebook_tab->('Slic3r::GUI::Tab::Filament'),
|
|
||||||
$make_treebook_tab->('Slic3r::GUI::Tab::Printer'),
|
|
||||||
);
|
|
||||||
|
|
||||||
$tabpanel->AddPage(Slic3r::GUI::Plater->new($tabpanel), "Plater");
|
$tabpanel->AddPage(Slic3r::GUI::Plater->new($tabpanel), "Plater");
|
||||||
$tabpanel->AddPage($tabs[0], "Print settings");
|
$tabpanel->AddPage(Slic3r::GUI::Tab::Print->new($tabpanel), "Print settings");
|
||||||
$tabpanel->AddPage($tabs[1], "Filament settings");
|
$tabpanel->AddPage(Slic3r::GUI::Tab::Filament->new($tabpanel), "Filament settings");
|
||||||
$tabpanel->AddPage($tabs[2], "Printer settings");
|
$tabpanel->AddPage(Slic3r::GUI::Tab::Printer->new($tabpanel), "Printer settings");
|
||||||
|
|
||||||
my $buttons_sizer;
|
my $buttons_sizer;
|
||||||
{
|
{
|
||||||
|
@ -4,17 +4,36 @@ use warnings;
|
|||||||
use utf8;
|
use utf8;
|
||||||
|
|
||||||
use Wx qw(:sizer :progressdialog);
|
use Wx qw(:sizer :progressdialog);
|
||||||
use Wx::Event qw();
|
use Wx::Event qw(EVT_TREE_SEL_CHANGED);
|
||||||
use base 'Wx::Treebook';
|
use base 'Wx::Panel';
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my ($parent) = @_;
|
my ($parent) = @_;
|
||||||
my $self = $class->SUPER::new($parent, -1, [-1,-1], [-1,-1], &Wx::wxBK_LEFT);
|
my $self = $class->SUPER::new($parent, -1, [-1,-1], [-1,-1], &Wx::wxBK_LEFT);
|
||||||
|
|
||||||
$self->{images} = Wx::ImageList->new(16, 16, 1);
|
$self->{sizer} = Wx::BoxSizer->new(&Wx::wxHORIZONTAL);
|
||||||
$self->AssignImageList($self->{images});
|
$self->{sizer}->SetSizeHints($self);
|
||||||
$self->{imagecount} = -1;
|
$self->SetSizer($self->{sizer});
|
||||||
|
|
||||||
|
$self->{treectrl} = Wx::TreeCtrl->new($self, -1, [-1, -1], [200, -1], &Wx::wxTR_NO_BUTTONS | &Wx::wxTR_HIDE_ROOT | &Wx::wxTR_SINGLE | &Wx::wxTR_NO_LINES);
|
||||||
|
$self->{sizer}->Add($self->{treectrl}, 0, &Wx::wxEXPAND);
|
||||||
|
|
||||||
|
$self->{icons} = Wx::ImageList->new(16, 16, 1);
|
||||||
|
$self->{treectrl}->AssignImageList($self->{icons});
|
||||||
|
$self->{iconcount} = -1;
|
||||||
|
|
||||||
|
$self->{treectrl}->AddRoot("root");
|
||||||
|
$self->{pages} = {};
|
||||||
|
$self->{treectrl}->SetIndent(0);
|
||||||
|
EVT_TREE_SEL_CHANGED($parent, $self->{treectrl}, sub {
|
||||||
|
$_->Hide for values %{$self->{pages}};
|
||||||
|
$self->{sizer}->Remove(1);
|
||||||
|
my $page = $self->{pages}->{ $self->{treectrl}->GetItemText($self->{treectrl}->GetSelection) };
|
||||||
|
$page->Show;
|
||||||
|
$self->{sizer}->Add($page, 1, &Wx::wxEXPAND | &Wx::wxLEFT, 5);
|
||||||
|
$self->{sizer}->Layout;
|
||||||
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
@ -22,17 +41,19 @@ sub new {
|
|||||||
sub AddOptionsPage {
|
sub AddOptionsPage {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $title = shift;
|
my $title = shift;
|
||||||
my $image = (ref $_[1]) ? undef : shift;
|
my $icon = (ref $_[1]) ? undef : shift;
|
||||||
my $page = Slic3r::GUI::Tab::Page->new($self, @_);
|
my $page = Slic3r::GUI::Tab::Page->new($self, @_);
|
||||||
|
|
||||||
my $bitmap = $image
|
my $bitmap = $icon
|
||||||
? Wx::Bitmap->new("$Slic3r::var/$image", &Wx::wxBITMAP_TYPE_PNG)
|
? Wx::Bitmap->new("$Slic3r::var/$icon", &Wx::wxBITMAP_TYPE_PNG)
|
||||||
: undef;
|
: undef;
|
||||||
if ($bitmap) {
|
if ($bitmap) {
|
||||||
$self->{images}->Add($bitmap);
|
$self->{icons}->Add($bitmap);
|
||||||
$self->{imagecount}++;
|
$self->{iconcount}++;
|
||||||
}
|
}
|
||||||
$self->AddPage($page, $title, undef, $self->{imagecount});
|
$page->Hide;
|
||||||
|
$self->{treectrl}->AppendItem($self->{treectrl}->GetRootItem, $title, $self->{iconcount});
|
||||||
|
$self->{pages}{$title} = $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
package Slic3r::GUI::Tab::Print;
|
package Slic3r::GUI::Tab::Print;
|
||||||
|
Loading…
Reference in New Issue
Block a user