| 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/gtk_chrome_button.h" | 5 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "chrome/browser/ui/gtk/nine_box.h" | 8 #include "chrome/browser/ui/gtk/nine_box.h" |
| 9 #include "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
| 10 #include "ui/gfx/gtk_util.h" | 10 #include "ui/gfx/gtk_util.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 " GtkButton::child-displacement-y = 0" | 47 " GtkButton::child-displacement-y = 0" |
| 48 " GtkButton::inner-border = { 0, 0, 0, 0 }" | 48 " GtkButton::inner-border = { 0, 0, 0, 0 }" |
| 49 "}" | 49 "}" |
| 50 "widget_class \"*.<GtkChromeButton>\" style \"chrome-button\""); | 50 "widget_class \"*.<GtkChromeButton>\" style \"chrome-button\""); |
| 51 | 51 |
| 52 GtkWidgetClass* widget_class = | 52 GtkWidgetClass* widget_class = |
| 53 reinterpret_cast<GtkWidgetClass*>(button_class); | 53 reinterpret_cast<GtkWidgetClass*>(button_class); |
| 54 widget_class->expose_event = gtk_chrome_button_expose; | 54 widget_class->expose_event = gtk_chrome_button_expose; |
| 55 | 55 |
| 56 g_nine_box_prelight = new NineBox( | 56 g_nine_box_prelight = new NineBox( |
| 57 IDR_TEXTBUTTON_TOP_LEFT_H, | 57 IDR_TEXTBUTTON_HOVER_TOP_LEFT, |
| 58 IDR_TEXTBUTTON_TOP_H, | 58 IDR_TEXTBUTTON_HOVER_TOP, |
| 59 IDR_TEXTBUTTON_TOP_RIGHT_H, | 59 IDR_TEXTBUTTON_HOVER_TOP_RIGHT, |
| 60 IDR_TEXTBUTTON_LEFT_H, | 60 IDR_TEXTBUTTON_HOVER_LEFT, |
| 61 IDR_TEXTBUTTON_CENTER_H, | 61 IDR_TEXTBUTTON_HOVER_CENTER, |
| 62 IDR_TEXTBUTTON_RIGHT_H, | 62 IDR_TEXTBUTTON_HOVER_RIGHT, |
| 63 IDR_TEXTBUTTON_BOTTOM_LEFT_H, | 63 IDR_TEXTBUTTON_HOVER_BOTTOM_LEFT, |
| 64 IDR_TEXTBUTTON_BOTTOM_H, | 64 IDR_TEXTBUTTON_HOVER_BOTTOM, |
| 65 IDR_TEXTBUTTON_BOTTOM_RIGHT_H); | 65 IDR_TEXTBUTTON_HOVER_BOTTOM_RIGHT); |
| 66 | 66 |
| 67 g_nine_box_active = new NineBox( | 67 g_nine_box_active = new NineBox( |
| 68 IDR_TEXTBUTTON_TOP_LEFT_P, | 68 IDR_TEXTBUTTON_PRESSED_TOP_LEFT, |
| 69 IDR_TEXTBUTTON_TOP_P, | 69 IDR_TEXTBUTTON_PRESSED_TOP, |
| 70 IDR_TEXTBUTTON_TOP_RIGHT_P, | 70 IDR_TEXTBUTTON_PRESSED_TOP_RIGHT, |
| 71 IDR_TEXTBUTTON_LEFT_P, | 71 IDR_TEXTBUTTON_PRESSED_LEFT, |
| 72 IDR_TEXTBUTTON_CENTER_P, | 72 IDR_TEXTBUTTON_PRESSED_CENTER, |
| 73 IDR_TEXTBUTTON_RIGHT_P, | 73 IDR_TEXTBUTTON_PRESSED_RIGHT, |
| 74 IDR_TEXTBUTTON_BOTTOM_LEFT_P, | 74 IDR_TEXTBUTTON_PRESSED_BOTTOM_LEFT, |
| 75 IDR_TEXTBUTTON_BOTTOM_P, | 75 IDR_TEXTBUTTON_PRESSED_BOTTOM, |
| 76 IDR_TEXTBUTTON_BOTTOM_RIGHT_P); | 76 IDR_TEXTBUTTON_PRESSED_BOTTOM_RIGHT); |
| 77 | 77 |
| 78 GObjectClass* gobject_class = G_OBJECT_CLASS(button_class); | 78 GObjectClass* gobject_class = G_OBJECT_CLASS(button_class); |
| 79 g_type_class_add_private(gobject_class, sizeof(GtkChromeButtonPrivate)); | 79 g_type_class_add_private(gobject_class, sizeof(GtkChromeButtonPrivate)); |
| 80 } | 80 } |
| 81 | 81 |
| 82 static void gtk_chrome_button_init(GtkChromeButton* button) { | 82 static void gtk_chrome_button_init(GtkChromeButton* button) { |
| 83 GtkChromeButtonPrivate* priv = GTK_CHROME_BUTTON_GET_PRIVATE(button); | 83 GtkChromeButtonPrivate* priv = GTK_CHROME_BUTTON_GET_PRIVATE(button); |
| 84 priv->paint_state = -1; | 84 priv->paint_state = -1; |
| 85 priv->use_gtk_rendering = FALSE; | 85 priv->use_gtk_rendering = FALSE; |
| 86 priv->hover_state = -1.0; | 86 priv->hover_state = -1.0; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 gdouble state) { | 164 gdouble state) { |
| 165 GtkChromeButtonPrivate* priv = GTK_CHROME_BUTTON_GET_PRIVATE(button); | 165 GtkChromeButtonPrivate* priv = GTK_CHROME_BUTTON_GET_PRIVATE(button); |
| 166 if (state >= 0.0 && state <= 1.0) | 166 if (state >= 0.0 && state <= 1.0) |
| 167 priv->hover_state = state; | 167 priv->hover_state = state; |
| 168 else | 168 else |
| 169 priv->hover_state = -1.0; | 169 priv->hover_state = -1.0; |
| 170 gtk_widget_queue_draw(GTK_WIDGET(button)); | 170 gtk_widget_queue_draw(GTK_WIDGET(button)); |
| 171 } | 171 } |
| 172 | 172 |
| 173 G_END_DECLS | 173 G_END_DECLS |
| OLD | NEW |