diff --git a/src/slic3r/GUI/DoubleSliderForGcode.cpp b/src/slic3r/GUI/DoubleSliderForGcode.cpp index 7ad6c3bf81..6704f8d1c0 100644 --- a/src/slic3r/GUI/DoubleSliderForGcode.cpp +++ b/src/slic3r/GUI/DoubleSliderForGcode.cpp @@ -8,7 +8,7 @@ namespace DoubleSlider { static const float LEFT_MARGIN = 13.0f + 100.0f; // avoid thumbnail toolbar -static const float HORIZONTAL_SLIDER_HEIGHT = 45.0f; +static const float HORIZONTAL_SLIDER_HEIGHT = 40.0f; void DSForGcode::Render(const int canvas_width, const int canvas_height, float extra_scale/* = 0.1f*/, float offset/* = 0.f*/) { @@ -16,7 +16,7 @@ void DSForGcode::Render(const int canvas_width, const int canvas_height, float e return; m_scale = extra_scale * 0.1f * m_em; - ImVec2 pos = ImVec2{std::max(LEFT_MARGIN, 0.2f * canvas_width), canvas_height - 1.5f * HORIZONTAL_SLIDER_HEIGHT * m_scale}; + ImVec2 pos = ImVec2{std::max(LEFT_MARGIN, 0.2f * canvas_width), canvas_height - HORIZONTAL_SLIDER_HEIGHT * m_scale}; ImVec2 size = ImVec2(canvas_width - 2 * pos.x, HORIZONTAL_SLIDER_HEIGHT * m_scale); m_ctrl.Init(pos, size, m_scale); diff --git a/src/slic3r/GUI/DoubleSliderForLayers.cpp b/src/slic3r/GUI/DoubleSliderForLayers.cpp index 3f0a2e1eaf..695fd5a601 100644 --- a/src/slic3r/GUI/DoubleSliderForLayers.cpp +++ b/src/slic3r/GUI/DoubleSliderForLayers.cpp @@ -172,7 +172,7 @@ void DSForLayers::draw_ticks(const ImRect& slideable_region) // return; //if (m_ticks.empty() || m_mode == MultiExtruder) // return; - if (m_ticks.empty()) + if (m_ticks.empty() || m_draw_mode == dmSlaPrint) return; const ImVec2 tick_border = ImVec2(23.0f, 2.0f) * m_scale; @@ -359,7 +359,7 @@ void DSForLayers::render_menu() else if (m_show_cog_menu) ImGui::OpenPopup("cog_menu_popup"); - if (m_allow_editing) + if (can_edit()) render_add_tick_menu(); render_cog_menu(); @@ -501,7 +501,7 @@ void DSForLayers::render_cog_menu() if (m_ticks.edit_extruder_sequence(m_ctrl.GetMaxPos(), m_mode)) process_ticks_changed(); } - if (m_allow_editing) { + if (can_edit()) { if (ImGuiPureWrap::menu_item_with_icon(_u8L("Use default colors").c_str(), "", icon_sz, 0, m_ticks.used_default_colors())) { UseDefaultColors(!m_ticks.used_default_colors()); } @@ -650,7 +650,7 @@ void DSForLayers::Render(const int canvas_width, const int canvas_height, float ImVec2 btn_pos = ImVec2(groove_center_x - 0.5f * action_btn_sz, pos.y - 0.75f * action_btn_sz); - if (!m_ticks.empty() && m_allow_editing && + if (!m_ticks.empty() && can_edit() && render_button(ImGui::DSRevert, ImGui::DSRevertHovered, "revert", btn_pos, fiRevertIcon)) discard_all_thicks(); @@ -676,7 +676,7 @@ void DSForLayers::Render(const int canvas_width, const int canvas_height, float m_values[m_ctrl.GetMinPos()], m_values[m_ctrl.GetMaxPos()])) process_jump_to_value(); - if (m_allow_editing) + if (can_edit()) render_color_picker(); } @@ -966,7 +966,7 @@ void DSForLayers::add_code_as_tick(Type type, int selected_extruder/* = -1*/) void DSForLayers::add_current_tick() { - if (!m_allow_editing) + if (!can_edit()) return; const int tick = m_ctrl.GetActivePos(); @@ -1041,6 +1041,11 @@ void DSForLayers::process_jump_to_value() } } +bool DSForLayers::can_edit() const +{ + return m_allow_editing && m_draw_mode != dmSlaPrint; +} + } // DoubleSlider diff --git a/src/slic3r/GUI/DoubleSliderForLayers.hpp b/src/slic3r/GUI/DoubleSliderForLayers.hpp index 5eea05913e..306a131402 100644 --- a/src/slic3r/GUI/DoubleSliderForLayers.hpp +++ b/src/slic3r/GUI/DoubleSliderForLayers.hpp @@ -169,6 +169,7 @@ private: void edit_tick(int tick = -1); void discard_all_thicks(); void process_jump_to_value(); + bool can_edit() const; std::string get_label(int pos) const override { return get_label(pos, ltHeightWithLayer); } diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index d6188f3d92..fd94bbe57d 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -303,7 +303,11 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode if (viewer != nullptr) { ImGuiWrapper& imgui = *wxGetApp().imgui(); const Size cnv_size = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size(); - ImGuiPureWrap::set_next_window_pos(0.5f * static_cast(cnv_size.get_width()), static_cast(cnv_size.get_height()), ImGuiCond_Always, 0.5f, 1.0f); + + Preview* preview = dynamic_cast(wxGetApp().plater()->get_current_canvas3D()->get_wxglcanvas_parent()); + assert(preview); + + ImGuiPureWrap::set_next_window_pos(0.5f * static_cast(cnv_size.get_width()), static_cast(cnv_size.get_height() - preview->get_moves_slider_height()), ImGuiCond_Always, 0.5f, 1.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); ImGui::SetNextWindowBgAlpha(0.25f); ImGuiPureWrap::begin(std::string("ToolPosition"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove); @@ -430,7 +434,7 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode if (table_shown) { static float table_wnd_height = 0.0f; const ImVec2 wnd_size = ImGui::GetWindowSize(); - ImGuiPureWrap::set_next_window_pos(ImGui::GetWindowPos().x + wnd_size.x, static_cast(cnv_size.get_height()), ImGuiCond_Always, 0.0f, 1.0f); + ImGuiPureWrap::set_next_window_pos(ImGui::GetWindowPos().x + wnd_size.x, static_cast(cnv_size.get_height() - preview->get_moves_slider_height()), ImGuiCond_Always, 0.0f, 1.0f); ImGui::SetNextWindowSizeConstraints({ 0.0f, 0.0f }, { -1.0f, wnd_size.y }); ImGuiPureWrap::begin(std::string("ToolPositionTableWnd"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 0348f811d9..1348564a4f 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1353,6 +1353,11 @@ void GLCanvas3D::post_event(wxEvent &&event) wxPostEvent(m_canvas, event); } +wxWindow* GLCanvas3D::get_wxglcanvas_parent() +{ + return m_canvas->GetParent(); +} + bool GLCanvas3D::init() { if (m_initialized) diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index ccc29d4b84..09ff631ed5 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -689,6 +689,8 @@ public: wxGLCanvas* get_wxglcanvas() { return m_canvas; } const wxGLCanvas* get_wxglcanvas() const { return m_canvas; } + wxWindow* get_wxglcanvas_parent(); + bool init(); void post_event(wxEvent &&event); diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index d7b4d4b0aa..41c8d7828d 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1837,7 +1837,7 @@ bool GUI_App::suppress_round_corners() const wxSize GUI_App::get_min_size(wxWindow* display_win) const { - wxSize min_size(120 * m_em_unit, 49 * m_em_unit); + wxSize min_size(76 * m_em_unit, 49 * m_em_unit); const wxDisplay display = wxDisplay(display_win); wxRect display_rect = display.GetGeometry(); diff --git a/src/slic3r/GUI/ImGuiDoubleSlider.cpp b/src/slic3r/GUI/ImGuiDoubleSlider.cpp index d78a47e634..39cbc78844 100644 --- a/src/slic3r/GUI/ImGuiDoubleSlider.cpp +++ b/src/slic3r/GUI/ImGuiDoubleSlider.cpp @@ -83,11 +83,11 @@ static bool behavior(ImGuiID id, const ImRect& region, ImRect ImGuiControl::DrawOptions::groove(const ImVec2& pos, const ImVec2& size, bool is_horizontal) const { ImVec2 groove_start = is_horizontal ? - ImVec2(pos.x + thumb_dummy_sz().x, pos.y + size.y - groove_sz().y - dummy_sz().y) : + ImVec2(pos.x + thumb_dummy_sz().x + text_dummy_sz().x, pos.y + size.y - groove_sz().y - dummy_sz().y) : ImVec2(pos.x + size.x - groove_sz().x - dummy_sz().x, pos.y + text_dummy_sz().y); ImVec2 groove_size = is_horizontal ? - ImVec2(size.x - 2 * thumb_dummy_sz().x - text_dummy_sz().x, groove_sz().y) : - ImVec2(groove_sz().x, size.y - 1.6 * text_dummy_sz().y); + ImVec2(size.x - 2 * (thumb_dummy_sz().x + text_dummy_sz().x), groove_sz().y) : + ImVec2(groove_sz().x, size.y - 2 * text_dummy_sz().y); return ImRect(groove_start, groove_start + groove_size); } @@ -283,7 +283,7 @@ void ImGuiControl::draw_background(const ImRect& slideable_region) ImGui::RenderFrame(groove.Min, groove.Max, groove_bg_clr, false, 0.5 * groove.GetWidth()); } -void ImGuiControl::draw_label(std::string label, const ImRect& thumb) +void ImGuiControl::draw_label(std::string label, const ImRect& thumb, bool is_mirrored /*= false*/, bool with_border /*= false*/) { if (label.empty() || label == "ErrVal") return; @@ -291,20 +291,64 @@ void ImGuiControl::draw_label(std::string label, const ImRect& thumb) const ImVec2 thumb_center = thumb.GetCenter(); ImVec2 text_padding = m_draw_opts.text_padding(); float rounding = m_draw_opts.rounding(); - ImVec2 triangle_offsets[3] = { ImVec2(2.0f, 0.0f) * m_draw_opts.scale, ImVec2(0.0f, 8.0f) * m_draw_opts.scale, ImVec2(9.0f, 0.0f) * m_draw_opts.scale }; + + float triangle_offset_x = 9.f * m_draw_opts.scale; + float triangle_offset_y = 8.f * m_draw_opts.scale; ImVec2 text_content_size = ImGui::CalcTextSize(label.c_str()); ImVec2 text_size = text_content_size + text_padding * 2; ImVec2 text_start = is_horizontal() ? - ImVec2(thumb.Max.x + triangle_offsets[2].x, thumb_center.y - text_size.y) : - ImVec2(thumb.Min.x - text_size.x - triangle_offsets[2].x, thumb_center.y - text_size.y) ; + ImVec2(thumb.Max.x + triangle_offset_x, thumb_center.y - text_size.y) : + ImVec2(thumb.Min.x - text_size.x - triangle_offset_x, thumb_center.y - text_size.y) ; + + if (is_mirrored) + text_start = is_horizontal() ? + ImVec2(thumb.Min.x - text_size.x - triangle_offset_x, thumb_center.y - text_size.y) : + ImVec2(thumb.Min.x - text_size.x - triangle_offset_x, thumb_center.y) ; + ImRect text_rect(text_start, text_start + text_size); + if (with_border) { + + float rounding_b = 0.75f * rounding; + + ImRect text_rect_b(text_rect); + text_rect_b.Expand(ImVec2(rounding_b, rounding_b)); + + float triangle_offset_x_b = triangle_offset_x + rounding_b; + float triangle_offset_y_b = triangle_offset_y + rounding_b; + + ImVec2 pos_1 = is_horizontal() ? + ImVec2(text_rect_b.Min.x + rounding_b, text_rect_b.Max.y) : + ImVec2(text_rect_b.Max.x - rounding_b, text_rect_b.Max.y); + ImVec2 pos_2 = is_horizontal() ? pos_1 - ImVec2(triangle_offset_x_b, 0.f) : pos_1 - ImVec2(0.f, triangle_offset_y_b); + ImVec2 pos_3 = is_horizontal() ? pos_1 - ImVec2(0.f, triangle_offset_y_b) : pos_1 + ImVec2(triangle_offset_x_b, 0.f); + + if (is_mirrored) { + pos_1 = is_horizontal() ? + ImVec2(text_rect_b.Max.x - rounding_b - 1, text_rect_b.Max.y - 1) : + ImVec2(text_rect_b.Max.x - rounding_b, text_rect_b.Min.y); + pos_2 = is_horizontal() ? pos_1 + ImVec2(triangle_offset_x_b, 0.f) : pos_1 + ImVec2(0.f, triangle_offset_y_b); + pos_3 = is_horizontal() ? pos_1 - ImVec2(0.f, triangle_offset_y_b) : pos_1 + ImVec2(triangle_offset_x_b, 0.f); + } + + ImGui::RenderFrame(text_rect_b.Min, text_rect_b.Max, thumb_bg_clr, true, rounding); + ImGui::GetCurrentWindow()->DrawList->AddTriangleFilled(pos_1, pos_2, pos_3, thumb_bg_clr); + } + ImVec2 pos_1 = is_horizontal() ? - ImVec2(text_rect.Min.x + triangle_offsets[0].x, text_rect.Max.y - triangle_offsets[0].y) : - text_rect.Max - triangle_offsets[0]; - ImVec2 pos_2 = is_horizontal() ? pos_1 - triangle_offsets[2] : pos_1 - triangle_offsets[1]; - ImVec2 pos_3 = is_horizontal() ? pos_1 - triangle_offsets[1] : pos_1 + triangle_offsets[2]; + ImVec2(text_rect.Min.x + rounding, text_rect.Max.y) : + ImVec2(text_rect.Max.x - rounding, text_rect.Max.y); + ImVec2 pos_2 = is_horizontal() ? pos_1 - ImVec2(triangle_offset_x, 0.f) : pos_1 - ImVec2(0.f, triangle_offset_y); + ImVec2 pos_3 = is_horizontal() ? pos_1 - ImVec2(0.f, triangle_offset_y) : pos_1 + ImVec2(triangle_offset_x, 0.f); + + if (is_mirrored) { + pos_1 = is_horizontal() ? + ImVec2(text_rect.Max.x - rounding-1, text_rect.Max.y-1) : + ImVec2(text_rect.Max.x - rounding, text_rect.Min.y); + pos_2 = is_horizontal() ? pos_1 + ImVec2(triangle_offset_x, 0.f) : pos_1 + ImVec2(0.f, triangle_offset_y); + pos_3 = is_horizontal() ? pos_1 - ImVec2(0.f, triangle_offset_y) : pos_1 + ImVec2(triangle_offset_x, 0.f); + } ImGui::RenderFrame(text_rect.Min, text_rect.Max, tooltip_bg_clr, true, rounding); ImGui::GetCurrentWindow()->DrawList->AddTriangleFilled(pos_1, pos_2, pos_3, tooltip_bg_clr); @@ -490,13 +534,17 @@ bool ImGuiControl::draw_slider( int* higher_pos, int* lower_pos, draw_label(higher_label, m_regions.higher_thumb); if (m_draw_lower_thumb && !m_combine_thumbs) { + ImVec2 text_size = ImGui::CalcTextSize(lower_label.c_str()) + m_draw_opts.text_padding() * 2.f; + const bool mirror_label = is_horizontal() ? (higher_thumb_center.x - lower_thumb_center.x < text_size.x) : + (lower_thumb_center.y - higher_thumb_center.y < text_size.y); + draw_thumb(lower_thumb_center, m_selection == ssLower); - draw_label(lower_label, m_regions.lower_thumb); + draw_label(lower_label, m_regions.lower_thumb, mirror_label); } // draw label on mouse move if (show_move_label) - draw_label(get_label_on_move(m_mouse_pos), mouse_pos_rc); + draw_label(get_label_on_move(m_mouse_pos), mouse_pos_rc, false, true); return pos_changed; } diff --git a/src/slic3r/GUI/ImGuiDoubleSlider.hpp b/src/slic3r/GUI/ImGuiDoubleSlider.hpp index 59493e8880..8530f08188 100644 --- a/src/slic3r/GUI/ImGuiDoubleSlider.hpp +++ b/src/slic3r/GUI/ImGuiDoubleSlider.hpp @@ -100,7 +100,7 @@ private: struct DrawOptions { float scale { 1.f }; // used for Retina on osx - ImVec2 dummy_sz() const { return ImVec2(24.0f, 22.0f) * scale; } + ImVec2 dummy_sz() const { return ImVec2(24.0f, 16.0f) * scale; } ImVec2 thumb_dummy_sz() const { return ImVec2(17.0f, 17.0f) * scale; } ImVec2 groove_sz() const { return ImVec2(4.0f, 4.0f) * scale; } ImVec2 draggable_region_sz()const { return ImVec2(20.0f, 19.0f) * scale; } @@ -160,7 +160,7 @@ private: void draw_scroll_line(const ImRect& scroll_line, const ImRect& slideable_region); void draw_background(const ImRect& slideable_region); - void draw_label(std::string label, const ImRect& thumb); + void draw_label(std::string label, const ImRect& thumb, bool is_mirrored = false, bool with_border = false); void draw_thumb(const ImVec2& center, bool mark = false); bool draw_slider(int* higher_pos, int* lower_pos, std::string& higher_label, std::string& lower_label, diff --git a/src/slic3r/GUI/NotificationManager.cpp b/src/slic3r/GUI/NotificationManager.cpp index 2cbc89f577..006f631b91 100644 --- a/src/slic3r/GUI/NotificationManager.cpp +++ b/src/slic3r/GUI/NotificationManager.cpp @@ -176,8 +176,8 @@ void NotificationManager::PopNotification::render(GLCanvas3D& canvas, float init ImVec2 win_pos(1.0f * (float)cnv_size.get_width() - right_gap, 1.0f * (float)cnv_size.get_height() - m_top_y); if (wxGetApp().plater()->is_preview_shown()) { - if (Preview* preview = dynamic_cast(canvas.get_wxglcanvas()->GetParent())) { - win_pos.y -= 1.5f * preview->get_moves_slider_height(); + if (Preview* preview = dynamic_cast(canvas.get_wxglcanvas_parent())) { + win_pos.y -= preview->get_moves_slider_height(); win_pos.x -= preview->get_layers_slider_width(); } } diff --git a/src/slic3r/GUI/TopBar.cpp b/src/slic3r/GUI/TopBar.cpp index 2268676f85..b984ec1180 100644 --- a/src/slic3r/GUI/TopBar.cpp +++ b/src/slic3r/GUI/TopBar.cpp @@ -333,24 +333,11 @@ void TopBarItemsCtrl::UpdateSearchSizeAndPosition() int em = em_unit(this); - int btns_width = 2 * m_btn_margin; - if (m_menu_btn) - btns_width += m_menu_btn->GetSize().GetWidth(); - else - btns_width += 4 * em; - - if (m_settings_btn) - btns_width += m_settings_btn->GetSize().GetWidth() + m_btn_margin; - else { - for (const Button* btn : m_pageButtons) - btns_width += btn->GetSize().GetWidth() + m_btn_margin; - } - wxWindow* parent_win = GetParent()->GetParent(); int top_win_without_sidebar = parent_win->GetSize().GetWidth() - 42 * em; bool update_bnts{ false }; - if (top_win_without_sidebar - btns_width < 15 * em) { + if (top_win_without_sidebar - m_btns_width < 15 * em) { if (!m_collapsed_btns) { m_sizer->SetItemMinSize(1, wxSize(20, -1)); m_collapsed_btns = update_bnts = true; @@ -388,11 +375,53 @@ wxPoint TopBarItemsCtrl::ButtonWithPopup::get_popup_pos() return pos; } +void TopBarItemsCtrl::update_btns_width() +{ + int em = em_unit(this); + + m_btns_width = 2 * m_btn_margin; + if (m_menu_btn) + m_btns_width += m_menu_btn->GetSize().GetWidth(); + else + m_btns_width += 4 * em; + + if (m_settings_btn) + m_btns_width += m_settings_btn->GetSize().GetWidth() + m_btn_margin; + else { + for (const Button* btn : m_pageButtons) + m_btns_width += btn->GetSize().GetWidth() + m_btn_margin; + } + + // Check min width of parent and change it if needed + + int sizebar_w = 25; + + wxWindow* parent_win = GetParent()->GetParent(); + int top_win_without_sidebar = parent_win->GetSize().GetWidth() - sizebar_w * em; + + if (top_win_without_sidebar < 0) + return; + + wxSize min_sz = parent_win->GetMinSize(); + if (m_btns_width < (76 - sizebar_w) * em) { + if (min_sz.GetWidth() > 76 * em) + parent_win->SetMinSize(wxSize(76 * em, 49 * em)); + } + else { + wxSize new_size = wxSize(m_btns_width + sizebar_w * em, 49 * em); + parent_win->SetMinSize(new_size); + if (top_win_without_sidebar < m_btns_width) + parent_win->SetSize(new_size); + } +} + TopBarItemsCtrl::TopBarItemsCtrl(wxWindow *parent, TopBarMenus* menus/* = nullptr*/, bool is_main/* = true*/) : wxControl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE | wxTAB_TRAVERSAL) ,m_menus(menus) { -#ifdef __WINDOWS__ + wxGetApp().UpdateDarkUI(this); + +#ifdef _WIN32 SetDoubleBuffered(true); #endif //__WINDOWS__ update_margins(); @@ -461,19 +490,13 @@ TopBarItemsCtrl::TopBarItemsCtrl(wxWindow *parent, TopBarMenus* menus/* = nullpt m_sizer->SetItemMinSize(1, wxSize(42 * wxGetApp().em_unit(), -1)); - this->Bind(wxEVT_PAINT, &TopBarItemsCtrl::OnPaint, this); - this->Bind(wxEVT_UPDATE_UI, [](wxUpdateUIEvent& evt) { auto user_account = wxGetApp().plater()->get_user_account(); evt.Enable(user_account ? user_account->is_logged() : false); evt.Check (user_account ? user_account->get_remember_session() : false); }, m_menus->remember_me_item_id); -} -void TopBarItemsCtrl::OnPaint(wxPaintEvent&) -{ - wxGetApp().UpdateDarkUI(this); - m_search->Refresh(); + update_btns_width(); } void TopBarItemsCtrl::UpdateMode() @@ -502,11 +525,11 @@ void TopBarItemsCtrl::Rescale() m_search->SetMinSize(wxSize(4 * em, -1)); m_search->SetMaxSize(wxSize(42 * em, -1)); m_search->Rescale(); - m_sizer->SetItemMinSize(1, wxSize(42 * em, -1)); m_buttons_sizer->SetVGap(m_btn_margin); m_buttons_sizer->SetHGap(m_btn_margin); + update_btns_width(); UpdateSearchSizeAndPosition(); m_sizer->Layout(); } @@ -571,6 +594,7 @@ bool TopBarItemsCtrl::InsertPage(size_t n, const wxString& text, bool bSelect/* m_buttons_sizer->Insert(n, new wxSizerItem(btn, 0, wxALIGN_CENTER_VERTICAL)); m_buttons_sizer->SetCols(m_buttons_sizer->GetCols() + 1); + update_btns_width(); UpdateSearchSizeAndPosition(); m_sizer->Layout(); return true; @@ -586,6 +610,7 @@ void TopBarItemsCtrl::RemovePage(size_t n) this->RemoveChild(btn); btn->Destroy(); + update_btns_width(); UpdateSearchSizeAndPosition(); m_sizer->Layout(); } @@ -594,6 +619,7 @@ void TopBarItemsCtrl::SetPageText(size_t n, const wxString& strText) { ScalableButton* btn = m_pageButtons[n]; btn->SetLabel(strText); + update_btns_width(); UpdateSearchSizeAndPosition(); } @@ -614,7 +640,7 @@ void TopBarItemsCtrl::ShowFull() m_account_btn->set_selected(true); m_menus->Popup(this, &m_menus->account, m_account_btn->get_popup_pos()); }); - + update_btns_width(); UpdateSearchSizeAndPosition(); } @@ -626,7 +652,7 @@ void TopBarItemsCtrl::ShowJustMode() m_settings_btn->Hide(); m_account_btn->Hide(); m_menus->set_cb_on_user_item(nullptr); - + update_btns_width(); UpdateSearchSizeAndPosition(); } diff --git a/src/slic3r/GUI/TopBar.hpp b/src/slic3r/GUI/TopBar.hpp index bb79cf542e..252a24e69f 100644 --- a/src/slic3r/GUI/TopBar.hpp +++ b/src/slic3r/GUI/TopBar.hpp @@ -61,15 +61,17 @@ class TopBarItemsCtrl : public wxControl ::TextInput* m_search{ nullptr }; + int m_btns_width{ 0 }; bool m_collapsed_btns{ false }; + void update_btns_width(); + public: TopBarItemsCtrl(wxWindow* parent, TopBarMenus* menus = nullptr, bool is_main = true); ~TopBarItemsCtrl() {} - void OnPaint(wxPaintEvent&); void SetSelection(int sel, bool force = false); void UpdateMode(); void Rescale();