diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-18 00:57:49 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-18 00:57:49 +0000 |
commit | 44b2c885548d647611d908309dfdf6306eac7ed8 (patch) | |
tree | c46fd5199ac07df770ca9b01a0b73dc594b6d63d /chrome/browser/cocoa/tab_contents_controller.mm | |
parent | 9eef357377e89bffd2d5ff9fad9de0c94d8cc934 (diff) | |
download | chromium_src-44b2c885548d647611d908309dfdf6306eac7ed8.zip chromium_src-44b2c885548d647611d908309dfdf6306eac7ed8.tar.gz chromium_src-44b2c885548d647611d908309dfdf6306eac7ed8.tar.bz2 |
Mac bookmark work.
- The bookmark menu is populated dynamically with bookmarks, including
subfolders --> submenus. E.g. star something --> shows up in menu.
Menu items are disabled but always present and current.
- Always Show Bookmarks" menu now live; reads from / writes to
preference, and shows correct "toggle state".
- Bookmark bar on each tab, present if requested. (Currently an empty box).
- Random stuff; e.g. bookmark prefs init moved to a x-plat location.
This CL does not contain Cole's views.
Bried english description of the nib file changes:
- add a new view for the bookmark bar in the tab; hook it up to the controller
- Many tag sets (e.g. View-->Always Show Bookmarks Bar now 40009)
- Remove dummy bookmark menu items
Review URL: http://codereview.chromium.org/46078
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11936 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/tab_contents_controller.mm')
-rw-r--r-- | chrome/browser/cocoa/tab_contents_controller.mm | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/chrome/browser/cocoa/tab_contents_controller.mm b/chrome/browser/cocoa/tab_contents_controller.mm index 69f3ba6..973e808 100644 --- a/chrome/browser/cocoa/tab_contents_controller.mm +++ b/chrome/browser/cocoa/tab_contents_controller.mm @@ -6,6 +6,7 @@ #import "base/sys_string_conversions.h" #import "chrome/app/chrome_dll_resource.h" +#import "chrome/browser/bookmarks/bookmark_model.h" #import "chrome/browser/command_updater.h" #import "chrome/browser/location_bar.h" #import "chrome/browser/tab_contents/tab_contents.h" @@ -30,6 +31,7 @@ static NSString* const kStarredImageName = @"starred"; @interface TabContentsController(Private) - (void)updateToolbarCommandStatus; +- (void)applyContentsBoxOffset:(BOOL)apply; @end // A C++ bridge class that handles listening for updates to commands and @@ -78,7 +80,8 @@ class LocationBarBridge : public LocationBar { bundle:(NSBundle*)bundle contents:(TabContents*)contents commands:(CommandUpdater*)commands - toolbarModel:(ToolbarModel*)toolbarModel { + toolbarModel:(ToolbarModel*)toolbarModel + bookmarkModel:(BookmarkModel*)bookmarkModel { if ((self = [super initWithNibName:name bundle:bundle])) { commands_ = commands; if (commands_) @@ -86,6 +89,7 @@ class LocationBarBridge : public LocationBar { locationBarBridge_ = new LocationBarBridge(self); contents_ = contents; toolbarModel_ = toolbarModel; + bookmarkModel_ = bookmarkModel; } return self; } @@ -100,6 +104,7 @@ class LocationBarBridge : public LocationBar { - (void)awakeFromNib { [contentsBox_ setContentView:contents_->GetNativeView()]; + [self applyContentsBoxOffset:YES]; // Provide a starting point since we won't get notifications if the state // doesn't change between tabs. @@ -234,6 +239,47 @@ class LocationBarBridge : public LocationBar { [goButton_ setImage:[NSImage imageNamed:imageName]]; } +- (void)toggleBookmarkBar:(BOOL)enable { + contentsBoxHasOffset_ = enable; + [self applyContentsBoxOffset:enable]; + + if (enable) { + // TODO(jrg): display something useful in the bookmark bar + // TODO(jrg): use a BookmarksView, not a ToolbarView + // TODO(jrg): don't draw a border around it + // TODO(jrg): ... + } +} + +// Apply a contents box offset to make (or remove) room for the +// bookmark bar. If apply==YES, always make room (the contentsBox_ is +// "full size"). If apply==NO we are trying to undo an offset. If no +// offset there is nothing to undo. +- (void)applyContentsBoxOffset:(BOOL)apply { + + if (bookmarkView_ == nil) { + // We're too early, but awakeFromNib will call me again. + return; + } + if (!contentsBoxHasOffset_ && apply) { + // There is no offset to unconditionally apply. + return; + } + + int offset = [bookmarkView_ frame].size.height; + NSRect frame = [contentsBox_ frame]; + if (apply) + frame.size.height -= offset; + else + frame.size.height += offset; + + // TODO(jrg): animate + [contentsBox_ setFrame:frame]; + + [bookmarkView_ setNeedsDisplay:YES]; + [contentsBox_ setNeedsDisplay:YES]; +} + @end //-------------------------------------------------------------------------- |