From 1b0ac1047562a14ced6d4f46cdef057f5b952880 Mon Sep 17 00:00:00 2001 From: ErrorFlynn Date: Mon, 5 Aug 2019 14:11:02 -0400 Subject: [PATCH] fixes for the listbox bugs described in issue #472 --- source/gui/widgets/listbox.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 7201af43..2a984cf5 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -2300,7 +2300,8 @@ namespace nana size_type count_of_exposed(bool with_rest) const { auto lister_s = this->content_view->view_area().height; - return (lister_s / item_height()) + (with_rest && (lister_s % item_height()) ? 1 : 0); + return (lister_s / item_height()) + (with_rest && + listbox_ptr->scroll_operation()->visible(true) && (lister_s % item_height()) ? 1 : 0); } void update(bool ignore_auto_draw = false) noexcept @@ -6062,7 +6063,15 @@ namespace nana auto listbox::last_visible() const -> index_pair { - return _m_ess().lister.advance(_m_ess().first_display(), static_cast(_m_ess().count_of_exposed(true))); + if(!const_cast(this)->scroll_operation()->visible(true)) + { + auto last_cat = size_categ()-1; + index_pair ip(last_cat, at(last_cat).size()-1); + if(last_cat == 0 && ip.item == npos) // if the listbox is empty + ip.cat = npos; // return empty index_pair + return ip; + } + return _m_ess().lister.advance(_m_ess().first_display(), static_cast(_m_ess().count_of_exposed(true)-1)); } auto listbox::visibles() const -> index_pairs