ENH: update send print dialog options GUI style
jira: [STUDIO-11444] Change-Id: I16f6e93edf09dc84786a0f7e6a14c9d0734542b8
This commit is contained in:
parent
64e7c5ac46
commit
6e9f2ecb5b
|
@ -618,7 +618,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
|
||||||
|
|
||||||
option_use_ams->setValue("on");
|
option_use_ams->setValue("on");
|
||||||
|
|
||||||
m_sizer_options = new wxGridSizer(0, 2, FromDIP(5), FromDIP(40));
|
m_sizer_options = new wxGridSizer(0, 2, FromDIP(5), FromDIP(28));
|
||||||
m_sizer_options->Add(option_timelapse, 0, wxEXPAND);
|
m_sizer_options->Add(option_timelapse, 0, wxEXPAND);
|
||||||
m_sizer_options->Add(option_use_ams, 0, wxEXPAND);
|
m_sizer_options->Add(option_use_ams, 0, wxEXPAND);
|
||||||
m_sizer_options->Add(option_auto_bed_level, 0, wxEXPAND);
|
m_sizer_options->Add(option_auto_bed_level, 0, wxEXPAND);
|
||||||
|
@ -4833,26 +4833,26 @@ std::string SelectMachineDialog::get_print_status_info(PrintDialogStatus status)
|
||||||
#endif //__WINDOWS__
|
#endif //__WINDOWS__
|
||||||
Bind(wxEVT_PAINT, &PrintOption::OnPaint, this);
|
Bind(wxEVT_PAINT, &PrintOption::OnPaint, this);
|
||||||
|
|
||||||
SetMinSize(wxSize(-1, FromDIP(60)));
|
SetMinSize(wxSize(-1, FromDIP(28)));
|
||||||
SetMaxSize(wxSize(-1, FromDIP(60)));
|
SetMaxSize(wxSize(-1, FromDIP(28)));
|
||||||
|
|
||||||
m_ops = ops;
|
m_ops = ops;
|
||||||
m_param = param;
|
m_param = param;
|
||||||
|
|
||||||
SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
|
SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
|
||||||
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
m_printoption_title = new Label(this, title);
|
m_printoption_title = new Label(this, title);
|
||||||
m_printoption_title->SetFont(Label::Body_13);
|
m_printoption_title->SetFont(Label::Head_13);
|
||||||
//m_printoption_title->SetBackgroundColour(0xF8F8F8);
|
//m_printoption_title->SetBackgroundColour(0xF8F8F8);
|
||||||
m_printoption_title->SetToolTip(tips);
|
m_printoption_title->SetToolTip(tips);
|
||||||
|
|
||||||
m_printoption_item = new PrintOptionItem(this, m_ops, param);
|
m_printoption_item = new PrintOptionItem(this, m_ops, param);
|
||||||
m_printoption_item->SetToolTip(tips);
|
m_printoption_item->SetFont(Label::Body_13);
|
||||||
|
|
||||||
sizer->Add(m_printoption_title, 0, wxALIGN_LEFT, 0);
|
sizer->Add(m_printoption_title, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 0);
|
||||||
sizer->AddSpacer(FromDIP(5));
|
sizer->AddStretchSpacer();
|
||||||
sizer->Add(m_printoption_item, 0, wxALIGN_LEFT, 0);
|
sizer->Add(m_printoption_item, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 0);
|
||||||
|
|
||||||
SetSizer(sizer);
|
SetSizer(sizer);
|
||||||
Layout();
|
Layout();
|
||||||
|
@ -4913,16 +4913,18 @@ bool PrintOption::contain_opt(const std::string &opt) const
|
||||||
|
|
||||||
void PrintOption::update_options(std::vector<POItem> ops, const wxString &tips)
|
void PrintOption::update_options(std::vector<POItem> ops, const wxString &tips)
|
||||||
{
|
{
|
||||||
m_ops = ops;
|
if (m_ops != ops)
|
||||||
m_printoption_item->update_options(ops);
|
{
|
||||||
|
m_ops = ops;
|
||||||
|
m_printoption_item->update_options(ops);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_printoption_title->GetToolTipText() != tips) { m_printoption_title->SetToolTip(tips); }
|
if (m_printoption_title->GetToolTipText() != tips) { m_printoption_title->SetToolTip(tips); }
|
||||||
if (m_printoption_item->GetToolTipText() != tips) { m_printoption_item->SetToolTip(tips); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintOption::update_tooltip(const wxString &tips) {
|
void PrintOption::update_tooltip(const wxString &tips)
|
||||||
|
{
|
||||||
if (m_printoption_title->GetToolTipText() != tips) { m_printoption_title->SetToolTip(tips); }
|
if (m_printoption_title->GetToolTipText() != tips) { m_printoption_title->SetToolTip(tips); }
|
||||||
if (m_printoption_item->GetToolTipText() != tips) { m_printoption_item->SetToolTip(tips); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PrintOption::getValue()
|
std::string PrintOption::getValue()
|
||||||
|
@ -4944,161 +4946,70 @@ int PrintOption::getValueInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintOptionItem::PrintOptionItem(wxWindow *parent, std::vector<POItem> ops, std::string param)
|
PrintOptionItem::PrintOptionItem(wxWindow *parent, std::vector<POItem> ops, std::string param)
|
||||||
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
|
: ComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(parent->FromDIP(70), parent->FromDIP(24)), 0, nullptr, wxCB_READONLY)
|
||||||
{
|
{
|
||||||
#ifdef __WINDOWS__
|
Bind(wxEVT_COMBOBOX, &PrintOptionItem::on_combobox_changed, this);
|
||||||
SetDoubleBuffered(true);
|
|
||||||
#endif //__WINDOWS__
|
|
||||||
|
|
||||||
m_ops = ops;
|
|
||||||
m_param = param;
|
m_param = param;
|
||||||
SetBackgroundColour(PRINT_OPT_ITEM_BG_GRAY);
|
update_options(ops);
|
||||||
|
|
||||||
Bind(wxEVT_PAINT, &PrintOptionItem::OnPaint, this);
|
|
||||||
auto width = ops.size() * FromDIP(56) + FromDIP(8);
|
|
||||||
auto height = FromDIP(22) + FromDIP(8);
|
|
||||||
SetMinSize(wxSize(width, height));
|
|
||||||
SetMaxSize(wxSize(width, height));
|
|
||||||
Bind(wxEVT_ENTER_WINDOW, [this](auto &e) { SetCursor(wxCURSOR_HAND); });
|
|
||||||
Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) { SetCursor(wxCURSOR_ARROW); });
|
|
||||||
Bind(wxEVT_LEFT_DOWN, &PrintOptionItem::on_left_down, this);
|
|
||||||
|
|
||||||
m_selected_bk = ScalableBitmap(this, "print_options_bg", 22);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintOptionItem::OnPaint(wxPaintEvent &event)
|
void PrintOptionItem::update_options(std::vector<POItem> ops) {
|
||||||
{
|
if (m_ops != ops) {
|
||||||
wxPaintDC dc(this);
|
m_ops = ops;
|
||||||
doRender(dc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintOptionItem::render(wxDC &dc)
|
ComboBox::Clear();
|
||||||
{
|
selected_key.clear();
|
||||||
#ifdef __WXMSW__
|
for (const auto &entry : m_ops) { Append(entry.value); }
|
||||||
wxSize size = GetSize();
|
|
||||||
wxMemoryDC memdc;
|
|
||||||
wxBitmap bmp(size.x, size.y);
|
|
||||||
memdc.SelectObject(bmp);
|
|
||||||
memdc.Blit({0, 0}, size, &dc, {0, 0});
|
|
||||||
|
|
||||||
{
|
Layout();
|
||||||
wxGCDC dc2(memdc);
|
Fit();
|
||||||
doRender(dc2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memdc.SelectObject(wxNullBitmap);
|
|
||||||
dc.DrawBitmap(bmp, 0, 0);
|
|
||||||
#else
|
|
||||||
doRender(dc);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintOptionItem::on_left_down(wxMouseEvent &evt)
|
void PrintOptionItem::on_combobox_changed(wxCommandEvent &evt) {
|
||||||
{
|
const auto &new_key = get_key(evt.GetString());
|
||||||
if (!m_enabled) { return;}
|
setValue(new_key);
|
||||||
|
|
||||||
auto pos = ClientToScreen(evt.GetPosition());
|
|
||||||
auto rect = ClientToScreen(wxPoint(0, 0));
|
|
||||||
auto select_size = GetSize().x / m_ops.size();
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
for (const auto& entry : m_ops) {
|
|
||||||
auto left_edge = rect.x + i * select_size;
|
|
||||||
auto right_edge = rect.x + (i + 1) * select_size;
|
|
||||||
|
|
||||||
if (pos.x > left_edge && pos.x < right_edge) {
|
|
||||||
selected_key = entry.key;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_param.empty()) {
|
|
||||||
AppConfig *config = wxGetApp().app_config;
|
|
||||||
if (selected_key == "on") {
|
|
||||||
config->set_str("print", m_param, "1");
|
|
||||||
} else if (selected_key == "off") {
|
|
||||||
config->set_str("print", m_param, "0");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wxCommandEvent event(EVT_SWITCH_PRINT_OPTION);
|
|
||||||
event.SetString(selected_key);
|
|
||||||
event.SetEventObject(GetParent());
|
|
||||||
wxPostEvent(GetParent(), event);
|
|
||||||
|
|
||||||
Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintOptionItem::doRender(wxDC &dc)
|
wxString PrintOptionItem::get_display_str(const std::string &key) const {
|
||||||
{
|
|
||||||
auto size = GetSize();
|
|
||||||
dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
|
|
||||||
dc.SetBrush(GetBackgroundColour());
|
|
||||||
dc.DrawRoundedRectangle(0, 0, size.x, size.y, FromDIP(5));
|
|
||||||
|
|
||||||
auto left = FromDIP(4);
|
|
||||||
|
|
||||||
int selected = 0;
|
|
||||||
for (const auto &entry : m_ops) {
|
for (const auto &entry : m_ops) {
|
||||||
if (entry.key == selected_key) {
|
if (entry.key == key) { return entry.value; }
|
||||||
break;
|
|
||||||
}
|
|
||||||
selected++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*selected*/
|
return wxEmptyString;
|
||||||
auto selected_left = selected * FromDIP(56) + FromDIP(4);
|
|
||||||
dc.DrawBitmap(m_selected_bk.bmp(), selected_left, FromDIP(4));
|
|
||||||
|
|
||||||
for (auto it = m_ops.begin(); it != m_ops.end(); ++it) {
|
|
||||||
auto text_key = it->key;
|
|
||||||
auto text_value = it->value;
|
|
||||||
|
|
||||||
if (text_key == selected_key) {
|
|
||||||
|
|
||||||
const wxColour& clr = wxGetApp().dark_mode() ? StateColor::darkModeColorFor("#00AE42") : "#00AE42";
|
|
||||||
dc.SetPen(wxPen(clr));
|
|
||||||
dc.SetTextForeground(clr);
|
|
||||||
|
|
||||||
dc.SetFont(::Label::Head_13);
|
|
||||||
auto text_size = dc.GetTextExtent(text_value);
|
|
||||||
auto text_left = left + (FromDIP(56) - text_size.x) / 2;
|
|
||||||
auto text_top = (size.y - text_size.y) / 2;
|
|
||||||
dc.DrawText(text_value, wxPoint(text_left, text_top));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const wxColour& clr = wxGetApp().dark_mode() ? StateColor::darkModeColorFor(*wxBLACK) : *wxBLACK;
|
|
||||||
dc.SetPen(wxPen(clr));
|
|
||||||
dc.SetTextForeground(clr);
|
|
||||||
|
|
||||||
dc.SetFont(::Label::Body_13);
|
|
||||||
auto text_size = dc.GetTextExtent(text_value);
|
|
||||||
auto text_left = left + (FromDIP(56) - text_size.x) / 2;
|
|
||||||
auto text_top = (size.y - text_size.y) / 2;
|
|
||||||
dc.DrawText(text_value, wxPoint(text_left, text_top));
|
|
||||||
}
|
|
||||||
|
|
||||||
left += FromDIP(56);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintOptionItem::setValue(std::string value)
|
std::string PrintOptionItem::get_key(const wxString &display_val) const {
|
||||||
{
|
for (const auto &entry : m_ops) {
|
||||||
|
if (entry.value == display_val) { return entry.key; }
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintOptionItem::setValue(std::string value) {
|
||||||
if (selected_key != value) {
|
if (selected_key != value) {
|
||||||
selected_key = value;
|
selected_key = value;
|
||||||
|
ComboBox::SetStringSelection(get_display_str(value));
|
||||||
|
|
||||||
|
if (!m_param.empty()) {
|
||||||
|
AppConfig *config = wxGetApp().app_config;
|
||||||
|
if (selected_key == "auto") {
|
||||||
|
config->set_str("print", m_param, "2");
|
||||||
|
} else if (selected_key == "on") {
|
||||||
|
config->set_str("print", m_param, "1");
|
||||||
|
} else if (selected_key == "off") {
|
||||||
|
config->set_str("print", m_param, "0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wxCommandEvent event(EVT_SWITCH_PRINT_OPTION);
|
wxCommandEvent event(EVT_SWITCH_PRINT_OPTION);
|
||||||
event.SetString(selected_key);
|
event.SetString(selected_key);
|
||||||
event.SetEventObject(GetParent());
|
event.SetEventObject(GetParent());
|
||||||
wxPostEvent(GetParent(), event);
|
wxPostEvent(GetParent(), event);
|
||||||
Refresh();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PrintOptionItem::getValue()
|
|
||||||
{
|
|
||||||
return selected_key;
|
|
||||||
}
|
|
||||||
|
|
||||||
SendModeSwitchButton::SendModeSwitchButton(wxWindow *parent, wxString mode, bool sel)
|
SendModeSwitchButton::SendModeSwitchButton(wxWindow *parent, wxString mode, bool sel)
|
||||||
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
|
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -207,44 +207,38 @@ static int get_brightness_value(wxImage image) {
|
||||||
struct POItem
|
struct POItem
|
||||||
{
|
{
|
||||||
std::string key;
|
std::string key;
|
||||||
wxString value;
|
wxString value; // the display value
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool operator==(const POItem &other) const { return key == other.key && value == other.value; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class PrintOptionItem : public wxPanel
|
class PrintOptionItem : public ComboBox
|
||||||
{
|
{
|
||||||
ScalableBitmap m_selected_bk;
|
|
||||||
std::vector<POItem> m_ops;
|
std::vector<POItem> m_ops;
|
||||||
std::string selected_key;
|
std::string selected_key;
|
||||||
std::string m_param;
|
std::string m_param;
|
||||||
|
|
||||||
bool m_enabled = true;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PrintOptionItem(wxWindow *parent, std::vector<POItem> ops, std::string param = "");
|
PrintOptionItem(wxWindow *parent, std::vector<POItem> ops, std::string param = "");
|
||||||
~PrintOptionItem(){};
|
~PrintOptionItem() {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool Enable(bool enable) override { m_enabled = enable; return m_enabled;}
|
bool Enable(bool enable) override { return ComboBox::Enable(enable); }
|
||||||
|
|
||||||
void setValue(std::string value);
|
void setValue(std::string value);
|
||||||
std::string getValue();
|
std::string getValue() const { return selected_key; }
|
||||||
|
|
||||||
void msw_rescale() { m_selected_bk.msw_rescale(); Refresh();};
|
void msw_rescale() { ComboBox::Rescale();};
|
||||||
void update_options(std::vector<POItem> ops){
|
void update_options(std::vector<POItem> ops);
|
||||||
m_ops = ops;
|
|
||||||
selected_key = "";
|
bool CanBeFocused() const override { return false; }
|
||||||
auto width = ops.size() * FromDIP(56) + FromDIP(8);
|
|
||||||
auto height = FromDIP(22) + FromDIP(8);
|
|
||||||
SetMinSize(wxSize(width, height));
|
|
||||||
SetMaxSize(wxSize(width, height));
|
|
||||||
Refresh();
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnPaint(wxPaintEvent &event);
|
void on_combobox_changed(wxCommandEvent &evt);
|
||||||
void render(wxDC &dc);
|
|
||||||
void on_left_down(wxMouseEvent &evt);
|
wxString get_display_str(const std::string& key) const;
|
||||||
void doRender(wxDC &dc);
|
std::string get_key(const wxString &display_val) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PrintOption : public wxPanel
|
class PrintOption : public wxPanel
|
||||||
|
@ -270,10 +264,12 @@ public:
|
||||||
|
|
||||||
bool contain_opt(const std::string& opt_str) const;
|
bool contain_opt(const std::string& opt_str) const;
|
||||||
void update_options(std::vector<POItem> ops, const wxString &tips);
|
void update_options(std::vector<POItem> ops, const wxString &tips);
|
||||||
|
void update_tooltip(const wxString &tips);
|
||||||
|
|
||||||
void update_tooltip(const wxString &tips);
|
void msw_rescale() { m_printoption_item->msw_rescale(); };
|
||||||
|
|
||||||
void msw_rescale() { m_printoption_item->msw_rescale(); };
|
// override funcs
|
||||||
|
bool CanBeFocused() const override { return false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnPaint(wxPaintEvent &event);
|
void OnPaint(wxPaintEvent &event);
|
||||||
|
|
Loading…
Reference in New Issue