Mercurial > mplayer.hg
annotate gui/app.c @ 34042:89ad6c0928cf
Support act files with -demuxer lavf.
author | cehoyos |
---|---|
date | Sun, 25 Sep 2011 09:55:30 +0000 |
parents | 1c4a2554d46b |
children | e905a896243d |
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" }, | |
44 { evEqualizer, "evEqualizer" }, | |
45 { evPlayList, "evPlaylist" }, | |
46 { evExit, "evExit" }, | |
47 { evIconify, "evIconify" }, | |
48 { evIncBalance, "evIncBalance" }, // NOTE TO MYSELF: not all of these events | |
49 { evDecBalance, "evDecBalance" }, // are actually implemented, and update doc | |
50 { evFullScreen, "evFullScreen" }, | |
51 { evFName, "evFName" }, | |
52 { evMovieTime, "evMovieTime" }, | |
53 { evAbout, "evAbout" }, | |
54 { evLoadPlay, "evLoadPlay" }, | |
55 { evPreferences, "evPreferences" }, | |
56 { evSkinBrowser, "evSkinBrowser" }, | |
57 { evBackward10sec, "evBackward10sec" }, | |
58 { evForward10sec, "evForward10sec" }, | |
59 { evBackward1min, "evBackward1min" }, | |
60 { evForward1min, "evForward1min" }, | |
61 { evBackward10min, "evBackward10min" }, | |
62 { evForward10min, "evForward10min" }, | |
63 { evIncVolume, "evIncVolume" }, | |
64 { evDecVolume, "evDecVolume" }, | |
65 { evMute, "evMute" }, | |
66 { evIncAudioBufDelay, "evIncAudioBufDelay" }, | |
67 { evDecAudioBufDelay, "evDecAudioBufDelay" }, | |
68 { evPlaySwitchToPause, "evPlaySwitchToPause" }, | |
69 { evPauseSwitchToPlay, "evPauseSwitchToPlay" }, | |
70 { evNormalSize, "evHalfSize" }, | |
71 { evNormalSize, "evNormalSize" }, | |
72 { evDoubleSize, "evDoubleSize" }, | |
73 { evSetMoviePosition, "evSetMoviePosition" }, | |
74 { evSetVolume, "evSetVolume" }, | |
75 { evSetBalance, "evSetBalance" }, | |
76 { evHelp, "evHelp" }, | |
77 { evLoadSubtitle, "evLoadSubtitle" }, | |
78 { evPlayDVD, "evPlayDVD" }, | |
79 { evPlayVCD, "evPlayVCD" }, | |
80 { evSetURL, "evSetURL" }, | |
81 { evLoadAudioFile, "evLoadAudioFile" }, | |
82 { evDropSubtitle, "evDropSubtitle" }, | |
83 { evSetAspect, "evSetAspect" } | |
84 }; | |
23077 | 85 |
33979 | 86 /** |
87 * @brief Free all memory allocated to an item and set all its pointers to NULL. | |
88 * | |
89 * @param item item to be freed | |
90 */ | |
32898 | 91 static void appClearItem(wItem *item) |
23077 | 92 { |
32917
9949f3a123cf
Add new function bpFree() to free txSamples (bitmaps).
ib
parents:
32912
diff
changeset
|
93 bpFree(&item->Bitmap); |
32921 | 94 bpFree(&item->Mask); |
32947 | 95 free(item->label); |
96 free(item->text); | |
32946 | 97 memset(item, 0, sizeof(*item)); |
23077 | 98 } |
99 | |
33979 | 100 /** |
101 * @brief Free all memory allocated to all GUI items and reset all item counters. | |
102 */ | |
32932 | 103 void appFreeStruct(void) |
23077 | 104 { |
32897 | 105 int i; |
106 | |
33555 | 107 appClearItem(&guiApp.main); |
108 guiApp.mainDecoration = 0; | |
32929 | 109 |
33555 | 110 appClearItem(&guiApp.sub); |
32929 | 111 |
33555 | 112 appClearItem(&guiApp.playbar); |
113 guiApp.playbarIsPresent = 0; | |
32929 | 114 |
33555 | 115 appClearItem(&guiApp.menu); |
116 appClearItem(&guiApp.menuSelected); | |
117 guiApp.menuIsPresent = 0; | |
32929 | 118 |
33555 | 119 for (i = 0; i <= guiApp.IndexOfMainItems; i++) |
120 appClearItem(&guiApp.mainItems[i]); | |
121 for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++) | |
122 appClearItem(&guiApp.playbarItems[i]); | |
123 for (i = 0; i <= guiApp.IndexOfMenuItems; i++) | |
124 appClearItem(&guiApp.menuItems[i]); | |
32897 | 125 |
33555 | 126 guiApp.IndexOfMainItems = -1; |
127 guiApp.IndexOfPlaybarItems = -1; | |
128 guiApp.IndexOfMenuItems = -1; | |
33266 | 129 |
32933 | 130 fntFreeFont(); |
23077 | 131 } |
132 | |
33979 | 133 /** |
134 * @brief Find the event belonging to an event name. | |
135 * | |
136 * @param str event name | |
137 * | |
138 * @return event >= 0 (ok) or -1 (not found) | |
139 */ | |
32897 | 140 int appFindMessage(unsigned char *str) |
23077 | 141 { |
32944 | 142 unsigned int i; |
32897 | 143 |
32944 | 144 for (i = 0; i < FF_ARRAY_ELEMS(evNames); i++) |
32897 | 145 if (!strcmp(evNames[i].name, str)) |
32911 | 146 return evNames[i].message; |
32897 | 147 |
148 return -1; | |
23077 | 149 } |
150 | |
33979 | 151 /** |
152 * @brief Modify the state (i.e. set a new value) to the item belonging to an event. | |
153 * | |
154 * @param event event | |
155 * @param state new value | |
156 */ | |
32897 | 157 void btnModify(int event, float state) |
23077 | 158 { |
32897 | 159 int i; |
160 | |
33555 | 161 for (i = 0; i <= guiApp.IndexOfMainItems; i++) { |
162 if (guiApp.mainItems[i].message == event) { | |
163 switch (guiApp.mainItems[i].type) { | |
32897 | 164 case itButton: |
33555 | 165 guiApp.mainItems[i].pressed = (int)state; |
32897 | 166 break; |
23077 | 167 |
32897 | 168 case itPotmeter: |
169 case itVPotmeter: | |
170 case itHPotmeter: | |
32960 | 171 if (state < 0.0f) |
172 state = 0.0f; | |
173 if (state > 100.0f) | |
174 state = 100.0f; | |
33555 | 175 guiApp.mainItems[i].value = state; |
32897 | 176 break; |
177 } | |
178 } | |
179 } | |
180 | |
33555 | 181 for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++) { |
182 if (guiApp.playbarItems[i].message == event) { | |
183 switch (guiApp.playbarItems[i].type) { | |
32897 | 184 case itButton: |
33555 | 185 guiApp.playbarItems[i].pressed = (int)state; |
32897 | 186 break; |
187 | |
188 case itPotmeter: | |
189 case itVPotmeter: | |
190 case itHPotmeter: | |
32960 | 191 if (state < 0.0f) |
192 state = 0.0f; | |
193 if (state > 100.0f) | |
194 state = 100.0f; | |
33555 | 195 guiApp.playbarItems[i].value = state; |
32897 | 196 break; |
197 } | |
198 } | |
199 } | |
23077 | 200 } |
201 | |
33979 | 202 /** |
203 * @brief Set the @a pressed state (i.e. a new value) to the item belonging to an event. | |
204 * | |
205 * @param event event | |
206 * @param set new value | |
207 */ | |
32897 | 208 void btnSet(int event, int set) |
23077 | 209 { |
32897 | 210 int i; |
211 | |
33555 | 212 for (i = 0; i <= guiApp.IndexOfMainItems; i++) |
213 if (guiApp.mainItems[i].message == event) | |
214 guiApp.mainItems[i].pressed = set; | |
32897 | 215 |
33555 | 216 for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++) |
217 if (guiApp.playbarItems[i].message == event) | |
218 guiApp.playbarItems[i].pressed = set; | |
23077 | 219 } |