From b87ea830299d95c9336059bf9f6dd1aed2bb3a66 Mon Sep 17 00:00:00 2001 From: mrjtuk Date: Wed, 30 Jul 2008 11:09:43 +0000 Subject: [PATCH] Fixed MultiList scrolling bug git-svn-id: svn://ultimatepp.org/upp/trunk@323 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- bazaar/MultiList/MultiList.cpp | 51 +++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/bazaar/MultiList/MultiList.cpp b/bazaar/MultiList/MultiList.cpp index 2cda5f663..caa6d09f4 100644 --- a/bazaar/MultiList/MultiList.cpp +++ b/bazaar/MultiList/MultiList.cpp @@ -499,13 +499,28 @@ void MultiList::SetSb() int rcnt = GetCount()/ncl; rcnt += (GetCount() % ncl) ? 1 : 0; sb.SetTotal(rcnt*cy); - sb.SetPage((GetSize().cy-cy/2)/cy*cy + cy/4); - sb.SetLine(cy/4); + sb.SetPage((GetSize().cy/cy)*cy); + sb.SetLine(cy); break; } } } +void MultiList::ScrollInto(int pos) +{ + switch (mode) { + case MODE_ROWS: + sb.ScrollInto((pos / ncl) * cy, max(0, sb.GetLine() - (GetSize().cy - sb.GetPage()))); + return; + case MODE_COLUMNS: + sb.ScrollInto(pos / max(1, GetColumnItems())); + return; + case MODE_LIST: + sb.ScrollInto(pos); + return; + } +} + void MultiList::Layout() { if (mode == MODE_ROWS) @@ -597,21 +612,6 @@ void MultiList::SetSbPos(int y) sb = minmax(y, 0, GetCount() - GetPageItems()); } -void MultiList::ScrollInto(int pos) -{ - switch (mode) { - case MODE_ROWS: - sb.ScrollInto(pos / ncl * cy + sb.GetLine()); - return; - case MODE_COLUMNS: - sb.ScrollInto(pos / max(1, GetColumnItems())); - return; - case MODE_LIST: - sb.ScrollInto(pos); - return; - } -} - void MultiList::KillCursor() { if(cursor < 0) return; @@ -1010,8 +1010,21 @@ void MultiList::InsertDrop(int ii, PasteClip& d) void MultiList::Serialize(Stream& s) { int version = 0; - s / version; - s / ncl; + int cnt; + s.Magic(); + s / version / ncl / cnt; + if (s.IsLoading()) + item.SetCount(cnt); + for (int i = 0; i < item.GetCount(); i++) { + Item &q = item[i]; + s % q.key % q.value % q.canselect; + if (s.IsLoading()) { + q.display = NULL; + q.sel = false; + } + } + s.Magic(); + Refresh(); SyncInfo(); }