Mercurial > mplayer.hg
comparison gui/win32/skinload.c @ 37053:84c93a60ead3
Add new item 'rpotmeter'.
This is the missing counterpart to hpotmeter and vpotmeter
allowing rotary control elements in a GUI skin now.
Based on an idea and a realization by Hans-Dieter Kosch,
hdkosch kabelbw de.
Additionally, update (and revise) documentation.
author | ib |
---|---|
date | Sat, 12 Apr 2014 23:29:29 +0000 |
parents | e2c10942873b |
children | b28b632efeef |
comparison
equal
deleted
inserted
replaced
37052:2ef6693131f7 | 37053:84c93a60ead3 |
---|---|
23 | 23 |
24 #include <string.h> | 24 #include <string.h> |
25 #include <stdlib.h> | 25 #include <stdlib.h> |
26 #include <stdio.h> | 26 #include <stdio.h> |
27 #include <inttypes.h> | 27 #include <inttypes.h> |
28 #include <math.h> | |
28 #include <windows.h> | 29 #include <windows.h> |
29 | 30 |
30 #include "mp_msg.h" | 31 #include "mp_msg.h" |
31 #include "help_mp.h" | 32 #include "help_mp.h" |
32 #include "cpudetect.h" | 33 #include "cpudetect.h" |
33 #include "libswscale/swscale.h" | 34 #include "libswscale/swscale.h" |
35 #include "libavutil/attributes.h" | |
36 #include "libavutil/common.h" | |
34 #include "libavutil/imgutils.h" | 37 #include "libavutil/imgutils.h" |
35 #include "gui.h" | 38 #include "gui.h" |
36 #include "gui/util/mem.h" | 39 #include "gui/util/mem.h" |
37 #include "gui/util/bitmap.h" | 40 #include "gui/util/bitmap.h" |
38 | 41 |
362 | 365 |
363 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[SKIN] [ITEM] [BUTTON] %s %i %i %i %i msg %i\n", | 366 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[SKIN] [ITEM] [BUTTON] %s %i %i %i %i msg %i\n", |
364 (mywidget->bitmap[0]) ? mywidget->bitmap[0]->name : NULL, | 367 (mywidget->bitmap[0]) ? mywidget->bitmap[0]->name : NULL, |
365 mywidget->x, mywidget->y, mywidget->width, mywidget->height, mywidget->msg); | 368 mywidget->x, mywidget->y, mywidget->width, mywidget->height, mywidget->msg); |
366 } | 369 } |
367 else if(!strncmp(desc, "hpotmeter", 9) || !strncmp(desc, "vpotmeter", 9) || /* legacy */ !strncmp(desc, "potmeter", 8)) | 370 else if(!strncmp(desc, "hpotmeter", 9) || !strncmp(desc, "vpotmeter", 9) || !strncmp(desc, "rpotmeter", 9) || /* legacy */ !strncmp(desc, "potmeter", 8)) |
368 { | 371 { |
369 int base = counttonextchar(desc, '=') + 1; | 372 int base = counttonextchar(desc, '=') + 1; |
370 int i; | 373 int i, av_uninit(x0), av_uninit(y0), av_uninit(x1), av_uninit(y1); |
371 /* hpotmeter = button, bwidth, bheight, phases, numphases, default, X, Y, width, height, message */ | 374 /* hpotmeter = button, bwidth, bheight, phases, numphases, default, X, Y, width, height, message */ |
372 if(!strncmp(desc, "vpotmeter", 9)) mywidget->type = tyVpotmeter; | 375 if(!strncmp(desc, "vpotmeter", 9)) mywidget->type = tyVpotmeter; |
376 else if(!strncmp(desc, "rpotmeter", 9)) mywidget->type = tyRpotmeter; | |
373 else mywidget->type = tyHpotmeter; | 377 else mywidget->type = tyHpotmeter; |
374 if (*desc == 'p') | 378 if (*desc == 'p') |
375 { | 379 { |
376 mywidget->bitmap[0] = NULL; | 380 mywidget->bitmap[0] = NULL; |
377 mywidget->width = 0; | 381 mywidget->width = 0; |
386 mywidget->width = atoi(findnextstring(temp, desc, &base)); | 390 mywidget->width = atoi(findnextstring(temp, desc, &base)); |
387 mywidget->height = atoi(findnextstring(temp, desc, &base)); | 391 mywidget->height = atoi(findnextstring(temp, desc, &base)); |
388 } | 392 } |
389 mywidget->bitmap[1] = pngRead(skin, findnextstring(temp, desc, &base)); | 393 mywidget->bitmap[1] = pngRead(skin, findnextstring(temp, desc, &base)); |
390 mywidget->phases = atoi(findnextstring(temp, desc, &base)); | 394 mywidget->phases = atoi(findnextstring(temp, desc, &base)); |
395 | |
396 if (*desc == 'r') | |
397 { | |
398 x0 = atoi(findnextstring(temp, desc, &base)); | |
399 y0 = atoi(findnextstring(temp, desc, &base)); | |
400 x1 = atoi(findnextstring(temp, desc, &base)); | |
401 y1 = atoi(findnextstring(temp, desc, &base)); | |
402 } | |
403 | |
391 mywidget->value = atof(findnextstring(temp, desc, &base)); | 404 mywidget->value = atof(findnextstring(temp, desc, &base)); |
392 mywidget->x = mywidget->wx = atoi(findnextstring(temp, desc, &base)); | 405 mywidget->x = mywidget->wx = atoi(findnextstring(temp, desc, &base)); |
393 mywidget->y = mywidget->wy = atoi(findnextstring(temp, desc, &base)); | 406 mywidget->y = mywidget->wy = atoi(findnextstring(temp, desc, &base)); |
394 mywidget->wwidth = atoi(findnextstring(temp, desc, &base)); | 407 mywidget->wwidth = atoi(findnextstring(temp, desc, &base)); |
395 mywidget->wheight = atoi(findnextstring(temp, desc, &base)); | 408 mywidget->wheight = atoi(findnextstring(temp, desc, &base)); |
404 | 417 |
405 mywidget->msg = evNames[i].msg; | 418 mywidget->msg = evNames[i].msg; |
406 break; | 419 break; |
407 } | 420 } |
408 } | 421 } |
409 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[SKIN] [ITEM] %s %s %i %i %s %i %f %i %i %i %i msg %i\n", | 422 if (*desc == 'r') |
410 (mywidget->type == tyHpotmeter) ? "[HPOTMETER]" : "[VPOTMETER]", | 423 { |
424 mywidget->zeropoint = appRadian(mywidget, x0, y0); | |
425 mywidget->arclength = appRadian(mywidget, x1, y1) - mywidget->zeropoint; | |
426 | |
427 if (mywidget->arclength < 0.0) mywidget->arclength += 2 * M_PI; | |
428 // else check if radians of (x0,y0) and (x1,y1) only differ below threshold | |
429 else if (mywidget->arclength < 0.05) mywidget->arclength = 2 * M_PI; | |
430 } | |
431 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[SKIN] [ITEM] %s %s %i %i %s %i ", | |
432 (mywidget->type == tyHpotmeter) ? "[HPOTMETER]" : (mywidget->type == tyVpotmeter) ? "[VPOTMETER]" : "[RPOTMETER]", | |
411 (mywidget->bitmap[0]) ? mywidget->bitmap[0]->name : NULL, | 433 (mywidget->bitmap[0]) ? mywidget->bitmap[0]->name : NULL, |
412 mywidget->width, mywidget->height, | 434 mywidget->width, mywidget->height, |
413 (mywidget->bitmap[1]) ? mywidget->bitmap[1]->name : NULL, | 435 (mywidget->bitmap[1]) ? mywidget->bitmap[1]->name : NULL, |
414 mywidget->phases, mywidget->value, | 436 mywidget->phases); |
437 if (*desc == 'r') | |
438 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "%i,%i %i,%i ", x0, y0, x1, y1); | |
439 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "%f %i %i %i %i msg %i\n", mywidget->value, | |
415 mywidget->wx, mywidget->wy, mywidget->wwidth, mywidget->wwidth, | 440 mywidget->wx, mywidget->wy, mywidget->wwidth, mywidget->wwidth, |
416 mywidget->msg); | 441 mywidget->msg); |
417 if (mywidget->bitmap[0] == NULL || mywidget->width == 0 || mywidget->height == 0) | 442 if (mywidget->bitmap[0] == NULL || mywidget->width == 0 || mywidget->height == 0) |
418 { | 443 { |
419 mywidget->bitmap[0] = mywidget->bitmap[1]; | 444 mywidget->bitmap[0] = mywidget->bitmap[1]; |
445 mywidget->width = mywidget->wwidth; | |
446 mywidget->height = mywidget->wheight; | |
447 } | |
448 if (*desc == 'r') | |
449 { | |
450 mywidget->maxwh = FFMAX(mywidget->width, mywidget->height); | |
451 | |
452 // clickedinsidewidget() checks with width/height, so set it | |
420 mywidget->width = mywidget->wwidth; | 453 mywidget->width = mywidget->wwidth; |
421 mywidget->height = mywidget->wheight; | 454 mywidget->height = mywidget->wheight; |
422 } | 455 } |
423 } | 456 } |
424 else if(!strncmp(desc, "pimage", 6)) | 457 else if(!strncmp(desc, "pimage", 6)) |