From 050742a9209c1eaebacf78fc456c20e08ee4f8dd Mon Sep 17 00:00:00 2001 From: ErrorFlynn Date: Mon, 5 Aug 2019 14:11:02 -0400 Subject: [PATCH 1/2] 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 41347095..2db0e5ab 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -2308,7 +2308,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 @@ -6073,7 +6074,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 From 0f1b5edc409ad9871f1d7a46ee45f9a46f21ff4a Mon Sep 17 00:00:00 2001 From: Yuchen Deng Date: Mon, 12 Aug 2019 21:03:59 +0800 Subject: [PATCH 2/2] fix compatibility on macOS --- include/nana/c++defines.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/nana/c++defines.hpp b/include/nana/c++defines.hpp index 4f00e5f9..4dc62a65 100644 --- a/include/nana/c++defines.hpp +++ b/include/nana/c++defines.hpp @@ -89,7 +89,7 @@ #define NANA_MINGW #endif // MINGW -#elif defined(APPLE) //Mac OS X +#elif defined(__APPLE__) || defined(APPLE) //Mac OS X //Symbols for MACOS #define NANA_MACOS #define NANA_POSIX @@ -252,7 +252,7 @@ # if __has_include() # undef STD_FILESYSTEM_NOT_SUPPORTED # endif -# if __has_include() +# if __has_include() # if !(defined(NANA_MINGW) && !defined(_GLIBCXX_HAS_GTHREADS)) //See the comment above regarding MinGW's threading support # undef STD_THREAD_NOT_SUPPORTED