diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 18fdbb0c1..d05413161 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -391,6 +391,8 @@ set(SLIC3R_GUI_SOURCES GUI/BBLStatusBar.cpp GUI/BBLStatusBarSend.hpp GUI/BBLStatusBarSend.cpp + GUI/BBLStatusBarPrint.hpp + GUI/BBLStatusBarPrint.cpp GUI/BBLStatusBarBind.hpp GUI/BBLStatusBarBind.cpp GUI/Mouse3DController.cpp diff --git a/src/slic3r/GUI/AmsMappingPopup.cpp b/src/slic3r/GUI/AmsMappingPopup.cpp index 23614b63e..9ab07228d 100644 --- a/src/slic3r/GUI/AmsMappingPopup.cpp +++ b/src/slic3r/GUI/AmsMappingPopup.cpp @@ -421,6 +421,7 @@ AmsMapingPopup::AmsMapingPopup(wxWindow *parent) wxBoxSizer* sizer_split_ams = new wxBoxSizer(wxHORIZONTAL); auto ams_title_text = new Label(parent, text); ams_title_text->SetFont(::Label::Body_13); + ams_title_text->SetBackgroundColour(*wxWHITE); ams_title_text->SetForegroundColour(0x909090); auto m_split_left_line = new wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); m_split_left_line->SetBackgroundColour(0xeeeeee); diff --git a/src/slic3r/GUI/BBLStatusBarPrint.cpp b/src/slic3r/GUI/BBLStatusBarPrint.cpp new file mode 100644 index 000000000..ae2b35888 --- /dev/null +++ b/src/slic3r/GUI/BBLStatusBarPrint.cpp @@ -0,0 +1,408 @@ +#include "BBLStatusBarPrint.hpp" + +#include +#include +#include +#include +#include +#include "wx/evtloop.h" +#include +#include "GUI_App.hpp" + +#include "I18N.hpp" + +#include +#include + +namespace Slic3r { + +wxDEFINE_EVENT(EVT_SHOW_ERROR_INFO, wxCommandEvent); + +BBLStatusBarPrint::BBLStatusBarPrint(wxWindow *parent, int id) + : m_self{new wxPanel(parent, id == -1 ? wxID_ANY : id)} + , m_sizer(new wxBoxSizer(wxHORIZONTAL)) +{ + m_self->SetBackgroundColour(*wxWHITE); + wxBoxSizer *m_sizer_body = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *m_sizer_top = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *m_sizer_bottom = new wxBoxSizer(wxHORIZONTAL); + + + auto top_panel = new wxPanel(m_self, wxID_ANY); + top_panel->SetBackgroundColour(*wxWHITE); + top_panel->SetMinSize(wxSize(m_self->FromDIP(530), m_self->FromDIP(26))); + top_panel->SetMaxSize(wxSize(m_self->FromDIP(530), m_self->FromDIP(26))); + + m_status_text = new wxStaticText(top_panel, wxID_ANY, wxEmptyString); + m_status_text->SetForegroundColour(wxColour(107, 107, 107)); + m_status_text->SetMinSize(wxSize(-1, m_self->FromDIP(26))); + m_status_text->SetMaxSize(wxSize(-1, m_self->FromDIP(26))); + m_status_text->SetFont(::Label::Body_13); + + StateColor btn_bt_white(std::pair(wxColour(0x90, 0x90, 0x90), StateColor::Disabled), + std::pair(wxColour(206, 206, 206), StateColor::Pressed), + std::pair(wxColour(238, 238, 238), StateColor::Hovered), + std::pair(*wxWHITE, StateColor::Normal)); + + StateColor btn_bd_white(std::pair(wxColour(255, 255, 254), StateColor::Disabled), + std::pair(wxColour(38, 46, 48), StateColor::Enabled)); + + + StateColor btn_txt_white(std::pair(wxColour("#FFFFFE"), StateColor::Disabled), std::pair(wxColour(38, 46, 48), StateColor::Normal)); + + m_cancelbutton = new Button(m_self, _L("Cancel")); + m_cancelbutton->SetMinSize(wxSize(m_self->FromDIP(80), m_self->FromDIP(32))); + m_cancelbutton->SetMaxSize(wxSize(m_self->FromDIP(80), m_self->FromDIP(32))); + m_cancelbutton->SetBackgroundColor(btn_bt_white); + m_cancelbutton->SetBorderColor(btn_bd_white); + m_cancelbutton->SetTextColor(btn_txt_white); + m_cancelbutton->SetCornerRadius(4); + m_cancelbutton->Bind(wxEVT_BUTTON, + [this](wxCommandEvent &evt) { + m_was_cancelled = true; + if (m_cancel_cb_fina) + m_cancel_cb_fina(); + }); + + m_stext_percent = new wxStaticText(top_panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0); + m_stext_percent->SetForegroundColour(wxColour(107, 107, 107)); + m_stext_percent->SetFont(::Label::Head_13); + m_stext_percent->Wrap(-1); + + m_sizer_status_text = new wxBoxSizer(wxHORIZONTAL); + m_link_show_error = new Label(top_panel, _L("Check the reason")); + m_link_show_error->SetMinSize(wxSize(-1, m_self->FromDIP(26))); + m_link_show_error->SetMinSize(wxSize(-1, m_self->FromDIP(26))); + m_link_show_error->SetForegroundColour(wxColour(0x00ae42)); + m_link_show_error->SetFont(::Label::Head_13); + m_link_show_error->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) { this->m_self->SetCursor(wxCURSOR_HAND); }); + m_link_show_error->Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) { this->m_self->SetCursor(wxCURSOR_ARROW); }); + + m_bitmap_show_error_close = create_scaled_bitmap("link_more_error_close", nullptr, 7); + m_bitmap_show_error_open = create_scaled_bitmap("link_more_error_open", nullptr, 7); + m_static_bitmap_show_error = new wxStaticBitmap(top_panel, wxID_ANY, m_bitmap_show_error_open, wxDefaultPosition, wxSize(m_self->FromDIP(7), m_self->FromDIP(7))); + + m_link_show_error->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {this->m_self->SetCursor(wxCURSOR_HAND); }); + m_link_show_error->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {this->m_self->SetCursor(wxCURSOR_ARROW); }); + m_link_show_error->Bind(wxEVT_LEFT_DOWN, [this](auto& e) { + if (!m_show_error_info_state) { m_show_error_info_state = true; m_static_bitmap_show_error->SetBitmap(m_bitmap_show_error_close); } + else { m_show_error_info_state = false; m_static_bitmap_show_error->SetBitmap(m_bitmap_show_error_open); } + wxCommandEvent* evt = new wxCommandEvent(EVT_SHOW_ERROR_INFO); + wxQueueEvent(this->m_self->GetParent(), evt); + }); + + + m_link_show_error->Hide(); + m_static_bitmap_show_error->Hide(); + m_static_bitmap_show_error->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {this->m_self->SetCursor(wxCURSOR_HAND); }); + m_static_bitmap_show_error->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {this->m_self->SetCursor(wxCURSOR_ARROW); }); + m_static_bitmap_show_error->Bind(wxEVT_LEFT_DOWN, [this](auto& e) { + if (!m_show_error_info_state) {m_show_error_info_state = true;m_static_bitmap_show_error->SetBitmap(m_bitmap_show_error_close);} + else {m_show_error_info_state = false;m_static_bitmap_show_error->SetBitmap(m_bitmap_show_error_open);} + wxCommandEvent* evt = new wxCommandEvent(EVT_SHOW_ERROR_INFO); + wxQueueEvent(this->m_self->GetParent(), evt); + }); + + m_sizer_status_text->Add(m_link_show_error, 0, wxALIGN_CENTER, 0); + m_sizer_status_text->Add(0, 0, 0, wxLEFT, top_panel->FromDIP(4)); + m_sizer_status_text->Add(m_static_bitmap_show_error, 0, wxALIGN_CENTER, 0); + + + m_prog = new wxGauge(m_self, wxID_ANY, 100, wxDefaultPosition, wxSize(-1, m_self->FromDIP(6)), wxGA_HORIZONTAL); + m_prog->SetMinSize(wxSize(m_self->FromDIP(530), m_self->FromDIP(6))); + m_prog->SetMaxSize(wxSize(m_self->FromDIP(530), m_self->FromDIP(6))); + m_prog->SetValue(0); + + m_sizer_bottom->Add(m_prog, 1, wxALIGN_CENTER, 0); + m_sizer_bottom->Add(0, 0, 1, wxEXPAND, 0); + + + m_sizer_top->Add(m_status_text, 1, wxALIGN_CENTER, 0); + m_sizer_top->Add(m_sizer_status_text, 0, wxLEFT|wxEXPAND, m_self->FromDIP(6)); + m_sizer_top->Add(0, 0, 1, wxEXPAND, 0); + m_sizer_top->Add(m_stext_percent, 0, wxEXPAND, 0); + + top_panel->SetSizer(m_sizer_top); + top_panel->Layout(); + + m_sizer_body->Add(top_panel, 0, wxEXPAND, 0); + m_sizer_body->Add(m_sizer_bottom, 0, wxEXPAND, 0); + m_sizer_body->Add(0, 0, 1, wxEXPAND, 0); + + wxBoxSizer *m_sizer_button = new wxBoxSizer(wxVERTICAL); + m_sizer_button->Add(m_cancelbutton, 0, wxALIGN_CENTER, 0); + + m_sizer->Add(m_sizer_body, 1, wxALIGN_CENTER, 0); + m_sizer->Add(m_sizer_button, 0, wxALIGN_CENTER, 0); + + m_self->SetSizer(m_sizer); + m_self->Layout(); + m_sizer->Fit(m_self); +} + +void BBLStatusBarPrint::set_prog_block() +{ +} + +int BBLStatusBarPrint::get_progress() const +{ + return m_prog->GetValue(); +} + +void BBLStatusBarPrint::set_progress(int val) +{ + if(val < 0) return; + + //add the logic for arrange/orient jobs, which don't call stop_busy + if (!m_prog->IsShown()) { + m_sizer->Show(m_prog); + m_sizer->Show(m_cancelbutton); + } + m_prog->SetValue(val); + set_percent_text(wxString::Format("%d%%", val)); + + m_sizer->Layout(); +} + +int BBLStatusBarPrint::get_range() const +{ + return m_prog->GetRange(); +} + +void BBLStatusBarPrint::set_range(int val) +{ + if(val != m_prog->GetRange()) { + m_prog->SetRange(val); + } +} + +void BBLStatusBarPrint::clear_percent() +{ + //set_percent_text(wxEmptyString); + m_cancelbutton->Hide(); +} + +void BBLStatusBarPrint::show_error_info(wxString msg, int code, wxString description, wxString extra) +{ + set_status_text(msg); + m_prog->Hide(); + m_stext_percent->Hide(); + m_link_show_error->Show(); + m_static_bitmap_show_error->Show(); + + m_cancelbutton->Show(); + m_self->Layout(); + m_sizer->Layout(); +} + +void BBLStatusBarPrint::show_progress(bool show) +{ + if (show) { + m_sizer->Show(m_prog); + m_sizer->Layout(); + } + else { + m_sizer->Hide(m_prog); + m_sizer->Layout(); + } +} + +void BBLStatusBarPrint::start_busy(int rate) +{ + m_busy = true; + show_progress(true); + show_cancel_button(); +} + +void BBLStatusBarPrint::stop_busy() +{ + show_progress(false); + hide_cancel_button(); + m_prog->SetValue(0); + m_sizer->Layout(); + m_busy = false; +} + +void BBLStatusBarPrint::set_cancel_callback_fina(BBLStatusBarPrint::CancelFn ccb) +{ + m_cancel_cb_fina = ccb; + if (ccb) { + m_sizer->Show(m_cancelbutton); + } else { + m_sizer->Hide(m_cancelbutton); + } +} + +void BBLStatusBarPrint::set_cancel_callback(BBLStatusBarPrint::CancelFn ccb) { + /* m_cancel_cb = ccb; + if (ccb) { + m_sizer->Show(m_cancelbutton); + } + else { + m_sizer->Hide(m_cancelbutton); + } + m_sizer->Layout();*/ +} + +wxPanel* BBLStatusBarPrint::get_panel() +{ + return m_self; +} + +bool BBLStatusBarPrint::is_english_text(wxString str) +{ + std::regex reg("^[0-9a-zA-Z]+$"); + std::smatch matchResult; + + std::string pattern_Special = "{}[]<>~!@#$%^&*(),.?/ :"; + for (auto i = 0; i < str.Length(); i++) { + std::string regex_str = wxString(str[i]).ToStdString(); + if (std::regex_match(regex_str, matchResult, reg)) { + continue; + } + else { + int result = pattern_Special.find(regex_str.c_str()); + if (result < 0 || result > pattern_Special.length()) { + return false; + } + } + } + return true; +} + +bool BBLStatusBarPrint::format_text(wxStaticText* dc, int width, const wxString& text, wxString& multiline_text) +{ + bool multiline = false; + multiline_text = text; + if (width > 0 && dc->GetTextExtent(text).x > width) { + size_t start = 0; + while (true) { + size_t idx = size_t(-1); + for (size_t i = start; i < multiline_text.Len(); i++) { + if (multiline_text[i] == ' ') { + if (dc->GetTextExtent(multiline_text.SubString(start, i)).x < width) + idx = i; + else { + if (idx == size_t(-1)) idx = i; + break; + } + } + } + if (idx == size_t(-1)) break; + multiline = true; + multiline_text[idx] = '\n'; + start = idx + 1; + if (dc->GetTextExtent(multiline_text.Mid(start)).x < width) break; + } + } + return multiline; + //return dc->GetTextExtent(multiline_text); +} + + +void BBLStatusBarPrint::set_status_text(const wxString& txt) +{ + //auto txtss = "Sending the printing task has timed out.\nPlease try again!"; + //auto txtss = "The printing project is being uploaded... 25%%"; + //m_status_text->SetLabelText(txtss); + //wxString str; + //format_text(m_status_text, m_self->FromDIP(300), txt, str); + + //if (m_status_text->GetTextExtent(txt).x > m_self->FromDIP(360)) { + // m_status_text->SetSize(m_self->FromDIP(360), m_self->FromDIP(40)); + //} + m_status_text->SetLabelText(txt); + //m_status_text->Wrap(m_self->FromDIP(360)); + //m_status_text->Layout(); + //m_self->Layout(); + //if (is_english_text(str)) m_status_text->Wrap(m_self->FromDIP(280)); +} + +void BBLStatusBarPrint::set_percent_text(const wxString &txt) +{ + m_stext_percent->SetLabelText(txt); +} + +void BBLStatusBarPrint::set_status_text(const std::string& txt) +{ + this->set_status_text(txt.c_str()); +} + +void BBLStatusBarPrint::set_status_text(const char *txt) +{ + this->set_status_text(wxString::FromUTF8(txt)); + get_panel()->GetParent()->Layout(); + get_panel()->GetParent()->Update(); +} + +void BBLStatusBarPrint::msw_rescale() { + //set_prog_block(); + m_cancelbutton->SetMinSize(wxSize(m_self->FromDIP(56), m_self->FromDIP(24))); +} + +wxString BBLStatusBarPrint::get_status_text() const +{ + return m_status_text->GetLabelText(); +} + +bool BBLStatusBarPrint::update_status(wxString &msg, bool &was_cancel, int percent, bool yield) +{ + set_status_text(msg); + if (percent >= 0) + this->set_progress(percent); + + if (yield) + wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI | wxEVT_CATEGORY_USER_INPUT); + was_cancel = m_was_cancelled; + return true; +} + +void BBLStatusBarPrint::reset() +{ + m_link_show_error->Hide(); + m_static_bitmap_show_error->Hide(); + m_prog->Show(); + m_stext_percent->Show(); + m_cancelbutton->Enable(); + m_cancelbutton->Show(); + m_was_cancelled = false; + + set_status_text(""); + set_progress(0); + set_percent_text(wxString::Format("%d%%", 0)); +} + +void BBLStatusBarPrint::set_font(const wxFont &font) +{ + m_self->SetFont(font); +} + +void BBLStatusBarPrint::show_cancel_button() +{ + m_sizer->Show(m_cancelbutton); + m_sizer->Layout(); +} + +void BBLStatusBarPrint::hide_cancel_button() +{ + m_sizer->Hide(m_cancelbutton); + m_cancelbutton->Hide(); + m_sizer->Layout(); +} + +void BBLStatusBarPrint::change_button_label(wxString name) +{ + m_cancelbutton->SetLabel(name); +} + +void BBLStatusBarPrint::disable_cancel_button() +{ + m_cancelbutton->Disable(); +} + +void BBLStatusBarPrint::enable_cancel_button() +{ + m_cancelbutton->Enable(); +} + +} diff --git a/src/slic3r/GUI/BBLStatusBarPrint.hpp b/src/slic3r/GUI/BBLStatusBarPrint.hpp new file mode 100644 index 000000000..37c4c146f --- /dev/null +++ b/src/slic3r/GUI/BBLStatusBarPrint.hpp @@ -0,0 +1,105 @@ +#ifndef BBLStatusBarPrint_HPP +#define BBLStatusBarPrint_HPP + +#include +#include + +#include +#include +#include +#include +#include + +#include "Jobs/ProgressIndicator.hpp" +#include "Widgets/Label.hpp" +#include "Widgets/Button.hpp" + +class wxTimer; +class wxGauge; +class wxButton; +class wxTimerEvent; +class wxStatusBar; +class wxWindow; +class wxFrame; +class wxString; +class wxFont; + +namespace Slic3r { + +class BBLStatusBarPrint : public ProgressIndicator +{ + wxPanel * m_self; // we cheat! It should be the base class but: perl! + wxGauge * m_prog; + Label * m_link_show_error; + wxBoxSizer* m_sizer_status_text; + wxStaticBitmap* m_static_bitmap_show_error; + wxBitmap m_bitmap_show_error_close; + wxBitmap m_bitmap_show_error_open; + Button * m_cancelbutton; + wxStaticText *m_status_text; + wxStaticText *m_stext_percent; + wxBoxSizer * m_sizer; + wxBoxSizer * m_sizer_eline; + wxWindow * block_left; + wxWindow * block_right; + +public: + BBLStatusBarPrint(wxWindow *parent = nullptr, int id = -1); + ~BBLStatusBarPrint() = default; + + int get_progress() const; + // if the argument is less than 0 it shows the last state or + // pulses if no state was set before. + void set_prog_block(); + void set_progress(int) override; + int get_range() const override; + void set_range(int = 100) override; + void clear_percent() override; + void show_error_info(wxString msg, int code, wxString description, wxString extra) override; + void show_progress(bool); + void start_busy(int = 100); + void stop_busy(); + void set_cancel_callback_fina(BBLStatusBarPrint::CancelFn ccb); + inline bool is_busy() const { return m_busy; } + void set_cancel_callback(CancelFn = CancelFn()) override; + inline void reset_cancel_callback() { set_cancel_callback(); } + wxPanel * get_panel(); + bool is_english_text(wxString str); + bool format_text(wxStaticText* dc, int width, const wxString& text, wxString& multiline_text); + void set_status_text(const wxString& txt); + void set_percent_text(const wxString &txt); + void msw_rescale(); + void set_status_text(const std::string &txt); + void set_status_text(const char *txt) override; + wxString get_status_text() const; + void set_font(const wxFont &font); + void set_object_info(const wxString &txt); + void set_slice_info(const wxString &txt); + void show_slice_info(bool show); + bool is_slice_info_shown(); + bool update_status(wxString &msg, bool &was_cancel, int percent = -1, bool yield = true); + void reset(); + // Temporary methods to satisfy Perl side + void show_cancel_button(); + void hide_cancel_button(); + void change_button_label(wxString name); + + void disable_cancel_button(); + void enable_cancel_button(); +private: + bool m_show_error_info_state = false; + bool m_busy = false; + bool m_was_cancelled = false; + CancelFn m_cancel_cb; + CancelFn m_cancel_cb_fina; +}; + +namespace GUI { +using Slic3r::BBLStatusBarPrint; +} + +wxDECLARE_EVENT(EVT_SHOW_ERROR_INFO, wxCommandEvent); + +} // namespace Slic3r + +#endif // BBLSTATUSBAR_HPP diff --git a/src/slic3r/GUI/BBLStatusBarSend.cpp b/src/slic3r/GUI/BBLStatusBarSend.cpp index 3976ae7bb..637c240ac 100644 --- a/src/slic3r/GUI/BBLStatusBarSend.cpp +++ b/src/slic3r/GUI/BBLStatusBarSend.cpp @@ -16,10 +16,10 @@ namespace Slic3r { -wxDEFINE_EVENT(EVT_SHOW_ERROR_INFO, wxCommandEvent); +wxDEFINE_EVENT(EVT_SHOW_ERROR_INFO_SEND, wxCommandEvent); BBLStatusBarSend::BBLStatusBarSend(wxWindow *parent, int id) - : m_self{new wxPanel(parent, id == -1 ? wxID_ANY : id)} + : m_self{new wxPanel(parent, id == -1 ? wxID_ANY : id)} , m_sizer(new wxBoxSizer(wxHORIZONTAL)) { m_self->SetBackgroundColour(wxColour(255,255,255)); @@ -57,7 +57,7 @@ BBLStatusBarSend::BBLStatusBarSend(wxWindow *parent, int id) m_cancelbutton->SetBorderColor(btn_bd_white); m_cancelbutton->SetTextColor(btn_txt_white); m_cancelbutton->SetCornerRadius(m_self->FromDIP(12)); - m_cancelbutton->Bind(wxEVT_BUTTON, + m_cancelbutton->Bind(wxEVT_BUTTON, [this](wxCommandEvent &evt) { m_was_cancelled = true; if (m_cancel_cb_fina) @@ -83,10 +83,10 @@ BBLStatusBarSend::BBLStatusBarSend(wxWindow *parent, int id) m_link_show_error->Bind(wxEVT_LEFT_DOWN, [this](auto& e) { if (!m_show_error_info_state) { m_show_error_info_state = true; m_static_bitmap_show_error->SetBitmap(m_bitmap_show_error_close); } else { m_show_error_info_state = false; m_static_bitmap_show_error->SetBitmap(m_bitmap_show_error_open); } - wxCommandEvent* evt = new wxCommandEvent(EVT_SHOW_ERROR_INFO); - wxQueueEvent(this->m_self->GetParent(), evt); + wxCommandEvent* evt = new wxCommandEvent(EVT_SHOW_ERROR_INFO_SEND); + wxQueueEvent(this->m_self->GetParent(), evt); }); - + m_link_show_error->Hide(); m_static_bitmap_show_error->Hide(); @@ -97,7 +97,7 @@ BBLStatusBarSend::BBLStatusBarSend(wxWindow *parent, int id) m_static_bitmap_show_error->Bind(wxEVT_LEFT_DOWN, [this](auto& e) { if (!m_show_error_info_state) {m_show_error_info_state = true;m_static_bitmap_show_error->SetBitmap(m_bitmap_show_error_close);} else {m_show_error_info_state = false;m_static_bitmap_show_error->SetBitmap(m_bitmap_show_error_open);} - wxCommandEvent* evt = new wxCommandEvent(EVT_SHOW_ERROR_INFO); + wxCommandEvent* evt = new wxCommandEvent(EVT_SHOW_ERROR_INFO_SEND); wxQueueEvent(this->m_self->GetParent(), evt); }); @@ -143,7 +143,7 @@ void BBLStatusBarSend::set_progress(int val) } m_prog->SetValue(val); set_percent_text(wxString::Format("%d%%", val)); - + m_sizer->Layout(); } @@ -206,9 +206,9 @@ void BBLStatusBarSend::stop_busy() m_busy = false; } -void BBLStatusBarSend::set_cancel_callback_fina(BBLStatusBarSend::CancelFn ccb) -{ - m_cancel_cb_fina = ccb; +void BBLStatusBarSend::set_cancel_callback_fina(BBLStatusBarSend::CancelFn ccb) +{ + m_cancel_cb_fina = ccb; if (ccb) { m_sizer->Show(m_cancelbutton); } else { @@ -307,18 +307,18 @@ void BBLStatusBarSend::set_percent_text(const wxString &txt) } void BBLStatusBarSend::set_status_text(const std::string& txt) -{ +{ this->set_status_text(txt.c_str()); } void BBLStatusBarSend::set_status_text(const char *txt) -{ +{ this->set_status_text(wxString::FromUTF8(txt)); get_panel()->GetParent()->Layout(); get_panel()->GetParent()->Update(); } -void BBLStatusBarSend::msw_rescale() { +void BBLStatusBarSend::msw_rescale() { //set_prog_block(); m_cancelbutton->SetMinSize(wxSize(m_self->FromDIP(56), m_self->FromDIP(24))); } @@ -372,7 +372,7 @@ void BBLStatusBarSend::hide_cancel_button() m_sizer->Layout(); } -void BBLStatusBarSend::change_button_label(wxString name) +void BBLStatusBarSend::change_button_label(wxString name) { m_cancelbutton->SetLabel(name); } diff --git a/src/slic3r/GUI/BBLStatusBarSend.hpp b/src/slic3r/GUI/BBLStatusBarSend.hpp index e5eff5202..dfab9257d 100644 --- a/src/slic3r/GUI/BBLStatusBarSend.hpp +++ b/src/slic3r/GUI/BBLStatusBarSend.hpp @@ -98,7 +98,7 @@ namespace GUI { using Slic3r::BBLStatusBarSend; } -wxDECLARE_EVENT(EVT_SHOW_ERROR_INFO, wxCommandEvent); +wxDECLARE_EVENT(EVT_SHOW_ERROR_INFO_SEND, wxCommandEvent); } // namespace Slic3r diff --git a/src/slic3r/GUI/CalibrationWizardPage.cpp b/src/slic3r/GUI/CalibrationWizardPage.cpp index 4e26bd316..27bf6de20 100644 --- a/src/slic3r/GUI/CalibrationWizardPage.cpp +++ b/src/slic3r/GUI/CalibrationWizardPage.cpp @@ -817,7 +817,7 @@ CaliPageSendingPanel::CaliPageSendingPanel(wxWindow* parent, wxWindowID id, cons Layout(); Fit(); - Bind(EVT_SHOW_ERROR_INFO, [this](auto& e) { + Bind(EVT_SHOW_ERROR_INFO_SEND, [this](auto& e) { show_send_failed_info(true); }); } diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 558764084..fad54f1d1 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -463,7 +463,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) m_filament_panel_left_sizer = new wxBoxSizer(wxVERTICAL); auto left_recommend_title_sizer = new wxBoxSizer(wxHORIZONTAL); - auto left_recommend_title1 = new Label(m_filament_left_panel, _L("Left Extruder")); + auto left_recommend_title1 = new Label(m_filament_left_panel, _L("Left Nozzle")); left_recommend_title1->SetFont(::Label::Head_13); left_recommend_title1->SetBackgroundColour(wxColour(0xF8F8F8)); left_recommend_title_sizer->Add(left_recommend_title1, 0, wxALIGN_CENTER, 0); @@ -482,7 +482,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) m_filament_panel_right_sizer = new wxBoxSizer(wxVERTICAL); auto right_recommend_title_sizer = new wxBoxSizer(wxHORIZONTAL); - auto right_recommend_title1 = new Label(m_filament_right_panel, _L("Right Extruder")); + auto right_recommend_title1 = new Label(m_filament_right_panel, _L("Right Nozzle")); right_recommend_title1->SetFont(::Label::Head_13); right_recommend_title1->SetBackgroundColour(wxColour(0xF8F8F8)); right_recommend_title_sizer->Add(right_recommend_title1, 0, wxALIGN_CENTER, 0); @@ -561,12 +561,21 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) sizer_split_options->Add(m_split_options_line, 1, wxALIGN_CENTER, 0); wxBoxSizer *sizer_advanced_options_title = new wxBoxSizer(wxHORIZONTAL); + + m_hyperlink = new wxHyperlinkCtrl(this, wxID_ANY, _L("Click here if you can't connect to the printer"), + wxT("https://wiki.bambulab.com/en/software/bambu-studio/failed-to-connect-printer"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); + m_hyperlink->SetFont(::Label::Body_13); + + + auto advanced_options_title = new Label(this, _L("Advanced Options")); advanced_options_title->SetFont(::Label::Body_13); advanced_options_title->SetForegroundColour(wxColour(38, 46, 48)); m_advanced_options_icon = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("advanced_option1", this, 18), wxDefaultPosition, wxSize(FromDIP(18), FromDIP(18))); + + sizer_advanced_options_title->Add(m_hyperlink, 0, wxALIGN_CENTER, 0); sizer_advanced_options_title->Add(0, 0, 1, wxEXPAND, 0); sizer_advanced_options_title->Add(advanced_options_title, 0, wxALIGN_CENTER, 0); sizer_advanced_options_title->Add(m_advanced_options_icon, 0, wxALIGN_CENTER, 0); @@ -650,43 +659,39 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) option_nozzle_offset_cali_cali->Hide(); option_use_ams->Hide(); - m_simplebook = new wxSimplebook(this, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_DIALOG_SIMBOOK_SIZE, 0); + m_simplebook = new wxSimplebook(this, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_DIALOG_SIMBOOK_SIZE2, 0); + m_simplebook->SetMinSize(SELECT_MACHINE_DIALOG_SIMBOOK_SIZE2); + m_simplebook->SetMaxSize(SELECT_MACHINE_DIALOG_SIMBOOK_SIZE2); // perpare mode m_panel_prepare = new wxPanel(m_simplebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); m_panel_prepare->SetBackgroundColour(m_colour_def_color); - wxBoxSizer *m_sizer_prepare = new wxBoxSizer(wxVERTICAL); - wxBoxSizer *m_sizer_pcont = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *m_sizer_prepare = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *m_sizer_pcont = new wxBoxSizer(wxVERTICAL); - m_sizer_prepare->Add(0, 0, 1, wxTOP, FromDIP(12)); - auto hyperlink_sizer = new wxBoxSizer( wxHORIZONTAL ); - m_hyperlink = new wxHyperlinkCtrl(m_panel_prepare, wxID_ANY, _L("Click here if you can't connect to the printer"), wxT("https://wiki.bambulab.com/en/software/bambu-studio/failed-to-connect-printer"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); - - hyperlink_sizer->Add(m_hyperlink, 0, wxALIGN_CENTER | wxALL, 5); - m_sizer_prepare->Add(hyperlink_sizer, 0, wxALIGN_CENTER | wxALL, 5); m_button_ensure = new Button(m_panel_prepare, _L("Send")); m_button_ensure->SetBackgroundColor(m_btn_bg_enable); m_button_ensure->SetBorderColor(m_btn_bg_enable); m_button_ensure->SetTextColor(StateColor::darkModeColorFor("#FFFFFE")); - m_button_ensure->SetSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE); - m_button_ensure->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE); - m_button_ensure->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE); - m_button_ensure->SetCornerRadius(FromDIP(5)); + m_button_ensure->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE2); + m_button_ensure->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE2); + m_button_ensure->SetCornerRadius(FromDIP(4)); m_button_ensure->Bind(wxEVT_BUTTON, &SelectMachineDialog::on_ok_btn, this); m_sizer_pcont->Add(0, 0, 1, wxEXPAND, 0); - m_sizer_pcont->Add(m_button_ensure, 0,wxRIGHT, 0); + m_sizer_pcont->Add(m_button_ensure, 0,wxALIGN_CENTER, 0); + m_sizer_prepare->Add(0, 0, 1, wxTOP, FromDIP(12)); + m_sizer_prepare->Add(m_sizer_pcont, 0, wxALIGN_CENTER, 0); - m_sizer_prepare->Add(m_sizer_pcont, 0, wxEXPAND, 0); m_panel_prepare->SetSizer(m_sizer_prepare); m_panel_prepare->Layout(); m_simplebook->AddPage(m_panel_prepare, wxEmptyString, true); // sending mode - m_status_bar = std::make_shared(m_simplebook); + m_status_bar = std::make_shared(m_simplebook); m_panel_sending = m_status_bar->get_panel(); m_simplebook->AddPage(m_panel_sending, wxEmptyString, false); @@ -716,11 +721,11 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) m_simplebook->AddPage(m_panel_finish, wxEmptyString, false); //show bind failed info - m_sw_print_failed_info = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(380), FromDIP(125)), wxVSCROLL); + m_sw_print_failed_info = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxSize(SELECT_MACHINE_DIALOG_SIMBOOK_SIZE2.x, FromDIP(125)), wxVSCROLL); m_sw_print_failed_info->SetBackgroundColour(*wxWHITE); m_sw_print_failed_info->SetScrollRate(0, 5); - m_sw_print_failed_info->SetMinSize(wxSize(FromDIP(380), FromDIP(125))); - m_sw_print_failed_info->SetMaxSize(wxSize(FromDIP(380), FromDIP(125))); + m_sw_print_failed_info->SetMinSize(wxSize(SELECT_MACHINE_DIALOG_SIMBOOK_SIZE2.x, FromDIP(125))); + m_sw_print_failed_info->SetMaxSize(wxSize(SELECT_MACHINE_DIALOG_SIMBOOK_SIZE2.x, FromDIP(125))); wxBoxSizer* sizer_print_failed_info = new wxBoxSizer(wxVERTICAL); m_sw_print_failed_info->SetSizer(sizer_print_failed_info); @@ -741,8 +746,8 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) m_st_txt_error_code->SetFont(::Label::Body_13); st_title_error_code->SetMinSize(wxSize(FromDIP(74), -1)); st_title_error_code->SetMaxSize(wxSize(FromDIP(74), -1)); - m_st_txt_error_code->SetMinSize(wxSize(FromDIP(260), -1)); - m_st_txt_error_code->SetMaxSize(wxSize(FromDIP(260), -1)); + m_st_txt_error_code->SetMinSize(wxSize(FromDIP(500), -1)); + m_st_txt_error_code->SetMaxSize(wxSize(FromDIP(500), -1)); sizer_error_code->Add(st_title_error_code, 0, wxALL, 0); sizer_error_code->Add(st_title_error_code_doc, 0, wxALL, 0); sizer_error_code->Add(m_st_txt_error_code, 0, wxALL, 0); @@ -759,8 +764,8 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) m_st_txt_error_desc->SetFont(::Label::Body_13); st_title_error_desc->SetMinSize(wxSize(FromDIP(74), -1)); st_title_error_desc->SetMaxSize(wxSize(FromDIP(74), -1)); - m_st_txt_error_desc->SetMinSize(wxSize(FromDIP(260), -1)); - m_st_txt_error_desc->SetMaxSize(wxSize(FromDIP(260), -1)); + m_st_txt_error_desc->SetMinSize(wxSize(FromDIP(500), -1)); + m_st_txt_error_desc->SetMaxSize(wxSize(FromDIP(500), -1)); sizer_error_desc->Add(st_title_error_desc, 0, wxALL, 0); sizer_error_desc->Add(st_title_error_desc_doc, 0, wxALL, 0); sizer_error_desc->Add(m_st_txt_error_desc, 0, wxALL, 0); @@ -776,8 +781,8 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) m_st_txt_extra_info->SetFont(::Label::Body_13); st_title_extra_info->SetMinSize(wxSize(FromDIP(74), -1)); st_title_extra_info->SetMaxSize(wxSize(FromDIP(74), -1)); - m_st_txt_extra_info->SetMinSize(wxSize(FromDIP(260), -1)); - m_st_txt_extra_info->SetMaxSize(wxSize(FromDIP(260), -1)); + m_st_txt_extra_info->SetMinSize(wxSize(FromDIP(500), -1)); + m_st_txt_extra_info->SetMaxSize(wxSize(FromDIP(500), -1)); sizer_extra_info->Add(st_title_extra_info, 0, wxALL, 0); sizer_extra_info->Add(st_title_extra_info_doc, 0, wxALL, 0); sizer_extra_info->Add(m_st_txt_extra_info, 0, wxALL, 0); @@ -816,8 +821,9 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) m_sizer_main->Add(sizer_advanced_options_title, 1, wxEXPAND|wxLEFT|wxRIGHT, FromDIP(15)); m_sizer_main->Add(m_sizer_options_timelapse, 0, wxEXPAND|wxLEFT|wxRIGHT, FromDIP(15)); m_sizer_main->Add(m_options_other, 0, wxEXPAND|wxLEFT|wxRIGHT, FromDIP(15)); + m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(30)); + m_sizer_main->Add(m_simplebook, 0, wxALIGN_CENTER, 0); m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(10)); - m_sizer_main->Add(m_simplebook, 0, wxALIGN_CENTER_HORIZONTAL, 0); m_sizer_main->Add(m_sw_print_failed_info, 0, wxALIGN_CENTER, 0); m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(18)); @@ -899,9 +905,9 @@ void SelectMachineDialog::show_print_failed_info(bool show, int code, wxString d m_st_txt_error_desc->SetLabelText( wxGetApp().filter_string(m_print_error_msg)); m_st_txt_extra_info->SetLabelText( wxGetApp().filter_string(m_print_error_extra)); - m_st_txt_error_code->Wrap(FromDIP(260)); - m_st_txt_error_desc->Wrap(FromDIP(260)); - m_st_txt_extra_info->Wrap(FromDIP(260)); + m_st_txt_error_code->Wrap(FromDIP(500)); + m_st_txt_error_desc->Wrap(FromDIP(500)); + m_st_txt_extra_info->Wrap(FromDIP(500)); } else { m_sw_print_failed_info->Show(false); @@ -3534,8 +3540,8 @@ void SelectMachineDialog::on_dpi_changed(const wxRect &suggested_rect) ams_mapping_help_icon->msw_rescale(); if (img_amsmapping_tip)img_amsmapping_tip->SetBitmap(ams_mapping_help_icon->bmp()); } - m_button_ensure->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE); - m_button_ensure->SetCornerRadius(FromDIP(12)); + m_button_ensure->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE2); + m_button_ensure->SetCornerRadius(FromDIP(4)); m_status_bar->msw_rescale(); for (auto material1 : m_materialList) { diff --git a/src/slic3r/GUI/SelectMachine.hpp b/src/slic3r/GUI/SelectMachine.hpp index 29fcbc4ba..0aca7357e 100644 --- a/src/slic3r/GUI/SelectMachine.hpp +++ b/src/slic3r/GUI/SelectMachine.hpp @@ -32,7 +32,7 @@ #include "DeviceManager.hpp" #include "Plater.hpp" #include "BBLStatusBar.hpp" -#include "BBLStatusBarSend.hpp" +#include "BBLStatusBarPrint.hpp" #include "Widgets/Label.hpp" #include "Widgets/Button.hpp" #include "Widgets/CheckBox.hpp" @@ -134,7 +134,9 @@ enum class ConfigNozzleIdx : int WX_DECLARE_HASH_MAP(int, Material *, wxIntegerHash, wxIntegerEqual, MaterialHash); #define SELECT_MACHINE_DIALOG_BUTTON_SIZE wxSize(FromDIP(57), FromDIP(32)) +#define SELECT_MACHINE_DIALOG_BUTTON_SIZE2 wxSize(FromDIP(80), FromDIP(32)) #define SELECT_MACHINE_DIALOG_SIMBOOK_SIZE wxSize(FromDIP(370), FromDIP(64)) +#define SELECT_MACHINE_DIALOG_SIMBOOK_SIZE2 wxSize(FromDIP(645), FromDIP(32)) #define LIST_REFRESH_INTERVAL 200 static int get_brightness_value(wxImage image) { @@ -295,7 +297,7 @@ private: std::vector m_filaments; std::vector m_ams_mapping_result; std::vector m_filaments_map; - std::shared_ptr m_status_bar; + std::shared_ptr m_status_bar; //SendModeSwitchButton* m_mode_print {nullptr}; //SendModeSwitchButton* m_mode_send {nullptr}; diff --git a/src/slic3r/GUI/SendToPrinter.cpp b/src/slic3r/GUI/SendToPrinter.cpp index f1cb0283d..b497110ae 100644 --- a/src/slic3r/GUI/SendToPrinter.cpp +++ b/src/slic3r/GUI/SendToPrinter.cpp @@ -302,7 +302,7 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater) m_button_ensure->SetTextColor(StateColor::darkModeColorFor("#FFFFFE")); m_button_ensure->SetSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE); m_button_ensure->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE); - m_button_ensure->SetCornerRadius(FromDIP(12)); + m_button_ensure->SetCornerRadius(6); m_button_ensure->Bind(wxEVT_BUTTON, &SendToPrinterDialog::on_ok, this); m_sizer_pcont->Add(m_button_ensure, 0, wxEXPAND | wxBOTTOM, FromDIP(10)); @@ -423,7 +423,7 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater) sizer_print_failed_info->Add(sizer_extra_info, 0, wxLEFT, 5); // bind - Bind(EVT_SHOW_ERROR_INFO, [this](auto& e) { + Bind(EVT_SHOW_ERROR_INFO_SEND, [this](auto& e) { show_print_failed_info(true); });