Mercurial > mplayer.hg
annotate gui/app.c @ 34326:d188b59d3fa4
Remove non-existing GUI user events.
There is no code for this events.
author | ib |
---|---|
date | Fri, 09 Dec 2011 11:42:25 +0000 |
parents | 58aaa0d8cc82 |
children | 4d4726efed3e |
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 |
19 #include "app.h" | |
32983 | 20 #include "skin/font.h" |
32921 | 21 |
32944 | 22 #include "libavutil/common.h" |
23 | |
33979 | 24 /** |
25 * @brief Initialize item counters. | |
26 */ | |
33555 | 27 guiItems guiApp = { |
28 .IndexOfMainItems = -1, | |
29 .IndexOfPlaybarItems = -1, | |
30 .IndexOfMenuItems = -1 | |
33266 | 31 }; |
32897 | 32 |
33979 | 33 /** |
34 * @brief Events belonging to event names. | |
35 */ | |
32897 | 36 static const evName evNames[] = { |
37 { evNone, "evNone" }, | |
38 { evPlay, "evPlay" }, | |
39 { evStop, "evStop" }, | |
40 { evPause, "evPause" }, | |
41 { evPrev, "evPrev" }, | |
42 { evNext, "evNext" }, | |
43 { evLoad, "evLoad" }, | |
34317 | 44 { evLoadPlay, "evLoadPlay" }, |
45 { evLoadAudioFile, "evLoadAudioFile" }, | |
46 { evLoadSubtitle, "evLoadSubtitle" }, | |
47 { evDropSubtitle, "evDropSubtitle" }, | |
34321
daebf766dea6
Cosmetic: Synchronize evPlaylist event and message names.
ib
parents:
34319
diff
changeset
|
48 { evPlaylist, "evPlaylist" }, |
34317 | 49 { evPlayVCD, "evPlayVCD" }, |
50 { evPlayDVD, "evPlayDVD" }, | |
34324 | 51 { evLoadURL, "evSetURL" }, // legacy |
52 { evLoadURL, "evLoadURL" }, | |
34317 | 53 { evPlaySwitchToPause, "evPlaySwitchToPause" }, |
54 { evPauseSwitchToPlay, "evPauseSwitchToPlay" }, | |
32897 | 55 { evBackward10sec, "evBackward10sec" }, |
56 { evForward10sec, "evForward10sec" }, | |
57 { evBackward1min, "evBackward1min" }, | |
58 { evForward1min, "evForward1min" }, | |
59 { evBackward10min, "evBackward10min" }, | |
60 { evForward10min, "evForward10min" }, | |
34317 | 61 { evSetMoviePosition, "evSetMoviePosition" }, |
34319 | 62 { evHalfSize, "evHalfSize" }, |
34317 | 63 { evDoubleSize, "evDoubleSize" }, |
64 { evFullScreen, "evFullScreen" }, | |
65 { evNormalSize, "evNormalSize" }, | |
34322 | 66 { evSetAspect, "evSetAspect" }, |
32897 | 67 { evIncVolume, "evIncVolume" }, |
68 { evDecVolume, "evDecVolume" }, | |
34317 | 69 { evSetVolume, "evSetVolume" }, |
32897 | 70 { evMute, "evMute" }, |
34317 | 71 { evSetBalance, "evSetBalance" }, |
72 { evEqualizer, "evEqualizer" }, | |
73 { evAbout, "evAbout" }, | |
74 { evPreferences, "evPreferences" }, | |
75 { evSkinBrowser, "evSkinBrowser" }, | |
76 { evIconify, "evIconify" }, | |
34326 | 77 { evExit, "evExit" } |
32897 | 78 }; |
23077 | 79 |
33979 | 80 /** |
81 * @brief Free all memory allocated to an item and set all its pointers to NULL. | |
82 * | |
83 * @param item item to be freed | |
84 */ | |
32898 | 85 static void appClearItem(wItem *item) |
23077 | 86 { |
32917
9949f3a123cf
Add new function bpFree() to free txSamples (bitmaps).
ib
parents:
32912
diff
changeset
|
87 bpFree(&item->Bitmap); |
32921 | 88 bpFree(&item->Mask); |
32947 | 89 free(item->label); |
90 free(item->text); | |
32946 | 91 memset(item, 0, sizeof(*item)); |
23077 | 92 } |
93 | |
33979 | 94 /** |
95 * @brief Free all memory allocated to all GUI items and reset all item counters. | |
96 */ | |
32932 | 97 void appFreeStruct(void) |
23077 | 98 { |
32897 | 99 int i; |
100 | |
33555 | 101 appClearItem(&guiApp.main); |
102 guiApp.mainDecoration = 0; | |
32929 | 103 |
33555 | 104 appClearItem(&guiApp.sub); |
32929 | 105 |
33555 | 106 appClearItem(&guiApp.playbar); |
107 guiApp.playbarIsPresent = 0; | |
32929 | 108 |
33555 | 109 appClearItem(&guiApp.menu); |
110 appClearItem(&guiApp.menuSelected); | |
111 guiApp.menuIsPresent = 0; | |
32929 | 112 |
33555 | 113 for (i = 0; i <= guiApp.IndexOfMainItems; i++) |
114 appClearItem(&guiApp.mainItems[i]); | |
115 for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++) | |
116 appClearItem(&guiApp.playbarItems[i]); | |
117 for (i = 0; i <= guiApp.IndexOfMenuItems; i++) | |
118 appClearItem(&guiApp.menuItems[i]); | |
32897 | 119 |
33555 | 120 guiApp.IndexOfMainItems = -1; |
121 guiApp.IndexOfPlaybarItems = -1; | |
122 guiApp.IndexOfMenuItems = -1; | |
33266 | 123 |
32933 | 124 fntFreeFont(); |
23077 | 125 } |
126 | |
33979 | 127 /** |
128 * @brief Find the event belonging to an event name. | |
129 * | |
130 * @param str event name | |
131 * | |
132 * @return event >= 0 (ok) or -1 (not found) | |
133 */ | |
32897 | 134 int appFindMessage(unsigned char *str) |
23077 | 135 { |
32944 | 136 unsigned int i; |
32897 | 137 |
32944 | 138 for (i = 0; i < FF_ARRAY_ELEMS(evNames); i++) |
32897 | 139 if (!strcmp(evNames[i].name, str)) |
32911 | 140 return evNames[i].message; |
32897 | 141 |
142 return -1; | |
23077 | 143 } |
144 | |
33979 | 145 /** |
146 * @brief Modify the state (i.e. set a new value) to the item belonging to an event. | |
147 * | |
148 * @param event event | |
149 * @param state new value | |
150 */ | |
32897 | 151 void btnModify(int event, float state) |
23077 | 152 { |
32897 | 153 int i; |
154 | |
33555 | 155 for (i = 0; i <= guiApp.IndexOfMainItems; i++) { |
156 if (guiApp.mainItems[i].message == event) { | |
157 switch (guiApp.mainItems[i].type) { | |
32897 | 158 case itButton: |
33555 | 159 guiApp.mainItems[i].pressed = (int)state; |
32897 | 160 break; |
23077 | 161 |
32897 | 162 case itPotmeter: |
163 case itVPotmeter: | |
164 case itHPotmeter: | |
32960 | 165 if (state < 0.0f) |
166 state = 0.0f; | |
167 if (state > 100.0f) | |
168 state = 100.0f; | |
33555 | 169 guiApp.mainItems[i].value = state; |
32897 | 170 break; |
171 } | |
172 } | |
173 } | |
174 | |
33555 | 175 for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++) { |
176 if (guiApp.playbarItems[i].message == event) { | |
177 switch (guiApp.playbarItems[i].type) { | |
32897 | 178 case itButton: |
33555 | 179 guiApp.playbarItems[i].pressed = (int)state; |
32897 | 180 break; |
181 | |
182 case itPotmeter: | |
183 case itVPotmeter: | |
184 case itHPotmeter: | |
32960 | 185 if (state < 0.0f) |
186 state = 0.0f; | |
187 if (state > 100.0f) | |
188 state = 100.0f; | |
33555 | 189 guiApp.playbarItems[i].value = state; |
32897 | 190 break; |
191 } | |
192 } | |
193 } | |
23077 | 194 } |
195 | |
33979 | 196 /** |
197 * @brief Set the @a pressed state (i.e. a new value) to the item belonging to an event. | |
198 * | |
199 * @param event event | |
200 * @param set new value | |
201 */ | |
32897 | 202 void btnSet(int event, int set) |
23077 | 203 { |
32897 | 204 int i; |
205 | |
33555 | 206 for (i = 0; i <= guiApp.IndexOfMainItems; i++) |
207 if (guiApp.mainItems[i].message == event) | |
208 guiApp.mainItems[i].pressed = set; | |
32897 | 209 |
33555 | 210 for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++) |
211 if (guiApp.playbarItems[i].message == event) | |
212 guiApp.playbarItems[i].pressed = set; | |
23077 | 213 } |