[MPlayer-cvslog] r36988 - in trunk/gui: skin/skin.c win32/gui.c win32/skinload.c win32/widgetrender.c

ib subversion at mplayerhq.hu
Mon Mar 10 18:32:29 CET 2014


Author: ib
Date: Mon Mar 10 18:32:29 2014
New Revision: 36988

Log:
Internally map item 'potmeter' onto 'hpotmeter'.

Former version of the GUI treated a potmeter very similar to a hpotmeter
(the Win32 GUI still does so) and lots of skins are solely using
potmeters instead of hpotmeters, although this doesn't make sense at
all.

The current version of the GUI is treating a potmeter differently, but
in order to not break old skins, restore the old behaviour.

For the X11/GTK GUI, a potmeter is now simply a hpotmeter with
button=NULL and (button)width=(button)height=0. For the Win32 GUI
(where skins unfortunately are handled a bit differently and things
are more complicated) a potmeter is now a hpotmeter without button
but (button)width=(widget)width and (button)height=(widget)height.

Additionally, print a legacy information, because the item 'potmeter' is
obsolete now and oughtn't be used any longer.

Modified:
   trunk/gui/skin/skin.c
   trunk/gui/win32/gui.c
   trunk/gui/win32/skinload.c
   trunk/gui/win32/widgetrender.c

Modified: trunk/gui/skin/skin.c
==============================================================================
--- trunk/gui/skin/skin.c	Mon Mar 10 18:15:24 2014	(r36987)
+++ trunk/gui/skin/skin.c	Mon Mar 10 18:32:29 2014	(r36988)
@@ -79,7 +79,7 @@ static void skin_legacy(const char *old,
             mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, "$p");
     } else if (strcmp(old, "evSetURL") == 0 && strcmp(data, old) == 0)
         mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, "evLoadURL");
-    else if (strcmp(old, "sub") == 0)
+    else if (strcmp(old, "sub") == 0 || strcmp(old, "potmeter") == 0)
         mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, data);
 }
 
@@ -719,6 +719,15 @@ static int item_vpotmeter(char *in)
  */
 static int item_potmeter(char *in)
 {
+    char param[256];
+
+    // legacy
+    skin_legacy("potmeter", "hpotmeter");
+
+    snprintf(param, sizeof(param), "NULL,0,0,%s", in);
+
+    return item_hpotmeter(param);
+/*
     unsigned char phfname[256];
     unsigned char buf[512];
     int ph, d, x, y, w, h, message;
@@ -782,6 +791,7 @@ static int item_potmeter(char *in)
     }
 
     return 0;
+*/
 }
 
 /**
@@ -1014,7 +1024,7 @@ static _item skinItem[] = {
     { "font",       item_font       },
     { "hpotmeter",  item_hpotmeter  },
     { "menu",       item_menu       },
-    { "potmeter",   item_potmeter   },
+    { "potmeter",   item_potmeter   }, // legacy
     { "section",    item_section    },
     { "selected",   item_selected   },
     { "slabel",     item_slabel     },

Modified: trunk/gui/win32/gui.c
==============================================================================
--- trunk/gui/win32/gui.c	Mon Mar 10 18:15:24 2014	(r36987)
+++ trunk/gui/win32/gui.c	Mon Mar 10 18:32:29 2014	(r36988)
@@ -926,8 +926,17 @@ static LRESULT CALLBACK EventProc(HWND h
 
                     if(item->type == tyHpotmeter)
                     {
+                        int wd = item->wwidth - item->width;
+
+                        if (wd == 0)   // legacy (potmeter)
+                        {
+                            item->x = GET_X_LPARAM(lParam);
+                            wd = item->wwidth;
+                        }
+                        else
                         item->x = GET_X_LPARAM(lParam) - gui->mousewx;
-                        item->value = ((item->x - item->wx) * 100.0f) / (float)(item->wwidth - item->width);
+
+                        item->value = ((item->x - item->wx) * 100.0f) / (float) wd;
                     }
                     if(item->type == tyPotmeter)
                     {

Modified: trunk/gui/win32/skinload.c
==============================================================================
--- trunk/gui/win32/skinload.c	Mon Mar 10 18:15:24 2014	(r36987)
+++ trunk/gui/win32/skinload.c	Mon Mar 10 18:32:29 2014	(r36988)
@@ -121,7 +121,7 @@ static void skin_legacy (const char *old
     }
     else if (strcmp(old, "evSetURL") == 0 && strcmp(data, old) == 0)
         mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, "evLoadURL");
-    else if (strcmp(old, "sub") == 0)
+    else if (strcmp(old, "sub") == 0 || strcmp(old, "potmeter") == 0)
         mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, data);
 }
 
@@ -364,23 +364,34 @@ static void addwidget(skin_t *skin, wind
               (mywidget->bitmap[0]) ? mywidget->bitmap[0]->name : NULL,
                mywidget->x, mywidget->y, mywidget->width, mywidget->height, mywidget->msg);
     }
-    else if(!strncmp(desc, "hpotmeter", 9) || !strncmp(desc, "vpotmeter", 9))
+    else if(!strncmp(desc, "hpotmeter", 9) || !strncmp(desc, "vpotmeter", 9) || /* legacy */ !strncmp(desc, "potmeter", 8))
     {
         int base = counttonextchar(desc, '=') + 1;
-        int i;
+        int i = 0;
         /* hpotmeter = button, bwidth, bheight, phases, numphases, default, X, Y, width, height, message */
-        if(!strncmp(desc, "hpotmeter", 9)) mywidget->type = tyHpotmeter;
-        else mywidget->type = tyVpotmeter;
-        mywidget->bitmap[0] = pngRead(skin, findnextstring(temp, desc, &base));
+        if(!strncmp(desc, "vpotmeter", 9)) mywidget->type = tyVpotmeter;
+        else mywidget->type = tyHpotmeter;
+        if (*desc != 'p')
+        {
+        mywidget->bitmap[i++] = pngRead(skin, findnextstring(temp, desc, &base));
         mywidget->width = atoi(findnextstring(temp, desc, &base));
         mywidget->height = atoi(findnextstring(temp, desc, &base));
-        mywidget->bitmap[1] = pngRead(skin, findnextstring(temp, desc, &base));
+        }
+        mywidget->bitmap[i] = pngRead(skin, findnextstring(temp, desc, &base));
         mywidget->phases = atoi(findnextstring(temp, desc, &base));
         mywidget->value = atof(findnextstring(temp, desc, &base));
         mywidget->x = mywidget->wx = atoi(findnextstring(temp, desc, &base));
         mywidget->y = mywidget->wy = atoi(findnextstring(temp, desc, &base));
         mywidget->wwidth = atoi(findnextstring(temp, desc, &base));
         mywidget->wheight = atoi(findnextstring(temp, desc, &base));
+        if (*desc == 'p')
+        {
+            // legacy
+            skin_legacy("potmeter", "hpotmeter");
+
+            mywidget->width = mywidget->wwidth;
+            mywidget->height = mywidget->wheight;
+        }
         findnextstring(temp, desc, &base);
         mywidget->msg = evNone;
         for (i=0; i<evBoxs; i++)

Modified: trunk/gui/win32/widgetrender.c
==============================================================================
--- trunk/gui/win32/widgetrender.c	Mon Mar 10 18:15:24 2014	(r36987)
+++ trunk/gui/win32/widgetrender.c	Mon Mar 10 18:32:29 2014	(r36988)
@@ -310,7 +310,7 @@ void renderwidget(skin_t *skin, image *d
     if(!img) return;
 
     y = item->y;
-    if(item->type == tyPotmeter)
+    if(/* item->type == tyPotmeter */ /* legacy (potmeter) */ item->type == tyHpotmeter && item->width == item->wwidth)
     {
         height = img->height / item->phases;
         y =  height * (int)(item->value * item->phases / 100);


More information about the MPlayer-cvslog mailing list