Mercurial > mplayer.hg
annotate gui/app.c @ 34768:47e03fa8a9d1
Use phrasing with infinitives in German translation of help_text.
author | ib |
---|---|
date | Sat, 14 Apr 2012 16:55:53 +0000 |
parents | ac6b38cd0d45 |
children | 411875efca3f |
rev | line source |
---|---|
26458 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
4 * MPlayer is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * MPlayer is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License along | |
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 */ | |
23077 | 18 |
34327 | 19 /** |
20 * @file | |
21 * @brief GUI application helpers | |
22 */ | |
23 | |
23077 | 24 #include "app.h" |
32983 | 25 #include "skin/font.h" |
32921 | 26 |
32944 | 27 #include "libavutil/common.h" |
28 | |
33979 | 29 /** |
30 * @brief Initialize item counters. | |
31 */ | |
33555 | 32 guiItems guiApp = { |
33 .IndexOfMainItems = -1, | |
34 .IndexOfPlaybarItems = -1, | |
35 .IndexOfMenuItems = -1 | |
33266 | 36 }; |
32897 | 37 |
33979 | 38 /** |
34327 | 39 * @brief Event messages belonging to event names. |
33979 | 40 */ |
32897 | 41 static const evName evNames[] = { |
42 { evNone, "evNone" }, | |
43 { evPlay, "evPlay" }, | |
44 { evStop, "evStop" }, | |
45 { evPause, "evPause" }, | |
46 { evPrev, "evPrev" }, | |
47 { evNext, "evNext" }, | |
48 { evLoad, "evLoad" }, | |
34317 | 49 { evLoadPlay, "evLoadPlay" }, |
50 { evLoadAudioFile, "evLoadAudioFile" }, | |
51 { evLoadSubtitle, "evLoadSubtitle" }, | |
52 { evDropSubtitle, "evDropSubtitle" }, | |
34321
daebf766dea6
Cosmetic: Synchronize evPlaylist event and message names.
ib
parents:
34319
diff
changeset
|
53 { evPlaylist, "evPlaylist" }, |
34387 | 54 { evPlayCD, "evPlayCD" }, |
34317 | 55 { evPlayVCD, "evPlayVCD" }, |
56 { evPlayDVD, "evPlayDVD" }, | |
34324 | 57 { evLoadURL, "evSetURL" }, // legacy |
58 { evLoadURL, "evLoadURL" }, | |
34317 | 59 { evPlaySwitchToPause, "evPlaySwitchToPause" }, |
60 { evPauseSwitchToPlay, "evPauseSwitchToPlay" }, | |
32897 | 61 { evBackward10sec, "evBackward10sec" }, |
62 { evForward10sec, "evForward10sec" }, | |
63 { evBackward1min, "evBackward1min" }, | |
64 { evForward1min, "evForward1min" }, | |
65 { evBackward10min, "evBackward10min" }, | |
66 { evForward10min, "evForward10min" }, | |
34317 | 67 { evSetMoviePosition, "evSetMoviePosition" }, |
34319 | 68 { evHalfSize, "evHalfSize" }, |
34317 | 69 { evDoubleSize, "evDoubleSize" }, |
70 { evFullScreen, "evFullScreen" }, | |
71 { evNormalSize, "evNormalSize" }, | |
34322 | 72 { evSetAspect, "evSetAspect" }, |
32897 | 73 { evIncVolume, "evIncVolume" }, |
74 { evDecVolume, "evDecVolume" }, | |
34317 | 75 { evSetVolume, "evSetVolume" }, |
32897 | 76 { evMute, "evMute" }, |
34317 | 77 { evSetBalance, "evSetBalance" }, |
78 { evEqualizer, "evEqualizer" }, | |
79 { evAbout, "evAbout" }, | |
80 { evPreferences, "evPreferences" }, | |
81 { evSkinBrowser, "evSkinBrowser" }, | |
34458 | 82 { evMenu, "evMenu" }, |
34317 | 83 { evIconify, "evIconify" }, |
34326 | 84 { evExit, "evExit" } |
32897 | 85 }; |
23077 | 86 |
33979 | 87 /** |
88 * @brief Free all memory allocated to an item and set all its pointers to NULL. | |
89 * | |
90 * @param item item to be freed | |
91 */ | |
32898 | 92 static void appClearItem(wItem *item) |
23077 | 93 { |
32917
9949f3a123cf
Add new function bpFree() to free txSamples (bitmaps).
ib
parents:
32912
diff
changeset
|
94 bpFree(&item->Bitmap); |
32921 | 95 bpFree(&item->Mask); |
32947 | 96 free(item->label); |
97 free(item->text); | |
32946 | 98 memset(item, 0, sizeof(*item)); |
23077 | 99 } |
100 | |
33979 | 101 /** |
102 * @brief Free all memory allocated to all GUI items and reset all item counters. | |
103 */ | |
32932 | 104 void appFreeStruct(void) |
23077 | 105 { |
32897 | 106 int i; |
107 | |
33555 | 108 appClearItem(&guiApp.main); |
109 guiApp.mainDecoration = 0; | |
32929 | 110 |
34697 | 111 appClearItem(&guiApp.video); |
32929 | 112 |
33555 | 113 appClearItem(&guiApp.playbar); |
114 guiApp.playbarIsPresent = 0; | |
32929 | 115 |
33555 | 116 appClearItem(&guiApp.menu); |
117 appClearItem(&guiApp.menuSelected); | |
118 guiApp.menuIsPresent = 0; | |
32929 | 119 |
33555 | 120 for (i = 0; i <= guiApp.IndexOfMainItems; i++) |
121 appClearItem(&guiApp.mainItems[i]); | |
122 for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++) | |
123 appClearItem(&guiApp.playbarItems[i]); | |
124 for (i = 0; i <= guiApp.IndexOfMenuItems; i++) | |
125 appClearItem(&guiApp.menuItems[i]); | |
32897 | 126 |
33555 | 127 guiApp.IndexOfMainItems = -1; |
128 guiApp.IndexOfPlaybarItems = -1; | |
129 guiApp.IndexOfMenuItems = -1; | |
33266 | 130 |
32933 | 131 fntFreeFont(); |
23077 | 132 } |
133 | |
33979 | 134 /** |
135 * @brief Find the event belonging to an event name. | |
136 * | |
34328 | 137 * @param name event name |
33979 | 138 * |
139 * @return event >= 0 (ok) or -1 (not found) | |
140 */ | |
34328 | 141 int appFindMessage(const char *name) |
23077 | 142 { |
32944 | 143 unsigned int i; |
32897 | 144 |
32944 | 145 for (i = 0; i < FF_ARRAY_ELEMS(evNames); i++) |
34328 | 146 if (!strcmp(evNames[i].name, name)) |
32911 | 147 return evNames[i].message; |
32897 | 148 |
149 return -1; | |
23077 | 150 } |
151 | |
33979 | 152 /** |
34339 | 153 * @brief Find the item belonging to an event. |
154 * | |
155 * @param event event | |
156 * | |
157 * @return pointer to the item (ok) or NULL (not found) | |
158 */ | |
159 wItem *appFindItem(int event) | |
160 { | |
161 wItem *item; | |
162 int i, n; | |
163 | |
34697 | 164 if (guiApp.videoWindow.isFullScreen && guiApp.playbarIsPresent) { |
34339 | 165 item = guiApp.playbarItems; |
166 n = guiApp.IndexOfPlaybarItems; | |
167 } else { | |
168 item = guiApp.mainItems; | |
169 n = guiApp.IndexOfMainItems; | |
170 } | |
171 | |
172 for (i = 0; i <= n; i++) | |
173 if (item[i].message == event) | |
34353 | 174 return &item[i]; |
34339 | 175 |
176 return NULL; | |
177 } | |
178 | |
179 /** | |
33979 | 180 * @brief Modify the state (i.e. set a new value) to the item belonging to an event. |
181 * | |
182 * @param event event | |
183 * @param state new value | |
184 */ | |
32897 | 185 void btnModify(int event, float state) |
23077 | 186 { |
32897 | 187 int i; |
188 | |
33555 | 189 for (i = 0; i <= guiApp.IndexOfMainItems; i++) { |
190 if (guiApp.mainItems[i].message == event) { | |
191 switch (guiApp.mainItems[i].type) { | |
32897 | 192 case itButton: |
33555 | 193 guiApp.mainItems[i].pressed = (int)state; |
32897 | 194 break; |
23077 | 195 |
32897 | 196 case itPotmeter: |
197 case itVPotmeter: | |
198 case itHPotmeter: | |
32960 | 199 if (state < 0.0f) |
200 state = 0.0f; | |
201 if (state > 100.0f) | |
202 state = 100.0f; | |
33555 | 203 guiApp.mainItems[i].value = state; |
32897 | 204 break; |
205 } | |
206 } | |
207 } | |
208 | |
33555 | 209 for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++) { |
210 if (guiApp.playbarItems[i].message == event) { | |
211 switch (guiApp.playbarItems[i].type) { | |
32897 | 212 case itButton: |
33555 | 213 guiApp.playbarItems[i].pressed = (int)state; |
32897 | 214 break; |
215 | |
216 case itPotmeter: | |
217 case itVPotmeter: | |
218 case itHPotmeter: | |
32960 | 219 if (state < 0.0f) |
220 state = 0.0f; | |
221 if (state > 100.0f) | |
222 state = 100.0f; | |
33555 | 223 guiApp.playbarItems[i].value = state; |
32897 | 224 break; |
225 } | |
226 } | |
227 } | |
23077 | 228 } |
229 | |
33979 | 230 /** |
231 * @brief Set the @a pressed state (i.e. a new value) to the item belonging to an event. | |
232 * | |
233 * @param event event | |
234 * @param set new value | |
235 */ | |
32897 | 236 void btnSet(int event, int set) |
23077 | 237 { |
32897 | 238 int i; |
239 | |
33555 | 240 for (i = 0; i <= guiApp.IndexOfMainItems; i++) |
241 if (guiApp.mainItems[i].message == event) | |
242 guiApp.mainItems[i].pressed = set; | |
32897 | 243 |
33555 | 244 for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++) |
245 if (guiApp.playbarItems[i].message == event) | |
246 guiApp.playbarItems[i].pressed = set; | |
23077 | 247 } |