diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-24 23:26:27 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-24 23:26:27 +0000 |
commit | d27fd0e73b0620cc3af740d2dd2138c20ca4372a (patch) | |
tree | e97bc4d580ed7893b035168f2380b3b2f28908bb /chrome/browser/cocoa/bookmark_bar_view.mm | |
parent | 38eb08a5fd1ea4f529b9d4651a2f2eb31b0d2192 (diff) | |
download | chromium_src-d27fd0e73b0620cc3af740d2dd2138c20ca4372a.zip chromium_src-d27fd0e73b0620cc3af740d2dd2138c20ca4372a.tar.gz chromium_src-d27fd0e73b0620cc3af740d2dd2138c20ca4372a.tar.bz2 |
Custom "menus" for the bookmark bar folders.
Full behavior: http://JRG_WRITE_FULL_DOC_AND_TEST_PLAN_TOMORROW
BUG=17608 (and a slew of others)
Brief details on how to test:
- add some bookmarks and bookmark folders.
- at a basic level, make sure bookmark folders feel like menus e.g.
-- click to open
-- can open "submenus" and sub-sub-menus
-- can open (click on) bookmarks in any of these submenus
- click-drag does NOT open a menu (different than Mac menus); it initiates a Drag
- click on folder in bookmark bar initiates "hover open"; moving mouse
over other folders will pop them open immediately (much like Mac menus)
- Bookmark bar non-drag hover-open is immediate, but bookmark folder
hover-open has a brief delay so quick "move down" a folder does not
trigger them all to open while you travel (much like Mac menus).
- DnD of bookmarks and folders on bookmark bar.
- While doing DnD of bookmark, "hover" over a folder and see it open.
- Bookmark folder menus have normal DnD "drop indicators" like the bookmark bar.
- Can "hover open" a nested subfolder.
- Can drag a bookmark from one deep sub-sub-folder to a different deep one.
- Confirm buttons and folders in submenus are themed, both with the
theme set at launch time and the theme we change to after launch.
- Empty folders have an "(empty)" item which is not selectable.
- Intentional delay in closing a sub-sub-folder when hovering over
another one. E.g. When moving to a sub-sub-menu, 'brief' travel
over a different submenu does not close the destination sub-menu.
- can use bookmark context menus in folder "menus".
- confirm DnD from "Other bookmarks" to any other random folder and
vice versa.
- While non-drag hover open is active, clicking anywhere other than
the bookmark bar or folder (e.g. the main web view) turns it off.
TODO:
- random bugs (e.g. "add folder" over a folder doesn't put it in there)
- (empty) needs to be revisited, both visually and for a drop indication
- core animations instead of drop indicators
- ...
Review URL: http://codereview.chromium.org/551226
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39947 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_bar_view.mm')
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_view.mm | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_view.mm b/chrome/browser/cocoa/bookmark_bar_view.mm index 96b7594..b1099b2 100644 --- a/chrome/browser/cocoa/bookmark_bar_view.mm +++ b/chrome/browser/cocoa/bookmark_bar_view.mm @@ -17,11 +17,19 @@ @implementation BookmarkBarView +@synthesize dropIndicatorShown = dropIndicatorShown_; +@synthesize dropIndicatorPosition = dropIndicatorPosition_; + - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; // This probably isn't strictly necessary, but can't hurt. [self unregisterDraggedTypes]; [super dealloc]; + + // To be clear, our controller_ is an IBOutlet and owns us, so we + // don't deallocate it explicitly. It is owned by the browser + // window controller, so gets deleted with a browser window is + // closed. } - (void)awakeFromNib { @@ -50,6 +58,10 @@ [controller_ updateTheme:themeProvider]; } +- (void)viewDidMoveToWindow { + [controller_ viewDidMoveToWindow]; +} + // Called after the current theme has changed. - (void)themeDidChangeNotification:(NSNotification*)aNotification { ThemeProvider* themeProvider = @@ -79,6 +91,10 @@ return noItemTextfield_; } +- (BookmarkBarController*)controller { + return controller_; +} + -(void)drawRect:(NSRect)dirtyRect { [super drawRect:dirtyRect]; @@ -113,18 +129,31 @@ // Find the position of the drop indicator. BookmarkButton* button = nil; [data getBytes:&button length:sizeof(button)]; - CGFloat x = - [controller_ indicatorPosForDragOfButton:button - toPoint:[info draggingLocation]]; - - // Need an update if the indicator wasn't previously shown or if it has - // moved. - if (!dropIndicatorShown_ || dropIndicatorPosition_ != x) { - dropIndicatorShown_ = YES; - dropIndicatorPosition_ = x; - [self setNeedsDisplay:YES]; + + // We only show the drop indicator if we're not in a position to + // perform a hover-open since it doesn't make sense to do both. + BOOL showIt = + [controller_ shouldShowIndicatorShownForPoint: + [info draggingLocation]]; + if (!showIt) { + if (dropIndicatorShown_) { + dropIndicatorShown_ = NO; + [self setNeedsDisplay:YES]; + } + } else { + CGFloat x = + [controller_ indicatorPosForDragOfButton:button + toPoint:[info draggingLocation]]; + // Need an update if the indicator wasn't previously shown or if it has + // moved. + if (!dropIndicatorShown_ || dropIndicatorPosition_ != x) { + dropIndicatorShown_ = YES; + dropIndicatorPosition_ = x; + [self setNeedsDisplay:YES]; + } } + [controller_ draggingEntered:info]; // allow hover-open to work. return NSDragOperationMove; } // Fall through otherwise. @@ -210,13 +239,8 @@ return NO; } -@end // @implementation BookmarkBarView - - -@implementation BookmarkBarView(TestingAPI) - - (void)setController:(id)controller { controller_ = controller; } -@end // @implementation BookmarkBarView(TestingAPI) +@end // @implementation BookmarkBarView |