Mercurial > audlegacy
comparison audacious/playlist_list.c @ 1048:b10e09537428 trunk
[svn] - self-caching transparency generator (right now we have a blend constant of 60%)
author | nenolod |
---|---|
date | Sun, 14 May 2006 16:05:32 -0700 |
parents | 91f6db060a8b |
children | 3131795a78c4 |
comparison
equal
deleted
inserted
replaced
1047:91f6db060a8b | 1048:b10e09537428 |
---|---|
1 /* BMP - Cross-platform multimedia player | 1 /* Audacious - Cross-platform multimedia player |
2 * Copyright (C) 2005-2006 Audacious development team. | |
3 * | |
4 * BMP - Cross-platform multimedia player | |
2 * Copyright (C) 2003-2004 BMP development team. | 5 * Copyright (C) 2003-2004 BMP development team. |
3 * | 6 * |
4 * Based on XMMS: | 7 * Based on XMMS: |
5 * Copyright (C) 1998-2003 XMMS development team. | 8 * Copyright (C) 1998-2003 XMMS development team. |
6 * | 9 * |
55 /* FIXME: the following globals should not be needed. */ | 58 /* FIXME: the following globals should not be needed. */ |
56 static gint width_approx_letters; | 59 static gint width_approx_letters; |
57 static gint width_colon, width_colon_third; | 60 static gint width_colon, width_colon_third; |
58 static gint width_approx_digits, width_approx_digits_half; | 61 static gint width_approx_digits, width_approx_digits_half; |
59 | 62 |
63 GdkPixmap *rootpix; | |
64 | |
65 /* Sort of stolen from XChat, but not really, as theres uses Xlib */ | |
66 static void | |
67 shade_gdkimage_generic (GdkVisual *visual, GdkImage *ximg, int bpl, int w, int h, int rm, int gm, int bm, int bg) | |
68 { | |
69 int x, y; | |
70 int bgr = (256 - rm) * (bg & visual->red_mask); | |
71 int bgg = (256 - gm) * (bg & visual->green_mask); | |
72 int bgb = (256 - bm) * (bg & visual->blue_mask); | |
73 | |
74 for (x = 0; x < w; x++) | |
75 { | |
76 for (y = 0; y < h; y++) | |
77 { | |
78 unsigned long pixel = gdk_image_get_pixel (ximg, x, y); | |
79 int r, g, b; | |
80 | |
81 r = rm * (pixel & visual->red_mask) + bgr; | |
82 g = gm * (pixel & visual->green_mask) + bgg; | |
83 b = bm * (pixel & visual->blue_mask) + bgb; | |
84 | |
85 gdk_image_put_pixel (ximg, x, y, | |
86 ((r >> 8) & visual->red_mask) | | |
87 ((g >> 8) & visual->green_mask) | | |
88 ((b >> 8) & visual->blue_mask)); | |
89 } | |
90 } | |
91 } | |
92 | |
93 /* and this is definately mine... -nenolod */ | |
94 GdkPixmap * | |
95 shade_pixmap(GdkPixmap *in, gint x, gint y, gint x_offset, gint y_offset, gint w, gint h, GdkColor *shade_color) | |
96 { | |
97 GdkImage *ximg; | |
98 GdkPixmap *p = gdk_pixmap_new(in, w, h, -1); | |
99 GdkGC *gc = gdk_gc_new(p); | |
100 | |
101 gdk_draw_pixmap(p, gc, in, x, y, 0, 0, w, h); | |
102 | |
103 ximg = gdk_drawable_copy_to_image(in, NULL, x, y, 0, 0, w, h); /* copy */ | |
104 | |
105 shade_gdkimage_generic(gdk_drawable_get_visual(GDK_WINDOW(playlistwin->window)), | |
106 ximg, ximg->bpl, w, h, 60, 60, 60, shade_color->pixel); | |
107 | |
108 gdk_draw_image(p, gc, ximg, 0, 0, x, y, w, h); | |
109 | |
110 g_object_unref(gc); | |
111 | |
112 return p; | |
113 } | |
114 | |
60 #ifdef GDK_WINDOWING_X11 | 115 #ifdef GDK_WINDOWING_X11 |
61 | 116 |
62 #include <gdk/gdkx.h> | 117 #include <gdk/gdkx.h> |
63 #include <X11/Xlib.h> | 118 #include <X11/Xlib.h> |
64 #include <X11/Xatom.h> | 119 #include <X11/Xatom.h> |
84 if(type == XA_PIXMAP) | 139 if(type == XA_PIXMAP) |
85 retval = gdk_pixmap_foreign_new(*((Pixmap *)data)); | 140 retval = gdk_pixmap_foreign_new(*((Pixmap *)data)); |
86 | 141 |
87 return retval; | 142 return retval; |
88 } | 143 } |
144 | |
89 | 145 |
90 #else | 146 #else |
91 | 147 |
92 static GdkPixmap *get_transparency_pixmap(void) | 148 static GdkPixmap *get_transparency_pixmap(void) |
93 { | 149 { |
439 gdk_draw_rectangle(obj, gc, TRUE, pl->pl_widget.x, pl->pl_widget.y, | 495 gdk_draw_rectangle(obj, gc, TRUE, pl->pl_widget.x, pl->pl_widget.y, |
440 width, height); | 496 width, height); |
441 } | 497 } |
442 else | 498 else |
443 { | 499 { |
444 GdkPixmap *rootpix = get_transparency_pixmap(); | 500 if (!rootpix) |
501 rootpix = shade_pixmap(get_transparency_pixmap(), 0, 0, 0, 0, gdk_screen_width(), gdk_screen_height(), | |
502 skin_get_color(bmp_active_skin, SKIN_PLEDIT_NORMALBG)); | |
445 gdk_draw_pixmap(obj, gc, rootpix, cfg.playlist_x + pl->pl_widget.x, | 503 gdk_draw_pixmap(obj, gc, rootpix, cfg.playlist_x + pl->pl_widget.x, |
446 cfg.playlist_y + pl->pl_widget.y, pl->pl_widget.x, pl->pl_widget.y, | 504 cfg.playlist_y + pl->pl_widget.y, pl->pl_widget.x, pl->pl_widget.y, |
447 width, height); | 505 width, height); |
448 } | 506 } |
449 | 507 |