annotate gui/skin/skin.c @ 37082:9e3b2b71a146

Remove pointless statement. The 'menu' item doesn't have an image, so no need to care about Bitmap.Image.
author ib
date Sat, 26 Apr 2014 16:30:54 +0000
parents b28b632efeef
children
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
37053
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
24 #include <math.h>
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
25 #include <stdio.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
26 #include <string.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
27
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
28 #include "skin.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
29 #include "font.h"
36032
c667e34fb941 Cosmetic: Rearrange #includes.
ib
parents: 35786
diff changeset
30 #include "gui/interface.h"
35525
e27855a45128 Rebuild GUI directory structure.
ib
parents: 35493
diff changeset
31 #include "gui/app/app.h"
e27855a45128 Rebuild GUI directory structure.
ib
parents: 35493
diff changeset
32 #include "gui/app/gui.h"
35529
8ad4d2fb46e8 Rebuild GUI directory structure.
ib
parents: 35525
diff changeset
33 #include "gui/dialog/dialog.h"
37024
0790f864cea2 Add a file for miscellaneous auxiliary functions.
ib
parents: 37020
diff changeset
34 #include "gui/util/misc.h"
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents: 33046
diff changeset
35 #include "gui/util/string.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
36
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
37 #include "help_mp.h"
36032
c667e34fb941 Cosmetic: Rearrange #includes.
ib
parents: 35786
diff changeset
38 #include "mp_msg.h"
37053
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
39 #include "libavutil/attributes.h"
23703
9fb716ab06a3 Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents: 23077
diff changeset
40 #include "libavutil/avstring.h"
32944
27a98940e3aa Use FF_ARRAY_ELEMS() rather than a separate constant.
ib
parents: 32937
diff changeset
41 #include "libavutil/common.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
42
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
43 typedef struct {
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
44 const char *name;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
45 int (*func)(char *in);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
46 } _item;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
47
33749
d8f49edf8f25 Remove skin related variables from interface.[ch].
ib
parents: 33556
diff changeset
48 char *skinDirInHome;
36043
40c13df3d953 Cosmetic: Rename variables (consistently).
ib
parents: 36032
diff changeset
49 char *skinDirInData;
33749
d8f49edf8f25 Remove skin related variables from interface.[ch].
ib
parents: 33556
diff changeset
50
32937
3c57056637cc Cosmetic: Rename listItems structure.
ib
parents: 32933
diff changeset
51 static guiItems *skin;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
52
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
53 static int linenumber;
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
54 static unsigned char currItem[32];
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
55 static unsigned char path[512];
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
56
32980
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
57 static unsigned char currWinName[32];
35688
6fd886ce32b9 Cosmetic: Rename wItem guiItem.
ib
parents: 35662
diff changeset
58 static guiItem *currWin;
32980
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
59 static int *currWinItemIdx;
35688
6fd886ce32b9 Cosmetic: Rename wItem guiItem.
ib
parents: 35662
diff changeset
60 static guiItem *currWinItems;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
61
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
62 /**
36891
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
63 * @brief Print a legacy information on an entry.
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
64 *
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
65 * @param old identifier (and deprecated entry)
37065
b28b632efeef Cosmetic: Revise a few comments.
ib
parents: 37053
diff changeset
66 * @param data string necessary for checking and to print the information on @a old
36891
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
67 */
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
68 static void skin_legacy(const char *old, const char *data)
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
69 {
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
70 const char *p;
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
71
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
72 if (strcmp(old, "fontid") == 0) {
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
73 p = strchr(data, ',');
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
74
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
75 if (p)
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
76 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, p, "font = fontfile");
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
77 } else if (strcmp(old, "$l") == 0) {
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
78 p = strstr(old, data);
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
79
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
80 if (p && (p == data || p[-1] != '$'))
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
81 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, "$p");
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
82 } else if (strcmp(old, "evSetURL") == 0 && strcmp(data, old) == 0)
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
83 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, "evLoadURL");
36892
f50427ad9ff6 Internally map item 'potmeter' onto 'hpotmeter'.
ib
parents: 36891
diff changeset
84 else if (strcmp(old, "sub") == 0 || strcmp(old, "potmeter") == 0)
36891
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
85 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, data);
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
86 }
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
87
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
88 /**
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
89 * @brief Display a skin error message.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
90 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
91 * @param format format string
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
92 * @param ... arguments
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
93 */
33022
9abc0dbd6314 Cosmetic: Rename ERRORMESSAGE() skin_error().
ib
parents: 32980
diff changeset
94 static void skin_error(const char *format, ...)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
95 {
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
96 char p[512];
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
97 va_list ap;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
98
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
99 va_start(ap, format);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
100 vsnprintf(p, sizeof(p), format, ap);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
101 va_end(ap);
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
102
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
103 gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_GUI_MSG_SkinErrorMessage, linenumber, p);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
104 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
105
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
106 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
107 * @brief Check whether a @a section definition has started.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
108 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
109 * @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
110 *
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 35450
diff changeset
111 * @return #True (ok) or #False (error)
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
112 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
113 static int section_item(char *item)
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
114 {
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
115 if (!skin) {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
116 skin_error(MSGTR_GUI_MSG_SkinErrorSection, item);
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 35450
diff changeset
117 return False;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
118 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
119
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 35450
diff changeset
120 return True;
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
121 }
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
122
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
123 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
124 * @brief Check whether a @a window definition has started.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
125 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
126 * @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
127 *
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 35450
diff changeset
128 * @return #True (ok) or #False (error)
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
129 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
130 static int window_item(char *item)
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
131 {
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
132 if (!currWinName[0]) {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
133 skin_error(MSGTR_GUI_MSG_SkinErrorWindow, item);
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 35450
diff changeset
134 return False;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
135 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
136
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 35450
diff changeset
137 return True;
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
138 }
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
139
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
140 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
141 * @brief Check whether a specific @a window definition has started.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
142 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
143 * @param name name of the window to be checked
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
144 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
145 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
146 */
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
147 static int in_window(char *name)
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
148 {
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
149 if (strcmp(currWinName, name) == 0) {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
150 skin_error(MSGTR_GUI_MSG_SkinErrorItem, name);
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
151 return 1;
32873
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
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
154 return 0;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
155 }
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
156
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
157 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
158 * @brief Get next free item in current @a window.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
159 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
160 * @return pointer to next free item (ok) or NULL (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
161 */
35688
6fd886ce32b9 Cosmetic: Rename wItem guiItem.
ib
parents: 35662
diff changeset
162 static guiItem *next_item(void)
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
163 {
35688
6fd886ce32b9 Cosmetic: Rename wItem guiItem.
ib
parents: 35662
diff changeset
164 guiItem *item = NULL;
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
165
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
166 if (*currWinItemIdx < MAX_ITEMS - 1) {
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
167 (*currWinItemIdx)++;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
168 item = &currWinItems[*currWinItemIdx];
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
169 } else
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
170 skin_error(MSGTR_GUI_MSG_SkinTooManyItems);
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
171
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
172 return item;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
173 }
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
174
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
175 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
176 * @brief Parse a @a section definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
177 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
178 * Syntax: section=movieplayer
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 * @param in definition to be analyzed
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 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
183 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
184 static int item_section(char *in)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
185 {
33064
33d307c4430c Add error check.
ib
parents: 33063
diff changeset
186 if (skin) {
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
187 skin_error(MSGTR_GUI_MSG_SkinErrorItem, currItem);
33064
33d307c4430c Add error check.
ib
parents: 33063
diff changeset
188 return 1;
33d307c4430c Add error check.
ib
parents: 33063
diff changeset
189 }
33d307c4430c Add error check.
ib
parents: 33063
diff changeset
190
33055
2be86f1db767 Make use of return value of strlower().
ib
parents: 33054
diff changeset
191 if (!strcmp(strlower(in), "movieplayer"))
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33357
diff changeset
192 skin = &guiApp;
33067
2d0058f30a6b Issue error message in case of wrong section name.
ib
parents: 33066
diff changeset
193 else {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
194 skin_error(MSGTR_GUI_MSG_SkinUnknownName, in);
33067
2d0058f30a6b Issue error message in case of wrong section name.
ib
parents: 33066
diff changeset
195 return 1;
2d0058f30a6b Issue error message in case of wrong section name.
ib
parents: 33066
diff changeset
196 }
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
197
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
198 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s: %s\n", currItem, in);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
199
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
200 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
201 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
202
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
203 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
204 * @brief Parse an @a end definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
205 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
206 * Syntax: end
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 * @param in definition to be analyzed
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 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
211 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
212 static int item_end(char *in)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
213 {
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
214 char *space, *name;
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
215
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33972
diff changeset
216 (void)in;
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33972
diff changeset
217
32980
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
218 if (currWinName[0]) {
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
219 space = " ";
32980
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
220 name = currWinName;
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
221 } else {
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
222 space = "";
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
223 name = "section";
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
224 }
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
225
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
226 if (!section_item(currItem))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
227 return 1;
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
228
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
229 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s%s (%s)\n", space, currItem, name);
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
230
32980
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
231 if (currWinName[0]) {
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
232 currWinName[0] = 0;
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
233 currWin = NULL;
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
234 currWinItemIdx = NULL;
2bfd000bb789 Cosmetic: Rename pointers handling current window and items.
ib
parents: 32979
diff changeset
235 currWinItems = NULL;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
236 } else
32937
3c57056637cc Cosmetic: Rename listItems structure.
ib
parents: 32933
diff changeset
237 skin = NULL;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
238
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
239 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
240 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
241
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
242 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
243 * @brief Parse a @a window definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
244 *
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34578
diff changeset
245 * Syntax: window=main|video|playbar|menu
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
246 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
247 * @param in definition to be analyzed
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 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
250 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
251 static int item_window(char *in)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
252 {
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
253 if (!section_item(currItem))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
254 return 1;
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
255
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
256 if (currWinName[0]) {
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
257 skin_error(MSGTR_GUI_MSG_SkinErrorItem, currItem);
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
258 return 1;
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
259 }
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
260
33083
8c96263e0f09 Clean up cmd_window().
ib
parents: 33081
diff changeset
261 strlower(in);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
262
36891
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
263 // legacy
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
264 if (strcmp(in, "sub") == 0) {
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
265 strcpy(in, "video");
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
266 skin_legacy("sub", in);
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
267 }
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34578
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;
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34578
diff changeset
273 } else if (strcmp(in, "video") == 0) {
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34578
diff changeset
274 currWin = &skin->video;
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 {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
286 skin_error(MSGTR_GUI_MSG_SkinUnknownName, 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
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
292 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s: %s\n", currItem, 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];
37051
1468239c0fe3 Remove pointless initialization.
ib
parents: 37050
diff changeset
310 int x, y, w, h;
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34578
diff changeset
311 int is_video, is_bar, is_menu;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
312
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
313 if (!window_item(currItem))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
314 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
315
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34578
diff changeset
316 is_video = (strcmp(currWinName, "video") == 0);
34698
456784c6c904 Cosmetic: Adjust indent.
ib
parents: 34697
diff changeset
317 is_bar = (strcmp(currWinName, "playbar") == 0);
456784c6c904 Cosmetic: Adjust indent.
ib
parents: 34697
diff changeset
318 is_menu = (strcmp(currWinName, "menu") == 0);
33104
65827197d1af Simplify cmd_base().
ib
parents: 33103
diff changeset
319
36991
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
320 cutStr(in, fname, ',', 0);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
321 x = cutInt(in, ',', 1);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
322 y = cutInt(in, ',', 2);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
323 w = cutInt(in, ',', 3);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
324 h = cutInt(in, ',', 4);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
325
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33972
diff changeset
326 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image: %s", fname);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
327
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
328 currWin->type = itBase;
33104
65827197d1af Simplify cmd_base().
ib
parents: 33103
diff changeset
329
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
330 if (!is_menu) {
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
331 currWin->x = x;
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
332 currWin->y = y;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
333
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33972
diff changeset
334 mp_msg(MSGT_GPLAYER, MSGL_DBG2, " %d,%d", x, y);
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
335 }
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
336
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33972
diff changeset
337 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "\n");
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
338
35785
24b744af09a7 Allow video window without image displayed in it.
ib
parents: 35784
diff changeset
339 if (is_video && (strcmp(fname, "NULL") == 0)) {
24b744af09a7 Allow video window without image displayed in it.
ib
parents: 35784
diff changeset
340 currWin->width = 0;
24b744af09a7 Allow video window without image displayed in it.
ib
parents: 35784
diff changeset
341 currWin->height = 0;
24b744af09a7 Allow video window without image displayed in it.
ib
parents: 35784
diff changeset
342 } else {
35786
21d852a58d32 Cosmetic: Adjust indent.
ib
parents: 35785
diff changeset
343 av_strlcpy(file, path, sizeof(file));
21d852a58d32 Cosmetic: Adjust indent.
ib
parents: 35785
diff changeset
344 av_strlcat(file, fname, sizeof(file));
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
345
35786
21d852a58d32 Cosmetic: Adjust indent.
ib
parents: 35785
diff changeset
346 if (skinImageRead(file, &currWin->Bitmap) != 0)
21d852a58d32 Cosmetic: Adjust indent.
ib
parents: 35785
diff changeset
347 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
348
35786
21d852a58d32 Cosmetic: Adjust indent.
ib
parents: 35785
diff changeset
349 currWin->width = currWin->Bitmap.Width;
21d852a58d32 Cosmetic: Adjust indent.
ib
parents: 35785
diff changeset
350 currWin->height = currWin->Bitmap.Height;
35785
24b744af09a7 Allow video window without image displayed in it.
ib
parents: 35784
diff changeset
351 }
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
352
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34578
diff changeset
353 if (is_video) {
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
354 if (w && h) {
33096
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
355 currWin->width = w;
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
356 currWin->height = h;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
357 }
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
358 }
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
359
35785
24b744af09a7 Allow video window without image displayed in it.
ib
parents: 35784
diff changeset
360 if (currWin->width == 0 || currWin->height == 0)
24b744af09a7 Allow video window without image displayed in it.
ib
parents: 35784
diff changeset
361 return 1;
24b744af09a7 Allow video window without image displayed in it.
ib
parents: 35784
diff changeset
362
36975
91f11a849d4d Remove unnecessary, bothering parentheses.
ib
parents: 36920
diff changeset
363 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s: %dx%d\n", is_video && w && h ? "size" : " bitmap", currWin->width, currWin->height);
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
364
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34578
diff changeset
365 if (!is_video) {
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33357
diff changeset
366 if (!bpRenderMask(&currWin->Bitmap, &currWin->Mask)) {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
367 skin_error(MSGTR_GUI_MSG_SkinMemoryError);
33114
5ad451a5ebec Remove useless warning message.
ib
parents: 33106
diff changeset
368 return 1;
5ad451a5ebec Remove useless warning message.
ib
parents: 33106
diff changeset
369 }
36996
a17b55521dd2 Don't use data type long.
ib
parents: 36991
diff changeset
370 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] mask: %ux%u\n", currWin->Mask.Width, currWin->Mask.Height);
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
371 }
33101
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
372
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
373 if (is_bar)
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 35450
diff changeset
374 skin->playbarIsPresent = True;
33105
1cd1adf9ee6c Cosmetic: Adjust indent after simplifying cmd_base().
ib
parents: 33104
diff changeset
375 if (is_menu)
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 35450
diff changeset
376 skin->menuIsPresent = True;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27377
diff changeset
377
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
378 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
379 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
380
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
381 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
382 * @brief Parse a @a background definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
383 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
384 * Syntax: background=R,G,B
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
385 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
386 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
387 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
388 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
389 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
390 static int item_background(char *in)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
391 {
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
392 if (!window_item(currItem))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
393 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
394
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
395 if (in_window("main"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
396 return 1;
33088
babdacb1ceac Disable background definition for playbar.
ib
parents: 33087
diff changeset
397 if (in_window("playbar"))
babdacb1ceac Disable background definition for playbar.
ib
parents: 33087
diff changeset
398 return 1;
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
399 if (in_window("menu"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
400 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
401
36991
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
402 currWin->R = cutInt(in, ',', 0);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
403 currWin->G = cutInt(in, ',', 1);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
404 currWin->B = cutInt(in, ',', 2);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
405
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
406 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s color: #%02x%02x%02x\n", currItem, currWin->R, currWin->G, currWin->B);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
407
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
408 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
409 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
410
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
411 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
412 * @brief Parse a @a button definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
413 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
414 * Syntax: button=image,x,y,width,height,message
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
415 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
416 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
417 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
418 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
419 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
420 static int item_button(char *in)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
421 {
33090
db699b367260 Reduce resp. increase arrays to reasonable size.
ib
parents: 33089
diff changeset
422 unsigned char fname[256];
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
423 unsigned char file[512];
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
424 int x, y, w, h, message;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
425 char msg[32];
35688
6fd886ce32b9 Cosmetic: Rename wItem guiItem.
ib
parents: 35662
diff changeset
426 guiItem *item;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
427
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
428 if (!window_item(currItem))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
429 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
430
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34578
diff changeset
431 if (in_window("video"))
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
432 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
433 if (in_window("menu"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
434 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
435
36991
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
436 cutStr(in, fname, ',', 0);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
437 x = cutInt(in, ',', 1);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
438 y = cutInt(in, ',', 2);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
439 w = cutInt(in, ',', 3);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
440 h = cutInt(in, ',', 4);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
441 cutStr(in, msg, ',', 5);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
442
33071
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
443 message = appFindMessage(msg);
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
444
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
445 if (message == -1) {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
446 skin_error(MSGTR_GUI_MSG_SkinUnknownMessage, msg);
33071
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
447 return 1;
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
448 }
36891
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
449 // legacy
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
450 else
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
451 skin_legacy("evSetURL", msg);
33071
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
452
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
453 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s image: %s %d,%d\n", currItem, fname, x, y);
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33972
diff changeset
454 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, message);
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33972
diff changeset
455 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] size: %dx%d\n", w, h);
33102
de688a61e439 Move debug messages so that they will be processed earlier.
ib
parents: 33101
diff changeset
456
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
457 item = next_item();
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
458
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
459 if (!item)
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
460 return 1;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
461
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
462 item->type = itButton;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
463 item->x = x;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
464 item->y = y;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
465 item->width = w;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
466 item->height = h;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
467 item->message = message;
33101
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
468 item->pressed = btnReleased;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
469
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
470 if (item->message == evPauseSwitchToPlay)
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
471 item->pressed = btnDisabled;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
472
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
473 item->Bitmap.Image = NULL;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
474
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
475 if (strcmp(fname, "NULL") != 0) {
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
476 av_strlcpy(file, path, sizeof(file));
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
477 av_strlcat(file, fname, sizeof(file));
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
478
33969
9184bc37d4d5 Cosmetic: Rename skinBPRead() skinImageRead().
ib
parents: 33968
diff changeset
479 if (skinImageRead(file, &item->Bitmap) != 0)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
480 return 1;
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
481
36996
a17b55521dd2 Don't use data type long.
ib
parents: 36991
diff changeset
482 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %ux%u)\n", item->Bitmap.Width, item->Bitmap.Height);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
483 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
484
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
485 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
486 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
487
33968
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 * @brief Parse a @a selected definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
490 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
491 * Syntax: selected=image
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
492 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
493 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
494 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
495 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
496 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
497 static int item_selected(char *in)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
498 {
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
499 unsigned char file[512];
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
500 guiItem *item;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
501
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
502 if (!window_item(currItem))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
503 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
504
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
505 if (in_window("main"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
506 return 1;
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34578
diff changeset
507 if (in_window("video"))
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
508 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
509 if (in_window("playbar"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
510 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
511
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
512 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] image %s: %s\n", currItem, in);
33102
de688a61e439 Move debug messages so that they will be processed earlier.
ib
parents: 33101
diff changeset
513
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
514 item = &skin->menuSelected;
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
515 item->type = itBase;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
516
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
517 av_strlcpy(file, path, sizeof(file));
33091
6ce0b74d03b7 Remove needless variable.
ib
parents: 33090
diff changeset
518 av_strlcat(file, in, sizeof(file));
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
519
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
520 if (skinImageRead(file, &item->Bitmap) != 0)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
521 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
522
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
523 item->width = item->Bitmap.Width;
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
524 item->height = item->Bitmap.Height;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
525
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
526 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] bitmap: %dx%d\n", item->width, item->height);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
527
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
528 return 0;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
529 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27377
diff changeset
530
33968
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 * @brief Parse a @a menu definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
533 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
534 * Syntax: menu=x,y,width,height,message
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
535 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
536 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
537 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
538 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
539 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
540 static int item_menu(char *in)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
541 {
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
542 int x, y, w, h, message;
33071
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
543 char msg[32];
35688
6fd886ce32b9 Cosmetic: Rename wItem guiItem.
ib
parents: 35662
diff changeset
544 guiItem *item;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
545
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
546 if (!window_item(currItem))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
547 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
548
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
549 if (in_window("main"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
550 return 1;
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34578
diff changeset
551 if (in_window("video"))
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
552 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
553 if (in_window("playbar"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
554 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
555
36991
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
556 x = cutInt(in, ',', 0);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
557 y = cutInt(in, ',', 1);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
558 w = cutInt(in, ',', 2);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
559 h = cutInt(in, ',', 3);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
560 cutStr(in, msg, ',', 4);
33071
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
561
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
562 message = appFindMessage(msg);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
563
33071
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
564 if (message == -1) {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
565 skin_error(MSGTR_GUI_MSG_SkinUnknownMessage, msg);
33071
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
566 return 1;
f4895241bdd5 Conform message determination
ib
parents: 33069
diff changeset
567 }
36891
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
568 // legacy
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
569 else
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
570 skin_legacy("evSetURL", msg);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
571
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
572 item = next_item();
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
573
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
574 if (!item)
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
575 return 1;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
576
33100
35efac3ece2c Add an itMenu item type.
ib
parents: 33099
diff changeset
577 item->type = itMenu;
33096
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
578 item->x = x;
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
579 item->y = y;
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
580 item->width = w;
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
581 item->height = h;
ca1a01b56c90 Avoid using skin pointer.
ib
parents: 33095
diff changeset
582 item->message = message;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
583
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33972
diff changeset
584 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] item #%d: %d,%d %dx%d\n", *currWinItemIdx, x, y, w, h);
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33972
diff changeset
585 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", msg, message);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
586
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
587 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
588 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
589
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
590 /**
37053
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
591 * @brief Parse a hpotmeter, vpotmeter or rpotmeter definition.
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
592 *
37053
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
593 * Parameters: button,bwidth,bheight,phases,numphases,[x0,y0,x1,y1,]default,x,y,width,height,message
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
594 *
37065
b28b632efeef Cosmetic: Revise a few comments.
ib
parents: 37053
diff changeset
595 * @param item memory location of an item to store the parameters in
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
596 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
597 *
37053
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
598 * @note item->type is already available.
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
599 *
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
600 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
601 */
37027
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
602 static int parse_potmeter(guiItem *item, char *in)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
603 {
36999
aff78cadcc18 Cosmetic: Rename some variables.
ib
parents: 36996
diff changeset
604 unsigned char bfname[256];
33090
db699b367260 Reduce resp. increase arrays to reasonable size.
ib
parents: 33089
diff changeset
605 unsigned char phfname[256];
33093
3de646fca03b Cosmetic: Rearrange variable declarations to match parameters.
ib
parents: 33092
diff changeset
606 unsigned char buf[512];
37053
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
607 int i = 0, av_uninit(x0), av_uninit(y0), av_uninit(x1), av_uninit(y1);
36999
aff78cadcc18 Cosmetic: Rename some variables.
ib
parents: 36996
diff changeset
608 int bwidth, bheight, num, d, x, y, w, h, message;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
609
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
610 if (!window_item(currItem))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
611 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
612
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34578
diff changeset
613 if (in_window("video"))
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
614 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
615 if (in_window("menu"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
616 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
617
37053
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
618 cutStr(in, bfname, ',', i++);
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
619 bwidth = cutInt(in, ',', i++);
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
620 bheight = cutInt(in, ',', i++);
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
621 cutStr(in, phfname, ',', i++);
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
622 num = cutInt(in, ',', i++);
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
623
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
624 if (item->type == itRPotmeter) {
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
625 x0 = cutInt(in, ',', i++);
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
626 y0 = cutInt(in, ',', i++);
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
627 x1 = cutInt(in, ',', i++);
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
628 y1 = cutInt(in, ',', i++);
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
629 }
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
630
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
631 d = cutInt(in, ',', i++);
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
632 x = cutInt(in, ',', i++);
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
633 y = cutInt(in, ',', i++);
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
634 w = cutInt(in, ',', i++);
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
635 h = cutInt(in, ',', i++);
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
636 cutStr(in, buf, ',', i++);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
637
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
638 message = appFindMessage(buf);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
639
33069
4b7d4905862c Rename error message and add missing checks.
ib
parents: 33067
diff changeset
640 if (message == -1) {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
641 skin_error(MSGTR_GUI_MSG_SkinUnknownMessage, buf);
33069
4b7d4905862c Rename error message and add missing checks.
ib
parents: 33067
diff changeset
642 return 1;
4b7d4905862c Rename error message and add missing checks.
ib
parents: 33067
diff changeset
643 }
36891
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
644 // legacy
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
645 else
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
646 skin_legacy("evSetURL", buf);
33069
4b7d4905862c Rename error message and add missing checks.
ib
parents: 33067
diff changeset
647
37050
3555aa94b881 Relocate code added in r37121.
ib
parents: 37028
diff changeset
648 if (d < 0 || d > 100) {
3555aa94b881 Relocate code added in r37121.
ib
parents: 37028
diff changeset
649 skin_error(MSGTR_GUI_MSG_SkinErrorDefault, d);
3555aa94b881 Relocate code added in r37121.
ib
parents: 37028
diff changeset
650 return 1;
3555aa94b881 Relocate code added in r37121.
ib
parents: 37028
diff changeset
651 }
3555aa94b881 Relocate code added in r37121.
ib
parents: 37028
diff changeset
652
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
653 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s image: %s %d,%d %dx%d\n", currItem, phfname, x, y, w, h);
36999
aff78cadcc18 Cosmetic: Rename some variables.
ib
parents: 36996
diff changeset
654 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] button image: %s %dx%d\n", bfname, bwidth, bheight);
aff78cadcc18 Cosmetic: Rename some variables.
ib
parents: 36996
diff changeset
655 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", num, d);
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33972
diff changeset
656 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
657
33101
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
658 item->x = x;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
659 item->y = y;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
660 item->width = w;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
661 item->height = h;
37020
c840891d1be9 Rename guiItem's members pwidth and pheight.
ib
parents: 37001
diff changeset
662 item->pbwidth = bwidth;
c840891d1be9 Rename guiItem's members pwidth and pheight.
ib
parents: 37001
diff changeset
663 item->pbheight = bheight;
36999
aff78cadcc18 Cosmetic: Rename some variables.
ib
parents: 36996
diff changeset
664 item->numphases = num;
33101
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
665 item->value = (float)d;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
666 item->message = message;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
667 item->pressed = btnReleased;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
668
37053
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
669 if (item->type == itRPotmeter) {
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
670 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] start: %d,%d / stop: %d,%d\n", x0, y0, x1, y1);
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
671
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
672 item->zeropoint = appRadian(item, x0, y0);
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
673 item->arclength = appRadian(item, x1, y1) - item->zeropoint;
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
674
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
675 if (item->arclength < 0.0)
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
676 item->arclength += 2 * M_PI;
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
677 // else check if radians of (x0,y0) and (x1,y1) only differ below threshold
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
678 else if (item->arclength < 0.05)
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
679 item->arclength = 2 * M_PI;
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
680 }
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
681
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
682 item->Bitmap.Image = NULL;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
683
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
684 if (strcmp(phfname, "NULL") != 0) {
37001
64fabc358356 Check numphases.
ib
parents: 37000
diff changeset
685 if (num == 0) {
64fabc358356 Check numphases.
ib
parents: 37000
diff changeset
686 skin_error(MSGTR_GUI_MSG_SkinErrorNumphases);
64fabc358356 Check numphases.
ib
parents: 37000
diff changeset
687 return 1;
64fabc358356 Check numphases.
ib
parents: 37000
diff changeset
688 }
64fabc358356 Check numphases.
ib
parents: 37000
diff changeset
689
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
690 av_strlcpy(buf, path, sizeof(buf));
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
691 av_strlcat(buf, phfname, sizeof(buf));
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
692
33969
9184bc37d4d5 Cosmetic: Rename skinBPRead() skinImageRead().
ib
parents: 33968
diff changeset
693 if (skinImageRead(buf, &item->Bitmap) != 0)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
694 return 1;
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
695
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
696 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (%s bitmap: %ux%u)\n", currItem, item->Bitmap.Width, item->Bitmap.Height);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
697 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
698
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
699 item->Mask.Image = NULL;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
700
36999
aff78cadcc18 Cosmetic: Rename some variables.
ib
parents: 36996
diff changeset
701 if (strcmp(bfname, "NULL") != 0) {
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
702 av_strlcpy(buf, path, sizeof(buf));
36999
aff78cadcc18 Cosmetic: Rename some variables.
ib
parents: 36996
diff changeset
703 av_strlcat(buf, bfname, sizeof(buf));
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
704
33969
9184bc37d4d5 Cosmetic: Rename skinBPRead() skinImageRead().
ib
parents: 33968
diff changeset
705 if (skinImageRead(buf, &item->Mask) != 0)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
706 return 1;
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
707
36996
a17b55521dd2 Don't use data type long.
ib
parents: 36991
diff changeset
708 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (button bitmap: %ux%u)\n", item->Mask.Width, item->Mask.Height);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
709 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
710
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
711 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
712 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
713
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
714 /**
37027
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
715 * @brief Parse a @a hpotmeter definition.
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
716 *
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
717 * Syntax: hpotmeter=button,bwidth,bheight,phases,numphases,default,x,y,width,height,message
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
718 *
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
719 * @param in definition to be analyzed
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
720 *
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
721 * @return 0 (ok) or 1 (error)
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
722 */
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
723 static int item_hpotmeter(char *in)
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
724 {
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
725 guiItem *item;
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
726
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
727 item = next_item();
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
728
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
729 if (!item)
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
730 return 1;
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
731
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
732 item->type = itHPotmeter;
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
733
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
734 return parse_potmeter(item, in);
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
735 }
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
736
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
737 /**
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
738 * @brief Parse a @a vpotmeter definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
739 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
740 * 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
741 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
742 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
743 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
744 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
745 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
746 static int item_vpotmeter(char *in)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
747 {
35688
6fd886ce32b9 Cosmetic: Rename wItem guiItem.
ib
parents: 35662
diff changeset
748 guiItem *item;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
749
37027
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
750 item = next_item();
33056
1c2070f0abca Prevent a segmentation fault.
ib
parents: 33055
diff changeset
751
37027
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
752 if (!item)
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
753 return 1;
33053
f64d41dac10b Cosmetic: Separate return statement with newline.
ib
parents: 33052
diff changeset
754
37027
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
755 item->type = itVPotmeter;
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
756
c9d36530a55b Don't use item_hpotmeter() for vpotmeter parsing.
ib
parents: 37025
diff changeset
757 return parse_potmeter(item, in);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
758 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
759
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
760 /**
37053
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
761 * @brief Parse a @a rpotmeter definition.
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
762 *
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
763 * Syntax: rpotmeter=button,bwidth,bheight,phases,numphases,x0,y0,x1,y1,default,x,y,width,height,message
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
764 *
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
765 * @param in definition to be analyzed
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
766 *
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
767 * @return 0 (ok) or 1 (error)
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
768 */
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
769 static int item_rpotmeter(char *in)
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
770 {
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
771 guiItem *item;
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
772
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
773 item = next_item();
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
774
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
775 if (!item)
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
776 return 1;
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
777
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
778 item->type = itRPotmeter;
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
779
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
780 return parse_potmeter(item, in);
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
781 }
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
782
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
783 /**
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
784 * @brief Parse a @a potmeter definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
785 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
786 * Syntax: potmeter=phases,numphases,default,x,y,width,height,message
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
787 *
36920
40ad45360c8a Replace old item 'potmeter' by new item 'pimage'.
ib
parents: 36892
diff changeset
788 * @note THIS ITEM IS DEPRECATED.
40ad45360c8a Replace old item 'potmeter' by new item 'pimage'.
ib
parents: 36892
diff changeset
789 *
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
790 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
791 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
792 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
793 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
794 static int item_potmeter(char *in)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
795 {
36892
f50427ad9ff6 Internally map item 'potmeter' onto 'hpotmeter'.
ib
parents: 36891
diff changeset
796 char param[256];
f50427ad9ff6 Internally map item 'potmeter' onto 'hpotmeter'.
ib
parents: 36891
diff changeset
797
f50427ad9ff6 Internally map item 'potmeter' onto 'hpotmeter'.
ib
parents: 36891
diff changeset
798 // legacy
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
799 skin_legacy(currItem, "hpotmeter");
36892
f50427ad9ff6 Internally map item 'potmeter' onto 'hpotmeter'.
ib
parents: 36891
diff changeset
800
f50427ad9ff6 Internally map item 'potmeter' onto 'hpotmeter'.
ib
parents: 36891
diff changeset
801 snprintf(param, sizeof(param), "NULL,0,0,%s", in);
f50427ad9ff6 Internally map item 'potmeter' onto 'hpotmeter'.
ib
parents: 36891
diff changeset
802
f50427ad9ff6 Internally map item 'potmeter' onto 'hpotmeter'.
ib
parents: 36891
diff changeset
803 return item_hpotmeter(param);
36920
40ad45360c8a Replace old item 'potmeter' by new item 'pimage'.
ib
parents: 36892
diff changeset
804 }
40ad45360c8a Replace old item 'potmeter' by new item 'pimage'.
ib
parents: 36892
diff changeset
805
40ad45360c8a Replace old item 'potmeter' by new item 'pimage'.
ib
parents: 36892
diff changeset
806 /**
40ad45360c8a Replace old item 'potmeter' by new item 'pimage'.
ib
parents: 36892
diff changeset
807 * @brief Parse a @a pimage definition.
40ad45360c8a Replace old item 'potmeter' by new item 'pimage'.
ib
parents: 36892
diff changeset
808 *
40ad45360c8a Replace old item 'potmeter' by new item 'pimage'.
ib
parents: 36892
diff changeset
809 * Syntax: pimage=phases,numphases,default,x,y,width,height,message
40ad45360c8a Replace old item 'potmeter' by new item 'pimage'.
ib
parents: 36892
diff changeset
810 *
40ad45360c8a Replace old item 'potmeter' by new item 'pimage'.
ib
parents: 36892
diff changeset
811 * @param in definition to be analyzed
40ad45360c8a Replace old item 'potmeter' by new item 'pimage'.
ib
parents: 36892
diff changeset
812 *
40ad45360c8a Replace old item 'potmeter' by new item 'pimage'.
ib
parents: 36892
diff changeset
813 * @return 0 (ok) or 1 (error)
40ad45360c8a Replace old item 'potmeter' by new item 'pimage'.
ib
parents: 36892
diff changeset
814 */
40ad45360c8a Replace old item 'potmeter' by new item 'pimage'.
ib
parents: 36892
diff changeset
815 static int item_pimage(char *in)
40ad45360c8a Replace old item 'potmeter' by new item 'pimage'.
ib
parents: 36892
diff changeset
816 {
33093
3de646fca03b Cosmetic: Rearrange variable declarations to match parameters.
ib
parents: 33092
diff changeset
817 unsigned char phfname[256];
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
818 unsigned char buf[512];
36999
aff78cadcc18 Cosmetic: Rename some variables.
ib
parents: 36996
diff changeset
819 int num, d, x, y, w, h, message;
35688
6fd886ce32b9 Cosmetic: Rename wItem guiItem.
ib
parents: 35662
diff changeset
820 guiItem *item;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
821
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
822 if (!window_item(currItem))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
823 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
824
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34578
diff changeset
825 if (in_window("video"))
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
826 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
827 if (in_window("menu"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
828 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
829
36991
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
830 cutStr(in, phfname, ',', 0);
36999
aff78cadcc18 Cosmetic: Rename some variables.
ib
parents: 36996
diff changeset
831 num = cutInt(in, ',', 1);
37000
ea94ee043275 Cosmetic: Adjust indent.
ib
parents: 36999
diff changeset
832 d = cutInt(in, ',', 2);
ea94ee043275 Cosmetic: Adjust indent.
ib
parents: 36999
diff changeset
833 x = cutInt(in, ',', 3);
ea94ee043275 Cosmetic: Adjust indent.
ib
parents: 36999
diff changeset
834 y = cutInt(in, ',', 4);
ea94ee043275 Cosmetic: Adjust indent.
ib
parents: 36999
diff changeset
835 w = cutInt(in, ',', 5);
ea94ee043275 Cosmetic: Adjust indent.
ib
parents: 36999
diff changeset
836 h = cutInt(in, ',', 6);
36991
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
837 cutStr(in, buf, ',', 7);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
838
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
839 message = appFindMessage(buf);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
840
33069
4b7d4905862c Rename error message and add missing checks.
ib
parents: 33067
diff changeset
841 if (message == -1) {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
842 skin_error(MSGTR_GUI_MSG_SkinUnknownMessage, buf);
33069
4b7d4905862c Rename error message and add missing checks.
ib
parents: 33067
diff changeset
843 return 1;
4b7d4905862c Rename error message and add missing checks.
ib
parents: 33067
diff changeset
844 }
36891
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
845 // legacy
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
846 else
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
847 skin_legacy("evSetURL", buf);
33069
4b7d4905862c Rename error message and add missing checks.
ib
parents: 33067
diff changeset
848
37050
3555aa94b881 Relocate code added in r37121.
ib
parents: 37028
diff changeset
849 if (d < 0 || d > 100) {
3555aa94b881 Relocate code added in r37121.
ib
parents: 37028
diff changeset
850 skin_error(MSGTR_GUI_MSG_SkinErrorDefault, d);
3555aa94b881 Relocate code added in r37121.
ib
parents: 37028
diff changeset
851 return 1;
3555aa94b881 Relocate code added in r37121.
ib
parents: 37028
diff changeset
852 }
3555aa94b881 Relocate code added in r37121.
ib
parents: 37028
diff changeset
853
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
854 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s image: %s %d,%d %dx%d\n", currItem, phfname, x, y, w, h);
36999
aff78cadcc18 Cosmetic: Rename some variables.
ib
parents: 36996
diff changeset
855 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] numphases: %d, default: %d%%\n", num, d);
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33972
diff changeset
856 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] message: %s (#%d)\n", buf, message);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
857
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
858 item = next_item();
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
859
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
860 if (!item)
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
861 return 1;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
862
36920
40ad45360c8a Replace old item 'potmeter' by new item 'pimage'.
ib
parents: 36892
diff changeset
863 item->type = itPimage;
33101
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
864 item->x = x;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
865 item->y = y;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
866 item->width = w;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
867 item->height = h;
36999
aff78cadcc18 Cosmetic: Rename some variables.
ib
parents: 36996
diff changeset
868 item->numphases = num;
33101
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
869 item->value = (float)d;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
870 item->message = message;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
871
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
872 item->Bitmap.Image = NULL;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
873
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
874 if (strcmp(phfname, "NULL") != 0) {
37001
64fabc358356 Check numphases.
ib
parents: 37000
diff changeset
875 if (num == 0) {
64fabc358356 Check numphases.
ib
parents: 37000
diff changeset
876 skin_error(MSGTR_GUI_MSG_SkinErrorNumphases);
64fabc358356 Check numphases.
ib
parents: 37000
diff changeset
877 return 1;
64fabc358356 Check numphases.
ib
parents: 37000
diff changeset
878 }
64fabc358356 Check numphases.
ib
parents: 37000
diff changeset
879
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
880 av_strlcpy(buf, path, sizeof(buf));
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
881 av_strlcat(buf, phfname, sizeof(buf));
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
882
33969
9184bc37d4d5 Cosmetic: Rename skinBPRead() skinImageRead().
ib
parents: 33968
diff changeset
883 if (skinImageRead(buf, &item->Bitmap) != 0)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
884 return 1;
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
885
36996
a17b55521dd2 Don't use data type long.
ib
parents: 36991
diff changeset
886 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] (bitmap: %ux%u)\n", item->Bitmap.Width, item->Bitmap.Height);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
887 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
888
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
889 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
890 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
891
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
892 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
893 * @brief Parse a @a font definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
894 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
895 * Syntax: font=fontfile
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
896 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
897 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
898 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
899 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
900 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
901 static int item_font(char *in)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
902 {
33092
83052a4ac698 Use more appropriate name for variable and reduce it to reasonable size.
ib
parents: 33091
diff changeset
903 char fnt[256];
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
904
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
905 if (!window_item(currItem))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
906 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
907
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34578
diff changeset
908 if (in_window("video"))
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
909 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
910 if (in_window("menu"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
911 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
912
36991
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
913 cutStr(in, fnt, ',', 0); // Note: This seems needless but isn't for compatibility
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
914 // reasons with a meanwhile deprecated second parameter.
36891
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
915 // legacy
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
916 skin_legacy("fontid", in);
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
917
33099
0b17f6bed6fc Don't needlessly store font information in the wItems array
ib
parents: 33098
diff changeset
918 switch (fntRead(path, fnt)) {
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
919 case -1:
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
920 skin_error(MSGTR_GUI_MSG_SkinMemoryError);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
921 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
922
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
923 case -2:
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
924 skin_error(MSGTR_GUI_MSG_SkinTooManyFonts);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
925 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
926
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
927 case -3:
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
928 skin_error(MSGTR_GUI_MSG_SkinFontFileNotFound);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
929 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
930
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
931 case -4:
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
932 skin_error(MSGTR_GUI_MSG_SkinFontImageNotFound);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
933 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
934 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
935
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
936 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s: %s (#%d)\n", currItem, fnt, fntFindID(fnt));
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
937
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
938 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
939 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
940
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
941 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
942 * @brief Parse a @a slabel definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
943 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
944 * Syntax: slabel=x,y,fontfile,"text"
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
945 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
946 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
947 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
948 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
949 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
950 static int item_slabel(char *in)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
951 {
33094
2faf1c3ded5d Cosmetic: Rearrange variable declarations to match parameters.
ib
parents: 33093
diff changeset
952 int x, y, id;
33090
db699b367260 Reduce resp. increase arrays to reasonable size.
ib
parents: 33089
diff changeset
953 char fnt[256];
33094
2faf1c3ded5d Cosmetic: Rearrange variable declarations to match parameters.
ib
parents: 33093
diff changeset
954 char txt[256];
35688
6fd886ce32b9 Cosmetic: Rename wItem guiItem.
ib
parents: 35662
diff changeset
955 guiItem *item;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
956
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
957 if (!window_item(currItem))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
958 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
959
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34578
diff changeset
960 if (in_window("video"))
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
961 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
962 if (in_window("menu"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
963 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
964
36991
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
965 x = cutInt(in, ',', 0);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
966 y = cutInt(in, ',', 1);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
967 cutStr(in, fnt, ',', 2);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
968 cutStr(in, txt, ',', 3);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
969 cutStr(txt, txt, '"', 1);
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
970
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
971 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s: \"%s\"\n", currItem, txt);
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33972
diff changeset
972 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
973
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
974 id = fntFindID(fnt);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
975
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
976 if (id < 0) {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
977 skin_error(MSGTR_GUI_MSG_SkinFontNotFound, fnt);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
978 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
979 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
980
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33972
diff changeset
981 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
982
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
983 item = next_item();
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
984
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
985 if (!item)
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
986 return 1;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
987
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
988 item->type = itSLabel;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
989 item->x = x;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
990 item->y = y;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
991 item->width = -1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
992 item->height = -1;
33101
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
993 item->fontid = id;
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
994 item->label = strdup(txt);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
995
32979
4905f5a87357 Replace some awkward and unnecessary usages of strlen().
ib
parents: 32958
diff changeset
996 if (!item->label) {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
997 skin_error(MSGTR_GUI_MSG_SkinMemoryError);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
998 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
999 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1000
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1001 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1002 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1003
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1004 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1005 * @brief Parse a @a dlabel definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1006 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1007 * Syntax: dlabel=x,y,width,align,fontfile,"text"
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1008 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1009 * @param in definition to be analyzed
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 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1012 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1013 static int item_dlabel(char *in)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1014 {
33094
2faf1c3ded5d Cosmetic: Rearrange variable declarations to match parameters.
ib
parents: 33093
diff changeset
1015 int x, y, w, a, id;
33090
db699b367260 Reduce resp. increase arrays to reasonable size.
ib
parents: 33089
diff changeset
1016 char fnt[256];
33094
2faf1c3ded5d Cosmetic: Rearrange variable declarations to match parameters.
ib
parents: 33093
diff changeset
1017 char txt[256];
35688
6fd886ce32b9 Cosmetic: Rename wItem guiItem.
ib
parents: 35662
diff changeset
1018 guiItem *item;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1019
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
1020 if (!window_item(currItem))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
1021 return 1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1022
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34578
diff changeset
1023 if (in_window("video"))
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
1024 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
1025 if (in_window("menu"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
1026 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1027
36991
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
1028 x = cutInt(in, ',', 0);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
1029 y = cutInt(in, ',', 1);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
1030 w = cutInt(in, ',', 2);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
1031 a = cutInt(in, ',', 3);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
1032 cutStr(in, fnt, ',', 4);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
1033 cutStr(in, txt, ',', 5);
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
1034 cutStr(txt, txt, '"', 1);
32951
c11e65fcb818 Clean up debug messages.
ib
parents: 32950
diff changeset
1035
36891
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
1036 // legacy
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
1037 skin_legacy("$l", txt);
c5ee0fc2ec75 Print an information on deprecated skin config file entries.
ib
parents: 36876
diff changeset
1038
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
1039 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s: \"%s\"\n", currItem, txt);
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33972
diff changeset
1040 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y);
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33972
diff changeset
1041 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d, align: %d\n", w, a);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1042
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
1043 id = fntFindID(fnt);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1044
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1045 if (id < 0) {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
1046 skin_error(MSGTR_GUI_MSG_SkinFontNotFound, fnt);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1047 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1048 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1049
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33972
diff changeset
1050 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1051
33098
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
1052 item = next_item();
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
1053
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
1054 if (!item)
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
1055 return 1;
b61dff4c9a35 Prevent an out-of-bounds array access.
ib
parents: 33097
diff changeset
1056
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1057 item->type = itDLabel;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1058 item->x = x;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1059 item->y = y;
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
1060 item->width = w;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1061 item->height = -1;
33101
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
1062 item->fontid = id;
930338bde973 Order member assignments according to their definition in the structure.
ib
parents: 33100
diff changeset
1063 item->align = a;
33089
d22b498bb573 Cosmetic: Use more appropriate variable names.
ib
parents: 33088
diff changeset
1064 item->label = strdup(txt);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1065
32979
4905f5a87357 Replace some awkward and unnecessary usages of strlen().
ib
parents: 32958
diff changeset
1066 if (!item->label) {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
1067 skin_error(MSGTR_GUI_MSG_SkinMemoryError);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1068 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1069 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1070
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1071 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1072 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1073
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1074 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1075 * @brief Parse a @a decoration definition.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1076 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1077 * Syntax: decoration=enable|disable
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1078 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1079 * @param in definition to be analyzed
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1080 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1081 * @return 0 (ok) or 1 (error)
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1082 */
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1083 static int item_decoration(char *in)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1084 {
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
1085 if (!window_item(currItem))
33054
ed66afc0b06c Replace macros to check whether a command is allowed by functions.
ib
parents: 33053
diff changeset
1086 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1087
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34578
diff changeset
1088 if (in_window("video"))
33058
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
1089 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
1090 if (in_window("playbar"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
1091 return 1;
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
1092 if (in_window("menu"))
b8374f9dc87b Replace macro by function.
ib
parents: 33057
diff changeset
1093 return 1;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1094
33086
1b9f989855f3 Remove needless variable.
ib
parents: 33084
diff changeset
1095 strlower(in);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1096
33086
1b9f989855f3 Remove needless variable.
ib
parents: 33084
diff changeset
1097 if (strcmp(in, "enable") != 0 && strcmp(in, "disable") != 0) {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
1098 skin_error(MSGTR_GUI_MSG_SkinUnknownParameter, in);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1099 return 1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1100 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1101
33087
ca17f301336d Simplify parameter analysis.
ib
parents: 33086
diff changeset
1102 skin->mainDecoration = (strcmp(in, "enable") == 0);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1103
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
1104 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %s: %s\n", currItem, in);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1105
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1106 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1107 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1108
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1109 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1110 * @brief Parsing functions responsible for skin item definitions.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1111 */
32878
afa6f80b0867 Limit scope of internally used skinItem array.
ib
parents: 32877
diff changeset
1112 static _item skinItem[] = {
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1113 { "background", item_background },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1114 { "base", item_base },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1115 { "button", item_button },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1116 { "decoration", item_decoration },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1117 { "dlabel", item_dlabel },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1118 { "end", item_end },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1119 { "font", item_font },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1120 { "hpotmeter", item_hpotmeter },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1121 { "menu", item_menu },
36920
40ad45360c8a Replace old item 'potmeter' by new item 'pimage'.
ib
parents: 36892
diff changeset
1122 { "pimage", item_pimage },
36892
f50427ad9ff6 Internally map item 'potmeter' onto 'hpotmeter'.
ib
parents: 36891
diff changeset
1123 { "potmeter", item_potmeter }, // legacy
37053
84c93a60ead3 Add new item 'rpotmeter'.
ib
parents: 37051
diff changeset
1124 { "rpotmeter", item_rpotmeter },
33106
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1125 { "section", item_section },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1126 { "selected", item_selected },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1127 { "slabel", item_slabel },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1128 { "vpotmeter", item_vpotmeter },
e9e5ee3a1a82 Cosmetic: Rename cmd functions item.
ib
parents: 33105
diff changeset
1129 { "window", item_window }
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1130 };
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1131
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1132 /**
35662
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1133 * @brief Read a skin @a image file.
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1134 *
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1135 * @param fname filename (with path)
37065
b28b632efeef Cosmetic: Revise a few comments.
ib
parents: 37053
diff changeset
1136 * @param img memory location to store the image data
35662
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1137 *
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1138 * @return return code of #bpRead()
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1139 */
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1140 int skinImageRead(char *fname, guiImage *img)
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1141 {
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1142 int i = bpRead(fname, img);
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1143
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1144 switch (i) {
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1145 case -1:
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
1146 skin_error(MSGTR_GUI_MSG_SkinErrorBitmap16Bit, fname);
35662
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1147 break;
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1148
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1149 case -2:
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
1150 skin_error(MSGTR_GUI_MSG_SkinBitmapNotFound, fname);
35662
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1151 break;
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1152
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1153 case -5:
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
1154 skin_error(MSGTR_GUI_MSG_SkinBitmapPngReadError, fname);
35662
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1155 break;
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1156
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1157 case -8:
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
1158 skin_error(MSGTR_GUI_MSG_SkinBitmapConversionError, fname);
35662
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1159 break;
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1160 }
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1161
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1162 return i;
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1163 }
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1164
782461b26312 Relocate some functions.
ib
parents: 35529
diff changeset
1165 /**
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1166 * @brief Build the skin file path for a skin name.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1167 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1168 * @param dir skins directory
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1169 * @param sname name of the skin
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1170 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1171 * @return skin file path
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1172 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1173 * @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
1174 */
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1175 static char *setname(char *dir, char *sname)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1176 {
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1177 static char skinfname[512];
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1178
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1179 av_strlcpy(skinfname, dir, sizeof(skinfname));
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1180 av_strlcat(skinfname, "/", sizeof(skinfname));
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1181 av_strlcat(skinfname, sname, sizeof(skinfname));
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1182 av_strlcat(skinfname, "/", sizeof(skinfname));
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1183 av_strlcpy(path, skinfname, sizeof(path));
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1184 av_strlcat(skinfname, "skin", sizeof(skinfname));
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1185
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1186 return skinfname;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1187 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1188
33968
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1189 /**
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1190 * @brief Read and parse a skin.
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1191 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1192 * @param sname name of the skin
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1193 *
253620911a2e Add doxygen comments to skin.c.
ib
parents: 33749
diff changeset
1194 * @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
1195 */
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1196 int skinRead(char *sname)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1197 {
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1198 char *skinfname;
34578
948bec0f8df3 Cosmetic: Change some variable names.
ib
parents: 34560
diff changeset
1199 FILE *skinfile;
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1200 unsigned char line[256];
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1201 unsigned char param[256];
32944
27a98940e3aa Use FF_ARRAY_ELEMS() rather than a separate constant.
ib
parents: 32937
diff changeset
1202 unsigned int i;
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1203
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1204 skinfname = setname(skinDirInHome, sname);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1205
34578
948bec0f8df3 Cosmetic: Change some variable names.
ib
parents: 34560
diff changeset
1206 if ((skinfile = fopen(skinfname, "rt")) == NULL) {
36043
40c13df3d953 Cosmetic: Rename variables (consistently).
ib
parents: 36032
diff changeset
1207 skinfname = setname(skinDirInData, sname);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1208
34578
948bec0f8df3 Cosmetic: Change some variable names.
ib
parents: 34560
diff changeset
1209 if ((skinfile = fopen(skinfname, "rt")) == NULL) {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
1210 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_GUI_MSG_SkinFileNotFound, skinfname);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1211 return -1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1212 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1213 }
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1214
33985
d99f341d8442 Replace all mp_dbg() calls by mp_msg().
ib
parents: 33972
diff changeset
1215 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] configuration file: %s\n", skinfname);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1216
32932
e95ec1b2feea Cosmetic: Rename appInitStruct() to appFreeStruct().
ib
parents: 32931
diff changeset
1217 appFreeStruct();
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1218
33078
c84938655cf4 Reset skin pointer and window name.
ib
parents: 33077
diff changeset
1219 skin = NULL;
c84938655cf4 Reset skin pointer and window name.
ib
parents: 33077
diff changeset
1220 currWinName[0] = 0;
33079
25c467321c98 Cosmetic: Adjust indent.
ib
parents: 33078
diff changeset
1221 linenumber = 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1222
34578
948bec0f8df3 Cosmetic: Change some variable names.
ib
parents: 34560
diff changeset
1223 while (fgetstr(line, sizeof(line), skinfile)) {
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1224 linenumber++;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1225
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1226 strswap(line, '\t', ' ');
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1227 trim(line);
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1228 decomment(line);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1229
33081
d217fdc83e63 (Almost entirely) cosmetic: Use more appropriate variable names.
ib
parents: 33079
diff changeset
1230 if (!*line)
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1231 continue;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1232
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
1233 cutStr(line, currItem, '=', 0);
36991
fa8b6892b0bf Cosmetic: Rename cut functions.
ib
parents: 36989
diff changeset
1234 cutStr(line, param, '=', 1);
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
1235 strlower(currItem);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1236
33076
27999e9c1b3f Leave loop after item function has been found and called.
ib
parents: 33075
diff changeset
1237 for (i = 0; i < FF_ARRAY_ELEMS(skinItem); i++) {
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
1238 if (!strcmp(currItem, skinItem[i].name)) {
35360
a3e8af09792d Close the skin file after reading.
ib
parents: 34698
diff changeset
1239 if (skinItem[i].func(param) != 0) {
a3e8af09792d Close the skin file after reading.
ib
parents: 34698
diff changeset
1240 fclose(skinfile);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1241 return -2;
35360
a3e8af09792d Close the skin file after reading.
ib
parents: 34698
diff changeset
1242 } else
33076
27999e9c1b3f Leave loop after item function has been found and called.
ib
parents: 33075
diff changeset
1243 break;
27999e9c1b3f Leave loop after item function has been found and called.
ib
parents: 33075
diff changeset
1244 }
27999e9c1b3f Leave loop after item function has been found and called.
ib
parents: 33075
diff changeset
1245 }
33077
706f36627399 Add a check for unknown items.
ib
parents: 33076
diff changeset
1246
706f36627399 Add a check for unknown items.
ib
parents: 33076
diff changeset
1247 if (i == FF_ARRAY_ELEMS(skinItem)) {
37028
7694f4226420 Make the current item string as currItem global.
ib
parents: 37027
diff changeset
1248 skin_error(MSGTR_GUI_MSG_SkinUnknownItem, currItem);
35360
a3e8af09792d Close the skin file after reading.
ib
parents: 34698
diff changeset
1249 fclose(skinfile);
33077
706f36627399 Add a check for unknown items.
ib
parents: 33076
diff changeset
1250 return -2;
706f36627399 Add a check for unknown items.
ib
parents: 33076
diff changeset
1251 }
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1252 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1253
35360
a3e8af09792d Close the skin file after reading.
ib
parents: 34698
diff changeset
1254 fclose(skinfile);
a3e8af09792d Close the skin file after reading.
ib
parents: 34698
diff changeset
1255
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1256 if (linenumber == 0) {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 36043
diff changeset
1257 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_GUI_MSG_SkinFileNotReadable, skinfname);
32873
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1258 return -1;
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1259 }
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1260
cf385b1901cb Cosmetic: Format to MPlayer coding style.
ib
parents: 32856
diff changeset
1261 return 0;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1262 }