Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: chrome/browser/ui/cocoa/draggable_button.h

Issue 7462018: [Mac] "Refactor" DraggableButton into a mixin and impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #import "base/memory/scoped_nsobject.h"
8 #import "chrome/browser/ui/cocoa/draggable_button_mixin.h"
9
7 // Class for buttons that can be drag sources. If the mouse is clicked and moved 10 // Class for buttons that can be drag sources. If the mouse is clicked and moved
8 // more than a given distance, this class will call |-beginDrag:| instead of 11 // more than a given distance, this class will call |-beginDrag:| instead of
9 // |-performClick:|. Subclasses should override these two methods. 12 // |-performClick:|. Subclasses should override these two methods.
10 @interface DraggableButton : NSButton { 13 @interface DraggableButton : NSButton<DraggableButtonMixin> {
11 @private 14 @private
12 BOOL draggable_; // Is this a draggable type of button? 15 scoped_nsobject<DraggableButtonImpl> draggableButtonImpl_;
13 BOOL actionHasFired_; // Has the action already fired for this click?
14 BOOL actsOnMouseDown_; // Does button action happen on mouse down when
15 // possible?
16 NSTimeInterval durationMouseWasDown_;
17 NSTimeInterval whenMouseDown_;
18 } 16 }
19 17
20 @property NSTimeInterval durationMouseWasDown; 18 @property(readonly, nonatomic) DraggableButtonImpl* draggableButton;
21 19
22 @property NSTimeInterval whenMouseDown; 20 @end
23
24 // Whether the action has already fired for this click.
25 @property(nonatomic) BOOL actionHasFired;
26
27 // Enable or disable dragability for special buttons like "Other Bookmarks".
28 @property(nonatomic) BOOL draggable;
29
30 // If it has a popup menu, for example, we want to perform the action on mouse
31 // down, if possible (as long as user still gets chance to drag, if
32 // appropriate).
33 @property(nonatomic) BOOL actsOnMouseDown;
34
35 // Called when a drag should start. Subclasses must override this to do any
36 // pasteboard manipulation and begin the drag, usually with
37 // -dragImage:at:offset:event:. Subclasses must call one of the blocking
38 // -drag* methods of NSView when overriding this method.
39 - (void)beginDrag:(NSEvent*)dragEvent;
40
41
42 // Override if you want to do any extra work on mouseUp, after a mouseDown
43 // action has already fired.
44 - (void)secondaryMouseUpAction:(BOOL)wasInside;
45
46 // This is called internally.
47 // Decides if we now have enough information to stop tracking the mouse.
48 // It's the function below, deltaIndicatesDragStartWithXDelta. however, that
49 // decides whether it's a drag or not.
50 // Override if you want to do something tricky when making the decision.
51 // Default impl returns YES if ABS(xDelta) or ABS(yDelta) >= their respective
52 // hysteresis limit.
53 - (BOOL)deltaIndicatesConclusionReachedWithXDelta:(float)xDelta
54 yDelta:(float)yDelta
55 xHysteresis:(float)xHysteresis
56 yHysteresis:(float)yHysteresis;
57
58 // This is called internally.
59 // Decides whether we should treat the click as a cue to start dragging, or
60 // instead call the mouseDown/mouseUp handler as appropriate.
61 // Override if you want to do something tricky when making the decision.
62 // Default impl returns YES if ABS(xDelta) or ABS(yDelta) >= their respective
63 // hysteresis limit.
64 - (BOOL)deltaIndicatesDragStartWithXDelta:(float)xDelta
65 yDelta:(float)yDelta
66 xHysteresis:(float)xHysteresis
67 yHysteresis:(float)yHysteresis;
68
69
70 @end // @interface DraggableButton
71
72 @interface DraggableButton (Private)
73
74 // Resets the draggable state of the button after dragging is finished. This is
75 // called by DraggableButton when the beginDrag call returns, it should not be
76 // called by the subclass.
77 - (void)endDrag;
78
79 // Called internally if the actsOnMouseDown property is set.
80 // Fires the button's action and tracks the click.
81 - (void)performMouseDownAction:(NSEvent*)theEvent;
82
83
84 @end // @interface DraggableButton(Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698