- Fix an error in SwapItems where the item tops would not be swapped
if the items were the same height. - Modified _RecalcItemTops to allow us to specify a range instead of just a starting point. This is useful for cases like Swap, where only the items in between those being swapped need to be recalculated. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24139 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
d6fdcf4304
commit
43948ef628
@ -160,7 +160,7 @@ class BListView : public BView, public BInvoker {
|
||||
bool _TryInitiateDrag(BPoint where);
|
||||
int32 _CalcFirstSelected(int32 after);
|
||||
int32 _CalcLastSelected(int32 before);
|
||||
void _RecalcItemTops(int32 start);
|
||||
void _RecalcItemTops(int32 start, int32 end = -1);
|
||||
virtual void DrawItem(BListItem* item, BRect itemRect,
|
||||
bool complete = false);
|
||||
|
||||
|
@ -1531,25 +1531,24 @@ BListView::_SwapItems(int32 a, int32 b)
|
||||
// track selection
|
||||
// NOTE: this is only important if the selection status
|
||||
// of both items is not the same
|
||||
int32 first = min_c(a, b);
|
||||
int32 last = max_c(a, b);
|
||||
if (ItemAt(a)->IsSelected() != ItemAt(b)->IsSelected()) {
|
||||
int32 first = min_c(a, b);
|
||||
int32 last = max_c(a, b);
|
||||
if (first < fFirstSelected || last > fLastSelected) {
|
||||
first = min_c(first, fFirstSelected);
|
||||
last = max_c(last, fLastSelected);
|
||||
_RescanSelection(first, last);
|
||||
}
|
||||
if (first < fFirstSelected || last > fLastSelected)
|
||||
_RescanSelection(min_c(first, fFirstSelected), min_c(last, fLastSelected));
|
||||
// though the actually selected items stayed the
|
||||
// same, the selection has still changed
|
||||
SelectionChanged();
|
||||
}
|
||||
|
||||
ItemAt(a)->SetTop(bFrame.top);
|
||||
ItemAt(b)->SetTop(aFrame.top);
|
||||
|
||||
// take care of invalidation
|
||||
if (Window()) {
|
||||
// NOTE: window looper is assumed to be locked!
|
||||
if (aFrame.Height() != bFrame.Height()) {
|
||||
ItemAt(a)->SetTop(bFrame.top);
|
||||
ItemAt(b)->SetTop(aFrame.top);
|
||||
_RecalcItemTops(first, last);
|
||||
// items in between shifted visually
|
||||
Invalidate(aFrame | bFrame);
|
||||
} else {
|
||||
@ -1676,14 +1675,18 @@ BListView::_RescanSelection(int32 from, int32 to)
|
||||
}
|
||||
|
||||
void
|
||||
BListView::_RecalcItemTops(int32 start)
|
||||
BListView::_RecalcItemTops(int32 start, int32 end)
|
||||
{
|
||||
int32 count = CountItems();
|
||||
if ((start < 0) || (start >= count))
|
||||
return;
|
||||
|
||||
if (end >= 0)
|
||||
count = end + 1;
|
||||
|
||||
float top = (start == 0) ? 0.0 : ItemAt(start - 1)->Bottom() + 1.0;
|
||||
|
||||
for (int32 i = start; i < CountItems(); i++) {
|
||||
for (int32 i = start; i < count; i++) {
|
||||
BListItem *item = ItemAt(i);
|
||||
item->SetTop(top);
|
||||
top += ceilf(item->Height());
|
||||
|
Loading…
x
Reference in New Issue
Block a user