Stubbing out more of the UI.

This commit is contained in:
Joseph Lenox 2018-04-24 17:21:18 -05:00
parent a06755c3dd
commit b04d58ecef
8 changed files with 96 additions and 10 deletions

15
src/GUI/Controller.hpp Normal file
View File

@ -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

View File

@ -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

View File

@ -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<Settings> gui_config; // GUI-specific configuration options
public:
virtual bool OnInit();
App(std::shared_ptr<Settings> config) : wxApp(), gui_config(config) {}
};
}} // namespace Slic3r::GUI
#endif // GUI_HPP

View File

@ -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<Settings> 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

View File

@ -8,12 +8,21 @@
#include <wx/aui/auibook.h>
#include <wx/tooltip.h>
#include <memory>
#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<Settings> gui_config);
private:
wxDECLARE_EVENT_TABLE();
@ -25,7 +34,13 @@ private:
// STUB: Statusbar reference
wxAuiNotebook* tabpanel;
Controller* controller;
Plater* plater;
std::shared_ptr<Settings> gui_config;
};
}} // Namespace Slic3r::GUI
#endif // MAINFRAME_HPP

17
src/GUI/Plater.hpp Normal file
View File

@ -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

15
src/GUI/Settings.hpp Normal file
View File

@ -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

View File

@ -41,9 +41,11 @@ main(int argc, char **argv)
DynamicPrintConfig print_config;
Slic3rGUI *gui = new Slic3rGUI;
std::shared_ptr<GUI::Settings> gui_config = std::make_shared<GUI::Settings>();
Slic3rGUI::SetInstance(gui);
GUI::App *gui = new GUI::App(gui_config);
GUI::App::SetInstance(gui);
wxEntry(argc, argv);
// load config files supplied via --load