| 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 #ifndef CHROME_BROWSER_UI_COCOA_TABS_TAB_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_TABS_TAB_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_TABS_TAB_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_TABS_TAB_CONTROLLER_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #import "chrome/browser/ui/cocoa/hover_close_button.h" | 10 #import "chrome/browser/ui/cocoa/hover_close_button.h" |
| 11 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" | 11 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" |
| 12 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 12 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
| 13 #include "chrome/browser/ui/tabs/tab_utils.h" |
| 13 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 14 | 15 |
| 15 // The loading/waiting state of the tab. | 16 // The loading/waiting state of the tab. |
| 16 enum TabLoadingState { | 17 enum TabLoadingState { |
| 17 kTabDone, | 18 kTabDone, |
| 18 kTabLoading, | 19 kTabLoading, |
| 19 kTabWaiting, | 20 kTabWaiting, |
| 20 kTabCrashed, | 21 kTabCrashed, |
| 21 }; | 22 }; |
| 22 | 23 |
| 23 @class MediaIndicatorView; | 24 @class MediaIndicatorButton; |
| 24 @class MenuController; | 25 @class MenuController; |
| 25 namespace TabControllerInternal { | 26 namespace TabControllerInternal { |
| 26 class MenuDelegate; | 27 class MenuDelegate; |
| 27 } | 28 } |
| 28 @class SpriteView; | 29 @class SpriteView; |
| 29 @class TabView; | 30 @class TabView; |
| 30 @protocol TabControllerTarget; | 31 @protocol TabControllerTarget; |
| 31 | 32 |
| 32 // A class that manages a single tab in the tab strip. Set its target/action | 33 // A class that manages a single tab in the tab strip. Set its target/action |
| 33 // to be sent a message when the tab is selected by the user clicking. Setting | 34 // to be sent a message when the tab is selected by the user clicking. Setting |
| 34 // the |loading| property to YES visually indicates that this tab is currently | 35 // the |loading| property to YES visually indicates that this tab is currently |
| 35 // loading content via a spinner. | 36 // loading content via a spinner. |
| 36 // | 37 // |
| 37 // The tab has the notion of an "icon view" which can be used to display | 38 // The tab has the notion of an "icon view" which can be used to display |
| 38 // identifying characteristics such as a favicon, or since it's a full-fledged | 39 // identifying characteristics such as a favicon, or since it's a full-fledged |
| 39 // view, something with state and animation such as a throbber for illustrating | 40 // view, something with state and animation such as a throbber for illustrating |
| 40 // progress. The default in the nib is an image view so nothing special is | 41 // progress. The default in the nib is an image view so nothing special is |
| 41 // required if that's all you need. | 42 // required if that's all you need. |
| 42 | 43 |
| 43 @interface TabController : NSViewController<TabDraggingEventTarget> { | 44 @interface TabController : NSViewController<TabDraggingEventTarget> { |
| 44 @private | 45 @private |
| 45 base::scoped_nsobject<SpriteView> iconView_; | 46 base::scoped_nsobject<SpriteView> iconView_; |
| 46 base::scoped_nsobject<MediaIndicatorView> mediaIndicatorView_; | 47 base::scoped_nsobject<MediaIndicatorButton> mediaIndicatorButton_; |
| 47 base::scoped_nsobject<HoverCloseButton> closeButton_; | 48 base::scoped_nsobject<HoverCloseButton> closeButton_; |
| 48 | 49 |
| 49 NSRect originalIconFrame_; // frame of iconView_ as loaded from nib | 50 NSRect originalIconFrame_; // frame of iconView_ as loaded from nib |
| 50 BOOL isIconShowing_; // last state of iconView_ in updateVisibility | 51 BOOL isIconShowing_; // last state of iconView_ in updateVisibility |
| 51 | 52 |
| 52 BOOL app_; | 53 BOOL app_; |
| 53 BOOL mini_; | 54 BOOL mini_; |
| 54 BOOL pinned_; | 55 BOOL pinned_; |
| 55 BOOL active_; | 56 BOOL active_; |
| 56 BOOL selected_; | 57 BOOL selected_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 71 @property(assign, nonatomic) BOOL pinned; | 72 @property(assign, nonatomic) BOOL pinned; |
| 72 @property(assign, nonatomic) NSString* toolTip; | 73 @property(assign, nonatomic) NSString* toolTip; |
| 73 // Note that |-selected| will return YES if the controller is |-active|, too. | 74 // Note that |-selected| will return YES if the controller is |-active|, too. |
| 74 // |-setSelected:| affects the selection, while |-setActive:| affects the key | 75 // |-setSelected:| affects the selection, while |-setActive:| affects the key |
| 75 // status/focus of the content. | 76 // status/focus of the content. |
| 76 @property(assign, nonatomic) BOOL active; | 77 @property(assign, nonatomic) BOOL active; |
| 77 @property(assign, nonatomic) BOOL selected; | 78 @property(assign, nonatomic) BOOL selected; |
| 78 @property(assign, nonatomic) id target; | 79 @property(assign, nonatomic) id target; |
| 79 @property(assign, nonatomic) GURL url; | 80 @property(assign, nonatomic) GURL url; |
| 80 @property(readonly, nonatomic) NSView* iconView; | 81 @property(readonly, nonatomic) NSView* iconView; |
| 81 @property(assign, nonatomic) MediaIndicatorView* mediaIndicatorView; | 82 @property(readonly, nonatomic) MediaIndicatorButton* mediaIndicatorButton; |
| 82 @property(readonly, nonatomic) HoverCloseButton* closeButton; | 83 @property(readonly, nonatomic) HoverCloseButton* closeButton; |
| 83 | 84 |
| 84 // Minimum and maximum allowable tab width. The minimum width does not show | 85 // Minimum and maximum allowable tab width. The minimum width does not show |
| 85 // the icon or the close button. The active tab always has at least a close | 86 // the icon or the close button. The active tab always has at least a close |
| 86 // button so it has a different minimum width. | 87 // button so it has a different minimum width. |
| 87 + (CGFloat)minTabWidth; | 88 + (CGFloat)minTabWidth; |
| 88 + (CGFloat)maxTabWidth; | 89 + (CGFloat)maxTabWidth; |
| 89 + (CGFloat)minActiveTabWidth; | 90 + (CGFloat)minActiveTabWidth; |
| 90 + (CGFloat)miniTabWidth; | 91 + (CGFloat)miniTabWidth; |
| 91 + (CGFloat)appTabWidth; | 92 + (CGFloat)appTabWidth; |
| 92 | 93 |
| 93 // The view associated with this controller, pre-casted as a TabView | 94 // The view associated with this controller, pre-casted as a TabView |
| 94 - (TabView*)tabView; | 95 - (TabView*)tabView; |
| 95 | 96 |
| 96 // Sets the tab's icon image. | 97 // Sets the tab's icon image. |
| 97 // |image| must be 16x16 in size. | 98 // |image| must be 16x16 in size. |
| 98 // |image| can be a horizontal strip of image sprites which will be animated. | 99 // |image| can be a horizontal strip of image sprites which will be animated. |
| 99 // Setting |animate| to YES will animate away the old image before animating | 100 // Setting |animate| to YES will animate away the old image before animating |
| 100 // the new image back to position. | 101 // the new image back to position. |
| 101 - (void)setIconImage:(NSImage*)image; | 102 - (void)setIconImage:(NSImage*)image; |
| 102 - (void)setIconImage:(NSImage*)image withToastAnimation:(BOOL)animate; | 103 - (void)setIconImage:(NSImage*)image withToastAnimation:(BOOL)animate; |
| 103 | 104 |
| 105 // Sets the current tab media state and updates the views. |
| 106 - (void)setMediaState:(TabMediaState)mediaState; |
| 107 |
| 104 // Closes the associated TabView by relaying the message to |target_| to | 108 // Closes the associated TabView by relaying the message to |target_| to |
| 105 // perform the close. | 109 // perform the close. |
| 106 - (void)closeTab:(id)sender; | 110 - (void)closeTab:(id)sender; |
| 107 | 111 |
| 108 // Selects the associated TabView by sending |action_| to |target_|. | 112 // Selects the associated TabView by sending |action_| to |target_|. |
| 109 - (void)selectTab:(id)sender; | 113 - (void)selectTab:(id)sender; |
| 110 | 114 |
| 111 // Called by the tabs to determine whether we are in rapid (tab) closure mode. | 115 // Called by the tabs to determine whether we are in rapid (tab) closure mode. |
| 112 // In this mode, we handle clicks slightly differently due to animation. | 116 // In this mode, we handle clicks slightly differently due to animation. |
| 113 // Ideally, tabs would know about their own animation and wouldn't need this. | 117 // Ideally, tabs would know about their own animation and wouldn't need this. |
| 114 - (BOOL)inRapidClosureMode; | 118 - (BOOL)inRapidClosureMode; |
| 115 | 119 |
| 116 // Updates the visibility of certain subviews, such as the icon and close | 120 // Updates the visibility of certain subviews, such as the icon and close |
| 117 // button, based on criteria such as the tab's selected state and its current | 121 // button, based on criteria such as the tab's selected state and its current |
| 118 // width. | 122 // width. |
| 119 - (void)updateVisibility; | 123 - (void)updateVisibility; |
| 120 | 124 |
| 121 // Update the title color to match the tabs current state. | 125 // Update the title color to match the tabs current state. |
| 122 - (void)updateTitleColor; | 126 - (void)updateTitleColor; |
| 123 @end | 127 @end |
| 124 | 128 |
| 125 @interface TabController(TestingAPI) | 129 @interface TabController(TestingAPI) |
| 126 - (int)iconCapacity; | 130 - (int)iconCapacity; |
| 127 - (BOOL)shouldShowIcon; | 131 - (BOOL)shouldShowIcon; |
| 128 - (BOOL)shouldShowMediaIndicator; | 132 - (BOOL)shouldShowMediaIndicator; |
| 129 - (BOOL)shouldShowCloseButton; | 133 - (BOOL)shouldShowCloseButton; |
| 130 @end // TabController(TestingAPI) | 134 @end // TabController(TestingAPI) |
| 131 | 135 |
| 132 #endif // CHROME_BROWSER_UI_COCOA_TABS_TAB_CONTROLLER_H_ | 136 #endif // CHROME_BROWSER_UI_COCOA_TABS_TAB_CONTROLLER_H_ |
| OLD | NEW |