comparison src/skins/ui_skin.c @ 2859:312ba23cbb87

transform UiSkinnedButton into windowless widget
author Tomasz Mon <desowin@gmail.com>
date Sun, 03 Aug 2008 14:11:02 +0200
parents 51fc44b99b58
children 3134a0987162
comparison
equal deleted inserted replaced
2858:528d19a2ea3d 2859:312ba23cbb87
1747 /* it's better to hide widget using SKIN_PLAYPAUSE/SKIN_POSBAR than display mess */ 1747 /* it's better to hide widget using SKIN_PLAYPAUSE/SKIN_POSBAR than display mess */
1748 if ((pixmap_id == SKIN_PLAYPAUSE && pixmap->width != 42) || pixmap_id == SKIN_POSBAR) { 1748 if ((pixmap_id == SKIN_PLAYPAUSE && pixmap->width != 42) || pixmap_id == SKIN_POSBAR) {
1749 gtk_widget_hide(widget); 1749 gtk_widget_hide(widget);
1750 return; 1750 return;
1751 } 1751 }
1752 gint x, y; 1752
1753 x = -1; 1753 /* Some skins include SKIN_VOLUME and/or SKIN_BALANCE without knobs */
1754 y = -1; 1754 if (pixmap_id == SKIN_VOLUME || pixmap_id == SKIN_BALANCE) {
1755 1755 if (ysrc+height > 421 && xsrc+width <= pixmap->width)
1756 if (gtk_widget_get_parent(widget) == SKINNED_WINDOW(mainwin)->normal) { 1756 return;
1757 GList *iter; 1757 }
1758 for (iter = GTK_FIXED (SKINNED_WINDOW(mainwin)->normal)->children; iter; iter = g_list_next (iter)) { 1758
1759 GtkFixedChild *child_data = (GtkFixedChild *) iter->data; 1759 /* XMMS skins seems to have SKIN_MONOSTEREO with size 58x20 instead of 58x24 */
1760 if (child_data->widget == widget) { 1760 if (pixmap_id == SKIN_MONOSTEREO)
1761 x = child_data->x; 1761 height = pixmap->height/2;
1762 y = child_data->y; 1762
1763 break; 1763 if (gtk_widget_get_parent(widget) == SKINNED_WINDOW(equalizerwin)->normal) {
1764 } 1764 if (!(pixmap_id == SKIN_EQMAIN && ysrc == 314)) /* equalizer preamp on equalizer graph */
1765 } 1765 gtk_widget_hide(widget);
1766 1766 }
1767 if (x != -1 && y != -1) { 1767
1768 /* Some skins include SKIN_VOLUME and/or SKIN_BALANCE 1768 if (gtk_widget_get_parent(widget) == SKINNED_WINDOW(playlistwin)->normal) {
1769 without knobs */ 1769 /* I haven't seen any skin with substandard playlist */
1770 if (pixmap_id == SKIN_VOLUME || pixmap_id == SKIN_BALANCE) { 1770 gtk_widget_hide(widget);
1771 if (ysrc+height > 421 && xsrc+width <= pixmap->width)
1772 return;
1773 }
1774 /* let's copy what's under widget */
1775 gdk_pixbuf_copy_area(skin_get_pixmap(aud_active_skin, SKIN_MAIN)->pixbuf,
1776 x, y, width, height, pix, xdest, ydest);
1777
1778 /* XMMS skins seems to have SKIN_MONOSTEREO with size 58x20 instead of 58x24 */
1779 if (pixmap_id == SKIN_MONOSTEREO)
1780 height = pixmap->height/2;
1781 }
1782 } else if (gtk_widget_get_parent(widget) == SKINNED_WINDOW(equalizerwin)->normal) {
1783 if (!(pixmap_id == SKIN_EQMAIN && ysrc == 314)) /* equalizer preamp on equalizer graph */
1784 gtk_widget_hide(widget);
1785 } else if (gtk_widget_get_parent(widget) == SKINNED_WINDOW(playlistwin)->normal) {
1786 /* I haven't seen any skin with substandard playlist */
1787 gtk_widget_hide(widget);
1788 } 1771 }
1789 } else 1772 } else
1790 return; 1773 return;
1791 } 1774 }
1792 1775
2037 randval = g_random_int_range(0, g_list_length(skinlist)); 2020 randval = g_random_int_range(0, g_list_length(skinlist));
2038 node = g_list_nth(skinlist, randval)->data; 2021 node = g_list_nth(skinlist, randval)->data;
2039 aud_active_skin_load(node->path); 2022 aud_active_skin_load(node->path);
2040 } 2023 }
2041 2024
2042 2025 void ui_skinned_widget_draw_with_coordinates(GtkWidget *widget, GdkPixbuf *obj, gint width, gint height, gint destx, gint desty, gboolean scale) {
2043 void ui_skinned_widget_draw(GtkWidget *widget, GdkPixbuf *obj, gint width, gint height, gboolean scale) {
2044 g_return_if_fail(widget != NULL); 2026 g_return_if_fail(widget != NULL);
2045 g_return_if_fail(obj != NULL); 2027 g_return_if_fail(obj != NULL);
2046 2028
2047 if (scale) { 2029 if (scale) {
2048 GdkPixbuf *image = gdk_pixbuf_scale_simple(obj, width * config.scale_factor, height* config.scale_factor, GDK_INTERP_NEAREST); 2030 GdkPixbuf *image = gdk_pixbuf_scale_simple(obj, width * config.scale_factor, height* config.scale_factor, GDK_INTERP_NEAREST);
2049 gdk_draw_pixbuf(widget->window, NULL, image, 0, 0, 0, 0, width * config.scale_factor , height * config.scale_factor, GDK_RGB_DITHER_NONE, 0, 0); 2031 gdk_draw_pixbuf(widget->window, NULL, image, 0, 0, destx, desty, width * config.scale_factor , height * config.scale_factor, GDK_RGB_DITHER_NONE, 0, 0);
2050 g_object_unref(image); 2032 g_object_unref(image);
2051 } else { 2033 } else {
2052 gdk_draw_pixbuf(widget->window, NULL, obj, 0, 0, 0, 0, width, height, GDK_RGB_DITHER_NONE, 0, 0); 2034 gdk_draw_pixbuf(widget->window, NULL, obj, 0, 0, destx, desty, width, height, GDK_RGB_DITHER_NONE, 0, 0);
2053 } 2035 }
2054 } 2036 }
2037
2038 void ui_skinned_widget_draw(GtkWidget *widget, GdkPixbuf *obj, gint width, gint height, gboolean scale) {
2039 ui_skinned_widget_draw_with_coordinates(widget, obj, width, height, 0, 0, scale);
2040 }