diff options
Diffstat (limited to 'chrome/browser/cocoa/bookmark_button.h')
-rw-r--r-- | chrome/browser/cocoa/bookmark_button.h | 109 |
1 files changed, 95 insertions, 14 deletions
diff --git a/chrome/browser/cocoa/bookmark_button.h b/chrome/browser/cocoa/bookmark_button.h index 3034166..3144247 100644 --- a/chrome/browser/cocoa/bookmark_button.h +++ b/chrome/browser/cocoa/bookmark_button.h @@ -3,30 +3,111 @@ // found in the LICENSE file. #import <Cocoa/Cocoa.h> - #import "chrome/browser/cocoa/draggable_button.h" -@protocol BookmarkButtonDelegate; +@class BookmarkButton; +class BookmarkModel; +class BookmarkNode; +class ThemeProvider; + +// Protocol for a BookmarkButton's delegate, responsible for doing +// things on behalf of a bookmark button. +@protocol BookmarkButtonDelegate + +// Fill the given pasteboard with appropriate data when the given button is +// dragged. Since the delegate has no way of providing pasteboard data later, +// all data must actually be put into the pasteboard and not merely promised. +- (void)fillPasteboard:(NSPasteboard*)pboard + forDragOfButton:(BookmarkButton*)button; + +// Bookmark buttons pass mouseEntered: and mouseExited: events to +// their delegate. This allows the delegate to decide (for example) +// which one, if any, should perform a hover-open. +- (void)mouseEnteredButton:(id)button event:(NSEvent*)event; +- (void)mouseExitedButton:(id)button event:(NSEvent*)event; + +@end + + +// Protocol to be implemented by controllers that logically own +// bookmark buttons. The controller may be either an NSViewController +// or NSWindowController. The BookmarkButton doesn't use this +// protocol directly; it is used when BookmarkButton controllers talk +// to each other. +// Other than the top level owner (the bookmark bar), all bookmark +// button controllers have a parent controller. +@protocol BookmarkButtonControllerProtocol + +// Close all bookmark folders, walking up the ownership chain. +- (void)closeAllBookmarkFolders; + +// Close just my bookmark folder. +- (void)closeBookmarkFolder:(id)sender; + +// Return the bookmark model for this controller. +- (BookmarkModel*)bookmarkModel; + +// Perform drag enter/exit operations, such as hover-open and hover-close. +- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)info; +- (void)draggingExited:(id<NSDraggingInfo>)info; + +// Perform the actual DnD of a bookmark button. + +// |point| is in the base coordinate system of the destination window; +// |it comes from an id<NSDraggingInfo>. +- (BOOL)dragButton:(BookmarkButton*)sourceButton to:(NSPoint)point; + +// Return YES if we should show the drop indicator, else NO. In some +// cases (e.g. hover open) we don't want to show the drop indicator. +// |point| is in the base coordinate system of the destination window; +// |it comes from an id<NSDraggingInfo>. +- (BOOL)shouldShowIndicatorShownForPoint:(NSPoint)point; + +// The x or y coordinate of (the middle of) the indicator to draw for +// a drag of the source button to the given point (given in window +// coordinates). +// |point| is in the base coordinate system of the destination window; +// |it comes from an id<NSDraggingInfo>. +// TODO(viettrungluu,jrg): instead of this, make buttons move around. +// http://crbug.com/35968 +- (CGFloat)indicatorPosForDragOfButton:(BookmarkButton*)sourceButton + toPoint:(NSPoint)point; + +// Return the parent window for all BookmarkBarFolderController windows. +- (NSWindow*)parentWindow; + +// Return the theme provider associated with this browser window. +- (ThemeProvider*)themeProvider; + +@end // @protocol BookmarkButtonControllerProtocol + // Class for bookmark bar buttons that can be drag sources. @interface BookmarkButton : DraggableButton { @private - id<BookmarkButtonDelegate> delegate_; + NSObject<BookmarkButtonDelegate>* delegate_; // weak like all delegates } -@property(assign, nonatomic) id<BookmarkButtonDelegate> delegate; +@property(assign, nonatomic) NSObject<BookmarkButtonDelegate>* delegate; + +// Return the bookmark node associated with this button, or NULL. +- (const BookmarkNode*)bookmarkNode; + +// Return YES if this is a folder button (the node has subnodes). +- (BOOL)isFolder; + +// At this time we represent an empty folder (e.g. the string +// '(empty)') as a disabled button with no associated node. +// +// TODO(jrg): improve; things work but are slightly ugly since "empty" +// and "one disabled button" are not the same thing. +// http://crbug.com/35967 +- (BOOL)isEmpty; @end // @interface BookmarkButton -// Protocol for a |BookmarkButton|'s delegate, which is responsible for doing -// things which require information about the bookmark represented by this -// button. -@protocol BookmarkButtonDelegate -// Fill the given pasteboard with appropriate data when the given button is -// dragged. Since the delegate has no way of providing pasteboard data later, -// all data must actually be put into the pasteboard and not merely promised. -- (void)fillPasteboard:(NSPasteboard*)pboard - forDragOfButton:(BookmarkButton*)button; +@interface BookmarkButton(TestingAPI) +- (void)beginDrag:(NSEvent*)event; +@end -@end // @protocol BookmarkButtonDelegate |