diff --git a/src/slic3r/GUI/AboutDialog.cpp b/src/slic3r/GUI/AboutDialog.cpp index b2b025880..fb1450ba1 100644 --- a/src/slic3r/GUI/AboutDialog.cpp +++ b/src/slic3r/GUI/AboutDialog.cpp @@ -45,9 +45,8 @@ AboutDialog::AboutDialog() main_sizer->Add(hsizer, 0, wxEXPAND | wxALL, 20); // logo - m_logo_bitmap = PrusaBitmap(this, "Slic3r_192px.png", 192); + m_logo_bitmap = ScalableBitmap(this, "Slic3r_192px.png", 192); m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bitmap.bmp()); -// auto *logo = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap(this, "Slic3r_192px.png", 192)); hsizer->Add(m_logo, 1, wxALIGN_CENTER_VERTICAL); wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL); @@ -56,8 +55,7 @@ AboutDialog::AboutDialog() // title { wxStaticText* title = new wxStaticText(this, wxID_ANY, SLIC3R_APP_NAME, wxDefaultPosition, wxDefaultSize); - wxFont title_font = GUI::wxGetApp().bold_font();// wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); -// title_font.SetWeight(wxFONTWEIGHT_BOLD); + wxFont title_font = GUI::wxGetApp().bold_font(); title_font.SetFamily(wxFONTFAMILY_ROMAN); title_font.SetPointSize(24); title->SetFont(title_font); @@ -68,9 +66,9 @@ AboutDialog::AboutDialog() { auto version_string = _(L("Version"))+ " " + std::string(SLIC3R_VERSION); wxStaticText* version = new wxStaticText(this, wxID_ANY, version_string.c_str(), wxDefaultPosition, wxDefaultSize); - wxFont version_font = GetFont();//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + wxFont version_font = GetFont(); #ifdef __WXMSW__ - version_font.SetPointSize(/*9*/version_font.GetPointSize()-1); + version_font.SetPointSize(version_font.GetPointSize()-1); #else version_font.SetPointSize(11); #endif @@ -82,7 +80,7 @@ AboutDialog::AboutDialog() m_html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO/*NEVER*/); { m_html->SetMinSize(wxSize(-1, 16 * wxGetApp().em_unit())); - wxFont font = GetFont();//GUI::wxGetApp().normal_font(); // wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + wxFont font = GetFont(); const auto text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue()); auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()); @@ -125,7 +123,7 @@ AboutDialog::AboutDialog() void AboutDialog::on_dpi_changed(const wxRect &suggested_rect) { - m_logo_bitmap.rescale(); + m_logo_bitmap.msw_rescale(); m_logo->SetBitmap(m_logo_bitmap.bmp()); const wxFont& font = GetFont(); diff --git a/src/slic3r/GUI/AboutDialog.hpp b/src/slic3r/GUI/AboutDialog.hpp index f74ab52f3..7019b21f6 100644 --- a/src/slic3r/GUI/AboutDialog.hpp +++ b/src/slic3r/GUI/AboutDialog.hpp @@ -25,7 +25,7 @@ private: class AboutDialog : public DPIDialog { - PrusaBitmap m_logo_bitmap; + ScalableBitmap m_logo_bitmap; wxHtmlWindow* m_html; wxStaticBitmap* m_logo; public: diff --git a/src/slic3r/GUI/BedShapeDialog.cpp b/src/slic3r/GUI/BedShapeDialog.cpp index 2762f0db7..00ebf117c 100644 --- a/src/slic3r/GUI/BedShapeDialog.cpp +++ b/src/slic3r/GUI/BedShapeDialog.cpp @@ -43,7 +43,7 @@ void BedShapeDialog::on_dpi_changed(const wxRect &suggested_rect) m_panel->m_shape_options_book->SetMinSize(wxSize(25 * em, -1)); for (auto og : m_panel->m_optgroups) - og->rescale(); + og->msw_rescale(); const wxSize& size = wxSize(50 * em, -1); diff --git a/src/slic3r/GUI/ButtonsDescription.hpp b/src/slic3r/GUI/ButtonsDescription.hpp index ccd992406..69005d2a5 100644 --- a/src/slic3r/GUI/ButtonsDescription.hpp +++ b/src/slic3r/GUI/ButtonsDescription.hpp @@ -4,12 +4,12 @@ #include #include -class PrusaBitmap; +class ScalableBitmap; namespace Slic3r { namespace GUI { -using t_icon_descriptions = std::vector>; +using t_icon_descriptions = std::vector>; class ButtonsDescription : public wxDialog { @@ -17,8 +17,6 @@ class ButtonsDescription : public wxDialog public: ButtonsDescription(wxWindow* parent, t_icon_descriptions* icon_descriptions); ~ButtonsDescription() {} - - }; } // GUI diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 571a1dccb..5e9327ffb 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -648,10 +648,10 @@ ConfigWizardIndex::ConfigWizardIndex(wxWindow *parent) , bullet_blue(GUI::from_u8(Slic3r::var("bullet_blue.png")), wxBITMAP_TYPE_PNG) , bullet_white(GUI::from_u8(Slic3r::var("bullet_white.png")), wxBITMAP_TYPE_PNG) */ - , bg(PrusaBitmap(parent, "Slic3r_192px_transparent.png", 192)) - , bullet_black(PrusaBitmap(parent, "bullet_black.png")) - , bullet_blue(PrusaBitmap(parent, "bullet_blue.png")) - , bullet_white(PrusaBitmap(parent, "bullet_white.png")) + , bg(ScalableBitmap(parent, "Slic3r_192px_transparent.png", 192)) + , bullet_black(ScalableBitmap(parent, "bullet_black.png")) + , bullet_blue(ScalableBitmap(parent, "bullet_blue.png")) + , bullet_white(ScalableBitmap(parent, "bullet_white.png")) , item_active(0) , item_hover(-1) , last_page((size_t)-1) @@ -839,15 +839,15 @@ void ConfigWizardIndex::on_mouse_move(wxMouseEvent &evt) evt.Skip(); } -void ConfigWizardIndex::rescale() +void ConfigWizardIndex::msw_rescale() { - bg.rescale(); + bg.msw_rescale(); SetMinSize(bg.bmp().GetSize()); logo->SetBitmap(bg.bmp()); - bullet_black.rescale(); - bullet_blue.rescale(); - bullet_white.rescale(); + bullet_black.msw_rescale(); + bullet_blue.msw_rescale(); + bullet_white.msw_rescale(); Refresh(); } @@ -1174,7 +1174,7 @@ const wxString& ConfigWizard::name(const bool from_menu/* = false*/) void ConfigWizard::on_dpi_changed(const wxRect &suggested_rect) { - p->index->rescale(); + p->index->msw_rescale(); Refresh(); } diff --git a/src/slic3r/GUI/ConfigWizard_private.hpp b/src/slic3r/GUI/ConfigWizard_private.hpp index 06777ba88..31a990b60 100644 --- a/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/src/slic3r/GUI/ConfigWizard_private.hpp @@ -210,7 +210,7 @@ public: void go_to(ConfigWizardPage *page); void clear(); - void rescale(); + void msw_rescale(); int em() const { return em_w; } private: @@ -231,10 +231,10 @@ private: const wxBitmap bullet_blue; const wxBitmap bullet_white; */ - PrusaBitmap bg; - PrusaBitmap bullet_black; - PrusaBitmap bullet_blue; - PrusaBitmap bullet_white; + ScalableBitmap bg; + ScalableBitmap bullet_black; + ScalableBitmap bullet_blue; + ScalableBitmap bullet_white; wxStaticBitmap* logo; std::vector items; diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 89310e7c3..822361c5d 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -33,21 +33,11 @@ wxString double_to_string(double const value, const int max_precision /*= 4*/) void Field::PostInitialize() { auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); - m_Undo_btn = new RevertButton(m_parent, "bullet_white.png");//(m_parent, wxID_ANY, "", wxDefaultPosition,wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); - m_Undo_to_sys_btn = new RevertButton(m_parent, "bullet_white.png");//(m_parent, wxID_ANY, "", wxDefaultPosition,wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); -// if (wxMSW) { -// m_Undo_btn->SetBackgroundColour(color); -// m_Undo_btn->SetBackgroundStyle(wxBG_STYLE_PAINT); -// m_Undo_to_sys_btn->SetBackgroundColour(color); -// m_Undo_to_sys_btn->SetBackgroundStyle(wxBG_STYLE_PAINT); -// } - m_Undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_back_to_initial_value(); })); - m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_back_to_sys_value(); })); + m_Undo_btn = new RevertButton(m_parent, "bullet_white.png"); + m_Undo_to_sys_btn = new RevertButton(m_parent, "bullet_white.png"); - //set default bitmap -// wxBitmap bmp = create_scaled_bitmap(m_parent, "bullet_white.png" ); -// set_undo_bitmap(&bmp); -// set_undo_to_sys_bitmap(&bmp); + m_Undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_back_to_initial_value(); })); + m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_back_to_sys_value(); })); switch (m_opt.type) { @@ -360,9 +350,9 @@ boost::any& TextCtrl::get_value() return m_value; } -void TextCtrl::rescale() +void TextCtrl::msw_rescale() { - Field::rescale(); + Field::msw_rescale(); auto size = wxSize(wxDefaultSize); if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit); if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit); @@ -523,9 +513,9 @@ void SpinCtrl::propagate_value() on_change_field(); } -void SpinCtrl::rescale() +void SpinCtrl::msw_rescale() { - Field::rescale(); + Field::msw_rescale(); wxSpinCtrl* field = dynamic_cast(window); field->SetMinSize(wxSize(-1, int(1.9f*field->GetFont().GetPixelSize().y))); @@ -843,9 +833,9 @@ boost::any& Choice::get_value() return m_value; } -void Choice::rescale() +void Choice::msw_rescale() { - Field::rescale(); + Field::msw_rescale(); wxBitmapComboBox* field = dynamic_cast(window); @@ -967,9 +957,9 @@ void PointCtrl::BUILD() y_textctrl->SetToolTip(get_tooltip_text(X+", "+Y)); } -void PointCtrl::rescale() +void PointCtrl::msw_rescale() { - Field::rescale(); + Field::msw_rescale(); const wxSize field_size(4 * m_em_unit, -1); @@ -1037,9 +1027,9 @@ void StaticText::BUILD() temp->SetToolTip(get_tooltip_text(legend)); } -void StaticText::rescale() +void StaticText::msw_rescale() { - Field::rescale(); + Field::msw_rescale(); auto size = wxSize(wxDefaultSize); if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit); diff --git a/src/slic3r/GUI/Field.hpp b/src/slic3r/GUI/Field.hpp index c776cadea..516570ea8 100644 --- a/src/slic3r/GUI/Field.hpp +++ b/src/slic3r/GUI/Field.hpp @@ -37,7 +37,7 @@ using t_back_to_init = std::function; wxString double_to_string(double const value, const int max_precision = 4); -class RevertButton : public /*wxButton*/PrusaButton +class RevertButton : public ScalableButton { bool hidden = false; // never show button if it's hidden ones public: @@ -54,7 +54,7 @@ public: wxWindow *parent, const std::string& icon_name = "" ) : - PrusaButton(parent, wxID_ANY, icon_name) {} + ScalableButton(parent, wxID_ANY, icon_name) {} // overridden from wxWindow base class virtual bool @@ -160,7 +160,7 @@ public: return std::move(p); //!p; } - bool set_undo_bitmap(const /*wxBitmap*/PrusaBitmap *bmp) { + bool set_undo_bitmap(const ScalableBitmap *bmp) { if (m_undo_bitmap != bmp) { m_undo_bitmap = bmp; m_Undo_btn->SetBitmap_(*bmp); @@ -169,7 +169,7 @@ public: return false; } - bool set_undo_to_sys_bitmap(const /*wxBitmap*/PrusaBitmap *bmp) { + bool set_undo_to_sys_bitmap(const ScalableBitmap *bmp) { if (m_undo_to_sys_bitmap != bmp) { m_undo_to_sys_bitmap = bmp; m_Undo_to_sys_btn->SetBitmap_(*bmp); @@ -217,9 +217,9 @@ public: m_side_text = side_text; } - virtual void rescale() { - m_Undo_to_sys_btn->rescale(); - m_Undo_btn->rescale(); + virtual void msw_rescale() { + m_Undo_to_sys_btn->msw_rescale(); + m_Undo_btn->msw_rescale(); // update em_unit value m_em_unit = em_unit(m_parent); @@ -228,12 +228,12 @@ public: protected: RevertButton* m_Undo_btn = nullptr; // Bitmap and Tooltip text for m_Undo_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. - const /*wxBitmap*/PrusaBitmap* m_undo_bitmap = nullptr; - const wxString* m_undo_tooltip = nullptr; + const ScalableBitmap* m_undo_bitmap = nullptr; + const wxString* m_undo_tooltip = nullptr; RevertButton* m_Undo_to_sys_btn = nullptr; // Bitmap and Tooltip text for m_Undo_to_sys_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. - const /*wxBitmap*/PrusaBitmap* m_undo_to_sys_bitmap = nullptr; - const wxString* m_undo_to_sys_tooltip = nullptr; + const ScalableBitmap* m_undo_to_sys_bitmap = nullptr; + const wxString* m_undo_to_sys_tooltip = nullptr; wxStaticText* m_Label = nullptr; // Color for Label. The wxColour will be updated only if the new wxColour pointer differs from the currently rendered one. @@ -290,7 +290,7 @@ public: boost::any& get_value() override; - void rescale() override; + void msw_rescale() override; virtual void enable(); virtual void disable(); @@ -355,7 +355,7 @@ public: return m_value = tmp_value; } - void rescale() override; + void msw_rescale() override; void enable() override { dynamic_cast(window)->Enable(); } void disable() override { dynamic_cast(window)->Disable(); } @@ -384,7 +384,7 @@ public: void set_values(const std::vector &values); boost::any& get_value() override; - void rescale() override; + void msw_rescale() override; void enable() override { dynamic_cast(window)->Enable(); }; void disable() override{ dynamic_cast(window)->Disable(); }; @@ -437,7 +437,7 @@ public: void set_value(const boost::any& value, bool change_event = false); boost::any& get_value() override; - void rescale() override; + void msw_rescale() override; void enable() override { x_textctrl->Enable(); @@ -471,7 +471,7 @@ public: boost::any& get_value()override { return m_value; } - void rescale() override; + void msw_rescale() override; void enable() override { dynamic_cast(window)->Enable(); }; void disable() override{ dynamic_cast(window)->Disable(); }; diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index cfae43027..649302341 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -3188,7 +3188,7 @@ double GLCanvas3D::get_size_proportional_to_max_bed_size(double factor) const return factor * m_bed.get_bounding_box().max_size(); } -void GLCanvas3D::rescale() +void GLCanvas3D::msw_rescale() { m_warning_texture.rescale(*this); } diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 32ed94221..45b5a58e7 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -594,7 +594,7 @@ public: double get_size_proportional_to_max_bed_size(double factor) const; - void rescale(); + void msw_rescale(); private: bool _is_shown_on_screen() const; diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index ff6094f70..f9df2649c 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -163,7 +163,7 @@ void ObjectList::create_objects_ctrl() m_sizer = new wxBoxSizer(wxVERTICAL); m_sizer->Add(this, 1, wxGROW); - m_objects_model = new PrusaObjectDataViewModel; + m_objects_model = new ObjectDataViewModel; AssociateModel(m_objects_model); m_objects_model->SetAssociatedControl(this); #if wxUSE_DRAG_AND_DROP && wxUSE_UNICODE @@ -173,7 +173,7 @@ void ObjectList::create_objects_ctrl() // column 0(Icon+Text) of the view control: // And Icon can be consisting of several bitmaps - AppendColumn(new wxDataViewColumn(_(L("Name")), new PrusaBitmapTextRenderer(), + AppendColumn(new wxDataViewColumn(_(L("Name")), new BitmapTextRenderer(), 0, 20*wxGetApp().em_unit()/*200*/, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE)); // column 1 of the view control: @@ -395,22 +395,10 @@ void ObjectList::update_name_in_model(const wxDataViewItem& item) const void ObjectList::init_icons() { -// m_bmp_modifiermesh = create_scaled_bitmap(nullptr, "add_modifier"); -// m_bmp_solidmesh = create_scaled_bitmap(nullptr, "add_part"); -// m_bmp_support_enforcer = create_scaled_bitmap(nullptr, "support_enforcer"); -// m_bmp_support_blocker = create_scaled_bitmap(nullptr, "support_blocker"); -// -// -// m_bmp_vector.reserve(4); // bitmaps for different types of parts -// m_bmp_vector.push_back(&m_bmp_solidmesh); -// m_bmp_vector.push_back(&m_bmp_modifiermesh); -// m_bmp_vector.push_back(&m_bmp_support_enforcer); -// m_bmp_vector.push_back(&m_bmp_support_blocker); - - m_bmp_modifiermesh = PrusaBitmap(nullptr, "add_modifier"); // Add part - m_bmp_solidmesh = PrusaBitmap(nullptr, "add_part"); // Add modifier - m_bmp_support_enforcer = PrusaBitmap(nullptr, "support_enforcer");// Add support enforcer - m_bmp_support_blocker = PrusaBitmap(nullptr, "support_blocker"); // Add support blocker + m_bmp_modifiermesh = ScalableBitmap(nullptr, "add_modifier"); // Add part + m_bmp_solidmesh = ScalableBitmap(nullptr, "add_part"); // Add modifier + m_bmp_support_enforcer = ScalableBitmap(nullptr, "support_enforcer");// Add support enforcer + m_bmp_support_blocker = ScalableBitmap(nullptr, "support_blocker"); // Add support blocker m_bmp_vector.reserve(4); // bitmaps for different types of parts m_bmp_vector.push_back(&m_bmp_solidmesh.bmp()); @@ -423,34 +411,34 @@ void ObjectList::init_icons() m_objects_model->SetVolumeBitmaps(m_bmp_vector); // init icon for manifold warning - m_bmp_manifold_warning = /*create_scaled_bitmap*/PrusaBitmap(nullptr, "exclamation"); + m_bmp_manifold_warning = ScalableBitmap(nullptr, "exclamation"); // init bitmap for "Split to sub-objects" context menu - m_bmp_split = /*create_scaled_bitmap*/PrusaBitmap(nullptr, "split_parts_SMALL"); + m_bmp_split = ScalableBitmap(nullptr, "split_parts_SMALL"); // init bitmap for "Add Settings" context menu - m_bmp_cog = /*create_scaled_bitmap*/PrusaBitmap(nullptr, "cog"); + m_bmp_cog = ScalableBitmap(nullptr, "cog"); } void ObjectList::rescale_icons() { m_bmp_vector.clear(); m_bmp_vector.reserve(4); // bitmaps for different types of parts - for (PrusaBitmap* bitmap : std::vector { + for (ScalableBitmap* bitmap : std::vector { &m_bmp_modifiermesh, // Add part &m_bmp_solidmesh, // Add modifier &m_bmp_support_enforcer, // Add support enforcer &m_bmp_support_blocker }) // Add support blocker { - bitmap->rescale(); + bitmap->msw_rescale(); m_bmp_vector.push_back(& bitmap->bmp()); } // Set volumes default bitmaps for the model m_objects_model->SetVolumeBitmaps(m_bmp_vector); - m_bmp_manifold_warning.rescale(); - m_bmp_split.rescale(); - m_bmp_cog.rescale(); + m_bmp_manifold_warning.msw_rescale(); + m_bmp_split.msw_rescale(); + m_bmp_cog.msw_rescale(); // Update CATEGORY_ICON according to new scale @@ -1057,7 +1045,7 @@ wxMenuItem* ObjectList::append_menu_item_split(wxMenu* menu) wxMenuItem* ObjectList::append_menu_item_settings(wxMenu* menu_) { - PrusaMenu* menu = dynamic_cast(menu_); + MenuWithSeparators* menu = dynamic_cast(menu_); const wxString menu_name = _(L("Add settings")); // Delete old items from settings popupmenu @@ -1105,7 +1093,7 @@ wxMenuItem* ObjectList::append_menu_item_settings(wxMenu* menu_) if (printer_technology() == ptFFF || menu->GetMenuItems().size() > 0 && !menu->GetMenuItems().back()->IsSeparator()) - menu->m_separator_frst = menu->AppendSeparator(); + menu->SetFirstSeparator(); // Add frequently settings create_freq_settings_popupmenu(menu); @@ -1113,7 +1101,7 @@ wxMenuItem* ObjectList::append_menu_item_settings(wxMenu* menu_) if (mode == comAdvanced) return nullptr; - menu->m_separator_scnd = menu->AppendSeparator(); + menu->SetSecondSeparator(); // Add full settings list auto menu_item = new wxMenuItem(menu, wxID_ANY, menu_name); @@ -1864,7 +1852,7 @@ void ObjectList::add_object_to_list(size_t obj_idx) stats.facets_added + stats.facets_reversed + stats.backwards_edges; if (errors > 0) { wxVariant variant; - variant << PrusaDataViewBitmapText(item_name, m_bmp_manifold_warning.bmp()); + variant << DataViewBitmapText(item_name, m_bmp_manifold_warning.bmp()); m_objects_model->SetValue(variant, item, 0); } @@ -2664,7 +2652,7 @@ void ObjectList::rename_item() wxVariant valueOld; m_objects_model->GetValue(valueOld, item, 0); - PrusaDataViewBitmapText bmpText; + DataViewBitmapText bmpText; bmpText << valueOld; // But replace the text with the value entered by user. @@ -2712,12 +2700,12 @@ void ObjectList::update_item_error_icon(const int obj_idx, const int vol_idx) co if (errors == 0) { // delete Error_icon if all errors are fixed wxVariant variant; - variant << PrusaDataViewBitmapText(from_u8(model_object->name), wxNullBitmap); + variant << DataViewBitmapText(from_u8(model_object->name), wxNullBitmap); m_objects_model->SetValue(variant, item, 0); } } -void ObjectList::rescale() +void ObjectList::msw_rescale() { // update min size !!! A width of control shouldn't be a wxDefaultCoord SetMinSize(wxSize(1, 15 * wxGetApp().em_unit())); @@ -2748,7 +2736,7 @@ void ObjectList::OnEditingDone(wxDataViewEvent &event) if (event.GetColumn() != 0) return; - const auto renderer = dynamic_cast(GetColumn(0)->GetRenderer()); + const auto renderer = dynamic_cast(GetColumn(0)->GetRenderer()); if (renderer->WasCanceled()) show_error(this, _(L("The supplied name is not valid;")) + "\n" + diff --git a/src/slic3r/GUI/GUI_ObjectList.hpp b/src/slic3r/GUI/GUI_ObjectList.hpp index 9421c79c7..da082d1d4 100644 --- a/src/slic3r/GUI/GUI_ObjectList.hpp +++ b/src/slic3r/GUI/GUI_ObjectList.hpp @@ -13,8 +13,8 @@ class wxBoxSizer; class wxMenuItem; -class PrusaObjectDataViewModel; -class PrusaMenu; +class ObjectDataViewModel; +class MenuWithSeparators; namespace Slic3r { class ConfigOptionsGroup; @@ -108,24 +108,24 @@ class ObjectList : public wxDataViewCtrl wxBoxSizer *m_sizer {nullptr}; wxWindow *m_parent {nullptr}; - /*wxBitmap*/PrusaBitmap m_bmp_modifiermesh; - /*wxBitmap*/PrusaBitmap m_bmp_solidmesh; - /*wxBitmap*/PrusaBitmap m_bmp_support_enforcer; - /*wxBitmap*/PrusaBitmap m_bmp_support_blocker; - /*wxBitmap*/PrusaBitmap m_bmp_manifold_warning; - /*wxBitmap*/PrusaBitmap m_bmp_cog; - /*wxBitmap*/PrusaBitmap m_bmp_split; + ScalableBitmap m_bmp_modifiermesh; + ScalableBitmap m_bmp_solidmesh; + ScalableBitmap m_bmp_support_enforcer; + ScalableBitmap m_bmp_support_blocker; + ScalableBitmap m_bmp_manifold_warning; + ScalableBitmap m_bmp_cog; + ScalableBitmap m_bmp_split; - PrusaMenu m_menu_object; - PrusaMenu m_menu_part; - PrusaMenu m_menu_sla_object; - PrusaMenu m_menu_instance; + MenuWithSeparators m_menu_object; + MenuWithSeparators m_menu_part; + MenuWithSeparators m_menu_sla_object; + MenuWithSeparators m_menu_instance; wxMenuItem* m_menu_item_split { nullptr }; wxMenuItem* m_menu_item_split_part { nullptr }; wxMenuItem* m_menu_item_settings { nullptr }; wxMenuItem* m_menu_item_split_instances { nullptr }; - std::vector m_bmp_vector; + std::vector m_bmp_vector; int m_selected_object_id = -1; bool m_prevent_list_events = false; // We use this flag to avoid circular event handling Select() @@ -139,9 +139,6 @@ class ObjectList : public wxDataViewCtrl // update_settings_items - updating canvas selection is undesirable, // because it would turn off the gizmos (mainly a problem for the SLA gizmo) -// bool m_parts_changed = false; -// bool m_part_settings_changed = false; - int m_selected_row = 0; wxDataViewItem m_last_selected_item {nullptr}; @@ -157,7 +154,7 @@ public: std::map CATEGORY_ICON; - PrusaObjectDataViewModel *m_objects_model{ nullptr }; + ObjectDataViewModel *m_objects_model{ nullptr }; DynamicPrintConfig *m_config {nullptr}; std::vector *m_objects{ nullptr }; @@ -289,7 +286,7 @@ public: void paste_volumes_into_list(int obj_idx, const ModelVolumePtrs& volumes); void paste_objects_into_list(const std::vector& object_idxs); - void rescale(); + void msw_rescale(); private: void OnChar(wxKeyEvent& event); diff --git a/src/slic3r/GUI/GUI_ObjectManipulation.cpp b/src/slic3r/GUI/GUI_ObjectManipulation.cpp index 526b07578..53f1923fd 100644 --- a/src/slic3r/GUI/GUI_ObjectManipulation.cpp +++ b/src/slic3r/GUI/GUI_ObjectManipulation.cpp @@ -78,7 +78,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) : // Add "uniform scaling" button in front of "Scale" option if (option_name == "Scale") { line.near_label_widget = [this](wxWindow* parent) { - auto btn = new PrusaLockButton(parent, wxID_ANY); + auto btn = new LockButton(parent, wxID_ANY); btn->Bind(wxEVT_BUTTON, [btn, this](wxCommandEvent &event){ event.Skip(); wxTheApp->CallAfter([btn, this]() { set_uniform_scaling(btn->IsLocked()); }); @@ -119,10 +119,10 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) : // call back for a rescale of button "Set uniform scale" m_og->rescale_near_label_widget = [this](wxWindow* win) { - auto *ctrl = dynamic_cast(win); + auto *ctrl = dynamic_cast(win); if (ctrl == nullptr) return; - ctrl->rescale(); + ctrl->msw_rescale(); }; } diff --git a/src/slic3r/GUI/GUI_ObjectManipulation.hpp b/src/slic3r/GUI/GUI_ObjectManipulation.hpp index a5a180a56..d7b45e3c8 100644 --- a/src/slic3r/GUI/GUI_ObjectManipulation.hpp +++ b/src/slic3r/GUI/GUI_ObjectManipulation.hpp @@ -7,7 +7,7 @@ #include "GLCanvas3D.hpp" class wxStaticText; -class PrusaLockButton; +class LockButton; namespace Slic3r { namespace GUI { @@ -76,7 +76,7 @@ class ObjectManipulation : public OG_Settings Vec3d m_new_size; bool m_new_enabled; bool m_uniform_scale {true}; - PrusaLockButton* m_lock_bnt{ nullptr }; + LockButton* m_lock_bnt{ nullptr }; #ifndef __APPLE__ // Currently focused option name (empty if none) diff --git a/src/slic3r/GUI/GUI_ObjectSettings.cpp b/src/slic3r/GUI/GUI_ObjectSettings.cpp index b8c0c41ae..b7ba2d4fc 100644 --- a/src/slic3r/GUI/GUI_ObjectSettings.cpp +++ b/src/slic3r/GUI/GUI_ObjectSettings.cpp @@ -60,7 +60,7 @@ ObjectSettings::ObjectSettings(wxWindow* parent) : m_settings_list_sizer = new wxBoxSizer(wxVERTICAL); m_og->sizer->Add(m_settings_list_sizer, 1, wxEXPAND | wxLEFT, 5); - m_bmp_delete = PrusaBitmap(parent, "cross"); + m_bmp_delete = ScalableBitmap(parent, "cross"); } void ObjectSettings::update_settings_list() @@ -79,12 +79,8 @@ void ObjectSettings::update_settings_list() { auto opt_key = (line.get_options())[0].opt_id; //we assume that we have one option per line -// auto btn = new wxBitmapButton(parent, wxID_ANY, create_scaled_bitmap(m_parent, "cross"/*"colorchange_delete_on.png"*/), -// wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); - auto btn = new PrusaButton(parent, wxID_ANY, m_bmp_delete); -//#ifdef __WXMSW__ -// btn->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); -//#endif // __WXMSW__ + auto btn = new ScalableButton(parent, wxID_ANY, m_bmp_delete); + btn->Bind(wxEVT_BUTTON, [opt_key, config, this](wxEvent &event) { config->erase(opt_key); wxGetApp().obj_list()->changed_object(); @@ -145,7 +141,7 @@ void ObjectSettings::update_settings_list() // call back for rescaling of the extracolumn control optgroup->rescale_extra_column_item = [this](wxWindow* win) { - auto *ctrl = dynamic_cast(win); + auto *ctrl = dynamic_cast(win); if (ctrl == nullptr) return; ctrl->SetBitmap_(m_bmp_delete); @@ -175,12 +171,12 @@ void ObjectSettings::UpdateAndShow(const bool show) OG_Settings::UpdateAndShow(show); } -void ObjectSettings::rescale() +void ObjectSettings::msw_rescale() { - m_bmp_delete.rescale(); + m_bmp_delete.msw_rescale(); for (auto group : m_og_settings) - group->rescale(); + group->msw_rescale(); } } //namespace GUI diff --git a/src/slic3r/GUI/GUI_ObjectSettings.hpp b/src/slic3r/GUI/GUI_ObjectSettings.hpp index 17accda18..3d49f13b7 100644 --- a/src/slic3r/GUI/GUI_ObjectSettings.hpp +++ b/src/slic3r/GUI/GUI_ObjectSettings.hpp @@ -38,7 +38,7 @@ class ObjectSettings : public OG_Settings // option groups for settings std::vector > m_og_settings; - PrusaBitmap m_bmp_delete; + ScalableBitmap m_bmp_delete; public: ObjectSettings(wxWindow* parent); @@ -46,7 +46,7 @@ public: void update_settings_list(); void UpdateAndShow(const bool show) override; - void rescale(); + void msw_rescale(); }; }} diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index e4ba4922e..88fea933e 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -396,13 +396,13 @@ void Preview::refresh_print() load_print(true); } -void Preview::rescale() +void Preview::msw_rescale() { // rescale slider - if (m_slider) m_slider->rescale(); + if (m_slider) m_slider->msw_rescale(); // rescale warning legend on the canvas - get_canvas3d()->rescale(); + get_canvas3d()->msw_rescale(); // rescale legend refresh_print(); @@ -519,7 +519,7 @@ void Preview::on_checkbox_shells(wxCommandEvent& evt) void Preview::create_double_slider() { - m_slider = new PrusaDoubleSlider(this, wxID_ANY, 0, 0, 0, 100); + m_slider = new DoubleSlider(this, wxID_ANY, 0, 0, 0, 100); m_double_slider_sizer->Add(m_slider, 0, wxEXPAND, 0); // sizer, m_canvas_widget diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index 8e5bd2bd1..2540980f4 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -13,7 +13,7 @@ class wxStaticText; class wxChoice; class wxComboCtrl; class wxCheckBox; -class PrusaDoubleSlider; +class DoubleSlider; namespace Slic3r { @@ -99,7 +99,7 @@ class Preview : public wxPanel bool m_loaded; bool m_enabled; - PrusaDoubleSlider* m_slider {nullptr}; + DoubleSlider* m_slider {nullptr}; public: Preview(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config, @@ -120,7 +120,7 @@ public: void reload_print(bool keep_volumes = false); void refresh_print(); - void rescale(); + void msw_rescale(); private: bool init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model); diff --git a/src/slic3r/GUI/KBShortcutsDialog.cpp b/src/slic3r/GUI/KBShortcutsDialog.cpp index 9a4561f07..7f77474f2 100644 --- a/src/slic3r/GUI/KBShortcutsDialog.cpp +++ b/src/slic3r/GUI/KBShortcutsDialog.cpp @@ -15,21 +15,21 @@ KBShortcutsDialog::KBShortcutsDialog() { SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); - main_sizer = new wxBoxSizer(wxVERTICAL); + auto main_sizer = new wxBoxSizer(wxVERTICAL); // logo - m_logo_bmp = PrusaBitmap(this, "Slic3r_32px.png", 32); + m_logo_bmp = ScalableBitmap(this, "Slic3r_32px.png", 32); // fonts const wxFont& font = wxGetApp().normal_font(); const wxFont& bold_font = wxGetApp().bold_font(); SetFont(font); - wxFont head_font = bold_font;// wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold(); + wxFont head_font = bold_font; #ifdef __WXOSX__ head_font.SetPointSize(14); #else - head_font.SetPointSize(/*12*/bold_font.GetPointSize() + 2); + head_font.SetPointSize(bold_font.GetPointSize() + 2); #endif // __WXOSX__ fill_shortcuts(); @@ -191,7 +191,7 @@ void KBShortcutsDialog::fill_shortcuts() void KBShortcutsDialog::on_dpi_changed(const wxRect &suggested_rect) { - m_logo_bmp.rescale(); + m_logo_bmp.msw_rescale(); for (wxStaticBitmap* bmp : m_head_bitmaps) bmp->SetBitmap(m_logo_bmp.bmp()); diff --git a/src/slic3r/GUI/KBShortcutsDialog.hpp b/src/slic3r/GUI/KBShortcutsDialog.hpp index f18e78682..66fe7c399 100644 --- a/src/slic3r/GUI/KBShortcutsDialog.hpp +++ b/src/slic3r/GUI/KBShortcutsDialog.hpp @@ -11,7 +11,7 @@ namespace Slic3r { namespace GUI { -class KBShortcutsDialog : public DPIDialog/*wxDialog*/ +class KBShortcutsDialog : public DPIDialog { enum PLACED_SIZER_ID { @@ -26,8 +26,7 @@ class KBShortcutsDialog : public DPIDialog/*wxDialog*/ wxString text_info {wxEmptyString}; ShortcutsVec m_full_shortcuts; - wxSizer* main_sizer; - PrusaBitmap m_logo_bmp; + ScalableBitmap m_logo_bmp; std::vector m_head_bitmaps; public: diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 74cefcb46..ccba1aaaa 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -270,11 +270,11 @@ void MainFrame::on_dpi_changed(const wxRect &suggested_rect) wxGetApp().preset_bundle->load_default_preset_bitmaps(this); // update Plater - wxGetApp().plater()->rescale(); + wxGetApp().plater()->msw_rescale(); // update Tabs for (auto tab : wxGetApp().tabs_list) - tab->rescale(); + tab->msw_rescale(); /* To correct window rendering (especially redraw of a status bar) * we should imitate window resizing. diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index a951d9847..fdbe3b038 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -484,7 +484,7 @@ bool ConfigOptionsGroup::update_visibility(ConfigOptionMode mode) { return true; } -void ConfigOptionsGroup::rescale() +void ConfigOptionsGroup::msw_rescale() { // update bitmaps for extra column items (like "mode markers" or buttons on settings panel) if (rescale_extra_column_item) @@ -498,7 +498,7 @@ void ConfigOptionsGroup::rescale() // update undo buttons : rescale bitmaps for (const auto& field : m_fields) - field.second->rescale(); + field.second->msw_rescale(); const int em = em_unit(parent()); diff --git a/src/slic3r/GUI/OptionsGroup.hpp b/src/slic3r/GUI/OptionsGroup.hpp index 868a4b8f7..67875587a 100644 --- a/src/slic3r/GUI/OptionsGroup.hpp +++ b/src/slic3r/GUI/OptionsGroup.hpp @@ -266,7 +266,7 @@ public: void Hide(); void Show(const bool show); bool update_visibility(ConfigOptionMode mode); - void rescale(); + void msw_rescale(); boost::any config_value(const std::string& opt_key, int opt_index, bool deserialize); // return option value from config boost::any get_config_value(const DynamicPrintConfig& config, const std::string& opt_key, int opt_index = -1); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 71e121c58..02cdaf208 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -111,7 +111,7 @@ public: bool showing_manifold_warning_icon; void show_sizer(bool show); - void rescale(); + void msw_rescale(); }; ObjectInfo::ObjectInfo(wxWindow *parent) : @@ -161,7 +161,7 @@ void ObjectInfo::show_sizer(bool show) manifold_warning_icon->Show(showing_manifold_warning_icon && show); } -void ObjectInfo::rescale() +void ObjectInfo::msw_rescale() { manifold_warning_icon->SetBitmap(create_scaled_bitmap(nullptr, "exclamation")); } @@ -288,12 +288,7 @@ wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(15 * }); } -// edit_btn = new wxButton(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); -// #ifdef __WINDOWS__ -// edit_btn->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); -// #endif -// edit_btn->SetBitmap(create_scaled_bitmap(this, "cog")); - edit_btn = new PrusaButton(parent, wxID_ANY, "cog"); + edit_btn = new ScalableButton(parent, wxID_ANY, "cog"); edit_btn->SetToolTip(_(L("Click to edit preset"))); edit_btn->Bind(wxEVT_BUTTON, ([preset_type, this](wxCommandEvent) @@ -339,10 +334,10 @@ void PresetComboBox::check_selection() this->last_selected = GetSelection(); } -void PresetComboBox::rescale() +void PresetComboBox::msw_rescale() { m_em_unit = wxGetApp().em_unit(); - edit_btn->rescale(); + edit_btn->msw_rescale(); } // Frequently changed parameters @@ -580,7 +575,7 @@ struct Sidebar::priv wxScrolledWindow *scrolled; wxPanel* presets_panel; // Used for MSW better layouts - PrusaModeSizer *mode_sizer; + ModeSizer *mode_sizer; wxFlexGridSizer *sizer_presets; PresetComboBox *combo_print; std::vector combos_filament; @@ -639,7 +634,7 @@ Sidebar::Sidebar(Plater *parent) p->scrolled->SetSizer(scrolled_sizer); // Sizer with buttons for mode changing - p->mode_sizer = new PrusaModeSizer(p->scrolled, 2 * wxGetApp().em_unit()); + p->mode_sizer = new ModeSizer(p->scrolled, 2 * wxGetApp().em_unit()); // The preset chooser p->sizer_presets = new wxFlexGridSizer(10, 1, 1, 2); @@ -854,23 +849,6 @@ void Sidebar::update_presets(Preset::Type preset_type) case Preset::TYPE_PRINTER: { -// wxWindowUpdateLocker noUpdates_scrolled(p->scrolled); - -// // Update the print choosers to only contain the compatible presets, update the dirty flags. -// if (print_tech == ptFFF) -// preset_bundle.prints.update_platter_ui(p->combo_print); -// else { -// preset_bundle.sla_prints.update_platter_ui(p->combo_sla_print); -// preset_bundle.sla_materials.update_platter_ui(p->combo_sla_material); -// } -// // Update the printer choosers, update the dirty flags. -// preset_bundle.printers.update_platter_ui(p->combo_printer); -// // Update the filament choosers to only contain the compatible presets, update the color preview, -// // update the dirty flags. -// if (print_tech == ptFFF) { -// for (size_t i = 0; i < p->combos_filament.size(); ++ i) -// preset_bundle.update_platter_filament_ui(i, p->combos_filament[i], wxGetApp().em_unit()); -// } update_all_preset_comboboxes(); p->show_preset_comboboxes(); break; @@ -896,33 +874,33 @@ void Sidebar::update_reslice_btn_tooltip() const p->btn_reslice->SetToolTip(tooltip); } -void Sidebar::rescale() +void Sidebar::msw_rescale() { SetMinSize(wxSize(40 * wxGetApp().em_unit(), -1)); - p->mode_sizer->rescale(); + p->mode_sizer->msw_rescale(); // Rescale preset comboboxes in respect to the current em_unit ... for (PresetComboBox* combo : std::vector { p->combo_print, p->combo_sla_print, p->combo_sla_material, p->combo_printer } ) - combo->rescale(); + combo->msw_rescale(); for (PresetComboBox* combo : p->combos_filament) - combo->rescale(); + combo->msw_rescale(); // ... then refill them and set min size to correct layout of the sidebar update_all_preset_comboboxes(); - p->frequently_changed_parameters->get_og(true)->rescale(); - p->frequently_changed_parameters->get_og(false)->rescale(); + p->frequently_changed_parameters->get_og(true)->msw_rescale(); + p->frequently_changed_parameters->get_og(false)->msw_rescale(); - p->object_list->rescale(); + p->object_list->msw_rescale(); - p->object_manipulation->get_og()->rescale(); - p->object_settings->rescale(); + p->object_manipulation->get_og()->msw_rescale(); + p->object_settings->msw_rescale(); - p->object_info->rescale(); + p->object_info->msw_rescale(); p->scrolled->Layout(); } @@ -1198,11 +1176,11 @@ struct Plater::priv MainFrame *main_frame; // Object popup menu - PrusaMenu object_menu; + MenuWithSeparators object_menu; // Part popup menu - PrusaMenu part_menu; + MenuWithSeparators part_menu; // SLA-Object popup menu - PrusaMenu sla_object_menu; + MenuWithSeparators sla_object_menu; // Removed/Prepended Items according to the view mode std::vector items_increase; @@ -3850,13 +3828,13 @@ bool Plater::can_paste_from_clipboard() const return true; } -void Plater::rescale() +void Plater::msw_rescale() { - p->preview->rescale(); + p->preview->msw_rescale(); - p->view3D->get_canvas3d()->rescale(); + p->view3D->get_canvas3d()->msw_rescale(); - p->sidebar->rescale(); + p->sidebar->msw_rescale(); Layout(); GetParent()->Layout(); diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index c39256f50..bedc31b35 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -14,7 +14,7 @@ #include "GLTexture.hpp" class wxButton; -class PrusaButton; +class ScalableButton; class wxBoxSizer; class wxGLCanvas; class wxScrolledWindow; @@ -47,7 +47,7 @@ public: PresetComboBox(wxWindow *parent, Preset::Type preset_type); ~PresetComboBox(); - /*wxButton*/PrusaButton* edit_btn { nullptr }; + ScalableButton* edit_btn { nullptr }; enum LabelItemType { LABEL_ITEM_MARKER = 0x4d, @@ -60,7 +60,7 @@ public: int em_unit() const { return m_em_unit; } void check_selection(); - void rescale(); + void msw_rescale(); private: typedef std::size_t Marker; @@ -88,7 +88,7 @@ public: void update_presets(Slic3r::Preset::Type preset_type); void update_mode_sizer() const; void update_reslice_btn_tooltip() const; - void rescale(); + void msw_rescale(); ObjectManipulation* obj_manipul(); ObjectList* obj_list(); @@ -206,7 +206,7 @@ public: bool can_copy() const; bool can_paste() const; - void rescale(); + void msw_rescale(); private: struct priv; diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 12d96624c..69f4e3493 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -144,7 +144,7 @@ void PreferencesDialog::accept() void PreferencesDialog::on_dpi_changed(const wxRect &suggested_rect) { - m_optgroup->rescale(); + m_optgroup->msw_rescale(); const int& em = em_unit(); const wxSize& size = wxSize(50 * em, 29 * em); diff --git a/src/slic3r/GUI/SysInfoDialog.cpp b/src/slic3r/GUI/SysInfoDialog.cpp index 471ba5486..31f75a926 100644 --- a/src/slic3r/GUI/SysInfoDialog.cpp +++ b/src/slic3r/GUI/SysInfoDialog.cpp @@ -54,8 +54,7 @@ SysInfoDialog::SysInfoDialog() main_sizer->Add(hsizer, 1, wxEXPAND | wxALL, 10); // logo - m_logo_bmp = PrusaBitmap(this, "Slic3r_192px.png", 192); -// auto *logo = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap(this, "Slic3r_192px.png", 192)); + m_logo_bmp = ScalableBitmap(this, "Slic3r_192px.png", 192); m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bmp.bmp()); hsizer->Add(m_logo, 0, wxALIGN_CENTER_VERTICAL); @@ -65,8 +64,7 @@ SysInfoDialog::SysInfoDialog() // title { wxStaticText* title = new wxStaticText(this, wxID_ANY, SLIC3R_APP_NAME, wxDefaultPosition, wxDefaultSize); - wxFont title_font = wxGetApp().bold_font();//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); -// title_font.SetWeight(wxFONTWEIGHT_BOLD); + wxFont title_font = wxGetApp().bold_font(); title_font.SetFamily(wxFONTFAMILY_ROMAN); title_font.SetPointSize(22); title->SetFont(title_font); @@ -74,7 +72,7 @@ SysInfoDialog::SysInfoDialog() } // main_info_text - wxFont font = wxGetApp().normal_font();//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + wxFont font = wxGetApp().normal_font(); const auto text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue()); auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()); @@ -136,7 +134,7 @@ SysInfoDialog::SysInfoDialog() void SysInfoDialog::on_dpi_changed(const wxRect &suggested_rect) { - m_logo_bmp.rescale(); + m_logo_bmp.msw_rescale(); m_logo->SetBitmap(m_logo_bmp.bmp()); wxFont font = GetFont(); diff --git a/src/slic3r/GUI/SysInfoDialog.hpp b/src/slic3r/GUI/SysInfoDialog.hpp index 6215d90ca..dec4b5635 100644 --- a/src/slic3r/GUI/SysInfoDialog.hpp +++ b/src/slic3r/GUI/SysInfoDialog.hpp @@ -12,11 +12,10 @@ namespace GUI { class SysInfoDialog : public DPIDialog { - wxString text_info {wxEmptyString}; - PrusaBitmap m_logo_bmp; + ScalableBitmap m_logo_bmp; wxStaticBitmap* m_logo; - wxHtmlWindow* m_opengl_info_html; - wxHtmlWindow* m_html; + wxHtmlWindow* m_opengl_info_html; + wxHtmlWindow* m_html; public: SysInfoDialog(); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 69b1e7832..b57678e86 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -117,61 +117,34 @@ void Tab::create_preset_tab() //buttons m_scaled_buttons.reserve(6); m_scaled_buttons.reserve(2); -// wxBitmap bmpMenu; -// bmpMenu = create_scaled_bitmap(this, "save"); -// m_btn_save_preset = new wxBitmapButton(panel, wxID_ANY, bmpMenu, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); -// if (wxMSW) m_btn_save_preset->SetBackgroundColour(color); -// bmpMenu = create_scaled_bitmap(this, "cross"/*"delete.png"*/); -// m_btn_delete_preset = new wxBitmapButton(panel, wxID_ANY, bmpMenu, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); -// if (wxMSW) m_btn_delete_preset->SetBackgroundColour(color); add_scaled_button(panel, &m_btn_save_preset, "save"); add_scaled_button(panel, &m_btn_delete_preset, "cross"); m_show_incompatible_presets = false; -// m_bmp_show_incompatible_presets = create_scaled_bitmap(this, "flag_red"); -// m_bmp_hide_incompatible_presets = create_scaled_bitmap(this, "flag_green"); add_scaled_bitmap(this, m_bmp_show_incompatible_presets, "flag_red"); add_scaled_bitmap(this, m_bmp_hide_incompatible_presets, "flag_green"); -// m_btn_hide_incompatible_presets = new wxBitmapButton(panel, wxID_ANY, m_bmp_hide_incompatible_presets, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); -// if (wxMSW) m_btn_hide_incompatible_presets->SetBackgroundColour(color); + add_scaled_button(panel, &m_btn_hide_incompatible_presets, m_bmp_hide_incompatible_presets.name()); m_btn_save_preset->SetToolTip(_(L("Save current ")) + m_title); m_btn_delete_preset->SetToolTip(_(L("Delete this preset"))); m_btn_delete_preset->Disable(); -// m_undo_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); -// m_undo_to_sys_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); -// m_question_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER); - add_scaled_button(panel, &m_question_btn, "question"); -// if (wxMSW) { -// m_undo_btn->SetBackgroundColour(color); -// m_undo_to_sys_btn->SetBackgroundColour(color); -// m_question_btn->SetBackgroundColour(color); -// } - m_question_btn->SetToolTip(_(L("Hover the cursor over buttons to find more information \n" "or click this button."))); // Determine the theme color of OS (dark or light) auto luma = wxGetApp().get_colour_approx_luma(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); // Bitmaps to be shown on the "Revert to system" aka "Lock to system" button next to each input field. -// m_bmp_value_lock = create_scaled_bitmap(this, luma >= 128 ? "lock_closed" : "lock_closed_white"); -// m_bmp_value_unlock = create_scaled_bitmap(this, "lock_open"); add_scaled_bitmap(this, m_bmp_value_lock , luma >= 128 ? "lock_closed" : "lock_closed_white"); add_scaled_bitmap(this, m_bmp_value_unlock, "lock_open"); m_bmp_non_system = &m_bmp_white_bullet; // Bitmaps to be shown on the "Undo user changes" button next to each input field. -// m_bmp_value_revert = create_scaled_bitmap(this, "undo"); -// m_bmp_white_bullet = create_scaled_bitmap(this, luma >= 128 ? "dot" : "dot_white"/*"bullet_white.png"*/); -// m_bmp_question = create_scaled_bitmap(this, "question"); -// m_bmp_value_revert = create_scaled_bitmap(this, "undo"); -// m_bmp_white_bullet = create_scaled_bitmap(this, "bullet_white.png"); add_scaled_bitmap(this, m_bmp_value_revert, "undo"); - add_scaled_bitmap(this, m_bmp_white_bullet, luma >= 128 ? "dot" : "dot_white"/*"bullet_white.png"*/); + add_scaled_bitmap(this, m_bmp_white_bullet, luma >= 128 ? "dot" : "dot_white"); fill_icon_descriptions(); set_tooltips_text(); @@ -179,11 +152,8 @@ void Tab::create_preset_tab() add_scaled_button(panel, &m_undo_btn, m_bmp_white_bullet.name()); add_scaled_button(panel, &m_undo_to_sys_btn, m_bmp_white_bullet.name()); -// m_undo_btn->SetBitmap(m_bmp_white_bullet); m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_roll_back_value(); })); -// m_undo_to_sys_btn->SetBitmap(m_bmp_white_bullet); m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_roll_back_value(true); })); -// m_question_btn->SetBitmap(m_bmp_question); m_question_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { auto dlg = new ButtonsDescription(this, &m_icon_descriptions); @@ -203,7 +173,7 @@ void Tab::create_preset_tab() m_default_text_clr = wxGetApp().get_label_clr_default(); // Sizer with buttons for mode changing - m_mode_sizer = new PrusaModeSizer(panel); + m_mode_sizer = new ModeSizer(panel); const float scale_factor = wxGetApp().em_unit()*0.1;// GetContentScaleFactor(); m_hsizer = new wxBoxSizer(wxHORIZONTAL); @@ -281,9 +251,9 @@ void Tab::create_preset_tab() // Fill cache for mode bitmaps m_mode_bitmap_cache.reserve(3); - m_mode_bitmap_cache.push_back(PrusaBitmap(this, "mode_simple_.png")); - m_mode_bitmap_cache.push_back(PrusaBitmap(this, "mode_middle_.png")); - m_mode_bitmap_cache.push_back(PrusaBitmap(this, "mode_expert_.png")); + m_mode_bitmap_cache.push_back(ScalableBitmap(this, "mode_simple_.png")); + m_mode_bitmap_cache.push_back(ScalableBitmap(this, "mode_middle_.png")); + m_mode_bitmap_cache.push_back(ScalableBitmap(this, "mode_expert_.png")); // Initialize the DynamicPrintConfig by default keys/values. build(); @@ -291,17 +261,21 @@ void Tab::create_preset_tab() m_complited = true; } -void Tab::add_scaled_button(wxWindow* parent, PrusaButton** btn, const std::string& icon_name, +void Tab::add_scaled_button(wxWindow* parent, + ScalableButton** btn, + const std::string& icon_name, const wxString& label/* = wxEmptyString*/, long style /*= wxBU_EXACTFIT | wxNO_BORDER*/) { - *btn = new PrusaButton(parent, wxID_ANY, icon_name, label, wxDefaultSize, wxDefaultPosition, style); + *btn = new ScalableButton(parent, wxID_ANY, icon_name, label, wxDefaultSize, wxDefaultPosition, style); m_scaled_buttons.push_back(*btn); } -void Tab::add_scaled_bitmap(wxWindow* parent, PrusaBitmap& bmp, const std::string& icon_name) +void Tab::add_scaled_bitmap(wxWindow* parent, + ScalableBitmap& bmp, + const std::string& icon_name) { - bmp = PrusaBitmap(parent, icon_name); + bmp = ScalableBitmap(parent, icon_name); m_scaled_bitmaps.push_back(&bmp); } @@ -321,8 +295,7 @@ Slic3r::GUI::PageShp Tab::add_options_page(const wxString& title, const std::str icon_idx = (m_icon_index.find(icon) == m_icon_index.end()) ? -1 : m_icon_index.at(icon); if (icon_idx == -1) { // Add a new icon to the icon list. -// m_icons->Add(create_scaled_bitmap(this, icon)); - m_scaled_icons_list.push_back(PrusaBitmap(this, icon)); + m_scaled_icons_list.push_back(ScalableBitmap(this, icon)); m_icons->Add(m_scaled_icons_list.back().bmp()); icon_idx = ++m_icon_count; m_icon_index[icon] = icon_idx; @@ -442,8 +415,8 @@ void Tab::update_changed_ui() { bool is_nonsys_value = false; bool is_modified_value = true; - const /*wxBitmap*/PrusaBitmap *sys_icon = &m_bmp_value_lock; - const /*wxBitmap*/PrusaBitmap *icon = &m_bmp_value_revert; + const ScalableBitmap *sys_icon = &m_bmp_value_lock; + const ScalableBitmap *icon = &m_bmp_value_revert; const wxColour *color = &m_sys_label_clr; @@ -766,11 +739,11 @@ void Tab::update_visibility() update_changed_tree_ui(); } -void Tab::rescale() +void Tab::msw_rescale() { m_em_unit = wxGetApp().em_unit(); - m_mode_sizer->rescale(); + m_mode_sizer->msw_rescale(); m_presets_choice->SetSize(35 * m_em_unit, -1); m_treectrl->SetMinSize(wxSize(20 * m_em_unit, -1)); @@ -779,25 +752,25 @@ void Tab::rescale() // rescale buttons and cached bitmaps for (const auto btn : m_scaled_buttons) - btn->rescale(); + btn->msw_rescale(); for (const auto bmp : m_scaled_bitmaps) - bmp->rescale(); - for (PrusaBitmap& bmp : m_mode_bitmap_cache) - bmp.rescale(); + bmp->msw_rescale(); + for (ScalableBitmap& bmp : m_mode_bitmap_cache) + bmp.msw_rescale(); // rescale icons for tree_ctrl - for (PrusaBitmap& bmp : m_scaled_icons_list) - bmp.rescale(); + for (ScalableBitmap& bmp : m_scaled_icons_list) + bmp.msw_rescale(); // recreate and set new ImageList for tree_ctrl m_icons->RemoveAll(); m_icons = new wxImageList(m_scaled_icons_list.front().bmp().GetWidth(), m_scaled_icons_list.front().bmp().GetHeight()); - for (PrusaBitmap& bmp : m_scaled_icons_list) + for (ScalableBitmap& bmp : m_scaled_icons_list) m_icons->Add(bmp.bmp()); m_treectrl->AssignImageList(m_icons); // rescale options_groups for (auto page : m_pages) - page->rescale(); + page->msw_rescale(); Layout(); } @@ -1705,12 +1678,8 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup) } auto printhost_browse = [=](wxWindow* parent) { -// auto btn = m_printhost_browse_btn = new wxButton(parent, wxID_ANY, _(L(" Browse ")) + dots, -// wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); -// btn->SetFont(Slic3r::GUI::wxGetApp().normal_font()); -// btn->SetBitmap(create_scaled_bitmap(this, "browse")); add_scaled_button(parent, &m_printhost_browse_btn, "browse", _(L(" Browse ")) + dots, wxBU_LEFT | wxBU_EXACTFIT); - PrusaButton* btn = m_printhost_browse_btn; + ScalableButton* btn = m_printhost_browse_btn; btn->SetFont(Slic3r::GUI::wxGetApp().normal_font()); auto sizer = new wxBoxSizer(wxHORIZONTAL); @@ -1728,12 +1697,8 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup) }; auto print_host_test = [this](wxWindow* parent) { -// auto btn = m_print_host_test_btn = new wxButton(parent, wxID_ANY, _(L("Test")), -// wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); -// btn->SetFont(Slic3r::GUI::wxGetApp().normal_font()); -// btn->SetBitmap(create_scaled_bitmap(this, "test")); add_scaled_button(parent, &m_print_host_test_btn, "test", _(L("Test")), wxBU_LEFT | wxBU_EXACTFIT); - PrusaButton* btn = m_print_host_test_btn; + ScalableButton* btn = m_print_host_test_btn; btn->SetFont(Slic3r::GUI::wxGetApp().normal_font()); auto sizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(btn); @@ -1849,11 +1814,7 @@ void TabPrinter::build_fff() Line line = optgroup->create_single_option_line("bed_shape");//{ _(L("Bed shape")), "" }; line.widget = [this](wxWindow* parent) { -// auto btn = new wxButton(parent, wxID_ANY, _(L(" Set "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); -// btn->SetFont(wxGetApp().small_font()); -// btn->SetBitmap(create_scaled_bitmap(this, "printer")); - - PrusaButton* btn; + ScalableButton* btn; add_scaled_button(parent, &btn, "printer_white", _(L(" Set ")) + dots, wxBU_LEFT | wxBU_EXACTFIT); btn->SetFont(wxGetApp().normal_font()); @@ -2054,11 +2015,7 @@ void TabPrinter::build_sla() Line line = optgroup->create_single_option_line("bed_shape");//{ _(L("Bed shape")), "" }; line.widget = [this](wxWindow* parent) { -// auto btn = new wxButton(parent, wxID_ANY, _(L(" Set ")) + dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); -// btn->SetFont(wxGetApp().small_font()); -// btn->SetBitmap(create_scaled_bitmap(this, "printer")); - - PrusaButton* btn; + ScalableButton* btn; add_scaled_button(parent, &btn, "printer_white", _(L(" Set ")) + dots, wxBU_LEFT | wxBU_EXACTFIT); btn->SetFont(wxGetApp().normal_font()); @@ -2157,7 +2114,6 @@ void TabPrinter::extruders_count_changed(size_t extruders_count) * of unregular pages of a Printer Settings */ build_unregular_pages(); -// reload_config(); // #ys_FIXME_delete_after_testing : This function is called from build_extruder_pages() now if (is_count_changed) { on_value_change("extruders_count", extruders_count); @@ -3029,12 +2985,9 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep { deps.checkbox = new wxCheckBox(parent, wxID_ANY, _(L("All"))); deps.checkbox->SetFont(Slic3r::GUI::wxGetApp().normal_font()); -// deps.btn = new wxButton(parent, wxID_ANY, _(L(" Set "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); add_scaled_button(parent, &deps.btn, "printer_white", _(L(" Set ")) + dots, wxBU_LEFT | wxBU_EXACTFIT); deps.btn->SetFont(Slic3r::GUI::wxGetApp().normal_font()); -// deps.btn->SetBitmap(create_scaled_bitmap(this, "printer")); - auto sizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add((deps.checkbox), 0, wxALIGN_CENTER_VERTICAL); sizer->Add((deps.btn), 0, wxALIGN_CENTER_VERTICAL); @@ -3190,10 +3143,10 @@ void Page::update_visibility(ConfigOptionMode mode) m_show = ret_val; } -void Page::rescale() +void Page::msw_rescale() { for (auto group : m_optgroups) - group->rescale(); + group->msw_rescale(); } Field* Page::get_field(const t_config_option_key& opt_key, int opt_index /*= -1*/) const @@ -3223,14 +3176,6 @@ ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, int noncommon_la { std::string bmp_name; const std::vector