Skip to content

Commit

Permalink
ENH: display filament labels in "change filament" context menus
Browse files Browse the repository at this point in the history
  • Loading branch information
javawizard committed Apr 8, 2024
1 parent fe914e8 commit 8084d36
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions src/slic3r/GUI/GUI_Factories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -897,8 +897,20 @@ void MenuFactory::append_menu_item_change_extruder(wxMenu* menu)
bool is_active_extruder = i == initial_extruder;
int icon_idx = i == 0 ? 0 : i - 1;

const wxString& item_name = (i == 0 ? _L("Default") : wxString::Format(_L("Filament %d"), i)) +
(is_active_extruder ? " (" + _L("active") + ")" : "");
wxString item_name = _L("Default");

if (i > 0) {
auto preset = wxGetApp().preset_bundle->filaments.find_preset(wxGetApp().preset_bundle->filament_presets[i - 1]);
if (preset == nullptr) {
item_name = wxString::Format(_L("Filament %d"), i);
} else {
item_name = from_u8(preset->label(false));
}
}

if (is_active_extruder) {
item_name << " (" + _L("current") + ")";
}

if (icon_idx >= 0 && icon_idx < icons.size()) {
append_menu_item(
Expand Down Expand Up @@ -1881,8 +1893,20 @@ void MenuFactory::append_menu_item_change_filament(wxMenu* menu)
//bool is_active_extruder = i == initial_extruder;
bool is_active_extruder = false;

const wxString& item_name = (i == 0 ? _L("Default") : wxString::Format(_L("Filament %d"), i)) +
(is_active_extruder ? " (" + _L("current") + ")" : "");
wxString item_name = _L("Default");

if (i > 0) {
auto preset = wxGetApp().preset_bundle->filaments.find_preset(wxGetApp().preset_bundle->filament_presets[i - 1]);
if (preset == nullptr) {
item_name = wxString::Format(_L("Filament %d"), i);
} else {
item_name = from_u8(preset->label(false));
}
}

if (is_active_extruder) {
item_name << " (" + _L("current") + ")";
}

append_menu_item(extruder_selection_menu, wxID_ANY, item_name, "",
[i](wxCommandEvent&) { obj_list()->set_extruder_for_selected_items(i); }, i == 0 ? wxNullBitmap : *icons[i - 1], menu,
Expand Down Expand Up @@ -1958,10 +1982,10 @@ void MenuFactory::append_menu_item_plate_name(wxMenu *menu)
// Delete old menu item
const int item_id = menu->FindItem(name);
if (item_id != wxNOT_FOUND) menu->Destroy(item_id);

PartPlate *plate = plater()->get_partplate_list().get_selected_plate();
assert(plate);

auto item = append_menu_item(
menu, wxID_ANY, name, "",
[plate](wxCommandEvent &e) {
Expand All @@ -1973,7 +1997,7 @@ void MenuFactory::append_menu_item_plate_name(wxMenu *menu)
else
{
plater()->select_plate_by_hover_id(hover_idx, false, true);
}
}
plater()->get_current_canvas3D()->post_event(SimpleEvent(EVT_GLCANVAS_PLATE_NAME_CHANGE));
},
"", nullptr, []() { return true; }, m_parent);
Expand Down

0 comments on commit 8084d36

Please sign in to comment.