haiku/headers/os/interface/Dragger.h
Alexandre Deckner c51d0337a1 * Rewrote BDragger's mouse tracking to be asynchronous using a message filter. Placed the filter in
kits/shared since i plan to use it in other places like Tracker. Animated replicants like 
ActivityMonitor wont stall anymore when initiating the drag. (On the desktop, Tracker's mouse 
tracking still busy loops sometimes, that's next on my list). 

I had asynchronous long click detection (one button mouse support) in it but decided to get rid of 
it, it adds unneeded complexity in the code and is even getting in your way sometimes (ex: now you can 
take your time to drag the dragger, you wont be interrupted). If we want to reimplement that 
someday it should be done system wide anyway (only Tracker and replicants have that 'feature' 
AFAIK).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29972 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-06 19:15:00 +00:00

124 lines
3.1 KiB
C++

/*
* Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _DRAGGER_H
#define _DRAGGER_H
#include <Locker.h>
#include <List.h>
#include <View.h>
class BBitmap;
class BMessage;
class BPopUpMenu;
class BShelf;
namespace BPrivate {
class replicant_data;
class ShelfContainerViewFilter;
};
class BDragger : public BView {
public:
BDragger(BRect bounds, BView* target,
uint32 resizingMask = B_FOLLOW_NONE,
uint32 flags = B_WILL_DRAW);
BDragger(BMessage* data);
virtual ~BDragger();
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
virtual void Draw(BRect updateRect);
virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint where);
virtual void MouseMoved(BPoint where, uint32 transit,
const BMessage* dragMessage);
virtual void MessageReceived(BMessage* message);
virtual void FrameMoved(BPoint newPosition);
virtual void FrameResized(float newWidth, float newHeight);
static status_t ShowAllDraggers();
static status_t HideAllDraggers();
static bool AreDraggersDrawn();
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
BMessage* specifier, int32 form,
const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
virtual status_t Perform(perform_code d, void* arg);
virtual void ResizeToPreferred();
virtual void GetPreferredSize(float* _width, float* _height);
virtual void MakeFocus(bool focus = true);
virtual void AllAttached();
virtual void AllDetached();
status_t SetPopUp(BPopUpMenu* contextMenu);
BPopUpMenu* PopUp() const;
bool InShelf() const;
BView* Target() const;
virtual BBitmap* DragBitmap(BPoint* offset, drawing_mode *mode);
class Private;
protected:
bool IsVisibilityChanging() const;
private:
friend class BPrivate::ShelfContainerViewFilter;
friend class BPrivate::replicant_data;
friend class Private;
friend class BShelf;
virtual void _ReservedDragger2();
virtual void _ReservedDragger3();
virtual void _ReservedDragger4();
static void _UpdateShowAllDraggers(bool visible);
BDragger& operator=(const BDragger& other);
void _AddToList();
void _RemoveFromList();
status_t _DetermineRelationship();
status_t _SetViewToDrag(BView* target);
void _SetShelf(BShelf* shelf);
void _SetZombied(bool state);
void _BuildDefaultPopUp();
void _ShowPopUp(BView* target, BPoint where);
static bool sVisible;
static bool sVisibleInitialized;
static BLocker sLock;
static BList sList;
enum relation {
TARGET_UNKNOWN,
TARGET_IS_CHILD,
TARGET_IS_PARENT,
TARGET_IS_SIBLING
};
BView* fTarget;
relation fRelation;
BShelf* fShelf;
bool fTransition;
bool fIsZombie;
char fErrCount;
bool fPopUpIsCustom;
BBitmap* fBitmap;
BPopUpMenu* fPopUp;
uint32 _reserved[3];
};
#endif /* _DRAGGER_H */