summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/draggable_button.h
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-30 06:37:36 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-30 06:37:36 +0000
commitaedec4f0910a973ef0bd13bdb3bcec36b00922c4 (patch)
tree4bb0aa3f522262ed34c0b5ed64b33a02693be622 /chrome/browser/cocoa/draggable_button.h
parent686e89ddab3da88b913292ff4e8bd97ccb8209d9 (diff)
downloadchromium_src-aedec4f0910a973ef0bd13bdb3bcec36b00922c4.zip
chromium_src-aedec4f0910a973ef0bd13bdb3bcec36b00922c4.tar.gz
chromium_src-aedec4f0910a973ef0bd13bdb3bcec36b00922c4.tar.bz2
Make download items drag sources on OS X.
Extract button dragging out of BookmarkButton into DraggableButton. Make BookmarkButton a subclass of DraggableButton. Create new class DownloadItemButton and make it a subclass of DraggableButton. xib change: Make download item a DownloadItemButton instead of an NSButton. BUG=15776 TEST=Download something, wait for it to complete, then drag it from the download shelf to somewhere. It should now work. Bookmarks should still be draggable in the bookmarks bar. Review URL: http://codereview.chromium.org/180036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37621 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/draggable_button.h')
-rw-r--r--chrome/browser/cocoa/draggable_button.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/draggable_button.h b/chrome/browser/cocoa/draggable_button.h
new file mode 100644
index 0000000..ed9a94f
--- /dev/null
+++ b/chrome/browser/cocoa/draggable_button.h
@@ -0,0 +1,30 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import <Cocoa/Cocoa.h>
+
+// Class for buttons that can be drag sources. If the mouse is clicked and moved
+// more than a given distance, this class will call |-beginDrag:| instead of
+// |-performClick:|. Subclasses should override these two methods.
+@interface DraggableButton : NSButton {
+ @private
+ BOOL draggable_; // Is this a draggable type of button?
+ BOOL mayDragStart_; // Set to YES on mouse down, NO on up or drag.
+ BOOL beingDragged_;
+
+ // Initial mouse-down to prevent a hair-trigger drag.
+ NSPoint initialMouseDownLocation_;
+}
+
+// Enable or disable dragability for special buttons like "Other Bookmarks".
+@property BOOL draggable;
+
+// Called when a drag starts. Subclasses must override this.
+- (void)beginDrag:(NSEvent*)dragEvent;
+
+// Subclasses should call this method to notify DraggableButton when a drag is
+// over.
+- (void)endDrag;
+
+@end // @interface DraggableButton