| 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_VIEWS_TABS_TAB_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/browser/ui/tabs/tab_audio_indicator.h" | 13 #include "chrome/browser/ui/tabs/tab_audio_indicator.h" |
| 14 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" | 14 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" |
| 15 #include "ui/base/animation/animation_delegate.h" | |
| 16 #include "ui/base/layout.h" | 15 #include "ui/base/layout.h" |
| 16 #include "ui/gfx/animation/animation_delegate.h" |
| 17 #include "ui/gfx/point.h" | 17 #include "ui/gfx/point.h" |
| 18 #include "ui/views/context_menu_controller.h" | 18 #include "ui/views/context_menu_controller.h" |
| 19 #include "ui/views/controls/button/button.h" | 19 #include "ui/views/controls/button/button.h" |
| 20 #include "ui/views/controls/glow_hover_controller.h" | 20 #include "ui/views/controls/glow_hover_controller.h" |
| 21 #include "ui/views/view.h" | 21 #include "ui/views/view.h" |
| 22 | 22 |
| 23 class TabController; | 23 class TabController; |
| 24 | 24 |
| 25 namespace gfx { | 25 namespace gfx { |
| 26 class Font; | |
| 27 } | |
| 28 namespace ui { | |
| 29 class Animation; | 26 class Animation; |
| 30 class AnimationContainer; | 27 class AnimationContainer; |
| 28 class Font; |
| 31 class LinearAnimation; | 29 class LinearAnimation; |
| 32 class MultiAnimation; | 30 class MultiAnimation; |
| 33 } | 31 } |
| 34 namespace views { | 32 namespace views { |
| 35 class ImageButton; | 33 class ImageButton; |
| 36 } | 34 } |
| 37 | 35 |
| 38 /////////////////////////////////////////////////////////////////////////////// | 36 /////////////////////////////////////////////////////////////////////////////// |
| 39 // | 37 // |
| 40 // A View that renders a Tab, either in a TabStrip or in a DraggedTabView. | 38 // A View that renders a Tab, either in a TabStrip or in a DraggedTabView. |
| 41 // | 39 // |
| 42 /////////////////////////////////////////////////////////////////////////////// | 40 /////////////////////////////////////////////////////////////////////////////// |
| 43 class Tab : public TabAudioIndicator::Delegate, | 41 class Tab : public TabAudioIndicator::Delegate, |
| 44 public ui::AnimationDelegate, | 42 public gfx::AnimationDelegate, |
| 45 public views::ButtonListener, | 43 public views::ButtonListener, |
| 46 public views::ContextMenuController, | 44 public views::ContextMenuController, |
| 47 public views::View { | 45 public views::View { |
| 48 public: | 46 public: |
| 49 // The menu button's class name. | 47 // The menu button's class name. |
| 50 static const char kViewClassName[]; | 48 static const char kViewClassName[]; |
| 51 | 49 |
| 52 explicit Tab(TabController* controller); | 50 explicit Tab(TabController* controller); |
| 53 virtual ~Tab(); | 51 virtual ~Tab(); |
| 54 | 52 |
| 55 TabController* controller() const { return controller_; } | 53 TabController* controller() const { return controller_; } |
| 56 | 54 |
| 57 // Used to set/check whether this Tab is being animated closed. | 55 // Used to set/check whether this Tab is being animated closed. |
| 58 void set_closing(bool closing) { closing_ = closing; } | 56 void set_closing(bool closing) { closing_ = closing; } |
| 59 bool closing() const { return closing_; } | 57 bool closing() const { return closing_; } |
| 60 | 58 |
| 61 // See description above field. | 59 // See description above field. |
| 62 void set_dragging(bool dragging) { dragging_ = dragging; } | 60 void set_dragging(bool dragging) { dragging_ = dragging; } |
| 63 bool dragging() const { return dragging_; } | 61 bool dragging() const { return dragging_; } |
| 64 | 62 |
| 65 // Sets the container all animations run from. | 63 // Sets the container all animations run from. |
| 66 void set_animation_container(ui::AnimationContainer* container); | 64 void set_animation_container(gfx::AnimationContainer* container); |
| 67 | 65 |
| 68 // Set the theme provider - because we get detached, we are frequently | 66 // Set the theme provider - because we get detached, we are frequently |
| 69 // outside of a hierarchy with a theme provider at the top. This should be | 67 // outside of a hierarchy with a theme provider at the top. This should be |
| 70 // called whenever we're detached or attached to a hierarchy. | 68 // called whenever we're detached or attached to a hierarchy. |
| 71 void set_theme_provider(ui::ThemeProvider* provider) { | 69 void set_theme_provider(ui::ThemeProvider* provider) { |
| 72 theme_provider_ = provider; | 70 theme_provider_ = provider; |
| 73 } | 71 } |
| 74 | 72 |
| 75 // Returns true if this tab is the active tab. | 73 // Returns true if this tab is the active tab. |
| 76 bool IsActive() const; | 74 bool IsActive() const; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 149 |
| 152 // The image. | 150 // The image. |
| 153 gfx::ImageSkia image; | 151 gfx::ImageSkia image; |
| 154 }; | 152 }; |
| 155 | 153 |
| 156 typedef std::list<ImageCacheEntry> ImageCache; | 154 typedef std::list<ImageCacheEntry> ImageCache; |
| 157 | 155 |
| 158 // Overridden from TabAudioIndicator::Delegate: | 156 // Overridden from TabAudioIndicator::Delegate: |
| 159 virtual void ScheduleAudioIndicatorPaint() OVERRIDE; | 157 virtual void ScheduleAudioIndicatorPaint() OVERRIDE; |
| 160 | 158 |
| 161 // Overridden from ui::AnimationDelegate: | 159 // Overridden from gfx::AnimationDelegate: |
| 162 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 160 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 163 virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE; | 161 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE; |
| 164 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 162 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
| 165 | 163 |
| 166 // Overridden from views::ButtonListener: | 164 // Overridden from views::ButtonListener: |
| 167 virtual void ButtonPressed(views::Button* sender, | 165 virtual void ButtonPressed(views::Button* sender, |
| 168 const ui::Event& event) OVERRIDE; | 166 const ui::Event& event) OVERRIDE; |
| 169 | 167 |
| 170 // Overridden from views::ContextMenuController: | 168 // Overridden from views::ContextMenuController: |
| 171 virtual void ShowContextMenuForView(views::View* source, | 169 virtual void ShowContextMenuForView(views::View* source, |
| 172 const gfx::Point& point, | 170 const gfx::Point& point, |
| 173 ui::MenuSourceType source_type) OVERRIDE; | 171 ui::MenuSourceType source_type) OVERRIDE; |
| 174 | 172 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 204 void DataChanged(const TabRendererData& old); | 202 void DataChanged(const TabRendererData& old); |
| 205 | 203 |
| 206 // Paint with the normal tab style. | 204 // Paint with the normal tab style. |
| 207 void PaintTab(gfx::Canvas* canvas); | 205 void PaintTab(gfx::Canvas* canvas); |
| 208 | 206 |
| 209 // Paint with the "immersive mode" light-bar style. | 207 // Paint with the "immersive mode" light-bar style. |
| 210 void PaintImmersiveTab(gfx::Canvas* canvas); | 208 void PaintImmersiveTab(gfx::Canvas* canvas); |
| 211 | 209 |
| 212 // Paint various portions of the Tab | 210 // Paint various portions of the Tab |
| 213 void PaintTabBackground(gfx::Canvas* canvas); | 211 void PaintTabBackground(gfx::Canvas* canvas); |
| 214 void PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas, | 212 void PaintInactiveTabBackgroundWithTitleChange( |
| 215 ui::MultiAnimation* animation); | 213 gfx::Canvas* canvas, |
| 214 gfx::MultiAnimation* animation); |
| 216 void PaintInactiveTabBackground(gfx::Canvas* canvas); | 215 void PaintInactiveTabBackground(gfx::Canvas* canvas); |
| 217 void PaintInactiveTabBackgroundUsingResourceId(gfx::Canvas* canvas, | 216 void PaintInactiveTabBackgroundUsingResourceId(gfx::Canvas* canvas, |
| 218 int tab_id); | 217 int tab_id); |
| 219 void PaintActiveTabBackground(gfx::Canvas* canvas); | 218 void PaintActiveTabBackground(gfx::Canvas* canvas); |
| 220 | 219 |
| 221 // Paints the icon at the specified coordinates, mirrored for RTL if needed. | 220 // Paints the icon at the specified coordinates, mirrored for RTL if needed. |
| 222 void PaintIcon(gfx::Canvas* canvas); | 221 void PaintIcon(gfx::Canvas* canvas); |
| 223 void PaintCaptureState(gfx::Canvas* canvas, gfx::Rect bounds); | 222 void PaintCaptureState(gfx::Canvas* canvas, gfx::Rect bounds); |
| 224 void PaintTitle(gfx::Canvas* canvas, SkColor title_color); | 223 void PaintTitle(gfx::Canvas* canvas, SkColor title_color); |
| 225 | 224 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 309 |
| 311 // Step in the immersive loading progress indicator. | 310 // Step in the immersive loading progress indicator. |
| 312 int immersive_loading_step_; | 311 int immersive_loading_step_; |
| 313 | 312 |
| 314 bool should_display_crashed_favicon_; | 313 bool should_display_crashed_favicon_; |
| 315 | 314 |
| 316 // The tab and the icon can both be animating. The tab 'throbs' by changing | 315 // The tab and the icon can both be animating. The tab 'throbs' by changing |
| 317 // color. The icon can have one of several of animations like crashing, | 316 // color. The icon can have one of several of animations like crashing, |
| 318 // recording, projecting, etc. Note that the icon animation related to network | 317 // recording, projecting, etc. Note that the icon animation related to network |
| 319 // state does not have an animation associated with it. | 318 // state does not have an animation associated with it. |
| 320 scoped_ptr<ui::Animation> tab_animation_; | 319 scoped_ptr<gfx::Animation> tab_animation_; |
| 321 scoped_ptr<ui::LinearAnimation> icon_animation_; | 320 scoped_ptr<gfx::LinearAnimation> icon_animation_; |
| 322 | 321 |
| 323 scoped_refptr<ui::AnimationContainer> animation_container_; | 322 scoped_refptr<gfx::AnimationContainer> animation_container_; |
| 324 | 323 |
| 325 scoped_ptr<TabAudioIndicator> tab_audio_indicator_; | 324 scoped_ptr<TabAudioIndicator> tab_audio_indicator_; |
| 326 | 325 |
| 327 views::ImageButton* close_button_; | 326 views::ImageButton* close_button_; |
| 328 | 327 |
| 329 ui::ThemeProvider* theme_provider_; | 328 ui::ThemeProvider* theme_provider_; |
| 330 | 329 |
| 331 bool tab_activated_with_last_gesture_begin_; | 330 bool tab_activated_with_last_gesture_begin_; |
| 332 | 331 |
| 333 views::GlowHoverController hover_controller_; | 332 views::GlowHoverController hover_controller_; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 static int font_height_; | 364 static int font_height_; |
| 366 | 365 |
| 367 // As the majority of the tabs are inactive, and painting tabs is slowish, | 366 // As the majority of the tabs are inactive, and painting tabs is slowish, |
| 368 // we cache a handful of the inactive tab backgrounds here. | 367 // we cache a handful of the inactive tab backgrounds here. |
| 369 static ImageCache* image_cache_; | 368 static ImageCache* image_cache_; |
| 370 | 369 |
| 371 DISALLOW_COPY_AND_ASSIGN(Tab); | 370 DISALLOW_COPY_AND_ASSIGN(Tab); |
| 372 }; | 371 }; |
| 373 | 372 |
| 374 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ | 373 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ |
| OLD | NEW |