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

Unified 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: Address comments 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/draggable_button.h
diff --git a/chrome/browser/ui/cocoa/draggable_button.h b/chrome/browser/ui/cocoa/draggable_button.h
index 4e0d596473380e1f4a5d532701de6dd18ad3ca5f..296cc9392ef244f7ced221f3ce403bbad4d9ff83 100644
--- a/chrome/browser/ui/cocoa/draggable_button.h
+++ b/chrome/browser/ui/cocoa/draggable_button.h
@@ -1,84 +1,26 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
+#ifndef CHROME_BROWSER_UI_COCOA_DRAGGABLE_BUTTON_H_
+#define CHROME_BROWSER_UI_COCOA_DRAGGABLE_BUTTON_H_
+#pragma once
+
#import <Cocoa/Cocoa.h>
+#import "base/memory/scoped_nsobject.h"
+#import "chrome/browser/ui/cocoa/draggable_button_mixin.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 {
+@interface DraggableButton : NSButton<DraggableButtonMixin> {
@private
- 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_;
+ scoped_nsobject<DraggableButtonImpl> draggableButtonImpl_;
}
-@property NSTimeInterval durationMouseWasDown;
-
-@property NSTimeInterval whenMouseDown;
-
-// Whether the action has already fired for this click.
-@property(nonatomic) BOOL actionHasFired;
-
-// 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;
-
-
-// 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;
-
-
-@end // @interface DraggableButton
-
-@interface DraggableButton (Private)
-
-// Resets the draggable state of the button after dragging is finished. This is
-// called by DraggableButton when the beginDrag call returns, it should not be
-// 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;
+@property(readonly, nonatomic) DraggableButtonImpl* draggableButton;
+@end
-@end // @interface DraggableButton(Private)
+#endif // CHROME_BROWSER_UI_COCOA_DRAGGABLE_BUTTON_H_
« no previous file with comments | « chrome/browser/ui/cocoa/download/download_item_button.mm ('k') | chrome/browser/ui/cocoa/draggable_button.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698