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 #include "chrome/browser/ui/gtk/custom_button.h" | 5 #include "chrome/browser/ui/gtk/custom_button.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "chrome/browser/ui/gtk/cairo_cached_surface.h" | 8 #include "chrome/browser/ui/gtk/cairo_cached_surface.h" |
9 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" | 9 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
10 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 10 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 64 } |
65 | 65 |
66 int CustomDrawButtonBase::Height() const { | 66 int CustomDrawButtonBase::Height() const { |
67 return surfaces_[0]->Height(); | 67 return surfaces_[0]->Height(); |
68 } | 68 } |
69 | 69 |
70 gboolean CustomDrawButtonBase::OnExpose(GtkWidget* widget, | 70 gboolean CustomDrawButtonBase::OnExpose(GtkWidget* widget, |
71 GdkEventExpose* e, | 71 GdkEventExpose* e, |
72 gdouble hover_state) { | 72 gdouble hover_state) { |
73 int paint_state = paint_override_ >= 0 ? | 73 int paint_state = paint_override_ >= 0 ? |
74 paint_override_ : GTK_WIDGET_STATE(widget); | 74 paint_override_ : gtk_widget_get_state(widget); |
75 | 75 |
76 // If the paint state is PRELIGHT then set it to NORMAL (we will paint the | 76 // If the paint state is PRELIGHT then set it to NORMAL (we will paint the |
77 // hover state according to |hover_state_|). | 77 // hover state according to |hover_state_|). |
78 if (paint_state == GTK_STATE_PRELIGHT) | 78 if (paint_state == GTK_STATE_PRELIGHT) |
79 paint_state = GTK_STATE_NORMAL; | 79 paint_state = GTK_STATE_NORMAL; |
80 bool animating_hover = hover_state > 0.0 && | 80 bool animating_hover = hover_state > 0.0 && |
81 paint_state == GTK_STATE_NORMAL; | 81 paint_state == GTK_STATE_NORMAL; |
82 CairoCachedSurface* pixbuf = PixbufForState(paint_state); | 82 CairoCachedSurface* pixbuf = PixbufForState(paint_state); |
83 CairoCachedSurface* hover_pixbuf = PixbufForState(GTK_STATE_PRELIGHT); | 83 CairoCachedSurface* hover_pixbuf = PixbufForState(GTK_STATE_PRELIGHT); |
84 | 84 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 NotificationService::AllSources()); | 266 NotificationService::AllSources()); |
267 } | 267 } |
268 | 268 |
269 CustomDrawButton::~CustomDrawButton() { | 269 CustomDrawButton::~CustomDrawButton() { |
270 widget_.Destroy(); | 270 widget_.Destroy(); |
271 native_widget_.Destroy(); | 271 native_widget_.Destroy(); |
272 } | 272 } |
273 | 273 |
274 void CustomDrawButton::Init() { | 274 void CustomDrawButton::Init() { |
275 widget_.Own(gtk_chrome_button_new()); | 275 widget_.Own(gtk_chrome_button_new()); |
276 GTK_WIDGET_UNSET_FLAGS(widget(), GTK_CAN_FOCUS); | 276 gtk_widget_set_can_focus(widget(), FALSE); |
277 g_signal_connect(widget(), "expose-event", | 277 g_signal_connect(widget(), "expose-event", |
278 G_CALLBACK(OnCustomExposeThunk), this); | 278 G_CALLBACK(OnCustomExposeThunk), this); |
279 hover_controller_.Init(widget()); | 279 hover_controller_.Init(widget()); |
280 } | 280 } |
281 | 281 |
282 void CustomDrawButton::Observe(NotificationType type, | 282 void CustomDrawButton::Observe(NotificationType type, |
283 const NotificationSource& source, const NotificationDetails& details) { | 283 const NotificationSource& source, const NotificationDetails& details) { |
284 DCHECK(NotificationType::BROWSER_THEME_CHANGED == type); | 284 DCHECK(NotificationType::BROWSER_THEME_CHANGED == type); |
285 SetBrowserTheme(); | 285 SetBrowserTheme(); |
286 } | 286 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 gtk_widget_set_app_paintable(widget(), TRUE); | 336 gtk_widget_set_app_paintable(widget(), TRUE); |
337 } | 337 } |
338 | 338 |
339 gtk_chrome_button_set_use_gtk_rendering( | 339 gtk_chrome_button_set_use_gtk_rendering( |
340 GTK_CHROME_BUTTON(widget()), UseGtkTheme()); | 340 GTK_CHROME_BUTTON(widget()), UseGtkTheme()); |
341 } | 341 } |
342 | 342 |
343 bool CustomDrawButton::UseGtkTheme() { | 343 bool CustomDrawButton::UseGtkTheme() { |
344 return theme_service_ && theme_service_->UsingNativeTheme(); | 344 return theme_service_ && theme_service_->UsingNativeTheme(); |
345 } | 345 } |
OLD | NEW |