mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-03 18:50:39 +08:00
Push GUI config/settings store out to a singleton unique_ptr that is instantiated during OnInit.
This commit is contained in:
parent
f20128bf4a
commit
650bcc8c4c
@ -15,7 +15,7 @@ PresetEditor::PresetEditor(wxWindow* parent, t_config_option_keys options) :
|
||||
{
|
||||
// choice menu
|
||||
this->_presets_choice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxSize(left_col_width, -1));
|
||||
this->_presets_choice->SetFont(small_font());
|
||||
this->_presets_choice->SetFont(ui_settings->small_font());
|
||||
|
||||
|
||||
// buttons
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "MainFrame.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "misc_ui.hpp"
|
||||
#include "Settings.hpp"
|
||||
#include "Preset.hpp"
|
||||
|
||||
// Logging mechanism
|
||||
@ -48,6 +49,8 @@ bool App::OnInit()
|
||||
// TODO: Call a logging function with channel GUI, severity info for datadir path
|
||||
Slic3r::Log::info(LogChannel, (_("Data dir: ") + datadir).ToStdWstring());
|
||||
|
||||
ui_settings = Settings::init_settings();
|
||||
|
||||
// Load gui settings from slic3r.ini
|
||||
if (wxFileExists(slic3r_ini)) {
|
||||
/*
|
||||
@ -62,15 +65,14 @@ bool App::OnInit()
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
this->gui_config->save_settings();
|
||||
ui_settings->save_settings();
|
||||
|
||||
// Load presets
|
||||
this->load_presets();
|
||||
|
||||
|
||||
wxImage::AddHandler(new wxPNGHandler());
|
||||
MainFrame *frame = new MainFrame( "Slic3r", wxDefaultPosition, wxDefaultSize, this->gui_config);
|
||||
MainFrame *frame = new MainFrame( "Slic3r", wxDefaultPosition, wxDefaultSize);
|
||||
this->SetTopWindow(frame);
|
||||
|
||||
// Load init bundle
|
||||
@ -135,18 +137,18 @@ bool App::OnInit()
|
||||
}
|
||||
|
||||
void App::save_window_pos(const wxTopLevelWindow* window, const wxString& name ) {
|
||||
this->gui_config->window_pos[name] =
|
||||
ui_settings->window_pos[name] =
|
||||
std::make_tuple<wxPoint, wxSize, bool>(
|
||||
window->GetScreenPosition(),
|
||||
window->GetSize(),
|
||||
window->IsMaximized());
|
||||
|
||||
this->gui_config->save_settings();
|
||||
ui_settings->save_settings();
|
||||
}
|
||||
|
||||
void App::restore_window_pos(wxTopLevelWindow* window, const wxString& name ) {
|
||||
try {
|
||||
auto tmp = gui_config->window_pos[name];
|
||||
auto tmp = ui_settings->window_pos[name];
|
||||
const auto& size = std::get<1>(tmp);
|
||||
const auto& pos = std::get<0>(tmp);
|
||||
window->SetSize(size);
|
||||
|
@ -18,7 +18,7 @@ class App: public wxApp
|
||||
{
|
||||
public:
|
||||
virtual bool OnInit();
|
||||
App(std::shared_ptr<Settings> config) : wxApp(), gui_config(config) {}
|
||||
App() : wxApp() {}
|
||||
|
||||
/// Save position, size, and maximize state for a TopLevelWindow (includes Frames) by name in Settings.
|
||||
void save_window_pos(const wxTopLevelWindow* window, const wxString& name );
|
||||
@ -33,7 +33,6 @@ public:
|
||||
void OnUnhandledException() override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Settings> gui_config; // GUI-specific configuration options
|
||||
std::unique_ptr<Notifier> notifier {nullptr};
|
||||
std::vector<Presets> presets { preset_types, Presets() };
|
||||
|
||||
|
@ -13,10 +13,8 @@ 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> _gui_config)
|
||||
: wxFrame(NULL, wxID_ANY, title, pos, size), loaded(false),
|
||||
tabpanel(nullptr), controller(nullptr), plater(nullptr), gui_config(_gui_config), preset_editor_tabs(std::map<wxWindowID, PresetEditor*>())
|
||||
tabpanel(nullptr), controller(nullptr), plater(nullptr), preset_editor_tabs(std::map<wxWindowID, PresetEditor*>())
|
||||
{
|
||||
this->SetIcon(wxIcon(var("Slic3r_128px.png"), wxBITMAP_TYPE_PNG));
|
||||
|
||||
@ -44,7 +42,7 @@ MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& si
|
||||
this->SetMinSize(wxSize(760, 490));
|
||||
this->SetSize(this->GetMinSize());
|
||||
wxTheApp->SetTopWindow(this);
|
||||
gui_config->restore_window_pos(this, "main_frame");
|
||||
ui_settings->restore_window_pos(this, "main_frame");
|
||||
this->Show();
|
||||
this->Layout();
|
||||
}
|
||||
@ -67,7 +65,7 @@ MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& si
|
||||
|
||||
*/
|
||||
// save window size
|
||||
gui_config->save_window_pos(this, "main_frame");
|
||||
ui_settings->save_window_pos(this, "main_frame");
|
||||
|
||||
// Propagate event
|
||||
e.Skip();
|
||||
@ -87,7 +85,7 @@ void MainFrame::init_tabpanel()
|
||||
// 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) {
|
||||
} else if (ui_settings->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);
|
||||
@ -102,11 +100,11 @@ void MainFrame::init_tabpanel()
|
||||
wxTheApp->CallAfter([=] { this->tabpanel->SetSelection(0); });
|
||||
}), panel->GetId());
|
||||
|
||||
this->plater = new Slic3r::GUI::Plater(panel, _("Plater"), gui_config);
|
||||
this->plater = new Slic3r::GUI::Plater(panel, _("Plater"));
|
||||
this->controller = new Slic3r::GUI::Controller(panel, _("Controller"));
|
||||
|
||||
panel->AddPage(this->plater, this->plater->GetName());
|
||||
if (this->gui_config->show_host) panel->AddPage(this->controller, this->controller->GetName());
|
||||
if (ui_settings->show_host) panel->AddPage(this->controller, this->controller->GetName());
|
||||
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,6 @@ 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);
|
||||
ProgressStatusBar* statusbar {new ProgressStatusBar(this, -1)};
|
||||
|
||||
bool has_plater_menu() { return this->plater_menu != nullptr; }
|
||||
@ -50,8 +49,6 @@ private:
|
||||
|
||||
wxMenu* plater_menu {nullptr};
|
||||
|
||||
|
||||
std::shared_ptr<Settings> gui_config;
|
||||
std::map<wxWindowID, PresetEditor*> preset_editor_tabs;
|
||||
|
||||
void on_plater_object_list_changed(bool force) {};
|
||||
|
@ -35,8 +35,8 @@ const auto TB_SETTINGS {wxNewId()};
|
||||
|
||||
const auto PROGRESS_BAR_EVENT = wxNewEventType();
|
||||
|
||||
Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptr<Settings> _settings) :
|
||||
wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, title), settings(_settings)
|
||||
Plater::Plater(wxWindow* parent, const wxString& title) :
|
||||
wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, title)
|
||||
{
|
||||
|
||||
// Set callback for status event for worker threads
|
||||
@ -154,7 +154,7 @@ Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptr<Settings
|
||||
auto* sizer {new wxBoxSizer(wxHORIZONTAL)};
|
||||
object_info_sizer->Add(sizer, 0, wxEXPAND | wxBOTTOM, 5);
|
||||
auto* text {new wxStaticText(this, wxID_ANY, _("Object:"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT)};
|
||||
text->SetFont(small_font());
|
||||
text->SetFont(ui_settings->small_font());
|
||||
sizer->Add(text, 0, wxALIGN_CENTER_VERTICAL);
|
||||
|
||||
/* We supply a bogus width to wxChoice (sizer will override it and stretch
|
||||
@ -162,7 +162,7 @@ Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptr<Settings
|
||||
* too much according to the contents, and this is bad with long file names.
|
||||
*/
|
||||
this->object_info.choice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxSize(100, -1));
|
||||
this->object_info.choice->SetFont(small_font());
|
||||
this->object_info.choice->SetFont(ui_settings->small_font());
|
||||
sizer->Add(this->object_info.choice, 1, wxALIGN_CENTER_VERTICAL);
|
||||
|
||||
// Select object on change.
|
||||
@ -183,11 +183,11 @@ Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptr<Settings
|
||||
{
|
||||
wxString name {"Manifold:"};
|
||||
auto* text {new wxStaticText(parent, wxID_ANY, name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT)};
|
||||
text->SetFont(small_font());
|
||||
text->SetFont(ui_settings->small_font());
|
||||
grid_sizer->Add(text, 0);
|
||||
|
||||
this->object_info.manifold = new wxStaticText(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
|
||||
this->object_info.manifold->SetFont(small_font());
|
||||
this->object_info.manifold->SetFont(ui_settings->small_font());
|
||||
|
||||
this->object_info.manifold_warning_icon = new wxStaticBitmap(this, wxID_ANY, wxBitmap(var("error.png"), wxBITMAP_TYPE_PNG));
|
||||
this->object_info.manifold_warning_icon->Hide();
|
||||
@ -1091,7 +1091,7 @@ void Plater::build_preset_chooser() {
|
||||
break;
|
||||
}
|
||||
auto* text {new wxStaticText(this, wxID_ANY, name, wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT)};
|
||||
text->SetFont(small_font());
|
||||
text->SetFont(ui_settings->small_font());
|
||||
|
||||
auto* choice {new wxBitmapComboBox(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY)};
|
||||
this->preset_choosers[static_cast<int>(group)] = choice;
|
||||
|
@ -68,7 +68,7 @@ struct info_fields {
|
||||
class Plater : public wxPanel
|
||||
{
|
||||
public:
|
||||
Plater(wxWindow* parent, const wxString& title, std::shared_ptr<Settings> _settings);
|
||||
Plater(wxWindow* parent, const wxString& title);
|
||||
|
||||
/// User-level function called through external interface.
|
||||
/// Pops file dialog.
|
||||
@ -112,7 +112,6 @@ public:
|
||||
private:
|
||||
std::shared_ptr<Slic3r::Print> print {std::make_shared<Print>(Slic3r::Print())};
|
||||
std::shared_ptr<Slic3r::Model> model {std::make_shared<Model>(Slic3r::Model())};
|
||||
std::shared_ptr<Settings> settings {};
|
||||
|
||||
std::shared_ptr<Slic3r::Config> config { Slic3r::Config::new_from_defaults(
|
||||
{"bed_shape", "complete_objects", "extruder_clearance_radius", "skirts", "skirt_distance",
|
||||
@ -266,11 +265,11 @@ template <typename T>
|
||||
static void add_info_field(wxWindow* parent, T*& field, wxString name, wxGridSizer* sizer) {
|
||||
name << ":";
|
||||
auto* text {new wxStaticText(parent, wxID_ANY, name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT)};
|
||||
text->SetFont(small_font());
|
||||
text->SetFont(ui_settings->small_font());
|
||||
sizer->Add(text, 0);
|
||||
|
||||
field = new wxStaticText(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
|
||||
field->SetFont(small_font());
|
||||
field->SetFont(ui_settings->small_font());
|
||||
sizer->Add(field, 0);
|
||||
}
|
||||
|
||||
|
@ -13,8 +13,8 @@
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
Plate2D::Plate2D(wxWindow* parent, const wxSize& size, std::vector<PlaterObject>& _objects, std::shared_ptr<Model> _model, std::shared_ptr<Config> _config, std::shared_ptr<Settings> _settings) :
|
||||
wxPanel(parent, wxID_ANY, wxDefaultPosition, size, wxTAB_TRAVERSAL), objects(_objects), model(_model), config(_config), settings(_settings)
|
||||
Plate2D::Plate2D(wxWindow* parent, const wxSize& size, std::vector<PlaterObject>& _objects, std::shared_ptr<Model> _model, std::shared_ptr<Config> _config) :
|
||||
wxPanel(parent, wxID_ANY, wxDefaultPosition, size, wxTAB_TRAVERSAL), objects(_objects), model(_model), config(_config)
|
||||
{
|
||||
|
||||
this->Bind(wxEVT_PAINT, [this](wxPaintEvent &e) { this->repaint(e); });
|
||||
@ -56,8 +56,8 @@ void Plate2D::repaint(wxPaintEvent& e) {
|
||||
// On MacOS the background is erased, on Windows the background is not erased
|
||||
// and on Linux/GTK the background is erased to gray color.
|
||||
// Fill DC with the background on Windows & Linux/GTK.
|
||||
const auto& brush_background {wxBrush(this->settings->color->BACKGROUND255(), wxBRUSHSTYLE_SOLID)};
|
||||
const auto& pen_background {wxPen(this->settings->color->BACKGROUND255(), 1, wxPENSTYLE_SOLID)};
|
||||
const auto& brush_background {wxBrush(ui_settings->color->BACKGROUND255(), wxBRUSHSTYLE_SOLID)};
|
||||
const auto& pen_background {wxPen(ui_settings->color->BACKGROUND255(), 1, wxPENSTYLE_SOLID)};
|
||||
dc.SetPen(pen_background);
|
||||
dc.SetBrush(brush_background);
|
||||
const auto& rect {this->GetUpdateRegion().GetBox()};
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "ColorScheme.hpp"
|
||||
#include "Plater.hpp"
|
||||
#include "Plater/PlaterObject.hpp"
|
||||
#include "Settings.hpp"
|
||||
#include "misc_ui.hpp"
|
||||
|
||||
#include "Log.hpp"
|
||||
@ -39,7 +38,7 @@ class Plate2D : public wxPanel {
|
||||
public:
|
||||
|
||||
/// Constructor. Keeps a reference to the main configuration, the model, and the gui settings.
|
||||
Plate2D(wxWindow* parent, const wxSize& size, std::vector<PlaterObject>& _objects, std::shared_ptr<Model> _model, std::shared_ptr<Config> _config, std::shared_ptr<Settings> _settings);
|
||||
Plate2D(wxWindow* parent, const wxSize& size, std::vector<PlaterObject>& _objects, std::shared_ptr<Model> _model, std::shared_ptr<Config> _config);
|
||||
|
||||
/// Read print bed size from config and calculate the scaled rendition of the bed given the draw canvas.
|
||||
void update_bed_size();
|
||||
@ -63,7 +62,6 @@ private:
|
||||
std::vector<PlaterObject>& objects; //< reference to parent vector
|
||||
std::shared_ptr<Slic3r::Model> model;
|
||||
std::shared_ptr<Slic3r::Config> config;
|
||||
std::shared_ptr<Settings> settings;
|
||||
|
||||
/// Different brushes to draw with, initialized from settings->Color during the constructor
|
||||
wxBrush objects_brush {};
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include "Settings.hpp"
|
||||
#include "Model.hpp"
|
||||
#include "Config.hpp"
|
||||
|
||||
@ -14,7 +13,7 @@ namespace Slic3r { namespace GUI {
|
||||
class Preview2D : public wxPanel {
|
||||
public:
|
||||
void reload_print() {};
|
||||
Preview2D(wxWindow* parent, const wxSize& size, std::vector<PlaterObject>& _objects, std::shared_ptr<Model> _model, std::shared_ptr<Config> _config, std::shared_ptr<Settings> _settings) :
|
||||
Preview2D(wxWindow* parent, const wxSize& size, std::vector<PlaterObject>& _objects, std::shared_ptr<Model> _model, std::shared_ptr<Config> _config) :
|
||||
wxPanel(parent, wxID_ANY, wxDefaultPosition, size, wxTAB_TRAVERSAL), objects(_objects), model(_model), config(_config), settings(_settings)
|
||||
{}
|
||||
|
||||
@ -23,7 +22,6 @@ private:
|
||||
std::vector<PlaterObject>& objects; //< reference to parent vector
|
||||
std::shared_ptr<Slic3r::Model> model;
|
||||
std::shared_ptr<Slic3r::Config> config;
|
||||
std::shared_ptr<Settings> settings;
|
||||
};
|
||||
|
||||
} } // Namespace Slic3r::GUI
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include "Settings.hpp"
|
||||
#include "Model.hpp"
|
||||
#include "Config.hpp"
|
||||
|
||||
@ -14,7 +13,7 @@ namespace Slic3r { namespace GUI {
|
||||
class Preview3D : public wxPanel {
|
||||
public:
|
||||
void reload_print() {};
|
||||
Preview3D(wxWindow* parent, const wxSize& size, std::vector<PlaterObject>& _objects, std::shared_ptr<Model> _model, std::shared_ptr<Config> _config, std::shared_ptr<Settings> _settings) :
|
||||
Preview3D(wxWindow* parent, const wxSize& size, std::vector<PlaterObject>& _objects, std::shared_ptr<Model> _model, std::shared_ptr<Config> _config) :
|
||||
wxPanel(parent, wxID_ANY, wxDefaultPosition, size, wxTAB_TRAVERSAL), objects(_objects), model(_model), config(_config), settings(_settings)
|
||||
{}
|
||||
|
||||
@ -23,7 +22,6 @@ private:
|
||||
std::vector<PlaterObject>& objects; //< reference to parent vector
|
||||
std::shared_ptr<Slic3r::Model> model;
|
||||
std::shared_ptr<Slic3r::Config> config;
|
||||
std::shared_ptr<Settings> settings;
|
||||
};
|
||||
|
||||
} } // Namespace Slic3r::GUI
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include "Settings.hpp"
|
||||
#include "Model.hpp"
|
||||
#include "Config.hpp"
|
||||
|
||||
@ -14,7 +13,7 @@ namespace Slic3r { namespace GUI {
|
||||
class PreviewDLP : public wxPanel {
|
||||
public:
|
||||
void reload_print() {};
|
||||
PreviewDLP(wxWindow* parent, const wxSize& size, std::vector<PlaterObject>& _objects, std::shared_ptr<Model> _model, std::shared_ptr<Config> _config, std::shared_ptr<Settings> _settings) :
|
||||
PreviewDLP(wxWindow* parent, const wxSize& size, std::vector<PlaterObject>& _objects, std::shared_ptr<Model> _model, std::shared_ptr<Config> _config) :
|
||||
wxPanel(parent, wxID_ANY, wxDefaultPosition, size, wxTAB_TRAVERSAL), objects(_objects), model(_model), config(_config), settings(_settings)
|
||||
{}
|
||||
|
||||
@ -23,7 +22,6 @@ private:
|
||||
std::vector<PlaterObject>& objects; //< reference to parent vector
|
||||
std::shared_ptr<Slic3r::Model> model;
|
||||
std::shared_ptr<Slic3r::Config> config;
|
||||
std::shared_ptr<Settings> settings;
|
||||
};
|
||||
|
||||
} } // Namespace Slic3r::GUI
|
||||
|
@ -1,7 +1,20 @@
|
||||
#include "Settings.hpp"
|
||||
#include "misc_ui.hpp"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
void Settings::Settings() {
|
||||
// Initialize fonts
|
||||
_small_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
if (the_os == OS::Mac) _small_font.SetPointSize(11);
|
||||
_small_bold_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
if (the_os == OS::Mac) _small_bold_font.SetPointSize(11);
|
||||
_small_bold_font.MakeBold()
|
||||
_medium_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
_medium_font.SetPointSize(12);
|
||||
|
||||
_scroll_step = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)->GetPointSize();
|
||||
}
|
||||
void Settings::save_settings() {
|
||||
/*
|
||||
sub save_settings {
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
|
||||
#include "libslic3r.h"
|
||||
@ -32,7 +33,7 @@ class Settings {
|
||||
bool invert_zoom {false};
|
||||
bool background_processing {false};
|
||||
|
||||
bool preset_editor_tabs {false};
|
||||
bool preset_editor_tabs {true};
|
||||
|
||||
bool hide_reload_dialog {false};
|
||||
|
||||
@ -57,9 +58,31 @@ class Settings {
|
||||
void save_window_pos(wxWindow* ref, wxString name);
|
||||
void restore_window_pos(wxWindow* ref, wxString name);
|
||||
|
||||
private:
|
||||
const std::string LogChannel {"GUI_Settings"}; //< Which log these messages should go to.
|
||||
|
||||
const wxFont& small_font() { return _small_font;}
|
||||
const wxFont& small_bold_font() { return _small_bold_font;}
|
||||
const wxFont& medium_font() { return _medium_font;}
|
||||
const int& scroll_step() { return _scroll_step; }
|
||||
|
||||
static std::unique_ptr<Settings> init_settings() {
|
||||
return std::make_unique<Settings>();
|
||||
}
|
||||
Settings(Settings&&) = default;
|
||||
Settings& operator=(Settings&&) = default;
|
||||
|
||||
Settings();
|
||||
private:
|
||||
Settings& operator=(const Settings&) = default;
|
||||
Settings(const Settings&) = default;
|
||||
|
||||
const std::string LogChannel {"GUI_Settings"}; //< Which log these messages should go to.
|
||||
|
||||
/// Fonts used by the UI.
|
||||
wxFont _small_font;
|
||||
wxFont _small_bold_font;
|
||||
wxFont _medium_font;
|
||||
|
||||
int _scroll_step {0};
|
||||
};
|
||||
|
||||
}} //namespace Slic3r::GUI
|
||||
|
@ -147,7 +147,5 @@ std::vector<wxString> open_model(wxWindow* parent, const Settings& settings, wxW
|
||||
return tmp;
|
||||
}
|
||||
|
||||
wxFont small_font() { return wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); }
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <wx/stdpaths.h>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
|
||||
#include "Settings.hpp"
|
||||
|
||||
@ -22,6 +23,7 @@
|
||||
/// Avoids wx pollution of libslic3r
|
||||
#define LOG_WSTRING(...) ((wxString("") << __VA_ARGS__).ToStdWstring())
|
||||
|
||||
|
||||
/// Common static (that is, free-standing) functions, not part of an object hierarchy.
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
@ -51,8 +53,6 @@ constexpr bool isDev = false;
|
||||
|
||||
constexpr bool threaded = false;
|
||||
|
||||
/// Font definition
|
||||
wxFont small_font();
|
||||
|
||||
// hopefully the compiler is smart enough to figure this out
|
||||
const std::map<const std::string, const std::string> FILE_WILDCARDS {
|
||||
@ -152,6 +152,9 @@ std::vector<wxString> open_model(wxWindow* parent, const Settings& settings, wxW
|
||||
|
||||
inline Slic3r::Point new_scale(const wxPoint& p) { return Slic3r::Point::new_scale(p.x, p.y); }
|
||||
|
||||
/// Singleton for UI settings.
|
||||
std::unique_ptr<Settings> ui_settings {nullptr};
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
||||
#endif // MISC_UI_HPP
|
||||
|
Loading…
x
Reference in New Issue
Block a user