From abda8e55ecdafae446c4abf90d4c9669230f30af Mon Sep 17 00:00:00 2001 From: Jinhao Date: Thu, 4 May 2017 05:08:07 +0800 Subject: [PATCH] fix issue that selection box appears in single selection listbox(#204) --- source/gui/widgets/skeletons/content_view.cpp | 10 ++++++---- source/gui/widgets/skeletons/content_view.hpp | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/source/gui/widgets/skeletons/content_view.cpp b/source/gui/widgets/skeletons/content_view.cpp index 4dfc49a0..df53bcd7 100644 --- a/source/gui/widgets/skeletons/content_view.cpp +++ b/source/gui/widgets/skeletons/content_view.cpp @@ -164,11 +164,9 @@ namespace nana { speed_horz = (std::min)(5, (std::max)(speed_horz, -5)); speed_vert = (std::min)(5, (std::max)(speed_vert, -5)); - view.move_origin({ + return view.move_origin({ speed_horz, speed_vert }); - - return true; } void size_changed(bool try_update) @@ -435,10 +433,12 @@ namespace nana { } } - void content_view::move_origin(const point& skew) + bool content_view::move_origin(const point& skew) { auto imd_area = this->view_area(); + auto pre_origin = impl_->origin; + impl_->origin.x += skew.x; if (impl_->origin.x + imd_area.width > impl_->content_size.width) impl_->origin.x = static_cast(impl_->content_size.width) - static_cast(imd_area.width); @@ -451,6 +451,8 @@ namespace nana { impl_->origin.y = static_cast(impl_->content_size.height) - static_cast(imd_area.height); if (impl_->origin.y < 0) impl_->origin.y = 0; + + return (pre_origin != impl_->origin); } void content_view::sync(bool try_update) diff --git a/source/gui/widgets/skeletons/content_view.hpp b/source/gui/widgets/skeletons/content_view.hpp index 2575fe29..6d4b2d40 100644 --- a/source/gui/widgets/skeletons/content_view.hpp +++ b/source/gui/widgets/skeletons/content_view.hpp @@ -70,7 +70,8 @@ namespace skeletons void change_position(int pos, bool aligned, bool horz); - void move_origin(const point& skew); + /// Returns true if the origin is moved + bool move_origin(const point& skew); void sync(bool try_update);