ENH: [STUDIO-1398] UI optimization for flushing amount setting window

Change-Id: I40f7a589b4a9dac0022c588e71aaa13d10c5e4d8
This commit is contained in:
maosheng.wei 2023-05-25 11:53:44 +08:00 committed by Lane.Wei
parent 12a66c5c70
commit c1010e5d0e
2 changed files with 36 additions and 2 deletions

View File

@ -8,6 +8,7 @@
#include "MsgDialog.hpp" #include "MsgDialog.hpp"
#include "Widgets/Button.hpp" #include "Widgets/Button.hpp"
#include "slic3r/Utils/ColorSpaceConvert.hpp" #include "slic3r/Utils/ColorSpaceConvert.hpp"
#include "MainFrame.hpp"
#include <wx/sizer.h> #include <wx/sizer.h>
@ -108,6 +109,7 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
calc_btn->SetFocus(); calc_btn->SetFocus();
calc_btn->SetId(wxID_RESET); calc_btn->SetId(wxID_RESET);
btn_sizer->Add(calc_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP); btn_sizer->Add(calc_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
m_button_list[wxRESET] = calc_btn;
} }
if (flags & wxOK) { if (flags & wxOK) {
Button* ok_btn = new Button(this, _L("OK")); Button* ok_btn = new Button(this, _L("OK"));
@ -119,6 +121,7 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
ok_btn->SetFocus(); ok_btn->SetFocus();
ok_btn->SetId(wxID_OK); ok_btn->SetId(wxID_OK);
btn_sizer->Add(ok_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP); btn_sizer->Add(ok_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
m_button_list[wxOK] = ok_btn;
} }
if (flags & wxCANCEL) { if (flags & wxCANCEL) {
Button* cancel_btn = new Button(this, _L("Cancel")); Button* cancel_btn = new Button(this, _L("Cancel"));
@ -129,16 +132,41 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
cancel_btn->SetTextColor(cancel_btn_text); cancel_btn->SetTextColor(cancel_btn_text);
cancel_btn->SetId(wxID_CANCEL); cancel_btn->SetId(wxID_CANCEL);
btn_sizer->Add(cancel_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP); btn_sizer->Add(cancel_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
m_button_list[wxCANCEL] = cancel_btn;
} }
return btn_sizer; return btn_sizer;
}
void WipingDialog::on_dpi_changed(const wxRect &suggested_rect)
{
for (auto button_item : m_button_list)
{
if (button_item.first == wxRESET)
{
button_item.second->SetMinSize(wxSize(FromDIP(75), FromDIP(24)));
button_item.second->SetCornerRadius(FromDIP(12));
}
if (button_item.first == wxOK) {
button_item.second->SetMinSize(BTN_SIZE);
button_item.second->SetCornerRadius(FromDIP(12));
}
if (button_item.first == wxCANCEL) {
button_item.second->SetMinSize(BTN_SIZE);
button_item.second->SetCornerRadius(FromDIP(12));
}
}
}; };
// Parent dialog for purging volume adjustments - it fathers WipingPanel widget (that contains all controls) and a button to toggle simple/advanced mode: // 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<float>& matrix, const std::vector<float>& extruders, const std::vector<std::string>& extruder_colours, WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, const std::vector<float>& extruders, const std::vector<std::string>& extruder_colours,
int extra_flush_volume, float flush_multiplier) int extra_flush_volume, float flush_multiplier)
: wxDialog(parent, wxID_ANY, _(L("Flushing volumes for filament change")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE/* | wxRESIZE_BORDER*/) : DPIDialog(parent ? parent : static_cast<wxWindow *>(wxGetApp().mainframe),
wxID_ANY,
_(L("Flushing volumes for filament change")),
wxDefaultPosition,
wxDefaultSize,
wxDEFAULT_DIALOG_STYLE /* | wxRESIZE_BORDER*/)
{ {
this->SetBackgroundColour(*wxWHITE); this->SetBackgroundColour(*wxWHITE);
this->SetMinSize(wxSize(MIN_WIPING_DIALOG_WIDTH, -1)); this->SetMinSize(wxSize(MIN_WIPING_DIALOG_WIDTH, -1));

View File

@ -1,6 +1,8 @@
#ifndef _WIPE_TOWER_DIALOG_H_ #ifndef _WIPE_TOWER_DIALOG_H_
#define _WIPE_TOWER_DIALOG_H_ #define _WIPE_TOWER_DIALOG_H_
#include "GUI_Utils.hpp"
#include <wx/spinctrl.h> #include <wx/spinctrl.h>
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
@ -62,7 +64,8 @@ private:
class WipingDialog : public wxDialog { class WipingDialog : public Slic3r::GUI::DPIDialog
{
public: public:
WipingDialog(wxWindow* parent, const std::vector<float>& matrix, const std::vector<float>& extruders, const std::vector<std::string>& extruder_colours, WipingDialog(wxWindow* parent, const std::vector<float>& matrix, const std::vector<float>& extruders, const std::vector<std::string>& extruder_colours,
int extra_flush_volume, float flush_multiplier); int extra_flush_volume, float flush_multiplier);
@ -79,10 +82,13 @@ public:
return m_panel_wiping->get_flush_multiplier(); return m_panel_wiping->get_flush_multiplier();
} }
void on_dpi_changed(const wxRect &suggested_rect) override;
private: private:
WipingPanel* m_panel_wiping = nullptr; WipingPanel* m_panel_wiping = nullptr;
std::vector<float> m_output_matrix; std::vector<float> m_output_matrix;
std::vector<float> m_output_extruders; std::vector<float> m_output_extruders;
std::unordered_map<int, Button *> m_button_list;
}; };
#endif // _WIPE_TOWER_DIALOG_H_ #endif // _WIPE_TOWER_DIALOG_H_