comparison gui/skin/skin.c @ 32937:3c57056637cc

Cosmetic: Rename listItems structure. To reflect the importance of the listItems structure and the fact that it holds almost all information concerning the GUI, it is renamed 'guiItems' now. Additionally, the listItems pointer used to collect the items defined in the skin file is renamed 'skin' now. That way, the intended purpose should be more obvious and the code in skin.c is a lot easier to read.
author ib
date Fri, 04 Mar 2011 12:50:21 +0000
parents 258baf2bfeca
children 27a98940e3aa
comparison
equal deleted inserted replaced
32936:919edf74d9e4 32937:3c57056637cc
33 typedef struct { 33 typedef struct {
34 const char *name; 34 const char *name;
35 int (*func)(char *in); 35 int (*func)(char *in);
36 } _item; 36 } _item;
37 37
38 static listItems *defList; 38 static guiItems *skin;
39 39
40 static int linenumber; 40 static int linenumber;
41 static unsigned char path[512]; 41 static unsigned char path[512];
42 static unsigned char window_name[32]; 42 static unsigned char window_name[32];
43 43
63 } 63 }
64 } 64 }
65 65
66 #define CHECKDEFLIST(str) \ 66 #define CHECKDEFLIST(str) \
67 { \ 67 { \
68 if (defList == NULL) \ 68 if (skin == NULL) \
69 { \ 69 { \
70 ERRORMESSAGE(MSGTR_SKIN_ERROR_SECTION, str); \ 70 ERRORMESSAGE(MSGTR_SKIN_ERROR_SECTION, str); \
71 return 1; \ 71 return 1; \
72 } \ 72 } \
73 } 73 }
147 147
148 // section=movieplayer 148 // section=movieplayer
149 static int cmd_section(char *in) 149 static int cmd_section(char *in)
150 { 150 {
151 strlower(in); 151 strlower(in);
152 defList = NULL; 152 skin = NULL;
153 153
154 if (!strcmp(in, "movieplayer")) 154 if (!strcmp(in, "movieplayer"))
155 defList = &appMPlayer; 155 skin = &appMPlayer;
156 156
157 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] sectionname: %s\n", in); 157 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] sectionname: %s\n", in);
158 158
159 return 0; 159 return 0;
160 } 160 }
168 window_name[0] = 0; 168 window_name[0] = 0;
169 currSection = NULL; 169 currSection = NULL;
170 currSubItem = NULL; 170 currSubItem = NULL;
171 currSubItems = NULL; 171 currSubItems = NULL;
172 } else 172 } else
173 defList = NULL; 173 skin = NULL;
174 174
175 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] end section\n"); 175 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] end section\n");
176 176
177 return 0; 177 return 0;
178 } 178 }
224 sy = cutItemToInt(in, ',', 4); 224 sy = cutItemToInt(in, ',', 4);
225 225
226 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] base: %s x: %d y: %d ( %dx%d )\n", fname, x, y, sx, sy); 226 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] base: %s x: %d y: %d ( %dx%d )\n", fname, x, y, sx, sy);
227 227
228 if (!strcmp(window_name, "main")) { 228 if (!strcmp(window_name, "main")) {
229 defList->main.x = x; 229 skin->main.x = x;
230 defList->main.y = y; 230 skin->main.y = y;
231 defList->main.type = itBase; 231 skin->main.type = itBase;
232 232
233 av_strlcpy(tmp, path, sizeof(tmp)); 233 av_strlcpy(tmp, path, sizeof(tmp));
234 av_strlcat(tmp, fname, sizeof(tmp)); 234 av_strlcat(tmp, fname, sizeof(tmp));
235 235
236 if (skinBPRead(tmp, &defList->main.Bitmap) != 0) 236 if (skinBPRead(tmp, &skin->main.Bitmap) != 0)
237 return 1; 237 return 1;
238 238
239 defList->main.width = defList->main.Bitmap.Width; 239 skin->main.width = skin->main.Bitmap.Width;
240 defList->main.height = defList->main.Bitmap.Height; 240 skin->main.height = skin->main.Bitmap.Height;
241 241
242 #ifdef CONFIG_XSHAPE 242 #ifdef CONFIG_XSHAPE
243 Convert32to1(&defList->main.Bitmap, &defList->main.Mask, 0x00ff00ff); 243 Convert32to1(&skin->main.Bitmap, &skin->main.Mask, 0x00ff00ff);
244 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", defList->main.Mask.Width, defList->main.Mask.Height); 244 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", skin->main.Mask.Width, skin->main.Mask.Height);
245 #else 245 #else
246 defList->main.Mask.Image = NULL; 246 skin->main.Mask.Image = NULL;
247 #endif 247 #endif
248 248
249 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d height: %d\n", defList->main.width, defList->main.height); 249 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d height: %d\n", skin->main.width, skin->main.height);
250 } 250 }
251 251
252 if (!strcmp(window_name, "sub")) { 252 if (!strcmp(window_name, "sub")) {
253 defList->sub.type = itBase; 253 skin->sub.type = itBase;
254 254
255 av_strlcpy(tmp, path, sizeof(tmp)); 255 av_strlcpy(tmp, path, sizeof(tmp));
256 av_strlcat(tmp, fname, sizeof(tmp)); 256 av_strlcat(tmp, fname, sizeof(tmp));
257 257
258 if (skinBPRead(tmp, &defList->sub.Bitmap) != 0) 258 if (skinBPRead(tmp, &skin->sub.Bitmap) != 0)
259 return 1; 259 return 1;
260 260
261 defList->sub.x = x; 261 skin->sub.x = x;
262 defList->sub.y = y; 262 skin->sub.y = y;
263 defList->sub.width = defList->sub.Bitmap.Width; 263 skin->sub.width = skin->sub.Bitmap.Width;
264 defList->sub.height = defList->sub.Bitmap.Height; 264 skin->sub.height = skin->sub.Bitmap.Height;
265 265
266 if (sx && sy) { 266 if (sx && sy) {
267 defList->sub.width = sx; 267 skin->sub.width = sx;
268 defList->sub.height = sy; 268 skin->sub.height = sy;
269 } 269 }
270 270
271 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %d,%d %dx%d\n", defList->sub.x, defList->sub.y, defList->sub.width, defList->sub.height); 271 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %d,%d %dx%d\n", skin->sub.x, skin->sub.y, skin->sub.width, skin->sub.height);
272 } 272 }
273 273
274 if (!strcmp(window_name, "menu")) { 274 if (!strcmp(window_name, "menu")) {
275 defList->menuIsPresent = 1; 275 skin->menuIsPresent = 1;
276 defList->menuBase.type = itBase; 276 skin->menuBase.type = itBase;
277 277
278 av_strlcpy(tmp, path, sizeof(tmp)); 278 av_strlcpy(tmp, path, sizeof(tmp));
279 av_strlcat(tmp, fname, sizeof(tmp)); 279 av_strlcat(tmp, fname, sizeof(tmp));
280 280
281 if (skinBPRead(tmp, &defList->menuBase.Bitmap) != 0) 281 if (skinBPRead(tmp, &skin->menuBase.Bitmap) != 0)
282 return 1; 282 return 1;
283 283
284 defList->menuBase.width = defList->menuBase.Bitmap.Width; 284 skin->menuBase.width = skin->menuBase.Bitmap.Width;
285 defList->menuBase.height = defList->menuBase.Bitmap.Height; 285 skin->menuBase.height = skin->menuBase.Bitmap.Height;
286 286
287 #ifdef CONFIG_XSHAPE 287 #ifdef CONFIG_XSHAPE
288 Convert32to1(&defList->menuBase.Bitmap, &defList->menuBase.Mask, 0x00ff00ff); 288 Convert32to1(&skin->menuBase.Bitmap, &skin->menuBase.Mask, 0x00ff00ff);
289 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", defList->menuBase.Mask.Width, defList->menuBase.Mask.Height); 289 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", skin->menuBase.Mask.Width, skin->menuBase.Mask.Height);
290 #else 290 #else
291 defList->menuBase.Mask.Image = NULL; 291 skin->menuBase.Mask.Image = NULL;
292 #endif 292 #endif
293 293
294 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d height: %d\n", defList->menuBase.width, defList->menuBase.height); 294 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d height: %d\n", skin->menuBase.width, skin->menuBase.height);
295 } 295 }
296 296
297 if (!strcmp(window_name, "playbar")) { 297 if (!strcmp(window_name, "playbar")) {
298 defList->barIsPresent = 1; 298 skin->barIsPresent = 1;
299 defList->bar.x = x; 299 skin->bar.x = x;
300 defList->bar.y = y; 300 skin->bar.y = y;
301 defList->bar.type = itBase; 301 skin->bar.type = itBase;
302 302
303 av_strlcpy(tmp, path, sizeof(tmp)); 303 av_strlcpy(tmp, path, sizeof(tmp));
304 av_strlcat(tmp, fname, sizeof(tmp)); 304 av_strlcat(tmp, fname, sizeof(tmp));
305 305
306 if (skinBPRead(tmp, &defList->bar.Bitmap) != 0) 306 if (skinBPRead(tmp, &skin->bar.Bitmap) != 0)
307 return 1; 307 return 1;
308 308
309 defList->bar.width = defList->bar.Bitmap.Width; 309 skin->bar.width = skin->bar.Bitmap.Width;
310 defList->bar.height = defList->bar.Bitmap.Height; 310 skin->bar.height = skin->bar.Bitmap.Height;
311 311
312 #ifdef CONFIG_XSHAPE 312 #ifdef CONFIG_XSHAPE
313 Convert32to1(&defList->bar.Bitmap, &defList->bar.Mask, 0x00ff00ff); 313 Convert32to1(&skin->bar.Bitmap, &skin->bar.Mask, 0x00ff00ff);
314 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", defList->bar.Mask.Width, defList->bar.Mask.Height); 314 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", skin->bar.Mask.Width, skin->bar.Mask.Height);
315 #else 315 #else
316 defList->bar.Mask.Image = NULL; 316 skin->bar.Mask.Image = NULL;
317 #endif 317 #endif
318 318
319 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d height: %d\n", defList->bar.width, defList->bar.height); 319 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d height: %d\n", skin->bar.width, skin->bar.height);
320 } 320 }
321 321
322 return 0; 322 return 0;
323 } 323 }
324 324
411 CHECK("sub"); 411 CHECK("sub");
412 CHECK("playbar"); 412 CHECK("playbar");
413 413
414 cutItem(in, fname, ',', 0); 414 cutItem(in, fname, ',', 0);
415 415
416 defList->menuSelected.type = itBase; 416 skin->menuSelected.type = itBase;
417 417
418 av_strlcpy(tmp, path, sizeof(tmp)); 418 av_strlcpy(tmp, path, sizeof(tmp));
419 av_strlcat(tmp, fname, sizeof(tmp)); 419 av_strlcat(tmp, fname, sizeof(tmp));
420 420
421 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] selected: %s\n", fname); 421 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] selected: %s\n", fname);
422 422
423 if (skinBPRead(tmp, &defList->menuSelected.Bitmap) != 0) 423 if (skinBPRead(tmp, &skin->menuSelected.Bitmap) != 0)
424 return 1; 424 return 1;
425 425
426 defList->menuSelected.width = defList->menuSelected.Bitmap.Width; 426 skin->menuSelected.width = skin->menuSelected.Bitmap.Width;
427 defList->menuSelected.height = defList->menuSelected.Bitmap.Height; 427 skin->menuSelected.height = skin->menuSelected.Bitmap.Height;
428 428
429 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d height: %d\n", defList->menuSelected.width, defList->menuSelected.height); 429 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d height: %d\n", skin->menuSelected.width, skin->menuSelected.height);
430 430
431 return 0; 431 return 0;
432 } 432 }
433 433
434 // menu=x,y,width,height,message 434 // menu=x,y,width,height,message
450 sy = cutItemToInt(in, ',', 3); 450 sy = cutItemToInt(in, ',', 3);
451 cutItem(in, tmp, ',', 4); 451 cutItem(in, tmp, ',', 4);
452 452
453 message = appFindMessage(tmp); 453 message = appFindMessage(tmp);
454 454
455 defList->IndexOfMenuItems++; 455 skin->IndexOfMenuItems++;
456 defList->menuItems[defList->IndexOfMenuItems].x = x; 456 skin->menuItems[skin->IndexOfMenuItems].x = x;
457 defList->menuItems[defList->IndexOfMenuItems].y = y; 457 skin->menuItems[skin->IndexOfMenuItems].y = y;
458 defList->menuItems[defList->IndexOfMenuItems].width = sx; 458 skin->menuItems[skin->IndexOfMenuItems].width = sx;
459 defList->menuItems[defList->IndexOfMenuItems].height = sy; 459 skin->menuItems[skin->IndexOfMenuItems].height = sy;
460 460
461 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] menuitem: %d\n", defList->IndexOfMenuItems); 461 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] menuitem: %d\n", skin->IndexOfMenuItems);
462 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] x: %d y: %d sx: %d sy: %d\n", x, y, sx, sy); 462 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] x: %d y: %d sx: %d sy: %d\n", x, y, sx, sy);
463 463
464 if ((defList->menuItems[defList->IndexOfMenuItems].message = message) == -1) 464 if ((skin->menuItems[skin->IndexOfMenuItems].message = message) == -1)
465 ERRORMESSAGE(MSGTR_SKIN_BITMAP_UnknownMessage, tmp); 465 ERRORMESSAGE(MSGTR_SKIN_BITMAP_UnknownMessage, tmp);
466 466
467 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %d\n", defList->mainItems[defList->IndexOfMainItems].message); 467 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %d\n", skin->mainItems[skin->IndexOfMainItems].message);
468 468
469 defList->menuItems[defList->IndexOfMenuItems].Bitmap.Image = NULL; 469 skin->menuItems[skin->IndexOfMenuItems].Bitmap.Image = NULL;
470 return 0; 470 return 0;
471 } 471 }
472 472
473 // hpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message 473 // hpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message
474 static int cmd_hpotmeter(char *in) 474 static int cmd_hpotmeter(char *in)
780 ERRORMESSAGE(MSGTR_SKIN_UnknownParameter, tmp); 780 ERRORMESSAGE(MSGTR_SKIN_UnknownParameter, tmp);
781 return 1; 781 return 1;
782 } 782 }
783 783
784 if (strcmp(tmp, "enable") != 0) 784 if (strcmp(tmp, "enable") != 0)
785 defList->mainDecoration = 0; 785 skin->mainDecoration = 0;
786 else 786 else
787 defList->mainDecoration = 1; 787 skin->mainDecoration = 1;
788 788
789 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] window decoration is %s\n", (defList->mainDecoration ? "enabled" : "disabled")); 789 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n[skin] window decoration is %s\n", (skin->mainDecoration ? "enabled" : "disabled"));
790 790
791 return 0; 791 return 0;
792 } 792 }
793 793
794 static _item skinItem[] = { 794 static _item skinItem[] = {