From 05383187e02cc0dec6a541859d44237a63d01820 Mon Sep 17 00:00:00 2001 From: "xun.zhang" Date: Tue, 24 Dec 2024 10:50:53 +0800 Subject: [PATCH] FIX: fail to translate in filamnet group pop up 1. Initilize the sentences in construct function 2. Fix some ui bugs jira:NONE Signed-off-by: xun.zhang Change-Id: I991df343932bb60d5ba86f41f641661f2159da47 --- bbl/i18n/list.txt | 3 +- resources/images/map_mode_disabled.svg | 3 + src/slic3r/GUI/CapsuleButton.cpp | 10 ++-- src/slic3r/GUI/CapsuleButton.hpp | 2 +- src/slic3r/GUI/DragDropPanel.cpp | 4 +- src/slic3r/GUI/FilamentGroupPopup.cpp | 77 +++++++++++++++----------- src/slic3r/GUI/FilamentGroupPopup.hpp | 4 +- src/slic3r/GUI/FilamentMapDialog.cpp | 42 +++++++++++++- src/slic3r/GUI/FilamentMapDialog.hpp | 5 -- src/slic3r/GUI/FilamentMapPanel.cpp | 24 ++++---- 10 files changed, 113 insertions(+), 61 deletions(-) create mode 100644 resources/images/map_mode_disabled.svg diff --git a/bbl/i18n/list.txt b/bbl/i18n/list.txt index 1b1a3fd4b..d45d1ac3e 100644 --- a/bbl/i18n/list.txt +++ b/bbl/i18n/list.txt @@ -174,4 +174,5 @@ src/slic3r/GUI/MultiMachineManagerPage.cpp src/slic3r/GUI/MultiTaskManagerPage.cpp src/slic3r/GUI/MultiMachine.cpp src/slic3r/GUI/FilamentMapDialog.cpp -src/slic3r/GUI/FilamentGroupPopup.cpp \ No newline at end of file +src/slic3r/GUI/FilamentGroupPopup.cpp +src/slic3r/GUI/FilamentMapPanel.cpp \ No newline at end of file diff --git a/resources/images/map_mode_disabled.svg b/resources/images/map_mode_disabled.svg new file mode 100644 index 000000000..91440c962 --- /dev/null +++ b/resources/images/map_mode_disabled.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/slic3r/GUI/CapsuleButton.cpp b/src/slic3r/GUI/CapsuleButton.cpp index ed544e982..a3a2d267d 100644 --- a/src/slic3r/GUI/CapsuleButton.cpp +++ b/src/slic3r/GUI/CapsuleButton.cpp @@ -2,7 +2,6 @@ #include "CapsuleButton.hpp" #include "wx/graphics.h" #include "Widgets/Label.hpp" -#include "wx/dcgraph.h" namespace Slic3r { namespace GUI { CapsuleButton::CapsuleButton(wxWindow *parent, wxWindowID id, const wxString &label, bool selected) : wxPanel(parent, id) @@ -61,10 +60,11 @@ void CapsuleButton::OnPaint(wxPaintEvent &event) gc->DrawRoundedRectangle(0, 0, rect.width, rect.height, 0); wxColour bg_color = m_selected ? wxColour("#EBF9F0") : wxColour("#FFFFFF"); wxColour border_color = m_hovered || m_selected ? wxColour("#00AE42") : wxColour("#CECECE"); - int cornerRadius = 5; + bg_color = StateColor::darkModeColorFor(bg_color); + border_color = StateColor::darkModeColorFor(border_color); gc->SetBrush(wxBrush(bg_color)); gc->SetPen(wxPen(border_color, 2)); - gc->DrawRoundedRectangle(1, 1, rect.width - 2, rect.height - 2, cornerRadius); + gc->DrawRoundedRectangle(1, 1, rect.width - 2, rect.height - 2, 5); delete gc; } } @@ -99,8 +99,8 @@ void CapsuleButton::OnLeaveWindow(wxMouseEvent &event) void CapsuleButton::UpdateStatus() { - const wxColour selected_color = wxColour("#EBF9F0"); - const wxColour normal_color = wxColour("#FFFFFF"); + wxColour selected_color = StateColor::darkModeColorFor(wxColour("#EBF9F0")); + wxColour normal_color = StateColor::darkModeColorFor(wxColour("#FFFFFF")); std::string icon_name = m_selected ? "capsule_tag_on" : "capsule_tag_off"; auto bmp = create_scaled_bitmap(icon_name, nullptr, FromDIP(16)); diff --git a/src/slic3r/GUI/CapsuleButton.hpp b/src/slic3r/GUI/CapsuleButton.hpp index 87d516752..55ed9714b 100644 --- a/src/slic3r/GUI/CapsuleButton.hpp +++ b/src/slic3r/GUI/CapsuleButton.hpp @@ -1,8 +1,8 @@ #ifndef CAPSULE_BUTTON_HPP #define CAPSULE_BUTTON_HPP -#include "GUI.hpp" #include "wxExtensions.hpp" +#include "Widgets/Label.hpp" namespace Slic3r { namespace GUI { class CapsuleButton : public wxPanel diff --git a/src/slic3r/GUI/DragDropPanel.cpp b/src/slic3r/GUI/DragDropPanel.cpp index c7f110200..9dbdf725b 100644 --- a/src/slic3r/GUI/DragDropPanel.cpp +++ b/src/slic3r/GUI/DragDropPanel.cpp @@ -181,7 +181,7 @@ DragDropPanel::DragDropPanel(wxWindow *parent, const wxString &label, bool is_au m_sizer->Add(title_panel, 0, wxEXPAND); m_sizer->AddSpacer(20); - m_grid_item_sizer = new wxGridSizer(0, 6, FromDIP(5),FromDIP(5)); // row = 0, col = 3, 10 10 is space + m_grid_item_sizer = new wxGridSizer(0, 6, FromDIP(4),FromDIP(4)); // row = 0, col = 3, 10 10 is space m_sizer->Add(m_grid_item_sizer, 1, wxEXPAND); // set droptarget @@ -197,7 +197,7 @@ void DragDropPanel::AddColorBlock(const wxColour &color, int filament_id, bool u { ColorPanel *panel = new ColorPanel(this, color, filament_id); panel->SetMinSize(wxSize(FromDIP(32), FromDIP(40))); - m_grid_item_sizer->Add(panel, 0, wxALIGN_CENTER); + m_grid_item_sizer->Add(panel, 0); m_filament_blocks.push_back(panel); if (update_ui) { m_filament_blocks.front()->Refresh(); // FIX BUG: STUDIO-8467 diff --git a/src/slic3r/GUI/FilamentGroupPopup.cpp b/src/slic3r/GUI/FilamentGroupPopup.cpp index 3a4c8bd7b..6666f14e0 100644 --- a/src/slic3r/GUI/FilamentGroupPopup.cpp +++ b/src/slic3r/GUI/FilamentGroupPopup.cpp @@ -2,35 +2,17 @@ #include "FilamentMapDialog.hpp" #include "GUI_App.hpp" #include "MsgDialog.hpp" -#include "I18N.hpp" #include "wx/dcgraph.h" +#include "I18N.hpp" namespace Slic3r { namespace GUI { -static const wxString AutoForFlushLabel = _L("Filament-Saving Mode"); -static const wxString AutoForMatchLabel = _L("Convenient Mode"); -static const wxString ManualLabel = _L("Manual Mode"); - -static const wxString AutoForFlushDesp = _L("(Arrange after slicing)"); -static const wxString AutoForMatchDesp = _L("(Arrange before slicing)"); -static const wxString ManualDesp = ""; -static const wxString MachineSyncTip = _L("(Please sync printer)"); - -static const wxString AutoForFlushDetail = _L("Disregrad the filaments in AMS. Optimize filament usage " - "by calculating the best allocation for the left and right " - "nozzles. Arrange the filaments according on the printer according to " - "the slicing results."); -static const wxString AutoForMatchDetail = _L("Based on the current filaments in the AMS, allocate the " - "filaments to the left and right nozzles."); -static const wxString ManualDetail = _L("Mannully allocate the filaments for the left and right nozzles."); - static const wxColour LabelEnableColor = wxColour("#262E30"); -static const wxColour LabelDisableColor = wxColour("#6B6B6B"); +static const wxColour LabelDisableColor = wxColour("#ACACAC"); static const wxColour GreyColor = wxColour("#6B6B6B"); static const wxColour GreenColor = wxColour("#00AE42"); static const wxColour BackGroundColor = wxColour("#FFFFFF"); - static bool is_multi_extruder() { const auto &preset_bundle = wxGetApp().preset_bundle; @@ -85,6 +67,23 @@ bool is_pop_up_required() FilamentGroupPopup::FilamentGroupPopup(wxWindow *parent) : PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS) { + const wxString AutoForFlushLabel = _L("Filament-Saving Mode"); + const wxString AutoForMatchLabel = _L("Convenient Mode"); + const wxString ManualLabel = _L("Manual Mode"); + + const wxString AutoForFlushDetail = _L("Disregrad the filaments in AMS. Optimize filament usage " + "by calculating the best arrangement for the left and right " + "nozzles. Arrange the filaments on the printer based on " + "the slicing results."); + const wxString AutoForMatchDetail = _L("Based on the current filaments in the AMS, arrange the " + "filaments to the left and right nozzles."); + const wxString ManualDetail = _L("Mannully arrange the filaments for the left and right nozzles."); + + const wxString AutoForFlushDesp = _L("(Arrange after slicing)"); + const wxString ManualDesp = ""; + const wxString AutoForMatchDesp = _L("(Arrange before slicing)"); + const wxString MachineSyncTip = _L("(Please sync printer)"); + wxBoxSizer *top_sizer = new wxBoxSizer(wxVERTICAL); const int horizontal_margin = FromDIP(16); const int vertical_margin = FromDIP(15); @@ -189,6 +188,7 @@ FilamentGroupPopup::FilamentGroupPopup(wxWindow *parent) : PopupWindow(parent, w GUI::wxGetApp().UpdateDarkUIWin(this); + Bind(wxEVT_PAINT, &FilamentGroupPopup::OnPaint, this); Bind(wxEVT_TIMER, &FilamentGroupPopup::OnTimer, this); Bind(wxEVT_ENTER_WINDOW, &FilamentGroupPopup::OnEnterWindow, this); Bind(wxEVT_LEAVE_WINDOW, &FilamentGroupPopup::OnLeaveWindow, this); @@ -222,17 +222,24 @@ void FilamentGroupPopup::DrawRoundedCorner(int radius) 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); - else - button_labels[ButtonType::btForMatch]->SetForegroundColour(LabelDisableColor); - - if (m_connected) { + button_labels[ButtonType::btForMatch]->SetForegroundColour(LabelEnableColor); + button_desps[ButtonType::btForMatch]->SetForegroundColour(LabelEnableColor); + detail_infos[ButtonType::btForMatch]->SetForegroundColour(GreyColor); + radio_btns[ButtonType::btForMatch]->SetBitmap(unchecked_bmp); button_desps[ButtonType::btForMatch]->SetLabel(AutoForMatchDesp); } else { + button_labels[ButtonType::btForMatch]->SetForegroundColour(LabelDisableColor); + button_desps[ButtonType::btForMatch]->SetForegroundColour(LabelDisableColor); + detail_infos[ButtonType::btForMatch]->SetForegroundColour(LabelDisableColor); + radio_btns[ButtonType::btForMatch]->SetBitmap(disabled_bmp); button_desps[ButtonType::btForMatch]->SetLabel(MachineSyncTip); } @@ -258,7 +265,6 @@ void FilamentGroupPopup::tryPopup(bool connect_status) if (canPopup()) { m_connected = connect_status; - DrawRoundedCorner(16); Init(); ResetTimer(); PopupWindow::Popup(); @@ -267,6 +273,11 @@ void FilamentGroupPopup::tryPopup(bool connect_status) void FilamentGroupPopup::tryClose() { StartTimer(); } +void FilamentGroupPopup::OnPaint(wxPaintEvent&) +{ + DrawRoundedCorner(16); +} + void FilamentGroupPopup::StartTimer() { m_timer->StartOnce(300); } void FilamentGroupPopup::ResetTimer() @@ -276,6 +287,8 @@ void FilamentGroupPopup::ResetTimer() void FilamentGroupPopup::OnRadioBtn(int idx) { + if (mode_list.at(idx) == FilamentMapMode::fmmAutoForMatch && !m_connected) + return; m_mode = mode_list.at(idx); set_prefered_map_mode(m_mode); @@ -290,7 +303,7 @@ void FilamentGroupPopup::OnRemindBtn(wxCommandEvent &event) set_pop_up_remind_flag(!is_checked); if (is_checked) { - MessageDialog dialog(nullptr, _L("No further pop up.You can go to \"Preferences\" to reopen the pop up."), _L("Tips"), wxICON_INFORMATION | wxOK); + MessageDialog dialog(nullptr, _L("No further pop-up will appear. You can reopen it in 'Preferences'"), _L("Tips"), wxICON_INFORMATION | wxOK); dialog.ShowModal(); Dismiss(); } @@ -311,8 +324,9 @@ 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); - auto unchecked_hover_bmp = create_scaled_bitmap("map_mode_off_hovered", nullptr); + 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); + for (int i = 0; i < ButtonType::btCount; ++i) { if (ButtonType::btForMatch == i && !m_connected) { @@ -339,8 +353,9 @@ void FilamentGroupPopup::UpdateButtonStatus(int hover_idx) remind_checkbox->Enable(false); else remind_checkbox->Enable(true); - Fit(); + Layout(); + Fit(); } }} // namespace Slic3r::GUI \ No newline at end of file diff --git a/src/slic3r/GUI/FilamentGroupPopup.hpp b/src/slic3r/GUI/FilamentGroupPopup.hpp index 52725de28..dc9fdd7a1 100644 --- a/src/slic3r/GUI/FilamentGroupPopup.hpp +++ b/src/slic3r/GUI/FilamentGroupPopup.hpp @@ -1,9 +1,6 @@ #ifndef FILAMENT_GROUP_HOVER_HPP #define FILAMENT_GROUP_HOVER_HPP -#include -#include -#include "wxExtensions.hpp" #include "Widgets/PopupWindow.hpp" #include "Widgets/CheckBox.hpp" #include "Widgets/Label.hpp" @@ -23,6 +20,7 @@ public: FilamentMapMode GetSelectedMode() const { return m_mode; } private: + void OnPaint(wxPaintEvent&event); void StartTimer(); void ResetTimer(); diff --git a/src/slic3r/GUI/FilamentMapDialog.cpp b/src/slic3r/GUI/FilamentMapDialog.cpp index f8a23e6e3..5e6c9fa80 100644 --- a/src/slic3r/GUI/FilamentMapDialog.cpp +++ b/src/slic3r/GUI/FilamentMapDialog.cpp @@ -9,6 +9,34 @@ namespace Slic3r { namespace GUI { +static const StateColor btn_bg_green( + std::pair(wxColour(27, 136, 68), StateColor::Pressed), + std::pair(wxColour(61, 203, 115), StateColor::Hovered), + std::pair(wxColour(0, 174, 66), StateColor::Normal) + ); + +static const StateColor btn_bd_green( + std::pair(wxColour(0, 174, 66), StateColor::Normal) + ); + +static const StateColor btn_text_green( + std::pair(wxColour(255, 255, 254), StateColor::Normal) + ); + +static const StateColor btn_bg_white( + std::pair(wxColour(206, 206, 206), StateColor::Pressed), + std::pair(wxColour(238, 238, 238), StateColor::Hovered), + std::pair(wxColour(255, 255, 255), StateColor::Normal) + ); + +static const StateColor btn_bd_white( + std::pair(wxColour(38, 46, 48), StateColor::Normal) + ); + +static const StateColor btn_text_white( + std::pair(wxColour(38, 46, 48), StateColor::Normal) + ); + FilamentMapDialog::FilamentMapDialog(wxWindow *parent, const std::vector &filament_color, const std::vector &filament_map, @@ -21,8 +49,8 @@ FilamentMapDialog::FilamentMapDialog(wxWindow *parent, { SetBackgroundColour(*wxWHITE); - SetMinSize(wxSize(FromDIP(550), -1)); - SetMaxSize(wxSize(FromDIP(550), -1)); + SetMinSize(wxSize(FromDIP(580), -1)); + SetMaxSize(wxSize(FromDIP(580), -1)); if (mode < fmmManual) m_page_type = PageType::ptAuto; @@ -70,8 +98,18 @@ FilamentMapDialog::FilamentMapDialog(wxWindow *parent, wxBoxSizer *button_sizer = new wxBoxSizer(wxHORIZONTAL); m_ok_btn = new Button(this, _L("OK")); m_cancel_btn = new Button(this, _L("Cancel")); + m_ok_btn->SetCornerRadius(FromDIP(12)); + m_cancel_btn->SetCornerRadius(FromDIP(12)); m_ok_btn->SetFont(Label::Body_12); m_cancel_btn->SetFont(Label::Body_12); + + m_ok_btn->SetBackgroundColor(btn_bg_green); + m_ok_btn->SetBorderColor(btn_bd_green); + m_ok_btn->SetTextColor(btn_text_green); + m_cancel_btn->SetBackgroundColor(btn_bg_white); + m_cancel_btn->SetBorderColor(btn_bd_white); + m_cancel_btn->SetTextColor(btn_text_white); + button_sizer->Add(m_ok_btn, 0, wxALL, FromDIP(8)); button_sizer->Add(m_cancel_btn, 0, wxALL, FromDIP(8)); main_sizer->Add(button_sizer, 0, wxALIGN_RIGHT | wxALL, FromDIP(15)); diff --git a/src/slic3r/GUI/FilamentMapDialog.hpp b/src/slic3r/GUI/FilamentMapDialog.hpp index abdc19f17..59973fed9 100644 --- a/src/slic3r/GUI/FilamentMapDialog.hpp +++ b/src/slic3r/GUI/FilamentMapDialog.hpp @@ -1,13 +1,8 @@ #ifndef slic3r_FilamentMapDialog_hpp_ #define slic3r_FilamentMapDialog_hpp_ -#include "GUI.hpp" #include "FilamentMapPanel.hpp" -#include -#include -#include #include -#include "SelectMachine.hpp" #include "CapsuleButton.hpp" class SwitchButton; diff --git a/src/slic3r/GUI/FilamentMapPanel.cpp b/src/slic3r/GUI/FilamentMapPanel.cpp index 2f150efeb..a7f6bc103 100644 --- a/src/slic3r/GUI/FilamentMapPanel.cpp +++ b/src/slic3r/GUI/FilamentMapPanel.cpp @@ -42,8 +42,8 @@ FilamentMapManualPanel::FilamentMapManualPanel(wxWindow *p top_sizer->Add(drag_sizer, 0, wxALIGN_CENTER|wxEXPAND); - m_tips = new Label(this, _L("Tips: You can drag the filaments to change which extruder they are assigned to.\n" - "But your filament arrangement may not be the most filament-efficient.")); + m_tips = new Label(this, _L("Tips: You can drag the filaments to reassign them to different nozzles.\n" + "But your filament arrangement may not be the most efficient for filament usage.")); m_tips->SetFont(Label::Body_14); m_tips->SetForegroundColour(wxColour("#6B6B6B")); top_sizer->AddSpacer(FromDIP(8)); @@ -165,18 +165,20 @@ void FilamentMapBtnPanel::OnPaint(wxPaintEvent &event) gc->DrawRoundedRectangle(0, 0, rect.width, rect.height, 0); wxColour bg_color = m_selected ? wxColour("#EBF9F0") : wxColour("#FFFFFF"); wxColour border_color = m_hover || m_selected ? wxColour("#00AE42") : wxColour("#CECECE"); - int cornerRadius = 8; + bg_color = StateColor::darkModeColorFor(bg_color); + border_color = StateColor::darkModeColorFor(border_color); gc->SetBrush(wxBrush(bg_color)); gc->SetPen(wxPen(border_color, 2)); - gc->DrawRoundedRectangle(1, 1, rect.width - 2, rect.height - 2, cornerRadius); + gc->DrawRoundedRectangle(1, 1, rect.width - 2, rect.height - 2, 8); delete gc; } } void FilamentMapBtnPanel::UpdateStatus() { - const wxColour selected_color = wxColour("#EBF9F0"); - const wxColour normal_color = wxColour("#FFFFFF"); + const wxColour selected_color = StateColor::darkModeColorFor(wxColour("#EBF9F0")); + const wxColour normal_color = StateColor::darkModeColorFor(wxColour("#FFFFFF")); + if (m_selected) { m_btn->SetBackgroundColour(selected_color); m_label->SetBackgroundColour(selected_color); @@ -235,13 +237,13 @@ void GUI::FilamentMapBtnPanel::Show() FilamentMapAutoPanel::FilamentMapAutoPanel(wxWindow *parent, FilamentMapMode mode) : wxPanel(parent) { static const wxString AutoForFlushDetail = _L("Disregrad the filaments in AMS. Optimize filament usage " - "by calculating the best allocation for the left and right " - "nozzles. Arrange the filaments according on the printer according to " + "by calculating the best arrangement for the left and right " + "nozzles. Arrange the filaments on the printer based on " "the slicing results."); - static const wxString AutoForMatchDetail = _L("Based on the current filaments in the AMS, allocate the " + static const wxString AutoForMatchDetail = _L("Based on the current filaments in the AMS, arrange the " "filaments to the left and right nozzles."); auto sizer = new wxBoxSizer(wxHORIZONTAL); - m_flush_panel = new FilamentMapBtnPanel(this, _L("Material-Saving Mode"), AutoForFlushDetail, "flush_mode_panel_icon"); + m_flush_panel = new FilamentMapBtnPanel(this, _L("Filament-Saving Mode"), AutoForFlushDetail, "flush_mode_panel_icon"); m_match_panel = new FilamentMapBtnPanel(this, _L("Convenient Mode"), AutoForMatchDetail,"match_mode_panel_icon"); sizer->AddStretchSpacer(); @@ -296,7 +298,7 @@ FilamentMapDefaultPanel::FilamentMapDefaultPanel(wxWindow *parent) : wxPanel(par { auto sizer = new wxBoxSizer(wxHORIZONTAL); - m_label = new Label(this, _L("The material allocation for the current disk follows the global settings.")); + m_label = new Label(this, _L("The filament arrangement for current plate follows the global settings.")); m_label->SetFont(Label::Body_14); m_label->SetBackgroundColour(*wxWHITE);