annotate gui/app/app.c @ 36859:9bc711c42ea6

Update documentation. This is missing in r36954.
author ib
date Fri, 28 Feb 2014 14:20:52 +0000
parents bb067298265a
children d66aef85ae31
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26458
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 25243
diff changeset
1 /*
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 25243
diff changeset
2 * This file is part of MPlayer.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 25243
diff changeset
3 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 25243
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 25243
diff changeset
5 * it under the terms of the GNU General Public License as published by
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 25243
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 25243
diff changeset
7 * (at your option) any later version.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 25243
diff changeset
8 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 25243
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 25243
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 25243
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 25243
diff changeset
12 * GNU General Public License for more details.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 25243
diff changeset
13 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 25243
diff changeset
14 * You should have received a copy of the GNU General Public License along
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 25243
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 25243
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 25243
diff changeset
17 */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
18
34327
4d4726efed3e Add doxygen comment to app.c
ib
parents: 34326
diff changeset
19 /**
4d4726efed3e Add doxygen comment to app.c
ib
parents: 34326
diff changeset
20 * @file
4d4726efed3e Add doxygen comment to app.c
ib
parents: 34326
diff changeset
21 * @brief GUI application helpers
4d4726efed3e Add doxygen comment to app.c
ib
parents: 34326
diff changeset
22 */
4d4726efed3e Add doxygen comment to app.c
ib
parents: 34326
diff changeset
23
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
24 #include "app.h"
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 34697
diff changeset
25 #include "gui.h"
35525
e27855a45128 Rebuild GUI directory structure.
ib
parents: 35493
diff changeset
26 #include "gui/skin/font.h"
32921
448517f556a5 Fix memory leak in appClearItem().
ib
parents: 32918
diff changeset
27
32944
27a98940e3aa Use FF_ARRAY_ELEMS() rather than a separate constant.
ib
parents: 32937
diff changeset
28 #include "libavutil/common.h"
27a98940e3aa Use FF_ARRAY_ELEMS() rather than a separate constant.
ib
parents: 32937
diff changeset
29
33979
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
30 /**
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
31 * @brief Initialize item counters.
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
32 */
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
33 guiItems guiApp = {
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
34 .IndexOfMainItems = -1,
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
35 .IndexOfPlaybarItems = -1,
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
36 .IndexOfMenuItems = -1
33266
de4f5f183ddb Initialize appMPlayer differently.
ib
parents: 33218
diff changeset
37 };
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
38
33979
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
39 /**
34327
4d4726efed3e Add doxygen comment to app.c
ib
parents: 34326
diff changeset
40 * @brief Event messages belonging to event names.
33979
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
41 */
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
42 static const evName evNames[] = {
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
43 { evNone, "evNone" },
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
44 { evPlay, "evPlay" },
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
45 { evStop, "evStop" },
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
46 { evPause, "evPause" },
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
47 { evPrev, "evPrev" },
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
48 { evNext, "evNext" },
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
49 { evLoad, "evLoad" },
34317
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
50 { evLoadPlay, "evLoadPlay" },
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
51 { evLoadAudioFile, "evLoadAudioFile" },
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
52 { evLoadSubtitle, "evLoadSubtitle" },
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
53 { evDropSubtitle, "evDropSubtitle" },
34321
daebf766dea6 Cosmetic: Synchronize evPlaylist event and message names.
ib
parents: 34319
diff changeset
54 { evPlaylist, "evPlaylist" },
34387
0ba85cad4c7e Add audio CD playback support to the X11/GTK GUI.
ib
parents: 34353
diff changeset
55 { evPlayCD, "evPlayCD" },
34317
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
56 { evPlayVCD, "evPlayVCD" },
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
57 { evPlayDVD, "evPlayDVD" },
34324
58aaa0d8cc82 Replace evSetURL by evLoadURL for consistency.
ib
parents: 34322
diff changeset
58 { evLoadURL, "evSetURL" }, // legacy
58aaa0d8cc82 Replace evSetURL by evLoadURL for consistency.
ib
parents: 34322
diff changeset
59 { evLoadURL, "evLoadURL" },
36429
28ea255e40ce Add support for TV/DVB to the GUI.
ib
parents: 35688
diff changeset
60 { evPlayTV, "evPlayTV" },
34317
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
61 { evPlaySwitchToPause, "evPlaySwitchToPause" },
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
62 { evPauseSwitchToPlay, "evPauseSwitchToPlay" },
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
63 { evBackward10sec, "evBackward10sec" },
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
64 { evForward10sec, "evForward10sec" },
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
65 { evBackward1min, "evBackward1min" },
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
66 { evForward1min, "evForward1min" },
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
67 { evBackward10min, "evBackward10min" },
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
68 { evForward10min, "evForward10min" },
34317
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
69 { evSetMoviePosition, "evSetMoviePosition" },
34319
0de7aa136e27 Fix bug with evHalfSize event.
ib
parents: 34317
diff changeset
70 { evHalfSize, "evHalfSize" },
34317
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
71 { evDoubleSize, "evDoubleSize" },
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
72 { evFullScreen, "evFullScreen" },
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
73 { evNormalSize, "evNormalSize" },
34322
6075b19ad3ad Cosmetic: Add evSetAspect event to video events.
ib
parents: 34321
diff changeset
74 { evSetAspect, "evSetAspect" },
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
75 { evIncVolume, "evIncVolume" },
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
76 { evDecVolume, "evDecVolume" },
34317
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
77 { evSetVolume, "evSetVolume" },
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
78 { evMute, "evMute" },
34317
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
79 { evSetBalance, "evSetBalance" },
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
80 { evEqualizer, "evEqualizer" },
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
81 { evAbout, "evAbout" },
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
82 { evPreferences, "evPreferences" },
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
83 { evSkinBrowser, "evSkinBrowser" },
34458
1e84148527ab Add user event evMenu.
ib
parents: 34387
diff changeset
84 { evMenu, "evMenu" },
34317
e905a896243d Cosmetic: Rearrange and group GUI user events.
ib
parents: 33979
diff changeset
85 { evIconify, "evIconify" },
34326
d188b59d3fa4 Remove non-existing GUI user events.
ib
parents: 34324
diff changeset
86 { evExit, "evExit" }
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
87 };
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
88
33979
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
89 /**
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
90 * @brief Free all memory allocated to an item and set all its pointers to NULL.
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
91 *
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
92 * @param item item to be freed
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
93 */
35688
6fd886ce32b9 Cosmetic: Rename wItem guiItem.
ib
parents: 35541
diff changeset
94 static void appClearItem(guiItem *item)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
95 {
32917
9949f3a123cf Add new function bpFree() to free txSamples (bitmaps).
ib
parents: 32912
diff changeset
96 bpFree(&item->Bitmap);
32921
448517f556a5 Fix memory leak in appClearItem().
ib
parents: 32918
diff changeset
97 bpFree(&item->Mask);
32947
0e4fd1834f76 Prefer free() to gfree().
ib
parents: 32946
diff changeset
98 free(item->label);
0e4fd1834f76 Prefer free() to gfree().
ib
parents: 32946
diff changeset
99 free(item->text);
32946
d551faf8d07e Simplify appClearItem() by using memset().
ib
parents: 32945
diff changeset
100 memset(item, 0, sizeof(*item));
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
101 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
102
33979
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
103 /**
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
104 * @brief Free all memory allocated to all GUI items and reset all item counters.
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
105 */
32932
e95ec1b2feea Cosmetic: Rename appInitStruct() to appFreeStruct().
ib
parents: 32931
diff changeset
106 void appFreeStruct(void)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
107 {
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
108 int i;
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
109
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
110 appClearItem(&guiApp.main);
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 34697
diff changeset
111 guiApp.mainDecoration = False;
32929
6ea9e024f05e Clean up appInitStruct().
ib
parents: 32928
diff changeset
112
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34458
diff changeset
113 appClearItem(&guiApp.video);
32929
6ea9e024f05e Clean up appInitStruct().
ib
parents: 32928
diff changeset
114
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
115 appClearItem(&guiApp.playbar);
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 34697
diff changeset
116 guiApp.playbarIsPresent = False;
32929
6ea9e024f05e Clean up appInitStruct().
ib
parents: 32928
diff changeset
117
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
118 appClearItem(&guiApp.menu);
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
119 appClearItem(&guiApp.menuSelected);
35493
411875efca3f Introduce boolean symbolic constants.
ib
parents: 34697
diff changeset
120 guiApp.menuIsPresent = False;
32929
6ea9e024f05e Clean up appInitStruct().
ib
parents: 32928
diff changeset
121
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
122 for (i = 0; i <= guiApp.IndexOfMainItems; i++)
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
123 appClearItem(&guiApp.mainItems[i]);
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
124 for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++)
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
125 appClearItem(&guiApp.playbarItems[i]);
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
126 for (i = 0; i <= guiApp.IndexOfMenuItems; i++)
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
127 appClearItem(&guiApp.menuItems[i]);
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
128
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
129 guiApp.IndexOfMainItems = -1;
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
130 guiApp.IndexOfPlaybarItems = -1;
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
131 guiApp.IndexOfMenuItems = -1;
33266
de4f5f183ddb Initialize appMPlayer differently.
ib
parents: 33218
diff changeset
132
32933
258baf2bfeca Move fntFreeFont() into appFreeStruct().
ib
parents: 32932
diff changeset
133 fntFreeFont();
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
134 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
135
33979
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
136 /**
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
137 * @brief Find the event belonging to an event name.
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
138 *
34328
6cfca461669c Change parameter name and its declaration to const.
ib
parents: 34327
diff changeset
139 * @param name event name
33979
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
140 *
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
141 * @return event >= 0 (ok) or -1 (not found)
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
142 */
34328
6cfca461669c Change parameter name and its declaration to const.
ib
parents: 34327
diff changeset
143 int appFindMessage(const char *name)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
144 {
32944
27a98940e3aa Use FF_ARRAY_ELEMS() rather than a separate constant.
ib
parents: 32937
diff changeset
145 unsigned int i;
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
146
32944
27a98940e3aa Use FF_ARRAY_ELEMS() rather than a separate constant.
ib
parents: 32937
diff changeset
147 for (i = 0; i < FF_ARRAY_ELEMS(evNames); i++)
34328
6cfca461669c Change parameter name and its declaration to const.
ib
parents: 34327
diff changeset
148 if (!strcmp(evNames[i].name, name))
32911
e06fbdd8eb46 Clean up the wItem structure.
ib
parents: 32900
diff changeset
149 return evNames[i].message;
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
150
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
151 return -1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
152 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
153
33979
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
154 /**
34339
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
155 * @brief Find the item belonging to an event.
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
156 *
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
157 * @param event event
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
158 *
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
159 * @return pointer to the item (ok) or NULL (not found)
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
160 */
35688
6fd886ce32b9 Cosmetic: Rename wItem guiItem.
ib
parents: 35541
diff changeset
161 guiItem *appFindItem(int event)
34339
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
162 {
35688
6fd886ce32b9 Cosmetic: Rename wItem guiItem.
ib
parents: 35541
diff changeset
163 guiItem *item;
34339
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
164 int i, n;
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
165
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34458
diff changeset
166 if (guiApp.videoWindow.isFullScreen && guiApp.playbarIsPresent) {
34339
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
167 item = guiApp.playbarItems;
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
168 n = guiApp.IndexOfPlaybarItems;
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
169 } else {
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
170 item = guiApp.mainItems;
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
171 n = guiApp.IndexOfMainItems;
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
172 }
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
173
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
174 for (i = 0; i <= n; i++)
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
175 if (item[i].message == event)
34353
deb52aa6ad88 Return right pointer.
ib
parents: 34339
diff changeset
176 return &item[i];
34339
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
177
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
178 return NULL;
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
179 }
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
180
f05c75392897 Enable gui slave commands.
ib
parents: 34328
diff changeset
181 /**
33979
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
182 * @brief Modify the state (i.e. set a new value) to the item belonging to an event.
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
183 *
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
184 * @param event event
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
185 * @param state new value
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
186 */
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
187 void btnModify(int event, float state)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
188 {
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
189 int i;
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
190
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
191 for (i = 0; i <= guiApp.IndexOfMainItems; i++) {
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
192 if (guiApp.mainItems[i].message == event) {
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
193 switch (guiApp.mainItems[i].type) {
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
194 case itButton:
35541
ded4a8c2aa70 Cosmetic: Add some blank lines.
ib
parents: 35525
diff changeset
195
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
196 guiApp.mainItems[i].pressed = (int)state;
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
197 break;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
198
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
199 case itPotmeter:
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
200 case itVPotmeter:
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
201 case itHPotmeter:
35541
ded4a8c2aa70 Cosmetic: Add some blank lines.
ib
parents: 35525
diff changeset
202
32960
06d7501e046f Make constants explicitly type float.
ib
parents: 32947
diff changeset
203 if (state < 0.0f)
06d7501e046f Make constants explicitly type float.
ib
parents: 32947
diff changeset
204 state = 0.0f;
06d7501e046f Make constants explicitly type float.
ib
parents: 32947
diff changeset
205 if (state > 100.0f)
06d7501e046f Make constants explicitly type float.
ib
parents: 32947
diff changeset
206 state = 100.0f;
35541
ded4a8c2aa70 Cosmetic: Add some blank lines.
ib
parents: 35525
diff changeset
207
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
208 guiApp.mainItems[i].value = state;
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
209 break;
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
210 }
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
211 }
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
212 }
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
213
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
214 for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++) {
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
215 if (guiApp.playbarItems[i].message == event) {
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
216 switch (guiApp.playbarItems[i].type) {
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
217 case itButton:
35541
ded4a8c2aa70 Cosmetic: Add some blank lines.
ib
parents: 35525
diff changeset
218
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
219 guiApp.playbarItems[i].pressed = (int)state;
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
220 break;
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
221
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
222 case itPotmeter:
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
223 case itVPotmeter:
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
224 case itHPotmeter:
35541
ded4a8c2aa70 Cosmetic: Add some blank lines.
ib
parents: 35525
diff changeset
225
32960
06d7501e046f Make constants explicitly type float.
ib
parents: 32947
diff changeset
226 if (state < 0.0f)
06d7501e046f Make constants explicitly type float.
ib
parents: 32947
diff changeset
227 state = 0.0f;
06d7501e046f Make constants explicitly type float.
ib
parents: 32947
diff changeset
228 if (state > 100.0f)
06d7501e046f Make constants explicitly type float.
ib
parents: 32947
diff changeset
229 state = 100.0f;
35541
ded4a8c2aa70 Cosmetic: Add some blank lines.
ib
parents: 35525
diff changeset
230
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
231 guiApp.playbarItems[i].value = state;
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
232 break;
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
233 }
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
234 }
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
235 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
236 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
237
33979
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
238 /**
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
239 * @brief Set the @a pressed state (i.e. a new value) to the item belonging to an event.
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
240 *
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
241 * @param event event
36859
9bc711c42ea6 Update documentation.
ib
parents: 36858
diff changeset
242 * @param state new state
33979
1c4a2554d46b Add doxygen comments to app.c.
ib
parents: 33753
diff changeset
243 */
36858
bb067298265a Fix bug with btnSet().
ib
parents: 36429
diff changeset
244 void btnSet(int event, int state)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
245 {
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
246 int i;
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
247
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
248 for (i = 0; i <= guiApp.IndexOfMainItems; i++)
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
249 if (guiApp.mainItems[i].message == event)
36858
bb067298265a Fix bug with btnSet().
ib
parents: 36429
diff changeset
250 if (hasButton(guiApp.mainItems[i]))
bb067298265a Fix bug with btnSet().
ib
parents: 36429
diff changeset
251 guiApp.mainItems[i].pressed = state;
32897
14af78beac02 Cosmetic: Format to MPlayer coding style.
ib
parents: 32847
diff changeset
252
33555
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
253 for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++)
c5a19bbeac2b Cosmetic: Rename some GUI variables and functions.
ib
parents: 33270
diff changeset
254 if (guiApp.playbarItems[i].message == event)
36858
bb067298265a Fix bug with btnSet().
ib
parents: 36429
diff changeset
255 if (hasButton(guiApp.mainItems[i]))
bb067298265a Fix bug with btnSet().
ib
parents: 36429
diff changeset
256 guiApp.playbarItems[i].pressed = state;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
257 }