summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/cocoa/draggable_button.h
diff options
context:
space:
mode:
authormaf@chromium.org <maf@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-05 02:18:36 +0000
committermaf@chromium.org <maf@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-05 02:18:36 +0000
commit797587a93927badde544d800c95739320eca04bb (patch)
tree03a10543cec88b7bf0b8419cb4999ae11a7fd626 /chrome/browser/ui/cocoa/draggable_button.h
parent9ad63d2ad848efdda29deef7ce65e6d286d2d478 (diff)
downloadchromium_src-797587a93927badde544d800c95739320eca04bb.zip
chromium_src-797587a93927badde544d800c95739320eca04bb.tar.gz
chromium_src-797587a93927badde544d800c95739320eca04bb.tar.bz2
Major rewrite of BookmarkButton event-handling to support proper menu
tracking on mousedown, sticky and non-sticky menus, drag-down to get menu on draggable folders, etc. Also contains first half of animation support for these UI items. Note that a forthcoming checkin will add live animation during the drag, but that's not covered by this checkin, which adds animation support for the bookmark toolbar buttons, but only in response to completed actions. BUG=72011,70002,72012 Review URL: http://codereview.chromium.org/6594065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77022 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/cocoa/draggable_button.h')
-rw-r--r--chrome/browser/ui/cocoa/draggable_button.h53
1 files changed, 52 insertions, 1 deletions
diff --git a/chrome/browser/ui/cocoa/draggable_button.h b/chrome/browser/ui/cocoa/draggable_button.h
index 7f58255..ab74c2b 100644
--- a/chrome/browser/ui/cocoa/draggable_button.h
+++ b/chrome/browser/ui/cocoa/draggable_button.h
@@ -9,18 +9,64 @@
// |-performClick:|. Subclasses should override these two methods.
@interface DraggableButton : NSButton {
@private
- BOOL draggable_; // Is this a draggable type of button?
+ BOOL draggable_; // Is this a draggable type of button?
+ BOOL actionHasFired_; // Has the action already fired for this click?
+ BOOL actsOnMouseDown_; // Does button action happen on mouse down when
+ // possible?
+ NSTimeInterval durationMouseWasDown_;
+ NSTimeInterval whenMouseDown_;
}
// Enable or disable dragability for special buttons like "Other Bookmarks".
@property(nonatomic) BOOL draggable;
+// If it has a popup menu, for example, we want to perform the action on mouse
+// down, if possible (as long as user still gets chance to drag, if
+// appropriate).
+@property(nonatomic) BOOL actsOnMouseDown;
+
// Called when a drag should start. Subclasses must override this to do any
// pasteboard manipulation and begin the drag, usually with
// -dragImage:at:offset:event:. Subclasses must call one of the blocking
// -drag* methods of NSView when overriding this method.
- (void)beginDrag:(NSEvent*)dragEvent;
+// Called internally. Default impl only returns YES if sender==self.
+// Override if your subclass wants to accept being tracked into while a
+// click is being tracked on another DraggableButton. Needed to support
+// buttons being used as fake menu items or menu titles, as BookmarkButton does.
+- (BOOL)acceptsTrackInFrom:(id)sender;
+
+// Override if you want to do any extra work on mouseUp, after a mouseDown
+// action has already fired.
+- (void)secondaryMouseUpAction:(BOOL)wasInside;
+
+// This is called internally.
+// Decides if we now have enough information to stop tracking the mouse.
+// It's the function below, deltaIndicatesDragStartWithXDelta. however, that
+// decides whether it's a drag or not.
+// Override if you want to do something tricky when making the decision.
+// Default impl returns YES if ABS(xDelta) or ABS(yDelta) >= their respective
+// hysteresis limit.
+- (BOOL)deltaIndicatesConclusionReachedWithXDelta:(float)xDelta
+ yDelta:(float)yDelta
+ xHysteresis:(float)xHysteresis
+ yHysteresis:(float)yHysteresis;
+
+// This is called internally.
+// Decides whether we should treat the click as a cue to start dragging, or
+// instead call the mouseDown/mouseUp handler as appropriate.
+// Override if you want to do something tricky when making the decision.
+// Default impl returns YES if ABS(xDelta) or ABS(yDelta) >= their respective
+// hysteresis limit.
+- (BOOL)deltaIndicatesDragStartWithXDelta:(float)xDelta
+ yDelta:(float)yDelta
+ xHysteresis:(float)xHysteresis
+ yHysteresis:(float)yHysteresis;
+
+
+@property(nonatomic) NSTimeInterval durationMouseWasDown;
+
@end // @interface DraggableButton
@interface DraggableButton (Private)
@@ -30,4 +76,9 @@
// called by the subclass.
- (void)endDrag;
+// Called internally if the actsOnMouseDown property is set.
+// Fires the button's action and tracks the click.
+- (void)performMouseDownAction:(NSEvent*)theEvent;
+
+
@end // @interface DraggableButton(Private)