Using of wxWidgets 3.1.6 WIP:

* Create Cache of wxBitmapBundles instead of wxBitmaps
* Use wxBitmapBundles instead of wxBitmap for most of Widgets
* Use empty bitmabundles instead of wxNullBitmap for wxBitmapComboBoxes.
* Updated wxWidgets.cmake
* OSX specific: Discard BitmapComboBox overrides
+ some code cleaning
This commit is contained in:
YuSanka 2022-05-10 12:24:04 +02:00
parent 2ab64819aa
commit dd6f7a71f1
45 changed files with 930 additions and 867 deletions

View file

@ -142,19 +142,11 @@ std::map<std::string, std::string> SettingsFactory::CATEGORY_ICON =
{ L("Hollowing") , "hollowing" }
};
//wxBitmap SettingsFactory::get_category_bitmap(const std::string& category_name, bool menu_bmp /*= true*/)
wxBitmap SettingsFactory::get_category_bitmap_(const std::string& category_name, bool menu_bmp /*= true*/)
wxBitmapBundle* SettingsFactory::get_category_bitmap(const std::string& category_name)
{
if (CATEGORY_ICON.find(category_name) == CATEGORY_ICON.end())
return wxNullBitmap;
return /*menu_bmp ? create_menu_bitmap(CATEGORY_ICON.at(category_name)) : */create_scaled_bitmap(CATEGORY_ICON.at(category_name));
}
wxBitmapBundle SettingsFactory::get_category_bitmap(const std::string& category_name)
{
if (CATEGORY_ICON.find(category_name) == CATEGORY_ICON.end())
return wxNullBitmap;
return create_menu_bitmap(CATEGORY_ICON.at(category_name));
return get_bmp_bundle("empty");
return get_bmp_bundle(CATEGORY_ICON.at(category_name));
}
//-------------------------------------
@ -437,13 +429,12 @@ static void create_freq_settings_popupmenu(wxMenu* menu, const bool is_object_se
#endif
}
std::vector<wxBitmap> MenuFactory::get_volume_bitmaps()
std::vector<wxBitmapBundle*> MenuFactory::get_volume_bitmaps()
{
std::vector<wxBitmap> volume_bmps;
std::vector<wxBitmapBundle*> volume_bmps;
volume_bmps.reserve(ADD_VOLUME_MENU_ITEMS.size());
for (auto item : ADD_VOLUME_MENU_ITEMS)
// volume_bmps.push_back(create_menu_bitmap(item.second));
volume_bmps.push_back(create_scaled_bitmap(item.second, nullptr, 16, false, "", true));
volume_bmps.push_back(get_bmp_bundle(item.second));
return volume_bmps;
}
@ -623,7 +614,7 @@ wxMenuItem* MenuFactory::append_menu_item_settings(wxMenu* menu_)
// Add full settings list
auto menu_item = new wxMenuItem(menu, wxID_ANY, menu_name);
menu_item->SetBitmap(create_menu_bitmap("cog"));
menu_item->SetBitmap(*get_bmp_bundle("cog"));
menu_item->SetSubMenu(create_settings_popupmenu(menu, is_object_settings, item));
return menu->Append(menu_item);
@ -768,7 +759,7 @@ void MenuFactory::append_menu_item_change_extruder(wxMenu* menu)
return;
}
std::vector<wxBitmap*> icons = get_extruder_color_icons(true);
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons(true);
wxMenu* extruder_selection_menu = new wxMenu();
const wxString& name = sels.Count() == 1 ? names[0] : names[1];
@ -787,7 +778,7 @@ void MenuFactory::append_menu_item_change_extruder(wxMenu* menu)
(is_active_extruder ? " (" + _L("active") + ")" : "");
append_menu_item(extruder_selection_menu, wxID_ANY, item_name, "",
[i](wxCommandEvent&) { obj_list()->set_extruder_for_selected_items(i); }, *icons[icon_idx], menu,
[i](wxCommandEvent&) { obj_list()->set_extruder_for_selected_items(i); }, icons[icon_idx], menu,
[is_active_extruder]() { return !is_active_extruder; }, m_parent);
}
@ -1147,12 +1138,6 @@ void MenuFactory::update_default_menu()
create_default_menu();
}
void MenuFactory::msw_rescale()
{
for (MenuWithSeparators* menu : { &m_object_menu, &m_sla_object_menu, &m_part_menu, &m_default_menu })
msw_rescale_menu(dynamic_cast<wxMenu*>(menu));
}
#ifdef _WIN32
// For this class is used code from stackoverflow:
// https://stackoverflow.com/questions/257288/is-it-possible-to-write-a-template-to-check-for-a-functions-existence
@ -1182,7 +1167,7 @@ static void update_menu_item_def_colors(T* item)
void MenuFactory::sys_color_changed()
{
for (MenuWithSeparators* menu : { &m_object_menu, &m_sla_object_menu, &m_part_menu, &m_default_menu }) {
msw_rescale_menu(dynamic_cast<wxMenu*>(menu));// msw_rescale_menu updates just icons, so use it
sys_color_changed_menu(dynamic_cast<wxMenu*>(menu));// msw_rescale_menu updates just icons, so use it
#ifdef _WIN32
// but under MSW we have to update item's bachground color
for (wxMenuItem* item : menu->GetMenuItems())
@ -1195,14 +1180,17 @@ void MenuFactory::sys_color_changed(wxMenuBar* menubar)
{
for (size_t id = 0; id < menubar->GetMenuCount(); id++) {
wxMenu* menu = menubar->GetMenu(id);
msw_rescale_menu(menu);
sys_color_changed_menu(menu);
#ifndef __linux__
menu->SetupBitmaps();
#ifdef _WIN32
// but under MSW we have to update item's bachground color
for (wxMenuItem* item : menu->GetMenuItems())
update_menu_item_def_colors(item);
#endif
#endif
}
menubar->Refresh();
// menubar->Refresh();
}