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/views/tabs/tab_renderer_data.h" | 13 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" |
14 #include "ui/base/animation/animation_delegate.h" | 14 #include "ui/base/animation/animation_delegate.h" |
15 #include "ui/base/layout.h" | 15 #include "ui/base/layout.h" |
16 #include "ui/gfx/point.h" | 16 #include "ui/gfx/point.h" |
17 #include "ui/views/context_menu_controller.h" | 17 #include "ui/views/context_menu_controller.h" |
18 #include "ui/views/controls/button/button.h" | 18 #include "ui/views/controls/button/button.h" |
19 #include "ui/views/controls/glow_hover_controller.h" | 19 #include "ui/views/controls/glow_hover_controller.h" |
20 #include "ui/views/view.h" | 20 #include "ui/views/view.h" |
21 | 21 |
22 class TabController; | 22 class TabController; |
23 | 23 |
24 namespace gfx { | 24 namespace gfx { |
25 class Font; | 25 class Font; |
26 } | 26 } |
27 namespace ui { | 27 namespace ui { |
| 28 class Animation; |
28 class AnimationContainer; | 29 class AnimationContainer; |
| 30 class LinearAnimation; |
29 class MultiAnimation; | 31 class MultiAnimation; |
30 class ThrobAnimation; | |
31 } | 32 } |
32 namespace views { | 33 namespace views { |
33 class ImageButton; | 34 class ImageButton; |
34 } | 35 } |
35 | 36 |
36 /////////////////////////////////////////////////////////////////////////////// | 37 /////////////////////////////////////////////////////////////////////////////// |
37 // | 38 // |
38 // A View that renders a Tab, either in a TabStrip or in a DraggedTabView. | 39 // A View that renders a Tab, either in a TabStrip or in a DraggedTabView. |
39 // | 40 // |
40 /////////////////////////////////////////////////////////////////////////////// | 41 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 13 matching lines...) Expand all Loading... |
54 // Used to set/check whether this Tab is being animated closed. | 55 // Used to set/check whether this Tab is being animated closed. |
55 void set_closing(bool closing) { closing_ = closing; } | 56 void set_closing(bool closing) { closing_ = closing; } |
56 bool closing() const { return closing_; } | 57 bool closing() const { return closing_; } |
57 | 58 |
58 // See description above field. | 59 // See description above field. |
59 void set_dragging(bool dragging) { dragging_ = dragging; } | 60 void set_dragging(bool dragging) { dragging_ = dragging; } |
60 bool dragging() const { return dragging_; } | 61 bool dragging() const { return dragging_; } |
61 | 62 |
62 // Sets the container all animations run from. | 63 // Sets the container all animations run from. |
63 void set_animation_container(ui::AnimationContainer* container); | 64 void set_animation_container(ui::AnimationContainer* container); |
64 ui::AnimationContainer* animation_container() const { | |
65 return animation_container_.get(); | |
66 } | |
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 void DataChanged(const TabRendererData& old); | 190 void DataChanged(const TabRendererData& old); |
193 | 191 |
194 // Paint with the normal tab style. | 192 // Paint with the normal tab style. |
195 void PaintTab(gfx::Canvas* canvas); | 193 void PaintTab(gfx::Canvas* canvas); |
196 | 194 |
197 // Paint with the "immersive mode" light-bar style. | 195 // Paint with the "immersive mode" light-bar style. |
198 void PaintTabImmersive(gfx::Canvas* canvas); | 196 void PaintTabImmersive(gfx::Canvas* canvas); |
199 | 197 |
200 // Paint various portions of the Tab | 198 // Paint various portions of the Tab |
201 void PaintTabBackground(gfx::Canvas* canvas); | 199 void PaintTabBackground(gfx::Canvas* canvas); |
202 void PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas); | 200 void PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas, |
| 201 ui::MultiAnimation* animation); |
203 void PaintInactiveTabBackground(gfx::Canvas* canvas); | 202 void PaintInactiveTabBackground(gfx::Canvas* canvas); |
204 void PaintInactiveTabBackgroundUsingResourceId(gfx::Canvas* canvas, | 203 void PaintInactiveTabBackgroundUsingResourceId(gfx::Canvas* canvas, |
205 int tab_id); | 204 int tab_id); |
206 void PaintActiveTabBackground(gfx::Canvas* canvas); | 205 void PaintActiveTabBackground(gfx::Canvas* canvas); |
207 | 206 |
208 // Paints the icon at the specified coordinates, mirrored for RTL if needed. | 207 // Paints the icon at the specified coordinates, mirrored for RTL if needed. |
209 void PaintIcon(gfx::Canvas* canvas); | 208 void PaintIcon(gfx::Canvas* canvas); |
210 void PaintTitle(gfx::Canvas* canvas, SkColor title_color); | 209 void PaintTitle(gfx::Canvas* canvas, SkColor title_color); |
211 | 210 |
212 // Invoked if data_.network_state changes, or the network_state is not none. | 211 // Invoked if data_.network_state changes, or the network_state is not none. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 // crashes. | 283 // crashes. |
285 int favicon_hiding_offset_; | 284 int favicon_hiding_offset_; |
286 | 285 |
287 // The current index of the loading animation. | 286 // The current index of the loading animation. |
288 int loading_animation_frame_; | 287 int loading_animation_frame_; |
289 | 288 |
290 bool should_display_crashed_favicon_; | 289 bool should_display_crashed_favicon_; |
291 | 290 |
292 // The tab and the icon can both be animating. The tab 'throbs' by changing | 291 // The tab and the icon can both be animating. The tab 'throbs' by changing |
293 // color. The icon can have one of several of animations like crashing, | 292 // color. The icon can have one of several of animations like crashing, |
294 // recording, projecting, etc. | 293 // recording, projecting, etc. Note that the icon animation related to network |
295 scoped_ptr<ui::ThrobAnimation> tab_animation_; | 294 // state does not have an animation associated with it. |
| 295 scoped_ptr<ui::Animation> tab_animation_; |
296 scoped_ptr<ui::LinearAnimation> icon_animation_; | 296 scoped_ptr<ui::LinearAnimation> icon_animation_; |
297 | 297 |
298 scoped_refptr<ui::AnimationContainer> animation_container_; | 298 scoped_refptr<ui::AnimationContainer> animation_container_; |
299 | 299 |
300 views::ImageButton* close_button_; | 300 views::ImageButton* close_button_; |
301 | 301 |
302 // Whether to disable throbber animations. Only true if this is an app tab | |
303 // renderer and a command line flag has been passed in to disable the | |
304 // animations. | |
305 bool throbber_disabled_; | |
306 | |
307 ui::ThemeProvider* theme_provider_; | 302 ui::ThemeProvider* theme_provider_; |
308 | 303 |
309 views::GlowHoverController hover_controller_; | 304 views::GlowHoverController hover_controller_; |
310 | 305 |
311 // The bounds of various sections of the display. | 306 // The bounds of various sections of the display. |
312 gfx::Rect favicon_bounds_; | 307 gfx::Rect favicon_bounds_; |
313 gfx::Rect title_bounds_; | 308 gfx::Rect title_bounds_; |
314 | 309 |
315 // The offset used to paint the inactive background image. | 310 // The offset used to paint the inactive background image. |
316 gfx::Point background_offset_; | 311 gfx::Point background_offset_; |
317 | 312 |
318 // Animation used when the title of an inactive mini tab changes. | |
319 scoped_ptr<ui::MultiAnimation> mini_title_animation_; | |
320 | |
321 struct TabImage { | 313 struct TabImage { |
322 gfx::ImageSkia* image_l; | 314 gfx::ImageSkia* image_l; |
323 gfx::ImageSkia* image_c; | 315 gfx::ImageSkia* image_c; |
324 gfx::ImageSkia* image_r; | 316 gfx::ImageSkia* image_r; |
325 int l_width; | 317 int l_width; |
326 int r_width; | 318 int r_width; |
327 int y_offset; | 319 int y_offset; |
328 }; | 320 }; |
329 static TabImage tab_active_; | 321 static TabImage tab_active_; |
330 static TabImage tab_inactive_; | 322 static TabImage tab_inactive_; |
(...skipping 20 matching lines...) Expand all Loading... |
351 static int font_height_; | 343 static int font_height_; |
352 | 344 |
353 // As the majority of the tabs are inactive, and painting tabs is slowish, | 345 // As the majority of the tabs are inactive, and painting tabs is slowish, |
354 // we cache a handful of the inactive tab backgrounds here. | 346 // we cache a handful of the inactive tab backgrounds here. |
355 static ImageCache* image_cache_; | 347 static ImageCache* image_cache_; |
356 | 348 |
357 DISALLOW_COPY_AND_ASSIGN(Tab); | 349 DISALLOW_COPY_AND_ASSIGN(Tab); |
358 }; | 350 }; |
359 | 351 |
360 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ | 352 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ |
OLD | NEW |