# HG changeset patch # User ib # Date 1394472749 0 # Node ID f50427ad9ff67ffab834383b0136fc3f75572ce0 # Parent c5ee0fc2ec75483d232288f840077f8a13cac05e 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. diff -r c5ee0fc2ec75 -r f50427ad9ff6 gui/skin/skin.c --- a/gui/skin/skin.c Mon Mar 10 17:15:24 2014 +0000 +++ b/gui/skin/skin.c Mon Mar 10 17:32:29 2014 +0000 @@ -79,7 +79,7 @@ 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_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 @@ } return 0; +*/ } /** @@ -1014,7 +1024,7 @@ { "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 }, diff -r c5ee0fc2ec75 -r f50427ad9ff6 gui/win32/gui.c --- a/gui/win32/gui.c Mon Mar 10 17:15:24 2014 +0000 +++ b/gui/win32/gui.c Mon Mar 10 17:32:29 2014 +0000 @@ -926,8 +926,17 @@ 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) { diff -r c5ee0fc2ec75 -r f50427ad9ff6 gui/win32/skinload.c --- a/gui/win32/skinload.c Mon Mar 10 17:15:24 2014 +0000 +++ b/gui/win32/skinload.c Mon Mar 10 17:32:29 2014 +0000 @@ -121,7 +121,7 @@ } 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 @@ (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; iy; - 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);