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