OLD | NEW |
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 #ifndef CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_FOLDER_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_FOLDER_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_FOLDER_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_FOLDER_CONTROLLER_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/memory/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" | 11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
12 #import "ui/base/cocoa/tracking_area.h" | 12 #import "ui/base/cocoa/tracking_area.h" |
13 | 13 |
14 class Profile; | 14 class Profile; |
15 | 15 |
16 @class BookmarkBarController; | 16 @class BookmarkBarController; |
17 @class BookmarkBarFolderView; | 17 @class BookmarkBarFolderView; |
18 @class BookmarkBarFolderHoverState; | 18 @class BookmarkBarFolderHoverState; |
19 @class BookmarkBarFolderWindow; | 19 @class BookmarkBarFolderWindow; |
20 @class BookmarkBarFolderWindowContentView; | 20 @class BookmarkBarFolderWindowContentView; |
21 @class BookmarkFolderTarget; | 21 @class BookmarkFolderTarget; |
22 | 22 |
23 // A controller for the pop-up windows from bookmark folder buttons | 23 // A controller for the pop-up windows from bookmark folder buttons |
24 // which look sort of like menus. | 24 // which look sort of like menus. |
25 @interface BookmarkBarFolderController : | 25 @interface BookmarkBarFolderController : |
26 NSWindowController<BookmarkButtonDelegate, | 26 NSWindowController<BookmarkButtonDelegate, |
27 BookmarkButtonControllerProtocol> { | 27 BookmarkButtonControllerProtocol> { |
28 @private | 28 @private |
29 // The button whose click opened us. | 29 // The button whose click opened us. |
30 scoped_nsobject<BookmarkButton> parentButton_; | 30 base::scoped_nsobject<BookmarkButton> parentButton_; |
31 | 31 |
32 // Bookmark bar folder controller chains are torn down in two ways: | 32 // Bookmark bar folder controller chains are torn down in two ways: |
33 // 1. Clicking "outside" the folder (see use of the NSEvent local event | 33 // 1. Clicking "outside" the folder (see use of the NSEvent local event |
34 // monitor in the bookmark bar controller). | 34 // monitor in the bookmark bar controller). |
35 // 2. Engaging a different folder (via hover over or explicit click). | 35 // 2. Engaging a different folder (via hover over or explicit click). |
36 // | 36 // |
37 // In either case, the BookmarkButtonControllerProtocol method | 37 // In either case, the BookmarkButtonControllerProtocol method |
38 // closeAllBookmarkFolders gets called. For bookmark bar folder | 38 // closeAllBookmarkFolders gets called. For bookmark bar folder |
39 // controllers, this is passed up the chain so we begin with a top | 39 // controllers, this is passed up the chain so we begin with a top |
40 // level "close". | 40 // level "close". |
41 // When any bookmark folder window closes, it necessarily tells | 41 // When any bookmark folder window closes, it necessarily tells |
42 // subcontroller windows to close (down the chain), and autoreleases | 42 // subcontroller windows to close (down the chain), and autoreleases |
43 // the controller. (Must autorelease since the controller can still | 43 // the controller. (Must autorelease since the controller can still |
44 // get delegate events such as windowDidClose). | 44 // get delegate events such as windowDidClose). |
45 // | 45 // |
46 // Bookmark bar folder controllers own their buttons. When doing | 46 // Bookmark bar folder controllers own their buttons. When doing |
47 // drag and drop of a button from one sub-sub-folder to a different | 47 // drag and drop of a button from one sub-sub-folder to a different |
48 // sub-sub-folder, we need to make sure the button's pointers stay | 48 // sub-sub-folder, we need to make sure the button's pointers stay |
49 // valid until we've dropped (or cancelled). Note that such a drag | 49 // valid until we've dropped (or cancelled). Note that such a drag |
50 // causes the source sub-sub-folder (previous parent window) to go | 50 // causes the source sub-sub-folder (previous parent window) to go |
51 // away (windows close, controllers autoreleased) since you're | 51 // away (windows close, controllers autoreleased) since you're |
52 // hovering over a different folder chain for dropping. To keep | 52 // hovering over a different folder chain for dropping. To keep |
53 // things valid (like the button's target, its delegate, the parent | 53 // things valid (like the button's target, its delegate, the parent |
54 // cotroller that we have a pointer to below [below], etc), we heep | 54 // cotroller that we have a pointer to below [below], etc), we heep |
55 // strong pointers to our owning controller, so the entire chain | 55 // strong pointers to our owning controller, so the entire chain |
56 // stays owned. | 56 // stays owned. |
57 | 57 |
58 // Our parent controller, if we are a nested folder, otherwise nil. | 58 // Our parent controller, if we are a nested folder, otherwise nil. |
59 // Strong to insure the object lives as long as we need it. | 59 // Strong to insure the object lives as long as we need it. |
60 scoped_nsobject<BookmarkBarFolderController> parentController_; | 60 base::scoped_nsobject<BookmarkBarFolderController> parentController_; |
61 | 61 |
62 // The main bar controller from whence we or a parent sprang. | 62 // The main bar controller from whence we or a parent sprang. |
63 BookmarkBarController* barController_; // WEAK: It owns us. | 63 BookmarkBarController* barController_; // WEAK: It owns us. |
64 | 64 |
65 // Our buttons. We do not have buttons for nested folders. | 65 // Our buttons. We do not have buttons for nested folders. |
66 scoped_nsobject<NSMutableArray> buttons_; | 66 base::scoped_nsobject<NSMutableArray> buttons_; |
67 | 67 |
68 // The scroll view that contains our main button view (below). | 68 // The scroll view that contains our main button view (below). |
69 IBOutlet NSScrollView* scrollView_; | 69 IBOutlet NSScrollView* scrollView_; |
70 | 70 |
71 // The view defining the visible area in which we draw our content. | 71 // The view defining the visible area in which we draw our content. |
72 IBOutlet BookmarkBarFolderWindowContentView* visibleView_; | 72 IBOutlet BookmarkBarFolderWindowContentView* visibleView_; |
73 | 73 |
74 // The main view of this window (where the buttons go) within the scroller. | 74 // The main view of this window (where the buttons go) within the scroller. |
75 IBOutlet BookmarkBarFolderView* folderView_; | 75 IBOutlet BookmarkBarFolderView* folderView_; |
76 | 76 |
(...skipping 18 matching lines...) Expand all Loading... |
95 // Direction switches if we'd grow off the screen. | 95 // Direction switches if we'd grow off the screen. |
96 BOOL subFolderGrowthToRight_; | 96 BOOL subFolderGrowthToRight_; |
97 | 97 |
98 // Weak; we keep track to work around a | 98 // Weak; we keep track to work around a |
99 // setShowsBorderOnlyWhileMouseInside bug. | 99 // setShowsBorderOnlyWhileMouseInside bug. |
100 BookmarkButton* buttonThatMouseIsIn_; | 100 BookmarkButton* buttonThatMouseIsIn_; |
101 | 101 |
102 // We model hover state as a state machine with specific allowable | 102 // We model hover state as a state machine with specific allowable |
103 // transitions. |hoverState_| is the state of this machine at any | 103 // transitions. |hoverState_| is the state of this machine at any |
104 // given time. | 104 // given time. |
105 scoped_nsobject<BookmarkBarFolderHoverState> hoverState_; | 105 base::scoped_nsobject<BookmarkBarFolderHoverState> hoverState_; |
106 | 106 |
107 // Logic for dealing with a click on a bookmark folder button. | 107 // Logic for dealing with a click on a bookmark folder button. |
108 scoped_nsobject<BookmarkFolderTarget> folderTarget_; | 108 base::scoped_nsobject<BookmarkFolderTarget> folderTarget_; |
109 | 109 |
110 // A controller for a pop-up bookmark folder window (custom menu). | 110 // A controller for a pop-up bookmark folder window (custom menu). |
111 // We (self) are the parentController_ for our folderController_. | 111 // We (self) are the parentController_ for our folderController_. |
112 // This is not a scoped_nsobject because it owns itself (when its | 112 // This is not a scoped_nsobject because it owns itself (when its |
113 // window closes the controller gets autoreleased). | 113 // window closes the controller gets autoreleased). |
114 BookmarkBarFolderController* folderController_; | 114 BookmarkBarFolderController* folderController_; |
115 | 115 |
116 // Implement basic menu scrolling through this tracking area. | 116 // Implement basic menu scrolling through this tracking area. |
117 ui::ScopedCrTrackingArea scrollTrackingArea_; | 117 ui::ScopedCrTrackingArea scrollTrackingArea_; |
118 | 118 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 - (NSView*)visibleView; | 206 - (NSView*)visibleView; |
207 - (NSScrollView*)scrollView; | 207 - (NSScrollView*)scrollView; |
208 - (NSView*)folderView; | 208 - (NSView*)folderView; |
209 | 209 |
210 - (IBAction)openBookmarkFolderFromButton:(id)sender; | 210 - (IBAction)openBookmarkFolderFromButton:(id)sender; |
211 | 211 |
212 - (BookmarkButton*)buttonForDroppingOnAtPoint:(NSPoint)point; | 212 - (BookmarkButton*)buttonForDroppingOnAtPoint:(NSPoint)point; |
213 @end | 213 @end |
214 | 214 |
215 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_FOLDER_CONTROLLER_H_ | 215 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_FOLDER_CONTROLLER_H_ |
OLD | NEW |