FIX: [STUDIO-1725] DropDown: icon scale size on Mac
Change-Id: I8128035df0c8623d220c791225adeb4a827cbb3f
This commit is contained in:
parent
92847823bc
commit
59773eee02
3 changed files with 20 additions and 8 deletions
|
@ -1356,15 +1356,16 @@ void Sidebar::load_ams_list(std::map<std::string, Ams *> const &list)
|
|||
{
|
||||
std::vector<DynamicPrintConfig> filament_ams_list;
|
||||
for (auto ams : list) {
|
||||
char n = ams.first.front() - '0' + 'A';
|
||||
for (auto tray : ams.second->trayList) {
|
||||
if (tray.second->setting_id.empty()) continue;
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__
|
||||
<< boost::format(": ams %1% tray %2% id %3% color %4%") % ams.first % tray.first % tray.second->setting_id % tray.second->color;
|
||||
char n = ams.first.front() - '0' + 'A';
|
||||
char t = tray.first.front() - '0' + '1';
|
||||
DynamicPrintConfig ams;
|
||||
ams.set_key_value("filament_id", new ConfigOptionStrings{tray.second->setting_id});
|
||||
ams.set_key_value("filament_type", new ConfigOptionStrings{tray.second->type});
|
||||
ams.set_key_value("tray_name", new ConfigOptionStrings{std::string(1, n) + tray.first});
|
||||
ams.set_key_value("tray_name", new ConfigOptionStrings{std::string(1, n) + std::string(1, t)});
|
||||
ams.set_key_value("filament_colour", new ConfigOptionStrings{"#" + tray.second->color.substr(0, 6)});
|
||||
filament_ams_list.emplace_back(std::move(ams));
|
||||
}
|
||||
|
|
|
@ -179,6 +179,15 @@ void DropDown::paintNow()
|
|||
Refresh();
|
||||
}
|
||||
|
||||
static wxSize GetBmpSize(wxBitmap & bmp)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
return bmp.GetScaledSize();
|
||||
#else
|
||||
return bmp.GetSize();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Here we do the actual rendering. I put it in a separate
|
||||
* method so that it can work no matter what type of DC
|
||||
|
@ -267,18 +276,19 @@ void DropDown::render(wxDC &dc)
|
|||
}
|
||||
if (rcContent.y > size.y) break;
|
||||
wxPoint pt = rcContent.GetLeftTop();
|
||||
auto & icon = icons[i];
|
||||
auto & icon = icons[i];
|
||||
auto size2 = GetBmpSize(icon);
|
||||
if (iconSize.x > 0) {
|
||||
if (icon.IsOk()) {
|
||||
pt.y += (rcContent.height - icon.GetSize().y) / 2;
|
||||
pt.y += (rcContent.height - size2.y) / 2;
|
||||
dc.DrawBitmap(icon, pt);
|
||||
}
|
||||
pt.x += iconSize.x + 5;
|
||||
pt.y = rcContent.y;
|
||||
} else if (icon.IsOk()) {
|
||||
pt.y += (rcContent.height - icon.GetSize().y) / 2;
|
||||
pt.y += (rcContent.height - size2.y) / 2;
|
||||
dc.DrawBitmap(icon, pt);
|
||||
pt.x += icon.GetWidth() + 5;
|
||||
pt.x += size2.x + 5;
|
||||
pt.y = rcContent.y;
|
||||
}
|
||||
auto text = texts[i];
|
||||
|
@ -305,7 +315,7 @@ void DropDown::messureSize()
|
|||
for (size_t i = 0; i < texts.size(); ++i) {
|
||||
wxSize size1 = text_off ? wxSize() : dc.GetMultiLineTextExtent(texts[i]);
|
||||
if (icons[i].IsOk()) {
|
||||
wxSize size2 = icons[i].GetSize();
|
||||
wxSize size2 = GetBmpSize(icons[i]);
|
||||
if (size2.x > iconSize.x) iconSize = size2;
|
||||
if (!align_icon) {
|
||||
size1.x += size2.x + (text_off ? 0 : 5);
|
||||
|
@ -317,7 +327,7 @@ void DropDown::messureSize()
|
|||
wxSize szContent = textSize;
|
||||
szContent.x += 10;
|
||||
if (check_bitmap.bmp().IsOk()) {
|
||||
auto szBmp = check_bitmap.bmp().GetSize();
|
||||
auto szBmp = check_bitmap.GetBmpSize();
|
||||
szContent.x += szBmp.x + 5;
|
||||
}
|
||||
if (iconSize.x > 0) szContent.x += iconSize.x + (text_off ? 0 : 5);
|
||||
|
|
|
@ -37,6 +37,7 @@ static std::map<wxColour, wxColour> gDarkColors{
|
|||
{"#D7E8DE", "#1F2B27"},
|
||||
{"#2B3436", "#808080"},
|
||||
{"#ABABAB", "#ABABAB"},
|
||||
{"#D9D9D9", "#2D2D32"},
|
||||
//{"#F0F0F0", "#3E3E44"},
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue