OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_CUSTOM_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_CUSTOM_BUTTON_H_ |
6 #define CHROME_BROWSER_UI_GTK_CUSTOM_BUTTON_H_ | 6 #define CHROME_BROWSER_UI_GTK_CUSTOM_BUTTON_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
| 11 #include "base/compiler_specific.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
13 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
14 #include "third_party/skia/include/core/SkColor.h" | 15 #include "third_party/skia/include/core/SkColor.h" |
15 #include "ui/base/animation/animation_delegate.h" | 16 #include "ui/base/animation/animation_delegate.h" |
16 #include "ui/base/animation/slide_animation.h" | 17 #include "ui/base/animation/slide_animation.h" |
17 #include "ui/base/gtk/gtk_signal.h" | 18 #include "ui/base/gtk/gtk_signal.h" |
18 #include "ui/base/gtk/owned_widget_gtk.h" | 19 #include "ui/base/gtk/owned_widget_gtk.h" |
19 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
20 | 21 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 53 |
53 void set_paint_override(int state) { paint_override_ = state; } | 54 void set_paint_override(int state) { paint_override_ = state; } |
54 int paint_override() const { return paint_override_; } | 55 int paint_override() const { return paint_override_; } |
55 | 56 |
56 // Set the background details. | 57 // Set the background details. |
57 void SetBackground(SkColor color, SkBitmap* image, SkBitmap* mask); | 58 void SetBackground(SkColor color, SkBitmap* image, SkBitmap* mask); |
58 | 59 |
59 // Provide content::NotificationObserver implementation. | 60 // Provide content::NotificationObserver implementation. |
60 virtual void Observe(int type, | 61 virtual void Observe(int type, |
61 const content::NotificationSource& source, | 62 const content::NotificationSource& source, |
62 const content::NotificationDetails& details); | 63 const content::NotificationDetails& details) OVERRIDE; |
63 | 64 |
64 private: | 65 private: |
65 // Get the CairoCachedSurface from |surfaces_| for |state|. | 66 // Get the CairoCachedSurface from |surfaces_| for |state|. |
66 CairoCachedSurface* PixbufForState(int state); | 67 CairoCachedSurface* PixbufForState(int state); |
67 | 68 |
68 // We store one surface for each possible state of the button; | 69 // We store one surface for each possible state of the button; |
69 // INSENSITIVE is the last available state; | 70 // INSENSITIVE is the last available state; |
70 scoped_ptr<CairoCachedSurface> surfaces_[GTK_STATE_INSENSITIVE + 1]; | 71 scoped_ptr<CairoCachedSurface> surfaces_[GTK_STATE_INSENSITIVE + 1]; |
71 | 72 |
72 // The background image. | 73 // The background image. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 106 |
106 virtual ~CustomDrawHoverController(); | 107 virtual ~CustomDrawHoverController(); |
107 | 108 |
108 void Init(GtkWidget* widget); | 109 void Init(GtkWidget* widget); |
109 | 110 |
110 double GetCurrentValue() { | 111 double GetCurrentValue() { |
111 return slide_animation_.GetCurrentValue(); | 112 return slide_animation_.GetCurrentValue(); |
112 } | 113 } |
113 | 114 |
114 private: | 115 private: |
115 virtual void AnimationProgressed(const ui::Animation* animation); | 116 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
116 | 117 |
117 CHROMEGTK_CALLBACK_1(CustomDrawHoverController, gboolean, OnEnter, | 118 CHROMEGTK_CALLBACK_1(CustomDrawHoverController, gboolean, OnEnter, |
118 GdkEventCrossing*); | 119 GdkEventCrossing*); |
119 CHROMEGTK_CALLBACK_1(CustomDrawHoverController, gboolean, OnLeave, | 120 CHROMEGTK_CALLBACK_1(CustomDrawHoverController, gboolean, OnLeave, |
120 GdkEventCrossing*); | 121 GdkEventCrossing*); |
121 | 122 |
122 ui::SlideAnimation slide_animation_; | 123 ui::SlideAnimation slide_animation_; |
123 GtkWidget* widget_; | 124 GtkWidget* widget_; |
124 }; | 125 }; |
125 | 126 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 189 |
189 // Resume normal drawing of the widget's state. | 190 // Resume normal drawing of the widget's state. |
190 void UnsetPaintOverride(); | 191 void UnsetPaintOverride(); |
191 | 192 |
192 // Set the background details. | 193 // Set the background details. |
193 void SetBackground(SkColor color, SkBitmap* image, SkBitmap* mask); | 194 void SetBackground(SkColor color, SkBitmap* image, SkBitmap* mask); |
194 | 195 |
195 // content::NotificationObserver implementation. | 196 // content::NotificationObserver implementation. |
196 virtual void Observe(int type, | 197 virtual void Observe(int type, |
197 const content::NotificationSource& source, | 198 const content::NotificationSource& source, |
198 const content::NotificationDetails& details); | 199 const content::NotificationDetails& details) OVERRIDE; |
199 | 200 |
200 // Returns a standard close button. Pass a |theme_provider| to use Gtk icons | 201 // Returns a standard close button. Pass a |theme_provider| to use Gtk icons |
201 // in Gtk rendering mode. | 202 // in Gtk rendering mode. |
202 static CustomDrawButton* CloseButton(GtkThemeService* theme_provider); | 203 static CustomDrawButton* CloseButton(GtkThemeService* theme_provider); |
203 | 204 |
204 private: | 205 private: |
205 // Sets the button to themed or not. | 206 // Sets the button to themed or not. |
206 void SetBrowserTheme(); | 207 void SetBrowserTheme(); |
207 | 208 |
208 // Whether to use the GTK+ theme. For this to be true, we have to be in GTK+ | 209 // Whether to use the GTK+ theme. For this to be true, we have to be in GTK+ |
(...skipping 20 matching lines...) Expand all Loading... |
229 // True if we should never do gtk rendering. | 230 // True if we should never do gtk rendering. |
230 bool forcing_chrome_theme_; | 231 bool forcing_chrome_theme_; |
231 | 232 |
232 // Used to listen for theme change notifications. | 233 // Used to listen for theme change notifications. |
233 content::NotificationRegistrar registrar_; | 234 content::NotificationRegistrar registrar_; |
234 | 235 |
235 DISALLOW_COPY_AND_ASSIGN(CustomDrawButton); | 236 DISALLOW_COPY_AND_ASSIGN(CustomDrawButton); |
236 }; | 237 }; |
237 | 238 |
238 #endif // CHROME_BROWSER_UI_GTK_CUSTOM_BUTTON_H_ | 239 #endif // CHROME_BROWSER_UI_GTK_CUSTOM_BUTTON_H_ |
OLD | NEW |