patch by Rene Gollent:

* BListItems now store the top offset of the frame within the parent BListView.
* This allows binary searching the clicked item.
* ItemFrame() is now a cheap call.
* Fixed several bugs in the sorting code of BOutlineListView which lead to
  crashes of client applications.
* Implemented previously unimplemented functions in BOutlineListView.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24092 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-02-24 14:15:28 +00:00
parent 6213408838
commit fef3930499
5 changed files with 172 additions and 91 deletions
+19 -4
View File
@@ -18,7 +18,8 @@ class BView;
class BListItem : public BArchivable {
public:
BListItem(uint32 outlineLevel = 0, bool expanded = true);
BListItem(uint32 outlineLevel = 0,
bool expanded = true);
BListItem(BMessage* archive);
virtual ~BListItem();
@@ -47,7 +48,7 @@ class BListItem : public BArchivable {
private:
friend class BOutlineListView;
friend class BListView;
bool HasSubitems() const;
virtual void _ReservedListItem1();
@@ -58,9 +59,11 @@ class BListItem : public BArchivable {
bool IsItemVisible() const;
void SetItemVisible(bool visible);
inline float Top() const;
inline float Bottom() const;
void SetTop(float top);
private:
uint32 _reserved[1];
float fTop;
BList* fTemporaryList;
float fWidth;
float fHeight;
@@ -72,6 +75,18 @@ class BListItem : public BArchivable {
bool fVisible : 1;
};
inline float
BListItem::Top(void) const
{
return fTop;
}
inline float
BListItem::Bottom(void) const
{
return (fTop + ceilf(fHeight) - 1.0);
}
#include <StringItem.h>
// to maintain source compatibility
+3 -4
View File
@@ -43,8 +43,8 @@ class BListView : public BView, public BInvoker {
virtual void MakeFocus(bool state = true);
virtual void FrameResized(float newWidth, float newHeight);
virtual void TargetedByScrollView(BScrollView* scroller);
void ScrollTo(float x, float y);
virtual void ScrollTo(BPoint where);
inline void ScrollTo(float x, float y);
virtual bool AddItem(BListItem* item);
virtual bool AddItem(BListItem* item, int32 atIndex);
virtual bool AddList(BList* newItems);
@@ -136,7 +136,6 @@ class BListView : public BView, public BInvoker {
};
virtual bool DoMiscellaneous(MiscCode code, MiscData *data);
private:
friend class BOutlineListView;
@@ -161,6 +160,7 @@ class BListView : public BView, public BInvoker {
bool _TryInitiateDrag(BPoint where);
int32 _CalcFirstSelected(int32 after);
int32 _CalcLastSelected(int32 before);
void _RecalcItemTops(int32 start);
virtual void DrawItem(BListItem* item, BRect itemRect,
bool complete = false);
@@ -174,12 +174,11 @@ class BListView : public BView, public BInvoker {
int32 fFirstSelected;
int32 fLastSelected;
int32 fAnchorIndex;
float fWidth;
BMessage* fSelectMessage;
BScrollView* fScrollView;
track_data* fTrack;
uint32 _reserved[3];
uint32 _reserved[4];
};
inline void