| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #import "base/mac/bundle_locations.h" | 9 #import "base/mac/bundle_locations.h" |
| 10 #import "base/mac/foundation_util.h" | 10 #import "base/mac/foundation_util.h" |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 - (void)resetAllButtonPositionsWithAnimation:(BOOL)animate; | 248 - (void)resetAllButtonPositionsWithAnimation:(BOOL)animate; |
| 249 | 249 |
| 250 @end | 250 @end |
| 251 | 251 |
| 252 namespace bookmarks { | 252 namespace bookmarks { |
| 253 | 253 |
| 254 CGFloat BookmarkHorizontalPadding() { | 254 CGFloat BookmarkHorizontalPadding() { |
| 255 if (!ui::MaterialDesignController::IsModeMaterial()) { | 255 if (!ui::MaterialDesignController::IsModeMaterial()) { |
| 256 return 1.0; | 256 return 1.0; |
| 257 } | 257 } |
| 258 return 10.0; | 258 return 4.0; |
| 259 } | 259 } |
| 260 | 260 |
| 261 CGFloat BookmarkVerticalPadding() { | 261 CGFloat BookmarkVerticalPadding() { |
| 262 if (!ui::MaterialDesignController::IsModeMaterial()) { | 262 if (!ui::MaterialDesignController::IsModeMaterial()) { |
| 263 return 2.0; | 263 return 2.0; |
| 264 } | 264 } |
| 265 return 4.0; | 265 return 4.0; |
| 266 } | 266 } |
| 267 | 267 |
| 268 CGFloat BookmarkLeftMargin() { | 268 CGFloat BookmarkLeftMargin() { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 [[self view] setFrame:NSMakeRect(0, 0, initialWidth_, 0)]; | 479 [[self view] setFrame:NSMakeRect(0, 0, initialWidth_, 0)]; |
| 480 | 480 |
| 481 const bool isModeMaterial = ui::MaterialDesignController::IsModeMaterial(); | 481 const bool isModeMaterial = ui::MaterialDesignController::IsModeMaterial(); |
| 482 | 482 |
| 483 // Complete init of the "off the side" button, as much as we can. | 483 // Complete init of the "off the side" button, as much as we can. |
| 484 if (isModeMaterial) { | 484 if (isModeMaterial) { |
| 485 [offTheSideButton_ setImage:[self offTheSideButtonImage:NO]]; | 485 [offTheSideButton_ setImage:[self offTheSideButtonImage:NO]]; |
| 486 BookmarkButtonCell* offTheSideCell = [offTheSideButton_ cell]; | 486 BookmarkButtonCell* offTheSideCell = [offTheSideButton_ cell]; |
| 487 [offTheSideCell setTag:kMaterialStandardButtonTypeWithLimitedClickFeedback]; | 487 [offTheSideCell setTag:kMaterialStandardButtonTypeWithLimitedClickFeedback]; |
| 488 [offTheSideCell setImagePosition:NSImageOnly]; | 488 [offTheSideCell setImagePosition:NSImageOnly]; |
| 489 |
| 490 // The cell is configured in the nib to draw a white highlight when clicked. |
| 491 [offTheSideCell setHighlightsBy:NSNoCellMask]; |
| 489 } else { | 492 } else { |
| 490 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 493 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 491 [offTheSideButton_ setImage: | 494 [offTheSideButton_ setImage: |
| 492 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_CHEVRONS).ToNSImage()]; | 495 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_CHEVRONS).ToNSImage()]; |
| 493 [offTheSideButton_.draggableButton setDraggable:NO]; | 496 [offTheSideButton_.draggableButton setDraggable:NO]; |
| 494 [offTheSideButton_.draggableButton setActsOnMouseDown:YES]; | 497 [offTheSideButton_.draggableButton setActsOnMouseDown:YES]; |
| 495 } | 498 } |
| 496 | 499 |
| 497 // We are enabled by default. | 500 // We are enabled by default. |
| 498 barIsEnabled_ = YES; | 501 barIsEnabled_ = YES; |
| 499 | 502 |
| 500 // Remember the original sizes of the 'no items' and 'import bookmarks' | 503 // Remember the original sizes of the 'no items' and 'import bookmarks' |
| 501 // fields to aid in resizing when the window frame changes. | 504 // fields to aid in resizing when the window frame changes. |
| 502 originalNoItemsRect_ = [[buttonView_ noItemTextfield] frame]; | 505 originalNoItemsRect_ = [[buttonView_ noItemTextfield] frame]; |
| 503 originalImportBookmarksRect_ = [[buttonView_ importBookmarksButton] frame]; | 506 originalImportBookmarksRect_ = [[buttonView_ importBookmarksButton] frame]; |
| 504 if (isModeMaterial) { | 507 if (isModeMaterial) { |
| 505 // Bookmark buttons start farther from the bookmark bar's left edge so | 508 // Bookmark buttons start farther from the bookmark bar's left edge so |
| 506 // adjust the positions of the noItems and importBookmarks textfields. | 509 // adjust the positions of the noItems and importBookmarks textfields. |
| 507 const CGFloat kMaterialBookmarksTextfieldOffsetX = 14; | 510 const CGFloat kMaterialBookmarksTextfieldOffsetX = 14; |
| 508 originalNoItemsRect_.origin.x += kMaterialBookmarksTextfieldOffsetX; | 511 originalNoItemsRect_.origin.x += kMaterialBookmarksTextfieldOffsetX; |
| 509 [[buttonView_ noItemTextfield] setFrame:originalNoItemsRect_]; | 512 [[buttonView_ noItemTextfield] setFrame:originalNoItemsRect_]; |
| 510 | 513 |
| 511 originalImportBookmarksRect_.origin.x += kMaterialBookmarksTextfieldOffsetX; | 514 originalImportBookmarksRect_.origin.x += kMaterialBookmarksTextfieldOffsetX; |
| 512 [[buttonView_ importBookmarksButton] setFrame:originalImportBookmarksRect_]; | 515 [[buttonView_ importBookmarksButton] setFrame:originalImportBookmarksRect_]; |
| 516 |
| 517 // Move the chevron button up 2pts from its position in the xib. |
| 518 NSRect chevronButtonFrame = [offTheSideButton_ frame]; |
| 519 chevronButtonFrame.origin.y -= 2; |
| 520 [offTheSideButton_ setFrame:chevronButtonFrame]; |
| 513 } | 521 } |
| 514 | 522 |
| 515 // To make life happier when the bookmark bar is floating, the chevron is a | 523 // To make life happier when the bookmark bar is floating, the chevron is a |
| 516 // child of the button view. | 524 // child of the button view. |
| 517 [offTheSideButton_ removeFromSuperview]; | 525 [offTheSideButton_ removeFromSuperview]; |
| 518 [buttonView_ addSubview:offTheSideButton_]; | 526 [buttonView_ addSubview:offTheSideButton_]; |
| 519 | 527 |
| 520 // When resized we may need to add new buttons, or remove them (if | 528 // When resized we may need to add new buttons, or remove them (if |
| 521 // no longer visible), or add/remove the "off the side" menu. | 529 // no longer visible), or add/remove the "off the side" menu. |
| 522 [[self view] setPostsFrameChangedNotifications:YES]; | 530 [[self view] setPostsFrameChangedNotifications:YES]; |
| (...skipping 2559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3082 - (id<BookmarkButtonControllerProtocol>)controllerForNode: | 3090 - (id<BookmarkButtonControllerProtocol>)controllerForNode: |
| 3083 (const BookmarkNode*)node { | 3091 (const BookmarkNode*)node { |
| 3084 // See if it's in the bar, then if it is in the hierarchy of visible | 3092 // See if it's in the bar, then if it is in the hierarchy of visible |
| 3085 // folder menus. | 3093 // folder menus. |
| 3086 if (bookmarkModel_->bookmark_bar_node() == node) | 3094 if (bookmarkModel_->bookmark_bar_node() == node) |
| 3087 return self; | 3095 return self; |
| 3088 return [folderController_ controllerForNode:node]; | 3096 return [folderController_ controllerForNode:node]; |
| 3089 } | 3097 } |
| 3090 | 3098 |
| 3091 @end | 3099 @end |
| OLD | NEW |