diff --git a/src/GUI/MainFrame.cpp b/src/GUI/MainFrame.cpp index c3684c27b..8c2575cf8 100644 --- a/src/GUI/MainFrame.cpp +++ b/src/GUI/MainFrame.cpp @@ -1,6 +1,4 @@ #include "MainFrame.hpp" -#include "Plater.hpp" -#include "Controller.hpp" namespace Slic3r { namespace GUI { @@ -11,7 +9,7 @@ MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& si : MainFrame(title, pos, size, nullptr) {} MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, std::shared_ptr config) : wxFrame(NULL, wxID_ANY, title, pos, size), loaded(false), - tabpanel(nullptr), controller(nullptr), plater(nullptr), gui_config(config) + tabpanel(nullptr), controller(nullptr), plater(nullptr), gui_config(config), preset_editor_tabs(std::map()) { // Set icon to either the .ico if windows or png for everything else. @@ -40,7 +38,34 @@ MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& si this->Show(); this->Layout(); } - +/* + # declare events + EVT_CLOSE($self, sub { + my (undef, $event) = @_; + + if ($event->CanVeto) { + if (!$self->{plater}->prompt_unsaved_changes) { + $event->Veto; + return; + } + + if ($self->{controller} && $self->{controller}->printing) { + my $confirm = Wx::MessageDialog->new($self, "You are currently printing. Do you want to stop printing and continue anyway?", + 'Unfinished Print', wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT); + if ($confirm->ShowModal == wxID_NO) { + $event->Veto; + return; + } + } + } + + # save window size + wxTheApp->save_window_pos($self, "main_frame"); + + # propagate event + $event->Skip; + }); +*/ } /// Private initialization function for the main frame tab panel. @@ -51,9 +76,8 @@ void MainFrame::init_tabpanel() panel->Bind(wxEVT_AUINOTEBOOK_PAGE_CHANGED, ([=](wxAuiNotebookEvent& e) { - auto panel = this->tabpanel->GetPage(this->tabpanel->GetSelection()); auto tabpanel = this->tabpanel; - // todo: trigger processing for activation(?) + // TODO: trigger processing for activation event if (tabpanel->GetSelection() > 1) { tabpanel->SetWindowStyle(tabpanel->GetWindowStyleFlag() | wxAUI_NB_CLOSE_ON_ACTIVE_TAB); } else if (this->gui_config->show_host == false && tabpanel->GetSelection() == 1) { @@ -63,40 +87,20 @@ void MainFrame::init_tabpanel() } }), panel->GetId()); + panel->Bind(wxEVT_AUINOTEBOOK_PAGE_CLOSE, ([=](wxAuiNotebookEvent& e) + { + if (typeid(panel) == typeid(Slic3r::GUI::PresetEditor)) { + wxDELETE(this->preset_editor_tabs[panel->GetId()]); + } + wxTheApp->CallAfter([=] { this->tabpanel->SetSelection(0); }); + }), panel->GetId()); + this->plater = new Slic3r::GUI::Plater(panel, _("Plater")); this->controller = new Slic3r::GUI::Controller(panel, _("Controller")); - -/* -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); - $panel->OnActivate if $panel->can('OnActivate'); - if ($self->{tabpanel}->GetSelection > 1) { - $self->{tabpanel}->SetWindowStyle($self->{tabpanel}->GetWindowStyleFlag | wxAUI_NB_CLOSE_ON_ACTIVE_TAB); - } elsif(($Slic3r::GUI::Settings->{_}{show_host} == 0) && ($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"); - $panel->AddPage($self->{controller} = Slic3r::GUI::Controller->new($panel), "Controller") - if ($Slic3r::GUI::Settings->{_}{show_host}); -*/ + panel->AddPage(this->plater, this->plater->GetName()); + if (this->gui_config->show_host) panel->AddPage(this->controller, this->controller->GetName()); + } void MainFrame::init_menubar() diff --git a/src/GUI/MainFrame.hpp b/src/GUI/MainFrame.hpp index 8631ac78a..76a2146eb 100644 --- a/src/GUI/MainFrame.hpp +++ b/src/GUI/MainFrame.hpp @@ -9,9 +9,12 @@ #include #include +#include + #include "Controller.hpp" #include "Plater.hpp" +#include "PresetEditor.hpp" #include "Settings.hpp" namespace Slic3r { namespace GUI { @@ -39,6 +42,7 @@ private: std::shared_ptr gui_config; + std::map preset_editor_tabs; }; diff --git a/src/GUI/PresetEditor.hpp b/src/GUI/PresetEditor.hpp new file mode 100644 index 000000000..8d6359eab --- /dev/null +++ b/src/GUI/PresetEditor.hpp @@ -0,0 +1,11 @@ +#ifndef PRESETEDITOR_HPP +#define PRESETEDITOR_HPP + +namespace Slic3r { namespace GUI { + +class PresetEditor : public wxPanel { + +}; + +}} // namespace Slic3r::GUI +#endif // PRESETEDITOR_HPP diff --git a/src/slic3r.cpp b/src/slic3r.cpp index 9dc862400..82a04a1f1 100644 --- a/src/slic3r.cpp +++ b/src/slic3r.cpp @@ -44,6 +44,8 @@ main(int argc, char **argv) std::shared_ptr gui_config = std::make_shared(); GUI::App *gui = new GUI::App(gui_config); + + gui_config->show_host = true; GUI::App::SetInstance(gui); wxEntry(argc, argv);