Follow-up 1fff5a624c
: Respect border color to the dark/light mode
+ Fixed issue with tooltips for PresetComboBoxes on Windows 2004
This commit is contained in:
parent
76a92e40be
commit
f9451eaf81
@ -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
|
//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;
|
double scale = suppress_scaling ? 1.0f : m_scale;
|
||||||
width *= 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)) {
|
x >= (width - border_width) || y >= (height - border_width)) {
|
||||||
const size_t idx = (x + y * width);
|
const size_t idx = (x + y * width);
|
||||||
const size_t idx_rgb = (x + y * width) * 3;
|
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;
|
a_data[idx] = 255u;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.
|
// 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* 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, 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) { return mksolid(width, height, rgb[0], rgb[1], rgb[2], wxALPHA_OPAQUE, suppress_scaling, border_width); }
|
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); }
|
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);
|
static bool parse_color(const std::string& scolor, unsigned char* rgb_out);
|
||||||
|
@ -186,6 +186,12 @@ void PresetComboBox::update_selection()
|
|||||||
validate_selection();
|
validate_selection();
|
||||||
|
|
||||||
SetSelection(m_last_selected);
|
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));
|
SetToolTip(GetString(m_last_selected));
|
||||||
|
|
||||||
// A workaround for a set of issues related to text fitting into gtk widgets:
|
// 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 += is_system ? ",syst" : ",nsyst";
|
||||||
bitmap_key += ",h" + std::to_string(icon_height);
|
bitmap_key += ",h" + std::to_string(icon_height);
|
||||||
if (wxGetApp().dark_mode())
|
bool dark_mode = wxGetApp().dark_mode();
|
||||||
|
if (dark_mode)
|
||||||
bitmap_key += ",dark";
|
bitmap_key += ",dark";
|
||||||
|
|
||||||
wxBitmap* bmp = bitmap_cache().find(bitmap_key);
|
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];
|
unsigned char rgb[3];
|
||||||
// Paint the color bars.
|
// Paint the color bars.
|
||||||
bitmap_cache().parse_color(filament_rgb, rgb);
|
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) {
|
if (!is_single_bar) {
|
||||||
bitmap_cache().parse_color(extruder_rgb, rgb);
|
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.
|
// Paint a lock at the system presets.
|
||||||
bmps.emplace_back(bitmap_cache().mkclear(space_icon_width, icon_height));
|
bmps.emplace_back(bitmap_cache().mkclear(space_icon_width, icon_height));
|
||||||
@ -916,8 +923,16 @@ void PlaterPresetComboBox::update()
|
|||||||
update_selection();
|
update_selection();
|
||||||
Thaw();
|
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);
|
SetToolTip(tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
// Use this part of code just on Windows to avoid of some layout issues on Linux
|
// Use this part of code just on Windows to avoid of some layout issues on Linux
|
||||||
|
Loading…
Reference in New Issue
Block a user