diff --git a/src/GUI/Controller.hpp b/src/GUI/Controller.hpp new file mode 100644 index 000000000..ef3650886 --- /dev/null +++ b/src/GUI/Controller.hpp @@ -0,0 +1,15 @@ +#ifndef CONTROLLER_UI_HPP +#define CONTROLLER_UI_HPP + +namespace Slic3r { namespace GUI { + +class Controller : public wxPanel { +public: + Controller(wxWindow* parent, const wxString& title) : + wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, title) + { } +}; + +}} // Namespace Slic3r::GUI + +#endif // CONTROLLER_UI_HPP diff --git a/src/GUI/GUI.cpp b/src/GUI/GUI.cpp index 3c669754f..7c249b3b0 100644 --- a/src/GUI/GUI.cpp +++ b/src/GUI/GUI.cpp @@ -5,18 +5,19 @@ #include "MainFrame.hpp" #include "GUI.hpp" -//using namespace Slic3r; +namespace Slic3r { namespace GUI { enum { ID_Hello = 1 }; -bool Slic3rGUI::OnInit() +bool App::OnInit() { - MainFrame *frame = new MainFrame( "Slic3r", wxDefaultPosition, wxDefaultSize); + MainFrame *frame = new MainFrame( "Slic3r", wxDefaultPosition, wxDefaultSize, this->gui_config); frame->Show( true ); return true; } +}} // namespace Slic3r::GUI diff --git a/src/GUI/GUI.hpp b/src/GUI/GUI.hpp index d287c9a9b..1339d1d34 100644 --- a/src/GUI/GUI.hpp +++ b/src/GUI/GUI.hpp @@ -1,10 +1,15 @@ #ifndef GUI_HPP #define GUI_HPP #include "MainFrame.hpp" -class Slic3rGUI: public wxApp + +namespace Slic3r { namespace GUI { +class App: public wxApp { + std::shared_ptr gui_config; // GUI-specific configuration options public: virtual bool OnInit(); + App(std::shared_ptr config) : wxApp(), gui_config(config) {} }; +}} // namespace Slic3r::GUI #endif // GUI_HPP diff --git a/src/GUI/MainFrame.cpp b/src/GUI/MainFrame.cpp index d21d2767e..c3684c27b 100644 --- a/src/GUI/MainFrame.cpp +++ b/src/GUI/MainFrame.cpp @@ -1,11 +1,17 @@ #include "MainFrame.hpp" +#include "Plater.hpp" +#include "Controller.hpp" + +namespace Slic3r { namespace GUI { wxBEGIN_EVENT_TABLE(MainFrame, wxFrame) wxEND_EVENT_TABLE() MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size) + : 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(NULL) + tabpanel(nullptr), controller(nullptr), plater(nullptr), gui_config(config) { // Set icon to either the .ico if windows or png for everything else. @@ -46,11 +52,19 @@ void MainFrame::init_tabpanel() panel->Bind(wxEVT_AUINOTEBOOK_PAGE_CHANGED, ([=](wxAuiNotebookEvent& e) { auto panel = this->tabpanel->GetPage(this->tabpanel->GetSelection()); - if panel->can('OnActivate') panel->OnActivate(); + auto tabpanel = this->tabpanel; + // todo: trigger processing for activation(?) + 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) { + tabpanel->SetWindowStyle(tabpanel->GetWindowStyleFlag() | wxAUI_NB_CLOSE_ON_ACTIVE_TAB); + } else { + tabpanel->SetWindowStyle(tabpanel->GetWindowStyleFlag() | ~wxAUI_NB_CLOSE_ON_ACTIVE_TAB); + } }), panel->GetId()); -// this->plater = Slic3r::GUI::Plater(panel, _("Plater")); -// this->controller = Slic3r::GUI::Controller(panel, _("Controller")); + this->plater = new Slic3r::GUI::Plater(panel, _("Plater")); + this->controller = new Slic3r::GUI::Controller(panel, _("Controller")); /* sub _init_tabpanel { @@ -88,3 +102,5 @@ sub _init_tabpanel { void MainFrame::init_menubar() { } + +}} // Namespace Slic3r::GUI diff --git a/src/GUI/MainFrame.hpp b/src/GUI/MainFrame.hpp index a1b32feb8..8631ac78a 100644 --- a/src/GUI/MainFrame.hpp +++ b/src/GUI/MainFrame.hpp @@ -8,12 +8,21 @@ #include #include +#include + +#include "Controller.hpp" +#include "Plater.hpp" +#include "Settings.hpp" + +namespace Slic3r { namespace GUI { + constexpr unsigned int TOOLTIP_TIMER = 32767; class MainFrame: public wxFrame { public: MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size); + MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, std::shared_ptr gui_config); private: wxDECLARE_EVENT_TABLE(); @@ -25,7 +34,13 @@ private: // STUB: Statusbar reference wxAuiNotebook* tabpanel; + Controller* controller; + Plater* plater; + + + std::shared_ptr gui_config; }; +}} // Namespace Slic3r::GUI #endif // MAINFRAME_HPP diff --git a/src/GUI/Plater.hpp b/src/GUI/Plater.hpp new file mode 100644 index 000000000..bf7aa917a --- /dev/null +++ b/src/GUI/Plater.hpp @@ -0,0 +1,17 @@ +#ifndef PLATER_HPP +#define PLATER_HPP + +namespace Slic3r { namespace GUI { + +class Plater : public wxPanel +{ +public: + Plater(wxWindow* parent, const wxString& title) : + wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, title) + { } + +}; + +} } // Namespace Slic3r::GUI + +#endif // PLATER_HPP diff --git a/src/GUI/Settings.hpp b/src/GUI/Settings.hpp new file mode 100644 index 000000000..07e219406 --- /dev/null +++ b/src/GUI/Settings.hpp @@ -0,0 +1,15 @@ +#ifndef SETTINGS_HPP +#define SETTINGS_HPP +namespace Slic3r { namespace GUI { + +/// Stub class to hold onto GUI-specific settings options. +/// TODO: Incorporate a copy of Slic3r::Config +class Settings { + public: + bool show_host; + Settings(): show_host(false) {} //< Show host/controller tab +}; + +}} //namespace Slic3r::GUI + +#endif // SETTINGS_HPP diff --git a/src/slic3r.cpp b/src/slic3r.cpp index 558d3f810..9dc862400 100644 --- a/src/slic3r.cpp +++ b/src/slic3r.cpp @@ -41,9 +41,11 @@ main(int argc, char **argv) DynamicPrintConfig print_config; - Slic3rGUI *gui = new Slic3rGUI; + std::shared_ptr gui_config = std::make_shared(); - Slic3rGUI::SetInstance(gui); + GUI::App *gui = new GUI::App(gui_config); + + GUI::App::SetInstance(gui); wxEntry(argc, argv); // load config files supplied via --load