From a478abd88a573e9036bc48984d39f7bf34218f48 Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Mon, 1 Aug 2022 18:00:28 +0800 Subject: [PATCH] FIX: ui style of base widgets Change-Id: Ie0cff84d7a6f19c9830ce60f2a188fe9a7df545c --- src/slic3r/GUI/Widgets/Button.cpp | 1 + src/slic3r/GUI/Widgets/ComboBox.cpp | 2 ++ src/slic3r/GUI/Widgets/SpinInput.cpp | 18 +++++++++++++++--- src/slic3r/GUI/Widgets/SpinInput.hpp | 5 ++++- src/slic3r/GUI/Widgets/StaticLine.cpp | 2 +- src/slic3r/GUI/Widgets/SwitchButton.cpp | 2 +- src/slic3r/GUI/Widgets/TextInput.cpp | 24 ++++++++++++++++-------- src/slic3r/GUI/Widgets/TextInput.hpp | 3 +++ 8 files changed, 43 insertions(+), 14 deletions(-) diff --git a/src/slic3r/GUI/Widgets/Button.cpp b/src/slic3r/GUI/Widgets/Button.cpp index 7972d51e6..7caa98a6f 100644 --- a/src/slic3r/GUI/Widgets/Button.cpp +++ b/src/slic3r/GUI/Widgets/Button.cpp @@ -26,6 +26,7 @@ Button::Button() , text_color(*wxBLACK) { background_color = StateColor( + std::make_pair(0xF0F0F0, (int) StateColor::Disabled), std::make_pair(0x00AE42, (int) StateColor::Checked), std::make_pair(*wxLIGHT_GREY, (int) StateColor::Hovered), std::make_pair(0x37EE7C, (int) StateColor::Hovered | StateColor::Checked), diff --git a/src/slic3r/GUI/Widgets/ComboBox.cpp b/src/slic3r/GUI/Widgets/ComboBox.cpp index e6fd9c2be..03b6f5f03 100644 --- a/src/slic3r/GUI/Widgets/ComboBox.cpp +++ b/src/slic3r/GUI/Widgets/ComboBox.cpp @@ -44,6 +44,8 @@ ComboBox::ComboBox(wxWindow * parent, TextInput::SetBackgroundColor(StateColor(std::make_pair(0xF0F0F0, (int) StateColor::Disabled), std::make_pair(0xEDFAF2, (int) StateColor::Focused), std::make_pair(*wxWHITE, (int) StateColor::Normal))); + TextInput::SetLabelColor(StateColor(std::make_pair(0x909090, (int) StateColor::Disabled), + std::make_pair(0x262E30, (int) StateColor::Normal))); } else { GetTextCtrl()->Bind(wxEVT_KEY_DOWN, &ComboBox::keyDown, this); } diff --git a/src/slic3r/GUI/Widgets/SpinInput.cpp b/src/slic3r/GUI/Widgets/SpinInput.cpp index 0e534465a..f872c25d6 100644 --- a/src/slic3r/GUI/Widgets/SpinInput.cpp +++ b/src/slic3r/GUI/Widgets/SpinInput.cpp @@ -29,7 +29,8 @@ SpinInput::SpinInput() , border_color(std::make_pair(0xDBDBDB, (int) StateColor::Disabled), std::make_pair(0x00AE42, (int) StateColor::Hovered), std::make_pair(0xDBDBDB, (int) StateColor::Normal)) - , text_color(std::make_pair(0xACACAC, (int) StateColor::Disabled), std::make_pair(*wxBLACK, (int) StateColor::Normal)) + , label_color(std::make_pair(0x909090, (int) StateColor::Disabled), std::make_pair(0x6B6B6B, (int) StateColor::Normal)) + , text_color(std::make_pair(0x909090, (int) StateColor::Disabled), std::make_pair(0x262E30, (int) StateColor::Normal)) , background_color(std::make_pair(0xF0F0F0, (int) StateColor::Disabled), std::make_pair(*wxWHITE, (int) StateColor::Normal)) { hover = false; @@ -60,10 +61,12 @@ void SpinInput::Create(wxWindow *parent, wxWindow::Create(parent, wxID_ANY, pos, size); SetFont(Label::Body_12); wxWindow::SetLabel(label); - state_handler.attach({&border_color, &text_color, &background_color}); + state_handler.attach({&border_color, &label_color, &text_color, &background_color}); state_handler.update_binds(); text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {20, 4}, wxDefaultSize, style | wxBORDER_NONE | wxTE_PROCESS_ENTER, wxTextValidator(wxFILTER_DIGITS)); text_ctrl->SetFont(Label::Body_14); + text_ctrl->SetBackgroundColour(background_color.colorForStates(state_handler.states())); + text_ctrl->SetForegroundColour(text_color.colorForStates(state_handler.states())); text_ctrl->SetInitialSize(text_ctrl->GetBestSize()); text_ctrl->Bind(wxEVT_SET_FOCUS, [this](auto &e) { e.SetId(GetId()); @@ -106,6 +109,12 @@ void SpinInput::SetLabel(const wxString &label) Refresh(); } +void SpinInput::SetLabelColor(StateColor const &color) +{ + label_color = color; + state_handler.update_binds(); +} + void SpinInput::SetTextColor(StateColor const &color) { text_color = color; @@ -171,6 +180,9 @@ bool SpinInput::Enable(bool enable) e.SetEventObject(this); GetEventHandler()->ProcessEvent(e); text_ctrl->SetBackgroundColour(background_color.colorForStates(state_handler.states())); + text_ctrl->SetForegroundColour(text_color.colorForStates(state_handler.states())); + button_inc->Enable(enable); + button_dec->Enable(enable); } return result; } @@ -205,7 +217,7 @@ void SpinInput::render(wxDC& dc) pt.x = size.x - labelSize.x - 5; pt.y = (size.y - labelSize.y) / 2; dc.SetFont(GetFont()); - dc.SetTextForeground(text_color.colorForStates(states)); + dc.SetTextForeground(label_color.colorForStates(states)); dc.DrawText(text, pt); } } diff --git a/src/slic3r/GUI/Widgets/SpinInput.hpp b/src/slic3r/GUI/Widgets/SpinInput.hpp index aded55bfb..e9d04392e 100644 --- a/src/slic3r/GUI/Widgets/SpinInput.hpp +++ b/src/slic3r/GUI/Widgets/SpinInput.hpp @@ -14,6 +14,7 @@ class SpinInput : public wxNavigationEnabled wxSize labelSize; double radius; StateHandler state_handler; + StateColor label_color; StateColor text_color; StateColor border_color; StateColor background_color; @@ -55,7 +56,9 @@ public: void SetLabel(const wxString &label) wxOVERRIDE; - void SetTextColor(StateColor const & color); + void SetLabelColor(StateColor const &color); + + void SetTextColor(StateColor const &color); void SetBackgroundColor(StateColor const & color); diff --git a/src/slic3r/GUI/Widgets/StaticLine.cpp b/src/slic3r/GUI/Widgets/StaticLine.cpp index 16f89ec9c..25538f480 100644 --- a/src/slic3r/GUI/Widgets/StaticLine.cpp +++ b/src/slic3r/GUI/Widgets/StaticLine.cpp @@ -15,7 +15,7 @@ StaticLine::StaticLine(wxWindow* parent, bool vertical, const wxString& label) , vertical(vertical) { wxWindow::SetBackgroundColour(parent->GetBackgroundColour()); - this->pen = wxPen(wxColour("#C4C4C4")); + this->pen = wxPen(wxColour("#EEEEEE")); DisableFocusFromKeyboard(); SetFont(Label::Body_14); SetLabel(label); diff --git a/src/slic3r/GUI/Widgets/SwitchButton.cpp b/src/slic3r/GUI/Widgets/SwitchButton.cpp index 9770ef5b7..8ae1165dc 100644 --- a/src/slic3r/GUI/Widgets/SwitchButton.cpp +++ b/src/slic3r/GUI/Widgets/SwitchButton.cpp @@ -80,7 +80,7 @@ void SwitchButton::Rescale() if (size.x > thumbSize.x) thumbSize.x = size.x; else size.x = thumbSize.x; thumbSize.x += BS * 12; - thumbSize.y += BS * 2; + thumbSize.y += BS * 6; trackSize.x = thumbSize.x + size.x + BS * 10; trackSize.y = thumbSize.y + BS * 2; auto maxWidth = GetMaxWidth(); diff --git a/src/slic3r/GUI/Widgets/TextInput.cpp b/src/slic3r/GUI/Widgets/TextInput.cpp index 605e2e12b..9a7d6b5bb 100644 --- a/src/slic3r/GUI/Widgets/TextInput.cpp +++ b/src/slic3r/GUI/Widgets/TextInput.cpp @@ -28,8 +28,10 @@ TextInput::TextInput() , border_color(std::make_pair(0xDBDBDB, (int) StateColor::Disabled), std::make_pair(0x00AE42, (int) StateColor::Hovered), std::make_pair(0xDBDBDB, (int) StateColor::Normal)) - , text_color(std::make_pair(0xACACAC, (int) StateColor::Disabled), - std::make_pair(0x363636, (int) StateColor::Normal)) + , label_color(std::make_pair(0x909090, (int) StateColor::Disabled), + std::make_pair(0x6B6B6B, (int) StateColor::Normal)) + , text_color(std::make_pair(0x909090, (int) StateColor::Disabled), + std::make_pair(0x262E30, (int) StateColor::Normal)) , background_color(std::make_pair(0xF0F0F0, (int) StateColor::Disabled), std::make_pair(*wxWHITE, (int) StateColor::Normal)) { @@ -62,11 +64,13 @@ void TextInput::Create(wxWindow * parent, wxWindow::Create(parent, wxID_ANY, pos, size, style); wxWindow::SetLabel(label); style &= ~wxRIGHT; - state_handler.attach({&border_color, &text_color, &background_color}); + state_handler.attach({&border_color, &label_color, & text_color, &background_color}); state_handler.update_binds(); text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {4, 4}, wxDefaultSize, style | wxBORDER_NONE); text_ctrl->SetFont(Label::Body_14); text_ctrl->SetInitialSize(text_ctrl->GetBestSize()); + text_ctrl->SetBackgroundColour(background_color.colorForStates(state_handler.states())); + text_ctrl->SetForegroundColour(text_color.colorForStates(state_handler.states())); text_ctrl->Bind(wxEVT_SET_FOCUS, [this](auto &e) { e.SetId(GetId()); ProcessEventLocally(e); @@ -121,6 +125,12 @@ void TextInput::SetBorderColor(StateColor const& color) state_handler.update_binds(); } +void TextInput::SetLabelColor(StateColor const &color) +{ + label_color = color; + state_handler.update_binds(); +} + void TextInput::SetTextColor(StateColor const& color) { text_color= color; @@ -149,6 +159,7 @@ bool TextInput::Enable(bool enable) e.SetEventObject(this); GetEventHandler()->ProcessEvent(e); text_ctrl->SetBackgroundColour(background_color.colorForStates(state_handler.states())); + text_ctrl->SetForegroundColour(text_color.colorForStates(state_handler.states())); } return result; } @@ -219,7 +230,7 @@ void TextInput::render(wxDC& dc) wxSize szIcon = icon.GetBmpSize(); pt.y = (size.y - szIcon.y) / 2; dc.DrawBitmap(icon.bmp(), pt); - pt.x += szIcon.x + 5; + pt.x += szIcon.x + 0; } auto text = wxWindow::GetLabel(); if (!text.IsEmpty()) { @@ -232,7 +243,7 @@ void TextInput::render(wxDC& dc) pt.x += textSize.x; pt.y = (size.y + textSize.y) / 2 - labelSize.y; } - dc.SetTextForeground(text_color.colorForStates(states)); + dc.SetTextForeground(label_color.colorForStates(states)); dc.SetFont(GetFont()); dc.DrawText(text, pt); } @@ -244,9 +255,6 @@ void TextInput::messureSize() wxClientDC dc(this); labelSize = dc.GetTextExtent(wxWindow::GetLabel()); wxSize textSize = text_ctrl->GetSize(); -#ifdef __WXOSX__ - textSize.y -= 3; // TODO: -#endif int h = textSize.y + 8; if (size.y < h) { size.y = h; diff --git a/src/slic3r/GUI/Widgets/TextInput.hpp b/src/slic3r/GUI/Widgets/TextInput.hpp index 92f5e8827..fccff263d 100644 --- a/src/slic3r/GUI/Widgets/TextInput.hpp +++ b/src/slic3r/GUI/Widgets/TextInput.hpp @@ -13,6 +13,7 @@ class TextInput : public wxNavigationEnabled ScalableBitmap icon; double radius; StateHandler state_handler; + StateColor label_color; StateColor text_color; StateColor border_color; StateColor background_color; @@ -49,6 +50,8 @@ public: void SetBorderColor(StateColor const & color); + void SetLabelColor(StateColor const &color); + void SetTextColor(StateColor const &color); void SetBackgroundColor(StateColor const &color);