mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
ENH: [STUDIO-1667] show ams tray name in color icon
Change-Id: Id98de7c8d08a337f32559b54acc0f8613aa2cf65
This commit is contained in:
parent
31ff48ccca
commit
91d36e0562
2 changed files with 11 additions and 2 deletions
|
@ -1360,9 +1360,11 @@ void Sidebar::load_ams_list(std::map<std::string, Ams *> const &list)
|
||||||
if (tray.second->setting_id.empty()) continue;
|
if (tray.second->setting_id.empty()) continue;
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__
|
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;
|
<< 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';
|
||||||
DynamicPrintConfig ams;
|
DynamicPrintConfig ams;
|
||||||
ams.set_key_value("filament_id", new ConfigOptionStrings{tray.second->setting_id});
|
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("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("filament_colour", new ConfigOptionStrings{"#" + tray.second->color.substr(0, 6)});
|
ams.set_key_value("filament_colour", new ConfigOptionStrings{"#" + tray.second->color.substr(0, 6)});
|
||||||
filament_ams_list.emplace_back(std::move(ams));
|
filament_ams_list.emplace_back(std::move(ams));
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,15 +384,22 @@ void PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
|
||||||
}
|
}
|
||||||
const_cast<Preset&>(*iter).is_visible = true;
|
const_cast<Preset&>(*iter).is_visible = true;
|
||||||
auto color = f.opt_string("filament_colour", 0u);
|
auto color = f.opt_string("filament_colour", 0u);
|
||||||
|
auto name = f.opt_string("tray_name", 0u);
|
||||||
wxColour clr(color);
|
wxColour clr(color);
|
||||||
wxImage img(16, 16);
|
wxImage img(24, 16);
|
||||||
if (clr.Red() > 224 && clr.Blue() > 224 && clr.Green() > 224) {
|
if (clr.Red() > 224 && clr.Blue() > 224 && clr.Green() > 224) {
|
||||||
img.SetRGB(wxRect({0, 0}, img.GetSize()), 128, 128, 128);
|
img.SetRGB(wxRect({0, 0}, img.GetSize()), 128, 128, 128);
|
||||||
img.SetRGB(wxRect({1, 1}, img.GetSize() - wxSize{2, 2}), clr.Red(), clr.Green(), clr.Blue());
|
img.SetRGB(wxRect({1, 1}, img.GetSize() - wxSize{2, 2}), clr.Red(), clr.Green(), clr.Blue());
|
||||||
} else {
|
} else {
|
||||||
img.SetRGB(wxRect({0, 0}, img.GetSize()), clr.Red(), clr.Green(), clr.Blue());
|
img.SetRGB(wxRect({0, 0}, img.GetSize()), clr.Red(), clr.Green(), clr.Blue());
|
||||||
}
|
}
|
||||||
int item_id = Append(get_preset_name(*iter), img, &m_first_ams_filament + (&f - &m_preset_bundle->filament_ams_list.front()));
|
wxBitmap bmp(img);
|
||||||
|
wxMemoryDC dc(bmp);
|
||||||
|
dc.SetFont(Label::Body_10);
|
||||||
|
dc.SetTextForeground(different_color(clr));
|
||||||
|
auto size = dc.GetTextExtent(name);
|
||||||
|
dc.DrawText(name, bmp.GetWidth() / 2 - size.x / 2, bmp.GetHeight() / 2 - size.y / 2);
|
||||||
|
int item_id = Append(get_preset_name(*iter), bmp.ConvertToImage(), &m_first_ams_filament + (&f - &m_preset_bundle->filament_ams_list.front()));
|
||||||
//validate_selection(id->value == selected); // can not select
|
//validate_selection(id->value == selected); // can not select
|
||||||
}
|
}
|
||||||
m_last_ams_filament = GetCount();
|
m_last_ams_filament = GetCount();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue