mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 11:53:48 +00:00
@@ -129,9 +129,10 @@ void BBLTopbarArt::DrawButton(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& i
|
|||||||
int bmpX = 0, bmpY = 0;
|
int bmpX = 0, bmpY = 0;
|
||||||
int textX = 0, textY = 0;
|
int textX = 0, textY = 0;
|
||||||
|
|
||||||
const wxBitmap& bmp = item.GetState() & wxAUI_BUTTON_STATE_DISABLED
|
// ORCA resolves the toolbar item bitmap using the actual window DPI context used for painting.
|
||||||
? item.GetDisabledBitmap()
|
// GetBitmap() / GetDisabledBitmap() was using internal window pointer (m_window), not the paint-time wnd
|
||||||
: item.GetBitmap();
|
// m_window was created before final DPI context was known so items not scales properly
|
||||||
|
const wxBitmap bmp = item.GetCurrentBitmapFor(wnd);
|
||||||
|
|
||||||
const wxSize bmpSize = bmp.IsOk() ? bmp.GetScaledSize() : wxSize(0, 0);
|
const wxSize bmpSize = bmp.IsOk() ? bmp.GetScaledSize() : wxSize(0, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,10 @@ void SwitchButton::Rescale()
|
|||||||
memdc.SelectObject(bmp);
|
memdc.SelectObject(bmp);
|
||||||
#endif
|
#endif
|
||||||
memdc.SetFont(dc.GetFont());
|
memdc.SetFont(dc.GetFont());
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
const double scale = GetDPIScaleFactor();
|
||||||
|
fontScale = scale;
|
||||||
|
#endif
|
||||||
if (fontScale) {
|
if (fontScale) {
|
||||||
memdc.SetFont(dc.GetFont().Scaled(fontScale));
|
memdc.SetFont(dc.GetFont().Scaled(fontScale));
|
||||||
textSize[0] = memdc.GetTextExtent(labels[0]);
|
textSize[0] = memdc.GetTextExtent(labels[0]);
|
||||||
@@ -176,6 +180,8 @@ void SwitchButton::Rescale()
|
|||||||
memdc.SelectObject(wxNullBitmap);
|
memdc.SelectObject(wxNullBitmap);
|
||||||
#ifdef __WXOSX__
|
#ifdef __WXOSX__
|
||||||
bmp = wxBitmap(bmp.ConvertToImage(), -1, scale);
|
bmp = wxBitmap(bmp.ConvertToImage(), -1, scale);
|
||||||
|
#elif defined(__WXMSW__)
|
||||||
|
bmp.SetScaleFactor(scale); // ORCA
|
||||||
#endif
|
#endif
|
||||||
(i == 0 ? m_off : m_on).bmp() = bmp;
|
(i == 0 ? m_off : m_on).bmp() = bmp;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -468,6 +468,10 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in,
|
|||||||
throw Slic3r::RuntimeError("Could not load bitmap: " + bmp_name);
|
throw Slic3r::RuntimeError("Could not load bitmap: " + bmp_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
// ORCA MSW needs to set scale factor for bitmaps loaded from cache because they arent auto scaled by wxBitmapBundle like bitmaps
|
||||||
|
bmp->SetScaleFactor(win ? win->GetDPIScaleFactor() : (wxWindow::FromDIP(100, nullptr) / 100.0));
|
||||||
|
#endif
|
||||||
return *bmp;
|
return *bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,6 +491,10 @@ wxBitmap create_scaled_bitmap2(const std::string& bmp_name_in, Slic3r::GUI::Bitm
|
|||||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "Could not load bitmap: " << bmp_name;
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "Could not load bitmap: " << bmp_name;
|
||||||
throw Slic3r::RuntimeError("Could not load bitmap: " + bmp_name);
|
throw Slic3r::RuntimeError("Could not load bitmap: " + bmp_name);
|
||||||
}
|
}
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
// ORCA MSW needs to set scale factor for bitmaps loaded from cache because they arent auto scaled by wxBitmapBundle like bitmaps
|
||||||
|
bmp->SetScaleFactor(win ? win->GetDPIScaleFactor() : (wxWindow::FromDIP(100, nullptr) / 100.0));
|
||||||
|
#endif
|
||||||
return *bmp;
|
return *bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,7 +508,8 @@ wxBitmap* get_default_extruder_color_icon(bool thin_icon/* = false*/)
|
|||||||
const int icon_height = lround(2 * em);
|
const int icon_height = lround(2 * em);
|
||||||
bool dark_mode = Slic3r::GUI::wxGetApp().dark_mode();
|
bool dark_mode = Slic3r::GUI::wxGetApp().dark_mode();
|
||||||
|
|
||||||
wxClientDC cdc((wxWindow*)Slic3r::GUI::wxGetApp().mainframe);
|
auto win = (wxWindow*)Slic3r::GUI::wxGetApp().mainframe;
|
||||||
|
wxClientDC cdc(win);
|
||||||
wxMemoryDC dc(&cdc);
|
wxMemoryDC dc(&cdc);
|
||||||
dc.SetFont(::Label::Body_12);
|
dc.SetFont(::Label::Body_12);
|
||||||
|
|
||||||
@@ -526,6 +535,12 @@ wxBitmap* get_default_extruder_color_icon(bool thin_icon/* = false*/)
|
|||||||
dc.SelectObject(wxNullBitmap);
|
dc.SelectObject(wxNullBitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
// ORCA MSW needs to set scale factor for bitmaps loaded from cache because they arent auto scaled by wxBitmapBundle like bitmaps
|
||||||
|
double scale = win ? win->GetDPIScaleFactor() : (wxWindow::FromDIP(100, nullptr) / 100.0);
|
||||||
|
bitmap->SetScaleFactor(scale);
|
||||||
|
#endif
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -633,6 +648,9 @@ wxBitmap *get_extruder_color_icon(std::vector<std::string> colors, bool is_gradi
|
|||||||
bitmap_key += "h" + std::to_string(icon_height) + "-w" + std::to_string(icon_width) + "-i" + label;
|
bitmap_key += "h" + std::to_string(icon_height) + "-w" + std::to_string(icon_width) + "-i" + label;
|
||||||
|
|
||||||
wxBitmap *bitmap = bmp_cache.find(bitmap_key);
|
wxBitmap *bitmap = bmp_cache.find(bitmap_key);
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
auto win = (wxWindow *) Slic3r::GUI::wxGetApp().mainframe;
|
||||||
|
#endif
|
||||||
if (bitmap == nullptr) {
|
if (bitmap == nullptr) {
|
||||||
|
|
||||||
std::vector<wxColour> wx_colors;
|
std::vector<wxColour> wx_colors;
|
||||||
@@ -656,8 +674,11 @@ wxBitmap *get_extruder_color_icon(std::vector<std::string> colors, bool is_gradi
|
|||||||
#ifndef __WXMSW__
|
#ifndef __WXMSW__
|
||||||
wxMemoryDC dc(base_bitmap);
|
wxMemoryDC dc(base_bitmap);
|
||||||
#else
|
#else
|
||||||
wxClientDC cdc((wxWindow *) Slic3r::GUI::wxGetApp().mainframe);
|
wxClientDC cdc(win);
|
||||||
wxMemoryDC dc(&cdc);
|
wxMemoryDC dc(&cdc);
|
||||||
|
// ORCA MSW needs to set scale factor for bitmaps loaded from cache because they arent auto scaled by wxBitmapBundle like bitmaps
|
||||||
|
double scale = win ? win->GetDPIScaleFactor() : (wxWindow::FromDIP(100, nullptr) / 100.0);
|
||||||
|
base_bitmap.SetScaleFactor(scale);
|
||||||
dc.SelectObject(base_bitmap);
|
dc.SelectObject(base_bitmap);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -694,6 +715,11 @@ wxBitmap *get_extruder_color_icon(std::vector<std::string> colors, bool is_gradi
|
|||||||
// cache result
|
// cache result
|
||||||
bitmap = bmp_cache.insert(bitmap_key, base_bitmap);
|
bitmap = bmp_cache.insert(bitmap_key, base_bitmap);
|
||||||
}
|
}
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
// ORCA MSW needs to set scale factor for bitmaps loaded from cache because they arent auto scaled by wxBitmapBundle like bitmaps
|
||||||
|
double scale = win ? win->GetDPIScaleFactor() : (wxWindow::FromDIP(100, nullptr) / 100.0);
|
||||||
|
bitmap->SetScaleFactor(scale);
|
||||||
|
#endif
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -704,6 +730,9 @@ wxBitmap *get_extruder_color_icon(std::string color, std::string label, int icon
|
|||||||
std::string bitmap_key = color + "-h" + std::to_string(icon_height) + "-w" + std::to_string(icon_width) + "-i" + label;
|
std::string bitmap_key = color + "-h" + std::to_string(icon_height) + "-w" + std::to_string(icon_width) + "-i" + label;
|
||||||
|
|
||||||
wxBitmap *bitmap = bmp_cache.find(bitmap_key);
|
wxBitmap *bitmap = bmp_cache.find(bitmap_key);
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
auto win = (wxWindow *) Slic3r::GUI::wxGetApp().mainframe;
|
||||||
|
#endif
|
||||||
if (bitmap == nullptr) {
|
if (bitmap == nullptr) {
|
||||||
// Paint the color icon.
|
// Paint the color icon.
|
||||||
// Slic3r::GUI::BitmapCache::parse_color(color, rgb);
|
// Slic3r::GUI::BitmapCache::parse_color(color, rgb);
|
||||||
@@ -714,7 +743,7 @@ wxBitmap *get_extruder_color_icon(std::string color, std::string label, int icon
|
|||||||
bitmap->UseAlpha();
|
bitmap->UseAlpha();
|
||||||
wxMemoryDC dc(*bitmap);
|
wxMemoryDC dc(*bitmap);
|
||||||
#elif defined(__WXMSW__)
|
#elif defined(__WXMSW__)
|
||||||
wxClientDC cdc((wxWindow *) Slic3r::GUI::wxGetApp().mainframe);
|
wxClientDC cdc(win);
|
||||||
wxMemoryDC dc(&cdc);
|
wxMemoryDC dc(&cdc);
|
||||||
dc.SelectObject(*bitmap);
|
dc.SelectObject(*bitmap);
|
||||||
#else
|
#else
|
||||||
@@ -748,6 +777,11 @@ wxBitmap *get_extruder_color_icon(std::string color, std::string label, int icon
|
|||||||
dc.DrawText(label, (icon_width - size.x) / 2, (icon_height - size.y) / 2);
|
dc.DrawText(label, (icon_width - size.x) / 2, (icon_height - size.y) / 2);
|
||||||
dc.SelectObject(wxNullBitmap);
|
dc.SelectObject(wxNullBitmap);
|
||||||
}
|
}
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
// ORCA MSW needs to set scale factor for bitmaps loaded from cache because they arent auto scaled by wxBitmapBundle like bitmaps
|
||||||
|
double scale = win ? win->GetDPIScaleFactor() : (wxWindow::FromDIP(100, nullptr) / 100.0);
|
||||||
|
bitmap->SetScaleFactor(scale);
|
||||||
|
#endif
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
void apply_extruder_selector(Slic3r::GUI::BitmapComboBox** ctrl,
|
void apply_extruder_selector(Slic3r::GUI::BitmapComboBox** ctrl,
|
||||||
|
|||||||
Reference in New Issue
Block a user