Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: chrome/browser/gtk/tabs/tab_renderer_gtk.h

Issue 155601: GTK Themes: Tint throbbers like we tint all other buttons in the interface. (Closed)
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/gtk/tabs/tab_gtk.cc ('k') | chrome/browser/gtk/tabs/tab_renderer_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 Data(int loading, int waiting, int waiting_to_loading);
44
40 SkBitmap* waiting_animation_frames; 45 SkBitmap* waiting_animation_frames;
41 SkBitmap* loading_animation_frames; 46 SkBitmap* loading_animation_frames;
42 int loading_animation_frame_count; 47 int loading_animation_frame_count;
43 int waiting_animation_frame_count; 48 int waiting_animation_frame_count;
44 int waiting_to_loading_frame_count_ratio; 49 int waiting_to_loading_frame_count_ratio;
45 }; 50 };
46 51
47 explicit LoadingAnimation(const Data* data); 52 explicit LoadingAnimation(ThemeProvider* theme_provider);
53
54 // Used in unit tests to inject specific data.
55 explicit LoadingAnimation(const LoadingAnimation::Data& data);
48 56
49 // Advance the loading animation to the next frame, or hide the animation if 57 // Advance the loading animation to the next frame, or hide the animation if
50 // the tab isn't loading. 58 // the tab isn't loading.
51 void ValidateLoadingAnimation(AnimationState animation_state); 59 void ValidateLoadingAnimation(AnimationState animation_state);
52 60
53 AnimationState animation_state() const { return animation_state_; } 61 AnimationState animation_state() const { return animation_state_; }
54 int animation_frame() const { return animation_frame_; } 62 int animation_frame() const { return animation_frame_; }
55 63
56 const SkBitmap* waiting_animation_frames() const { 64 const SkBitmap* waiting_animation_frames() const {
57 return data_->waiting_animation_frames; 65 return data_->waiting_animation_frames;
58 } 66 }
59 const SkBitmap* loading_animation_frames() const { 67 const SkBitmap* loading_animation_frames() const {
60 return data_->loading_animation_frames; 68 return data_->loading_animation_frames;
61 } 69 }
62 70
71 // Provide NotificationObserver implementation.
72 virtual void Observe(NotificationType type,
73 const NotificationSource& source,
74 const NotificationDetails& details);
75
63 private: 76 private:
64 const Data* const data_; 77 scoped_ptr<Data> data_;
78
79 // Used to listen for theme change notifications.
80 NotificationRegistrar registrar_;
81
82 // Gives us our throbber images.
83 ThemeProvider* theme_provider_;
65 84
66 // Current state of the animation. 85 // Current state of the animation.
67 AnimationState animation_state_; 86 AnimationState animation_state_;
68 87
69 // The current index into the Animation image strip. 88 // The current index into the Animation image strip.
70 int animation_frame_; 89 int animation_frame_;
71 90
72 DISALLOW_COPY_AND_ASSIGN(LoadingAnimation); 91 DISALLOW_COPY_AND_ASSIGN(LoadingAnimation);
73 }; 92 };
74 93
75 TabRendererGtk(); 94 explicit TabRendererGtk(ThemeProvider* theme_provider);
76 virtual ~TabRendererGtk(); 95 virtual ~TabRendererGtk();
77 96
78 // TabContents. If only the loading state was updated, the loading_only flag 97 // 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 98 // should be specified. If other things change, set this flag to false to
80 // update everything. 99 // update everything.
81 virtual void UpdateData(TabContents* contents, bool loading_only); 100 virtual void UpdateData(TabContents* contents, bool loading_only);
82 101
83 // Sets the pinned state of the tab. 102 // Sets the pinned state of the tab.
84 void set_pinned(bool pinned); 103 void set_pinned(bool pinned);
85 bool is_pinned() const; 104 bool is_pinned() const;
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 // still render the old theme for this tab. 337 // still render the old theme for this tab.
319 ThemeProvider* theme_provider_; 338 ThemeProvider* theme_provider_;
320 339
321 // The close button. 340 // The close button.
322 scoped_ptr<CustomDrawButton> close_button_; 341 scoped_ptr<CustomDrawButton> close_button_;
323 342
324 DISALLOW_COPY_AND_ASSIGN(TabRendererGtk); 343 DISALLOW_COPY_AND_ASSIGN(TabRendererGtk);
325 }; 344 };
326 345
327 #endif // CHROME_BROWSER_GTK_TABS_TAB_RENDERER_GTK_H_ 346 #endif // CHROME_BROWSER_GTK_TABS_TAB_RENDERER_GTK_H_
OLDNEW
« no previous file with comments | « chrome/browser/gtk/tabs/tab_gtk.cc ('k') | chrome/browser/gtk/tabs/tab_renderer_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698