From 6bd54f011216dcd29644a20725dde45972ee4634 Mon Sep 17 00:00:00 2001 From: bubnikv <bubnikv@gmail.com> Date: Tue, 9 Apr 2019 13:13:42 +0200 Subject: [PATCH] Hopefully fixing the "scroll to the first selected line" issue at the object list. --- src/slic3r/GUI/2DBed.cpp | 8 ++++---- src/slic3r/GUI/GUI_ObjectList.cpp | 19 +++---------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/slic3r/GUI/2DBed.cpp b/src/slic3r/GUI/2DBed.cpp index eb55d5fdc..ce2012461 100644 --- a/src/slic3r/GUI/2DBed.cpp +++ b/src/slic3r/GUI/2DBed.cpp @@ -18,10 +18,10 @@ wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(25 * wxGetApp().em_unit(), - #ifdef __APPLE__ m_user_drawn_background = false; #endif /*__APPLE__*/ - Bind(wxEVT_PAINT, ([this](wxPaintEvent e) { repaint(); })); - Bind(wxEVT_LEFT_DOWN, ([this](wxMouseEvent event) { mouse_event(event); })); - Bind(wxEVT_MOTION, ([this](wxMouseEvent event) { mouse_event(event); })); - Bind(wxEVT_SIZE, ([this](wxSizeEvent e) { Refresh(); })); + Bind(wxEVT_PAINT, ([this](wxPaintEvent &/* e */) { repaint(); })); + Bind(wxEVT_LEFT_DOWN, ([this](wxMouseEvent &event) { mouse_event(event); })); + Bind(wxEVT_MOTION, ([this](wxMouseEvent &event) { mouse_event(event); })); + Bind(wxEVT_SIZE, ([this](wxSizeEvent & /* e */) { Refresh(); })); } void Bed_2D::repaint() { diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 37d30bbe2..e6b99bdb3 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -141,6 +141,8 @@ ObjectList::ObjectList(wxWindow* parent) : #ifdef __WXOSX__ Bind(wxEVT_KEY_DOWN, &ObjectList::OnChar, this); #endif //__WXOSX__ + + Bind(wxEVT_SIZE, ([this](wxSizeEvent &e) { this->EnsureVisible(this->GetCurrentItem()); e.Skip(); })); } ObjectList::~ObjectList() @@ -2071,23 +2073,8 @@ void ObjectList::update_selections() select_items(sels); - /* Because of ScrollLines() and GetItemRect() functions are implemented - * only for GENERIC DataViewCtrl in current version of wxWidgets, - * use this part of code only for MSW - */ -#if defined(wxUSE_GENERICDATAVIEWCTRL) // Scroll selected Item in the middle of an object list - if (GetSelection()) { - const wxRect& sel_rc = GetItemRect(GetSelection()); - const wxRect& main_rc = GetClientRect(); - if (sel_rc.GetBottom() <= main_rc.GetTop()+sel_rc.height || - sel_rc.GetTop() >= main_rc.GetBottom() ) - { - const wxRect& top_rc = GetItemRect(GetTopItem()); - ScrollLines(int((sel_rc.y - top_rc.y) / top_rc.GetHeight()) - 0.5*GetCountPerPage()); - } - } -#endif + this->EnsureVisible(this->GetCurrentItem()); } void ObjectList::update_selections_on_canvas()