annotate gui/skin/skin.c @ 33968:253620911a2e

Add doxygen comments to skin.c.
author ib
date Mon, 05 Sep 2011 15:47:55 +0000
parents d8f49edf8f25
children 9184bc37d4d5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26458
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
1 /*
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
2 * This file is part of MPlayer.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
3 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
5 * it under the terms of the GNU General Public License as published by
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
7 * (at your option) any later version.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
8 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
12 * GNU General Public License for more details.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
13 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
14 * You should have received a copy of the GNU General Public License along
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
17 */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
18
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
19 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
20 * @file
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
21 * @brief Skin parser
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
22 */
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
23
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
24 #include <stdio.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
25 #include <string.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
26
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
27 #include "skin.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
28 #include "font.h"
32893
c873777e957d Get rid of needless listItems variable and pointer.
ib
parents: 32880
diff changeset
29 #include "gui/app.h"
33023
ba432e34dc7e Add message showing function.
ib
parents: 33022
diff changeset
30 #include "gui/interface.h"
33556
520fb0f7544c Rename GUI directory 'mplayer' and some files in it.
ib
parents: 33555
diff changeset
31 #include "gui/ui/widgets.h"
33046
9684ad0e1291 Move files with auxiliary functions to own directory.
ib
parents: 33023
diff changeset
32 #include "gui/util/cut.h"
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents: 33046
diff changeset
33 #include "gui/util/string.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
34
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
35 #include "config.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
36 #include "help_mp.h"
23703
9fb716ab06a3 Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents: 23077
diff changeset
37 #include "libavutil/avstring.h"
32944
27a98940e3aa Use FF_ARRAY_ELEMS() rather than a separate constant.
ib
parents: 32937
diff changeset
38 #include "libavutil/common.h"
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
39 #include "mp_msg.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
40
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
41 typedef struct {
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
42 const char *name;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
43 int (*func)(char *in);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
44 } _item;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
45
33749
d8f49edf8f25 Remove skin related variables from interface.[ch].
ib
parents: 33556
diff changeset
46 char *skinDirInHome;
d8f49edf8f25 Remove skin related variables from interface.[ch].
ib
parents: 33556
diff changeset
47 char *skinMPlayerDir;
d8f49edf8f25 Remove skin related variables from interface.[ch].
ib
parents: 33556
diff changeset
48
32937
3c57056637cc Cosmetic: Rename listItems structure.
ib
parents: 32933
diff changeset
49 static guiItems *skin;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
50
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
51 static int linenumber;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
52 static unsigned char path[512];
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
53
32980
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
54 static unsigned char currWinName[32];
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
55 static wItem *currWin;
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
56 static int *currWinItemIdx;
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
57 static wItem *currWinItems;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
58
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
59 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
60 * @brief Display a skin error message.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
61 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
62 * @param format format string
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
63 * @param ... arguments
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
64 */
33022
9abc0dbd6314 Cosmetic: Rename ERRORMESSAGE() skin_error().
ib
parents: 32980
diff changeset
65 static void skin_error(const char *format, ...)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
66 {
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
67 char p[512];
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
68 va_list ap;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
69
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
70 va_start(ap, format);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
71 vsnprintf(p, sizeof(p), format, ap);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
72 va_end(ap);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
73
33023
ba432e34dc7e Add message showing function.
ib
parents: 33022
diff changeset
74 gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_ERRORMESSAGE, linenumber, p);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
75 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
76
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
77 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
78 * @brief Check whether a @a section definition has started.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
79 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
80 * @param item name of the item to be put in a message in case of an error
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
81 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
82 * @return 1 (ok) or 0 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
83 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
84 static int section_item(char *item)
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
85 {
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
86 if (!skin) {
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
87 skin_error(MSGTR_SKIN_ERROR_SECTION, item);
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
88 return 0;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
89 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
90
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
91 return 1;
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
92 }
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
93
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
94 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
95 * @brief Check whether a @a window definition has started.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
96 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
97 * @param item name of the item to be put in a message in case of an error
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
98 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
99 * @return 1 (ok) or 0 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
100 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
101 static int window_item(char *item)
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
102 {
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
103 if (!currWinName[0]) {
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
104 skin_error(MSGTR_SKIN_ERROR_WINDOW, item);
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
105 return 0;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
106 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
107
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
108 return 1;
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
109 }
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
110
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
111 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
112 * @brief Check whether a specific @a window definition has started.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
113 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
114 * @param name name of the window to be checked
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
115 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
116 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
117 */
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
118 static int in_window(char *name)
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
119 {
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
120 if (strcmp(currWinName, name) == 0) {
33062
be0848508395 Cosmetic: Rename error message.
ib
parents: 33059
diff changeset
121 skin_error(MSGTR_SKIN_ERROR_ITEM, name);
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
122 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
123 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
124
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
125 return 0;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
126 }
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
127
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
128 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
129 * @brief Read a skin @a image file.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
130 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
131 * @param fname filename (with path)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
132 * @param bf pointer suitable to store the image data
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
133 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
134 * @return return code of #bpRead()
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
135 */
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33357
diff changeset
136 int skinBPRead(char *fname, guiImage *bf)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
137 {
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
138 int i = bpRead(fname, bf);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
139
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
140 switch (i) {
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
141 case -1:
33022
9abc0dbd6314 Cosmetic: Rename ERRORMESSAGE() skin_error().
ib
parents: 32980
diff changeset
142 skin_error(MSGTR_SKIN_BITMAP_16bit, fname);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
143 break;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
144
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
145 case -2:
33022
9abc0dbd6314 Cosmetic: Rename ERRORMESSAGE() skin_error().
ib
parents: 32980
diff changeset
146 skin_error(MSGTR_SKIN_BITMAP_FileNotFound, fname);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
147 break;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
148
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
149 case -5:
33022
9abc0dbd6314 Cosmetic: Rename ERRORMESSAGE() skin_error().
ib
parents: 32980
diff changeset
150 skin_error(MSGTR_SKIN_BITMAP_PNGReadError, fname);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
151 break;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
152
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
153 case -8:
33022
9abc0dbd6314 Cosmetic: Rename ERRORMESSAGE() skin_error().
ib
parents: 32980
diff changeset
154 skin_error(MSGTR_SKIN_BITMAP_ConversionError, fname);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
155 break;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
156 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
157
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
158 return i;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
159 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
160
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
161 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
162 * @brief Get next free item in current @a window.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
163 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
164 * @return pointer to next free item (ok) or NULL (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
165 */
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
166 static wItem *next_item(void)
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
167 {
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
168 wItem *item = NULL;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
169
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
170 if (*currWinItemIdx < MAX_ITEMS - 1) {
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
171 (*currWinItemIdx)++;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
172 item = &currWinItems[*currWinItemIdx];
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
173 } else
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
174 skin_error(MSGTR_SKIN_TooManyItemsDeclared);
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
175
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
176 return item;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
177 }
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
178
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
179 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
180 * @brief Parse a @a section definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
181 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
182 * Syntax: section=movieplayer
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
183 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
184 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
185 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
186 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
187 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
188 static int item_section(char *in)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
189 {
33064
33d307c4430c Add error check.
ib
parents: 33063
diff changeset
190 if (skin) {
33d307c4430c Add error check.
ib
parents: 33063
diff changeset
191 skin_error(MSGTR_SKIN_ERROR_ITEM, "section");
33d307c4430c Add error check.
ib
parents: 33063
diff changeset
192 return 1;
33d307c4430c Add error check.
ib
parents: 33063
diff changeset
193 }
33d307c4430c Add error check.
ib
parents: 33063
diff changeset
194
33055
2be86f1db767 Make use of return value of strlower().
ib
parents: 33054
diff changeset
195 if (!strcmp(strlower(in), "movieplayer"))
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33357
diff changeset
196 skin = &guiApp;
33067
2d0058f30a6b Issue error message in case of wrong section name.
ib
parents: 33066
diff changeset
197 else {
2d0058f30a6b Issue error message in case of wrong section name.
ib
parents: 33066
diff changeset
198 skin_error(MSGTR_SKIN_UNKNOWN_NAME, in);
2d0058f30a6b Issue error message in case of wrong section name.
ib
parents: 33066
diff changeset
199 return 1;
2d0058f30a6b Issue error message in case of wrong section name.
ib
parents: 33066
diff changeset
200 }
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
201
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
202 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] section: %s\n", in);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
203
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
204 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
205 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
206
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
207 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
208 * @brief Parse an @a end definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
209 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
210 * Syntax: end
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
211 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
212 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
213 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
214 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
215 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
216 static int item_end(char *in)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
217 {
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
218 char *space, *name;
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
219
33357
5a5c875e7392 gui: Fix compilation without debug enabled.
diego
parents: 33129
diff changeset
220 #ifdef MP_DEBUG
32980
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
221 if (currWinName[0]) {
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
222 space = " ";
32980
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
223 name = currWinName;
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
224 } else {
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
225 space = "";
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
226 name = "section";
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
227 }
32958
80087dd00035 Fix some debug messages.
ib
parents: 32951
diff changeset
228 #endif
80087dd00035 Fix some debug messages.
ib
parents: 32951
diff changeset
229
80087dd00035 Fix some debug messages.
ib
parents: 32951
diff changeset
230 (void)in;
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
231
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
232 if (!section_item("end"))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
233 return 1;
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
234
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
235 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %send (%s)\n", space, name);
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
236
32980
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
237 if (currWinName[0]) {
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
238 currWinName[0] = 0;
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
239 currWin = NULL;
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
240 currWinItemIdx = NULL;
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
241 currWinItems = NULL;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
242 } else
32937
3c57056637cc Cosmetic: Rename listItems structure.
ib
parents: 32933
diff changeset
243 skin = NULL;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
244
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
245 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
246 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
247
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
248 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
249 * @brief Parse a @a window definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
250 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
251 * Syntax: window=main|sub|playbar|menu
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
252 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
253 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
254 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
255 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
256 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
257 static int item_window(char *in)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
258 {
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
259 if (!section_item("window"))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
260 return 1;
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
261
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
262 if (currWinName[0]) {
33062
be0848508395 Cosmetic: Rename error message.
ib
parents: 33059
diff changeset
263 skin_error(MSGTR_SKIN_ERROR_ITEM, "window");
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
264 return 1;
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
265 }
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
266
33083
8c96263e0f09 Clean up cmd_window().
ib
parents: 33081
diff changeset
267 strlower(in);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
268
33083
8c96263e0f09 Clean up cmd_window().
ib
parents: 33081
diff changeset
269 if (strcmp(in, "main") == 0) {
33095
772af04413f3 Avoid using appMPlayer.
ib
parents: 33094
diff changeset
270 currWin = &skin->main;
772af04413f3 Avoid using appMPlayer.
ib
parents: 33094
diff changeset
271 currWinItemIdx = &skin->IndexOfMainItems;
772af04413f3 Avoid using appMPlayer.
ib
parents: 33094
diff changeset
272 currWinItems = skin->mainItems;
33083
8c96263e0f09 Clean up cmd_window().
ib
parents: 33081
diff changeset
273 } else if (strcmp(in, "sub") == 0) {
33095
772af04413f3 Avoid using appMPlayer.
ib
parents: 33094
diff changeset
274 currWin = &skin->sub;
33083
8c96263e0f09 Clean up cmd_window().
ib
parents: 33081
diff changeset
275 currWinItemIdx = NULL;
8c96263e0f09 Clean up cmd_window().
ib
parents: 33081
diff changeset
276 currWinItems = NULL;
8c96263e0f09 Clean up cmd_window().
ib
parents: 33081
diff changeset
277 } else if (strcmp(in, "playbar") == 0) {
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33357
diff changeset
278 currWin = &skin->playbar;
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33357
diff changeset
279 currWinItemIdx = &skin->IndexOfPlaybarItems;
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33357
diff changeset
280 currWinItems = skin->playbarItems;
33083
8c96263e0f09 Clean up cmd_window().
ib
parents: 33081
diff changeset
281 } else if (strcmp(in, "menu") == 0) {
33095
772af04413f3 Avoid using appMPlayer.
ib
parents: 33094
diff changeset
282 currWin = &skin->menu;
772af04413f3 Avoid using appMPlayer.
ib
parents: 33094
diff changeset
283 currWinItemIdx = &skin->IndexOfMenuItems;
772af04413f3 Avoid using appMPlayer.
ib
parents: 33094
diff changeset
284 currWinItems = skin->menuItems;
33066
fd4d66a6add6 Don't start GUI in case of window name error.
ib
parents: 33065
diff changeset
285 } else {
33065
83c226105086 Rename and revise error message.
ib
parents: 33064
diff changeset
286 skin_error(MSGTR_SKIN_UNKNOWN_NAME, in);
33066
fd4d66a6add6 Don't start GUI in case of window name error.
ib
parents: 33065
diff changeset
287 return 1;
fd4d66a6add6 Don't start GUI in case of window name error.
ib
parents: 33065
diff changeset
288 }
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
289
33083
8c96263e0f09 Clean up cmd_window().
ib
parents: 33081
diff changeset
290 av_strlcpy(currWinName, in, sizeof(currWinName));
8c96263e0f09 Clean up cmd_window().
ib
parents: 33081
diff changeset
291
32980
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
292 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] window: %s\n", currWinName);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
293
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
294 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
295 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
296
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
297 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
298 * @brief Parse a @a base definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
299 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
300 * Syntax: base=image,x,y[,width,height]
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
301 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
302 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
303 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
304 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
305 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
306 static int item_base(char *in)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
307 {
33090
db699b367260 Reduce resp. increase arrays to reasonable size.
ib
parents: 33089
diff changeset
308 unsigned char fname[256];
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
309 unsigned char file[512];
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
310 int x, y;
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
311 int w = 0, h = 0;
33104
65827197d1af Simplify cmd_base().
ib
parents: 33103
diff changeset
312 int is_sub, is_bar, is_menu;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
313
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
314 if (!window_item("base"))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
315 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
316
33104
65827197d1af Simplify cmd_base().
ib
parents: 33103
diff changeset
317 is_sub = (strcmp(currWinName, "sub") == 0);
65827197d1af Simplify cmd_base().
ib
parents: 33103
diff changeset
318 is_bar = (strcmp(currWinName, "playbar") == 0);
65827197d1af Simplify cmd_base().
ib
parents: 33103
diff changeset
319 is_menu = (strcmp(currWinName, "menu") == 0);
65827197d1af Simplify cmd_base().
ib
parents: 33103
diff changeset
320
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
321 cutItem(in, fname, ',', 0);
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
322 x = cutItemToInt(in, ',', 1);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
323 y = cutItemToInt(in, ',', 2);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
324 w = cutItemToInt(in, ',', 3);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
325 h = cutItemToInt(in, ',', 4);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
326
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
327 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s", fname);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
328
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
329 currWin->type = itBase;
33104
65827197d1af Simplify cmd_base().
ib
parents: 33103
diff changeset
330
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
331 if (!is_menu) {
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
332 currWin->x = x;
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
333 currWin->y = y;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
334
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
335 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, " %d,%d", x, y);
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
336 }
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
337
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
338 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "\n");
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
339
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
340 av_strlcpy(file, path, sizeof(file));
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
341 av_strlcat(file, fname, sizeof(file));
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
342
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
343 if (skinBPRead(file, &currWin->Bitmap) != 0)
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
344 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
345
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
346 currWin->width = currWin->Bitmap.Width;
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
347 currWin->height = currWin->Bitmap.Height;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
348
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
349 if (is_sub) {
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
350 if (w && h) {
33096
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
351 currWin->width = w;
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
352 currWin->height = h;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
353 }
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
354 }
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
355
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
356 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", currWin->width, currWin->height);
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
357
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
358 if (!is_sub) {
27377
d58d06eafe83 Change a bunch of X11-specific preprocessor directives.
diego
parents: 26458
diff changeset
359 #ifdef CONFIG_XSHAPE
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33357
diff changeset
360 if (!bpRenderMask(&currWin->Bitmap, &currWin->Mask)) {
33114
5ad451a5ebec Remove useless warning message.
ib
parents: 33106
diff changeset
361 skin_error(MSGTR_SKIN_NotEnoughMemory);
5ad451a5ebec Remove useless warning message.
ib
parents: 33106
diff changeset
362 return 1;
5ad451a5ebec Remove useless warning message.
ib
parents: 33106
diff changeset
363 }
33096
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
364 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %lux%lu\n", currWin->Mask.Width, currWin->Mask.Height);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
365 #else
33096
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
366 currWin->Mask.Image = NULL;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
367 #endif
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
368 }
33101
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
369
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
370 if (is_bar)
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33357
diff changeset
371 skin->playbarIsPresent = 1;
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
372 if (is_menu)
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
373 skin->menuIsPresent = 1;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27377
diff changeset
374
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
375 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
376 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
377
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
378 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
379 * @brief Parse a @a background definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
380 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
381 * Syntax: background=R,G,B
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
382 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
383 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
384 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
385 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
386 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
387 static int item_background(char *in)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
388 {
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
389 if (!window_item("background"))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
390 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
391
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
392 if (in_window("main"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
393 return 1;
33088
babdacb1ceac Disable background definition for playbar.
ib
parents: 33087
diff changeset
394 if (in_window("playbar"))
babdacb1ceac Disable background definition for playbar.
ib
parents: 33087
diff changeset
395 return 1;
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
396 if (in_window("menu"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
397 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
398
32980
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
399 currWin->R = cutItemToInt(in, ',', 0);
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
400 currWin->G = cutItemToInt(in, ',', 1);
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
401 currWin->B = cutItemToInt(in, ',', 2);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
402
32980
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
403 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] background color: #%02x%02x%02x\n", currWin->R, currWin->G, currWin->B);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
404
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
405 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
406 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
407
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
408 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
409 * @brief Parse a @a button definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
410 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
411 * Syntax: button=image,x,y,width,height,message
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
412 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
413 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
414 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
415 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
416 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
417 static int item_button(char *in)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
418 {
33090
db699b367260 Reduce resp. increase arrays to reasonable size.
ib
parents: 33089
diff changeset
419 unsigned char fname[256];
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
420 unsigned char file[512];
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
421 int x, y, w, h, message;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
422 char msg[32];
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
423 wItem *item;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
424
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
425 if (!window_item("button"))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
426 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
427
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
428 if (in_window("sub"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
429 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
430 if (in_window("menu"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
431 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
432
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
433 cutItem(in, fname, ',', 0);
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
434 x = cutItemToInt(in, ',', 1);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
435 y = cutItemToInt(in, ',', 2);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
436 w = cutItemToInt(in, ',', 3);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
437 h = cutItemToInt(in, ',', 4);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
438 cutItem(in, msg, ',', 5);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
439
33071
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
440 message = appFindMessage(msg);
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
441
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
442 if (message == -1) {
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
443 skin_error(MSGTR_SKIN_UnknownMessage, msg);
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
444 return 1;
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
445 }
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
446
33102
de688a61e439 Move debug messages so that they will be processed earlier.
ib
parents: 33101
diff changeset
447 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %d,%d\n", fname, x, y);
de688a61e439 Move debug messages so that they will be processed earlier.
ib
parents: 33101
diff changeset
448 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, message);
de688a61e439 Move debug messages so that they will be processed earlier.
ib
parents: 33101
diff changeset
449 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] size: %dx%d\n", w, h);
de688a61e439 Move debug messages so that they will be processed earlier.
ib
parents: 33101
diff changeset
450
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
451 item = next_item();
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
452
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
453 if (!item)
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
454 return 1;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
455
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
456 item->type = itButton;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
457 item->x = x;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
458 item->y = y;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
459 item->width = w;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
460 item->height = h;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
461 item->message = message;
33101
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
462 item->pressed = btnReleased;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
463
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
464 if (item->message == evPauseSwitchToPlay)
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
465 item->pressed = btnDisabled;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
466
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
467 item->Bitmap.Image = NULL;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
468
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
469 if (strcmp(fname, "NULL") != 0) {
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
470 av_strlcpy(file, path, sizeof(file));
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
471 av_strlcat(file, fname, sizeof(file));
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
472
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
473 if (skinBPRead(file, &item->Bitmap) != 0)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
474 return 1;
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
475
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
476 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
477 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
478
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
479 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
480 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
481
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
482 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
483 * @brief Parse a @a selected definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
484 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
485 * Syntax: selected=image
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
486 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
487 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
488 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
489 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
490 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
491 static int item_selected(char *in)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
492 {
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
493 unsigned char file[512];
33096
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
494 wItem *currItem;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
495
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
496 if (!window_item("selected"))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
497 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
498
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
499 if (in_window("main"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
500 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
501 if (in_window("sub"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
502 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
503 if (in_window("playbar"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
504 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
505
33102
de688a61e439 Move debug messages so that they will be processed earlier.
ib
parents: 33101
diff changeset
506 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image selected: %s\n", in);
de688a61e439 Move debug messages so that they will be processed earlier.
ib
parents: 33101
diff changeset
507
33096
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
508 currItem = &skin->menuSelected;
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
509 currItem->type = itBase;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
510
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
511 av_strlcpy(file, path, sizeof(file));
33091
6ce0b74d03b7 Remove needless variable.
ib
parents: 33090
diff changeset
512 av_strlcat(file, in, sizeof(file));
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
513
33096
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
514 if (skinBPRead(file, &currItem->Bitmap) != 0)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
515 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
516
33096
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
517 currItem->width = currItem->Bitmap.Width;
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
518 currItem->height = currItem->Bitmap.Height;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
519
33096
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
520 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", currItem->width, currItem->height);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
521
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
522 return 0;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
523 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27377
diff changeset
524
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
525 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
526 * @brief Parse a @a menu definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
527 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
528 * Syntax: menu=x,y,width,height,message
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
529 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
530 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
531 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
532 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
533 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
534 static int item_menu(char *in)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
535 {
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
536 int x, y, w, h, message;
33071
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
537 char msg[32];
33096
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
538 wItem *item;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
539
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
540 if (!window_item("menu"))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
541 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
542
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
543 if (in_window("main"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
544 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
545 if (in_window("sub"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
546 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
547 if (in_window("playbar"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
548 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
549
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
550 x = cutItemToInt(in, ',', 0);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
551 y = cutItemToInt(in, ',', 1);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
552 w = cutItemToInt(in, ',', 2);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
553 h = cutItemToInt(in, ',', 3);
33071
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
554 cutItem(in, msg, ',', 4);
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
555
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
556 message = appFindMessage(msg);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
557
33071
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
558 if (message == -1) {
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
559 skin_error(MSGTR_SKIN_UnknownMessage, msg);
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
560 return 1;
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
561 }
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
562
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
563 item = next_item();
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
564
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
565 if (!item)
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
566 return 1;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
567
33100
35efac3ece2c Add an itMenu item type.
ib
parents: 33099
diff changeset
568 item->type = itMenu;
33096
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
569 item->x = x;
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
570 item->y = y;
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
571 item->width = w;
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
572 item->height = h;
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
573 item->message = message;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
574
33096
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
575 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] item #%d: %d,%d %dx%d\n", *currWinItemIdx, x, y, w, h);
33071
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
576 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, message);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
577
33096
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
578 item->Bitmap.Image = NULL;
33053
f64d41dac10b Cosmetic: Separate return statement with newline.
ib
parents: 33052
diff changeset
579
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
580 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
581 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
582
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
583 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
584 * @brief Parse a @a hpotmeter definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
585 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
586 * Syntax: hpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
587 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
588 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
589 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
590 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
591 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
592 static int item_hpotmeter(char *in)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
593 {
33090
db699b367260 Reduce resp. increase arrays to reasonable size.
ib
parents: 33089
diff changeset
594 unsigned char pfname[256];
db699b367260 Reduce resp. increase arrays to reasonable size.
ib
parents: 33089
diff changeset
595 unsigned char phfname[256];
33093
3de646fca03b Cosmetic: Rearrange variable declarations to match parameters.
ib
parents: 33092
diff changeset
596 unsigned char buf[512];
3de646fca03b Cosmetic: Rearrange variable declarations to match parameters.
ib
parents: 33092
diff changeset
597 int pwidth, pheight, ph, d, x, y, w, h, message;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
598 wItem *item;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
599
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
600 if (!window_item("h/v potmeter"))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
601 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
602
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
603 if (in_window("sub"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
604 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
605 if (in_window("menu"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
606 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
607
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
608 cutItem(in, pfname, ',', 0);
32911
e06fbdd8eb46 Clean up the wItem structure.
ib
parents: 32910
diff changeset
609 pwidth = cutItemToInt(in, ',', 1);
e06fbdd8eb46 Clean up the wItem structure.
ib
parents: 32910
diff changeset
610 pheight = cutItemToInt(in, ',', 2);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
611 cutItem(in, phfname, ',', 3);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
612 ph = cutItemToInt(in, ',', 4);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
613 d = cutItemToInt(in, ',', 5);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
614 x = cutItemToInt(in, ',', 6);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
615 y = cutItemToInt(in, ',', 7);
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
616 w = cutItemToInt(in, ',', 8);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
617 h = cutItemToInt(in, ',', 9);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
618 cutItem(in, buf, ',', 10);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
619
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
620 message = appFindMessage(buf);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
621
33069
4b7d4905862c Rename error message and add missing checks.
ib
parents: 33067
diff changeset
622 if (message == -1) {
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
623 skin_error(MSGTR_SKIN_UnknownMessage, buf);
33069
4b7d4905862c Rename error message and add missing checks.
ib
parents: 33067
diff changeset
624 return 1;
4b7d4905862c Rename error message and add missing checks.
ib
parents: 33067
diff changeset
625 }
4b7d4905862c Rename error message and add missing checks.
ib
parents: 33067
diff changeset
626
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
627 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] h/v potmeter image: %s %d,%d %dx%d\n", phfname, x, y, w, h);
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
628 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %dx%d\n", pfname, pwidth, pheight);
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
629 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d);
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
630 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
631
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
632 item = next_item();
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
633
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
634 if (!item)
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
635 return 1;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
636
33101
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
637 item->type = itHPotmeter;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
638 item->x = x;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
639 item->y = y;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
640 item->width = w;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
641 item->height = h;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
642 item->pwidth = pwidth;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
643 item->pheight = pheight;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
644 item->numphases = ph;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
645 item->value = (float)d;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
646 item->message = message;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
647 item->pressed = btnReleased;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
648
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
649 item->Bitmap.Image = NULL;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
650
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
651 if (strcmp(phfname, "NULL") != 0) {
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
652 av_strlcpy(buf, path, sizeof(buf));
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
653 av_strlcat(buf, phfname, sizeof(buf));
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
654
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
655 if (skinBPRead(buf, &item->Bitmap) != 0)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
656 return 1;
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
657
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
658 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (potmeter bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
659 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
660
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
661 item->Mask.Image = NULL;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
662
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
663 if (strcmp(pfname, "NULL") != 0) {
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
664 av_strlcpy(buf, path, sizeof(buf));
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
665 av_strlcat(buf, pfname, sizeof(buf));
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
666
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
667 if (skinBPRead(buf, &item->Mask) != 0)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
668 return 1;
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
669
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
670 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (button bitmap: %lux%lu)\n", item->Mask.Width, item->Mask.Height);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
671 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
672
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
673 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
674 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
675
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
676 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
677 * @brief Parse a @a vpotmeter definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
678 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
679 * Syntax: vpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
680 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
681 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
682 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
683 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
684 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
685 static int item_vpotmeter(char *in)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
686 {
33056
1c2070f0abca Prevent a segmentation fault.
ib
parents: 33055
diff changeset
687 int r;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
688 wItem *item;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
689
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
690 r = item_hpotmeter(in);
33056
1c2070f0abca Prevent a segmentation fault.
ib
parents: 33055
diff changeset
691
1c2070f0abca Prevent a segmentation fault.
ib
parents: 33055
diff changeset
692 if (r == 0) {
33057
0d6b33bc311e Cosmetic: Adjust indent.
ib
parents: 33056
diff changeset
693 item = &currWinItems[*currWinItemIdx];
0d6b33bc311e Cosmetic: Adjust indent.
ib
parents: 33056
diff changeset
694 item->type = itVPotmeter;
33056
1c2070f0abca Prevent a segmentation fault.
ib
parents: 33055
diff changeset
695 }
33053
f64d41dac10b Cosmetic: Separate return statement with newline.
ib
parents: 33052
diff changeset
696
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
697 return r;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
698 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
699
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
700 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
701 * @brief Parse a @a potmeter definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
702 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
703 * Syntax: potmeter=phases,numphases,default,x,y,width,height,message
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
704 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
705 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
706 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
707 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
708 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
709 static int item_potmeter(char *in)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
710 {
33093
3de646fca03b Cosmetic: Rearrange variable declarations to match parameters.
ib
parents: 33092
diff changeset
711 unsigned char phfname[256];
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
712 unsigned char buf[512];
33093
3de646fca03b Cosmetic: Rearrange variable declarations to match parameters.
ib
parents: 33092
diff changeset
713 int ph, d, x, y, w, h, message;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
714 wItem *item;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
715
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
716 if (!window_item("potmeter"))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
717 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
718
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
719 if (in_window("sub"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
720 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
721 if (in_window("menu"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
722 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
723
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
724 cutItem(in, phfname, ',', 0);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
725 ph = cutItemToInt(in, ',', 1);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
726 d = cutItemToInt(in, ',', 2);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
727 x = cutItemToInt(in, ',', 3);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
728 y = cutItemToInt(in, ',', 4);
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
729 w = cutItemToInt(in, ',', 5);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
730 h = cutItemToInt(in, ',', 6);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
731 cutItem(in, buf, ',', 7);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
732
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
733 message = appFindMessage(buf);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
734
33069
4b7d4905862c Rename error message and add missing checks.
ib
parents: 33067
diff changeset
735 if (message == -1) {
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
736 skin_error(MSGTR_SKIN_UnknownMessage, buf);
33069
4b7d4905862c Rename error message and add missing checks.
ib
parents: 33067
diff changeset
737 return 1;
4b7d4905862c Rename error message and add missing checks.
ib
parents: 33067
diff changeset
738 }
4b7d4905862c Rename error message and add missing checks.
ib
parents: 33067
diff changeset
739
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
740 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] potmeter image: %s %d,%d %dx%d\n", phfname, x, y, w, h);
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
741 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", ph, d);
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
742 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
743
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
744 item = next_item();
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
745
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
746 if (!item)
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
747 return 1;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
748
33101
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
749 item->type = itPotmeter;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
750 item->x = x;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
751 item->y = y;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
752 item->width = w;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
753 item->height = h;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
754 item->numphases = ph;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
755 item->value = (float)d;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
756 item->message = message;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
757
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
758 item->Bitmap.Image = NULL;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
759
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
760 if (strcmp(phfname, "NULL") != 0) {
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
761 av_strlcpy(buf, path, sizeof(buf));
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
762 av_strlcat(buf, phfname, sizeof(buf));
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
763
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
764 if (skinBPRead(buf, &item->Bitmap) != 0)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
765 return 1;
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
766
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
767 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %lux%lu)\n", item->Bitmap.Width, item->Bitmap.Height);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
768 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
769
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
770 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
771 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
772
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
773 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
774 * @brief Parse a @a font definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
775 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
776 * Syntax: font=fontfile
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
777 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
778 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
779 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
780 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
781 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
782 static int item_font(char *in)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
783 {
33092
83052a4ac698 Use more appropriate name for variable and reduce it to reasonable size.
ib
parents: 33091
diff changeset
784 char fnt[256];
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
785
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
786 if (!window_item("font"))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
787 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
788
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
789 if (in_window("sub"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
790 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
791 if (in_window("menu"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
792 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
793
33092
83052a4ac698 Use more appropriate name for variable and reduce it to reasonable size.
ib
parents: 33091
diff changeset
794 cutItem(in, fnt, ',', 0); // Note: This seems needless but isn't for compatibility
83052a4ac698 Use more appropriate name for variable and reduce it to reasonable size.
ib
parents: 33091
diff changeset
795 // reasons with a meanwhile depreciated second parameter.
33099
0b17f6bed6fc Don't needlessly store font information in the wItems array
ib
parents: 33098
diff changeset
796 switch (fntRead(path, fnt)) {
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
797 case -1:
33097
533c658a18da Revise font related error messages.
ib
parents: 33096
diff changeset
798 skin_error(MSGTR_SKIN_NotEnoughMemory);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
799 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
800
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
801 case -2:
33022
9abc0dbd6314 Cosmetic: Rename ERRORMESSAGE() skin_error().
ib
parents: 32980
diff changeset
802 skin_error(MSGTR_SKIN_FONT_TooManyFontsDeclared);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
803 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
804
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
805 case -3:
33022
9abc0dbd6314 Cosmetic: Rename ERRORMESSAGE() skin_error().
ib
parents: 32980
diff changeset
806 skin_error(MSGTR_SKIN_FONT_FontFileNotFound);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
807 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
808
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
809 case -4:
33022
9abc0dbd6314 Cosmetic: Rename ERRORMESSAGE() skin_error().
ib
parents: 32980
diff changeset
810 skin_error(MSGTR_SKIN_FONT_FontImageNotFound);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
811 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
812 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
813
33092
83052a4ac698 Use more appropriate name for variable and reduce it to reasonable size.
ib
parents: 33091
diff changeset
814 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, fntFindID(fnt));
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
815
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
816 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
817 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
818
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
819 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
820 * @brief Parse a @a slabel definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
821 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
822 * Syntax: slabel=x,y,fontfile,"text"
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
823 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
824 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
825 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
826 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
827 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
828 static int item_slabel(char *in)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
829 {
33094
2faf1c3ded5d Cosmetic: Rearrange variable declarations to match parameters.
ib
parents: 33093
diff changeset
830 int x, y, id;
33090
db699b367260 Reduce resp. increase arrays to reasonable size.
ib
parents: 33089
diff changeset
831 char fnt[256];
33094
2faf1c3ded5d Cosmetic: Rearrange variable declarations to match parameters.
ib
parents: 33093
diff changeset
832 char txt[256];
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
833 wItem *item;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
834
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
835 if (!window_item("slabel"))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
836 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
837
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
838 if (in_window("sub"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
839 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
840 if (in_window("menu"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
841 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
842
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
843 x = cutItemToInt(in, ',', 0);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
844 y = cutItemToInt(in, ',', 1);
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
845 cutItem(in, fnt, ',', 2);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
846 cutItem(in, txt, ',', 3);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
847 cutItem(txt, txt, '"', 1);
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
848
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
849 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] slabel: \"%s\"\n", txt);
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
850 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
851
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
852 id = fntFindID(fnt);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
853
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
854 if (id < 0) {
33097
533c658a18da Revise font related error messages.
ib
parents: 33096
diff changeset
855 skin_error(MSGTR_SKIN_FONT_NonExistentFont, fnt);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
856 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
857 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
858
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
859 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
860
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
861 item = next_item();
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
862
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
863 if (!item)
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
864 return 1;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
865
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
866 item->type = itSLabel;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
867 item->x = x;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
868 item->y = y;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
869 item->width = -1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
870 item->height = -1;
33101
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
871 item->fontid = id;
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
872 item->label = strdup(txt);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
873
32979
4905f5a87357 Replace some awkward and unnecessary usages of strlen().
ib
parents: 32958
diff changeset
874 if (!item->label) {
33097
533c658a18da Revise font related error messages.
ib
parents: 33096
diff changeset
875 skin_error(MSGTR_SKIN_NotEnoughMemory);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
876 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
877 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
878
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
879 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
880 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
881
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
882 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
883 * @brief Parse a @a dlabel definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
884 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
885 * Syntax: dlabel=x,y,width,align,fontfile,"text"
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
886 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
887 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
888 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
889 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
890 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
891 static int item_dlabel(char *in)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
892 {
33094
2faf1c3ded5d Cosmetic: Rearrange variable declarations to match parameters.
ib
parents: 33093
diff changeset
893 int x, y, w, a, id;
33090
db699b367260 Reduce resp. increase arrays to reasonable size.
ib
parents: 33089
diff changeset
894 char fnt[256];
33094
2faf1c3ded5d Cosmetic: Rearrange variable declarations to match parameters.
ib
parents: 33093
diff changeset
895 char txt[256];
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
896 wItem *item;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
897
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
898 if (!window_item("dlabel"))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
899 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
900
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
901 if (in_window("sub"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
902 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
903 if (in_window("menu"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
904 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
905
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
906 x = cutItemToInt(in, ',', 0);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
907 y = cutItemToInt(in, ',', 1);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
908 w = cutItemToInt(in, ',', 2);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
909 a = cutItemToInt(in, ',', 3);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
910 cutItem(in, fnt, ',', 4);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
911 cutItem(in, txt, ',', 5);
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
912 cutItem(txt, txt, '"', 1);
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
913
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
914 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] dlabel: \"%s\"\n", txt);
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
915 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y);
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
916 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d, align: %d\n", w, a);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
917
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
918 id = fntFindID(fnt);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
919
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
920 if (id < 0) {
33097
533c658a18da Revise font related error messages.
ib
parents: 33096
diff changeset
921 skin_error(MSGTR_SKIN_FONT_NonExistentFont, fnt);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
922 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
923 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
924
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
925 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
926
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
927 item = next_item();
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
928
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
929 if (!item)
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
930 return 1;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
931
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
932 item->type = itDLabel;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
933 item->x = x;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
934 item->y = y;
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
935 item->width = w;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
936 item->height = -1;
33101
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
937 item->fontid = id;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
938 item->align = a;
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
939 item->label = strdup(txt);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
940
32979
4905f5a87357 Replace some awkward and unnecessary usages of strlen().
ib
parents: 32958
diff changeset
941 if (!item->label) {
33097
533c658a18da Revise font related error messages.
ib
parents: 33096
diff changeset
942 skin_error(MSGTR_SKIN_NotEnoughMemory);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
943 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
944 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
945
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
946 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
947 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
948
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
949 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
950 * @brief Parse a @a decoration definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
951 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
952 * Syntax: decoration=enable|disable
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
953 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
954 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
955 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
956 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
957 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
958 static int item_decoration(char *in)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
959 {
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
960 if (!window_item("decoration"))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
961 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
962
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
963 if (in_window("sub"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
964 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
965 if (in_window("playbar"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
966 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
967 if (in_window("menu"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
968 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
969
33086
1b9f989855f3 Remove needless variable.
ib
parents: 33084
diff changeset
970 strlower(in);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
971
33086
1b9f989855f3 Remove needless variable.
ib
parents: 33084
diff changeset
972 if (strcmp(in, "enable") != 0 && strcmp(in, "disable") != 0) {
1b9f989855f3 Remove needless variable.
ib
parents: 33084
diff changeset
973 skin_error(MSGTR_SKIN_UnknownParameter, in);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
974 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
975 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
976
33087
ca17f301336d Simplify parameter analysis.
ib
parents: 33086
diff changeset
977 skin->mainDecoration = (strcmp(in, "enable") == 0);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
978
33086
1b9f989855f3 Remove needless variable.
ib
parents: 33084
diff changeset
979 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] decoration: %s\n", in);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
980
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
981 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
982 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
983
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
984 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
985 * @brief Parsing functions responsible for skin item definitions.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
986 */
32878
afa6f80b0867 Limit scope of internally used skinItem array.
ib
parents: 32877
diff changeset
987 static _item skinItem[] = {
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
988 { "background", item_background },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
989 { "base", item_base },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
990 { "button", item_button },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
991 { "decoration", item_decoration },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
992 { "dlabel", item_dlabel },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
993 { "end", item_end },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
994 { "font", item_font },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
995 { "hpotmeter", item_hpotmeter },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
996 { "menu", item_menu },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
997 { "potmeter", item_potmeter },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
998 { "section", item_section },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
999 { "selected", item_selected },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1000 { "slabel", item_slabel },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1001 { "vpotmeter", item_vpotmeter },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1002 { "window", item_window }
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1003 };
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1004
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1005 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1006 * @brief Build the skin file path for a skin name.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1007 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1008 * @param dir skins directory
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1009 * @param sname name of the skin
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1010 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1011 * @return skin file path
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1012 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1013 * @note As a side effect, variable #path gets set to the skin path.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1014 */
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1015 static char *setname(char *dir, char *sname)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1016 {
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1017 static char skinfname[512];
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1018
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1019 av_strlcpy(skinfname, dir, sizeof(skinfname));
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1020 av_strlcat(skinfname, "/", sizeof(skinfname));
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1021 av_strlcat(skinfname, sname, sizeof(skinfname));
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1022 av_strlcat(skinfname, "/", sizeof(skinfname));
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1023 av_strlcpy(path, skinfname, sizeof(path));
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1024 av_strlcat(skinfname, "skin", sizeof(skinfname));
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1025
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1026 return skinfname;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1027 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1028
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1029 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1030 * @brief Read and parse a skin.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1031 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1032 * @param sname name of the skin
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1033 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1034 * @return 0 (ok), -1 (skin file not found or not readable) or -2 (parsing error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1035 */
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1036 int skinRead(char *sname)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1037 {
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1038 char *skinfname;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1039 FILE *skinFile;
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1040 unsigned char line[256];
33075
c7cfa1a653c8 Cosmetic: Rename command item.
ib
parents: 33073
diff changeset
1041 unsigned char item[32];
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1042 unsigned char param[256];
32944
27a98940e3aa Use FF_ARRAY_ELEMS() rather than a separate constant.
ib
parents: 32937
diff changeset
1043 unsigned int i;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1044
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1045 skinfname = setname(skinDirInHome, sname);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1046
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1047 if ((skinFile = fopen(skinfname, "rt")) == NULL) {
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1048 skinfname = setname(skinMPlayerDir, sname);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1049
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1050 if ((skinFile = fopen(skinfname, "rt")) == NULL) {
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1051 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotFound, skinfname);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1052 return -1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1053 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1054 }
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1055
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1056 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] configuration file: %s\n", skinfname);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1057
32932
e95ec1b2feea Cosmetic: Rename appInitStruct() to appFreeStruct().
ib
parents: 32931
diff changeset
1058 appFreeStruct();
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1059
33078
c84938655cf4 Reset skin pointer and window name.
ib
parents: 33077
diff changeset
1060 skin = NULL;
c84938655cf4 Reset skin pointer and window name.
ib
parents: 33077
diff changeset
1061 currWinName[0] = 0;
33079
25c467321c98 Cosmetic: Adjust indent.
ib
parents: 33078
diff changeset
1062 linenumber = 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1063
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1064 while (fgets(line, sizeof(line), skinFile)) {
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1065 linenumber++;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1066
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1067 line[strcspn(line, "\n\r")] = 0; // remove any kind of newline, if any
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1068 strswap(line, '\t', ' ');
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1069 trim(line);
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1070 decomment(line);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1071
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1072 if (!*line)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1073 continue;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1074
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1075 cutItem(line, item, '=', 0);
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1076 cutItem(line, param, '=', 1);
33075
c7cfa1a653c8 Cosmetic: Rename command item.
ib
parents: 33073
diff changeset
1077 strlower(item);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1078
33076
27999e9c1b3f Leave loop after item function has been found and called.
ib
parents: 33075
diff changeset
1079 for (i = 0; i < FF_ARRAY_ELEMS(skinItem); i++) {
27999e9c1b3f Leave loop after item function has been found and called.
ib
parents: 33075
diff changeset
1080 if (!strcmp(item, skinItem[i].name)) {
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1081 if (skinItem[i].func(param) != 0)
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1082 return -2;
33076
27999e9c1b3f Leave loop after item function has been found and called.
ib
parents: 33075
diff changeset
1083 else
27999e9c1b3f Leave loop after item function has been found and called.
ib
parents: 33075
diff changeset
1084 break;
27999e9c1b3f Leave loop after item function has been found and called.
ib
parents: 33075
diff changeset
1085 }
27999e9c1b3f Leave loop after item function has been found and called.
ib
parents: 33075
diff changeset
1086 }
33077
706f36627399 Add a check for unknown items.
ib
parents: 33076
diff changeset
1087
706f36627399 Add a check for unknown items.
ib
parents: 33076
diff changeset
1088 if (i == FF_ARRAY_ELEMS(skinItem)) {
706f36627399 Add a check for unknown items.
ib
parents: 33076
diff changeset
1089 skin_error(MSGTR_SKIN_UNKNOWN_ITEM, item);
706f36627399 Add a check for unknown items.
ib
parents: 33076
diff changeset
1090 return -2;
706f36627399 Add a check for unknown items.
ib
parents: 33076
diff changeset
1091 }
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1092 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1093
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1094 if (linenumber == 0) {
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1095 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotReadable, skinfname);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1096 return -1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1097 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1098
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1099 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1100 }