| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_GTK_TABS_TAB_RENDERER_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_TABS_TAB_RENDERER_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_TABS_TAB_RENDERER_GTK_H_ | 6 #define CHROME_BROWSER_GTK_TABS_TAB_RENDERER_GTK_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include "app/animation.h" | 10 #include "app/animation.h" |
| 11 #include "app/gfx/canvas.h" | 11 #include "app/gfx/canvas.h" |
| 12 #include "app/gfx/font.h" | 12 #include "app/gfx/font.h" |
| 13 #include "app/slide_animation.h" | 13 #include "app/slide_animation.h" |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/gfx/rect.h" | 15 #include "base/gfx/rect.h" |
| 16 #include "base/string16.h" | 16 #include "base/string16.h" |
| 17 #include "chrome/common/notification_observer.h" |
| 18 #include "chrome/common/notification_registrar.h" |
| 17 #include "chrome/common/owned_widget_gtk.h" | 19 #include "chrome/common/owned_widget_gtk.h" |
| 18 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
| 19 | 21 |
| 20 namespace gfx { | 22 namespace gfx { |
| 21 class Size; | 23 class Size; |
| 22 } // namespace gfx | 24 } // namespace gfx |
| 23 | 25 |
| 24 class CustomDrawButton; | 26 class CustomDrawButton; |
| 25 class TabContents; | 27 class TabContents; |
| 26 class ThemeProvider; | 28 class ThemeProvider; |
| 27 | 29 |
| 28 class TabRendererGtk : public AnimationDelegate { | 30 class TabRendererGtk : public AnimationDelegate { |
| 29 public: | 31 public: |
| 30 // Possible animation states. | 32 // Possible animation states. |
| 31 enum AnimationState { | 33 enum AnimationState { |
| 32 ANIMATION_NONE, | 34 ANIMATION_NONE, |
| 33 ANIMATION_WAITING, | 35 ANIMATION_WAITING, |
| 34 ANIMATION_LOADING | 36 ANIMATION_LOADING |
| 35 }; | 37 }; |
| 36 | 38 |
| 37 class LoadingAnimation { | 39 class LoadingAnimation : public NotificationObserver { |
| 38 public: | 40 public: |
| 39 struct Data { | 41 struct Data { |
| 42 explicit Data(ThemeProvider* theme_provider); |
| 43 |
| 40 SkBitmap* waiting_animation_frames; | 44 SkBitmap* waiting_animation_frames; |
| 41 SkBitmap* loading_animation_frames; | 45 SkBitmap* loading_animation_frames; |
| 42 int loading_animation_frame_count; | 46 int loading_animation_frame_count; |
| 43 int waiting_animation_frame_count; | 47 int waiting_animation_frame_count; |
| 44 int waiting_to_loading_frame_count_ratio; | 48 int waiting_to_loading_frame_count_ratio; |
| 45 }; | 49 }; |
| 46 | 50 |
| 47 explicit LoadingAnimation(const Data* data); | 51 explicit LoadingAnimation(ThemeProvider* theme_provider); |
| 48 | 52 |
| 49 // Advance the loading animation to the next frame, or hide the animation if | 53 // Advance the loading animation to the next frame, or hide the animation if |
| 50 // the tab isn't loading. | 54 // the tab isn't loading. |
| 51 void ValidateLoadingAnimation(AnimationState animation_state); | 55 void ValidateLoadingAnimation(AnimationState animation_state); |
| 52 | 56 |
| 53 AnimationState animation_state() const { return animation_state_; } | 57 AnimationState animation_state() const { return animation_state_; } |
| 54 int animation_frame() const { return animation_frame_; } | 58 int animation_frame() const { return animation_frame_; } |
| 55 | 59 |
| 56 const SkBitmap* waiting_animation_frames() const { | 60 const SkBitmap* waiting_animation_frames() const { |
| 57 return data_->waiting_animation_frames; | 61 return data_->waiting_animation_frames; |
| 58 } | 62 } |
| 59 const SkBitmap* loading_animation_frames() const { | 63 const SkBitmap* loading_animation_frames() const { |
| 60 return data_->loading_animation_frames; | 64 return data_->loading_animation_frames; |
| 61 } | 65 } |
| 62 | 66 |
| 67 // Provide NotificationObserver implementation. |
| 68 virtual void Observe(NotificationType type, |
| 69 const NotificationSource& source, |
| 70 const NotificationDetails& details); |
| 71 |
| 63 private: | 72 private: |
| 64 const Data* const data_; | 73 scoped_ptr<Data> data_; |
| 74 |
| 75 // Used to listen for theme change notifications. |
| 76 NotificationRegistrar registrar_; |
| 77 |
| 78 // Gives us our throbber images. |
| 79 ThemeProvider* theme_provider_; |
| 65 | 80 |
| 66 // Current state of the animation. | 81 // Current state of the animation. |
| 67 AnimationState animation_state_; | 82 AnimationState animation_state_; |
| 68 | 83 |
| 69 // The current index into the Animation image strip. | 84 // The current index into the Animation image strip. |
| 70 int animation_frame_; | 85 int animation_frame_; |
| 71 | 86 |
| 72 DISALLOW_COPY_AND_ASSIGN(LoadingAnimation); | 87 DISALLOW_COPY_AND_ASSIGN(LoadingAnimation); |
| 73 }; | 88 }; |
| 74 | 89 |
| 75 TabRendererGtk(); | 90 explicit TabRendererGtk(ThemeProvider* theme_provider); |
| 76 virtual ~TabRendererGtk(); | 91 virtual ~TabRendererGtk(); |
| 77 | 92 |
| 78 // TabContents. If only the loading state was updated, the loading_only flag | 93 // TabContents. If only the loading state was updated, the loading_only flag |
| 79 // should be specified. If other things change, set this flag to false to | 94 // should be specified. If other things change, set this flag to false to |
| 80 // update everything. | 95 // update everything. |
| 81 virtual void UpdateData(TabContents* contents, bool loading_only); | 96 virtual void UpdateData(TabContents* contents, bool loading_only); |
| 82 | 97 |
| 83 // Sets the pinned state of the tab. | 98 // Sets the pinned state of the tab. |
| 84 void set_pinned(bool pinned); | 99 void set_pinned(bool pinned); |
| 85 bool is_pinned() const; | 100 bool is_pinned() const; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 // still render the old theme for this tab. | 333 // still render the old theme for this tab. |
| 319 ThemeProvider* theme_provider_; | 334 ThemeProvider* theme_provider_; |
| 320 | 335 |
| 321 // The close button. | 336 // The close button. |
| 322 scoped_ptr<CustomDrawButton> close_button_; | 337 scoped_ptr<CustomDrawButton> close_button_; |
| 323 | 338 |
| 324 DISALLOW_COPY_AND_ASSIGN(TabRendererGtk); | 339 DISALLOW_COPY_AND_ASSIGN(TabRendererGtk); |
| 325 }; | 340 }; |
| 326 | 341 |
| 327 #endif // CHROME_BROWSER_GTK_TABS_TAB_RENDERER_GTK_H_ | 342 #endif // CHROME_BROWSER_GTK_TABS_TAB_RENDERER_GTK_H_ |
| OLD | NEW |