From 8f2ff7447e2c92817e19b0d22e002682daa0e365 Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Tue, 17 Dec 2024 14:16:54 +0800 Subject: [PATCH] ENH: param multiple extruder indicator icon Change-Id: I9e382dc72deaa0b682b1474c9b4094c31e550ad8 Jira: STUDIO-8872, STUDIO-9213 (cherry picked from commit dba496e1cc9cb293f63f950dd02f94e27b72fda1) --- src/slic3r/GUI/OG_CustomCtrl.cpp | 19 ++++++++++++++----- src/slic3r/GUI/OptionsGroup.hpp | 1 + src/slic3r/GUI/Tab.cpp | 2 ++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/OG_CustomCtrl.cpp b/src/slic3r/GUI/OG_CustomCtrl.cpp index 331d4a5db8..62cb0d7351 100644 --- a/src/slic3r/GUI/OG_CustomCtrl.cpp +++ b/src/slic3r/GUI/OG_CustomCtrl.cpp @@ -121,7 +121,7 @@ int OG_CustomCtrl::get_height(const Line& line) for (auto ctrl_line : ctrl_lines) if (&ctrl_line.og_line == &line) return ctrl_line.height; - + return 0; } @@ -366,7 +366,7 @@ void OG_CustomCtrl::OnMotion(wxMouseEvent& event) tooltip += line.og_line.label_tooltip; // BBS: markdown tip focusedLine = &line; - markdowntip = line.og_line.label.empty() + markdowntip = line.og_line.label.empty() ? line.og_line.get_options().front().opt_id : into_u8(line.og_line.label); markdowntip.erase(0, markdowntip.find_last_of('#') + 1); // BBS @@ -801,9 +801,18 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord h_pos, wxCoord v_pos) break; } } + bool is_multi_extruder = false; + if (ctrl->opt_group->draw_multi_extruder) + for (const Option& opt : option_set) + is_multi_extruder |= opt.opt_id.find_last_of('#') != std::string::npos; + wxCoord icon_pos = h_pos; + if (is_multi_extruder) { + static ScalableBitmap multi_extruder(ctrl, "multi_extruder"); + h_pos = draw_act_bmps(dc, wxPoint(h_pos, v_pos), multi_extruder.bmp(), multi_extruder.bmp(), false).x; + } is_url_string = !suppress_hyperlinks && !og_line.label_path.empty(); // BBS - h_pos = draw_text(dc, wxPoint(h_pos, v_pos), label /* + ":" */, text_clr, ctrl->opt_group->label_width * ctrl->m_em_unit, is_url_string, true); + h_pos = draw_text(dc, wxPoint(h_pos, v_pos), label /* + ":" */, text_clr, icon_pos + ctrl->opt_group->label_width * ctrl->m_em_unit - h_pos, is_url_string, true); } // If there's a widget, build it and set result to the correct position. @@ -837,7 +846,7 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord h_pos, wxCoord v_pos) h_pos = draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->bmp(), field->undo_bitmap()->bmp(), field->blink(), bmp_rect_id).x; } #ifndef DISABLE_BLINKING - else if (field && !field->undo_to_sys_bitmap() && field->blink()) + else if (field && !field->undo_to_sys_bitmap() && field->blink()) draw_blinking_bmp(dc, wxPoint(h_pos, v_pos), field->blink()); #endif }; @@ -943,7 +952,7 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC &dc, wxPoint pos, const wxString dc.SetFont(old_font.Underlined()); #else dc.SetFont(old_font.Bold().Underlined()); -#endif +#endif color = &clr_url; } dc.SetTextForeground(color ? *color : diff --git a/src/slic3r/GUI/OptionsGroup.hpp b/src/slic3r/GUI/OptionsGroup.hpp index ce523cbedc..18e3003a73 100644 --- a/src/slic3r/GUI/OptionsGroup.hpp +++ b/src/slic3r/GUI/OptionsGroup.hpp @@ -128,6 +128,7 @@ public: wxFont label_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }; int sidetext_width{ -1 }; int sublabel_width{ -1 }; + bool draw_multi_extruder { false }; /// Returns a copy of the pointer of the parent wxWindow. /// Accessor function is because users are not allowed to change the parent diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 0637c28506..c2b67579ea 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -5135,6 +5135,7 @@ void TabPrinter::build_unregular_pages(bool from_initial_build/* = false*/) existed_page = i; break; } + m_rebuild_kinematics_page = false; if (existed_page < n_before_extruders && (is_marlin_flavor || from_initial_build)) { auto page = build_kinematics_page(); @@ -7724,6 +7725,7 @@ void Tab::switch_excluder(int extruder_id) if (opt.second.second >= 0) { const_cast(opt.second.second) = index; page->m_opt_id_map.insert({opt.second.first + "#" + std::to_string(index), opt.first}); + group->draw_multi_extruder = !is_extruder && variant_ctrl->IsThisEnabled(); } } }