diff --git a/src/slic3r/GUI/AboutDialog.cpp b/src/slic3r/GUI/AboutDialog.cpp index de4aca579c8..0b3b3608614 100644 --- a/src/slic3r/GUI/AboutDialog.cpp +++ b/src/slic3r/GUI/AboutDialog.cpp @@ -232,7 +232,7 @@ AboutDialog::AboutDialog() main_sizer->Add(ver_sizer, 0, wxEXPAND | wxALL, 0); // logo - m_logo_bitmap = ScalableBitmap(this, "OrcaSlicer_about", 250); + m_logo_bitmap = ScalableBitmap(this, "OrcaSlicer_about", {562,250}); m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bitmap.bmp(), wxDefaultPosition,wxDefaultSize, 0); m_logo->SetSizer(vesizer); diff --git a/src/slic3r/GUI/Widgets/SwitchButton.cpp b/src/slic3r/GUI/Widgets/SwitchButton.cpp index 67aa424578f..a852cb29d2f 100644 --- a/src/slic3r/GUI/Widgets/SwitchButton.cpp +++ b/src/slic3r/GUI/Widgets/SwitchButton.cpp @@ -9,8 +9,8 @@ SwitchButton::SwitchButton(wxWindow* parent, wxWindowID id) : wxBitmapToggleButton(parent, id, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE | wxBU_EXACTFIT) - , m_on(this, "toggle_on", 16, false, false, true) - , m_off(this, "toggle_off", 16, false, false, true) + , m_on(this, "toggle_on", {28, 16}) + , m_off(this, "toggle_off", {28, 16}) , text_color(std::pair{0xfffffe, (int) StateColor::Checked}, std::pair{0x6B6B6B, (int) StateColor::Normal}) , track_color(0xD9D9D9) , thumb_color(std::pair{0x009688, (int) StateColor::Checked}, std::pair{0xD9D9D9, (int) StateColor::Normal}) @@ -145,4 +145,5 @@ void SwitchButton::Rescale() void SwitchButton::update() { SetBitmap((GetValue() ? m_on : m_off).bmp()); + } diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index dc9bf65e17d..be95f09032f 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -413,17 +413,26 @@ static int scale() } #endif // __WXGTK2__ -wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name_in, int px_cnt/* = 16*/) +wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name_in, int width/* = 16*/, int height/* = -1*/) { +#ifdef __WXGTK2__ + width *= scale(); + if (height > 0) + height *= scale(); +#endif // __WXGTK2__ + static Slic3r::GUI::BitmapCache cache; std::string bmp_name = bmp_name_in; boost::replace_last(bmp_name, ".png", ""); + if (height < 0) + height = width; + // Try loading an SVG first, then PNG if SVG is not found: - wxBitmapBundle* bmp = cache.from_svg(bmp_name, px_cnt, px_cnt, Slic3r::GUI::wxGetApp().dark_mode()); + wxBitmapBundle* bmp = cache.from_svg(bmp_name, width, height, Slic3r::GUI::wxGetApp().dark_mode()); if (bmp == nullptr) { - bmp = cache.from_png(bmp_name, px_cnt, px_cnt); + bmp = cache.from_png(bmp_name, width, height); if (!bmp) // Neither SVG nor PNG has been found, raise error throw Slic3r::RuntimeError("Could not load bitmap: " + bmp_name); @@ -887,7 +896,7 @@ ScalableBitmap::ScalableBitmap( wxWindow *parent, const bool resize/* = false*/, const bool use_legacy_bmp/* = false*/): m_parent(parent), m_icon_name(icon_name), m_legacy_bmp(use_legacy_bmp), - m_px_cnt(px_cnt), m_grayscale(grayscale), m_resize(resize) // BBS: support resize by fill border + m_size({px_cnt, px_cnt}), m_grayscale(grayscale), m_resize(resize) // BBS: support resize by fill border { // Orca: there is currently an issue causing the advanced SwitchButton to not scale properly // when using get_bmp_bundle. This allows for the older method of getting a scaled bitmap to be @@ -895,8 +904,8 @@ ScalableBitmap::ScalableBitmap( wxWindow *parent, if (m_legacy_bmp) { m_bmp = create_scaled_bitmap(icon_name, parent, px_cnt, m_grayscale, std::string(), false, resize); if (px_cnt == 0) { - m_px_cnt = GetHeight(); // scale - unsigned int height = (unsigned int) (parent->FromDIP(m_px_cnt) + 0.5f); + m_size.x = m_size.y = GetHeight(); // scale + unsigned int height = (unsigned int) (parent->FromDIP(px_cnt) + 0.5f); if (height != GetHeight()) sys_color_changed(); } @@ -905,14 +914,24 @@ ScalableBitmap::ScalableBitmap( wxWindow *parent, } } +ScalableBitmap::ScalableBitmap( wxWindow *parent, + const std::string& icon_name, + const wxSize size, + const bool grayscale/* = false*/, + const bool resize/* = false*/): + m_parent(parent), m_icon_name(icon_name), + m_size(size), m_grayscale(grayscale), m_resize(resize) // BBS: support resize by fill border +{ + m_bmp = *get_bmp_bundle(icon_name, size.x, size.y); +} void ScalableBitmap::sys_color_changed() { if (m_legacy_bmp) { // BBS: support resize by fill border - m_bmp = create_scaled_bitmap(m_icon_name, m_parent, m_px_cnt, m_grayscale, std::string(), false, m_resize); + m_bmp = create_scaled_bitmap(m_icon_name, m_parent, m_size.x, m_grayscale, std::string(), false, m_resize); } else - m_bmp = *get_bmp_bundle(m_icon_name, m_px_cnt); + m_bmp = *get_bmp_bundle(m_icon_name, m_size.x, m_size.y); } // ---------------------------------------------------------------------------- diff --git a/src/slic3r/GUI/wxExtensions.hpp b/src/slic3r/GUI/wxExtensions.hpp index b2e2eebc86b..c342efd99a8 100644 --- a/src/slic3r/GUI/wxExtensions.hpp +++ b/src/slic3r/GUI/wxExtensions.hpp @@ -55,7 +55,7 @@ void msw_buttons_rescale(wxDialog* dlg, const int em_unit, const std::vector< int em_unit(wxWindow* win); int mode_icon_px_size(); -wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name, int px_cnt = 16); +wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name, int width = 16, int height = -1); wxBitmapBundle* get_empty_bmp_bundle(int width, int height); wxBitmapBundle* get_solid_bmp_bundle(int width, int height, const std::string& color); @@ -171,6 +171,11 @@ class ScalableBitmap const bool grayscale = false, const bool resize = false, // BBS: support resize by fill border const bool use_legacy_bmp = false); + ScalableBitmap( wxWindow *parent, + const std::string& icon_name, + const wxSize size, + const bool grayscale = false, + const bool resize = false); ~ScalableBitmap() {} @@ -183,7 +188,7 @@ class ScalableBitmap wxBitmap get_bitmap() const { return m_bmp.GetBitmapFor(m_parent); } wxWindow* parent() const { return m_parent;} const std::string& name() const{ return m_icon_name; } - int px_cnt() const { return m_px_cnt; } + int px_cnt() const { return m_size.x; } wxSize GetSize() const { #ifdef __WIN32__ @@ -199,7 +204,7 @@ class ScalableBitmap wxWindow* m_parent{ nullptr }; wxBitmapBundle m_bmp = wxBitmapBundle(); std::string m_icon_name = ""; - int m_px_cnt {16}; + wxSize m_size {16, 16}; bool m_grayscale{ false }; bool m_resize{ false }; bool m_legacy_bmp{ false };