Mercurial > mplayer.hg
annotate gui/app/app.c @ 35605:71f19d352561
Fix bug with wrong video window size after end of fullscreen playback.
(This is a regression introduced in r35572.)
The normal size the window should have (media size or configured size)
depends on the current state of playback. In order to influence the
size, add a boolean parameter. This usually is True unless playback has
stopped.
author | ib |
---|---|
date | Wed, 19 Dec 2012 13:58:06 +0000 |
parents | ded4a8c2aa70 |
children | 6fd886ce32b9 |
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" |
35493 | 25 #include "gui.h" |
35525 | 26 #include "gui/skin/font.h" |
32921 | 27 |
32944 | 28 #include "libavutil/common.h" |
29 | |
33979 | 30 /** |
31 * @brief Initialize item counters. | |
32 */ | |
33555 | 33 guiItems guiApp = { |
34 .IndexOfMainItems = -1, | |
35 .IndexOfPlaybarItems = -1, | |
36 .IndexOfMenuItems = -1 | |
33266 | 37 }; |
32897 | 38 |
33979 | 39 /** |
34327 | 40 * @brief Event messages belonging to event names. |
33979 | 41 */ |
32897 | 42 static const evName evNames[] = { |
43 { evNone, "evNone" }, | |
44 { evPlay, "evPlay" }, | |
45 { evStop, "evStop" }, | |
46 { evPause, "evPause" }, | |
47 { evPrev, "evPrev" }, | |
48 { evNext, "evNext" }, | |
49 { evLoad, "evLoad" }, | |
34317 | 50 { evLoadPlay, "evLoadPlay" }, |
51 { evLoadAudioFile, "evLoadAudioFile" }, | |
52 { evLoadSubtitle, "evLoadSubtitle" }, | |
53 { evDropSubtitle, "evDropSubtitle" }, | |
34321
daebf766dea6
Cosmetic: Synchronize evPlaylist event and message names.
ib
parents:
34319
diff
changeset
|
54 { evPlaylist, "evPlaylist" }, |
34387 | 55 { evPlayCD, "evPlayCD" }, |
34317 | 56 { evPlayVCD, "evPlayVCD" }, |
57 { evPlayDVD, "evPlayDVD" }, | |
34324 | 58 { evLoadURL, "evSetURL" }, // legacy |
59 { evLoadURL, "evLoadURL" }, | |
34317 | 60 { evPlaySwitchToPause, "evPlaySwitchToPause" }, |
61 { evPauseSwitchToPlay, "evPauseSwitchToPlay" }, | |
32897 | 62 { evBackward10sec, "evBackward10sec" }, |
63 { evForward10sec, "evForward10sec" }, | |
64 { evBackward1min, "evBackward1min" }, | |
65 { evForward1min, "evForward1min" }, | |
66 { evBackward10min, "evBackward10min" }, | |
67 { evForward10min, "evForward10min" }, | |
34317 | 68 { evSetMoviePosition, "evSetMoviePosition" }, |
34319 | 69 { evHalfSize, "evHalfSize" }, |
34317 | 70 { evDoubleSize, "evDoubleSize" }, |
71 { evFullScreen, "evFullScreen" }, | |
72 { evNormalSize, "evNormalSize" }, | |
34322 | 73 { evSetAspect, "evSetAspect" }, |
32897 | 74 { evIncVolume, "evIncVolume" }, |
75 { evDecVolume, "evDecVolume" }, | |
34317 | 76 { evSetVolume, "evSetVolume" }, |
32897 | 77 { evMute, "evMute" }, |
34317 | 78 { evSetBalance, "evSetBalance" }, |
79 { evEqualizer, "evEqualizer" }, | |
80 { evAbout, "evAbout" }, | |
81 { evPreferences, "evPreferences" }, | |
82 { evSkinBrowser, "evSkinBrowser" }, | |
34458 | 83 { evMenu, "evMenu" }, |
34317 | 84 { evIconify, "evIconify" }, |
34326 | 85 { evExit, "evExit" } |
32897 | 86 }; |
23077 | 87 |
33979 | 88 /** |
89 * @brief Free all memory allocated to an item and set all its pointers to NULL. | |
90 * | |
91 * @param item item to be freed | |
92 */ | |
32898 | 93 static void appClearItem(wItem *item) |
23077 | 94 { |
32917
9949f3a123cf
Add new function bpFree() to free txSamples (bitmaps).
ib
parents:
32912
diff
changeset
|
95 bpFree(&item->Bitmap); |
32921 | 96 bpFree(&item->Mask); |
32947 | 97 free(item->label); |
98 free(item->text); | |
32946 | 99 memset(item, 0, sizeof(*item)); |
23077 | 100 } |
101 | |
33979 | 102 /** |
103 * @brief Free all memory allocated to all GUI items and reset all item counters. | |
104 */ | |
32932 | 105 void appFreeStruct(void) |
23077 | 106 { |
32897 | 107 int i; |
108 | |
33555 | 109 appClearItem(&guiApp.main); |
35493 | 110 guiApp.mainDecoration = False; |
32929 | 111 |
34697 | 112 appClearItem(&guiApp.video); |
32929 | 113 |
33555 | 114 appClearItem(&guiApp.playbar); |
35493 | 115 guiApp.playbarIsPresent = False; |
32929 | 116 |
33555 | 117 appClearItem(&guiApp.menu); |
118 appClearItem(&guiApp.menuSelected); | |
35493 | 119 guiApp.menuIsPresent = False; |
32929 | 120 |
33555 | 121 for (i = 0; i <= guiApp.IndexOfMainItems; i++) |
122 appClearItem(&guiApp.mainItems[i]); | |
123 for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++) | |
124 appClearItem(&guiApp.playbarItems[i]); | |
125 for (i = 0; i <= guiApp.IndexOfMenuItems; i++) | |
126 appClearItem(&guiApp.menuItems[i]); | |
32897 | 127 |
33555 | 128 guiApp.IndexOfMainItems = -1; |
129 guiApp.IndexOfPlaybarItems = -1; | |
130 guiApp.IndexOfMenuItems = -1; | |
33266 | 131 |
32933 | 132 fntFreeFont(); |
23077 | 133 } |
134 | |
33979 | 135 /** |
136 * @brief Find the event belonging to an event name. | |
137 * | |
34328 | 138 * @param name event name |
33979 | 139 * |
140 * @return event >= 0 (ok) or -1 (not found) | |
141 */ | |
34328 | 142 int appFindMessage(const char *name) |
23077 | 143 { |
32944 | 144 unsigned int i; |
32897 | 145 |
32944 | 146 for (i = 0; i < FF_ARRAY_ELEMS(evNames); i++) |
34328 | 147 if (!strcmp(evNames[i].name, name)) |
32911 | 148 return evNames[i].message; |
32897 | 149 |
150 return -1; | |
23077 | 151 } |
152 | |
33979 | 153 /** |
34339 | 154 * @brief Find the item belonging to an event. |
155 * | |
156 * @param event event | |
157 * | |
158 * @return pointer to the item (ok) or NULL (not found) | |
159 */ | |
160 wItem *appFindItem(int event) | |
161 { | |
162 wItem *item; | |
163 int i, n; | |
164 | |
34697 | 165 if (guiApp.videoWindow.isFullScreen && guiApp.playbarIsPresent) { |
34339 | 166 item = guiApp.playbarItems; |
167 n = guiApp.IndexOfPlaybarItems; | |
168 } else { | |
169 item = guiApp.mainItems; | |
170 n = guiApp.IndexOfMainItems; | |
171 } | |
172 | |
173 for (i = 0; i <= n; i++) | |
174 if (item[i].message == event) | |
34353 | 175 return &item[i]; |
34339 | 176 |
177 return NULL; | |
178 } | |
179 | |
180 /** | |
33979 | 181 * @brief Modify the state (i.e. set a new value) to the item belonging to an event. |
182 * | |
183 * @param event event | |
184 * @param state new value | |
185 */ | |
32897 | 186 void btnModify(int event, float state) |
23077 | 187 { |
32897 | 188 int i; |
189 | |
33555 | 190 for (i = 0; i <= guiApp.IndexOfMainItems; i++) { |
191 if (guiApp.mainItems[i].message == event) { | |
192 switch (guiApp.mainItems[i].type) { | |
32897 | 193 case itButton: |
35541 | 194 |
33555 | 195 guiApp.mainItems[i].pressed = (int)state; |
32897 | 196 break; |
23077 | 197 |
32897 | 198 case itPotmeter: |
199 case itVPotmeter: | |
200 case itHPotmeter: | |
35541 | 201 |
32960 | 202 if (state < 0.0f) |
203 state = 0.0f; | |
204 if (state > 100.0f) | |
205 state = 100.0f; | |
35541 | 206 |
33555 | 207 guiApp.mainItems[i].value = state; |
32897 | 208 break; |
209 } | |
210 } | |
211 } | |
212 | |
33555 | 213 for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++) { |
214 if (guiApp.playbarItems[i].message == event) { | |
215 switch (guiApp.playbarItems[i].type) { | |
32897 | 216 case itButton: |
35541 | 217 |
33555 | 218 guiApp.playbarItems[i].pressed = (int)state; |
32897 | 219 break; |
220 | |
221 case itPotmeter: | |
222 case itVPotmeter: | |
223 case itHPotmeter: | |
35541 | 224 |
32960 | 225 if (state < 0.0f) |
226 state = 0.0f; | |
227 if (state > 100.0f) | |
228 state = 100.0f; | |
35541 | 229 |
33555 | 230 guiApp.playbarItems[i].value = state; |
32897 | 231 break; |
232 } | |
233 } | |
234 } | |
23077 | 235 } |
236 | |
33979 | 237 /** |
238 * @brief Set the @a pressed state (i.e. a new value) to the item belonging to an event. | |
239 * | |
240 * @param event event | |
241 * @param set new value | |
242 */ | |
32897 | 243 void btnSet(int event, int set) |
23077 | 244 { |
32897 | 245 int i; |
246 | |
33555 | 247 for (i = 0; i <= guiApp.IndexOfMainItems; i++) |
248 if (guiApp.mainItems[i].message == event) | |
249 guiApp.mainItems[i].pressed = set; | |
32897 | 250 |
33555 | 251 for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++) |
252 if (guiApp.playbarItems[i].message == event) | |
253 guiApp.playbarItems[i].pressed = set; | |
23077 | 254 } |