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 /base | |
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 'base')
-rw-r--r-- | base/chrome_application_mac.h | 20 | ||||
-rw-r--r-- | base/chrome_application_mac.mm | 18 |
2 files changed, 38 insertions, 0 deletions
diff --git a/base/chrome_application_mac.h b/base/chrome_application_mac.h index d7e7989..07fd433 100644 --- a/base/chrome_application_mac.h +++ b/base/chrome_application_mac.h @@ -8,15 +8,35 @@ #import <AppKit/AppKit.h> #include "base/basictypes.h" +#include "base/scoped_nsobject.h" + +// Event hooks must implement this protocol. +@protocol CrApplicationEventHookProtocol +- (void)hookForEvent:(NSEvent*)theEvent; +@end + @interface CrApplication : NSApplication { @private BOOL handlingSendEvent_; + // Array of objects implementing the CrApplicationEventHookProtocol + scoped_nsobject<NSMutableArray> eventHooks_; } @property(readonly, getter=isHandlingSendEvent, nonatomic) BOOL handlingSendEvent; +// Add or remove an event hook to be called for every sendEvent: +// that the application receives. These handlers are called before +// the normal [NSApplication sendEvent:] call is made. + +// This is not a good alternative to a nested event loop. It should +// be used only when normal event logic and notification breaks down +// (e.g. when clicking outside a canBecomeKey:NO window to "switch +// context" out of it). +- (void)addEventHook:(id<CrApplicationEventHookProtocol>)hook; +- (void)removeEventHook:(id<CrApplicationEventHookProtocol>)hook; + + (NSApplication*)sharedApplication; @end diff --git a/base/chrome_application_mac.mm b/base/chrome_application_mac.mm index cdad4ab..a163534 100644 --- a/base/chrome_application_mac.mm +++ b/base/chrome_application_mac.mm @@ -28,11 +28,29 @@ return app; } +- (id)init { + if ((self = [super init])) { + eventHooks_.reset([[NSMutableArray alloc] init]); + } + return self; +} + - (void)sendEvent:(NSEvent*)event { chrome_application_mac::ScopedSendingEvent sendingEventScoper; + for (id<CrApplicationEventHookProtocol> handler in eventHooks_.get()) { + [handler hookForEvent:event]; + } [super sendEvent:event]; } +- (void)addEventHook:(id<CrApplicationEventHookProtocol>)handler { + [eventHooks_ addObject:handler]; +} + +- (void)removeEventHook:(id<CrApplicationEventHookProtocol>)handler { + [eventHooks_ removeObject:handler]; +} + @end namespace chrome_application_mac { |