annotate src/skins/ui_skinned_button.c @ 3085:ac0af6b39272

Introduce new GIO plugin to buildsystem. stdio is now deprecated. Thoughts: - getc()/ungetc() should be moved to VFS core now
author William Pitcock <nenolod@atheme.org>
date Wed, 29 Apr 2009 20:58:36 -0500
parents 6baa6eaf8290
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2585
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1 /*
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
2 * Audacious - a cross-platform multimedia player
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
3 * Copyright (c) 2007 Tomasz Moń
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
4 *
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation; under version 3 of the License.
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
8 *
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
12 * GNU General Public License for more details.
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
13 *
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses>.
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
16 *
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
17 * The Audacious team does not consider modular code linking to
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
18 * Audacious or using our public API to be a derived work.
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
19 */
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
20
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
21 #include "ui_skinned_button.h"
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
22 #include "skins_cfg.h"
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
23 #include <math.h>
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
24
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
25 #define UI_SKINNED_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ui_skinned_button_get_type(), UiSkinnedButtonPrivate))
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
26 typedef struct _UiSkinnedButtonPrivate UiSkinnedButtonPrivate;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
27
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
28 enum {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
29 PRESSED,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
30 RELEASED,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
31 CLICKED,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
32 DOUBLED,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
33 LAST_SIGNAL
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
34 };
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
35
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
36 struct _UiSkinnedButtonPrivate {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
37 //Skinned part
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
38 GdkGC *gc;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
39 gint w;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
40 gint h;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
41 SkinPixmapId skin_index1;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
42 SkinPixmapId skin_index2;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
43 gboolean scaled;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
44 gint move_x, move_y;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
45
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
46 gint nx, ny, px, py;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
47 //Toogle button needs also those
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
48 gint pnx, pny, ppx, ppy;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
49 };
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
50
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
51
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
52 static GtkWidgetClass *parent_class = NULL;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
53 static void ui_skinned_button_class_init(UiSkinnedButtonClass *klass);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
54 static void ui_skinned_button_init(UiSkinnedButton *button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
55 static void ui_skinned_button_destroy(GtkObject *object);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
56 static void ui_skinned_button_realize(GtkWidget *widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
57 static void ui_skinned_button_unrealize(GtkWidget *widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
58 static void ui_skinned_button_map(GtkWidget *widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
59 static void ui_skinned_button_unmap(GtkWidget *widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
60 static void ui_skinned_button_size_request(GtkWidget *widget, GtkRequisition *requisition);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
61 static gint ui_skinned_button_expose(GtkWidget *widget,GdkEventExpose *event);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
62
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
63 static void ui_skinned_button_size_allocate(GtkWidget *widget, GtkAllocation *allocation);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
64 static void ui_skinned_button_update_state(UiSkinnedButton *button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
65
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
66 static guint button_signals[LAST_SIGNAL] = { 0 };
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
67 static gint ui_skinned_button_button_press(GtkWidget *widget, GdkEventButton *event);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
68 static gint ui_skinned_button_button_release(GtkWidget *widget, GdkEventButton *event);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
69 static void button_pressed(UiSkinnedButton *button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
70 static void button_released(UiSkinnedButton *button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
71 static void ui_skinned_button_pressed(UiSkinnedButton *button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
72 static void ui_skinned_button_released(UiSkinnedButton *button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
73 static void ui_skinned_button_clicked(UiSkinnedButton *button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
74 static void ui_skinned_button_set_pressed (UiSkinnedButton *button, gboolean pressed);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
75
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
76 static void ui_skinned_button_toggle_scaled(UiSkinnedButton *button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
77
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
78 static gint ui_skinned_button_enter_notify(GtkWidget *widget, GdkEventCrossing *event);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
79 static gint ui_skinned_button_leave_notify(GtkWidget *widget, GdkEventCrossing *event);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
80
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
81 GType ui_skinned_button_get_type() {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
82 static GType button_type = 0;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
83 if (!button_type) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
84 static const GTypeInfo button_info = {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
85 sizeof (UiSkinnedButtonClass),
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
86 NULL,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
87 NULL,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
88 (GClassInitFunc) ui_skinned_button_class_init,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
89 NULL,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
90 NULL,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
91 sizeof (UiSkinnedButton),
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
92 0,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
93 (GInstanceInitFunc) ui_skinned_button_init,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
94 };
2590
Tomasz Mon <desowin@gmail.com>
parents: 2585
diff changeset
95 button_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSkinnedButton", &button_info, 0);
2585
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
96 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
97
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
98 return button_type;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
99 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
100
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
101 static void ui_skinned_button_class_init (UiSkinnedButtonClass *klass) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
102 GObjectClass *gobject_class;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
103 GtkObjectClass *object_class;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
104 GtkWidgetClass *widget_class;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
105
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
106 gobject_class = G_OBJECT_CLASS(klass);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
107 object_class = (GtkObjectClass*) klass;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
108 widget_class = (GtkWidgetClass*) klass;
3032
6baa6eaf8290 Don't use deprecated gtk_type_class()
Tomasz Mon <desowin@gmail.com>
parents: 3017
diff changeset
109 parent_class = g_type_class_peek_parent(klass);
2585
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
110
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
111 object_class->destroy = ui_skinned_button_destroy;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
112
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
113 widget_class->realize = ui_skinned_button_realize;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
114 widget_class->unrealize = ui_skinned_button_unrealize;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
115 widget_class->map = ui_skinned_button_map;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
116 widget_class->unmap = ui_skinned_button_unmap;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
117 widget_class->expose_event = ui_skinned_button_expose;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
118 widget_class->size_request = ui_skinned_button_size_request;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
119 widget_class->size_allocate = ui_skinned_button_size_allocate;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
120 widget_class->button_press_event = ui_skinned_button_button_press;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
121 widget_class->button_release_event = ui_skinned_button_button_release;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
122 widget_class->enter_notify_event = ui_skinned_button_enter_notify;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
123 widget_class->leave_notify_event = ui_skinned_button_leave_notify;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
124
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
125 klass->pressed = button_pressed;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
126 klass->released = button_released;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
127 klass->clicked = NULL;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
128 klass->scaled = ui_skinned_button_toggle_scaled;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
129
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
130 button_signals[PRESSED] =
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
131 g_signal_new ("pressed", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
132 G_STRUCT_OFFSET (UiSkinnedButtonClass, pressed), NULL, NULL,
3017
963796db51ea Don't use deprecated gtk macros and types
Tomasz Mon <desowin@gmail.com>
parents: 2888
diff changeset
133 g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
2585
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
134
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
135 button_signals[RELEASED] =
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
136 g_signal_new ("released", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
137 G_STRUCT_OFFSET (UiSkinnedButtonClass, released), NULL, NULL,
3017
963796db51ea Don't use deprecated gtk macros and types
Tomasz Mon <desowin@gmail.com>
parents: 2888
diff changeset
138 g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
2585
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
139
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
140 button_signals[CLICKED] =
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
141 g_signal_new ("clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
142 G_STRUCT_OFFSET (UiSkinnedButtonClass, clicked), NULL, NULL,
3017
963796db51ea Don't use deprecated gtk macros and types
Tomasz Mon <desowin@gmail.com>
parents: 2888
diff changeset
143 g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
2585
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
144
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
145 button_signals[DOUBLED] =
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
146 g_signal_new ("toggle-scaled", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
147 G_STRUCT_OFFSET (UiSkinnedButtonClass, scaled), NULL, NULL,
3017
963796db51ea Don't use deprecated gtk macros and types
Tomasz Mon <desowin@gmail.com>
parents: 2888
diff changeset
148 g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
2585
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
149
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
150 g_type_class_add_private (gobject_class, sizeof (UiSkinnedButtonPrivate));
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
151 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
152
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
153 static void ui_skinned_button_init (UiSkinnedButton *button) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
154 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
155 button->inside = FALSE;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
156 button->type = TYPE_NOT_SET;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
157 priv->move_x = 0;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
158 priv->move_y = 0;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
159 button->event_window = NULL;
2859
312ba23cbb87 transform UiSkinnedButton into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2721
diff changeset
160
312ba23cbb87 transform UiSkinnedButton into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2721
diff changeset
161 GTK_WIDGET_SET_FLAGS (button, GTK_NO_WINDOW);
2585
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
162 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
163
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
164 static void ui_skinned_button_destroy (GtkObject *object) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
165 UiSkinnedButton *button;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
166
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
167 g_return_if_fail (object != NULL);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
168 g_return_if_fail (UI_SKINNED_IS_BUTTON (object));
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
169
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
170 button = UI_SKINNED_BUTTON(object);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
171
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
172 if (GTK_OBJECT_CLASS (parent_class)->destroy)
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
173 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
174 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
175
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
176 static void ui_skinned_button_realize (GtkWidget *widget) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
177 g_return_if_fail (widget != NULL);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
178 g_return_if_fail (UI_SKINNED_IS_BUTTON(widget));
2859
312ba23cbb87 transform UiSkinnedButton into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2721
diff changeset
179
312ba23cbb87 transform UiSkinnedButton into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2721
diff changeset
180 if (GTK_WIDGET_CLASS (parent_class)->realize)
312ba23cbb87 transform UiSkinnedButton into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2721
diff changeset
181 (* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
312ba23cbb87 transform UiSkinnedButton into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2721
diff changeset
182
2585
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
183 UiSkinnedButton *button = UI_SKINNED_BUTTON (widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
184 GdkWindowAttr attributes;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
185 gint attributes_mask;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
186
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
187 attributes.x = widget->allocation.x;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
188 attributes.y = widget->allocation.y;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
189 attributes.width = widget->allocation.width;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
190 attributes.height = widget->allocation.height;
2860
2e081c64a529 transform UiSkinnedTextbox into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2859
diff changeset
191 attributes.wclass = GDK_INPUT_ONLY;
2e081c64a529 transform UiSkinnedTextbox into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2859
diff changeset
192 attributes.window_type = GDK_WINDOW_CHILD;
2585
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
193 attributes.event_mask = gtk_widget_get_events(widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
194 attributes.event_mask |= GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
195
2859
312ba23cbb87 transform UiSkinnedButton into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2721
diff changeset
196 attributes.wclass = GDK_INPUT_ONLY;
312ba23cbb87 transform UiSkinnedButton into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2721
diff changeset
197 attributes_mask = GDK_WA_X | GDK_WA_Y;
312ba23cbb87 transform UiSkinnedButton into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2721
diff changeset
198 button->event_window = gdk_window_new (widget->window, &attributes, attributes_mask);
312ba23cbb87 transform UiSkinnedButton into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2721
diff changeset
199
312ba23cbb87 transform UiSkinnedButton into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2721
diff changeset
200 gdk_window_set_user_data(button->event_window, widget);
2585
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
201 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
202
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
203 static void ui_skinned_button_unrealize (GtkWidget *widget) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
204 UiSkinnedButton *button = UI_SKINNED_BUTTON (widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
205
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
206 if ( button->event_window != NULL )
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
207 {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
208 gdk_window_set_user_data( button->event_window , NULL );
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
209 gdk_window_destroy( button->event_window );
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
210 button->event_window = NULL;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
211 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
212
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
213 if (GTK_WIDGET_CLASS (parent_class)->unrealize)
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
214 (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
215 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
216
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
217 static void ui_skinned_button_map (GtkWidget *widget)
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
218 {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
219 UiSkinnedButton *button = UI_SKINNED_BUTTON (widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
220
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
221 if (button->event_window != NULL)
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
222 gdk_window_show (button->event_window);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
223
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
224 if (GTK_WIDGET_CLASS (parent_class)->map)
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
225 (* GTK_WIDGET_CLASS (parent_class)->map) (widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
226 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
227
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
228 static void ui_skinned_button_unmap (GtkWidget *widget)
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
229 {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
230 UiSkinnedButton *button = UI_SKINNED_BUTTON (widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
231
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
232 if (button->event_window != NULL)
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
233 gdk_window_hide (button->event_window);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
234
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
235 if (GTK_WIDGET_CLASS (parent_class)->unmap)
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
236 (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
237 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
238
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
239 static void ui_skinned_button_size_request(GtkWidget *widget, GtkRequisition *requisition) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
240 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE(widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
241 requisition->width = priv->w*(priv->scaled ? config.scale_factor : 1);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
242 requisition->height = priv->h*(priv->scaled ? config.scale_factor : 1);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
243 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
244
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
245 static void ui_skinned_button_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
246 UiSkinnedButton *button = UI_SKINNED_BUTTON (widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
247 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
248 widget->allocation = *allocation;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
249 widget->allocation.x = ceil(widget->allocation.x*(priv->scaled ? config.scale_factor : 1));
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
250 widget->allocation.y = ceil(widget->allocation.y*(priv->scaled ? config.scale_factor : 1));
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
251
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
252 if (GTK_WIDGET_REALIZED (widget))
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
253 {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
254 if ( button->event_window != NULL )
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
255 gdk_window_move_resize(button->event_window, ceil(allocation->x*(priv->scaled ? config.scale_factor : 1)), ceil(allocation->y*(priv->scaled ? config.scale_factor : 1)), allocation->width, allocation->height);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
256 else
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
257 gdk_window_move_resize(widget->window, ceil(allocation->x*(priv->scaled ? config.scale_factor : 1)), ceil(allocation->y*(priv->scaled ? config.scale_factor : 1)), allocation->width, allocation->height);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
258 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
259
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
260 if (button->x + priv->move_x == ceil(widget->allocation.x/(priv->scaled ? config.scale_factor : 1)))
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
261 priv->move_x = 0;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
262 if (button->y + priv->move_y == ceil(widget->allocation.y/(priv->scaled ? config.scale_factor : 1)))
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
263 priv->move_y = 0;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
264
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
265 button->x = ceil(widget->allocation.x/(priv->scaled ? config.scale_factor : 1));
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
266 button->y = ceil(widget->allocation.y/(priv->scaled ? config.scale_factor : 1));
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
267 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
268
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
269 static gboolean ui_skinned_button_expose(GtkWidget *widget, GdkEventExpose *event) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
270 g_return_val_if_fail (widget != NULL, FALSE);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
271 g_return_val_if_fail (UI_SKINNED_IS_BUTTON (widget), FALSE);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
272 g_return_val_if_fail (event != NULL, FALSE);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
273
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
274 UiSkinnedButton *button = UI_SKINNED_BUTTON (widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
275 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
276 g_return_val_if_fail (priv->w > 0 && priv->h > 0, FALSE);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
277
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
278 //TYPE_SMALL doesn't have its own face
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
279 if (button->type == TYPE_SMALL || button->type == TYPE_NOT_SET)
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
280 return FALSE;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
281
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
282 GdkPixbuf *obj;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
283 obj = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, priv->w, priv->h);
2859
312ba23cbb87 transform UiSkinnedButton into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2721
diff changeset
284 gdk_pixbuf_fill(obj, 0x00000000); /* fill with alpha */
2585
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
285
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
286 switch (button->type) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
287 case TYPE_PUSH:
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
288 skin_draw_pixbuf(widget, aud_active_skin, obj,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
289 button->pressed ? priv->skin_index2 : priv->skin_index1,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
290 button->pressed ? priv->px : priv->nx,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
291 button->pressed ? priv->py : priv->ny,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
292 0, 0, priv->w, priv->h);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
293 break;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
294 case TYPE_TOGGLE:
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
295 if (button->inside)
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
296 skin_draw_pixbuf(widget, aud_active_skin, obj,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
297 button->pressed ? priv->skin_index2 : priv->skin_index1,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
298 button->pressed ? priv->ppx : priv->pnx,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
299 button->pressed ? priv->ppy : priv->pny,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
300 0, 0, priv->w, priv->h);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
301 else
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
302 skin_draw_pixbuf(widget, aud_active_skin, obj,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
303 button->pressed ? priv->skin_index2 : priv->skin_index1,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
304 button->pressed ? priv->px : priv->nx,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
305 button->pressed ? priv->py : priv->ny,
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
306 0, 0, priv->w, priv->h);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
307 break;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
308 default:
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
309 break;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
310 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
311
2859
312ba23cbb87 transform UiSkinnedButton into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2721
diff changeset
312 ui_skinned_widget_draw_with_coordinates(widget, obj, priv->w, priv->h,
312ba23cbb87 transform UiSkinnedButton into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2721
diff changeset
313 widget->allocation.x,
312ba23cbb87 transform UiSkinnedButton into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2721
diff changeset
314 widget->allocation.y,
312ba23cbb87 transform UiSkinnedButton into windowless widget
Tomasz Mon <desowin@gmail.com>
parents: 2721
diff changeset
315 priv->scaled);
2585
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
316 g_object_unref(obj);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
317
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
318 return FALSE;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
319 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
320
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
321 GtkWidget* ui_skinned_button_new () {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
322 UiSkinnedButton *button = g_object_new (ui_skinned_button_get_type (), NULL);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
323
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
324 return GTK_WIDGET(button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
325 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
326
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
327 void ui_skinned_push_button_setup(GtkWidget *button, GtkWidget *fixed, gint x, gint y, gint w, gint h, gint nx, gint ny, gint px, gint py, SkinPixmapId si) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
328
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
329 UiSkinnedButton *sbutton = UI_SKINNED_BUTTON(button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
330 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE(sbutton);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
331 priv->w = w;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
332 priv->h = h;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
333 sbutton->x = x;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
334 sbutton->y = y;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
335 priv->nx = nx;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
336 priv->ny = ny;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
337 priv->px = px;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
338 priv->py = py;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
339 sbutton->type = TYPE_PUSH;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
340 priv->skin_index1 = si;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
341 priv->skin_index2 = si;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
342 priv->scaled = FALSE;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
343
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
344 gtk_fixed_put(GTK_FIXED(fixed), GTK_WIDGET(button), sbutton->x, sbutton->y);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
345 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
346
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
347 void ui_skinned_toggle_button_setup(GtkWidget *button, GtkWidget *fixed, gint x, gint y, gint w, gint h, gint nx, gint ny, gint px, gint py, gint pnx, gint pny, gint ppx, gint ppy, SkinPixmapId si) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
348
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
349 UiSkinnedButton *sbutton = UI_SKINNED_BUTTON(button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
350 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE(sbutton);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
351 priv->w = w;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
352 priv->h = h;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
353 sbutton->x = x;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
354 sbutton->y = y;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
355 priv->nx = nx;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
356 priv->ny = ny;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
357 priv->px = px;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
358 priv->py = py;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
359 priv->pnx = pnx;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
360 priv->pny = pny;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
361 priv->ppx = ppx;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
362 priv->ppy = ppy;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
363 sbutton->type = TYPE_TOGGLE;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
364 priv->skin_index1 = si;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
365 priv->skin_index2 = si;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
366 priv->scaled = FALSE;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
367
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
368 gtk_fixed_put(GTK_FIXED(fixed), GTK_WIDGET(button), sbutton->x, sbutton->y);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
369 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
370
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
371 void ui_skinned_small_button_setup(GtkWidget *button, GtkWidget *fixed, gint x, gint y, gint w, gint h) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
372
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
373 UiSkinnedButton *sbutton = UI_SKINNED_BUTTON(button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
374 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE(sbutton);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
375 priv->w = w;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
376 priv->h = h;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
377 sbutton->x = x;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
378 sbutton->y = y;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
379 sbutton->type = TYPE_SMALL;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
380 priv->scaled = FALSE;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
381
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
382 gtk_fixed_put(GTK_FIXED(fixed), GTK_WIDGET(button), sbutton->x, sbutton->y);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
383 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
384
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
385 static void button_pressed(UiSkinnedButton *button) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
386 button->button_down = TRUE;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
387 ui_skinned_button_update_state(button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
388 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
389
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
390 static void button_released(UiSkinnedButton *button) {
2721
e75a38ffb384 small logic change
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
391 if(button->hover && button->button_down) ui_skinned_button_clicked(button);
2585
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
392 button->button_down = FALSE;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
393 ui_skinned_button_update_state(button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
394 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
395
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
396 static void ui_skinned_button_update_state(UiSkinnedButton *button) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
397 ui_skinned_button_set_pressed(button, button->button_down);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
398 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
399
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
400 static void ui_skinned_button_set_pressed (UiSkinnedButton *button, gboolean pressed) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
401 if (pressed != button->pressed) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
402 button->pressed = pressed;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
403 gtk_widget_queue_draw(GTK_WIDGET(button));
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
404 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
405 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
406
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
407 static gboolean ui_skinned_button_button_press(GtkWidget *widget, GdkEventButton *event) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
408 UiSkinnedButton *button;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
409
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
410 if (event->type == GDK_BUTTON_PRESS) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
411 button = UI_SKINNED_BUTTON(widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
412
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
413 if (event->button == 1)
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
414 ui_skinned_button_pressed (button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
415 else if (event->button == 3) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
416 event->x = event->x + button->x;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
417 event->y = event->y + button->y;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
418 return FALSE;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
419 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
420 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
421
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
422 return TRUE;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
423 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
424
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
425 static gboolean ui_skinned_button_button_release(GtkWidget *widget, GdkEventButton *event) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
426 UiSkinnedButton *button;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
427 if (event->button == 1) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
428 button = UI_SKINNED_BUTTON(widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
429 ui_skinned_button_released(button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
430 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
431 return TRUE;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
432 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
433
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
434 static void ui_skinned_button_pressed(UiSkinnedButton *button) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
435 g_return_if_fail(UI_SKINNED_IS_BUTTON(button));
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
436 g_signal_emit(button, button_signals[PRESSED], 0);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
437 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
438
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
439 static void ui_skinned_button_released(UiSkinnedButton *button) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
440 g_return_if_fail(UI_SKINNED_IS_BUTTON(button));
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
441 g_signal_emit(button, button_signals[RELEASED], 0);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
442 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
443
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
444 static void ui_skinned_button_clicked(UiSkinnedButton *button) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
445 g_return_if_fail(UI_SKINNED_IS_BUTTON(button));
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
446 button->inside = !button->inside;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
447 g_signal_emit(button, button_signals[CLICKED], 0);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
448 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
449
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
450 static gboolean ui_skinned_button_enter_notify(GtkWidget *widget, GdkEventCrossing *event) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
451 UiSkinnedButton *button;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
452
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
453 button = UI_SKINNED_BUTTON(widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
454 button->hover = TRUE;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
455 if(button->button_down) ui_skinned_button_set_pressed(button, TRUE);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
456
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
457 return FALSE;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
458 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
459
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
460 static gboolean ui_skinned_button_leave_notify(GtkWidget *widget, GdkEventCrossing *event) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
461 UiSkinnedButton *button;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
462
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
463 button = UI_SKINNED_BUTTON (widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
464 button->hover = FALSE;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
465 if(button->button_down) ui_skinned_button_set_pressed(button, FALSE);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
466
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
467 return FALSE;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
468 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
469
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
470 static void ui_skinned_button_toggle_scaled(UiSkinnedButton *button) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
471 GtkWidget *widget = GTK_WIDGET (button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
472 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
473 priv->scaled = !priv->scaled;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
474
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
475 gtk_widget_set_size_request(widget, priv->w*(priv->scaled ? config.scale_factor : 1), priv->h*(priv->scaled ? config.scale_factor : 1));
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
476
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
477 gtk_widget_queue_draw(widget);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
478 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
479
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
480 void ui_skinned_button_set_skin_index2(GtkWidget *button, SkinPixmapId si) {
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
481 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
482 priv->skin_index2 = si;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
483 }
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
484
2698
32e99af83a3e I don't think redraw signal is needed anymore
Tomasz Mon <desowin@gmail.com>
parents: 2668
diff changeset
485 void ui_skinned_button_move_relative(GtkWidget *widget, gint x, gint y) {
32e99af83a3e I don't think redraw signal is needed anymore
Tomasz Mon <desowin@gmail.com>
parents: 2668
diff changeset
486 UiSkinnedButton *button = UI_SKINNED_BUTTON(widget);
32e99af83a3e I don't think redraw signal is needed anymore
Tomasz Mon <desowin@gmail.com>
parents: 2668
diff changeset
487 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE(widget);
2585
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
488 priv->move_x += x;
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
489 priv->move_y += y;
2698
32e99af83a3e I don't think redraw signal is needed anymore
Tomasz Mon <desowin@gmail.com>
parents: 2668
diff changeset
490 gtk_fixed_move(GTK_FIXED(gtk_widget_get_parent(widget)), widget,
32e99af83a3e I don't think redraw signal is needed anymore
Tomasz Mon <desowin@gmail.com>
parents: 2668
diff changeset
491 button->x+priv->move_x, button->y+priv->move_y);
2585
43bac1471075 add ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
492 }
2668
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
493
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
494 void ui_skinned_button_set_inside(GtkWidget *widget, gboolean inside) {
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
495 g_return_if_fail(UI_SKINNED_IS_BUTTON(widget));
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
496
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
497 UiSkinnedButton *button = UI_SKINNED_BUTTON(widget);
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
498 button->inside = inside;
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
499 gtk_widget_queue_draw(widget);
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
500 }