From d54425a901a8f04d9253ea630219f537765ad4ac Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 3 Apr 2018 22:07:59 +0200 Subject: [PATCH] Added show/hide of "Purging volumes" button depending on a state of "wipe_tower" --- xs/src/slic3r/GUI/GUI.cpp | 11 ++++++++--- xs/src/slic3r/GUI/GUI.hpp | 2 ++ xs/src/slic3r/GUI/OptionsGroup.cpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 6 +++++- xs/src/slic3r/GUI/WipeTowerDialog.cpp | 12 ++++++------ 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 3c8504756..933a1ce0e 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -182,6 +182,7 @@ wxLocale* g_wxLocale; std::shared_ptr m_optgroup; double m_brim_width = 0.0; +wxButton* g_wiping_dialog_button = nullptr; void set_wxapp(wxApp *app) { @@ -682,10 +683,10 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl Line line = { _(L("")), "" }; line.widget = [config](wxWindow* parent){ - auto wiping_dialog_button = new wxButton(parent, wxID_ANY, _(L("Purging volumes"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT); + g_wiping_dialog_button = new wxButton(parent, wxID_ANY, _(L("Purging volumes")) + "\u2026", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); auto sizer = new wxBoxSizer(wxHORIZONTAL); - sizer->Add(wiping_dialog_button); - wiping_dialog_button->Bind(wxEVT_BUTTON, ([config, parent](wxCommandEvent& e) + sizer->Add(g_wiping_dialog_button); + g_wiping_dialog_button->Bind(wxEVT_BUTTON, ([config, parent](wxCommandEvent& e) { std::vector init_matrix = (config->option("wiping_volumes_matrix"))->values; std::vector init_extruders = (config->option("wiping_volumes_extruders"))->values; @@ -713,4 +714,8 @@ ConfigOptionsGroup* get_optgroup() return m_optgroup.get(); } +wxButton* get_wiping_dialog_button(){ + return g_wiping_dialog_button; +} + } } diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 084b6de46..7561d256d 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -18,6 +18,7 @@ class wxArrayLong; class wxColour; class wxBoxSizer; class wxFlexGridSizer; +class wxButton; namespace Slic3r { @@ -129,6 +130,7 @@ wxString from_u8(const std::string &str); void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer); ConfigOptionsGroup* get_optgroup(); +wxButton* get_wiping_dialog_button(); } } diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 0be24824c..0f165e2d3 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -137,7 +137,7 @@ void OptionsGroup::append_line(const Line& line) { // If there's a widget, build it and add the result to the sizer. if (line.widget != nullptr) { auto wgt = line.widget(parent()); - grid_sizer->Add(wgt, 0, wxEXPAND | wxBOTTOM | wxTOP, wxOSX ? 0 : 5); + grid_sizer->Add(wgt, 0, wxEXPAND | wxBOTTOM | wxTOP, wxOSX ? 0 : 1); return; } diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 50de384de..1d92439f9 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -335,7 +335,11 @@ void Tab::on_value_change(std::string opt_key, boost::any value) bool val = m_config->opt_float("brim_width") > 0.0 ? true : false; get_optgroup()->set_value("brim", val); } - + if (opt_key == "wipe_tower"){ + m_config->opt_bool("wipe_tower") ? + get_wiping_dialog_button()->Show() : + get_wiping_dialog_button()->Hide(); + } update(); } diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index df0552299..421ae272d 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -30,11 +30,11 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) EndModal(wxID_OK); },wxID_OK); this->Show(); - wxMessageDialog(this,L("Ramming denotes the rapid extrusion just before a tool change in a single-extruder MM printer. Its purpose is to " + wxMessageDialog(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 " "the good shape. For this reason, the extrusion rates during ramming are adjustable.\n\nThis is an expert-level " - "setting, incorrect adjustment will likely lead to jams, extruder wheel grinding into filament etc."),L("Warning"),wxOK|wxICON_EXCLAMATION).ShowModal(); + "setting, incorrect adjustment will likely lead to jams, extruder wheel grinding into filament etc.")),_(L("Warning")),wxOK|wxICON_EXCLAMATION).ShowModal(); } @@ -249,7 +249,7 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, con m_page_advanced->Bind(wxEVT_PAINT,[this](wxPaintEvent&) { wxPaintDC dc(m_page_advanced); int y_pos = 0.5 * (edit_boxes[0][0]->GetPosition().y + edit_boxes[0][edit_boxes.size()-1]->GetPosition().y + edit_boxes[0][edit_boxes.size()-1]->GetSize().y); - wxString label = L("From"); + wxString label = _(L("From")); int text_width = 0; int text_height = 0; dc.GetTextExtent(label,&text_width,&text_height); @@ -314,8 +314,8 @@ bool WipingPanel::advanced_matches_simple() { // Switches the dialog from simple to advanced mode and vice versa void WipingPanel::toggle_advanced(bool user_action) { if (m_advanced && !advanced_matches_simple() && user_action) { - if (wxMessageDialog(this,wxString(L("Switching to simple settings will discard changes done in the advanced mode!\n\nDo you want to proceed?")), - wxString(L("Warning")),wxYES_NO|wxICON_EXCLAMATION).ShowModal() != wxID_YES) + if (wxMessageDialog(this,wxString(_(L("Switching to simple settings will discard changes done in the advanced mode!\n\nDo you want to proceed?"))), + wxString(_(L("Warning"))),wxYES_NO|wxICON_EXCLAMATION).ShowModal() != wxID_YES) return; } if (user_action) @@ -326,7 +326,7 @@ void WipingPanel::toggle_advanced(bool user_action) { (m_advanced ? m_page_advanced : m_page_simple)->Show(); (!m_advanced ? m_page_advanced : m_page_simple)->Hide(); - m_widget_button->SetLabel(m_advanced ? L("Show simplified settings") : L("Show advanced settings")); + m_widget_button->SetLabel(m_advanced ? _(L("Show simplified settings")) : _(L("Show advanced settings"))); if (m_advanced) if (user_action) fill_in_matrix(); // otherwise keep values loaded from config