From 5a2abf7e211327cde57717b5ab7b79b63c967bbd Mon Sep 17 00:00:00 2001 From: "xun.zhang" Date: Fri, 10 Jan 2025 12:06:59 +0800 Subject: [PATCH] ENH: add global map mode tag for pop up 1. Add tag to mark the global map mode 2. Fix some wrong usage of bmp in code 3. Fix display error in dark mode jira:STUDIO-9729 Signed-off-by: xun.zhang Change-Id: Idb36a5022c403e02c26d7fe23a95dd6877deca90 --- .../images/flush_mode_panel_icon_disabled.svg | 7 +++ resources/images/global_map_mode_tag.svg | 4 ++ src/slic3r/GUI/CapsuleButton.cpp | 12 ++--- src/slic3r/GUI/CapsuleButton.hpp | 3 ++ src/slic3r/GUI/FilamentGroupPopup.cpp | 53 +++++++++---------- src/slic3r/GUI/FilamentGroupPopup.hpp | 11 +++- src/slic3r/GUI/FilamentMapDialog.cpp | 2 - src/slic3r/GUI/FilamentMapPanel.cpp | 11 ++-- src/slic3r/GUI/FilamentMapPanel.hpp | 3 ++ 9 files changed, 63 insertions(+), 43 deletions(-) create mode 100644 resources/images/flush_mode_panel_icon_disabled.svg create mode 100644 resources/images/global_map_mode_tag.svg diff --git a/resources/images/flush_mode_panel_icon_disabled.svg b/resources/images/flush_mode_panel_icon_disabled.svg new file mode 100644 index 000000000..2e9cfc710 --- /dev/null +++ b/resources/images/flush_mode_panel_icon_disabled.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/resources/images/global_map_mode_tag.svg b/resources/images/global_map_mode_tag.svg new file mode 100644 index 000000000..d185c3563 --- /dev/null +++ b/resources/images/global_map_mode_tag.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/slic3r/GUI/CapsuleButton.cpp b/src/slic3r/GUI/CapsuleButton.cpp index daba169f2..962ad4b93 100644 --- a/src/slic3r/GUI/CapsuleButton.cpp +++ b/src/slic3r/GUI/CapsuleButton.cpp @@ -24,10 +24,10 @@ CapsuleButton::CapsuleButton(wxWindow *parent, wxWindowID id, const wxString &la auto sizer = new wxBoxSizer(wxHORIZONTAL); - std::string icon_name = selected ? "capsule_tag_on" : "capsule_tag_off"; - auto bmp = create_scaled_bitmap(icon_name, nullptr, FromDIP(16)); + tag_on_bmp = create_scaled_bitmap("capsule_tag_on", nullptr, FromDIP(16)); + tag_off_bmp = create_scaled_bitmap("capsule_tag_off", nullptr, FromDIP(16)); - m_btn = new wxBitmapButton(this, wxID_ANY, bmp, wxDefaultPosition, wxDefaultSize, wxNO_BORDER); + m_btn = new wxBitmapButton(this, wxID_ANY, selected?tag_on_bmp:tag_off_bmp, wxDefaultPosition, wxDefaultSize, wxNO_BORDER); m_btn->SetBackgroundColour(*wxWHITE); m_label = new Label(this, label); @@ -109,15 +109,13 @@ void CapsuleButton::OnLeaveWindow(wxMouseEvent &event) void CapsuleButton::UpdateStatus() { - std::string icon_name = m_selected ? "capsule_tag_on" : "capsule_tag_off"; - auto bmp = create_scaled_bitmap(icon_name, nullptr, FromDIP(16)); - m_btn->SetBitmap(bmp); - if (m_selected) { + m_btn->SetBitmap(tag_on_bmp); m_label->SetForegroundColour(TextSelectColor); m_label->SetBackgroundColour(BgSelectColor); m_btn->SetBackgroundColour(BgSelectColor); } else { + m_btn->SetBitmap(tag_off_bmp); m_label->SetForegroundColour(TextNormalColor); m_label->SetBackgroundColour(BgNormalColor); m_btn->SetBackgroundColour(BgNormalColor); diff --git a/src/slic3r/GUI/CapsuleButton.hpp b/src/slic3r/GUI/CapsuleButton.hpp index da10baf8c..7ec13f3e2 100644 --- a/src/slic3r/GUI/CapsuleButton.hpp +++ b/src/slic3r/GUI/CapsuleButton.hpp @@ -21,6 +21,9 @@ private: wxBitmapButton *m_btn; Label *m_label; + wxBitmap tag_on_bmp; + wxBitmap tag_off_bmp; + bool m_hovered; bool m_selected; }; diff --git a/src/slic3r/GUI/FilamentGroupPopup.cpp b/src/slic3r/GUI/FilamentGroupPopup.cpp index f2466a37b..750aad0f4 100644 --- a/src/slic3r/GUI/FilamentGroupPopup.cpp +++ b/src/slic3r/GUI/FilamentGroupPopup.cpp @@ -78,18 +78,23 @@ FilamentGroupPopup::FilamentGroupPopup(wxWindow *parent) : PopupWindow(parent, w button_labels.resize(ButtonType::btCount); button_desps.resize(ButtonType::btCount); detail_infos.resize(ButtonType::btCount); + global_mode_tags.resize(ButtonType::btCount); + std::vector btn_texts = {AutoForFlushLabel, AutoForMatchLabel, ManualLabel}; std::vector btn_desps = {AutoForFlushDesp, AutoForMatchDesp, ManualDesp}; std::vector mode_details = {AutoForFlushDetail, AutoForMatchDetail, ManualDetail}; top_sizer->AddSpacer(vertical_margin); - - auto checked_bmp = create_scaled_bitmap("map_mode_on", nullptr, 16); - auto unchecked_bmp = create_scaled_bitmap("map_mode_off", nullptr, 16); + checked_bmp = create_scaled_bitmap("map_mode_on", nullptr, 16);; + unchecked_bmp = create_scaled_bitmap("map_mode_off", nullptr, 16); + disabled_bmp = create_scaled_bitmap("map_mode_disabled", nullptr, 16); + checked_hover_bmp = create_scaled_bitmap("map_mode_on_hovered", nullptr, 16); + unchecked_hover_bmp = create_scaled_bitmap("map_mode_off_hovered", nullptr, 16); + global_tag_bmp = create_scaled_bitmap("global_map_mode_tag", nullptr, 16); for (size_t idx = 0; idx < ButtonType::btCount; ++idx) { wxBoxSizer *button_sizer = new wxBoxSizer(wxHORIZONTAL); - radio_btns[idx] = new wxBitmapButton(this, idx, unchecked_bmp, wxDefaultPosition, wxDefaultSize, wxNO_BORDER); + radio_btns[idx] = new wxBitmapButton(this, wxID_ANY, unchecked_bmp, wxDefaultPosition, wxDefaultSize, wxNO_BORDER); radio_btns[idx]->SetBackgroundColour(BackGroundColor); button_labels[idx] = new Label(this, btn_texts[idx]); @@ -102,10 +107,16 @@ FilamentGroupPopup::FilamentGroupPopup(wxWindow *parent) : PopupWindow(parent, w button_desps[idx]->SetForegroundColour(LabelEnableColor); button_desps[idx]->SetFont(Label::Body_14); - button_sizer->Add(radio_btns[idx], 0, wxALIGN_CENTER_VERTICAL); + global_mode_tags[idx] = new wxBitmapButton(this, wxID_ANY, global_tag_bmp, wxDefaultPosition, wxDefaultSize, wxNO_BORDER); + global_mode_tags[idx]->SetBackgroundColour(BackGroundColor); + global_mode_tags[idx]->SetToolTip(_L("Global settings")); + + button_sizer->Add(radio_btns[idx], 0, wxALIGN_CENTER); button_sizer->AddSpacer(ratio_spacing); - button_sizer->Add(button_labels[idx], 0, wxALIGN_CENTER_VERTICAL); - button_sizer->Add(button_desps[idx], 0, wxALIGN_CENTER_VERTICAL); + button_sizer->Add(button_labels[idx], 0, wxALIGN_CENTER); + button_sizer->Add(button_desps[idx], 0, wxALIGN_CENTER); + button_sizer->AddSpacer(ratio_spacing); + button_sizer->Add(global_mode_tags[idx], 0, wxALIGN_CENTER); wxBoxSizer *label_sizer = new wxBoxSizer(wxHORIZONTAL); @@ -170,23 +181,11 @@ void FilamentGroupPopup::DrawRoundedCorner(int radius) HWND hwnd = GetHWND(); if (hwnd) { HRGN hrgn = CreateRoundRectRgn(0, 0, GetRect().GetWidth(), GetRect().GetHeight(), radius, radius); - SetWindowRgn(hwnd, hrgn, TRUE); + SetWindowRgn(hwnd, hrgn, FALSE); SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); SetLayeredWindowAttributes(hwnd, 0, 0, LWA_COLORKEY); } -#else - wxClientDC dc(this); - wxGraphicsContext *gc = wxGraphicsContext::Create(dc); - if (gc) { - gc->SetBrush(*wxWHITE_BRUSH); - gc->SetPen(*wxTRANSPARENT_PEN); - wxRect rect(0, 0, GetSize().GetWidth(), GetSize().GetHeight()); - wxGraphicsPath path = wxGraphicsRenderer::GetDefaultRenderer()->CreatePath(); - path.AddRoundedRectangle(0, 0, rect.width, rect.height, radius); - gc->DrawPath(path); - delete gc; - } #endif } @@ -195,8 +194,6 @@ void FilamentGroupPopup::Init() const wxString AutoForMatchDesp = _L("(Arrange before slicing)"); const wxString MachineSyncTip = _L("(Please sync printer)"); - auto disabled_bmp = create_scaled_bitmap("map_mode_disabled", nullptr, 16); - auto unchecked_bmp = create_scaled_bitmap("map_mode_off", nullptr, 16); radio_btns[ButtonType::btForMatch]->Enable(m_connected); if (m_connected) { button_labels[ButtonType::btForMatch]->SetForegroundColour(LabelEnableColor); @@ -239,6 +236,7 @@ void FilamentGroupPopup::tryPopup(Plater* plater,PartPlate* partplate,bool skip_ m_active = true; Init(); ResetTimer(); + DrawRoundedCorner(16); PopupWindow::Popup(); } } @@ -308,13 +306,12 @@ void FilamentGroupPopup::OnEnterWindow(wxMouseEvent &) { ResetTimer(); } void FilamentGroupPopup::UpdateButtonStatus(int hover_idx) { - auto checked_bmp = create_scaled_bitmap("map_mode_on", nullptr, 16); - auto unchecked_bmp = create_scaled_bitmap("map_mode_off", nullptr, 16); - auto checked_hover_bmp = create_scaled_bitmap("map_mode_on_hovered", nullptr, 16); - auto unchecked_hover_bmp = create_scaled_bitmap("map_mode_off_hovered", nullptr, 16); - - + auto global_mode = plater_ref->get_global_filament_map_mode(); for (int i = 0; i < ButtonType::btCount; ++i) { + if (mode_list.at(i) == global_mode) + global_mode_tags[i]->Show(); + else + global_mode_tags[i]->Hide(); if (ButtonType::btForMatch == i && !m_connected) { button_labels[i]->SetFont(Label::Body_14); continue; diff --git a/src/slic3r/GUI/FilamentGroupPopup.hpp b/src/slic3r/GUI/FilamentGroupPopup.hpp index 2b853c5b9..8c4612b30 100644 --- a/src/slic3r/GUI/FilamentGroupPopup.hpp +++ b/src/slic3r/GUI/FilamentGroupPopup.hpp @@ -48,11 +48,20 @@ private: FilamentMapMode m_mode; wxTimer *m_timer; - std::vector radio_btns; + std::vector radio_btns; + std::vector global_mode_tags; std::vector