Mercurial > mplayer.hg
annotate gui/app.c @ 33115:c2da7b725fd8
Use appropriate data type uint32_t for 32 bpp bitmap data.
Don't use int. Besides, rename variable holding transparent color.
author | ib |
---|---|
date | Mon, 04 Apr 2011 13:02:56 +0000 |
parents | eabc2472e7eb |
children | f0c2a62e3e89 |
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; |
32897 | 144 break; |
23077 | 145 |
32897 | 146 case itPotmeter: |
147 case itVPotmeter: | |
148 case itHPotmeter: | |
32960 | 149 if (state < 0.0f) |
150 state = 0.0f; | |
151 if (state > 100.0f) | |
152 state = 100.0f; | |
32912 | 153 appMPlayer.mainItems[i].value = state; |
32897 | 154 break; |
155 } | |
156 } | |
157 } | |
158 | |
32931
03b1051bed5c
Rename the 'NumberOf' members of the listItems structure.
ib
parents:
32930
diff
changeset
|
159 for (i = 0; i <= appMPlayer.IndexOfBarItems; i++) { |
32911 | 160 if (appMPlayer.barItems[i].message == event) { |
32897 | 161 switch (appMPlayer.barItems[i].type) { |
162 case itButton: | |
163 appMPlayer.barItems[i].pressed = (int)state; | |
164 break; | |
165 | |
166 case itPotmeter: | |
167 case itVPotmeter: | |
168 case itHPotmeter: | |
32960 | 169 if (state < 0.0f) |
170 state = 0.0f; | |
171 if (state > 100.0f) | |
172 state = 100.0f; | |
32897 | 173 appMPlayer.barItems[i].value = state; |
174 break; | |
175 } | |
176 } | |
177 } | |
23077 | 178 } |
179 | |
32897 | 180 void btnSet(int event, int set) |
23077 | 181 { |
32897 | 182 int i; |
183 | |
33103 | 184 for (i = 0; i <= appMPlayer.IndexOfMainItems; i++) |
185 if (appMPlayer.mainItems[i].message == event) | |
32912 | 186 appMPlayer.mainItems[i].pressed = set; |
32897 | 187 |
33103 | 188 for (i = 0; i <= appMPlayer.IndexOfBarItems; i++) |
189 if (appMPlayer.barItems[i].message == event) | |
32897 | 190 appMPlayer.barItems[i].pressed = set; |
23077 | 191 } |