diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index 548a930dc0..7aee6c7a94 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -744,6 +744,7 @@ wxBoxSizer *StatusBasePanel::create_bed_control(wxWindow *parent) bSizer_z_ctrl->AddStretchSpacer(); m_bpButton_z_10 = new Button(panel, wxString("10"), "monitor_bed_up", 0, FromDIP(15)); m_bpButton_z_10->SetFont(::Label::Body_13); + m_bpButton_z_10->SetBorderWidth(2); m_bpButton_z_10->SetBackgroundColor(z_10_ctrl_bg); m_bpButton_z_10->SetBorderColor(z_10_ctrl_bd); m_bpButton_z_10->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal))); @@ -754,6 +755,7 @@ wxBoxSizer *StatusBasePanel::create_bed_control(wxWindow *parent) m_bpButton_z_1 = new Button(panel, wxString(" 1"), "monitor_bed_up", 0, FromDIP(15)); m_bpButton_z_1->SetFont(::Label::Body_13); + m_bpButton_z_1->SetBorderWidth(2); m_bpButton_z_1->SetBackgroundColor(z_1_ctrl_bg); m_bpButton_z_1->SetBorderColor(z_1_ctrl_bd); m_bpButton_z_1->SetMinSize(Z_BUTTON_SIZE); @@ -765,6 +767,7 @@ wxBoxSizer *StatusBasePanel::create_bed_control(wxWindow *parent) m_bpButton_z_down_1 = new Button(panel, wxString(" 1"), "monitor_bed_down", 0, FromDIP(15)); m_bpButton_z_down_1->SetFont(::Label::Body_13); + m_bpButton_z_down_1->SetBorderWidth(2); m_bpButton_z_down_1->SetBackgroundColor(z_1_ctrl_bg); m_bpButton_z_down_1->SetBorderColor(z_1_ctrl_bd); m_bpButton_z_down_1->SetMinSize(Z_BUTTON_SIZE); @@ -774,6 +777,7 @@ wxBoxSizer *StatusBasePanel::create_bed_control(wxWindow *parent) m_bpButton_z_down_10 = new Button(panel, wxString("10"), "monitor_bed_down", 0, FromDIP(15)); m_bpButton_z_down_10->SetFont(::Label::Body_13); + m_bpButton_z_down_10->SetBorderWidth(2); m_bpButton_z_down_10->SetBackgroundColor(z_10_ctrl_bg); m_bpButton_z_down_10->SetBorderColor(z_10_ctrl_bd); m_bpButton_z_down_10->SetMinSize(Z_BUTTON_SIZE); @@ -811,6 +815,7 @@ wxBoxSizer *StatusBasePanel::create_extruder_control(wxWindow *parent) StateColor e_ctrl_bg(std::pair(BUTTON_PRESS_COL, StateColor::Pressed), std::pair(BUTTON_NORMAL1_COL, StateColor::Normal)); StateColor e_ctrl_bd(std::pair(BUTTON_HOVER_COL, StateColor::Hovered), std::pair(BUTTON_NORMAL1_COL, StateColor::Normal)); m_bpButton_e_10 = new Button(panel, "", "monitor_extruder_up", 0, FromDIP(22)); + m_bpButton_e_10->SetBorderWidth(2); m_bpButton_e_10->SetBackgroundColor(e_ctrl_bg); m_bpButton_e_10->SetBorderColor(e_ctrl_bd); m_bpButton_e_10->SetMinSize(wxSize(FromDIP(40), FromDIP(40))); @@ -825,6 +830,7 @@ wxBoxSizer *StatusBasePanel::create_extruder_control(wxWindow *parent) bSizer_e_ctrl->Add(m_bitmap_extruder_img, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP | wxBOTTOM, FromDIP(5)); bSizer_e_ctrl->Add(0, FromDIP(7), 0, 0, 0); m_bpButton_e_down_10 = new Button(panel, "", "monitor_extruder_down", 0, FromDIP(22)); + m_bpButton_e_down_10->SetBorderWidth(2); m_bpButton_e_down_10->SetBackgroundColor(e_ctrl_bg); m_bpButton_e_down_10->SetBorderColor(e_ctrl_bd); m_bpButton_e_down_10->SetMinSize(wxSize(FromDIP(40), FromDIP(40))); diff --git a/src/slic3r/GUI/Widgets/ComboBox.cpp b/src/slic3r/GUI/Widgets/ComboBox.cpp index 712614667e..f010ce81c7 100644 --- a/src/slic3r/GUI/Widgets/ComboBox.cpp +++ b/src/slic3r/GUI/Widgets/ComboBox.cpp @@ -38,7 +38,6 @@ ComboBox::ComboBox(wxWindow * parent, GetTextCtrl()->Hide(); TextInput::SetFont(Label::Body_14); TextInput::SetBorderColor(StateColor(std::make_pair(0xDBDBDB, (int) StateColor::Disabled), - std::make_pair(0xEDFAF2, (int) StateColor::Focused), std::make_pair(0x00AE42, (int) StateColor::Hovered), std::make_pair(0xDBDBDB, (int) StateColor::Normal))); TextInput::SetBackgroundColor(StateColor(std::make_pair(0xF0F0F0, (int) StateColor::Disabled), diff --git a/src/slic3r/GUI/Widgets/SpinInput.cpp b/src/slic3r/GUI/Widgets/SpinInput.cpp index f872c25d6c..e54a5db00c 100644 --- a/src/slic3r/GUI/Widgets/SpinInput.cpp +++ b/src/slic3r/GUI/Widgets/SpinInput.cpp @@ -6,14 +6,9 @@ BEGIN_EVENT_TABLE(SpinInput, wxPanel) -EVT_MOTION(SpinInput::mouseMoved) -EVT_ENTER_WINDOW(SpinInput::mouseEnterWindow) -EVT_LEAVE_WINDOW(SpinInput::mouseLeaveWindow) EVT_KEY_DOWN(SpinInput::keyPressed) -EVT_KEY_UP(SpinInput::keyReleased) EVT_MOUSEWHEEL(SpinInput::mouseWheelMoved) -// catch paint events EVT_PAINT(SpinInput::paintEvent) END_EVENT_TABLE() @@ -25,16 +20,14 @@ END_EVENT_TABLE() */ SpinInput::SpinInput() - : state_handler(this) - , border_color(std::make_pair(0xDBDBDB, (int) StateColor::Disabled), - std::make_pair(0x00AE42, (int) StateColor::Hovered), - std::make_pair(0xDBDBDB, (int) StateColor::Normal)) - , label_color(std::make_pair(0x909090, (int) StateColor::Disabled), std::make_pair(0x6B6B6B, (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; radius = 0; + border_width = 1; + border_color = StateColor(std::make_pair(0xDBDBDB, (int) StateColor::Disabled), std::make_pair(0x00AE42, (int) StateColor::Hovered), + std::make_pair(0xDBDBDB, (int) StateColor::Normal)); + background_color = StateColor(std::make_pair(0xF0F0F0, (int) StateColor::Disabled), std::make_pair(*wxWHITE, (int) StateColor::Normal)); } @@ -58,10 +51,10 @@ void SpinInput::Create(wxWindow *parent, long style, int min, int max, int initial) { - wxWindow::Create(parent, wxID_ANY, pos, size); + StaticBox::Create(parent, wxID_ANY, pos, size); SetFont(Label::Body_12); wxWindow::SetLabel(label); - state_handler.attach({&border_color, &label_color, &text_color, &background_color}); + state_handler.attach({&label_color, &text_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); @@ -121,12 +114,6 @@ void SpinInput::SetTextColor(StateColor const &color) state_handler.update_binds(); } -void SpinInput::SetBackgroundColor(StateColor const& color) -{ - background_color = color; - state_handler.update_binds(); -} - void SpinInput::SetSize(wxSize const &size) { wxWindow::SetSize(size); @@ -201,24 +188,22 @@ void SpinInput::paintEvent(wxPaintEvent& evt) */ void SpinInput::render(wxDC& dc) { + StaticBox::render(dc); int states = state_handler.states(); wxSize size = GetSize(); - dc.SetPen(wxPen(border_color.colorForStates(states))); - dc.SetBrush(wxBrush(background_color.colorForStates(states))); - dc.DrawRoundedRectangle(0, 0, size.x, size.y, radius); + // draw seperator of buttons wxPoint pt = button_inc->GetPosition(); pt.y = size.y / 2; dc.SetPen(wxPen(border_color.defaultColor())); dc.DrawLine(pt, pt + wxSize{button_inc->GetSize().x - 2, 0}); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - // start draw - auto text = GetLabel(); - if (!text.IsEmpty()) { + // draw label + auto label = GetLabel(); + if (!label.IsEmpty()) { pt.x = size.x - labelSize.x - 5; pt.y = (size.y - labelSize.y) / 2; dc.SetFont(GetFont()); dc.SetTextForeground(label_color.colorForStates(states)); - dc.DrawText(text, pt); + dc.DrawText(label, pt); } } @@ -275,24 +260,6 @@ Button *SpinInput::createButton(bool inc) return btn; } -void SpinInput::mouseEnterWindow(wxMouseEvent& event) -{ - if (!hover) - { - hover = true; - Refresh(); - } -} - -void SpinInput::mouseLeaveWindow(wxMouseEvent& event) -{ - if (hover) - { - hover = false; - Refresh(); - } -} - void SpinInput::onTimer(wxTimerEvent &evnet) { if (delta < -1 || delta > 1) { delta /= 2; @@ -336,9 +303,6 @@ void SpinInput::mouseWheelMoved(wxMouseEvent &event) text_ctrl->SetFocus(); } -// currently unused events -void SpinInput::mouseMoved(wxMouseEvent& event) {} - void SpinInput::keyPressed(wxKeyEvent &event) { switch (event.GetKeyCode()) { @@ -359,7 +323,6 @@ void SpinInput::keyPressed(wxKeyEvent &event) default: event.Skip(); break; } } -void SpinInput::keyReleased(wxKeyEvent &event) {} void SpinInput::sendSpinEvent() { diff --git a/src/slic3r/GUI/Widgets/SpinInput.hpp b/src/slic3r/GUI/Widgets/SpinInput.hpp index e9d04392ef..5b0868880c 100644 --- a/src/slic3r/GUI/Widgets/SpinInput.hpp +++ b/src/slic3r/GUI/Widgets/SpinInput.hpp @@ -2,22 +2,15 @@ #define slic3r_GUI_SpinInput_hpp_ #include -#include "../wxExtensions.hpp" -#include "StateHandler.hpp" +#include "StaticBox.hpp" class Button; -class SpinInput : public wxNavigationEnabled +class SpinInput : public wxNavigationEnabled { - - bool hover; wxSize labelSize; - double radius; - StateHandler state_handler; StateColor label_color; StateColor text_color; - StateColor border_color; - StateColor background_color; wxTextCtrl * text_ctrl; Button * button_inc; Button * button_dec; @@ -60,8 +53,6 @@ public: void SetTextColor(StateColor const &color); - void SetBackgroundColor(StateColor const & color); - void SetSize(wxSize const &size); void Rescale(); @@ -91,12 +82,8 @@ private: Button *createButton(bool inc); // some useful events - void mouseMoved(wxMouseEvent& event); void mouseWheelMoved(wxMouseEvent& event); - void mouseEnterWindow(wxMouseEvent& event); - void mouseLeaveWindow(wxMouseEvent& event); void keyPressed(wxKeyEvent& event); - void keyReleased(wxKeyEvent& event); void onTimer(wxTimerEvent &evnet); void onTextLostFocus(wxEvent &event); void onTextEnter(wxCommandEvent &event); diff --git a/src/slic3r/GUI/Widgets/StaticBox.cpp b/src/slic3r/GUI/Widgets/StaticBox.cpp index f8c55919c7..849ad0fa81 100644 --- a/src/slic3r/GUI/Widgets/StaticBox.cpp +++ b/src/slic3r/GUI/Widgets/StaticBox.cpp @@ -35,9 +35,6 @@ StaticBox::StaticBox(wxWindow* parent, bool StaticBox::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) { wxWindow::Create(parent, id, pos, size, style); -#ifdef __WXMSW__ - SetBackgroundStyle(wxBG_STYLE_PAINT); -#endif state_handler.attach({&border_color, &background_color, &background_color2}); state_handler.update_binds(); SetBackgroundColour(GetParentBackgroundColor(parent)); @@ -122,6 +119,11 @@ void StaticBox::paintEvent(wxPaintEvent& evt) void StaticBox::render(wxDC& dc) { #ifdef __WXMSW__ + if (radius == 0) { + doRender(dc); + return; + } + wxSize size = GetSize(); wxMemoryDC memdc; wxBitmap bmp(size.x, size.y); @@ -149,10 +151,20 @@ void StaticBox::doRender(wxDC& dc) if ((border_width && border_color.count() > 0) || background_color.count() > 0) { wxRect rc(0, 0, size.x, size.y); if (border_width && border_color.count() > 0 && (GetWindowStyle() & wxBORDER_NONE) == 0) { -#ifdef __WXOSX__ - int d = ceil(border_width / 2.0); - rc.Deflate(d, d); -#endif + if (dc.GetContentScaleFactor() == 1.0) { + int d = floor(border_width / 2.0); + int d2 = floor(border_width - 1); + rc.x += d; + rc.width -= d2; + rc.y += d; + rc.height -= d2; + } else { + int d = 1; + rc.x += d; + rc.width -= d; + rc.y += d; + rc.height -= d; + } dc.SetPen(wxPen(border_color.colorForStates(states), border_width)); } else { dc.SetPen(wxPen(background_color.colorForStates(states))); diff --git a/src/slic3r/GUI/Widgets/TabCtrl.cpp b/src/slic3r/GUI/Widgets/TabCtrl.cpp index 84c1a4b63c..b2b7602726 100644 --- a/src/slic3r/GUI/Widgets/TabCtrl.cpp +++ b/src/slic3r/GUI/Widgets/TabCtrl.cpp @@ -31,6 +31,7 @@ TabCtrl::TabCtrl(wxWindow * parent, #else radius = 1; #endif + border_width = 1; SetBorderColor(0xcecece); sizer = new wxBoxSizer(wxHORIZONTAL); sizer->AddSpacer(10); @@ -251,9 +252,6 @@ void TabCtrl::doRender(wxDC& dc) { wxSize size = GetSize(); int states = state_handler.states(); - dc.SetPen(wxPen(border_color.colorForStates(states), border_width)); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - if (sel < 0) { return; } auto x1 = btns[sel]->GetPosition().x; @@ -262,6 +260,8 @@ void TabCtrl::doRender(wxDC& dc) const int BS2 = (1 + border_width) / 2; #if 0 x1 -= TAB_BUTTON_SPACE; x2 += TAB_BUTTON_SPACE; + dc.SetPen(wxPen(border_color.colorForStates(states), border_width)); + dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawLine(0, size.y - BS2, x1 - radius + BS2, size.y - BS2); dc.DrawArc(x1 - radius, size.y, x1, size.y - radius, x1 - radius, size.y - radius); dc.DrawLine(x1, size.y - radius, x1, radius); @@ -272,6 +272,7 @@ void TabCtrl::doRender(wxDC& dc) dc.DrawArc(x2, size.y - radius, x2 + radius, size.y, x2 + radius, size.y - radius); dc.DrawLine(x2 + radius - BS2, size.y - BS2, size.x, size.y - BS2); #else + dc.SetPen(wxPen(border_color.colorForStates(states), border_width)); dc.DrawLine(0, size.y - BS2, size.x, size.y - BS2); wxColor c(0x42AE00); dc.SetPen(wxPen(c, 0)); diff --git a/src/slic3r/GUI/Widgets/TextInput.cpp b/src/slic3r/GUI/Widgets/TextInput.cpp index 9a7d6b5bb4..446948e543 100644 --- a/src/slic3r/GUI/Widgets/TextInput.cpp +++ b/src/slic3r/GUI/Widgets/TextInput.cpp @@ -5,14 +5,6 @@ BEGIN_EVENT_TABLE(TextInput, wxPanel) -EVT_MOTION(TextInput::mouseMoved) -EVT_ENTER_WINDOW(TextInput::mouseEnterWindow) -EVT_LEAVE_WINDOW(TextInput::mouseLeaveWindow) -EVT_KEY_DOWN(TextInput::keyPressed) -EVT_KEY_UP(TextInput::keyReleased) -EVT_MOUSEWHEEL(TextInput::mouseWheelMoved) - -// catch paint events EVT_PAINT(TextInput::paintEvent) END_EVENT_TABLE() @@ -24,19 +16,16 @@ END_EVENT_TABLE() */ TextInput::TextInput() - : state_handler(this) - , border_color(std::make_pair(0xDBDBDB, (int) StateColor::Disabled), - std::make_pair(0x00AE42, (int) StateColor::Hovered), - std::make_pair(0xDBDBDB, (int) StateColor::Normal)) - , label_color(std::make_pair(0x909090, (int) StateColor::Disabled), + : 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; radius = 0; + border_width = 1; + border_color = StateColor(std::make_pair(0xDBDBDB, (int) StateColor::Disabled), std::make_pair(0x00AE42, (int) StateColor::Hovered), + std::make_pair(0xDBDBDB, (int) StateColor::Normal)); + background_color = StateColor(std::make_pair(0xF0F0F0, (int) StateColor::Disabled), std::make_pair(*wxWHITE, (int) StateColor::Normal)); SetFont(Label::Body_12); } @@ -61,10 +50,10 @@ void TextInput::Create(wxWindow * parent, long style) { text_ctrl = nullptr; - wxWindow::Create(parent, wxID_ANY, pos, size, style); + StaticBox::Create(parent, wxID_ANY, pos, size, style); wxWindow::SetLabel(label); style &= ~wxRIGHT; - state_handler.attach({&border_color, &label_color, & text_color, &background_color}); + state_handler.attach({&label_color, & text_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); @@ -119,12 +108,6 @@ void TextInput::SetIcon(const wxBitmap &icon) Rescale(); } -void TextInput::SetBorderColor(StateColor const& color) -{ - border_color = color; - state_handler.update_binds(); -} - void TextInput::SetLabelColor(StateColor const &color) { label_color = color; @@ -137,12 +120,6 @@ void TextInput::SetTextColor(StateColor const& color) state_handler.update_binds(); } -void TextInput::SetBackgroundColor(StateColor const& color) -{ - background_color = color; - state_handler.update_binds(); -} - void TextInput::Rescale() { if (!this->icon.name().empty()) @@ -217,13 +194,10 @@ void TextInput::paintEvent(wxPaintEvent &evt) */ void TextInput::render(wxDC& dc) { + StaticBox::render(dc); int states = state_handler.states(); wxSize size = GetSize(); bool align_right = GetWindowStyle() & wxRIGHT; - dc.SetPen(wxPen(border_color.colorForStates(states))); - dc.SetBrush(wxBrush(background_color.colorForStates(states))); - dc.DrawRoundedRectangle(0, 0, size.x, size.y, radius); - dc.SetBrush(*wxTRANSPARENT_BRUSH); // start draw wxPoint pt = {5, 0}; if (icon.bmp().IsOk()) { @@ -264,27 +238,3 @@ void TextInput::messureSize() SetMinSize(minSize); SetSize(size); } - -void TextInput::mouseEnterWindow(wxMouseEvent& event) -{ - if (!hover) - { - hover = true; - Refresh(); - } -} - -void TextInput::mouseLeaveWindow(wxMouseEvent& event) -{ - if (hover) - { - hover = false; - Refresh(); - } -} - -// currently unused events -void TextInput::mouseMoved(wxMouseEvent& event) {} -void TextInput::mouseWheelMoved(wxMouseEvent& event) {} -void TextInput::keyPressed(wxKeyEvent& event) {} -void TextInput::keyReleased(wxKeyEvent& event) {} diff --git a/src/slic3r/GUI/Widgets/TextInput.hpp b/src/slic3r/GUI/Widgets/TextInput.hpp index fccff263d3..152fb88f3d 100644 --- a/src/slic3r/GUI/Widgets/TextInput.hpp +++ b/src/slic3r/GUI/Widgets/TextInput.hpp @@ -2,21 +2,15 @@ #define slic3r_GUI_TextInput_hpp_ #include -#include "../wxExtensions.hpp" -#include "StateHandler.hpp" +#include "StaticBox.hpp" -class TextInput : public wxNavigationEnabled +class TextInput : public wxNavigationEnabled { - bool hover; wxSize labelSize; ScalableBitmap icon; - double radius; - StateHandler state_handler; StateColor label_color; StateColor text_color; - StateColor border_color; - StateColor background_color; wxTextCtrl * text_ctrl; static const int TextInputWidth = 200; @@ -48,14 +42,10 @@ public: void SetIcon(const wxBitmap & icon); - void SetBorderColor(StateColor const & color); - void SetLabelColor(StateColor const &color); void SetTextColor(StateColor const &color); - void SetBackgroundColor(StateColor const &color); - virtual void Rescale(); virtual bool Enable(bool enable = true) override; @@ -81,14 +71,6 @@ private: void messureSize(); - // some useful events - void mouseMoved(wxMouseEvent& event); - void mouseWheelMoved(wxMouseEvent& event); - void mouseEnterWindow(wxMouseEvent& event); - void mouseLeaveWindow(wxMouseEvent& event); - void keyPressed(wxKeyEvent& event); - void keyReleased(wxKeyEvent& event); - DECLARE_EVENT_TABLE() };