Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display filament labels in "change filament" context menus #4921

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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