diff --git a/src/GUI/GUI.hpp b/src/GUI/GUI.hpp index c693e847b..e6c89b90f 100644 --- a/src/GUI/GUI.hpp +++ b/src/GUI/GUI.hpp @@ -2,14 +2,17 @@ #define GUI_HPP #include "MainFrame.hpp" #include "Notifier.hpp" +#include namespace Slic3r { namespace GUI { +// Friendly indices for the preset lists. enum class PresetID { PRINT = 0, FILAMENT = 1, PRINTER = 2 }; +using preset_list = std::vector; class App: public wxApp { @@ -22,7 +25,7 @@ public: private: std::shared_ptr gui_config; // GUI-specific configuration options Notifier* notifier; - + std::vector presets { preset_list(), preset_list(), preset_list() }; }; }} // namespace Slic3r::GUI diff --git a/src/GUI/MainFrame.cpp b/src/GUI/MainFrame.cpp index 547c0757b..f006423b1 100644 --- a/src/GUI/MainFrame.cpp +++ b/src/GUI/MainFrame.cpp @@ -15,6 +15,11 @@ MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& si 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. + if (the_os == OS::Windows) + this->SetIcon(wxIcon(var("Slic3r.ico"), wxBITMAP_TYPE_ICO)); + else + this->SetIcon(wxIcon(var("Slic3r_128px.png"), wxBITMAP_TYPE_PNG)); + this->init_tabpanel(); this->init_menubar(); diff --git a/src/GUI/misc_ui.cpp b/src/GUI/misc_ui.cpp index b509cf097..278f6e4d7 100644 --- a/src/GUI/misc_ui.cpp +++ b/src/GUI/misc_ui.cpp @@ -11,5 +11,20 @@ void check_version(bool manual) { #endif +const wxString var(const wxString& in) { + wxFileName f(wxStandardPaths::Get().GetExecutablePath()); + wxString appPath(f.GetPath()); + + // replace center string with path to VAR in actual distribution later + return appPath + "/../var/" + in; +} + +/// Returns the path to Slic3r's default user data directory. +const wxString home(const wxString& in) { + if (the_os == OS::Windows) + return wxGetHomeDir() + "/" + in + "/"; + return wxGetHomeDir() + "/." + in + "/"; +} + }} // namespace Slic3r::GUI diff --git a/src/GUI/misc_ui.hpp b/src/GUI/misc_ui.hpp index 83ef2646c..cc92e5a03 100644 --- a/src/GUI/misc_ui.hpp +++ b/src/GUI/misc_ui.hpp @@ -1,15 +1,44 @@ #ifndef MISC_UI_HPP #define MISC_UI_HPP +#include +#ifndef WX_PRECOMP + #include +#endif + +#include +#include + /// Common static (that is, free-standing) functions, not part of an object hierarchy. namespace Slic3r { namespace GUI { +enum class OS { Linux, Mac, Windows } ; +// constants to reduce the proliferation of macros in the rest of the code +#ifdef __WIN32 +constexpr OS the_os = OS::Windows; +#elif __APPLE__ +constexpr OS the_os = OS::Mac; +#elif __linux__ +constexpr OS the_os = OS::Linux; +#endif + +#ifdef SLIC3R_DEV +constexpr bool isDev = true; +#else +constexpr bool isDev = false; +#endif + /// Performs a check via the Internet for a new version of Slic3r. -/// If this version of Slic3r was compiled with SLIC3R_DEV, check the development +/// If this version of Slic3r was compiled with -DSLIC3R_DEV, check the development /// space instead of release. void check_version(bool manual = false); +const wxString var(const wxString& in); + +/// Always returns path to home directory. +const wxString home(const wxString& in = "Slic3r"); + }} // namespace Slic3r::GUI #endif // MISC_UI_HPP