From 6826c30a259c4ace5774b83ca8eab4c025021741 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 19 Nov 2008 03:54:59 +0000 Subject: [PATCH] When an item is added to the list, we must immediately set its top, otherwise if it tries to make use of any positional information in the subsequent call to Update() (i.e. calls to ItemFrame(), or Top(), it will get back bogus coordinates. This should correctly fix the problems seen with Themes, possibly amongst others. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28692 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/ListView.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/kits/interface/ListView.cpp b/src/kits/interface/ListView.cpp index f4bcd695c5..1d56b62fa8 100644 --- a/src/kits/interface/ListView.cpp +++ b/src/kits/interface/ListView.cpp @@ -533,8 +533,10 @@ BListView::AddItem(BListItem *item, int32 index) if (Window()) { BFont font; GetFont(&font); + item->SetTop((index > 0) ? ItemAt(index - 1)->Bottom() + 1.0 : 0.0); + item->Update(this, &font); - _RecalcItemTops(index); + _RecalcItemTops(index + 1); _FixupScrollBar(); _InvalidateFrom(index); @@ -549,15 +551,16 @@ BListView::AddItem(BListItem* item) { if (!fList.AddItem(item)) return false; - // No need to adapt selection, as this item is the last in the list if (Window()) { BFont font; GetFont(&font); + int32 index = CountItems() - 1; + item->SetTop((index > 0) ? ItemAt(index - 1)->Bottom() + 1.0 : 0.0); + item->Update(this, &font); - _RecalcItemTops(CountItems() - 1); - + _FixupScrollBar(); InvalidateItem(CountItems() - 1); } @@ -584,10 +587,12 @@ BListView::AddList(BList* list, int32 index) BFont font; GetFont(&font); - for (int32 i = index; i <= (index + list->CountItems() - 1); i++) + for (int32 i = index; i <= (index + list->CountItems() - 1); i++) { + ItemAt(i)->SetTop((i > 0) ? ItemAt(i - 1)->Bottom() + 1.0 : 0.0); ItemAt(i)->Update(this, &font); - - _RecalcItemTops(index); + } + + _RecalcItemTops(index + list->CountItems() - 1); _FixupScrollBar(); Invalidate(); // TODO