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