summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-03 20:07:50 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-03 20:07:50 +0000
commit2e329df021404dd6c217960e94ec5d29ab2aebaf (patch)
treeaaa504135a23097e24cd677ed69b91d534ad42a3 /chrome/browser
parentc0c9717eb3399cb5034a9c3d45c1ac6a03d6e292 (diff)
downloadchromium_src-2e329df021404dd6c217960e94ec5d29ab2aebaf.zip
chromium_src-2e329df021404dd6c217960e94ec5d29ab2aebaf.tar.gz
chromium_src-2e329df021404dd6c217960e94ec5d29ab2aebaf.tar.bz2
Properly show/hide "off the side" button/menu (chevron) on bookmark bar as needed.
BUG=http://crbug.com/17852 TEST=delete all bookmarks. No chevron. Add one bookmark to bookmark bar. No chevron. Make window real wide. Add some more bookmarks (but not enough that it spills over). No chevron. Make window thinner. Chevron appears! Widen window until chevron hides. Add more bookmarks until it appears again. Review URL: http://codereview.chromium.org/201005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25356 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/cocoa/bookmark_bar_controller.h2
-rw-r--r--chrome/browser/cocoa/bookmark_bar_controller.mm19
-rw-r--r--chrome/browser/cocoa/bookmark_bar_controller_unittest.mm8
3 files changed, 12 insertions, 17 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_controller.h b/chrome/browser/cocoa/bookmark_bar_controller.h
index 8948510..a2ae151 100644
--- a/chrome/browser/cocoa/bookmark_bar_controller.h
+++ b/chrome/browser/cocoa/bookmark_bar_controller.h
@@ -144,7 +144,7 @@ class PrefService;
- (NSRect)frameForBookmarkButtonFromCell:(NSCell*)cell xOffset:(int*)xOffset;
- (void)checkForBookmarkButtonGrowth:(NSButton*)button;
- (void)frameDidChange;
-- (BOOL)offTheSideButtonIsEnabled;
+- (BOOL)offTheSideButtonIsHidden;
- (NSMenu *)menuForFolderNode:(const BookmarkNode*)node;
- (int64)nodeIdFromMenuTag:(int32)tag;
- (int32)menuTagFromNodeId:(int64)menuid;
diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm
index ed45bcc..e8e5daf 100644
--- a/chrome/browser/cocoa/bookmark_bar_controller.mm
+++ b/chrome/browser/cocoa/bookmark_bar_controller.mm
@@ -112,25 +112,25 @@ const CGFloat kBookmarkHorizontalPadding = 1.0;
// TODO(jrg): when we are smarter about creating buttons (e.g. don't
// bother creating buttons which aren't visible), we'll have to be
// smarter here too.
-- (void)checkEnableOffTheSideButton {
+- (void)checkHideOffTheSideButton {
NSButton* button = [buttons_ lastObject];
if ((!button) ||
(NSMaxX([button frame]) <=
NSMaxX([[button superview] frame]))) {
- [offTheSideButton_ setEnabled:NO];
+ [offTheSideButton_ setHidden:YES];
} else {
- [offTheSideButton_ setEnabled:YES];
+ [offTheSideButton_ setHidden:NO];
}
}
-- (BOOL)offTheSideButtonIsEnabled {
- return [offTheSideButton_ isEnabled];
+- (BOOL)offTheSideButtonIsHidden {
+ return [offTheSideButton_ isHidden];
}
// Called when our controlled frame has changed size.
// TODO(jrg): be smarter (e.g. add/remove buttons as appropriate).
- (void)frameDidChange {
- [self checkEnableOffTheSideButton];
+ [self checkHideOffTheSideButton];
}
// Show or hide the bar based on the value of |show|. Handles
@@ -520,11 +520,6 @@ const CGFloat kBookmarkHorizontalPadding = 1.0;
}
// Add all items from the given model to our bookmark bar.
-// TODO(jrg): lots of things!
-// - bookmark folders (e.g. menu from the button)
-// - button and menu on the right for when bookmarks don't all fit on the
-// screen
-// - ...
//
// TODO(jrg): write a "build bar" so there is a nice spot for things
// like the contextual menu which is invoked when not over a
@@ -577,7 +572,7 @@ const CGFloat kBookmarkHorizontalPadding = 1.0;
const BookmarkNode* node = model->GetBookmarkBarNode();
[self clearBookmarkBar];
[self addNodesToBar:node];
- [self checkEnableOffTheSideButton];
+ [self checkHideOffTheSideButton];
}
- (void)beingDeleted:(BookmarkModel*)model {
diff --git a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm
index 66a87bc..55c4c18 100644
--- a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm
+++ b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm
@@ -188,15 +188,15 @@ TEST_F(BookmarkBarControllerTest, FrameChangeNotification) {
}
// Confirm off the side button only enabled when reasonable.
-TEST_F(BookmarkBarControllerTest, OffTheSideButtonEnable) {
+TEST_F(BookmarkBarControllerTest, OffTheSideButtonHidden) {
BookmarkModel* model = helper_.profile()->GetBookmarkModel();
[bar_ loaded:model];
- EXPECT_FALSE([bar_ offTheSideButtonIsEnabled]);
+ EXPECT_TRUE([bar_ offTheSideButtonIsHidden]);
for (int i = 0; i < 2; i++) {
model->SetURLStarred(GURL("http://www.foo.com"), L"small", true);
- EXPECT_FALSE([bar_ offTheSideButtonIsEnabled]);
+ EXPECT_TRUE([bar_ offTheSideButtonIsHidden]);
}
for (int i = 0; i < 20; i++) {
@@ -205,7 +205,7 @@ TEST_F(BookmarkBarControllerTest, OffTheSideButtonEnable) {
L"super duper wide title",
GURL("http://superfriends.hall-of-justice.edu"));
}
- EXPECT_TRUE([bar_ offTheSideButtonIsEnabled]);
+ EXPECT_FALSE([bar_ offTheSideButtonIsHidden]);
}
TEST_F(BookmarkBarControllerTest, TagMap) {