Mercurial > mplayer.hg
annotate gui/app.c @ 33495:52a393df8df8
Put code checking if at the EOS in a function.
author | cboesch |
---|---|
date | Sat, 11 Jun 2011 15:39:00 +0000 |
parents | f9d3084f2e95 |
children | c5a19bbeac2b |
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" | |
32897 | 20 |
32921 | 21 #include "interface.h" |
32983 | 22 #include "skin/font.h" |
32921 | 23 |
32944 | 24 #include "libavutil/common.h" |
25 | |
33266 | 26 guiItems appMPlayer = { |
33270 | 27 .IndexOfMainItems = -1, |
28 .IndexOfBarItems = -1, | |
29 .IndexOfMenuItems = -1 | |
33266 | 30 }; |
32897 | 31 |
32 static const evName evNames[] = { | |
33 { evNone, "evNone" }, | |
34 { evPlay, "evPlay" }, | |
35 { evStop, "evStop" }, | |
36 { evPause, "evPause" }, | |
37 { evPrev, "evPrev" }, | |
38 { evNext, "evNext" }, | |
39 { evLoad, "evLoad" }, | |
40 { evEqualizer, "evEqualizer" }, | |
41 { evPlayList, "evPlaylist" }, | |
42 { evExit, "evExit" }, | |
43 { evIconify, "evIconify" }, | |
44 { evIncBalance, "evIncBalance" }, // NOTE TO MYSELF: not all of these events | |
45 { evDecBalance, "evDecBalance" }, // are actually implemented, and update doc | |
46 { evFullScreen, "evFullScreen" }, | |
47 { evFName, "evFName" }, | |
48 { evMovieTime, "evMovieTime" }, | |
49 { evAbout, "evAbout" }, | |
50 { evLoadPlay, "evLoadPlay" }, | |
51 { evPreferences, "evPreferences" }, | |
52 { evSkinBrowser, "evSkinBrowser" }, | |
53 { evBackward10sec, "evBackward10sec" }, | |
54 { evForward10sec, "evForward10sec" }, | |
55 { evBackward1min, "evBackward1min" }, | |
56 { evForward1min, "evForward1min" }, | |
57 { evBackward10min, "evBackward10min" }, | |
58 { evForward10min, "evForward10min" }, | |
59 { evIncVolume, "evIncVolume" }, | |
60 { evDecVolume, "evDecVolume" }, | |
61 { evMute, "evMute" }, | |
62 { evIncAudioBufDelay, "evIncAudioBufDelay" }, | |
63 { evDecAudioBufDelay, "evDecAudioBufDelay" }, | |
64 { evPlaySwitchToPause, "evPlaySwitchToPause" }, | |
65 { evPauseSwitchToPlay, "evPauseSwitchToPlay" }, | |
66 { evNormalSize, "evHalfSize" }, | |
67 { evNormalSize, "evNormalSize" }, | |
68 { evDoubleSize, "evDoubleSize" }, | |
69 { evSetMoviePosition, "evSetMoviePosition" }, | |
70 { evSetVolume, "evSetVolume" }, | |
71 { evSetBalance, "evSetBalance" }, | |
72 { evHelp, "evHelp" }, | |
73 { evLoadSubtitle, "evLoadSubtitle" }, | |
74 { evPlayDVD, "evPlayDVD" }, | |
75 { evPlayVCD, "evPlayVCD" }, | |
76 { evSetURL, "evSetURL" }, | |
77 { evLoadAudioFile, "evLoadAudioFile" }, | |
78 { evDropSubtitle, "evDropSubtitle" }, | |
79 { evSetAspect, "evSetAspect" } | |
80 }; | |
23077 | 81 |
32898 | 82 static void appClearItem(wItem *item) |
23077 | 83 { |
32917
9949f3a123cf
Add new function bpFree() to free txSamples (bitmaps).
ib
parents:
32912
diff
changeset
|
84 bpFree(&item->Bitmap); |
32921 | 85 bpFree(&item->Mask); |
32947 | 86 free(item->label); |
87 free(item->text); | |
32946 | 88 memset(item, 0, sizeof(*item)); |
23077 | 89 } |
90 | |
32932 | 91 void appFreeStruct(void) |
23077 | 92 { |
32897 | 93 int i; |
94 | |
32929 | 95 appClearItem(&appMPlayer.main); |
96 appMPlayer.mainDecoration = 0; | |
97 | |
98 appClearItem(&appMPlayer.sub); | |
99 | |
100 appClearItem(&appMPlayer.bar); | |
101 appMPlayer.barIsPresent = 0; | |
102 | |
33084 | 103 appClearItem(&appMPlayer.menu); |
32929 | 104 appClearItem(&appMPlayer.menuSelected); |
105 appMPlayer.menuIsPresent = 0; | |
106 | |
32931
03b1051bed5c
Rename the 'NumberOf' members of the listItems structure.
ib
parents:
32930
diff
changeset
|
107 for (i = 0; i <= appMPlayer.IndexOfMainItems; i++) |
32926 | 108 appClearItem(&appMPlayer.mainItems[i]); |
32931
03b1051bed5c
Rename the 'NumberOf' members of the listItems structure.
ib
parents:
32930
diff
changeset
|
109 for (i = 0; i <= appMPlayer.IndexOfBarItems; i++) |
32926 | 110 appClearItem(&appMPlayer.barItems[i]); |
32931
03b1051bed5c
Rename the 'NumberOf' members of the listItems structure.
ib
parents:
32930
diff
changeset
|
111 for (i = 0; i <= appMPlayer.IndexOfMenuItems; i++) |
32926 | 112 appClearItem(&appMPlayer.menuItems[i]); |
32897 | 113 |
33266 | 114 appMPlayer.IndexOfMainItems = -1; |
115 appMPlayer.IndexOfBarItems = -1; | |
116 appMPlayer.IndexOfMenuItems = -1; | |
117 | |
32933 | 118 fntFreeFont(); |
23077 | 119 } |
120 | |
32897 | 121 int appFindMessage(unsigned char *str) |
23077 | 122 { |
32944 | 123 unsigned int i; |
32897 | 124 |
32944 | 125 for (i = 0; i < FF_ARRAY_ELEMS(evNames); i++) |
32897 | 126 if (!strcmp(evNames[i].name, str)) |
32911 | 127 return evNames[i].message; |
32897 | 128 |
129 return -1; | |
23077 | 130 } |
131 | |
32897 | 132 void btnModify(int event, float state) |
23077 | 133 { |
32897 | 134 int i; |
135 | |
32931
03b1051bed5c
Rename the 'NumberOf' members of the listItems structure.
ib
parents:
32930
diff
changeset
|
136 for (i = 0; i <= appMPlayer.IndexOfMainItems; i++) { |
32912 | 137 if (appMPlayer.mainItems[i].message == event) { |
138 switch (appMPlayer.mainItems[i].type) { | |
32897 | 139 case itButton: |
32912 | 140 appMPlayer.mainItems[i].pressed = (int)state; |
32897 | 141 break; |
23077 | 142 |
32897 | 143 case itPotmeter: |
144 case itVPotmeter: | |
145 case itHPotmeter: | |
32960 | 146 if (state < 0.0f) |
147 state = 0.0f; | |
148 if (state > 100.0f) | |
149 state = 100.0f; | |
32912 | 150 appMPlayer.mainItems[i].value = state; |
32897 | 151 break; |
152 } | |
153 } | |
154 } | |
155 | |
32931
03b1051bed5c
Rename the 'NumberOf' members of the listItems structure.
ib
parents:
32930
diff
changeset
|
156 for (i = 0; i <= appMPlayer.IndexOfBarItems; i++) { |
32911 | 157 if (appMPlayer.barItems[i].message == event) { |
32897 | 158 switch (appMPlayer.barItems[i].type) { |
159 case itButton: | |
160 appMPlayer.barItems[i].pressed = (int)state; | |
161 break; | |
162 | |
163 case itPotmeter: | |
164 case itVPotmeter: | |
165 case itHPotmeter: | |
32960 | 166 if (state < 0.0f) |
167 state = 0.0f; | |
168 if (state > 100.0f) | |
169 state = 100.0f; | |
32897 | 170 appMPlayer.barItems[i].value = state; |
171 break; | |
172 } | |
173 } | |
174 } | |
23077 | 175 } |
176 | |
32897 | 177 void btnSet(int event, int set) |
23077 | 178 { |
32897 | 179 int i; |
180 | |
33103 | 181 for (i = 0; i <= appMPlayer.IndexOfMainItems; i++) |
182 if (appMPlayer.mainItems[i].message == event) | |
32912 | 183 appMPlayer.mainItems[i].pressed = set; |
32897 | 184 |
33103 | 185 for (i = 0; i <= appMPlayer.IndexOfBarItems; i++) |
186 if (appMPlayer.barItems[i].message == event) | |
32897 | 187 appMPlayer.barItems[i].pressed = set; |
23077 | 188 } |