diff --git a/src/slic3r/GUI/AboutDialog.cpp b/src/slic3r/GUI/AboutDialog.cpp index db2e76736..9825f0cf9 100644 --- a/src/slic3r/GUI/AboutDialog.cpp +++ b/src/slic3r/GUI/AboutDialog.cpp @@ -42,9 +42,7 @@ AboutDialog::AboutDialog() main_sizer->Add(hsizer, 0, wxEXPAND | wxALL, 20); // logo -// wxBitmap logo_bmp = wxBitmap(from_u8(Slic3r::var("Slic3r_192px.png")), wxBITMAP_TYPE_PNG); -// auto *logo = new wxStaticBitmap(this, wxID_ANY, std::move(logo_bmp)); - auto *logo = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("Slic3r_192px.png")); + auto *logo = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("Slic3r_192px.png", 192)); hsizer->Add(logo, 1, wxALIGN_CENTER_VERTICAL); wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL); diff --git a/src/slic3r/GUI/BitmapCache.cpp b/src/slic3r/GUI/BitmapCache.cpp index bea242470..7ad36f09b 100644 --- a/src/slic3r/GUI/BitmapCache.cpp +++ b/src/slic3r/GUI/BitmapCache.cpp @@ -15,6 +15,7 @@ #include "nanosvg/nanosvg.h" #define NANOSVGRAST_IMPLEMENTATION #include "nanosvg/nanosvgrast.h" +#include "GUI_App.hpp" namespace Slic3r { namespace GUI { @@ -244,6 +245,9 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned int tar wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency) { + width = width * 0.1f * Slic3r::GUI::wxGetApp().em_unit() + 0.5f; + height = height * 0.1f * Slic3r::GUI::wxGetApp().em_unit() + 0.5f; + wxImage image(width, height); image.InitAlpha(); unsigned char* imgdata = image.GetData(); diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 8b574fc8d..80b7c3648 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -62,18 +62,18 @@ ObjectList::ObjectList(wxWindow* parent) : // Fill CATEGORY_ICON { // ptFFF - CATEGORY_ICON[L("Layers and Perimeters")] = create_scaled_bitmap("layers.png"); // wxBitmap(from_u8(var("layers.png")), wxBITMAP_TYPE_PNG); - CATEGORY_ICON[L("Infill")] = create_scaled_bitmap("infill.png"); // wxBitmap(from_u8(var("infill.png")), wxBITMAP_TYPE_PNG); - CATEGORY_ICON[L("Support material")] = create_scaled_bitmap("building.png"); // wxBitmap(from_u8(var("building.png")), wxBITMAP_TYPE_PNG); - CATEGORY_ICON[L("Speed")] = create_scaled_bitmap("time.png"); // wxBitmap(from_u8(var("time.png")), wxBITMAP_TYPE_PNG); - CATEGORY_ICON[L("Extruders")] = create_scaled_bitmap("funnel.png"); // wxBitmap(from_u8(var("funnel.png")), wxBITMAP_TYPE_PNG); - CATEGORY_ICON[L("Extrusion Width")] = create_scaled_bitmap("funnel.png"); // wxBitmap(from_u8(var("funnel.png")), wxBITMAP_TYPE_PNG); -// CATEGORY_ICON[L("Skirt and brim")] = create_scaled_bitmap("box.png"); // wxBitmap(from_u8(var("box.png")), wxBITMAP_TYPE_PNG); -// CATEGORY_ICON[L("Speed > Acceleration")] = create_scaled_bitmap("time.png"); // wxBitmap(from_u8(var("time.png")), wxBITMAP_TYPE_PNG); - CATEGORY_ICON[L("Advanced")] = create_scaled_bitmap("wand.png"); // wxBitmap(from_u8(var("wand.png")), wxBITMAP_TYPE_PNG); + CATEGORY_ICON[L("Layers and Perimeters")] = create_scaled_bitmap("layers"); + CATEGORY_ICON[L("Infill")] = create_scaled_bitmap("infill"); + CATEGORY_ICON[L("Support material")] = create_scaled_bitmap("support"); + CATEGORY_ICON[L("Speed")] = create_scaled_bitmap("time"); + CATEGORY_ICON[L("Extruders")] = create_scaled_bitmap("funnel"); + CATEGORY_ICON[L("Extrusion Width")] = create_scaled_bitmap("funnel"); +// CATEGORY_ICON[L("Skirt and brim")] = create_scaled_bitmap("skirt+brim"); +// CATEGORY_ICON[L("Speed > Acceleration")] = create_scaled_bitmap("time"); + CATEGORY_ICON[L("Advanced")] = create_scaled_bitmap("wrench"); // ptSLA - CATEGORY_ICON[L("Supports")] = create_scaled_bitmap("building.png"); // wxBitmap(from_u8(var("building.png")), wxBITMAP_TYPE_PNG); - CATEGORY_ICON[L("Pad")] = create_scaled_bitmap("brick.png"); // wxBitmap(from_u8(var("brick.png")), wxBITMAP_TYPE_PNG); + CATEGORY_ICON[L("Supports")] = create_scaled_bitmap("sla_supports"); + CATEGORY_ICON[L("Pad")] = create_scaled_bitmap("brick.png"); } // create control @@ -386,13 +386,6 @@ void ObjectList::update_name_in_model(const wxDataViewItem& item) const void ObjectList::init_icons() { -// m_bmp_modifiermesh = wxBitmap(from_u8(var("lambda.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("plugin.png")), wxBITMAP_TYPE_PNG); -// m_bmp_solidmesh = wxBitmap(from_u8(var("object.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("package.png")), wxBITMAP_TYPE_PNG); - -// m_bmp_support_enforcer = wxBitmap(from_u8(var("support_enforcer_.png")), wxBITMAP_TYPE_PNG); -// m_bmp_support_blocker = wxBitmap(from_u8(var("support_blocker_.png")), wxBITMAP_TYPE_PNG); - - m_bmp_modifiermesh = create_scaled_bitmap("lambda.png"); m_bmp_solidmesh = create_scaled_bitmap("object.png"); m_bmp_support_enforcer = create_scaled_bitmap("support_enforcer_.png"); @@ -407,16 +400,13 @@ void ObjectList::init_icons() m_objects_model->SetVolumeBitmaps(m_bmp_vector); // init icon for manifold warning -// m_bmp_manifold_warning = wxBitmap(from_u8(var("exclamation_mark_.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("error.png")), wxBITMAP_TYPE_PNG); m_bmp_manifold_warning = create_scaled_bitmap("exclamation_mark_.png"); // init bitmap for "Split to sub-objects" context menu -// m_bmp_split = wxBitmap(from_u8(var("split.png")), wxBITMAP_TYPE_PNG); - m_bmp_split = create_scaled_bitmap("split.png"); + m_bmp_split = create_scaled_bitmap("split_parts"); // init bitmap for "Add Settings" context menu -// m_bmp_cog = wxBitmap(from_u8(var("cog.png")), wxBITMAP_TYPE_PNG); - m_bmp_cog = create_scaled_bitmap("cog.png"); + m_bmp_cog = create_scaled_bitmap("cog"); } diff --git a/src/slic3r/GUI/GUI_ObjectManipulation.cpp b/src/slic3r/GUI/GUI_ObjectManipulation.cpp index 48bb1f690..7e7d8a1d5 100644 --- a/src/slic3r/GUI/GUI_ObjectManipulation.cpp +++ b/src/slic3r/GUI/GUI_ObjectManipulation.cpp @@ -92,7 +92,6 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) : else if (option_name == "Size") { line.near_label_widget = [this](wxWindow* parent) { return new wxStaticBitmap(parent, wxID_ANY, wxNullBitmap, wxDefaultPosition, -// wxBitmap(from_u8(var("one_layer_lock_on.png")), wxBITMAP_TYPE_PNG).GetSize()); create_scaled_bitmap("one_layer_lock_on.png").GetSize()); }; } diff --git a/src/slic3r/GUI/GUI_ObjectSettings.cpp b/src/slic3r/GUI/GUI_ObjectSettings.cpp index cd995bc09..b1f33eea1 100644 --- a/src/slic3r/GUI/GUI_ObjectSettings.cpp +++ b/src/slic3r/GUI/GUI_ObjectSettings.cpp @@ -77,7 +77,6 @@ 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, wxBitmap(from_u8(var("colorchange_delete_on.png")), wxBITMAP_TYPE_PNG), auto btn = new wxBitmapButton(parent, wxID_ANY, create_scaled_bitmap("colorchange_delete_on.png"), wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); #ifdef __WXMSW__ diff --git a/src/slic3r/GUI/KBShortcutsDialog.cpp b/src/slic3r/GUI/KBShortcutsDialog.cpp index 66e9deec8..b4d25fa5d 100644 --- a/src/slic3r/GUI/KBShortcutsDialog.cpp +++ b/src/slic3r/GUI/KBShortcutsDialog.cpp @@ -17,8 +17,7 @@ KBShortcutsDialog::KBShortcutsDialog() auto main_sizer = new wxBoxSizer(wxVERTICAL); // logo -// wxBitmap logo_bmp = wxBitmap(from_u8(Slic3r::var("Slic3r_32px.png")), wxBITMAP_TYPE_PNG); - const wxBitmap logo_bmp = create_scaled_bitmap("Slic3r_32px.png"); + const wxBitmap logo_bmp = create_scaled_bitmap("Slic3r_32px.png", 32); // fonts wxFont head_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold(); diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index d69480b28..0c3cf316d 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -56,9 +56,13 @@ wxFrame(NULL, wxID_ANY, SLIC3R_BUILD, wxDefaultPosition, wxDefaultSize, wxDEFAUL // initialize default width_unit according to the width of the one symbol ("x") of the current system font const wxSize size = GetTextExtent("m"); -// wxGetApp().set_em_unit(size.x-1); wxGetApp().set_em_unit(std::max(10, size.x - 1)); + /* Load default preset bitmaps before a tabpanel initialization, + * but after filling of an em_unit value + */ + wxGetApp().preset_bundle->load_default_preset_bitmaps(); + // initialize tabpanel and menubar init_tabpanel(); init_menubar(); @@ -388,11 +392,11 @@ void MainFrame::init_menubar() windowMenu->AppendSeparator(); } append_menu_item(windowMenu, wxID_HIGHEST + 2, _(L("P&rint Settings Tab")) + "\tCtrl+2", _(L("Show the print settings")), - [this, tab_offset](wxCommandEvent&) { select_tab(tab_offset + 0); }, "cog.png"); + [this, tab_offset](wxCommandEvent&) { select_tab(tab_offset + 0); }, "cog"); append_menu_item(windowMenu, wxID_HIGHEST + 3, _(L("&Filament Settings Tab")) + "\tCtrl+3", _(L("Show the filament settings")), [this, tab_offset](wxCommandEvent&) { select_tab(tab_offset + 1); }, "spool.png"); append_menu_item(windowMenu, wxID_HIGHEST + 4, _(L("Print&er Settings Tab")) + "\tCtrl+4", _(L("Show the printer settings")), - [this, tab_offset](wxCommandEvent&) { select_tab(tab_offset + 2); }, "printer_empty.png"); + [this, tab_offset](wxCommandEvent&) { select_tab(tab_offset + 2); }, "printer"); if (m_plater) { windowMenu->AppendSeparator(); wxMenuItem* item_3d = append_menu_item(windowMenu, wxID_HIGHEST + 5, _(L("3&D")) + "\tCtrl+5", _(L("Show the 3D editing view")), diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index cc2b9c842..beb0c97cd 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -24,7 +24,7 @@ namespace GUI { MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, wxWindowID button_id) : - MsgDialog(parent, title, headline, create_scaled_bitmap("Slic3r_192px.png"), button_id) + MsgDialog(parent, title, headline, create_scaled_bitmap("Slic3r_192px.png", 192), button_id) {} MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, wxBitmap bitmap, wxWindowID button_id) : diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 3e7ab3bbc..8f75d0ec9 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -286,7 +286,7 @@ wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(15 * #ifdef __WINDOWS__ edit_btn->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); #endif - edit_btn->SetBitmap(create_scaled_bitmap("cog.png")); + edit_btn->SetBitmap(create_scaled_bitmap("cog")); edit_btn->SetToolTip(_(L("Click to edit preset"))); edit_btn->Bind(wxEVT_BUTTON, ([preset_type, this](wxCommandEvent) @@ -2829,15 +2829,15 @@ bool Plater::priv::init_common_menu(wxMenu* menu, const bool is_part/* = false*/ wxMenuItem* item_delete = nullptr; if (is_part) { item_delete = append_menu_item(menu, wxID_ANY, _(L("Delete")) + "\tDel", _(L("Remove the selected object")), - [this](wxCommandEvent&) { q->remove_selected(); }, "brick_delete.png"); + [this](wxCommandEvent&) { q->remove_selected(); }, "remove"); sidebar->obj_list()->append_menu_item_export_stl(menu); } else { wxMenuItem* item_increase = append_menu_item(menu, wxID_ANY, _(L("Increase copies")) + "\t+", _(L("Place one more copy of the selected object")), - [this](wxCommandEvent&) { q->increase_instances(); }, "add.png"); + [this](wxCommandEvent&) { q->increase_instances(); }, "instance_add"); wxMenuItem* item_decrease = append_menu_item(menu, wxID_ANY, _(L("Decrease copies")) + "\t-", _(L("Remove one copy of the selected object")), - [this](wxCommandEvent&) { q->decrease_instances(); }, "delete.png"); + [this](wxCommandEvent&) { q->decrease_instances(); }, "instance_remove"); wxMenuItem* item_set_number_of_copies = append_menu_item(menu, wxID_ANY, _(L("Set number of copies")) + dots, _(L("Change the number of copies of the selected object")), [this](wxCommandEvent&) { q->set_number_of_copies(); }, "textfield.png"); @@ -2847,7 +2847,7 @@ bool Plater::priv::init_common_menu(wxMenu* menu, const bool is_part/* = false*/ // Delete menu was moved to be after +/- instace to make it more difficult to be selected by mistake. item_delete = append_menu_item(menu, wxID_ANY, _(L("Delete")) + "\tDel", _(L("Remove the selected object")), - [this](wxCommandEvent&) { q->remove_selected(); }, "brick_delete.png"); + [this](wxCommandEvent&) { q->remove_selected(); }, "remove"); menu->AppendSeparator(); wxMenuItem* item_instance_to_object = sidebar->obj_list()->append_menu_item_instance_to_object(menu); @@ -2902,11 +2902,11 @@ bool Plater::priv::complit_init_object_menu() return false; wxMenuItem* item_split_objects = append_menu_item(split_menu, wxID_ANY, _(L("To objects")), _(L("Split the selected object into individual objects")), - [this](wxCommandEvent&) { split_object(); }, "shape_ungroup_o.png", &object_menu); + [this](wxCommandEvent&) { split_object(); }, "split_objects.png", &object_menu); wxMenuItem* item_split_volumes = append_menu_item(split_menu, wxID_ANY, _(L("To parts")), _(L("Split the selected object into individual sub-parts")), - [this](wxCommandEvent&) { split_volume(); }, "shape_ungroup_p.png", &object_menu); + [this](wxCommandEvent&) { split_volume(); }, "split_parts.png", &object_menu); - wxMenuItem* item_split = append_submenu(&object_menu, split_menu, wxID_ANY, _(L("Split")), _(L("Split the selected object")), "shape_ungroup.png"); + wxMenuItem* item_split = append_submenu(&object_menu, split_menu, wxID_ANY, _(L("Split")), _(L("Split the selected object"))/*, "shape_ungroup.png"*/); object_menu.AppendSeparator(); // "Add (volumes)" popupmenu will be added later in append_menu_items_add_volume() diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index 82223b15c..7d1cedc96 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -4,6 +4,7 @@ #include "AppConfig.hpp" #include "BitmapCache.hpp" #include "I18N.hpp" +#include "wxExtensions.hpp" #ifdef _MSC_VER #define WIN32_LEAN_AND_MEAN @@ -798,12 +799,14 @@ bool PresetCollection::delete_current_preset() bool PresetCollection::load_bitmap_default(const std::string &file_name) { - return m_bitmap_main_frame->LoadFile(wxString::FromUTF8(Slic3r::var(file_name).c_str()), wxBITMAP_TYPE_PNG); +// return m_bitmap_main_frame->LoadFile(wxString::FromUTF8(Slic3r::var(file_name).c_str()), wxBITMAP_TYPE_PNG); + return load_scaled_bitmap(&m_bitmap_main_frame, file_name); } bool PresetCollection::load_bitmap_add(const std::string &file_name) { - return m_bitmap_add->LoadFile(wxString::FromUTF8(Slic3r::var(file_name).c_str()), wxBITMAP_TYPE_PNG); +// return m_bitmap_add->LoadFile(wxString::FromUTF8(Slic3r::var(file_name).c_str()), wxBITMAP_TYPE_PNG); + return load_scaled_bitmap(&m_bitmap_add, file_name); } const Preset* PresetCollection::get_selected_preset_parent() const diff --git a/src/slic3r/GUI/PresetBundle.cpp b/src/slic3r/GUI/PresetBundle.cpp index f78a04126..d8fefbf3f 100644 --- a/src/slic3r/GUI/PresetBundle.cpp +++ b/src/slic3r/GUI/PresetBundle.cpp @@ -4,6 +4,7 @@ #include "BitmapCache.hpp" #include "Plater.hpp" #include "I18N.hpp" +#include "wxExtensions.hpp" #include #include @@ -102,13 +103,14 @@ PresetBundle::PresetBundle() : } // Load the default preset bitmaps. - this->prints .load_bitmap_default("cog.png"); - this->sla_prints .load_bitmap_default("package_green.png"); - this->filaments .load_bitmap_default("spool.png"); - this->sla_materials.load_bitmap_default("package_green.png"); - this->printers .load_bitmap_default("printer_empty.png"); - this->printers .load_bitmap_add("add.png"); - this->load_compatible_bitmaps(); + // #ys_FIXME_to_delete we'll load them later, using em_unit() +// this->prints .load_bitmap_default("cog"); +// this->sla_prints .load_bitmap_default("package_green.png"); +// this->filaments .load_bitmap_default("spool.png"); +// this->sla_materials.load_bitmap_default("package_green.png"); +// this->printers .load_bitmap_default("printer_empty.png"); +// this->printers .load_bitmap_add("add.png"); +// this->load_compatible_bitmaps(); // Re-activate the default presets, so their "edited" preset copies will be updated with the additional configuration values above. this->prints .select_preset(0); @@ -400,14 +402,20 @@ bool PresetBundle::load_compatible_bitmaps() const std::string path_bitmap_incompatible = "flag-red-icon.png"; const std::string path_bitmap_lock = "sys_lock.png";//"lock.png"; const std::string path_bitmap_lock_open = "sys_unlock.png";//"lock_open.png"; - bool loaded_compatible = m_bitmapCompatible ->LoadFile( - wxString::FromUTF8(Slic3r::var(path_bitmap_compatible).c_str()), wxBITMAP_TYPE_PNG); - bool loaded_incompatible = m_bitmapIncompatible->LoadFile( - wxString::FromUTF8(Slic3r::var(path_bitmap_incompatible).c_str()), wxBITMAP_TYPE_PNG); - bool loaded_lock = m_bitmapLock->LoadFile( - wxString::FromUTF8(Slic3r::var(path_bitmap_lock).c_str()), wxBITMAP_TYPE_PNG); - bool loaded_lock_open = m_bitmapLockOpen->LoadFile( - wxString::FromUTF8(Slic3r::var(path_bitmap_lock_open).c_str()), wxBITMAP_TYPE_PNG); +// bool loaded_compatible = m_bitmapCompatible ->LoadFile( +// wxString::FromUTF8(Slic3r::var(path_bitmap_compatible).c_str()), wxBITMAP_TYPE_PNG); +// bool loaded_incompatible = m_bitmapIncompatible->LoadFile( +// wxString::FromUTF8(Slic3r::var(path_bitmap_incompatible).c_str()), wxBITMAP_TYPE_PNG); +// bool loaded_lock = m_bitmapLock->LoadFile( +// wxString::FromUTF8(Slic3r::var(path_bitmap_lock).c_str()), wxBITMAP_TYPE_PNG); +// bool loaded_lock_open = m_bitmapLockOpen->LoadFile( +// wxString::FromUTF8(Slic3r::var(path_bitmap_lock_open).c_str()), wxBITMAP_TYPE_PNG); + + bool loaded_compatible = load_scaled_bitmap(&m_bitmapCompatible, path_bitmap_compatible); + bool loaded_incompatible = load_scaled_bitmap(&m_bitmapIncompatible,path_bitmap_incompatible); + bool loaded_lock = load_scaled_bitmap(&m_bitmapLock, path_bitmap_lock); + bool loaded_lock_open = load_scaled_bitmap(&m_bitmapLockOpen, path_bitmap_lock_open); + if (loaded_compatible) { prints .set_bitmap_compatible(m_bitmapCompatible); filaments .set_bitmap_compatible(m_bitmapCompatible); @@ -1438,6 +1446,17 @@ bool PresetBundle::parse_color(const std::string &scolor, unsigned char *rgb_out return true; } +void PresetBundle::load_default_preset_bitmaps() +{ + this->prints.load_bitmap_default("cog"); + this->sla_prints.load_bitmap_default("package_green.png"); + this->filaments.load_bitmap_default("spool.png"); + this->sla_materials.load_bitmap_default("package_green.png"); + this->printers.load_bitmap_default("printer"); + this->printers.load_bitmap_add("add.png"); + this->load_compatible_bitmaps(); +} + void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, GUI::PresetComboBox *ui) { if (ui == nullptr || this->printers.get_edited_preset().printer_technology() == ptSLA || diff --git a/src/slic3r/GUI/PresetBundle.hpp b/src/slic3r/GUI/PresetBundle.hpp index 9f289f1e9..abd936ee2 100644 --- a/src/slic3r/GUI/PresetBundle.hpp +++ b/src/slic3r/GUI/PresetBundle.hpp @@ -127,6 +127,8 @@ public: static bool parse_color(const std::string &scolor, unsigned char *rgb_out); + void load_default_preset_bitmaps(); + private: std::string load_system_presets(); // Merge one vendor's presets with the other vendor's presets, report duplicates. diff --git a/src/slic3r/GUI/SysInfoDialog.cpp b/src/slic3r/GUI/SysInfoDialog.cpp index dfaba71ae..95bd7e61a 100644 --- a/src/slic3r/GUI/SysInfoDialog.cpp +++ b/src/slic3r/GUI/SysInfoDialog.cpp @@ -52,9 +52,7 @@ SysInfoDialog::SysInfoDialog() main_sizer->Add(hsizer, 1, wxEXPAND | wxALL, 10); // logo -// wxBitmap logo_bmp = wxBitmap(from_u8(Slic3r::var("Slic3r_192px.png")), wxBITMAP_TYPE_PNG); -// auto *logo = new wxStaticBitmap(this, wxID_ANY, std::move(logo_bmp)); - auto *logo = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("Slic3r_192px.png")); + auto *logo = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("Slic3r_192px.png", 192)); hsizer->Add(logo, 0, wxALIGN_CENTER_VERTICAL); wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index c2cdf8f03..5b200a194 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -116,18 +116,14 @@ void Tab::create_preset_tab() //buttons wxBitmap bmpMenu; -// bmpMenu = wxBitmap(from_u8(Slic3r::var("disk.png")), wxBITMAP_TYPE_PNG); bmpMenu = create_scaled_bitmap("disk.png"); m_btn_save_preset = new wxBitmapButton(panel, wxID_ANY, bmpMenu, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); if (wxMSW) m_btn_save_preset->SetBackgroundColour(color); -// bmpMenu = wxBitmap(from_u8(Slic3r::var("delete.png")), wxBITMAP_TYPE_PNG); bmpMenu = create_scaled_bitmap("delete.png"); m_btn_delete_preset = new wxBitmapButton(panel, wxID_ANY, bmpMenu, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); if (wxMSW) m_btn_delete_preset->SetBackgroundColour(color); m_show_incompatible_presets = false; -// m_bmp_show_incompatible_presets.LoadFile(from_u8(Slic3r::var("flag-red-icon.png")), wxBITMAP_TYPE_PNG); -// m_bmp_hide_incompatible_presets.LoadFile(from_u8(Slic3r::var("flag-green-icon.png")), wxBITMAP_TYPE_PNG); m_bmp_show_incompatible_presets = create_scaled_bitmap("flag-red-icon.png"); m_bmp_hide_incompatible_presets = create_scaled_bitmap("flag-green-icon.png"); m_btn_hide_incompatible_presets = new wxBitmapButton(panel, wxID_ANY, m_bmp_hide_incompatible_presets, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); @@ -152,15 +148,10 @@ void Tab::create_preset_tab() // 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 .LoadFile(from_u8(var("sys_lock.png")), wxBITMAP_TYPE_PNG); -// m_bmp_value_unlock .LoadFile(from_u8(var(luma >= 128 ? "sys_unlock.png" : "sys_unlock_grey.png")), wxBITMAP_TYPE_PNG); m_bmp_value_lock = create_scaled_bitmap("sys_lock.png"); m_bmp_value_unlock = create_scaled_bitmap(luma >= 128 ? "sys_unlock.png" : "sys_unlock_grey.png"); 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 .LoadFile(from_u8(var(luma >= 128 ? "action_undo.png" : "action_undo_grey.png")), wxBITMAP_TYPE_PNG); -// m_bmp_white_bullet .LoadFile(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG); -// m_bmp_question .LoadFile(from_u8(var("question_mark_01.png")), wxBITMAP_TYPE_PNG); m_bmp_value_revert = create_scaled_bitmap(luma >= 128 ? "action_undo.png" : "action_undo_grey.png"); m_bmp_white_bullet = create_scaled_bitmap("bullet_white.png"); m_bmp_question = create_scaled_bitmap("question_mark_01.png"); @@ -954,7 +945,7 @@ void TabPrint::build() m_presets = &m_preset_bundle->prints; load_initial_data(); - auto page = add_options_page(_(L("Layers and perimeters")), "layers.png"); + auto page = add_options_page(_(L("Layers and perimeters")), "layers"); auto optgroup = page->new_optgroup(_(L("Layer height"))); optgroup->append_single_option_line("layer_height"); optgroup->append_single_option_line("first_layer_height"); @@ -987,7 +978,7 @@ void TabPrint::build() optgroup->append_single_option_line("seam_position"); optgroup->append_single_option_line("external_perimeters_first"); - page = add_options_page(_(L("Infill")), "infill.png"); + page = add_options_page(_(L("Infill")), "infill"); optgroup = page->new_optgroup(_(L("Infill"))); optgroup->append_single_option_line("fill_density"); optgroup->append_single_option_line("fill_pattern"); @@ -1006,7 +997,7 @@ void TabPrint::build() optgroup->append_single_option_line("only_retract_when_crossing_perimeters"); optgroup->append_single_option_line("infill_first"); - page = add_options_page(_(L("Skirt and brim")), "box.png"); + page = add_options_page(_(L("Skirt and brim")), "skirt+brim"); optgroup = page->new_optgroup(_(L("Skirt"))); optgroup->append_single_option_line("skirts"); optgroup->append_single_option_line("skirt_distance"); @@ -1016,7 +1007,7 @@ void TabPrint::build() optgroup = page->new_optgroup(_(L("Brim"))); optgroup->append_single_option_line("brim_width"); - page = add_options_page(_(L("Support material")), "building.png"); + page = add_options_page(_(L("Support material")), "support"); optgroup = page->new_optgroup(_(L("Support material"))); optgroup->append_single_option_line("support_material"); optgroup->append_single_option_line("support_material_auto"); @@ -1041,7 +1032,7 @@ void TabPrint::build() optgroup->append_single_option_line("dont_support_bridges"); optgroup->append_single_option_line("support_material_synchronize_layers"); - page = add_options_page(_(L("Speed")), "time.png"); + page = add_options_page(_(L("Speed")), "time"); optgroup = page->new_optgroup(_(L("Speed for print moves"))); optgroup->append_single_option_line("perimeter_speed"); optgroup->append_single_option_line("small_perimeter_speed"); @@ -1075,7 +1066,7 @@ void TabPrint::build() optgroup->append_single_option_line("max_volumetric_extrusion_rate_slope_negative"); #endif /* HAS_PRESSURE_EQUALIZER */ - page = add_options_page(_(L("Multiple Extruders")), "funnel.png"); + page = add_options_page(_(L("Multiple Extruders")), "funnel"); optgroup = page->new_optgroup(_(L("Extruders"))); optgroup->append_single_option_line("perimeter_extruder"); optgroup->append_single_option_line("infill_extruder"); @@ -1125,7 +1116,7 @@ void TabPrint::build() optgroup = page->new_optgroup(_(L("Other"))); optgroup->append_single_option_line("clip_multipart_objects"); - page = add_options_page(_(L("Output options")), "page_white_go.png"); + page = add_options_page(_(L("Output options")), "output+page_white"); optgroup = page->new_optgroup(_(L("Sequential printing"))); optgroup->append_single_option_line("complete_objects"); line = { _(L("Extruder clearance (mm)")), "" }; @@ -1520,7 +1511,7 @@ void TabFilament::build() const int gcode_field_height = 15 * m_em_unit; // 150 const int notes_field_height = 25 * m_em_unit; // 250 - page = add_options_page(_(L("Custom G-code")), "cog.png"); + page = add_options_page(_(L("Custom G-code")), "cog"); optgroup = page->new_optgroup(_(L("Start G-code")), 0); Option option = optgroup->get_option("start_filament_gcode"); option.opt.full_width = true; @@ -1696,7 +1687,6 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup) auto printhost_cafile_browse = [this, optgroup] (wxWindow* parent) { auto btn = new wxButton(parent, wxID_ANY, _(L(" Browse "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT); -// btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("zoom.png")), wxBITMAP_TYPE_PNG)); btn->SetFont(Slic3r::GUI::wxGetApp().normal_font()); btn->SetBitmap(create_scaled_bitmap("zoom.png")); auto sizer = new wxBoxSizer(wxHORIZONTAL); @@ -1769,15 +1759,14 @@ void TabPrinter::build_fff() m_sys_extruders_count = parent_preset == nullptr ? 0 : static_cast(parent_preset->config.option("nozzle_diameter"))->values.size(); - auto page = add_options_page(_(L("General")), "printer_empty.png"); + auto page = add_options_page(_(L("General")), "printer"); auto optgroup = page->new_optgroup(_(L("Size and coordinates"))); 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(wxBitmap(from_u8(Slic3r::var("printer_empty.png")), wxBITMAP_TYPE_PNG)); - btn->SetBitmap(create_scaled_bitmap("printer_empty.png")); + btn->SetBitmap(create_scaled_bitmap("printer")); auto sizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(btn); @@ -1906,7 +1895,7 @@ void TabPrinter::build_fff() const int gcode_field_height = 15 * m_em_unit; // 150 const int notes_field_height = 25 * m_em_unit; // 250 - page = add_options_page(_(L("Custom G-code")), "cog.png"); + page = add_options_page(_(L("Custom G-code")), "cog"); optgroup = page->new_optgroup(_(L("Start G-code")), 0); option = optgroup->get_option("start_gcode"); option.opt.full_width = true; @@ -1971,15 +1960,14 @@ void TabPrinter::build_sla() { if (!m_pages.empty()) m_pages.resize(0); - auto page = add_options_page(_(L("General")), "printer_empty.png"); + auto page = add_options_page(_(L("General")), "printer"); auto optgroup = page->new_optgroup(_(L("Size and coordinates"))); 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(wxBitmap(from_u8(Slic3r::var("printer_empty.png")), wxBITMAP_TYPE_PNG)); - btn->SetBitmap(create_scaled_bitmap("printer_empty.png")); + btn->SetBitmap(create_scaled_bitmap("printer")); auto sizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(btn); @@ -2081,7 +2069,7 @@ void TabPrinter::append_option_line(ConfigOptionsGroupShp optgroup, const std::s PageShp TabPrinter::build_kinematics_page() { - auto page = add_options_page(_(L("Machine limits")), "cog.png", true); + auto page = add_options_page(_(L("Machine limits")), "cog", true); if (m_use_silent_mode) { // Legend for OptionsGroups @@ -2173,7 +2161,7 @@ void TabPrinter::build_extruder_pages() } if (m_extruders_count > 1 && m_config->opt_bool("single_extruder_multi_material") && !m_has_single_extruder_MM_page) { // create a page, but pretend it's an extruder page, so we can add it to m_pages ourselves - auto page = add_options_page(_(L("Single extruder MM setup")), "printer_empty.png", true); + auto page = add_options_page(_(L("Single extruder MM setup")), "printer", true); auto optgroup = page->new_optgroup(_(L("Single extruder multimaterial parameters"))); optgroup->append_single_option_line("cooling_tube_retraction"); optgroup->append_single_option_line("cooling_tube_length"); @@ -2189,7 +2177,7 @@ void TabPrinter::build_extruder_pages() //# build page char buf[512]; sprintf(buf, _CHB(L("Extruder %d")), extruder_idx + 1); - auto page = add_options_page(from_u8(buf), "funnel.png", true); + auto page = add_options_page(from_u8(buf), "funnel", true); m_pages.insert(m_pages.begin() + n_before_extruders + extruder_idx, page); auto optgroup = page->new_optgroup(_(L("Size"))); @@ -2921,8 +2909,7 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep deps.btn = new wxButton(parent, wxID_ANY, _(L(" Set "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); deps.btn->SetFont(Slic3r::GUI::wxGetApp().normal_font()); -// deps.btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("printer_empty.png")), wxBITMAP_TYPE_PNG)); - deps.btn->SetBitmap(create_scaled_bitmap("printer_empty.png")); + deps.btn->SetBitmap(create_scaled_bitmap("printer")); auto sizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add((deps.checkbox), 0, wxALIGN_CENTER_VERTICAL); @@ -3113,7 +3100,6 @@ ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, int noncommon_la bmp_name = mode == comExpert ? "mode_expert_.png" : mode == comAdvanced ? "mode_middle_.png" : "mode_simple_.png"; } -// auto bmp = new wxStaticBitmap(parent, wxID_ANY, bmp_name.empty() ? wxNullBitmap : wxBitmap(from_u8(var(bmp_name)), wxBITMAP_TYPE_PNG)); auto bmp = new wxStaticBitmap(parent, wxID_ANY, bmp_name.empty() ? wxNullBitmap : create_scaled_bitmap(bmp_name)); bmp->SetBackgroundStyle(wxBG_STYLE_PAINT); return bmp; @@ -3312,13 +3298,13 @@ void TabSLAPrint::build() m_presets = &m_preset_bundle->sla_prints; load_initial_data(); - auto page = add_options_page(_(L("Layers and perimeters")), "package_green.png"); + auto page = add_options_page(_(L("Layers and perimeters")), "layers"); auto optgroup = page->new_optgroup(_(L("Layers"))); optgroup->append_single_option_line("layer_height"); optgroup->append_single_option_line("faded_layers"); - page = add_options_page(_(L("Supports")), "building.png"); + page = add_options_page(_(L("Supports")), "sla_supports"); optgroup = page->new_optgroup(_(L("Supports"))); optgroup->append_single_option_line("supports_enable"); @@ -3356,17 +3342,17 @@ void TabSLAPrint::build() // optgroup->append_single_option_line("pad_edge_radius"); optgroup->append_single_option_line("pad_wall_slope"); - page = add_options_page(_(L("Advanced")), "wrench.png"); + page = add_options_page(_(L("Advanced")), "wrench"); optgroup = page->new_optgroup(_(L("Slicing"))); optgroup->append_single_option_line("slice_closing_radius"); - page = add_options_page(_(L("Output options")), "page_white_go.png"); + page = add_options_page(_(L("Output options")), "output+page_white"); optgroup = page->new_optgroup(_(L("Output file"))); Option option = optgroup->get_option("output_filename_format"); option.opt.full_width = true; optgroup->append_single_option_line(option); - page = add_options_page(_(L("Dependencies")), "wrench.png"); + page = add_options_page(_(L("Dependencies")), "wrench"); optgroup = page->new_optgroup(_(L("Profile dependencies"))); Line line = optgroup->create_single_option_line("compatible_printers");//Line { _(L("Compatible printers")), "" }; line.widget = [this](wxWindow* parent) { diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index 932db9cc2..a27b84058 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -418,33 +418,42 @@ void PrusaCollapsiblePaneMSW::Collapse(bool collapse) } #endif //__WXMSW__ + +// If an icon has horizontal orientation (width > height) call this function with is_horizontal = true +bool load_scaled_bitmap(wxBitmap** bmp, const std::string& bmp_name_in, const int px_cnt/* = 16*/, const bool is_horizontal /*= false*/) +{ + static Slic3r::GUI::BitmapCache cache; + + unsigned int height, width = height = 0; + unsigned int& scale_base = is_horizontal ? width : height; + scale_base = (unsigned int)(Slic3r::GUI::wxGetApp().em_unit() * px_cnt * 0.1f + 0.5f); + + std::string bmp_name = bmp_name_in; + boost::replace_last(bmp_name, ".png", ""); + *bmp = cache.load_svg(bmp_name, width, height); + if (*bmp == nullptr) + *bmp = cache.load_png(bmp_name, width, height); + return *bmp != nullptr; +} + +// If an icon has horizontal orientation (width > height) call this function with is_horizontal = true +wxBitmap create_scaled_bitmap(const std::string& bmp_name_in, const int px_cnt/* = 16*/, const bool is_horizontal /* = false*/) +{ + wxBitmap *bmp {nullptr}; + load_scaled_bitmap(&bmp, bmp_name_in, px_cnt, is_horizontal); + return *bmp; +} + // ***************************************************************************** // ---------------------------------------------------------------------------- // PrusaObjectDataViewModelNode // ---------------------------------------------------------------------------- -// If an icon has horizontal orientation (width > height) call this function with is_horizontal = true -wxBitmap create_scaled_bitmap(const std::string& bmp_name_in, const bool is_horizontal /* = false*/) -{ - static Slic3r::GUI::BitmapCache cache; - - unsigned int height, width = height = 0; - unsigned int& scale_base = is_horizontal ? width : height; - scale_base = (unsigned int)(Slic3r::GUI::wxGetApp().em_unit() * 1.6f + 0.5f); - - std::string bmp_name = bmp_name_in; - boost::replace_last(bmp_name, ".png", ""); - wxBitmap *bmp = cache.load_svg(bmp_name, width, height); - if (bmp == nullptr) - bmp = cache.load_png(bmp_name, width, height); - return *bmp; -} - void PrusaObjectDataViewModelNode::set_object_action_icon() { m_action_icon = create_scaled_bitmap("add_object.png"); } void PrusaObjectDataViewModelNode::set_part_action_icon() { - m_action_icon = create_scaled_bitmap(m_type == itVolume ? "cog.png" : "brick_go.png"); + m_action_icon = create_scaled_bitmap(m_type == itVolume ? "cog" : "brick_go.png"); } Slic3r::GUI::BitmapCache *m_bitmap_cache = nullptr; @@ -1486,8 +1495,8 @@ PrusaDoubleSlider::PrusaDoubleSlider(wxWindow *parent, if (!is_osx) SetDoubleBuffered(true);// SetDoubleBuffered exists on Win and Linux/GTK, but is missing on OSX - m_bmp_thumb_higher = wxBitmap(style == wxSL_HORIZONTAL ? create_scaled_bitmap("right_half_circle.png") : create_scaled_bitmap("up_half_circle.png", true)); - m_bmp_thumb_lower = wxBitmap(style == wxSL_HORIZONTAL ? create_scaled_bitmap("left_half_circle.png" ) : create_scaled_bitmap("down_half_circle.png", true)); + m_bmp_thumb_higher = wxBitmap(style == wxSL_HORIZONTAL ? create_scaled_bitmap("right_half_circle.png") : create_scaled_bitmap("up_half_circle.png", 16, true)); + m_bmp_thumb_lower = wxBitmap(style == wxSL_HORIZONTAL ? create_scaled_bitmap("left_half_circle.png" ) : create_scaled_bitmap("down_half_circle.png",16, true)); m_thumb_size = m_bmp_thumb_lower.GetSize(); m_bmp_add_tick_on = create_scaled_bitmap("colorchange_add_on.png"); diff --git a/src/slic3r/GUI/wxExtensions.hpp b/src/slic3r/GUI/wxExtensions.hpp index 912475ced..1a50a8adb 100644 --- a/src/slic3r/GUI/wxExtensions.hpp +++ b/src/slic3r/GUI/wxExtensions.hpp @@ -31,7 +31,8 @@ wxMenuItem* append_submenu(wxMenu* menu, wxMenu* sub_menu, int id, const wxStrin wxMenuItem* append_menu_radio_item(wxMenu* menu, int id, const wxString& string, const wxString& description, std::function cb, wxEvtHandler* event_handler); -wxBitmap create_scaled_bitmap(const std::string& bmp_name, const bool is_horizontal = false); +bool load_scaled_bitmap(wxBitmap** bmp, const std::string& bmp_name, const int px_cnt=16, const bool is_horizontal = false); +wxBitmap create_scaled_bitmap(const std::string& bmp_name, const int px_cnt=16, const bool is_horizontal = false); class wxCheckListBoxComboPopup : public wxCheckListBox, public wxComboPopup {