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_folder_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" |
6 | 6 |
7 #include "base/mac/bundle_locations.h" | 7 #include "base/mac/bundle_locations.h" |
8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 deltaVisibleY(0.0), | 101 deltaVisibleY(0.0), |
102 deltaScrollerHeight(0.0), | 102 deltaScrollerHeight(0.0), |
103 deltaScrollerY(0.0), | 103 deltaScrollerY(0.0), |
104 minimumY(0.0), | 104 minimumY(0.0), |
105 screenBottomY(0.0), | 105 screenBottomY(0.0), |
106 oldWindowY(0.0), | 106 oldWindowY(0.0), |
107 folderY(0.0), | 107 folderY(0.0), |
108 folderTop(0.0) {} | 108 folderTop(0.0) {} |
109 }; | 109 }; |
110 | 110 |
| 111 NSRect GetFirstButtonFrameForHeight(CGFloat height) { |
| 112 CGFloat y = height - bookmarks::kBookmarkFolderButtonHeight - |
| 113 bookmarks::kBookmarkVerticalPadding; |
| 114 return NSMakeRect(0, y, bookmarks::kDefaultBookmarkWidth, |
| 115 bookmarks::kBookmarkFolderButtonHeight); |
| 116 } |
| 117 |
111 } // namespace | 118 } // namespace |
112 | 119 |
113 | 120 |
114 // Required to set the right tracking bounds for our fake menus. | 121 // Required to set the right tracking bounds for our fake menus. |
115 @interface NSView(Private) | 122 @interface NSView(Private) |
116 - (void)_updateTrackingAreas; | 123 - (void)_updateTrackingAreas; |
117 @end | 124 @end |
118 | 125 |
119 @interface BookmarkBarFolderController(Private) | 126 @interface BookmarkBarFolderController(Private) |
120 - (void)configureWindow; | 127 - (void)configureWindow; |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 // Must have at least 1 button (for "empty") | 786 // Must have at least 1 button (for "empty") |
780 int buttons = std::max(node->child_count() - startingIndex, 1); | 787 int buttons = std::max(node->child_count() - startingIndex, 1); |
781 | 788 |
782 // Prelim height of the window. We'll trim later as needed. | 789 // Prelim height of the window. We'll trim later as needed. |
783 int height = [self menuHeightForButtonCount:buttons]; | 790 int height = [self menuHeightForButtonCount:buttons]; |
784 // We'll need this soon... | 791 // We'll need this soon... |
785 [self window]; | 792 [self window]; |
786 | 793 |
787 // TODO(jrg): combine with frame code in bookmark_bar_controller.mm | 794 // TODO(jrg): combine with frame code in bookmark_bar_controller.mm |
788 // http://crbug.com/35966 | 795 // http://crbug.com/35966 |
789 NSRect buttonsOuterFrame = NSMakeRect( | 796 NSRect buttonsOuterFrame = GetFirstButtonFrameForHeight(height); |
790 0, | |
791 height - bookmarks::kBookmarkFolderButtonHeight - | |
792 bookmarks::kBookmarkVerticalPadding, | |
793 bookmarks::kDefaultBookmarkWidth, | |
794 bookmarks::kBookmarkFolderButtonHeight); | |
795 | 797 |
796 // TODO(jrg): combine with addNodesToButtonList: code from | 798 // TODO(jrg): combine with addNodesToButtonList: code from |
797 // bookmark_bar_controller.mm (but use y offset) | 799 // bookmark_bar_controller.mm (but use y offset) |
798 // http://crbug.com/35966 | 800 // http://crbug.com/35966 |
799 if (node->empty()) { | 801 if (node->empty()) { |
800 // If no children we are the empty button. | 802 // If no children we are the empty button. |
801 BookmarkButton* button = [self makeButtonForNode:nil | 803 BookmarkButton* button = [self makeButtonForNode:nil |
802 frame:buttonsOuterFrame]; | 804 frame:buttonsOuterFrame]; |
803 [buttons_ addObject:button]; | 805 [buttons_ addObject:button]; |
804 [folderView_ addSubview:button]; | 806 [folderView_ addSubview:button]; |
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1910 for (NSButton* aButton in buttons_.get()) { | 1912 for (NSButton* aButton in buttons_.get()) { |
1911 // If this button is showing its menu then we need to move the menu, too. | 1913 // If this button is showing its menu then we need to move the menu, too. |
1912 if (aButton == subButton) | 1914 if (aButton == subButton) |
1913 [folderController_ | 1915 [folderController_ |
1914 offsetFolderMenuWindow:NSMakeSize(0.0, chrome::kBookmarkBarHeight)]; | 1916 offsetFolderMenuWindow:NSMakeSize(0.0, chrome::kBookmarkBarHeight)]; |
1915 } | 1917 } |
1916 } else { | 1918 } else { |
1917 // If all nodes have been removed from this folder then add in the | 1919 // If all nodes have been removed from this folder then add in the |
1918 // 'empty' placeholder button. | 1920 // 'empty' placeholder button. |
1919 NSRect buttonFrame = | 1921 NSRect buttonFrame = |
1920 NSMakeRect(0.0, 0.0, bookmarks::kDefaultBookmarkWidth, | 1922 GetFirstButtonFrameForHeight([self menuHeightForButtonCount:1]); |
1921 bookmarks::kBookmarkFolderButtonHeight); | |
1922 BookmarkButton* button = [self makeButtonForNode:nil | 1923 BookmarkButton* button = [self makeButtonForNode:nil |
1923 frame:buttonFrame]; | 1924 frame:buttonFrame]; |
1924 [buttons_ addObject:button]; | 1925 [buttons_ addObject:button]; |
1925 [folderView_ addSubview:button]; | 1926 [folderView_ addSubview:button]; |
1926 buttonCount = 1; | 1927 buttonCount = 1; |
1927 } | 1928 } |
1928 | 1929 |
1929 [self adjustWindowForButtonCount:buttonCount]; | 1930 [self adjustWindowForButtonCount:buttonCount]; |
1930 | 1931 |
1931 if (animate && !ignoreAnimations_) | 1932 if (animate && !ignoreAnimations_) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1970 | 1971 |
1971 - (void)setIgnoreAnimations:(BOOL)ignore { | 1972 - (void)setIgnoreAnimations:(BOOL)ignore { |
1972 ignoreAnimations_ = ignore; | 1973 ignoreAnimations_ = ignore; |
1973 } | 1974 } |
1974 | 1975 |
1975 - (BookmarkButton*)buttonThatMouseIsIn { | 1976 - (BookmarkButton*)buttonThatMouseIsIn { |
1976 return buttonThatMouseIsIn_; | 1977 return buttonThatMouseIsIn_; |
1977 } | 1978 } |
1978 | 1979 |
1979 @end // BookmarkBarFolderController | 1980 @end // BookmarkBarFolderController |
OLD | NEW |