| 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 "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" | 10 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 bool animating_hover = hover_state > 0.0 && | 84 bool animating_hover = hover_state > 0.0 && |
| 85 paint_state == GTK_STATE_NORMAL; | 85 paint_state == GTK_STATE_NORMAL; |
| 86 gfx::CairoCachedSurface* pixbuf = PixbufForState(paint_state); | 86 gfx::CairoCachedSurface* pixbuf = PixbufForState(paint_state); |
| 87 gfx::CairoCachedSurface* hover_pixbuf = PixbufForState(GTK_STATE_PRELIGHT); | 87 gfx::CairoCachedSurface* hover_pixbuf = PixbufForState(GTK_STATE_PRELIGHT); |
| 88 | 88 |
| 89 if (!pixbuf || !pixbuf->valid()) | 89 if (!pixbuf || !pixbuf->valid()) |
| 90 return FALSE; | 90 return FALSE; |
| 91 if (animating_hover && (!hover_pixbuf || !hover_pixbuf->valid())) | 91 if (animating_hover && (!hover_pixbuf || !hover_pixbuf->valid())) |
| 92 return FALSE; | 92 return FALSE; |
| 93 | 93 |
| 94 cairo_t* cairo_context = gdk_cairo_create(GDK_DRAWABLE(widget->window)); | 94 cairo_t* cairo_context = gdk_cairo_create(GDK_DRAWABLE( |
| 95 gtk_widget_get_window(widget))); |
| 95 GtkAllocation allocation; | 96 GtkAllocation allocation; |
| 96 gtk_widget_get_allocation(widget, &allocation); | 97 gtk_widget_get_allocation(widget, &allocation); |
| 97 cairo_translate(cairo_context, allocation.x, allocation.y); | 98 cairo_translate(cairo_context, allocation.x, allocation.y); |
| 98 | 99 |
| 99 if (flipped_) { | 100 if (flipped_) { |
| 100 // Horizontally flip the image for non-LTR/RTL reasons. | 101 // Horizontally flip the image for non-LTR/RTL reasons. |
| 101 cairo_translate(cairo_context, allocation.width, 0.0f); | 102 cairo_translate(cairo_context, allocation.width, 0.0f); |
| 102 cairo_scale(cairo_context, -1.0f, 1.0f); | 103 cairo_scale(cairo_context, -1.0f, 1.0f); |
| 103 } | 104 } |
| 104 | 105 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 } | 369 } |
| 369 | 370 |
| 370 gtk_chrome_button_set_use_gtk_rendering( | 371 gtk_chrome_button_set_use_gtk_rendering( |
| 371 GTK_CHROME_BUTTON(widget()), UseGtkTheme()); | 372 GTK_CHROME_BUTTON(widget()), UseGtkTheme()); |
| 372 } | 373 } |
| 373 | 374 |
| 374 bool CustomDrawButton::UseGtkTheme() { | 375 bool CustomDrawButton::UseGtkTheme() { |
| 375 return !forcing_chrome_theme_ && theme_service_ && | 376 return !forcing_chrome_theme_ && theme_service_ && |
| 376 theme_service_->UsingNativeTheme(); | 377 theme_service_->UsingNativeTheme(); |
| 377 } | 378 } |
| OLD | NEW |