Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2379)

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm

Issue 7329032: Mac. Auto show and hide Bookmark Bar "Other Bookmarks" folder button depending on whether it's em... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm
===================================================================
--- chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm (revision 91882)
+++ chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm (working copy)
@@ -843,14 +843,17 @@
return (AnimatableView*)[self view];
}
-// Position the off-the-side chevron to the left of the otherBookmarks button.
+// Position the off-the-side chevron to the left of the otherBookmarks button,
+// unless it's hidden in which case it's right aligned on top of it.
- (void)positionOffTheSideButton {
NSRect frame = [offTheSideButton_ frame];
frame.size.height = bookmarks::kBookmarkFolderButtonHeight;
- if (otherBookmarksButton_.get()) {
+ if (otherBookmarksButton_.get() && ![otherBookmarksButton_ isHidden]) {
frame.origin.x = ([otherBookmarksButton_ frame].origin.x -
(frame.size.width +
bookmarks::kBookmarkHorizontalPadding));
+ } else {
+ frame.origin.x = (NSMaxX([otherBookmarksButton_ frame]) - frame.size.width);
}
[offTheSideButton_ setFrame:frame];
}
@@ -1314,12 +1317,25 @@
}
}
+// Shows or hides the Other Bookmarks button as appropriate, and returns
+// whether it ended up visible.
+- (BOOL)setOtherBookmarksButtonVisibility {
+ if (!otherBookmarksButton_.get())
+ return NO;
+
+ BOOL visible = ![otherBookmarksButton_ bookmarkNode]->empty();
+ [otherBookmarksButton_ setHidden:!visible];
+ return visible;
+}
+
// Create the button for "Other Bookmarks" on the right of the bar.
- (void)createOtherBookmarksButton {
// Can't create this until the model is loaded, but only need to
// create it once.
- if (otherBookmarksButton_.get())
+ if (otherBookmarksButton_.get()) {
+ [self setOtherBookmarksButtonVisibility];
return;
+ }
// TODO(jrg): remove duplicate code
NSCell* cell = [self cellForBookmarkNode:bookmarkModel_->other_node()];
@@ -1345,6 +1361,8 @@
[button setAction:@selector(openBookmarkFolderFromButton:)];
[buttonView_ addSubview:button];
+ [self setOtherBookmarksButtonVisibility];
+
// Now that it's here, move the chevron over.
[self positionOffTheSideButton];
}
@@ -1554,9 +1572,11 @@
CGFloat maxViewX = NSMaxX([[self view] bounds]);
NSButton* otherBookmarksButton = otherBookmarksButton_.get();
// If necessary, pull in the width to account for the Other Bookmarks button.
- if (otherBookmarksButton_)
+ if ([self setOtherBookmarksButtonVisibility])
maxViewX = [otherBookmarksButton frame].origin.x -
bookmarks::kBookmarkHorizontalPadding;
+
+ [self positionOffTheSideButton];
// If we're already overflowing, then we need to account for the chevron.
if (barCount > displayedButtonCount_)
maxViewX = [offTheSideButton_ frame].origin.x -
@@ -2096,6 +2116,8 @@
// If we go from 0 --> 1 bookmarks we may need to hide the
// "bookmarks go here" text container.
[self showOrHideNoItemContainerForNode:model->GetBookmarkBarNode()];
+ // Cope with chevron or "Other Bookmarks" buttons possibly changing state.
+ [self reconfigureBookmarkBar];
}
// TODO(jrg): for now this is brute force.
@@ -2121,9 +2143,8 @@
// If the bar is one of the parents we may need to update the visibility
// of the "bookmarks go here" presentation.
[self showOrHideNoItemContainerForNode:model->GetBookmarkBarNode()];
- // If we moved the only item on the "off the side" menu somewhere
- // else, we may no longer need to show it.
- [self configureOffTheSideButtonContentsAndVisibility];
+ // Cope with chevron or "Other Bookmarks" buttons possibly changing state.
+ [self reconfigureBookmarkBar];
}
- (void)nodeRemoved:(BookmarkModel*)model
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698