summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 23:56:19 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 23:56:19 +0000
commitcb514b8024f425b974c680b06dcace135b32de39 (patch)
tree79a1530164118302eee0562b6bdf58f3a022f880 /chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm
parentb1e8cb31f85869171dcb383c7ec5e8176833ec04 (diff)
downloadchromium_src-cb514b8024f425b974c680b06dcace135b32de39.zip
chromium_src-cb514b8024f425b974c680b06dcace135b32de39.tar.gz
chromium_src-cb514b8024f425b974c680b06dcace135b32de39.tar.bz2
Added menus for bookmark bar folders. This is NOT based on the Cole
prototype; it is an attempt to get something functional in the short term, and have a visual baseline before doing something new. Added folder icons for bookmark bar folder buttons. Added an "off the side" button/menu for bookmark buttons which don't fit on the bar. Updated "Add page..." item to allow creating bookmarks in the folders (if selected over a folder button). BUG=http://crbug.com/8381 TEST=Here we go: 1) Make sure bookmark bar folders have the "folder" icon. 2) Right click on a folder --> Add Page, and add a bookmark. Make sure bookmark is now in the folder, not at the top level. 3) (Oh, you just implicitly verified you can open bookmark folders!) 4) Add 5 bookmarks then shrink the window thinner so all bookmark buttons don't fit. Make sure "off the right" button gets enabled (on right side of bar) and shows bookmarks in a pop-up menu (when clicked) that don't completely fit on the bar. 5) Make it super-wide so the all fit and make sure "off the right" button is disabled. 6) Add a bunch of bookmarks to a folder; make sure they all work. 7) Add nested folders (by editing the bookmark pref file and restarting Chrome) and make sure bookmark folder buttons have nested/cascading menus. Review URL: http://codereview.chromium.org/159286 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm')
-rw-r--r--chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm24
1 files changed, 22 insertions, 2 deletions
diff --git a/chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm b/chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm
index a62103f..46f17bf 100644
--- a/chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm
+++ b/chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm
@@ -2,17 +2,37 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#import "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h"
-
+#include "app/gfx/text_elider.h"
+#include "base/sys_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/browser.h"
#import "chrome/browser/cocoa/bookmark_menu_bridge.h"
+#import "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "webkit/glue/window_open_disposition.h" // CURRENT_TAB
+namespace {
+
+// Menus more than this many pixels wide will get trimmed
+// TODO(jrg): ask UI dudes what a good value is.
+const NSUInteger kMaximumMenuPixelsWide = 300;
+
+}
+
@implementation BookmarkMenuCocoaController
++ (NSString*)menuTitleForNode:(const BookmarkNode*)node {
+ NSFont* nsfont = [NSFont menuBarFontOfSize:0]; // 0 means "default"
+ gfx::Font font = gfx::Font::CreateFont(base::SysNSStringToWide([nsfont
+ fontName]),
+ (int)[nsfont pointSize]);
+ std::wstring title = gfx::ElideText(node->GetTitle(),
+ font,
+ kMaximumMenuPixelsWide);
+ return base::SysWideToNSString(title);
+}
+
- (id)initWithBridge:(BookmarkMenuBridge *)bridge {
if ((self = [super init])) {
bridge_ = bridge;