* Applied a changed patch by Romain that fixes the non-working double click in
BListView. This fixes bug #3919. Got rid of the _TryInitiateDrag() method, and let MouseMoved() do it all. * Style cleanup of the header, automatic whitespace cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30782 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2002-2009, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _LIST_VIEW_H
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
|
||||
#include <Invoker.h>
|
||||
#include <View.h>
|
||||
#include <List.h>
|
||||
#include <ListItem.h>
|
||||
#include <View.h>
|
||||
|
||||
|
||||
struct track_data;
|
||||
@@ -25,11 +25,14 @@ class BListView : public BView, public BInvoker {
|
||||
BListView(BRect frame, const char* name,
|
||||
list_view_type type = B_SINGLE_SELECTION_LIST,
|
||||
uint32 resizeMask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);
|
||||
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS
|
||||
| B_NAVIGABLE);
|
||||
BListView(const char* name,
|
||||
list_view_type type = B_SINGLE_SELECTION_LIST,
|
||||
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);
|
||||
BListView(list_view_type type = B_SINGLE_SELECTION_LIST);
|
||||
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS
|
||||
| B_NAVIGABLE);
|
||||
BListView(
|
||||
list_view_type type = B_SINGLE_SELECTION_LIST);
|
||||
BListView(BMessage* data);
|
||||
|
||||
virtual ~BListView();
|
||||
@@ -37,15 +40,14 @@ class BListView : public BView, public BInvoker {
|
||||
static BArchivable* Instantiate(BMessage* data);
|
||||
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void MessageReceived(BMessage* msg);
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void MouseDown(BPoint where);
|
||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||
virtual void MakeFocus(bool state = true);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void FrameResized(float newWidth, float newHeight);
|
||||
virtual void FrameMoved(BPoint newPosition);
|
||||
virtual void SetFont(const BFont* font,
|
||||
uint32 mask = B_FONT_ALL);
|
||||
virtual void SetFont(const BFont* font, uint32 mask = B_FONT_ALL);
|
||||
virtual void TargetedByScrollView(BScrollView* scroller);
|
||||
virtual void ScrollTo(BPoint where);
|
||||
inline void ScrollTo(float x, float y);
|
||||
@@ -78,7 +80,8 @@ class BListView : public BView, public BInvoker {
|
||||
virtual void MakeEmpty();
|
||||
bool IsEmpty() const;
|
||||
void DoForEach(bool (*func)(BListItem* item));
|
||||
void DoForEach(bool (*func)(BListItem* item, void* arg), void* arg);
|
||||
void DoForEach(bool (*func)(BListItem* item, void* arg),
|
||||
void* arg);
|
||||
const BListItem** Items() const;
|
||||
void InvalidateItem(int32 index);
|
||||
void ScrollToSelection();
|
||||
@@ -105,7 +108,8 @@ class BListView : public BView, public BInvoker {
|
||||
BRect ItemFrame(int32 index);
|
||||
|
||||
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
|
||||
BMessage* specifier, int32 form, const char* property);
|
||||
BMessage* specifier, int32 form,
|
||||
const char* property);
|
||||
virtual status_t GetSupportedSuites(BMessage* data);
|
||||
|
||||
virtual status_t Perform(perform_code code, void* arg);
|
||||
@@ -137,6 +141,7 @@ class BListView : public BView, public BInvoker {
|
||||
};
|
||||
|
||||
virtual bool DoMiscellaneous(MiscCode code, MiscData* data);
|
||||
|
||||
private:
|
||||
friend class BOutlineListView;
|
||||
|
||||
@@ -144,7 +149,7 @@ class BListView : public BView, public BInvoker {
|
||||
virtual void _ReservedListView3();
|
||||
virtual void _ReservedListView4();
|
||||
|
||||
BListView& operator=(const BListView&);
|
||||
BListView& operator=(const BListView& other);
|
||||
|
||||
void _InitObject(list_view_type type);
|
||||
void _FixupScrollBar();
|
||||
@@ -155,10 +160,7 @@ class BListView : public BView, public BInvoker {
|
||||
bool _Select(int32 index, bool extend);
|
||||
bool _Select(int32 from, int32 to, bool extend);
|
||||
bool _Deselect(int32 index);
|
||||
// void _Deselect(int32 from, int32 to);
|
||||
bool _DeselectAll(int32 exceptFrom, int32 exceptTo);
|
||||
// void PerformDelayedSelect();
|
||||
bool _TryInitiateDrag(BPoint where);
|
||||
int32 _CalcFirstSelected(int32 after);
|
||||
int32 _CalcLastSelected(int32 before);
|
||||
void _RecalcItemTops(int32 start, int32 end = -1);
|
||||
@@ -182,6 +184,7 @@ class BListView : public BView, public BInvoker {
|
||||
uint32 _reserved[4];
|
||||
};
|
||||
|
||||
|
||||
inline void
|
||||
BListView::ScrollTo(float x, float y)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2008, Haiku, Inc.
|
||||
* Copyright (c) 2001-2009, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
@@ -382,22 +382,27 @@ BListView::MouseDown(BPoint point)
|
||||
void
|
||||
BListView::MouseUp(BPoint pt)
|
||||
{
|
||||
fTrack->item_index = -1;
|
||||
fTrack->try_drag = false;
|
||||
}
|
||||
|
||||
// MouseMoved
|
||||
|
||||
void
|
||||
BListView::MouseMoved(BPoint pt, uint32 code, const BMessage *msg)
|
||||
BListView::MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage)
|
||||
{
|
||||
if (fTrack->item_index == -1) {
|
||||
if (fTrack->item_index == -1 || !fTrack->try_drag) {
|
||||
// mouse was not clicked above any item
|
||||
// or no mouse button pressed
|
||||
return;
|
||||
}
|
||||
|
||||
if (_TryInitiateDrag(pt))
|
||||
return;
|
||||
// Initiate a drag if the mouse was moved far enough
|
||||
BPoint offset = where - fTrack->drag_start;
|
||||
float dragDistance = sqrtf(offset.x * offset.x + offset.y * offset.y);
|
||||
if (dragDistance >= 5.0f) {
|
||||
fTrack->try_drag = false;
|
||||
InitiateDrag(fTrack->drag_start, fTrack->item_index,
|
||||
fTrack->was_selected);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1553,23 +1558,6 @@ BListView::_DeselectAll(int32 exceptFrom, int32 exceptTo)
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BListView::_TryInitiateDrag(BPoint where)
|
||||
{
|
||||
if (!fTrack->try_drag || fTrack->item_index < 0)
|
||||
return false;
|
||||
|
||||
BPoint offset = where - fTrack->drag_start;
|
||||
float dragDistance = sqrtf(offset.x * offset.x + offset.y * offset.y);
|
||||
|
||||
if (dragDistance > 5.0) {
|
||||
fTrack->try_drag = false;
|
||||
return InitiateDrag(fTrack->drag_start, fTrack->item_index, fTrack->was_selected);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
BListView::_CalcFirstSelected(int32 after)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user