| OLD | NEW |
| 1 // Copyright (c) 2011 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_GTK_TABS_TAB_RENDERER_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_TABS_TAB_RENDERER_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_TABS_TAB_RENDERER_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_TABS_TAB_RENDERER_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 #include <map> | 10 #include <map> |
| 11 | 11 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 24 #include "ui/gfx/image/cairo_cached_surface.h" | 24 #include "ui/gfx/image/cairo_cached_surface.h" |
| 25 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
| 26 | 26 |
| 27 namespace gfx { | 27 namespace gfx { |
| 28 class CairoCachedSurface; | 28 class CairoCachedSurface; |
| 29 class Image; | 29 class Image; |
| 30 class Size; | 30 class Size; |
| 31 } // namespace gfx | 31 } // namespace gfx |
| 32 | 32 |
| 33 class CustomDrawButton; | 33 class CustomDrawButton; |
| 34 class GtkThemeService; | 34 class ThemeServiceGtk; |
| 35 | 35 |
| 36 namespace content { | 36 namespace content { |
| 37 class WebContents; | 37 class WebContents; |
| 38 } | 38 } |
| 39 | 39 |
| 40 namespace ui { | 40 namespace ui { |
| 41 class SlideAnimation; | 41 class SlideAnimation; |
| 42 class ThrobAnimation; | 42 class ThrobAnimation; |
| 43 } | 43 } |
| 44 | 44 |
| 45 class TabRendererGtk : public ui::AnimationDelegate, | 45 class TabRendererGtk : public ui::AnimationDelegate, |
| 46 public content::NotificationObserver { | 46 public content::NotificationObserver { |
| 47 public: | 47 public: |
| 48 // Possible animation states. | 48 // Possible animation states. |
| 49 enum AnimationState { | 49 enum AnimationState { |
| 50 ANIMATION_NONE, | 50 ANIMATION_NONE, |
| 51 ANIMATION_WAITING, | 51 ANIMATION_WAITING, |
| 52 ANIMATION_LOADING | 52 ANIMATION_LOADING |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 class LoadingAnimation : public content::NotificationObserver { | 55 class LoadingAnimation : public content::NotificationObserver { |
| 56 public: | 56 public: |
| 57 struct Data { | 57 struct Data { |
| 58 explicit Data(GtkThemeService* theme_service); | 58 explicit Data(ThemeServiceGtk* theme_service); |
| 59 Data(int loading, int waiting, int waiting_to_loading); | 59 Data(int loading, int waiting, int waiting_to_loading); |
| 60 | 60 |
| 61 int loading_animation_frame_count; | 61 int loading_animation_frame_count; |
| 62 int waiting_animation_frame_count; | 62 int waiting_animation_frame_count; |
| 63 int waiting_to_loading_frame_count_ratio; | 63 int waiting_to_loading_frame_count_ratio; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 explicit LoadingAnimation(GtkThemeService* theme_service); | 66 explicit LoadingAnimation(ThemeServiceGtk* theme_service); |
| 67 | 67 |
| 68 // Used in unit tests to inject specific data. | 68 // Used in unit tests to inject specific data. |
| 69 explicit LoadingAnimation(const LoadingAnimation::Data& data); | 69 explicit LoadingAnimation(const LoadingAnimation::Data& data); |
| 70 | 70 |
| 71 virtual ~LoadingAnimation(); | 71 virtual ~LoadingAnimation(); |
| 72 | 72 |
| 73 // Advance the loading animation to the next frame, or hide the animation if | 73 // Advance the loading animation to the next frame, or hide the animation if |
| 74 // the tab isn't loading. Returns |true| if the icon area needs to be | 74 // the tab isn't loading. Returns |true| if the icon area needs to be |
| 75 // repainted. | 75 // repainted. |
| 76 bool ValidateLoadingAnimation(AnimationState animation_state); | 76 bool ValidateLoadingAnimation(AnimationState animation_state); |
| 77 | 77 |
| 78 AnimationState animation_state() const { return animation_state_; } | 78 AnimationState animation_state() const { return animation_state_; } |
| 79 int animation_frame() const { return animation_frame_; } | 79 int animation_frame() const { return animation_frame_; } |
| 80 | 80 |
| 81 // Provide content::NotificationObserver implementation. | 81 // Provide content::NotificationObserver implementation. |
| 82 virtual void Observe(int type, | 82 virtual void Observe(int type, |
| 83 const content::NotificationSource& source, | 83 const content::NotificationSource& source, |
| 84 const content::NotificationDetails& details) OVERRIDE; | 84 const content::NotificationDetails& details) OVERRIDE; |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 scoped_ptr<Data> data_; | 87 scoped_ptr<Data> data_; |
| 88 | 88 |
| 89 // Used to listen for theme change notifications. | 89 // Used to listen for theme change notifications. |
| 90 content::NotificationRegistrar registrar_; | 90 content::NotificationRegistrar registrar_; |
| 91 | 91 |
| 92 // Gives us our throbber images. | 92 // Gives us our throbber images. |
| 93 GtkThemeService* theme_service_; | 93 ThemeServiceGtk* theme_service_; |
| 94 | 94 |
| 95 // Current state of the animation. | 95 // Current state of the animation. |
| 96 AnimationState animation_state_; | 96 AnimationState animation_state_; |
| 97 | 97 |
| 98 // The current index into the Animation image strip. | 98 // The current index into the Animation image strip. |
| 99 int animation_frame_; | 99 int animation_frame_; |
| 100 | 100 |
| 101 DISALLOW_COPY_AND_ASSIGN(LoadingAnimation); | 101 DISALLOW_COPY_AND_ASSIGN(LoadingAnimation); |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 explicit TabRendererGtk(GtkThemeService* theme_service); | 104 explicit TabRendererGtk(ThemeServiceGtk* theme_service); |
| 105 virtual ~TabRendererGtk(); | 105 virtual ~TabRendererGtk(); |
| 106 | 106 |
| 107 // Provide content::NotificationObserver implementation. | 107 // Provide content::NotificationObserver implementation. |
| 108 virtual void Observe(int type, | 108 virtual void Observe(int type, |
| 109 const content::NotificationSource& source, | 109 const content::NotificationSource& source, |
| 110 const content::NotificationDetails& details) OVERRIDE; | 110 const content::NotificationDetails& details) OVERRIDE; |
| 111 | 111 |
| 112 // WebContents. If only the loading state was updated, the loading_only flag | 112 // WebContents. If only the loading state was updated, the loading_only flag |
| 113 // should be specified. If other things change, set this flag to false to | 113 // should be specified. If other things change, set this flag to false to |
| 114 // update everything. | 114 // update everything. |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 LoadingAnimation loading_animation_; | 406 LoadingAnimation loading_animation_; |
| 407 | 407 |
| 408 // The offset used to paint the tab theme images. | 408 // The offset used to paint the tab theme images. |
| 409 int background_offset_x_; | 409 int background_offset_x_; |
| 410 | 410 |
| 411 // The vertical offset used to paint the tab theme images. Controlled by the | 411 // The vertical offset used to paint the tab theme images. Controlled by the |
| 412 // tabstrip and plumbed here to offset the theme image by the size of the | 412 // tabstrip and plumbed here to offset the theme image by the size of the |
| 413 // alignment in the BrowserTitlebar. | 413 // alignment in the BrowserTitlebar. |
| 414 int background_offset_y_; | 414 int background_offset_y_; |
| 415 | 415 |
| 416 GtkThemeService* theme_service_; | 416 ThemeServiceGtk* theme_service_; |
| 417 | 417 |
| 418 // The close button. | 418 // The close button. |
| 419 scoped_ptr<CustomDrawButton> close_button_; | 419 scoped_ptr<CustomDrawButton> close_button_; |
| 420 | 420 |
| 421 // The current color of the close button. | 421 // The current color of the close button. |
| 422 SkColor close_button_color_; | 422 SkColor close_button_color_; |
| 423 | 423 |
| 424 // Indicates whether this tab is the active one. | 424 // Indicates whether this tab is the active one. |
| 425 bool is_active_; | 425 bool is_active_; |
| 426 | 426 |
| 427 // Color of the title text on the selected tab. | 427 // Color of the title text on the selected tab. |
| 428 SkColor selected_title_color_; | 428 SkColor selected_title_color_; |
| 429 | 429 |
| 430 // Color of the title text on an unselected tab. | 430 // Color of the title text on an unselected tab. |
| 431 SkColor unselected_title_color_; | 431 SkColor unselected_title_color_; |
| 432 | 432 |
| 433 DISALLOW_COPY_AND_ASSIGN(TabRendererGtk); | 433 DISALLOW_COPY_AND_ASSIGN(TabRendererGtk); |
| 434 }; | 434 }; |
| 435 | 435 |
| 436 #endif // CHROME_BROWSER_UI_GTK_TABS_TAB_RENDERER_GTK_H_ | 436 #endif // CHROME_BROWSER_UI_GTK_TABS_TAB_RENDERER_GTK_H_ |
| OLD | NEW |