* use BListItem::Height() consistently (clicking a nick in Vision now selects
that same nick, not a different one) * performance improvement in Draw() (using ItemFrame() in the inner loop scales really bad) * fixed scroll range for when BListItem::Height() is non-integer (scrolling all the way to the bottom in Visions nick list works now) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22835 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -187,11 +187,19 @@ BListView::Archive(BMessage *archive, bool deep) const
|
|||||||
void
|
void
|
||||||
BListView::Draw(BRect updateRect)
|
BListView::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < CountItems(); i++) {
|
int32 count = CountItems();
|
||||||
BRect itemFrame = ItemFrame(i);
|
if (count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
BRect itemFrame(Bounds().left, 0, Bounds().right, -1);
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
BListItem* item = ItemAt(i);
|
||||||
|
itemFrame.bottom = itemFrame.top + ceilf(item->Height()) - 1;
|
||||||
|
|
||||||
if (itemFrame.Intersects(updateRect))
|
if (itemFrame.Intersects(updateRect))
|
||||||
DrawItem(((BListItem*)ItemAt(i)), itemFrame);
|
DrawItem(item, itemFrame);
|
||||||
|
|
||||||
|
itemFrame.top = itemFrame.bottom + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,7 +704,7 @@ BListView::IndexOf(BPoint point) const
|
|||||||
|
|
||||||
// TODO: somehow binary search, but items don't know their frame
|
// TODO: somehow binary search, but items don't know their frame
|
||||||
for (int i = 0; i < fList.CountItems(); i++) {
|
for (int i = 0; i < fList.CountItems(); i++) {
|
||||||
y += ItemAt(i)->Height();
|
y += ceilf(ItemAt(i)->Height());
|
||||||
|
|
||||||
if (point.y < y)
|
if (point.y < y)
|
||||||
return i;
|
return i;
|
||||||
@@ -1010,7 +1018,7 @@ BListView::FrameMoved(BPoint new_position)
|
|||||||
BRect
|
BRect
|
||||||
BListView::ItemFrame(int32 index)
|
BListView::ItemFrame(int32 index)
|
||||||
{
|
{
|
||||||
BRect frame(0, 0, Bounds().Width(), -1);
|
BRect frame(Bounds().left, 0, Bounds().right, -1);
|
||||||
|
|
||||||
if (index < 0 || index >= CountItems())
|
if (index < 0 || index >= CountItems())
|
||||||
return frame;
|
return frame;
|
||||||
@@ -1018,7 +1026,7 @@ BListView::ItemFrame(int32 index)
|
|||||||
// TODO: this is very expensive, the (last) offsets could be cached
|
// TODO: this is very expensive, the (last) offsets could be cached
|
||||||
for (int32 i = 0; i <= index; i++) {
|
for (int32 i = 0; i <= index; i++) {
|
||||||
frame.top = frame.bottom + 1;
|
frame.top = frame.bottom + 1;
|
||||||
frame.bottom += (float)ceil(ItemAt(i)->Height());
|
frame.bottom = frame.top + ceilf(ItemAt(i)->Height()) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return frame;
|
return frame;
|
||||||
@@ -1200,9 +1208,8 @@ BListView::_FixupScrollBar()
|
|||||||
int32 count = CountItems();
|
int32 count = CountItems();
|
||||||
|
|
||||||
float itemHeight = 0;
|
float itemHeight = 0;
|
||||||
for (int32 i = 0; BListItem* item = ItemAt(i); i++) {
|
for (int32 i = 0; i < count; i++)
|
||||||
itemHeight += item->Height();
|
itemHeight += ceilf(ItemAt(i)->Height());
|
||||||
}
|
|
||||||
|
|
||||||
if (bounds.Height() > itemHeight) {
|
if (bounds.Height() > itemHeight) {
|
||||||
// no scrolling
|
// no scrolling
|
||||||
@@ -1218,10 +1225,8 @@ BListView::_FixupScrollBar()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count != 0) {
|
if (count != 0)
|
||||||
vertScroller->SetSteps((float)ceil(FirstItem()->Height()),
|
vertScroller->SetSteps(ceilf(FirstItem()->Height()), bounds.Height());
|
||||||
bounds.Height());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// _InvalidateFrom
|
// _InvalidateFrom
|
||||||
|
|||||||
Reference in New Issue
Block a user