diff src/audacious/ui_skinned_button.c @ 3006:3c4ed53a685f trunk

use ui_skinned_set_push_button_data instead accessing values directly
author Tomasz Mon <desowin@gmail.com>
date Sun, 08 Jul 2007 20:33:32 +0200
parents 3db40ad79fd9
children 6cb0f58e7e7d
line wrap: on
line diff
--- a/src/audacious/ui_skinned_button.c	Sun Jul 08 19:56:51 2007 +0200
+++ b/src/audacious/ui_skinned_button.c	Sun Jul 08 20:33:32 2007 +0200
@@ -40,16 +40,20 @@
 };
 
 struct _UiSkinnedButtonPrivate {
-        //Skinned part
-        GdkPixmap        *img;
-        GdkGC            *gc;
-        gint             w;
-        gint             h;
-        SkinPixmapId     skin_index1;
-        SkinPixmapId     skin_index2;
-        GtkWidget        *fixed;
-        gboolean         double_size;
-        gint             move_x, move_y;
+    //Skinned part
+    GdkPixmap        *img;
+    GdkGC            *gc;
+    gint             w;
+    gint             h;
+    SkinPixmapId     skin_index1;
+    SkinPixmapId     skin_index2;
+    GtkWidget        *fixed;
+    gboolean         double_size;
+    gint             move_x, move_y;
+
+    gint             nx, ny, px, py;
+    //Toogle button needs also those
+    gint             pnx, pny, ppx, ppy;
 };
 
 
@@ -230,8 +234,7 @@
     UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
     widget->allocation = *allocation;
     if (GTK_WIDGET_REALIZED (widget))
-        gdk_window_move_resize(widget->window, allocation->x, allocation->y, allocation->width, allocation->height);
-
+gdk_window_move_resize(widget->window, allocation->x*(1+priv->double_size), allocation->y*(1+priv->double_size), allocation->width, allocation->height);
     button->x = widget->allocation.x/(priv->double_size ? 2 : 1);
     button->y = widget->allocation.y/(priv->double_size ? 2 : 1);
     priv->move_x = 0;
@@ -261,22 +264,22 @@
         case TYPE_PUSH:
             skin_draw_pixmap(bmp_active_skin, obj, gc,
                              button->pressed ? priv->skin_index2 : priv->skin_index1,
-                             button->pressed ? button->px : button->nx,
-                             button->pressed ? button->py : button->ny,
+                             button->pressed ? priv->px : priv->nx,
+                             button->pressed ? priv->py : priv->ny,
                              0, 0, priv->w, priv->h);
             break;
         case TYPE_TOGGLE:
             if (button->inside)
                 skin_draw_pixmap(bmp_active_skin, obj, gc,
                                  button->pressed ? priv->skin_index2 : priv->skin_index1,
-                                 button->pressed ? button->ppx : button->pnx,
-                                 button->pressed ? button->ppy : button->pny,
+                                 button->pressed ? priv->ppx : priv->pnx,
+                                 button->pressed ? priv->ppy : priv->pny,
                                  0, 0, priv->w, priv->h);
             else
                 skin_draw_pixmap(bmp_active_skin, obj, gc,
                                  button->pressed ? priv->skin_index2 : priv->skin_index1,
-                                 button->pressed ? button->px : button->nx,
-                                 button->pressed ? button->py : button->ny,
+                                 button->pressed ? priv->px : priv->nx,
+                                 button->pressed ? priv->py : priv->ny,
                                  0, 0, priv->w, priv->h);
             break;
         default:
@@ -322,10 +325,10 @@
     priv->h = h;
     sbutton->x = x;
     sbutton->y = y;
-    sbutton->nx = nx;
-    sbutton->ny = ny;
-    sbutton->px = px;
-    sbutton->py = py;
+    priv->nx = nx;
+    priv->ny = ny;
+    priv->px = px;
+    priv->py = py;
     sbutton->type = TYPE_PUSH;
     priv->skin_index1 = si;
     priv->skin_index2 = si;
@@ -343,14 +346,14 @@
     priv->h = h;
     sbutton->x = x;
     sbutton->y = y;
-    sbutton->nx = nx;
-    sbutton->ny = ny;
-    sbutton->px = px;
-    sbutton->py = py;
-    sbutton->pnx = pnx;
-    sbutton->pny = pny;
-    sbutton->ppx = ppx;
-    sbutton->ppy = ppy;
+    priv->nx = nx;
+    priv->ny = ny;
+    priv->px = px;
+    priv->py = py;
+    priv->pnx = pnx;
+    priv->pny = pny;
+    priv->ppx = ppx;
+    priv->ppy = ppy;
     sbutton->type = TYPE_TOGGLE;
     priv->skin_index1 = si;
     priv->skin_index2 = si;
@@ -464,7 +467,7 @@
     priv->double_size = !priv->double_size;
 
     gtk_widget_set_size_request(widget, priv->w*(1+priv->double_size), priv->h*(1+priv->double_size));
-    gtk_widget_set_uposition(widget, button->x*(1+priv->double_size), button->y*(1+priv->double_size));
+    //gtk_widget_set_uposition(widget, button->x*(1+priv->double_size), button->y*(1+priv->double_size));
 
     gtk_widget_queue_draw(widget);
 }
@@ -481,11 +484,11 @@
 
 
 void ui_skinned_set_push_button_data(GtkWidget *button, gint nx, gint ny, gint px, gint py) {
-    UiSkinnedButton *b = UI_SKINNED_BUTTON(button);
-    if (nx > -1) b->nx = nx;
-    if (ny > -1) b->ny = ny;
-    if (px > -1) b->px = px;
-    if (py > -1) b->py = py;
+    UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE(button);
+    if (nx > -1) priv->nx = nx;
+    if (ny > -1) priv->ny = ny;
+    if (px > -1) priv->px = px;
+    if (py > -1) priv->py = py;
 }
 
 void ui_skinned_button_set_skin_index(GtkWidget *button, SkinPixmapId si) {