Go back to using regular Notebook instead of AuiNotebook for tabs.

This commit is contained in:
Joseph Lenox 2018-11-10 11:56:00 -06:00
parent 2fae745f56
commit 26b2a1e0cd
2 changed files with 17 additions and 29 deletions

View File

@ -9,9 +9,8 @@ use File::Basename qw(basename dirname);
use List::Util qw(min);
use Slic3r::Geometry qw(X Y Z);
use Wx qw(:frame :bitmap :id :misc :panel :sizer :menu :dialog :filedialog
:font :icon :aui wxTheApp);
use Wx::AUI;
use Wx::Event qw(EVT_CLOSE EVT_AUINOTEBOOK_PAGE_CHANGED EVT_AUINOTEBOOK_PAGE_CLOSE);
:font :icon :notebook wxTheApp);
use Wx::Event qw(EVT_CLOSE EVT_NOTEBOOK_PAGE_CHANGED);
use base 'Wx::Frame';
our $qs_last_input_file;
@ -94,26 +93,10 @@ sub new {
sub _init_tabpanel {
my ($self) = @_;
$self->{tabpanel} = my $panel = Wx::AuiNotebook->new($self, -1, wxDefaultPosition, wxDefaultSize, wxAUI_NB_TOP);
EVT_AUINOTEBOOK_PAGE_CHANGED($self, $self->{tabpanel}, sub {
my $panel = $self->{tabpanel}->GetPage($self->{tabpanel}->GetSelection);
$self->{tabpanel} = my $panel = Wx::Notebook->new($self, -1, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL);
EVT_NOTEBOOK_PAGE_CHANGED($self, $self->{tabpanel}, sub {
my $panel = $self->{tabpanel}->GetCurrentPage;
$panel->OnActivate if $panel->can('OnActivate');
if ($self->{tabpanel}->GetSelection > 1) {
$self->{tabpanel}->SetWindowStyle($self->{tabpanel}->GetWindowStyleFlag);
} elsif(!$Slic3r::GUI::Settings->{_}{show_host} && ($self->{tabpanel}->GetSelection == 1)){
$self->{tabpanel}->SetWindowStyle($self->{tabpanel}->GetWindowStyleFlag | wxAUI_NB_CLOSE_ON_ACTIVE_TAB);
} else {
$self->{tabpanel}->SetWindowStyle($self->{tabpanel}->GetWindowStyleFlag & ~wxAUI_NB_CLOSE_ON_ACTIVE_TAB);
}
});
EVT_AUINOTEBOOK_PAGE_CLOSE($self, $self->{tabpanel}, sub {
my $panel = $self->{tabpanel}->GetPage($self->{tabpanel}->GetSelection);
if ($panel->isa('Slic3r::GUI::PresetEditor')) {
delete $self->{preset_editor_tabs}{$panel->name};
}
wxTheApp->CallAfter(sub {
$self->{tabpanel}->SetSelection(0);
});
});
$panel->AddPage($self->{plater} = Slic3r::GUI::Plater->new($panel), "Plater");
@ -121,9 +104,9 @@ sub _init_tabpanel {
if ($Slic3r::GUI::Settings->{_}{show_host});
if ($Slic3r::GUI::Settings->{_}{tabbed_preset_editors}) {
$self->{plater}->show_preset_editor('print', 0,0,0);
$self->{plater}->show_preset_editor('filament', 0,0,0);
$self->{plater}->show_preset_editor('printer', 0, 0, 0);
foreach my $group (qw(print filament printer)) {
$self->{plater}->show_preset_editor($group, 0, $panel);
}
}
}

View File

@ -884,7 +884,7 @@ sub selected_presets {
}
sub show_preset_editor {
my ($self, $group, $i, $load) = @_;
my ($self, $group, $i, $panel) = @_;
wxTheApp->CallAfter(sub {
my @presets = $self->selected_presets($group);
@ -894,13 +894,18 @@ sub show_preset_editor {
my $mainframe = $self->GetFrame;
my $tabpanel = $mainframe->{tabpanel};
if (exists $mainframe->{preset_editor_tabs}{$group}) {
my $tabindex = 0;
$tabindex = 1 if $Slic3r::GUI::Settings->{_}{show_host};
$tabindex += 1 if $group eq 'print';
$tabindex += 2 if $group eq 'filament';
$tabindex += 3 if $group eq 'printer';
# we already have an open editor
$tabpanel->SetSelection($tabpanel->GetPageIndex($mainframe->{preset_editor_tabs}{$group}));
$tabpanel->SetSelection($tabindex);
return;
} elsif ($Slic3r::GUI::Settings->{_}{tabbed_preset_editors}) {
my $class = "Slic3r::GUI::PresetEditor::" . ucfirst($group);
$mainframe->{preset_editor_tabs}{$group} = $preset_editor = $class->new($self->GetFrame);
$tabpanel->AddPage($preset_editor, ucfirst($group) . " Settings", $load);
$mainframe->{preset_editor_tabs}{$group} = $preset_editor = $class->new($tabpanel);
$tabpanel->AddPage($preset_editor, ucfirst($group) . " Settings");
} else {
my $class = "Slic3r::GUI::PresetEditorDialog::" . ucfirst($group);
$dlg = $class->new($self);