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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm

Issue 7462018: [Mac] "Refactor" DraggableButton into a mixin and impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
6 6
7 #include "base/mac/mac_util.h" 7 #include "base/mac/mac_util.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "chrome/browser/bookmarks/bookmark_editor.h" 10 #include "chrome/browser/bookmarks/bookmark_editor.h"
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 330
331 - (void)awakeFromNib { 331 - (void)awakeFromNib {
332 // We default to NOT open, which means height=0. 332 // We default to NOT open, which means height=0.
333 DCHECK([[self view] isHidden]); // Hidden so it's OK to change. 333 DCHECK([[self view] isHidden]); // Hidden so it's OK to change.
334 334
335 // Set our initial height to zero, since that is what the superview 335 // Set our initial height to zero, since that is what the superview
336 // expects. We will resize ourselves open later if needed. 336 // expects. We will resize ourselves open later if needed.
337 [[self view] setFrame:NSMakeRect(0, 0, initialWidth_, 0)]; 337 [[self view] setFrame:NSMakeRect(0, 0, initialWidth_, 0)];
338 338
339 // Complete init of the "off the side" button, as much as we can. 339 // Complete init of the "off the side" button, as much as we can.
340 [offTheSideButton_ setDraggable:NO]; 340 [offTheSideButton_.draggableButton setDraggable:NO];
341 [offTheSideButton_ setActsOnMouseDown:YES]; 341 [offTheSideButton_.draggableButton setActsOnMouseDown:YES];
342 342
343 // We are enabled by default. 343 // We are enabled by default.
344 barIsEnabled_ = YES; 344 barIsEnabled_ = YES;
345 345
346 // Remember the original sizes of the 'no items' and 'import bookmarks' 346 // Remember the original sizes of the 'no items' and 'import bookmarks'
347 // fields to aid in resizing when the window frame changes. 347 // fields to aid in resizing when the window frame changes.
348 originalNoItemsRect_ = [[buttonView_ noItemTextfield] frame]; 348 originalNoItemsRect_ = [[buttonView_ noItemTextfield] frame];
349 originalImportBookmarksRect_ = [[buttonView_ importBookmarksButton] frame]; 349 originalImportBookmarksRect_ = [[buttonView_ importBookmarksButton] frame];
350 350
351 // To make life happier when the bookmark bar is floating, the chevron is a 351 // To make life happier when the bookmark bar is floating, the chevron is a
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 if (themeProvider) { 1109 if (themeProvider) {
1110 NSColor* color = 1110 NSColor* color =
1111 themeProvider->GetNSColor(ThemeService::COLOR_BOOKMARK_TEXT, 1111 themeProvider->GetNSColor(ThemeService::COLOR_BOOKMARK_TEXT,
1112 true); 1112 true);
1113 [cell setTextColor:color]; 1113 [cell setTextColor:color];
1114 } 1114 }
1115 1115
1116 if (node->is_folder()) { 1116 if (node->is_folder()) {
1117 [button setTarget:self]; 1117 [button setTarget:self];
1118 [button setAction:@selector(openBookmarkFolderFromButton:)]; 1118 [button setAction:@selector(openBookmarkFolderFromButton:)];
1119 [button setActsOnMouseDown:YES]; 1119 [[button draggableButton] setActsOnMouseDown:YES];
1120 // If it has a title, and it will be truncated, show full title in 1120 // If it has a title, and it will be truncated, show full title in
1121 // tooltip. 1121 // tooltip.
1122 NSString* title = base::SysUTF16ToNSString(node->GetTitle()); 1122 NSString* title = base::SysUTF16ToNSString(node->GetTitle());
1123 if ([title length] && 1123 if ([title length] &&
1124 [[button cell] cellSize].width > bookmarks::kDefaultBookmarkWidth) { 1124 [[button cell] cellSize].width > bookmarks::kDefaultBookmarkWidth) {
1125 [button setToolTip:title]; 1125 [button setToolTip:title];
1126 } 1126 }
1127 } else { 1127 } else {
1128 // Make the button do something 1128 // Make the button do something
1129 [button setTarget:self]; 1129 [button setTarget:self];
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 return; 1187 return;
1188 } 1188 }
1189 1189
1190 // TODO(jrg): remove duplicate code 1190 // TODO(jrg): remove duplicate code
1191 NSCell* cell = [self cellForBookmarkNode:bookmarkModel_->other_node()]; 1191 NSCell* cell = [self cellForBookmarkNode:bookmarkModel_->other_node()];
1192 int ignored = 0; 1192 int ignored = 0;
1193 NSRect frame = [self frameForBookmarkButtonFromCell:cell xOffset:&ignored]; 1193 NSRect frame = [self frameForBookmarkButtonFromCell:cell xOffset:&ignored];
1194 frame.origin.x = [[self buttonView] bounds].size.width - frame.size.width; 1194 frame.origin.x = [[self buttonView] bounds].size.width - frame.size.width;
1195 frame.origin.x -= bookmarks::kBookmarkHorizontalPadding; 1195 frame.origin.x -= bookmarks::kBookmarkHorizontalPadding;
1196 BookmarkButton* button = [[BookmarkButton alloc] initWithFrame:frame]; 1196 BookmarkButton* button = [[BookmarkButton alloc] initWithFrame:frame];
1197 [button setDraggable:NO]; 1197 [[button draggableButton] setDraggable:NO];
1198 [button setActsOnMouseDown:YES]; 1198 [[button draggableButton] setActsOnMouseDown:YES];
1199 otherBookmarksButton_.reset(button); 1199 otherBookmarksButton_.reset(button);
1200 view_id_util::SetID(button, VIEW_ID_OTHER_BOOKMARKS); 1200 view_id_util::SetID(button, VIEW_ID_OTHER_BOOKMARKS);
1201 1201
1202 // Make sure this button, like all other BookmarkButtons, lives 1202 // Make sure this button, like all other BookmarkButtons, lives
1203 // until the end of the current event loop. 1203 // until the end of the current event loop.
1204 [[button retain] autorelease]; 1204 [[button retain] autorelease];
1205 1205
1206 // Peg at right; keep same height as bar. 1206 // Peg at right; keep same height as bar.
1207 [button setAutoresizingMask:(NSViewMinXMargin)]; 1207 [button setAutoresizingMask:(NSViewMinXMargin)];
1208 [button setCell:cell]; 1208 [button setCell:cell];
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after
2481 // to minimize touching the object passed in (likely a mock). 2481 // to minimize touching the object passed in (likely a mock).
2482 - (void)setButtonContextMenu:(id)menu { 2482 - (void)setButtonContextMenu:(id)menu {
2483 buttonContextMenu_ = menu; 2483 buttonContextMenu_ = menu;
2484 } 2484 }
2485 2485
2486 - (void)setIgnoreAnimations:(BOOL)ignore { 2486 - (void)setIgnoreAnimations:(BOOL)ignore {
2487 ignoreAnimations_ = ignore; 2487 ignoreAnimations_ = ignore;
2488 } 2488 }
2489 2489
2490 @end 2490 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698