diff --git a/src/slic3r/GUI/RammingChart.cpp b/src/slic3r/GUI/RammingChart.cpp index 5bf75bbc747..265c4aa4e0b 100644 --- a/src/slic3r/GUI/RammingChart.cpp +++ b/src/slic3r/GUI/RammingChart.cpp @@ -14,20 +14,22 @@ wxDEFINE_EVENT(EVT_WIPE_TOWER_CHART_CHANGED, wxCommandEvent); void Chart::draw() { wxAutoBufferedPaintDC dc(this); // unbuffered DC caused flickering on win + // scaling button and tick line from text size gives better result compared to dc.GetContentScale + int text_width, text_height; + dc.GetTextExtent("m",&text_width,&text_height); + side = text_width; + int tick_w = text_width / 2; + dc.SetBrush(GetBackgroundColour()); dc.SetPen(GetBackgroundColour()); dc.DrawRectangle(GetClientRect()); // otherwise the background would end up black on windows -#ifdef _WIN32 - dc.SetPen(wxPen(GetForegroundColour())); - dc.SetBrush(wxBrush(Slic3r::GUI::wxGetApp().get_highlight_default_clr())); -#else - dc.SetPen(*wxBLACK_PEN); - dc.SetBrush(*wxWHITE_BRUSH); -#endif + dc.SetPen( wxPen(StateColor::darkModeColorFor(wxColour("#DBDBDB")), 1)); // input box border color + dc.SetBrush(wxBrush(StateColor::darkModeColorFor(wxColour("#F1F1F1")))); // sidebar titlebar bg color dc.DrawRectangle(m_rect); if (visible_area.m_width < 0.499) { + dc.SetTextForeground(StateColor::darkModeColorFor(wxColour("#FF6F00"))); // Use orange color for warning dc.DrawText(_(L("NO RAMMING AT ALL")),wxPoint(m_rect.GetLeft()+m_rect.GetWidth()/2-legend_side,m_rect.GetBottom()-m_rect.GetHeight()/2)); return; } @@ -35,15 +37,11 @@ void Chart::draw() { if (!m_line_to_draw.empty()) { for (unsigned int i=0;iDisableFocusFromKeyboard(); btn->Bind(wxEVT_LEFT_DOWN, [=](auto &e) { delta = inc ? 1 : -1; - SetValue(val + delta); + SetValue(val + delta * step); text_ctrl->SetFocus(); if (!btn->HasCapture()) btn->CaptureMouse(); @@ -241,7 +242,7 @@ Button *SpinInput::createButton(bool inc) delta = inc ? 1 : -1; if (!btn->HasCapture()) btn->CaptureMouse(); - SetValue(val + delta); + SetValue(val + delta * step); sendSpinEvent(); }); btn->Bind(wxEVT_LEFT_UP, [=](auto &e) { @@ -259,7 +260,7 @@ void SpinInput::onTimer(wxTimerEvent &evnet) { delta /= 2; return; } - SetValue(val + delta); + SetValue(val + delta * step); sendSpinEvent(); } @@ -293,7 +294,7 @@ void SpinInput::onTextEnter(wxCommandEvent &event) void SpinInput::mouseWheelMoved(wxMouseEvent &event) { auto delta = event.GetWheelRotation() < 0 ? 1 : -1; - SetValue(val + delta); + SetValue(val + delta * step); sendSpinEvent(); text_ctrl->SetFocus(); } @@ -305,10 +306,10 @@ void SpinInput::keyPressed(wxKeyEvent &event) case WXK_DOWN: long value; if (!text_ctrl->GetValue().ToLong(&value)) { value = val; } - if (event.GetKeyCode() == WXK_DOWN && value > min) { - --value; - } else if (event.GetKeyCode() == WXK_UP && value + 1 < max) { - ++value; + if (event.GetKeyCode() == WXK_DOWN && value - step >= min) { + value = value - step; + } else if (event.GetKeyCode() == WXK_UP && value + step <= max) { + value = value + step; } if (value != val) { SetValue(value); diff --git a/src/slic3r/GUI/Widgets/SpinInput.hpp b/src/slic3r/GUI/Widgets/SpinInput.hpp index cc342276f9a..030eb569423 100644 --- a/src/slic3r/GUI/Widgets/SpinInput.hpp +++ b/src/slic3r/GUI/Widgets/SpinInput.hpp @@ -23,6 +23,7 @@ class SpinInput : public wxNavigationEnabled int min; int max; int delta; + int step; static const int SpinInputWidth = 200; static const int SpinInputHeight = 50; @@ -36,7 +37,7 @@ class SpinInput : public wxNavigationEnabled const wxPoint &pos = wxDefaultPosition, const wxSize & size = wxDefaultSize, long style = 0, - int min = 0, int max = 100, int initial = 0); + int min = 0, int max = 100, int initial = 0, const int& step = 1); void Create(wxWindow * parent, wxString text, @@ -46,7 +47,8 @@ class SpinInput : public wxNavigationEnabled long style = 0, int min = 0, int max = 100, - int initial = 0); + int initial = 0, + int step = 1); void SetCornerRadius(double radius); @@ -70,6 +72,10 @@ class SpinInput : public wxNavigationEnabled int GetValue () const; + void SetStep(int value) { step = value; }; + + int GetStep() { return step; }; + void SetRange(int min, int max); protected: diff --git a/src/slic3r/GUI/WipeTowerDialog.cpp b/src/slic3r/GUI/WipeTowerDialog.cpp index babad123d67..de93b3c5ac2 100644 --- a/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/src/slic3r/GUI/WipeTowerDialog.cpp @@ -9,6 +9,7 @@ #include "MsgDialog.hpp" #include "libslic3r/Color.hpp" #include "Widgets/Button.hpp" +#include "Widgets/StaticLine.hpp" #include "Widgets/DialogButtons.hpp" #include "slic3r/Utils/ColorSpaceConvert.hpp" #include "MainFrame.hpp" @@ -49,37 +50,27 @@ static void update_ui(wxWindow* window) RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) : wxDialog(parent, wxID_ANY, _(L("Ramming customization")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE/* | wxRESIZE_BORDER*/) { - update_ui(this); + SetBackgroundColour(*wxWHITE); m_panel_ramming = new RammingPanel(this,parameters); - - // Not found another way of getting the background colours of RammingDialog, RammingPanel and Chart correct than setting - // them all explicitely. Reading the parent colour yielded colour that didn't really match it, no wxSYS_COLOUR_... matched - // colour used for the dialog. Same issue (and "solution") here : https://forums.wxwidgets.org/viewtopic.php?f=1&t=39608 - // Whoever can fix this, feel free to do so. -#ifndef _WIN32 - this-> SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_FRAMEBK)); - m_panel_ramming->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_FRAMEBK)); -#endif m_panel_ramming->Show(true); - this->Show(); auto main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer->Add(m_panel_ramming, 1, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5); - main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxTOP | wxBOTTOM, 10); + auto dlg_btns = new DialogButtons(this, {"OK", "Cancel"}); + main_sizer->Add(dlg_btns, 0, wxEXPAND); SetSizer(main_sizer); main_sizer->SetSizeHints(this); - update_ui(static_cast(this->FindWindowById(wxID_OK, this))); - update_ui(static_cast(this->FindWindowById(wxID_CANCEL, this))); - this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); }); this->Bind(wxEVT_BUTTON,[this](wxCommandEvent&) { m_output_data = m_panel_ramming->get_parameters(); EndModal(wxID_OK); },wxID_OK); + + wxGetApp().UpdateDlgDarkUI(this); this->Show(); -// wxMessageDialog dlg(this, _(L("Ramming denotes the rapid extrusion just before a tool change in a single-extruder MM printer. Its purpose is to " + Slic3r::GUI::MessageDialog dlg(this, _(L("Ramming denotes the rapid extrusion just before a tool change in a single-extruder MM printer. Its purpose is to " "properly shape the end of the unloaded filament so it does not prevent insertion of the new filament and can itself " "be reinserted later. This phase is important and different materials can require different extrusion speeds to get " @@ -100,6 +91,7 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters) : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize/*,wxPoint(50,50), wxSize(800,350),wxBORDER_RAISED*/) { + SetBackgroundColour(*wxWHITE); update_ui(this); auto sizer_chart = new wxBoxSizer(wxVERTICAL); auto sizer_param = new wxBoxSizer(wxVERTICAL); @@ -120,48 +112,59 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters) buttons.push_back(std::make_pair(x, y)); m_chart = new Chart(this, wxRect(scale(10),scale(10),scale(480),scale(360)), buttons, ramming_speed_size, 0.25f, scale(10)); -#ifdef _WIN32 update_ui(m_chart); -#else - m_chart->SetBackgroundColour(parent->GetBackgroundColour()); // see comment in RammingDialog constructor -#endif sizer_chart->Add(m_chart, 0, wxALL, 5); - m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,0.,5.0,3.,0.5); - m_widget_volume = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,0,10000,0); - m_widget_ramming_line_width_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,10,200,100); - m_widget_ramming_step_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,10,200,100); + m_widget_time = new SpinInput(this, wxEmptyString, _L("ms") , wxDefaultPosition, wxSize(scale(120), -1), wxSP_ARROW_KEYS, 0 , 5000 , 3000, 500); + m_widget_volume = new SpinInput(this, wxEmptyString, _L("mm³"), wxDefaultPosition, wxSize(scale(120), -1), wxSP_ARROW_KEYS, 0 , 10000, 0 ); + m_widget_ramming_line_width_multiplicator = new SpinInput(this, wxEmptyString, _L("%") , wxDefaultPosition, wxSize(scale(120), -1), wxSP_ARROW_KEYS, 10, 200 , 100 ); + m_widget_ramming_step_multiplicator = new SpinInput(this, wxEmptyString, _L("%") , wxDefaultPosition, wxSize(scale(120), -1), wxSP_ARROW_KEYS, 10, 200 , 100 ); -#ifdef _WIN32 - update_ui(m_widget_time->GetText()); - update_ui(m_widget_volume); - update_ui(m_widget_ramming_line_width_multiplicator); - update_ui(m_widget_ramming_step_multiplicator); -#endif + auto add_title = [this, sizer_param](wxString label){ + auto title = new StaticLine(this, 0, label); + title->SetFont(Label::Head_14); + title->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#363636"))); + sizer_param->Add(title, 0, wxEXPAND | wxBOTTOM, scale(8)); + }; + + SetFont(Label::Body_14); + wxSize col_size; + for(auto label : {"Time", "Volume", "Width", "Spacing"}) + col_size.IncTo(GetTextExtent(_L(label))); + col_size = wxSize(col_size.x + scale(30) ,-1); + + auto add_spin = [this, sizer_param, col_size](wxString label, SpinInput* spin){ + spin->Bind(wxEVT_KILL_FOCUS, [this](auto &e) { + e.SetId(GetId()); + ProcessEventLocally(e); + e.Skip(); + }); + auto h_sizer = new wxBoxSizer(wxHORIZONTAL); + auto text = new wxStaticText(this, wxID_ANY, label, wxDefaultPosition, col_size); + text->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#363636"))); + h_sizer->Add(text, 0, wxALIGN_CENTER_VERTICAL); + h_sizer->Add(spin); + sizer_param->Add(h_sizer, 0, wxEXPAND | wxBOTTOM, scale(2)); + }; - auto gsizer_param = new wxFlexGridSizer(2, 5, 15); - gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Total ramming time")) + " (" + _(L("s")) + "):")), 0, wxALIGN_CENTER_VERTICAL); - gsizer_param->Add(m_widget_time); - gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Total rammed volume")) + " (" + _(L("mm")) + wxString("³):", wxConvUTF8))), 0, wxALIGN_CENTER_VERTICAL); - gsizer_param->Add(m_widget_volume); - gsizer_param->AddSpacer(20); - gsizer_param->AddSpacer(20); - gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Ramming line width")) + " (%):")), 0, wxALIGN_CENTER_VERTICAL); - gsizer_param->Add(m_widget_ramming_line_width_multiplicator); - gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Ramming line spacing")) + " (%):")), 0, wxALIGN_CENTER_VERTICAL); - gsizer_param->Add(m_widget_ramming_step_multiplicator); - - sizer_param->Add(gsizer_param, 0, wxTOP, scale(10)); - - m_widget_time->SetValue(m_chart->get_time()); - m_widget_time->SetDigits(2); + add_title(_L("Total ramming")); + add_spin( _L("Time") , m_widget_time ); + add_spin( _L("Volume"), m_widget_volume); + + sizer_param->AddSpacer(10); + + add_title(_L("Ramming line")); + add_spin( _L("Width") , m_widget_ramming_line_width_multiplicator); + add_spin( _L("Spacing"), m_widget_ramming_step_multiplicator ); + + m_widget_time->SetValue(int(m_chart->get_time() * 1000)); m_widget_volume->SetValue(m_chart->get_volume()); m_widget_volume->Disable(); m_widget_ramming_line_width_multiplicator->SetValue(m_ramming_line_width_multiplicator); - m_widget_ramming_step_multiplicator->SetValue(m_ramming_step_multiplicator); - - m_widget_ramming_step_multiplicator->Bind(wxEVT_TEXT,[this](wxCommandEvent&) { line_parameters_changed(); }); - m_widget_ramming_line_width_multiplicator->Bind(wxEVT_TEXT,[this](wxCommandEvent&) { line_parameters_changed(); }); + m_widget_ramming_step_multiplicator->SetValue(m_ramming_step_multiplicator); + + m_widget_ramming_step_multiplicator->Bind(wxEVT_SPINCTRL,[this](wxCommandEvent&) { line_parameters_changed(); }); + m_widget_ramming_line_width_multiplicator->Bind(wxEVT_SPINCTRL,[this](wxCommandEvent&) { line_parameters_changed(); }); auto sizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(sizer_chart, 0, wxALL, 5); @@ -170,10 +173,15 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters) sizer->SetSizeHints(this); SetSizer(sizer); - m_widget_time->Bind(wxEVT_TEXT,[this](wxCommandEvent&) {m_chart->set_xy_range(m_widget_time->GetValue(),-1);}); + m_widget_time->Bind(wxEVT_SPINCTRL,[this](wxCommandEvent&) { + m_chart->set_xy_range(m_widget_time->GetValue() * 0.001,-1); + }); m_widget_time->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value m_widget_volume->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value - Bind(EVT_WIPE_TOWER_CHART_CHANGED,[this](wxCommandEvent&) {m_widget_volume->SetValue(m_chart->get_volume()); m_widget_time->SetValue(m_chart->get_time());} ); + Bind(EVT_WIPE_TOWER_CHART_CHANGED,[this](wxCommandEvent&) { + m_widget_volume->SetValue(m_chart->get_volume()); + m_widget_time->SetValue(m_chart->get_time() * 1000); + }); Refresh(true); // erase background } @@ -340,7 +348,7 @@ void WipingDialog::on_dpi_changed(const wxRect &suggested_rect) // Parent dialog for purging volume adjustments - it fathers WipingPanel widget (that contains all controls) and a button to toggle simple/advanced mode: WipingDialog::WipingDialog(wxWindow* parent, const std::vector& matrix, const std::vector& extruders, const std::vector& extruder_colours, const std::vector&extra_flush_volume, float flush_multiplier) - : DPIDialog(parent ? parent : static_cast(wxGetApp().mainframe), + : GUI::DPIDialog(parent ? parent : static_cast(wxGetApp().mainframe), wxID_ANY, _(L("Flushing volumes for filament change")), wxDefaultPosition, diff --git a/src/slic3r/GUI/WipeTowerDialog.hpp b/src/slic3r/GUI/WipeTowerDialog.hpp index 4a1abfaad27..31ffe2f0808 100644 --- a/src/slic3r/GUI/WipeTowerDialog.hpp +++ b/src/slic3r/GUI/WipeTowerDialog.hpp @@ -10,6 +10,8 @@ #include #include +#include "Widgets/SpinInput.hpp" + #include "RammingChart.hpp" class Button; class Label; @@ -23,10 +25,10 @@ class RammingPanel : public wxPanel { private: Chart* m_chart = nullptr; - wxSpinCtrl* m_widget_volume = nullptr; - wxSpinCtrl* m_widget_ramming_line_width_multiplicator = nullptr; - wxSpinCtrl* m_widget_ramming_step_multiplicator = nullptr; - wxSpinCtrlDouble* m_widget_time = nullptr; + SpinInput* m_widget_volume = nullptr; + SpinInput* m_widget_ramming_line_width_multiplicator = nullptr; + SpinInput* m_widget_ramming_step_multiplicator = nullptr; + SpinInput* m_widget_time = nullptr; int m_ramming_step_multiplicator; int m_ramming_line_width_multiplicator;