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

Side by Side Diff: chrome/browser/ui/gtk/custom_button.cc

Issue 7484035: Reapplies r91761. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 int CustomDrawButtonBase::Height() const { 67 int CustomDrawButtonBase::Height() const {
68 return surfaces_[0]->Height(); 68 return surfaces_[0]->Height();
69 } 69 }
70 70
71 gboolean CustomDrawButtonBase::OnExpose(GtkWidget* widget, 71 gboolean CustomDrawButtonBase::OnExpose(GtkWidget* widget,
72 GdkEventExpose* e, 72 GdkEventExpose* e,
73 gdouble hover_state) { 73 gdouble hover_state) {
74 int paint_state = paint_override_ >= 0 ? 74 int paint_state = paint_override_ >= 0 ?
75 paint_override_ : GTK_WIDGET_STATE(widget); 75 paint_override_ : gtk_widget_get_state(widget);
76 76
77 // If the paint state is PRELIGHT then set it to NORMAL (we will paint the 77 // If the paint state is PRELIGHT then set it to NORMAL (we will paint the
78 // hover state according to |hover_state_|). 78 // hover state according to |hover_state_|).
79 if (paint_state == GTK_STATE_PRELIGHT) 79 if (paint_state == GTK_STATE_PRELIGHT)
80 paint_state = GTK_STATE_NORMAL; 80 paint_state = GTK_STATE_NORMAL;
81 bool animating_hover = hover_state > 0.0 && 81 bool animating_hover = hover_state > 0.0 &&
82 paint_state == GTK_STATE_NORMAL; 82 paint_state == GTK_STATE_NORMAL;
83 CairoCachedSurface* pixbuf = PixbufForState(paint_state); 83 CairoCachedSurface* pixbuf = PixbufForState(paint_state);
84 CairoCachedSurface* hover_pixbuf = PixbufForState(GTK_STATE_PRELIGHT); 84 CairoCachedSurface* hover_pixbuf = PixbufForState(GTK_STATE_PRELIGHT);
85 85
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 NotificationService::AllSources()); 267 NotificationService::AllSources());
268 } 268 }
269 269
270 CustomDrawButton::~CustomDrawButton() { 270 CustomDrawButton::~CustomDrawButton() {
271 widget_.Destroy(); 271 widget_.Destroy();
272 native_widget_.Destroy(); 272 native_widget_.Destroy();
273 } 273 }
274 274
275 void CustomDrawButton::Init() { 275 void CustomDrawButton::Init() {
276 widget_.Own(gtk_chrome_button_new()); 276 widget_.Own(gtk_chrome_button_new());
277 GTK_WIDGET_UNSET_FLAGS(widget(), GTK_CAN_FOCUS); 277 gtk_widget_set_can_focus(widget(), FALSE);
278 g_signal_connect(widget(), "expose-event", 278 g_signal_connect(widget(), "expose-event",
279 G_CALLBACK(OnCustomExposeThunk), this); 279 G_CALLBACK(OnCustomExposeThunk), this);
280 hover_controller_.Init(widget()); 280 hover_controller_.Init(widget());
281 } 281 }
282 282
283 void CustomDrawButton::Observe(int type, 283 void CustomDrawButton::Observe(int type,
284 const NotificationSource& source, const NotificationDetails& details) { 284 const NotificationSource& source, const NotificationDetails& details) {
285 DCHECK(chrome::NOTIFICATION_BROWSER_THEME_CHANGED == type); 285 DCHECK(chrome::NOTIFICATION_BROWSER_THEME_CHANGED == type);
286 SetBrowserTheme(); 286 SetBrowserTheme();
287 } 287 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 gtk_widget_set_app_paintable(widget(), TRUE); 337 gtk_widget_set_app_paintable(widget(), TRUE);
338 } 338 }
339 339
340 gtk_chrome_button_set_use_gtk_rendering( 340 gtk_chrome_button_set_use_gtk_rendering(
341 GTK_CHROME_BUTTON(widget()), UseGtkTheme()); 341 GTK_CHROME_BUTTON(widget()), UseGtkTheme());
342 } 342 }
343 343
344 bool CustomDrawButton::UseGtkTheme() { 344 bool CustomDrawButton::UseGtkTheme() {
345 return theme_service_ && theme_service_->UsingNativeTheme(); 345 return theme_service_ && theme_service_->UsingNativeTheme();
346 } 346 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/crypto_module_password_dialog.cc ('k') | chrome/browser/ui/gtk/download/download_item_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698