From bbe2aca4834e30a5b15ab41e898ea774f1f7d1af Mon Sep 17 00:00:00 2001 From: Jinhao Date: Fri, 21 Sep 2018 01:47:34 +0800 Subject: [PATCH] fix bug that treebox.scroll_into_view() generated a wrong position --- source/gui/widgets/treebox.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/source/gui/widgets/treebox.cpp b/source/gui/widgets/treebox.cpp index 30739d1c..195f6900 100644 --- a/source/gui/widgets/treebox.cpp +++ b/source/gui/widgets/treebox.cpp @@ -643,16 +643,11 @@ namespace nana { auto const short_side = (std::min)(pos, last_pos - pos); if (short_side >= capacity / 2) - { - pos = short_side - capacity / 2; - } + pos -= capacity / 2; + else if (short_side == pos || (last_pos + 1 < capacity)) + pos = 0; else - { - if (short_side == pos || (last_pos + 1 < capacity)) - pos = 0; - else - pos = last_pos + 1 - capacity; - } + pos = last_pos + 1 - capacity; } else if (align_v::bottom == bearing) {