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

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

Issue 2013523005: [Mac][Material Design] Bring bookmark hover state, etc. up to spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo, fix chevron button highlight state. Created 4 years, 6 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
OLDNEW
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_folder_controller.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/mac/bundle_locations.h" 9 #include "base/mac/bundle_locations.h"
10 #include "base/mac/sdk_forward_declarations.h" 10 #include "base/mac/sdk_forward_declarations.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 deltaScrollerY(0.0), 117 deltaScrollerY(0.0),
118 minimumY(0.0), 118 minimumY(0.0),
119 screenBottomY(0.0), 119 screenBottomY(0.0),
120 oldWindowY(0.0), 120 oldWindowY(0.0),
121 folderY(0.0), 121 folderY(0.0),
122 folderTop(0.0) {} 122 folderTop(0.0) {}
123 }; 123 };
124 124
125 NSRect GetFirstButtonFrameForHeight(CGFloat height) { 125 NSRect GetFirstButtonFrameForHeight(CGFloat height) {
126 CGFloat y = height - bookmarks::kBookmarkFolderButtonHeight - 126 CGFloat y = height - bookmarks::kBookmarkFolderButtonHeight -
127 bookmarks::BookmarkVerticalPadding(); 127 bookmarks::BookmarkTopVerticalPadding();
128 return NSMakeRect(0, y, bookmarks::kDefaultBookmarkWidth, 128 return NSMakeRect(0, y, bookmarks::kDefaultBookmarkWidth,
129 bookmarks::kBookmarkFolderButtonHeight); 129 bookmarks::kBookmarkFolderButtonHeight);
130 } 130 }
131 131
132 } // namespace 132 } // namespace
133 133
134 namespace bookmarks {
135
136 CGFloat BookmarkTopVerticalPadding() {
137 return bookmarks::BookmarkVerticalPadding();
138 }
139
140 CGFloat BookmarkBottomVerticalPadding() {
141 return ui::MaterialDesignController::IsModeMaterial()
142 ? 0 : bookmarks::BookmarkVerticalPadding();
143 }
144
145 } // bookmarks
146
134 147
135 // Required to set the right tracking bounds for our fake menus. 148 // Required to set the right tracking bounds for our fake menus.
136 @interface NSView(Private) 149 @interface NSView(Private)
137 - (void)_updateTrackingAreas; 150 - (void)_updateTrackingAreas;
138 @end 151 @end
139 152
140 @interface BookmarkBarFolderController () 153 @interface BookmarkBarFolderController ()
141 - (void)configureWindow; 154 - (void)configureWindow;
142 - (void)addOrUpdateScrollTracking; 155 - (void)addOrUpdateScrollTracking;
143 - (void)removeScrollTracking; 156 - (void)removeScrollTracking;
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 (NSMinY(screenVisibleFrame) + bookmarks::kScrollWindowVerticalMargin); 558 (NSMinY(screenVisibleFrame) + bookmarks::kScrollWindowVerticalMargin);
546 if ((availableVerticalSpace < kMinSqueezedMenuHeight) && 559 if ((availableVerticalSpace < kMinSqueezedMenuHeight) &&
547 (windowHeight > availableVerticalSpace)) { 560 (windowHeight > availableVerticalSpace)) {
548 newWindowTopLeft.y = std::min( 561 newWindowTopLeft.y = std::min(
549 newWindowTopLeft.y + windowHeight + NSHeight([parentButton_ frame]), 562 newWindowTopLeft.y + windowHeight + NSHeight([parentButton_ frame]),
550 NSMaxY(screenVisibleFrame)); 563 NSMaxY(screenVisibleFrame));
551 } 564 }
552 } else { 565 } else {
553 // Parent is a folder: expose as much as we can vertically; grow right/left. 566 // Parent is a folder: expose as much as we can vertically; grow right/left.
554 newWindowTopLeft.x = [self childFolderWindowLeftForWidth:windowWidth]; 567 newWindowTopLeft.x = [self childFolderWindowLeftForWidth:windowWidth];
555 NSPoint topOfWindow = NSMakePoint(0, 568 NSPoint topOfWindow =
556 NSMaxY([parentButton_ frame]) - 569 NSMakePoint(0, NSMaxY([parentButton_ frame]) +
557 bookmarks::BookmarkVerticalPadding()); 570 bookmarks::BookmarkTopVerticalPadding());
558 topOfWindow = ui::ConvertPointFromWindowToScreen( 571 topOfWindow = ui::ConvertPointFromWindowToScreen(
559 [parentButton_ window], 572 [parentButton_ window],
560 [[parentButton_ superview] convertPoint:topOfWindow toView:nil]); 573 [[parentButton_ superview] convertPoint:topOfWindow toView:nil]);
561 newWindowTopLeft.y = topOfWindow.y + 574 newWindowTopLeft.y = topOfWindow.y;
562 2 * bookmarks::BookmarkVerticalPadding();
563 } 575 }
564 return newWindowTopLeft; 576 return newWindowTopLeft;
565 } 577 }
566 578
567 // Set our window level to the right spot so we're above the menubar, dock, etc. 579 // Set our window level to the right spot so we're above the menubar, dock, etc.
568 // Factored out so we can override/noop in a unit test. 580 // Factored out so we can override/noop in a unit test.
569 - (void)configureWindowLevel { 581 - (void)configureWindowLevel {
570 [[self window] setLevel:NSPopUpMenuWindowLevel]; 582 [[self window] setLevel:NSPopUpMenuWindowLevel];
571 } 583 }
572 584
573 - (int)menuHeightForButtonCount:(int)buttonCount { 585 - (int)menuHeightForButtonCount:(int)buttonCount {
574 // This does not take into account any padding which may be required at the 586 // This does not take into account any padding which may be required at the
575 // top and/or bottom of the window. 587 // top and/or bottom of the window.
576 return (buttonCount * bookmarks::kBookmarkFolderButtonHeight) + 588 return (buttonCount * bookmarks::kBookmarkFolderButtonHeight) +
577 2 * bookmarks::BookmarkVerticalPadding(); 589 bookmarks::BookmarkTopVerticalPadding() +
590 bookmarks::BookmarkBottomVerticalPadding();
578 } 591 }
579 592
580 - (void)adjustWindowLeft:(CGFloat)windowLeft 593 - (void)adjustWindowLeft:(CGFloat)windowLeft
581 size:(NSSize)windowSize 594 size:(NSSize)windowSize
582 scrollingBy:(CGFloat)scrollDelta { 595 scrollingBy:(CGFloat)scrollDelta {
583 // Callers of this function should make adjustments to the vertical 596 // Callers of this function should make adjustments to the vertical
584 // attributes of the folder view only (height, scroll position). 597 // attributes of the folder view only (height, scroll position).
585 // This function will then make appropriate layout adjustments in order 598 // This function will then make appropriate layout adjustments in order
586 // to accommodate screen/dock margins, scroll-up and scroll-down arrow 599 // to accommodate screen/dock margins, scroll-up and scroll-down arrow
587 // presentation, etc. 600 // presentation, etc.
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 int destIndex = [self indexForDragToPoint:point]; 1752 int destIndex = [self indexForDragToPoint:point];
1740 int numButtons = static_cast<int>([buttons_ count]); 1753 int numButtons = static_cast<int>([buttons_ count]);
1741 1754
1742 // If it's a drop strictly between existing buttons or at the very beginning 1755 // If it's a drop strictly between existing buttons or at the very beginning
1743 if (destIndex >= 0 && destIndex < numButtons) { 1756 if (destIndex >= 0 && destIndex < numButtons) {
1744 // ... put the indicator right between the buttons. 1757 // ... put the indicator right between the buttons.
1745 BookmarkButton* button = 1758 BookmarkButton* button =
1746 [buttons_ objectAtIndex:static_cast<NSUInteger>(destIndex)]; 1759 [buttons_ objectAtIndex:static_cast<NSUInteger>(destIndex)];
1747 DCHECK(button); 1760 DCHECK(button);
1748 NSRect buttonFrame = [button frame]; 1761 NSRect buttonFrame = [button frame];
1749 y = NSMaxY(buttonFrame) + 0.5 * bookmarks::BookmarkVerticalPadding(); 1762 y = NSMaxY(buttonFrame) + 0.5 * bookmarks::BookmarkTopVerticalPadding();
1750 1763
1751 // If it's a drop at the end (past the last button, if there are any) ... 1764 // If it's a drop at the end (past the last button, if there are any) ...
1752 } else if (destIndex == numButtons) { 1765 } else if (destIndex == numButtons) {
1753 // and if it's past the last button ... 1766 // and if it's past the last button ...
1754 if (numButtons > 0) { 1767 if (numButtons > 0) {
1755 // ... find the last button, and put the indicator below it. 1768 // ... find the last button, and put the indicator below it.
1756 BookmarkButton* button = 1769 BookmarkButton* button =
1757 [buttons_ objectAtIndex:static_cast<NSUInteger>(destIndex - 1)]; 1770 [buttons_ objectAtIndex:static_cast<NSUInteger>(destIndex - 1)];
1758 DCHECK(button); 1771 DCHECK(button);
1759 NSRect buttonFrame = [button frame]; 1772 NSRect buttonFrame = [button frame];
1760 y = buttonFrame.origin.y - 0.5 * bookmarks::BookmarkVerticalPadding(); 1773 y = buttonFrame.origin.y -
1774 0.5 * bookmarks::BookmarkBottomVerticalPadding();
1761 1775
1762 } 1776 }
1763 } else { 1777 } else {
1764 NOTREACHED(); 1778 NOTREACHED();
1765 } 1779 }
1766 1780
1767 return y; 1781 return y;
1768 } 1782 }
1769 1783
1770 - (Profile*)profile { 1784 - (Profile*)profile {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 2080
2067 - (void)setIgnoreAnimations:(BOOL)ignore { 2081 - (void)setIgnoreAnimations:(BOOL)ignore {
2068 ignoreAnimations_ = ignore; 2082 ignoreAnimations_ = ignore;
2069 } 2083 }
2070 2084
2071 - (BookmarkButton*)buttonThatMouseIsIn { 2085 - (BookmarkButton*)buttonThatMouseIsIn {
2072 return buttonThatMouseIsIn_; 2086 return buttonThatMouseIsIn_;
2073 } 2087 }
2074 2088
2075 @end // BookmarkBarFolderController 2089 @end // BookmarkBarFolderController
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698