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