From 8448d1a1dcc501548a742630c3ab4465ecc8100c Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 6 Nov 2020 16:24:03 +0100 Subject: [PATCH] OSX specific : Set top border for the mode buttons, when settings pages has new layouts (when tabs bar is hidden) + Code cleaning for OG_CustomCtrl (delete unused input parameter from the draw_blinking_bmp()) --- src/slic3r/GUI/MainFrame.cpp | 4 ++++ src/slic3r/GUI/OG_CustomCtrl.cpp | 4 ++-- src/slic3r/GUI/OG_CustomCtrl.hpp | 2 +- src/slic3r/GUI/Plater.cpp | 6 ++++++ src/slic3r/GUI/Plater.hpp | 1 + src/slic3r/GUI/wxExtensions.cpp | 11 +++++++++++ src/slic3r/GUI/wxExtensions.hpp | 3 +++ 7 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index b46a6a6f3..b2ff35fa1 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -429,6 +429,10 @@ void MainFrame::update_layout() // m_tabpanel->SetMinSize(size); // } //#endif + +#ifdef __APPLE__ + m_plater->sidebar().change_top_border_for_mode_sizer(m_layout != ESettingsLayout::Old); +#endif Layout(); Thaw(); diff --git a/src/slic3r/GUI/OG_CustomCtrl.cpp b/src/slic3r/GUI/OG_CustomCtrl.cpp index 22729c8c2..2a235f600 100644 --- a/src/slic3r/GUI/OG_CustomCtrl.cpp +++ b/src/slic3r/GUI/OG_CustomCtrl.cpp @@ -627,7 +627,7 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC& dc, wxPoint pos, const wxStr return pos.x + width + ctrl->m_h_gap; } -wxPoint OG_CustomCtrl::CtrlLine::draw_blinking_bmp(wxDC& dc, wxPoint pos, bool is_blinking, size_t rect_id) +wxPoint OG_CustomCtrl::CtrlLine::draw_blinking_bmp(wxDC& dc, wxPoint pos, bool is_blinking) { wxBitmap bmp_blinking = create_scaled_bitmap(is_blinking ? "search_blink" : "empty", ctrl); wxCoord h_pos = pos.x; @@ -643,7 +643,7 @@ wxPoint OG_CustomCtrl::CtrlLine::draw_blinking_bmp(wxDC& dc, wxPoint pos, bool i wxCoord OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmap& bmp_undo_to_sys, const wxBitmap& bmp_undo, bool is_blinking, size_t rect_id) { - pos = draw_blinking_bmp(dc, pos, is_blinking, rect_id); + pos = draw_blinking_bmp(dc, pos, is_blinking); wxCoord h_pos = pos.x; wxCoord v_pos = pos.y; diff --git a/src/slic3r/GUI/OG_CustomCtrl.hpp b/src/slic3r/GUI/OG_CustomCtrl.hpp index 2ca1b8a77..722b393f5 100644 --- a/src/slic3r/GUI/OG_CustomCtrl.hpp +++ b/src/slic3r/GUI/OG_CustomCtrl.hpp @@ -55,7 +55,7 @@ class OG_CustomCtrl :public wxPanel void render(wxDC& dc, wxCoord v_pos); wxCoord draw_mode_bmp(wxDC& dc, wxCoord v_pos); wxCoord draw_text (wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width, bool is_url = false); - wxPoint draw_blinking_bmp(wxDC& dc, wxPoint pos, bool is_blinking, size_t rect_id = 0); + wxPoint draw_blinking_bmp(wxDC& dc, wxPoint pos, bool is_blinking); wxCoord draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmap& bmp_undo_to_sys, const wxBitmap& bmp_undo, bool is_blinking, size_t rect_id = 0); bool launch_browser() const; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index c44281d7c..f461b6d4e 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -910,6 +910,12 @@ void Sidebar::update_mode_sizer() const p->mode_sizer->SetMode(m_mode); } +void Sidebar::change_top_border_for_mode_sizer(bool increase_border) +{ + p->mode_sizer->set_items_flag(increase_border ? wxTOP : 0); + p->mode_sizer->set_items_border(increase_border ? int(0.5 * wxGetApp().em_unit()) : 0); +} + void Sidebar::update_reslice_btn_tooltip() const { wxString tooltip = wxString("Slice") + " [" + GUI::shortkey_ctrl_prefix() + "R]"; diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index e7b7c8442..42a22ae80 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -72,6 +72,7 @@ public: void update_all_preset_comboboxes(); void update_presets(Slic3r::Preset::Type preset_type); void update_mode_sizer() const; + void change_top_border_for_mode_sizer(bool increase_border); void update_reslice_btn_tooltip() const; void msw_rescale(); void sys_color_changed(); diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index e46a1de2e..5674d2a2a 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -696,6 +696,17 @@ void ModeSizer::SetMode(const int mode) m_mode_btns[m]->SetState(int(m) == mode); } +void ModeSizer::set_items_flag(int flag) +{ + for (wxSizerItem* item : this->GetChildren()) + item->SetFlag(flag); +} + +void ModeSizer::set_items_border(int border) +{ + for (wxSizerItem* item : this->GetChildren()) + item->SetBorder(border); +} void ModeSizer::msw_rescale() { diff --git a/src/slic3r/GUI/wxExtensions.hpp b/src/slic3r/GUI/wxExtensions.hpp index 40596b4de..e0952d79d 100644 --- a/src/slic3r/GUI/wxExtensions.hpp +++ b/src/slic3r/GUI/wxExtensions.hpp @@ -298,6 +298,9 @@ public: void SetMode(const /*ConfigOptionMode*/int mode); + void set_items_flag(int flag); + void set_items_border(int border); + void msw_rescale(); private: