1653
|
1 /* BMP - Cross-platform multimedia player
|
|
2 * Copyright (C) 2003-2004 BMP development team.
|
|
3 *
|
|
4 * Based on XMMS:
|
|
5 * Copyright (C) 1998-2003 XMMS development team.
|
|
6 *
|
|
7 * This program is free software; you can redistribute it and/or modify
|
|
8 * it under the terms of the GNU General Public License as published by
|
|
9 * the Free Software Foundation; either version 2 of the License, or
|
|
10 * (at your option) any later version.
|
|
11 *
|
|
12 * This program is distributed in the hope that it will be useful,
|
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 * GNU General Public License for more details.
|
|
16 *
|
|
17 * You should have received a copy of the GNU General Public License
|
|
18 * along with this program; if not, write to the Free Software
|
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
20 */
|
|
21
|
|
22 #ifdef HAVE_CONFIG_H
|
|
23 # include "config.h"
|
|
24 #endif
|
|
25
|
|
26 /* TODO: enforce default sizes! */
|
|
27
|
|
28 #include <glib.h>
|
|
29 #include <stdio.h>
|
|
30 #include <stdlib.h>
|
|
31 #include <string.h>
|
|
32 #include <ctype.h>
|
|
33
|
|
34 #include "widgetcore.h"
|
|
35
|
|
36 #include "equalizer.h"
|
|
37 #include "main.h"
|
|
38 #include "ui_playlist.h"
|
|
39 #include "skinwin.h"
|
|
40 #include "util.h"
|
|
41
|
|
42 #include "debug.h"
|
|
43
|
|
44 #include "platform/smartinclude.h"
|
1670
|
45 #include "libaudacious/vfs.h"
|
1653
|
46
|
|
47 #define EXTENSION_TARGETS 7
|
|
48
|
|
49 static gchar *ext_targets[EXTENSION_TARGETS] = { "bmp", "xpm", "png", "svg",
|
|
50 "gif", "jpg", "jpeg" };
|
|
51
|
|
52 struct _SkinPixmapIdMapping {
|
|
53 SkinPixmapId id;
|
|
54 const gchar *name;
|
|
55 const gchar *alt_name;
|
|
56 gint width, height;
|
|
57 };
|
|
58
|
|
59 struct _SkinMaskInfo {
|
|
60 gint width, height;
|
|
61 gchar *inistr;
|
|
62 };
|
|
63
|
|
64 typedef struct _SkinPixmapIdMapping SkinPixmapIdMapping;
|
|
65 typedef struct _SkinMaskInfo SkinMaskInfo;
|
|
66
|
|
67
|
|
68 Skin *bmp_active_skin = NULL;
|
|
69
|
|
70 static gint skin_current_num;
|
|
71
|
|
72 static SkinMaskInfo skin_mask_info[] = {
|
|
73 {275, 116, "Normal"},
|
|
74 {275, 16, "WindowShade"},
|
|
75 {275, 116, "Equalizer"},
|
|
76 {275, 16, "EqualizerWS"}
|
|
77 };
|
|
78
|
|
79 static SkinPixmapIdMapping skin_pixmap_id_map[] = {
|
|
80 {SKIN_MAIN, "main", NULL, 0, 0},
|
|
81 {SKIN_CBUTTONS, "cbuttons", NULL, 0, 0},
|
|
82 {SKIN_SHUFREP, "shufrep", NULL, 0, 0},
|
|
83 {SKIN_TEXT, "text", NULL, 0, 0},
|
|
84 {SKIN_TITLEBAR, "titlebar", NULL, 0, 0},
|
|
85 {SKIN_VOLUME, "volume", NULL, 0, 0},
|
|
86 {SKIN_BALANCE, "balance", "volume", 0, 0},
|
|
87 {SKIN_MONOSTEREO, "monoster", NULL, 0, 0},
|
|
88 {SKIN_PLAYPAUSE, "playpaus", NULL, 0, 0},
|
|
89 {SKIN_NUMBERS, "nums_ex", "numbers", 0, 0},
|
|
90 {SKIN_POSBAR, "posbar", NULL, 0, 0},
|
|
91 {SKIN_EQMAIN, "eqmain", NULL, 0, 0},
|
|
92 {SKIN_PLEDIT, "pledit", NULL, 0, 0},
|
|
93 {SKIN_EQ_EX, "eq_ex", NULL, 0, 0}
|
|
94 };
|
|
95
|
|
96 static guint skin_pixmap_id_map_size = G_N_ELEMENTS(skin_pixmap_id_map);
|
|
97
|
|
98 static const guchar skin_default_viscolor[24][3] = {
|
|
99 {9, 34, 53},
|
|
100 {10, 18, 26},
|
|
101 {0, 54, 108},
|
|
102 {0, 58, 116},
|
|
103 {0, 62, 124},
|
|
104 {0, 66, 132},
|
|
105 {0, 70, 140},
|
|
106 {0, 74, 148},
|
|
107 {0, 78, 156},
|
|
108 {0, 82, 164},
|
|
109 {0, 86, 172},
|
|
110 {0, 92, 184},
|
|
111 {0, 98, 196},
|
|
112 {0, 104, 208},
|
|
113 {0, 110, 220},
|
|
114 {0, 116, 232},
|
|
115 {0, 122, 244},
|
|
116 {0, 128, 255},
|
|
117 {0, 128, 255},
|
|
118 {0, 104, 208},
|
|
119 {0, 80, 160},
|
|
120 {0, 56, 112},
|
|
121 {0, 32, 64},
|
|
122 {200, 200, 200}
|
|
123 };
|
|
124
|
|
125 static GdkBitmap *
|
|
126 skin_create_transparent_mask(const gchar *,
|
|
127 const gchar *,
|
|
128 const gchar *,
|
|
129 GdkWindow *,
|
|
130 gint, gint);
|
|
131
|
|
132 static void
|
|
133 skin_setup_masks(Skin * skin);
|
|
134
|
|
135 static void
|
|
136 skin_set_default_vis_color(Skin * skin);
|
|
137
|
|
138
|
|
139 void
|
|
140 skin_lock(Skin * skin)
|
|
141 {
|
|
142 g_mutex_lock(skin->lock);
|
|
143 }
|
|
144
|
|
145 void
|
|
146 skin_unlock(Skin * skin)
|
|
147 {
|
|
148 g_mutex_unlock(skin->lock);
|
|
149 }
|
|
150
|
|
151 gboolean
|
|
152 bmp_active_skin_reload(void)
|
|
153 {
|
|
154 return bmp_active_skin_load(bmp_active_skin->path);
|
|
155 }
|
|
156
|
|
157 gboolean
|
|
158 bmp_active_skin_load(const gchar * path)
|
|
159 {
|
|
160 g_return_val_if_fail(bmp_active_skin != NULL, FALSE);
|
|
161
|
|
162 memset(&bmp_active_skin->properties, 0, sizeof(SkinProperties));
|
|
163
|
|
164 if (!skin_load(bmp_active_skin, path))
|
|
165 return FALSE;
|
|
166
|
|
167 skin_setup_masks(bmp_active_skin);
|
|
168
|
|
169 if (cfg.playlist_transparent)
|
|
170 {
|
|
171 if (rootpix != NULL)
|
|
172 g_object_unref(rootpix);
|
|
173
|
|
174 rootpix = shade_pixmap(get_transparency_pixmap(), 0, 0, 0, 0, gdk_screen_width(), gdk_screen_height(),
|
|
175 skin_get_color(bmp_active_skin, SKIN_PLEDIT_NORMALBG));
|
|
176 }
|
|
177
|
|
178 draw_main_window(TRUE);
|
|
179 draw_playlist_window(TRUE);
|
|
180 draw_equalizer_window(TRUE);
|
|
181
|
|
182 vis_set_window(mainwin_vis, mainwin->window);
|
|
183 playlistwin_update_list();
|
|
184
|
|
185 return TRUE;
|
|
186 }
|
|
187
|
|
188 void
|
|
189 skin_pixmap_free(SkinPixmap * p)
|
|
190 {
|
|
191 g_return_if_fail(p != NULL);
|
|
192 g_return_if_fail(p->pixmap != NULL);
|
|
193
|
|
194 g_object_unref(p->pixmap);
|
|
195 p->pixmap = NULL;
|
|
196 }
|
|
197
|
|
198 Skin *
|
|
199 skin_new(void)
|
|
200 {
|
|
201 Skin *skin;
|
|
202 skin = g_new0(Skin, 1);
|
|
203 skin->lock = g_mutex_new();
|
|
204 return skin;
|
|
205 }
|
|
206
|
|
207 void
|
|
208 skin_free(Skin * skin)
|
|
209 {
|
|
210 gint i;
|
|
211
|
|
212 g_return_if_fail(skin != NULL);
|
|
213
|
|
214 skin_lock(skin);
|
|
215
|
|
216 for (i = 0; i < SKIN_PIXMAP_COUNT; i++)
|
|
217 skin_pixmap_free(&skin->pixmaps[i]);
|
|
218
|
|
219 for (i = 0; i < SKIN_PIXMAP_COUNT; i++) {
|
|
220 if (skin->masks[i])
|
|
221 g_object_unref(skin->masks[i]);
|
|
222
|
|
223 skin->masks[i] = NULL;
|
|
224 }
|
|
225
|
|
226 skin_set_default_vis_color(skin);
|
|
227 skin_unlock(skin);
|
|
228 }
|
|
229
|
|
230 void
|
|
231 skin_destroy(Skin * skin)
|
|
232 {
|
|
233 g_return_if_fail(skin != NULL);
|
|
234 skin_free(skin);
|
|
235 g_mutex_free(skin->lock);
|
|
236 g_free(skin);
|
|
237 }
|
|
238
|
|
239 const SkinPixmapIdMapping *
|
|
240 skin_pixmap_id_lookup(guint id)
|
|
241 {
|
|
242 guint i;
|
|
243
|
|
244 for (i = 0; i < skin_pixmap_id_map_size; i++) {
|
|
245 if (id == skin_pixmap_id_map[i].id) {
|
|
246 return &skin_pixmap_id_map[i];
|
|
247 }
|
|
248 }
|
|
249
|
|
250 return NULL;
|
|
251 }
|
|
252
|
|
253 const gchar *
|
|
254 skin_pixmap_id_to_name(SkinPixmapId id)
|
|
255 {
|
|
256 guint i;
|
|
257
|
|
258 for (i = 0; i < skin_pixmap_id_map_size; i++) {
|
|
259 if (id == skin_pixmap_id_map[i].id)
|
|
260 return skin_pixmap_id_map[i].name;
|
|
261 }
|
|
262 return NULL;
|
|
263 }
|
|
264
|
|
265 static void
|
|
266 skin_set_default_vis_color(Skin * skin)
|
|
267 {
|
|
268 memcpy(skin->vis_color, skin_default_viscolor,
|
|
269 sizeof(skin_default_viscolor));
|
|
270 }
|
|
271
|
|
272 /*
|
|
273 * I have rewritten this to take an array of possible targets,
|
|
274 * once we find a matching target we now return, instead of loop
|
|
275 * recursively. This allows for us to support many possible format
|
|
276 * targets for our skinning engine than just the original winamp
|
|
277 * formats.
|
|
278 *
|
|
279 * -- nenolod, 16 January 2006
|
|
280 */
|
|
281 gchar *
|
|
282 skin_pixmap_locate(const gchar * dirname, gchar ** basenames)
|
|
283 {
|
|
284 gchar *filename;
|
|
285 gint i;
|
|
286
|
|
287 for (i = 0; basenames[i]; i++)
|
|
288 if (!(filename = find_file_recursively(dirname, basenames[i])))
|
|
289 g_free(filename);
|
|
290 else
|
|
291 return filename;
|
|
292
|
|
293 /* can't find any targets -- sorry */
|
|
294 return NULL;
|
|
295 }
|
|
296
|
|
297 /* FIXME: this function is temporary. It will be removed when the skinning system
|
|
298 uses GdkPixbuf in place of GdkPixmap */
|
|
299
|
|
300 static GdkPixmap *
|
|
301 pixmap_new_from_file(const gchar * filename)
|
|
302 {
|
|
303 GdkPixbuf *pixbuf;
|
|
304 GdkPixmap *pixmap;
|
|
305 gint width, height;
|
|
306
|
|
307 if (!(pixbuf = gdk_pixbuf_new_from_file(filename, NULL)))
|
|
308 return NULL;
|
|
309
|
|
310 width = gdk_pixbuf_get_width(pixbuf);
|
|
311 height = gdk_pixbuf_get_height(pixbuf);
|
|
312
|
|
313 if (!(pixmap = gdk_pixmap_new(mainwin->window, width, height,
|
|
314 gdk_rgb_get_visual()->depth))) {
|
|
315 g_object_unref(pixbuf);
|
|
316 return NULL;
|
|
317 }
|
|
318
|
|
319 gdk_pixbuf_render_to_drawable(pixbuf, pixmap, mainwin_gc, 0, 0, 0, 0,
|
|
320 width, height, GDK_RGB_DITHER_MAX, 0, 0);
|
|
321 g_object_unref(pixbuf);
|
|
322
|
|
323 return pixmap;
|
|
324 }
|
|
325
|
|
326 static gboolean
|
|
327 skin_load_pixmap_id(Skin * skin, SkinPixmapId id, const gchar * path_p)
|
|
328 {
|
|
329 const gchar *path;
|
|
330 gchar *filename;
|
|
331 gint width, height;
|
|
332 const SkinPixmapIdMapping *pixmap_id_mapping;
|
|
333 GdkPixmap *gpm;
|
|
334 SkinPixmap *pm = NULL;
|
|
335 gchar *basenames[EXTENSION_TARGETS * 2 + 1]; /* alternate basenames */
|
|
336 gint i, y;
|
|
337
|
|
338 g_return_val_if_fail(skin != NULL, FALSE);
|
|
339 g_return_val_if_fail(id < SKIN_PIXMAP_COUNT, FALSE);
|
|
340
|
|
341 pixmap_id_mapping = skin_pixmap_id_lookup(id);
|
|
342 g_return_val_if_fail(pixmap_id_mapping != NULL, FALSE);
|
|
343
|
|
344 memset(&basenames, 0, sizeof(basenames));
|
|
345
|
|
346 for (i = 0, y = 0; i < EXTENSION_TARGETS; i++, y++)
|
|
347 {
|
|
348 basenames[y] = g_strdup_printf("%s.%s", pixmap_id_mapping->name,
|
|
349 ext_targets[i]);
|
|
350
|
|
351 if (pixmap_id_mapping->alt_name)
|
|
352 basenames[++y] = g_strdup_printf("%s.%s",
|
|
353 pixmap_id_mapping->alt_name, ext_targets[i]);
|
|
354 }
|
|
355
|
|
356 path = path_p ? path_p : skin->path;
|
|
357 filename = skin_pixmap_locate(path, basenames);
|
|
358
|
|
359 for (i = 0; basenames[i] != NULL; i++)
|
|
360 {
|
|
361 g_free(basenames[i]);
|
|
362 basenames[i] = NULL;
|
|
363 }
|
|
364
|
|
365 if (!(gpm = pixmap_new_from_file(filename))) {
|
|
366 g_warning("loading of %s failed", filename);
|
|
367 g_free(filename);
|
|
368 return FALSE;
|
|
369 }
|
|
370
|
|
371 g_free(filename);
|
|
372
|
|
373 gdk_drawable_get_size(GDK_DRAWABLE(gpm), &width, &height);
|
|
374 pm = &skin->pixmaps[id];
|
|
375 pm->pixmap = gpm;
|
|
376 pm->width = width;
|
|
377 pm->height = height;
|
|
378 pm->current_width = width;
|
|
379 pm->current_height = height;
|
|
380
|
|
381 return TRUE;
|
|
382 }
|
|
383
|
|
384 void
|
|
385 skin_mask_create(Skin * skin,
|
|
386 const gchar * path,
|
|
387 gint id,
|
|
388 GdkWindow * window)
|
|
389 {
|
|
390 skin->masks[id] =
|
|
391 skin_create_transparent_mask(path, "region.txt",
|
|
392 skin_mask_info[id].inistr, window,
|
|
393 skin_mask_info[id].width,
|
|
394 skin_mask_info[id].height);
|
|
395 }
|
|
396
|
|
397 static void
|
|
398 skin_setup_masks(Skin * skin)
|
|
399 {
|
|
400 GdkBitmap *mask;
|
|
401
|
|
402 if (cfg.show_wm_decorations)
|
|
403 return;
|
|
404
|
|
405 if (cfg.player_visible) {
|
|
406 mask = skin_get_mask(skin, SKIN_MASK_MAIN + cfg.player_shaded);
|
|
407 gtk_widget_shape_combine_mask(mainwin, mask, 0, 0);
|
|
408 }
|
|
409
|
|
410 mask = skin_get_mask(skin, SKIN_MASK_EQ + cfg.equalizer_shaded);
|
|
411 gtk_widget_shape_combine_mask(equalizerwin, mask, 0, 0);
|
|
412 }
|
|
413
|
|
414 static GdkBitmap *
|
|
415 create_default_mask(GdkWindow * parent, gint w, gint h)
|
|
416 {
|
|
417 GdkBitmap *ret;
|
|
418 GdkGC *gc;
|
|
419 GdkColor pattern;
|
|
420
|
|
421 ret = gdk_pixmap_new(parent, w, h, 1);
|
|
422 gc = gdk_gc_new(ret);
|
|
423 pattern.pixel = 1;
|
|
424 gdk_gc_set_foreground(gc, &pattern);
|
|
425 gdk_draw_rectangle(ret, gc, TRUE, 0, 0, w, h);
|
|
426 gdk_gc_destroy(gc);
|
|
427
|
|
428 return ret;
|
|
429 }
|
|
430
|
|
431 static void
|
|
432 skin_query_color(GdkColormap * cm, GdkColor * c)
|
|
433 {
|
|
434 #ifdef GDK_WINDOWING_X11
|
|
435 XColor xc = { 0,0,0,0,0,0 };
|
|
436
|
|
437 xc.pixel = c->pixel;
|
|
438 XQueryColor(GDK_COLORMAP_XDISPLAY(cm), GDK_COLORMAP_XCOLORMAP(cm), &xc);
|
|
439 c->red = xc.red;
|
|
440 c->green = xc.green;
|
|
441 c->blue = xc.blue;
|
|
442 #else
|
|
443 /* do nothing. see what breaks? */
|
|
444 #endif
|
|
445 }
|
|
446
|
|
447 static glong
|
|
448 skin_calc_luminance(GdkColor * c)
|
|
449 {
|
|
450 return (0.212671 * c->red + 0.715160 * c->green + 0.072169 * c->blue);
|
|
451 }
|
|
452
|
|
453 static void
|
|
454 skin_get_textcolors(GdkPixmap * text, GdkColor * bgc, GdkColor * fgc)
|
|
455 {
|
|
456 /*
|
|
457 * Try to extract reasonable background and foreground colors
|
|
458 * from the font pixmap
|
|
459 */
|
|
460
|
|
461 GdkImage *gi;
|
|
462 GdkColormap *cm;
|
|
463 gint i;
|
|
464
|
|
465 g_return_if_fail(text != NULL);
|
|
466
|
|
467 /* Get the first line of text */
|
|
468 gi = gdk_drawable_get_image(text, 0, 0, 152, 6);
|
|
469 cm = gdk_window_get_colormap(playlistwin->window);
|
|
470 g_return_if_fail(GDK_IS_WINDOW(playlistwin->window));
|
|
471
|
|
472 for (i = 0; i < 6; i++) {
|
|
473 GdkColor c;
|
|
474 gint x;
|
|
475 glong d, max_d;
|
|
476
|
|
477 /* Get a pixel from the middle of the space character */
|
|
478 bgc[i].pixel = gdk_image_get_pixel(gi, 151, i);
|
|
479 skin_query_color(cm, &bgc[i]);
|
|
480
|
|
481 max_d = 0;
|
|
482 for (x = 1; x < 150; x++) {
|
|
483 c.pixel = gdk_image_get_pixel(gi, x, i);
|
|
484 skin_query_color(cm, &c);
|
|
485
|
|
486 d = labs(skin_calc_luminance(&c) - skin_calc_luminance(&bgc[i]));
|
|
487 if (d > max_d) {
|
|
488 memcpy(&fgc[i], &c, sizeof(GdkColor));
|
|
489 max_d = d;
|
|
490 }
|
|
491 }
|
|
492 }
|
|
493 gdk_image_destroy(gi);
|
|
494 }
|
|
495
|
|
496 gboolean
|
|
497 init_skins(const gchar * path)
|
|
498 {
|
|
499 bmp_active_skin = skin_new();
|
|
500
|
|
501 if (!bmp_active_skin_load(path)) {
|
|
502 /* FIXME: Oddly, g_message() causes a crash if path is NULL on
|
|
503 * Solaris (see bug #165) */
|
|
504 if (path)
|
|
505 g_message("Unable to load skin (%s), trying default...", path);
|
|
506
|
|
507 /* can't load configured skin, retry with default */
|
|
508 if (!bmp_active_skin_load(BMP_DEFAULT_SKIN_PATH)) {
|
|
509 g_message("Unable to load default skin (%s)! Giving up.",
|
|
510 BMP_DEFAULT_SKIN_PATH);
|
|
511 return FALSE;
|
|
512 }
|
|
513 }
|
|
514
|
|
515 if (cfg.random_skin_on_play)
|
|
516 skinlist_update();
|
|
517
|
|
518 return TRUE;
|
|
519 }
|
|
520
|
|
521 /*
|
|
522 * Opens and parses a skin's hints file.
|
|
523 * Hints files are somewhat like "scripts" in Winamp3/5.
|
|
524 * We'll probably add scripts to it next.
|
|
525 */
|
|
526 void
|
|
527 skin_parse_hints(Skin * skin, gchar *path_p)
|
|
528 {
|
|
529 gchar *filename, *tmp;
|
|
530
|
|
531 path_p = path_p ? path_p : skin->path;
|
|
532
|
|
533 filename = find_file_recursively(path_p, "skin.hints");
|
|
534
|
|
535 if (filename == NULL)
|
|
536 return;
|
|
537
|
|
538 #if 0
|
|
539 skin->description = read_ini_string(filename, "skin", "skinDescription");
|
|
540 #endif
|
|
541
|
|
542 tmp = read_ini_string(filename, "skin", "mainwinOthertext");
|
|
543
|
|
544 if (tmp != NULL)
|
|
545 skin->properties.mainwin_othertext = atoi(tmp);
|
|
546 }
|
|
547
|
|
548 static guint
|
|
549 hex_chars_to_int(gchar hi, gchar lo)
|
|
550 {
|
|
551 /*
|
|
552 * Converts a value in the range 0x00-0xFF
|
|
553 * to a integer in the range 0-65535
|
|
554 */
|
|
555 gchar str[3];
|
|
556
|
|
557 str[0] = hi;
|
|
558 str[1] = lo;
|
|
559 str[2] = 0;
|
|
560
|
|
561 return (CLAMP(strtol(str, NULL, 16), 0, 0xFF) << 8);
|
|
562 }
|
|
563
|
|
564 GdkColor *
|
|
565 skin_load_color(const gchar * path, const gchar * file,
|
|
566 const gchar * section, const gchar * key,
|
|
567 gchar * default_hex)
|
|
568 {
|
|
569 gchar *filename, *value;
|
|
570 GdkColor *color = NULL;
|
|
571
|
|
572 filename = find_file_recursively(path, file);
|
|
573 if (filename || default_hex) {
|
|
574 if (filename) {
|
|
575 value = read_ini_string(filename, section, key);
|
|
576 if (value == NULL) {
|
|
577 value = g_strdup(default_hex);
|
|
578 }
|
|
579 } else {
|
|
580 value = g_strdup(default_hex);
|
|
581 }
|
|
582 if (value) {
|
|
583 gchar *ptr = value;
|
|
584 gint len;
|
|
585
|
|
586 color = g_new0(GdkColor, 1);
|
|
587 g_strstrip(value);
|
|
588
|
|
589 if (value[0] == '#')
|
|
590 ptr++;
|
|
591 len = strlen(ptr);
|
|
592 /*
|
|
593 * The handling of incomplete values is done this way
|
|
594 * to maximize winamp compatibility
|
|
595 */
|
|
596 if (len >= 6) {
|
|
597 color->red = hex_chars_to_int(*ptr, *(ptr + 1));
|
|
598 ptr += 2;
|
|
599 }
|
|
600 if (len >= 4) {
|
|
601 color->green = hex_chars_to_int(*ptr, *(ptr + 1));
|
|
602 ptr += 2;
|
|
603 }
|
|
604 if (len >= 2)
|
|
605 color->blue = hex_chars_to_int(*ptr, *(ptr + 1));
|
|
606
|
|
607 gdk_color_alloc(gdk_window_get_colormap(playlistwin->window),
|
|
608 color);
|
|
609 g_free(value);
|
|
610 }
|
|
611 if (filename)
|
|
612 g_free(filename);
|
|
613 }
|
|
614 return color;
|
|
615 }
|
|
616
|
|
617
|
|
618
|
|
619 GdkBitmap *
|
|
620 skin_create_transparent_mask(const gchar * path,
|
|
621 const gchar * file,
|
|
622 const gchar * section,
|
|
623 GdkWindow * window,
|
|
624 gint width,
|
|
625 gint height)
|
|
626 {
|
|
627 GdkBitmap *mask = NULL;
|
|
628 GdkGC *gc = NULL;
|
|
629 GdkColor pattern;
|
|
630 GdkPoint *gpoints;
|
|
631
|
|
632 gchar *filename = NULL;
|
|
633 gboolean created_mask = FALSE;
|
|
634 GArray *num, *point;
|
|
635 guint i, j;
|
|
636 gint k;
|
|
637
|
|
638 if (path)
|
|
639 filename = find_file_recursively(path, file);
|
|
640
|
|
641 /* filename will be null if path wasn't set */
|
|
642 if (!filename) {
|
|
643 return create_default_mask(window, width, height);
|
|
644 }
|
|
645
|
|
646 if ((num = read_ini_array(filename, section, "NumPoints")) == NULL) {
|
|
647 g_free(filename);
|
|
648 return NULL;
|
|
649 }
|
|
650
|
|
651 if ((point = read_ini_array(filename, section, "PointList")) == NULL) {
|
|
652 g_array_free(num, TRUE);
|
|
653 g_free(filename);
|
|
654 return NULL;
|
|
655 }
|
|
656
|
|
657 mask = gdk_pixmap_new(window, width, height, 1);
|
|
658 gc = gdk_gc_new(mask);
|
|
659
|
|
660 pattern.pixel = 0;
|
|
661 gdk_gc_set_foreground(gc, &pattern);
|
|
662 gdk_draw_rectangle(mask, gc, TRUE, 0, 0, width, height);
|
|
663 pattern.pixel = 1;
|
|
664 gdk_gc_set_foreground(gc, &pattern);
|
|
665
|
|
666 j = 0;
|
|
667 for (i = 0; i < num->len; i++) {
|
|
668 if ((int)(point->len - j) >= (g_array_index(num, gint, i) * 2)) {
|
|
669 created_mask = TRUE;
|
|
670 gpoints = g_new(GdkPoint, g_array_index(num, gint, i));
|
|
671 for (k = 0; k < g_array_index(num, gint, i); k++) {
|
|
672 gpoints[k].x = g_array_index(point, gint, j + k * 2);
|
|
673 gpoints[k].y = g_array_index(point, gint, j + k * 2 + 1);
|
|
674 }
|
|
675 j += k * 2;
|
|
676 gdk_draw_polygon(mask, gc, TRUE, gpoints,
|
|
677 g_array_index(num, gint, i));
|
|
678 g_free(gpoints);
|
|
679 }
|
|
680 }
|
|
681 g_array_free(num, TRUE);
|
|
682 g_array_free(point, TRUE);
|
|
683 g_free(filename);
|
|
684
|
|
685 if (!created_mask)
|
|
686 gdk_draw_rectangle(mask, gc, TRUE, 0, 0, width, height);
|
|
687
|
|
688 gdk_gc_destroy(gc);
|
|
689
|
|
690 return mask;
|
|
691 }
|
|
692
|
|
693 void
|
|
694 skin_load_viscolor(Skin * skin, const gchar * path, const gchar * basename)
|
|
695 {
|
1670
|
696 VFSFile *file;
|
1653
|
697 gint i, c;
|
|
698 gchar line[256], *filename;
|
|
699 GArray *a;
|
|
700
|
|
701 g_return_if_fail(skin != NULL);
|
|
702 g_return_if_fail(path != NULL);
|
|
703 g_return_if_fail(basename != NULL);
|
|
704
|
|
705 skin_set_default_vis_color(skin);
|
|
706
|
|
707 filename = find_file_recursively(path, basename);
|
|
708 if (!filename)
|
|
709 return;
|
|
710
|
1670
|
711 if (!(file = vfs_fopen(filename, "r"))) {
|
1653
|
712 g_free(filename);
|
|
713 return;
|
|
714 }
|
|
715
|
|
716 g_free(filename);
|
|
717
|
|
718 for (i = 0; i < 24; i++) {
|
1670
|
719 if (vfs_fgets(line, 255, file)) {
|
1653
|
720 a = string_to_garray(line);
|
|
721 if (a->len > 2) {
|
|
722 for (c = 0; c < 3; c++)
|
|
723 skin->vis_color[i][c] = g_array_index(a, gint, c);
|
|
724 }
|
|
725 g_array_free(a, TRUE);
|
|
726 }
|
|
727 else
|
|
728 break;
|
|
729 }
|
|
730
|
1670
|
731 vfs_fclose(file);
|
1653
|
732 }
|
|
733
|
|
734 #if 0
|
|
735 static void
|
|
736 skin_numbers_generate_dash(Skin * skin)
|
|
737 {
|
|
738 GdkGC *gc;
|
|
739 GdkPixmap *pixmap;
|
|
740 SkinPixmap *numbers;
|
|
741
|
|
742 g_return_if_fail(skin != NULL);
|
|
743
|
|
744 numbers = &skin->pixmaps[SKIN_NUMBERS];
|
|
745 if (!numbers->pixmap || numbers->current_width < 99)
|
|
746 return;
|
|
747
|
|
748 gc = gdk_gc_new(numbers->pixmap);
|
|
749 pixmap = gdk_pixmap_new(mainwin->window, 108,
|
|
750 numbers->current_height,
|
|
751 -1);
|
|
752
|
|
753 skin_draw_pixmap(skin, pixmap, gc, SKIN_NUMBERS, 0, 0, 0, 0, 99, 13);
|
|
754 skin_draw_pixmap(skin, pixmap, gc, SKIN_NUMBERS, 90, 0, 99, 0, 9, 13);
|
|
755 skin_draw_pixmap(skin, pixmap, gc, SKIN_NUMBERS, 20, 6, 101, 6, 5, 1);
|
|
756
|
|
757 g_object_unref(numbers->pixmap);
|
|
758 g_object_unref(gc);
|
|
759
|
|
760 numbers->pixmap = pixmap;
|
|
761 numbers->current_width = 108;
|
|
762 }
|
|
763 #endif
|
|
764
|
|
765 static void
|
|
766 skin_load_cursor(Skin * skin, const gchar * dirname)
|
|
767 {
|
|
768 const gchar * basename = "normal.cur";
|
|
769 gchar * filename = NULL;
|
|
770 GdkPixbuf * cursor_pixbuf = NULL;
|
|
771 GdkPixbufAnimation * cursor_animated = NULL;
|
|
772 GdkCursor * cursor_gdk = NULL;
|
|
773 GError * error = NULL;
|
|
774
|
|
775 filename = find_file_recursively(dirname, basename);
|
|
776
|
|
777 if (filename && cfg.custom_cursors) {
|
|
778 cursor_animated = gdk_pixbuf_animation_new_from_file(filename, &error);
|
|
779 cursor_pixbuf = gdk_pixbuf_animation_get_static_image(cursor_animated);
|
|
780 cursor_gdk = gdk_cursor_new_from_pixbuf(gdk_display_get_default(),
|
|
781 cursor_pixbuf, 0, 0);
|
|
782 } else {
|
|
783 cursor_gdk = gdk_cursor_new(GDK_LEFT_PTR);
|
|
784 }
|
|
785
|
|
786 gdk_window_set_cursor(mainwin->window, cursor_gdk);
|
|
787 gdk_window_set_cursor(playlistwin->window, cursor_gdk);
|
|
788 gdk_window_set_cursor(equalizerwin->window, cursor_gdk);
|
|
789 gdk_cursor_unref(cursor_gdk);
|
|
790 }
|
|
791
|
|
792 static void
|
|
793 skin_load_pixmaps(Skin * skin, const gchar * path)
|
|
794 {
|
|
795 GdkPixmap *text_pm;
|
|
796 guint i;
|
|
797
|
|
798 for (i = 0; i < SKIN_PIXMAP_COUNT; i++)
|
|
799 skin_load_pixmap_id(skin, i, path);
|
|
800
|
|
801 text_pm = skin->pixmaps[SKIN_TEXT].pixmap;
|
|
802
|
|
803 if (text_pm)
|
|
804 skin_get_textcolors(text_pm, skin->textbg, skin->textfg);
|
|
805
|
|
806 #if 0
|
|
807 if (skin->pixmaps[SKIN_NUMBERS].pixmap)
|
|
808 skin_numbers_generate_dash(skin);
|
|
809 #endif
|
|
810
|
|
811 skin->colors[SKIN_PLEDIT_NORMAL] =
|
|
812 skin_load_color(path, "pledit.txt", "text", "normal", "#2499ff");
|
|
813 skin->colors[SKIN_PLEDIT_CURRENT] =
|
|
814 skin_load_color(path, "pledit.txt", "text", "current", "#ffeeff");
|
|
815 skin->colors[SKIN_PLEDIT_NORMALBG] =
|
|
816 skin_load_color(path, "pledit.txt", "text", "normalbg", "#0a120a");
|
|
817 skin->colors[SKIN_PLEDIT_SELECTEDBG] =
|
|
818 skin_load_color(path, "pledit.txt", "text", "selectedbg", "#0a124a");
|
|
819
|
|
820 skin_mask_create(skin, path, SKIN_MASK_MAIN, mainwin->window);
|
|
821 skin_mask_create(skin, path, SKIN_MASK_MAIN_SHADE, mainwin->window);
|
|
822
|
|
823 skin_mask_create(skin, path, SKIN_MASK_EQ, equalizerwin->window);
|
|
824 skin_mask_create(skin, path, SKIN_MASK_EQ_SHADE, equalizerwin->window);
|
|
825
|
|
826 skin_load_viscolor(skin, path, "viscolor.txt");
|
|
827 }
|
|
828
|
|
829 static gboolean
|
|
830 skin_load_nolock(Skin * skin, const gchar * path, gboolean force)
|
|
831 {
|
|
832 gchar *cpath;
|
|
833
|
|
834 g_return_val_if_fail(skin != NULL, FALSE);
|
|
835 g_return_val_if_fail(path != NULL, FALSE);
|
|
836 REQUIRE_LOCK(skin->lock);
|
|
837
|
|
838 if (!g_file_test(path, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_DIR))
|
|
839 return FALSE;
|
|
840
|
|
841 if (!force) {
|
|
842 if (skin->path)
|
|
843 if (!strcmp(skin->path, path))
|
|
844 return FALSE;
|
|
845 }
|
|
846
|
|
847 skin_current_num++;
|
|
848
|
|
849 skin->path = g_strdup(path);
|
|
850
|
|
851 if (!file_is_archive(path)) {
|
|
852 skin_load_pixmaps(skin, path);
|
|
853 skin_load_cursor(skin, path);
|
|
854
|
|
855 /* Parse the hints for this skin. */
|
|
856 skin_parse_hints(skin, NULL);
|
|
857
|
|
858 return TRUE;
|
|
859 }
|
|
860
|
|
861 if (!(cpath = archive_decompress(path))) {
|
|
862 g_message("Unable to extract skin archive (%s)", path);
|
|
863 return FALSE;
|
|
864 }
|
|
865
|
|
866 skin_load_pixmaps(skin, cpath);
|
|
867 skin_load_cursor(skin, cpath);
|
|
868
|
|
869 /* Parse the hints for this skin. */
|
|
870 skin_parse_hints(skin, cpath);
|
|
871
|
|
872 del_directory(cpath);
|
|
873 g_free(cpath);
|
|
874
|
|
875 return TRUE;
|
|
876 }
|
|
877
|
|
878 void
|
|
879 skin_install_skin(const gchar * path)
|
|
880 {
|
|
881 gchar *command;
|
|
882
|
|
883 g_return_if_fail(path != NULL);
|
|
884
|
|
885 command = g_strdup_printf("cp %s %s", path, bmp_paths[BMP_PATH_USER_SKIN_DIR]);
|
|
886 if (system(command)) {
|
|
887 g_message("Unable to install skin (%s) into user directory (%s)",
|
|
888 path, bmp_paths[BMP_PATH_USER_SKIN_DIR]);
|
|
889 }
|
|
890 g_free(command);
|
|
891 }
|
|
892
|
|
893
|
|
894 gboolean
|
|
895 skin_load(Skin * skin, const gchar * path)
|
|
896 {
|
|
897 gboolean error;
|
|
898
|
|
899 g_return_val_if_fail(skin != NULL, FALSE);
|
|
900
|
|
901 if (!path)
|
|
902 return FALSE;
|
|
903
|
|
904 skin_lock(skin);
|
|
905 error = skin_load_nolock(skin, path, FALSE);
|
|
906 skin_unlock(skin);
|
|
907
|
|
908 return error;
|
|
909 }
|
|
910
|
|
911 gboolean
|
|
912 skin_reload_forced(void)
|
|
913 {
|
|
914 gboolean error;
|
|
915
|
|
916 skin_lock(bmp_active_skin);
|
|
917 error = skin_load_nolock(bmp_active_skin, bmp_active_skin->path, TRUE);
|
|
918 skin_unlock(bmp_active_skin);
|
|
919
|
|
920 return error;
|
|
921 }
|
|
922
|
|
923 void
|
|
924 skin_reload(Skin * skin)
|
|
925 {
|
|
926 g_return_if_fail(skin != NULL);
|
|
927 skin_load_nolock(skin, skin->path, TRUE);
|
|
928 }
|
|
929
|
|
930
|
|
931 static SkinPixmap *
|
|
932 skin_get_pixmap(Skin * skin, SkinPixmapId map_id)
|
|
933 {
|
|
934 g_return_val_if_fail(skin != NULL, NULL);
|
|
935 g_return_val_if_fail(map_id < SKIN_PIXMAP_COUNT, NULL);
|
|
936
|
|
937 return &skin->pixmaps[map_id];
|
|
938 }
|
|
939
|
|
940 GdkBitmap *
|
|
941 skin_get_mask(Skin * skin, SkinMaskId mi)
|
|
942 {
|
|
943 g_return_val_if_fail(skin != NULL, NULL);
|
|
944 g_return_val_if_fail(mi < SKIN_PIXMAP_COUNT, NULL);
|
|
945
|
|
946 return skin->masks[mi];
|
|
947 }
|
|
948
|
|
949 GdkColor *
|
|
950 skin_get_color(Skin * skin, SkinColorId color_id)
|
|
951 {
|
|
952 GdkColor *ret = NULL;
|
|
953
|
|
954 g_return_val_if_fail(skin != NULL, NULL);
|
|
955
|
|
956 switch (color_id) {
|
|
957 case SKIN_TEXTBG:
|
|
958 if (skin->pixmaps[SKIN_TEXT].pixmap)
|
|
959 ret = skin->textbg;
|
|
960 else
|
|
961 ret = skin->def_textbg;
|
|
962 break;
|
|
963 case SKIN_TEXTFG:
|
|
964 if (skin->pixmaps[SKIN_TEXT].pixmap)
|
|
965 ret = skin->textfg;
|
|
966 else
|
|
967 ret = skin->def_textfg;
|
|
968 break;
|
|
969 default:
|
|
970 if (color_id < SKIN_COLOR_COUNT)
|
|
971 ret = skin->colors[color_id];
|
|
972 break;
|
|
973 }
|
|
974 return ret;
|
|
975 }
|
|
976
|
|
977 void
|
|
978 skin_get_viscolor(Skin * skin, guchar vis_color[24][3])
|
|
979 {
|
|
980 gint i;
|
|
981
|
|
982 g_return_if_fail(skin != NULL);
|
|
983
|
|
984 for (i = 0; i < 24; i++) {
|
|
985 vis_color[i][0] = skin->vis_color[i][0];
|
|
986 vis_color[i][1] = skin->vis_color[i][1];
|
|
987 vis_color[i][2] = skin->vis_color[i][2];
|
|
988 }
|
|
989 }
|
|
990
|
|
991 gint
|
|
992 skin_get_id(void)
|
|
993 {
|
|
994 return skin_current_num;
|
|
995 }
|
|
996
|
|
997 void
|
|
998 skin_draw_pixmap(Skin * skin, GdkDrawable * drawable, GdkGC * gc,
|
|
999 SkinPixmapId pixmap_id,
|
|
1000 gint xsrc, gint ysrc, gint xdest, gint ydest,
|
|
1001 gint width, gint height)
|
|
1002 {
|
|
1003 SkinPixmap *pixmap;
|
|
1004
|
|
1005 g_return_if_fail(skin != NULL);
|
|
1006
|
|
1007 pixmap = skin_get_pixmap(skin, pixmap_id);
|
|
1008 g_return_if_fail(pixmap != NULL);
|
|
1009 g_return_if_fail(pixmap->pixmap != NULL);
|
|
1010
|
|
1011 if (xsrc > pixmap->width || ysrc > pixmap->height)
|
|
1012 return;
|
|
1013
|
|
1014 width = MIN(width, pixmap->width - xsrc);
|
|
1015 height = MIN(height, pixmap->height - ysrc);
|
|
1016 gdk_draw_pixmap(drawable, gc, pixmap->pixmap, xsrc, ysrc,
|
|
1017 xdest, ydest, width, height);
|
|
1018 }
|
|
1019
|
|
1020 void
|
|
1021 skin_get_eq_spline_colors(Skin * skin, guint32 colors[19])
|
|
1022 {
|
|
1023 gint i;
|
|
1024 GdkPixmap *pixmap;
|
|
1025 GdkImage *img;
|
|
1026 SkinPixmap *eqmainpm;
|
|
1027
|
|
1028 g_return_if_fail(skin != NULL);
|
|
1029
|
|
1030 eqmainpm = &skin->pixmaps[SKIN_EQMAIN];
|
|
1031 if (eqmainpm->pixmap &&
|
|
1032 eqmainpm->current_width >= 116 && eqmainpm->current_height >= 313)
|
|
1033 pixmap = eqmainpm->pixmap;
|
|
1034 else
|
|
1035 return;
|
|
1036
|
|
1037 if (!GDK_IS_DRAWABLE(pixmap))
|
|
1038 return;
|
|
1039
|
|
1040 if (!(img = gdk_drawable_get_image(pixmap, 115, 294, 1, 19)))
|
|
1041 return;
|
|
1042
|
|
1043 for (i = 0; i < 19; i++)
|
|
1044 colors[i] = gdk_image_get_pixel(img, 0, i);
|
|
1045
|
|
1046 gdk_image_destroy(img);
|
|
1047 }
|
|
1048
|
|
1049
|
|
1050 static void
|
|
1051 skin_draw_playlistwin_frame_top(Skin * skin,
|
|
1052 GdkDrawable * drawable,
|
|
1053 GdkGC * gc,
|
|
1054 gint width, gint height, gboolean focus)
|
|
1055 {
|
|
1056 /* The title bar skin consists of 2 sets of 4 images, 1 set
|
|
1057 * for focused state and the other for unfocused. The 4 images
|
|
1058 * are:
|
|
1059 *
|
|
1060 * a. right corner (25,20)
|
|
1061 * b. left corner (25,20)
|
|
1062 * c. tiler (25,20)
|
|
1063 * d. title (100,20)
|
|
1064 *
|
|
1065 * min allowed width = 100+25+25 = 150
|
|
1066 */
|
|
1067
|
|
1068 gint i, y, c;
|
|
1069
|
|
1070 /* get y offset of the pixmap set to use */
|
|
1071 if (focus)
|
|
1072 y = 0;
|
|
1073 else
|
|
1074 y = 21;
|
|
1075
|
|
1076 /* left corner */
|
|
1077 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 0, y, 0, 0, 25, 20);
|
|
1078
|
|
1079 /* titlebar title */
|
|
1080 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 26, y,
|
|
1081 (width - 100) / 2, 0, 100, 20);
|
|
1082
|
|
1083 /* titlebar right corner */
|
|
1084 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 153, y,
|
|
1085 width - 25, 0, 25, 20);
|
|
1086
|
|
1087 /* tile draw the remaining frame */
|
|
1088
|
|
1089 /* compute tile count */
|
|
1090 c = (width - (100 + 25 + 25)) / 25;
|
|
1091
|
|
1092 for (i = 0; i < c / 2; i++) {
|
|
1093 /* left of title */
|
|
1094 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 127, y,
|
|
1095 25 + i * 25, 0, 25, 20);
|
|
1096
|
|
1097 /* right of title */
|
|
1098 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 127, y,
|
|
1099 (width + 100) / 2 + i * 25, 0, 25, 20);
|
|
1100 }
|
|
1101
|
|
1102 if (c & 1) {
|
|
1103 /* Odd tile count, so one remaining to draw. Here we split
|
|
1104 * it into two and draw half on either side of the title */
|
|
1105 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 127, y,
|
|
1106 ((c / 2) * 25) + 25, 0, 12, 20);
|
|
1107 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 127, y,
|
|
1108 (width / 2) + ((c / 2) * 25) + 50, 0, 13, 20);
|
|
1109 }
|
|
1110 }
|
|
1111
|
|
1112 static void
|
|
1113 skin_draw_playlistwin_frame_bottom(Skin * skin,
|
|
1114 GdkDrawable * drawable,
|
|
1115 GdkGC * gc,
|
|
1116 gint width, gint height, gboolean focus)
|
|
1117 {
|
|
1118 /* The bottom frame skin consists of 1 set of 4 images. The 4
|
|
1119 * images are:
|
|
1120 *
|
|
1121 * a. left corner with menu buttons (125,38)
|
|
1122 * b. visualization window (75,38)
|
|
1123 * c. right corner with play buttons (150,38)
|
|
1124 * d. frame tile (25,38)
|
|
1125 *
|
|
1126 * (min allowed width = 125+150+25=300
|
|
1127 */
|
|
1128
|
|
1129 gint i, c;
|
|
1130
|
|
1131 /* bottom left corner (menu buttons) */
|
|
1132 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 0, 72,
|
|
1133 0, height - 38, 125, 38);
|
|
1134
|
|
1135 c = (width - 275) / 25;
|
|
1136
|
|
1137 /* draw visualization window, if width allows */
|
|
1138 if (c >= 3) {
|
|
1139 c -= 3;
|
|
1140 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 205, 0,
|
|
1141 width - (150 + 75), height - 38, 75, 38);
|
|
1142 }
|
|
1143
|
|
1144 /* Bottom right corner (playbuttons etc) */
|
|
1145 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT,
|
|
1146 126, 72, width - 150, height - 38, 150, 38);
|
|
1147
|
|
1148 /* Tile draw the remaining undrawn portions */
|
|
1149 for (i = 0; i < c; i++)
|
|
1150 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 179, 0,
|
|
1151 125 + i * 25, height - 38, 25, 38);
|
|
1152 }
|
|
1153
|
|
1154 static void
|
|
1155 skin_draw_playlistwin_frame_sides(Skin * skin,
|
|
1156 GdkDrawable * drawable,
|
|
1157 GdkGC * gc,
|
|
1158 gint width, gint height, gboolean focus)
|
|
1159 {
|
|
1160 /* The side frames consist of 2 tile images. 1 for the left, 1 for
|
|
1161 * the right.
|
|
1162 * a. left (12,29)
|
|
1163 * b. right (19,29)
|
|
1164 */
|
|
1165
|
|
1166 gint i;
|
|
1167
|
|
1168 /* frame sides */
|
|
1169 for (i = 0; i < (height - (20 + 38)) / 29; i++) {
|
|
1170 /* left */
|
|
1171 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 0, 42,
|
|
1172 0, 20 + i * 29, 12, 29);
|
|
1173
|
|
1174 /* right */
|
|
1175 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 32, 42,
|
|
1176 width - 19, 20 + i * 29, 19, 29);
|
|
1177 }
|
|
1178 }
|
|
1179
|
|
1180
|
|
1181 void
|
|
1182 skin_draw_playlistwin_frame(Skin * skin,
|
|
1183 GdkDrawable * drawable, GdkGC * gc,
|
|
1184 gint width, gint height, gboolean focus)
|
|
1185 {
|
|
1186 skin_draw_playlistwin_frame_top(skin, drawable, gc, width, height, focus);
|
|
1187 skin_draw_playlistwin_frame_bottom(skin, drawable, gc, width, height,
|
|
1188 focus);
|
|
1189 skin_draw_playlistwin_frame_sides(skin, drawable, gc, width, height,
|
|
1190 focus);
|
|
1191 }
|
|
1192
|
|
1193
|
|
1194 void
|
|
1195 skin_draw_playlistwin_shaded(Skin * skin,
|
|
1196 GdkDrawable * drawable, GdkGC * gc,
|
|
1197 gint width, gboolean focus)
|
|
1198 {
|
|
1199 /* The shade mode titlebar skin consists of 4 images:
|
|
1200 * a) left corner offset (72,42) size (25,14)
|
|
1201 * b) right corner, focused offset (99,57) size (50,14)
|
|
1202 * c) right corner, unfocused offset (99,42) size (50,14)
|
|
1203 * d) bar tile offset (72,57) size (25,14)
|
|
1204 */
|
|
1205
|
|
1206 gint i;
|
|
1207
|
|
1208 /* left corner */
|
|
1209 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 72, 42, 0, 0, 25, 14);
|
|
1210
|
|
1211 /* bar tile */
|
|
1212 for (i = 0; i < (width - 75) / 25; i++)
|
|
1213 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 72, 57,
|
|
1214 (i * 25) + 25, 0, 25, 14);
|
|
1215
|
|
1216 /* right corner */
|
|
1217 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 99, focus ? 57 : 42,
|
|
1218 width - 50, 0, 50, 14);
|
|
1219 }
|
|
1220
|
|
1221
|
|
1222 void
|
|
1223 skin_draw_mainwin_titlebar(Skin * skin,
|
|
1224 GdkDrawable * drawable, GdkGC * gc,
|
|
1225 gboolean shaded, gboolean focus)
|
|
1226 {
|
|
1227 /* The titlebar skin consists of 2 sets of 2 images, one for for
|
|
1228 * shaded and the other for unshaded mode, giving a total of 4.
|
|
1229 * The images are exactly 275x14 pixels, aligned and arranged
|
|
1230 * vertically on each other in the pixmap in the following order:
|
|
1231 *
|
|
1232 * a) unshaded, focused offset (27, 0)
|
|
1233 * b) unshaded, unfocused offset (27, 15)
|
|
1234 * c) shaded, focused offset (27, 29)
|
|
1235 * d) shaded, unfocused offset (27, 42)
|
|
1236 */
|
|
1237
|
|
1238 gint y_offset;
|
|
1239
|
|
1240 if (shaded) {
|
|
1241 if (focus)
|
|
1242 y_offset = 29;
|
|
1243 else
|
|
1244 y_offset = 42;
|
|
1245 }
|
|
1246 else {
|
|
1247 if (focus)
|
|
1248 y_offset = 0;
|
|
1249 else
|
|
1250 y_offset = 15;
|
|
1251 }
|
|
1252
|
|
1253 skin_draw_pixmap(skin, drawable, gc, SKIN_TITLEBAR, 27, y_offset,
|
|
1254 0, 0, MAINWIN_WIDTH, MAINWIN_TITLEBAR_HEIGHT);
|
|
1255 }
|