From 4eded76136799bbd92ee0d3ca099adb90b3c1296 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 12 Nov 2020 10:13:16 +0100 Subject: [PATCH] Custom controls : The width for full_width fields is updated according to the custom control width (thanks to the @supermerill for the mention on it, https://github.com/prusa3d/PrusaSlicer/pull/5135/commits/6acf6bdf2110b3a8b7c54a0450ae1437176d2027) + Deleted redundant background color, as mentioned in the #5062 --- src/slic3r/GUI/OG_CustomCtrl.cpp | 17 ++++------------- src/slic3r/GUI/OptionsGroup.cpp | 6 +----- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/slic3r/GUI/OG_CustomCtrl.cpp b/src/slic3r/GUI/OG_CustomCtrl.cpp index af9aeb42e..7feaacedc 100644 --- a/src/slic3r/GUI/OG_CustomCtrl.cpp +++ b/src/slic3r/GUI/OG_CustomCtrl.cpp @@ -205,12 +205,6 @@ wxPoint OG_CustomCtrl::get_pos(const Line& line, Field* field_in/* = nullptr*/) void OG_CustomCtrl::OnPaint(wxPaintEvent&) { -#ifdef _WIN32 - SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); -#else - SetBackgroundColour(GetParent()->GetBackgroundColour()); -#endif // _WIN32 - // case, when custom controll is destroyed but doesn't deleted from the evet loop if(!this->opt_group->custom_ctrl) return; @@ -424,12 +418,6 @@ void OG_CustomCtrl::CtrlLine::msw_rescale() wxSize label_sz = ctrl->GetTextExtent(og_line.label); height = label_sz.y * (label_sz.GetWidth() > int(ctrl->opt_group->label_width * ctrl->m_em_unit) ? 2 : 1) + ctrl->m_v_gap; } - - if (og_line.get_options().front().opt.full_width) { - Field* field = ctrl->opt_group->get_field(og_line.get_options().front().opt_id); - if (field->getWindow()) - field->getWindow()->SetSize(wxSize(3 * Field::def_width_wider() * ctrl->m_em_unit, -1)); - } correct_items_positions(); } @@ -509,7 +497,10 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord v_pos) option_set.front().side_widget == nullptr && og_line.get_extra_widgets().size() == 0) { if (field && field->undo_to_sys_bitmap()) - draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->bmp(), field->undo_bitmap()->bmp(), field->blink()); + h_pos = draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->bmp(), field->undo_bitmap()->bmp(), field->blink()) + ctrl->m_h_gap; + // update width for full_width fields + if (option_set.front().opt.full_width && field->getWindow()) + field->getWindow()->SetSize(ctrl->GetSize().x - h_pos, -1); return; } diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index fe935dce2..b1065da66 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -296,11 +296,7 @@ void OptionsGroup::activate_line(Line& line) const auto& option = option_set.front(); const auto& field = build_field(option); - if (custom_ctrl) { - if (is_window_field(field) && option.opt.full_width) - field->getWindow()->SetSize(wxSize(3 * Field::def_width_wider() * wxGetApp().em_unit(), -1)); - } - else { + if (!custom_ctrl) { if (is_window_field(field)) sizer->Add(field->getWindow(), option.opt.full_width ? 1 : 0, wxBOTTOM | wxTOP | (option.opt.full_width ? wxEXPAND : wxALIGN_CENTER_VERTICAL), (wxOSX || !staticbox) ? 0 : 2);