| 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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 // Change the layout of the bookmark bar's subviews in response to a visibility | 595 // Change the layout of the bookmark bar's subviews in response to a visibility |
| 596 // change (e.g., show or hide the bar) or style change (attached or floating). | 596 // change (e.g., show or hide the bar) or style change (attached or floating). |
| 597 - (void)layoutSubviews { | 597 - (void)layoutSubviews { |
| 598 NSRect frame = [[self view] frame]; | 598 NSRect frame = [[self view] frame]; |
| 599 NSRect buttonViewFrame = NSMakeRect(0, 0, NSWidth(frame), NSHeight(frame)); | 599 NSRect buttonViewFrame = NSMakeRect(0, 0, NSWidth(frame), NSHeight(frame)); |
| 600 | 600 |
| 601 // Add padding to the detached bookmark bar. | 601 // Add padding to the detached bookmark bar. |
| 602 // The state of our morph (if any); 1 is total bubble, 0 is the regular bar. | 602 // The state of our morph (if any); 1 is total bubble, 0 is the regular bar. |
| 603 CGFloat morph = [self detachedMorphProgress]; | 603 CGFloat morph = [self detachedMorphProgress]; |
| 604 CGFloat padding = 0; | 604 CGFloat padding = 0; |
| 605 if (ui::MaterialDesignController::IsModeMaterial()) { | 605 padding = bookmarks::kNTPBookmarkBarPadding; |
| 606 padding = bookmarks::kMaterialNTPBookmarkBarPadding; | |
| 607 } else { | |
| 608 padding = bookmarks::kNTPBookmarkBarPadding; | |
| 609 } | |
| 610 buttonViewFrame = | 606 buttonViewFrame = |
| 611 NSInsetRect(buttonViewFrame, morph * padding, morph * padding); | 607 NSInsetRect(buttonViewFrame, morph * padding, morph * padding); |
| 612 | 608 |
| 613 [buttonView_ setFrame:buttonViewFrame]; | 609 [buttonView_ setFrame:buttonViewFrame]; |
| 614 | 610 |
| 615 // Update bookmark button backgrounds. | 611 // Update bookmark button backgrounds. |
| 616 if ([self isAnimationRunning]) { | 612 if ([self isAnimationRunning]) { |
| 617 for (NSButton* button in buttons_.get()) | 613 for (NSButton* button in buttons_.get()) |
| 618 [button setNeedsDisplay:YES]; | 614 [button setNeedsDisplay:YES]; |
| 619 // Update the apps and other buttons explicitly, since they are not in the | 615 // Update the apps and other buttons explicitly, since they are not in the |
| (...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1977 } | 1973 } |
| 1978 | 1974 |
| 1979 // Returns a frame appropriate for the given bookmark cell, suitable | 1975 // Returns a frame appropriate for the given bookmark cell, suitable |
| 1980 // for creating an NSButton that will contain it. |xOffset| is the X | 1976 // for creating an NSButton that will contain it. |xOffset| is the X |
| 1981 // offset for the frame; it is increased to be an appropriate X offset | 1977 // offset for the frame; it is increased to be an appropriate X offset |
| 1982 // for the next button. | 1978 // for the next button. |
| 1983 - (NSRect)frameForBookmarkButtonFromCell:(NSCell*)cell | 1979 - (NSRect)frameForBookmarkButtonFromCell:(NSCell*)cell |
| 1984 xOffset:(int*)xOffset { | 1980 xOffset:(int*)xOffset { |
| 1985 DCHECK(xOffset); | 1981 DCHECK(xOffset); |
| 1986 NSRect bounds = [buttonView_ bounds]; | 1982 NSRect bounds = [buttonView_ bounds]; |
| 1987 if (ui::MaterialDesignController::IsModeMaterial()) { | 1983 bounds.size.height = bookmarks::kBookmarkButtonHeight; |
| 1988 bounds.size.height = bookmarks::kMaterialBookmarkButtonHeight; | |
| 1989 } else { | |
| 1990 bounds.size.height = bookmarks::kBookmarkButtonHeight; | |
| 1991 } | |
| 1992 | 1984 |
| 1993 NSRect frame = NSInsetRect(bounds, | 1985 NSRect frame = NSInsetRect(bounds, |
| 1994 bookmarks::BookmarkHorizontalPadding(), | 1986 bookmarks::BookmarkHorizontalPadding(), |
| 1995 bookmarks::BookmarkVerticalPadding()); | 1987 bookmarks::BookmarkVerticalPadding()); |
| 1996 frame.size.width = [self widthForBookmarkButtonCell:cell]; | 1988 frame.size.width = [self widthForBookmarkButtonCell:cell]; |
| 1997 | 1989 |
| 1998 // Add an X offset based on what we've already done | 1990 // Add an X offset based on what we've already done |
| 1999 frame.origin.x += *xOffset; | 1991 frame.origin.x += *xOffset; |
| 2000 | 1992 |
| 2001 // And up the X offset for next time. | 1993 // And up the X offset for next time. |
| (...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3087 - (id<BookmarkButtonControllerProtocol>)controllerForNode: | 3079 - (id<BookmarkButtonControllerProtocol>)controllerForNode: |
| 3088 (const BookmarkNode*)node { | 3080 (const BookmarkNode*)node { |
| 3089 // See if it's in the bar, then if it is in the hierarchy of visible | 3081 // See if it's in the bar, then if it is in the hierarchy of visible |
| 3090 // folder menus. | 3082 // folder menus. |
| 3091 if (bookmarkModel_->bookmark_bar_node() == node) | 3083 if (bookmarkModel_->bookmark_bar_node() == node) |
| 3092 return self; | 3084 return self; |
| 3093 return [folderController_ controllerForNode:node]; | 3085 return [folderController_ controllerForNode:node]; |
| 3094 } | 3086 } |
| 3095 | 3087 |
| 3096 @end | 3088 @end |
| OLD | NEW |