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_folder_controller.h | |
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_folder_controller.h')
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_folder_controller.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_folder_controller.h b/chrome/browser/cocoa/bookmark_bar_folder_controller.h new file mode 100644 index 0000000..5f199d4 --- /dev/null +++ b/chrome/browser/cocoa/bookmark_bar_folder_controller.h @@ -0,0 +1,92 @@ +// 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> + +#include "base/scoped_nsobject.h" +#import "chrome/browser/cocoa/bookmark_button.h" + +@class BookmarkBarFolderView; + +// A controller for the pop-up windows from bookmark folder buttons +// which look sort of like menus. +@interface BookmarkBarFolderController : + NSWindowController<BookmarkButtonDelegate, + BookmarkButtonControllerProtocol> { + @private + // The button whose click opened us. + scoped_nsobject<BookmarkButton> parentButton_; + + // Bookmark bar folder controller chains are torn down in two ways: + // 1. Clicking "outside" the folder (see use of + // CrApplicationEventHookProtocol in the bookmark bar controller). + // 2. Engaging a different folder (via hover over or explicit click). + // + // In either case, the BookmarkButtonControllerProtocol method + // closeAllBookmarkFolders gets called. For bookmark bar folder + // controllers, this is passed up the chain so we begin with a top + // level "close". + // When any bookmark folder window closes, it necessarily tells + // subcontroller windows to close (down the chain), and autoreleases + // the controller. (Must autorelease since the controller can still + // get delegate events such as windowDidClose). + // + // Bookmark bar folder controllers own their buttons. When doing + // drag and drop of a button from one sub-sub-folder to a different + // sub-sub-folder, we need to make sure the button's pointers stay + // valid until we've dropped (or cancelled). Note that such a drag + // causes the source sub-sub-folder (previous parent window) to go + // away (windows close, controllers autoreleased) since you're + // hovering over a different folder chain for dropping. To keep + // things valid (like the button's target, its delegate, the parent + // cotroller that we have a pointer to below [below], etc), we heep + // strong pointers to our owning controller, so the entire chain + // stays owned. + + // Our parent controller. This may be another + // BookmarkBarFolderController (if we are a nested folder) or it may + // be the BookmarkBarController (if not). + // Strong to insure the object lives as long as we need it. + scoped_nsobject<NSObject<BookmarkButtonControllerProtocol> > + parentController_; + + // Our buttons. We do not have buttons for nested folders. + scoped_nsobject<NSMutableArray> buttons_; + + // The main view of this window (where the buttons go). + IBOutlet BookmarkBarFolderView* mainView_; + + // Like normal menus, hovering over a folder button causes it to + // open. This variable is set when a hover is initiated (but has + // not necessarily fired yet). + scoped_nsobject<BookmarkButton> hoverButton_; + + // A controller for a pop-up bookmark folder window (custom menu). + // We (self) are the parentController_ for our folderController_. + // This is not a scoped_nsobject because it owns itself (when its + // window closes the controller gets autoreleased). + BookmarkBarFolderController* folderController_; + + // Has a draggingExited been called? Only relevant for + // performSelector:after:delay: calls that get triggered in the + // middle of a drag. + BOOL draggingExited_; +} + +- (id)initWithParentButton:(BookmarkButton*)button + parentController:(NSObject<BookmarkButtonControllerProtocol>*)controller; + +// Return the parent button that owns the bookmark folder we represent. +- (BookmarkButton*)parentButton; + +@end + + +@interface BookmarkBarFolderController(TestingAPI) +- (NSView*)mainView; +- (NSPoint)windowTopLeft; +- (NSArray*)buttons; +- (BookmarkBarFolderController*)folderController; +@end + |