From f9451eaf812de8f9c0bbae036d7b03214ffdde17 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 5 Feb 2021 13:26:03 +0100 Subject: [PATCH] Follow-up https://github.com/prusa3d/PrusaSlicer/commit/1fff5a624ceaa80bfb278fea9015618366f3d79b: Respect border color to the dark/light mode + Fixed issue with tooltips for PresetComboBoxes on Windows 2004 --- src/slic3r/GUI/BitmapCache.cpp | 4 ++-- src/slic3r/GUI/BitmapCache.hpp | 4 ++-- src/slic3r/GUI/PresetComboBoxes.cpp | 23 +++++++++++++++++++---- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/slic3r/GUI/BitmapCache.cpp b/src/slic3r/GUI/BitmapCache.cpp index f6562b299..0a6f3e4f9 100644 --- a/src/slic3r/GUI/BitmapCache.cpp +++ b/src/slic3r/GUI/BitmapCache.cpp @@ -338,7 +338,7 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_ } //we make scaled solid bitmaps only for the cases, when its will be used with scaled SVG icon in one output bitmap -wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling/* = false*/, size_t border_width /*= 0*/) +wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling/* = false*/, size_t border_width /*= 0*/, bool dark_mode/* = false*/) { double scale = suppress_scaling ? 1.0f : m_scale; width *= scale; @@ -371,7 +371,7 @@ wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsi x >= (width - border_width) || y >= (height - border_width)) { const size_t idx = (x + y * width); const size_t idx_rgb = (x + y * width) * 3; - px_data[idx_rgb] = px_data[idx_rgb + 1] = px_data[idx_rgb + 2] = 0u; + px_data[idx_rgb] = px_data[idx_rgb + 1] = px_data[idx_rgb + 2] = dark_mode ? 245u : 110u; a_data[idx] = 255u; } } diff --git a/src/slic3r/GUI/BitmapCache.hpp b/src/slic3r/GUI/BitmapCache.hpp index 629733b52..8147de996 100644 --- a/src/slic3r/GUI/BitmapCache.hpp +++ b/src/slic3r/GUI/BitmapCache.hpp @@ -35,8 +35,8 @@ public: // Load svg from resources/icons. bitmap_key is given without the .svg suffix. SVG will be rasterized to provided height/width. wxBitmap* load_svg(const std::string &bitmap_key, unsigned width = 0, unsigned height = 0, const bool grayscale = false, const bool dark_mode = false); - wxBitmap mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling = false, size_t border_width = 0); - wxBitmap mksolid(size_t width, size_t height, const unsigned char rgb[3], bool suppress_scaling = false, size_t border_width = 0) { return mksolid(width, height, rgb[0], rgb[1], rgb[2], wxALPHA_OPAQUE, suppress_scaling, border_width); } + wxBitmap mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false); + wxBitmap mksolid(size_t width, size_t height, const unsigned char rgb[3], bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb[0], rgb[1], rgb[2], wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); } wxBitmap mkclear(size_t width, size_t height) { return mksolid(width, height, 0, 0, 0, wxALPHA_TRANSPARENT); } static bool parse_color(const std::string& scolor, unsigned char* rgb_out); diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp index e3ef37c0c..86c643c04 100644 --- a/src/slic3r/GUI/PresetComboBoxes.cpp +++ b/src/slic3r/GUI/PresetComboBoxes.cpp @@ -186,6 +186,12 @@ void PresetComboBox::update_selection() validate_selection(); SetSelection(m_last_selected); +#ifdef __WXMSW__ + // From the Windows 2004 the tooltip for preset combobox doesn't work after next call of SetTooltip() + // (There was an issue, when tooltip doesn't appears after changing of the preset selection) + // But this workaround seems to work: We should to kill tooltip and than set new tooltip value + SetToolTip(NULL); +#endif SetToolTip(GetString(m_last_selected)); // A workaround for a set of issues related to text fitting into gtk widgets: @@ -411,7 +417,8 @@ wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, con bitmap_key += is_system ? ",syst" : ",nsyst"; bitmap_key += ",h" + std::to_string(icon_height); - if (wxGetApp().dark_mode()) + bool dark_mode = wxGetApp().dark_mode(); + if (dark_mode) bitmap_key += ",dark"; wxBitmap* bmp = bitmap_cache().find(bitmap_key); @@ -427,10 +434,10 @@ wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, con unsigned char rgb[3]; // Paint the color bars. bitmap_cache().parse_color(filament_rgb, rgb); - bmps.emplace_back(bitmap_cache().mksolid(is_single_bar ? wide_icon_width : norm_icon_width, icon_height, rgb, false, 1)); + bmps.emplace_back(bitmap_cache().mksolid(is_single_bar ? wide_icon_width : norm_icon_width, icon_height, rgb, false, 1, dark_mode)); if (!is_single_bar) { bitmap_cache().parse_color(extruder_rgb, rgb); - bmps.emplace_back(bitmap_cache().mksolid(thin_icon_width, icon_height, rgb, false, 1)); + bmps.emplace_back(bitmap_cache().mksolid(thin_icon_width, icon_height, rgb, false, 1, dark_mode)); } // Paint a lock at the system presets. bmps.emplace_back(bitmap_cache().mkclear(space_icon_width, icon_height)); @@ -916,8 +923,16 @@ void PlaterPresetComboBox::update() update_selection(); Thaw(); - if (!tooltip.IsEmpty()) + if (!tooltip.IsEmpty()) { +#ifdef __WXMSW__ + // From the Windows 2004 the tooltip for preset combobox doesn't work after next call of SetTooltip() + // (There was an issue, when tooltip doesn't appears after changing of the preset selection) + // But this workaround seems to work: We should to kill tooltip and than set new tooltip value + // See, https://groups.google.com/g/wx-users/c/mOEe3fgHrzk + SetToolTip(NULL); +#endif SetToolTip(tooltip); + } #ifdef __WXMSW__ // Use this part of code just on Windows to avoid of some layout issues on Linux