Mercurial > mplayer.hg
comparison gui/ui/playbar.c @ 37053:84c93a60ead3
Add new item 'rpotmeter'.
This is the missing counterpart to hpotmeter and vpotmeter
allowing rotary control elements in a GUI skin now.
Based on an idea and a realization by Hans-Dieter Kosch,
hdkosch kabelbw de.
Additionally, update (and revise) documentation.
author | ib |
---|---|
date | Sat, 12 Apr 2014 23:29:29 +0000 |
parents | 2ef6693131f7 |
children |
comparison
equal
deleted
inserted
replaced
37052:2ef6693131f7 | 37053:84c93a60ead3 |
---|---|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
17 */ | 17 */ |
18 | 18 |
19 /* playbar window */ | 19 /* playbar window */ |
20 | 20 |
21 #include <math.h> | |
21 #include <stdlib.h> | 22 #include <stdlib.h> |
22 #include <stdio.h> | 23 #include <stdio.h> |
23 #include <sys/stat.h> | 24 #include <sys/stat.h> |
24 #include <unistd.h> | 25 #include <unistd.h> |
25 #include <string.h> | 26 #include <string.h> |
121 static void uiPlaybarMouse( int Button, int X, int Y, int RX, int RY ) | 122 static void uiPlaybarMouse( int Button, int X, int Y, int RX, int RY ) |
122 { | 123 { |
123 static int itemtype = 0; | 124 static int itemtype = 0; |
124 int i; | 125 int i; |
125 guiItem * item = NULL; | 126 guiItem * item = NULL; |
127 static double prev_point; | |
128 double point; | |
126 float value = 0.0f; | 129 float value = 0.0f; |
127 | 130 |
128 static int SelectedItem = -1; | 131 static int SelectedItem = -1; |
129 int currentselected = -1; | 132 int currentselected = -1; |
133 static int endstop; | |
130 | 134 |
131 for ( i=0;i <= guiApp.IndexOfPlaybarItems;i++ ) | 135 for ( i=0;i <= guiApp.IndexOfPlaybarItems;i++ ) |
132 if ( ( guiApp.playbarItems[i].pressed != btnDisabled )&& | 136 if ( ( guiApp.playbarItems[i].pressed != btnDisabled )&& |
133 ( isInside( X,Y,guiApp.playbarItems[i].x,guiApp.playbarItems[i].y,guiApp.playbarItems[i].x+guiApp.playbarItems[i].width,guiApp.playbarItems[i].y+guiApp.playbarItems[i].height ) ) ) | 137 ( isInside( X,Y,guiApp.playbarItems[i].x,guiApp.playbarItems[i].y,guiApp.playbarItems[i].x+guiApp.playbarItems[i].width,guiApp.playbarItems[i].y+guiApp.playbarItems[i].height ) ) ) |
134 { currentselected=i; break; } | 138 { currentselected=i; break; } |
160 if ( ( SelectedItem > -1 ) && | 164 if ( ( SelectedItem > -1 ) && |
161 ( ( ( item->message == evPlaySwitchToPause && item->message == evPauseSwitchToPlay ) ) || | 165 ( ( ( item->message == evPlaySwitchToPause && item->message == evPauseSwitchToPlay ) ) || |
162 ( ( item->message == evPauseSwitchToPlay && item->message == evPlaySwitchToPause ) ) ) ) | 166 ( ( item->message == evPauseSwitchToPlay && item->message == evPlaySwitchToPause ) ) ) ) |
163 { item->pressed=btnDisabled; } | 167 { item->pressed=btnDisabled; } |
164 break; | 168 break; |
169 case itRPotmeter: | |
170 prev_point=appRadian( item, X - item->x, Y - item->y ) - item->zeropoint; | |
171 if ( prev_point < 0.0 ) prev_point+=2*M_PI; | |
172 if ( prev_point <= item->arclength ) endstop=False; | |
173 else endstop=STOPPED_AT_0 + STOPPED_AT_100; // block movement | |
174 break; | |
165 } | 175 } |
166 | 176 |
167 break; | 177 break; |
168 case wsRLMouseButton: | 178 case wsRLMouseButton: |
169 if ( SelectedItem != -1 ) // NOTE TO MYSELF: only if hasButton | 179 if ( SelectedItem != -1 ) // NOTE TO MYSELF: only if hasButton |
180 case itHPotmeter: | 190 case itHPotmeter: |
181 value=100.0 * ( X - item->x ) / item->width; | 191 value=100.0 * ( X - item->x ) / item->width; |
182 break; | 192 break; |
183 case itVPotmeter: | 193 case itVPotmeter: |
184 value=100.0 - 100.0 * ( Y - item->y ) / item->height; | 194 value=100.0 - 100.0 * ( Y - item->y ) / item->height; |
195 break; | |
196 case itRPotmeter: | |
197 if ( endstop ) { itemtype=0; return; } | |
198 point=appRadian( item, X - item->x, Y - item->y ) - item->zeropoint; | |
199 if ( point < 0.0 ) point+=2*M_PI; | |
200 value=100.0 * point / item->arclength; | |
185 break; | 201 break; |
186 } | 202 } |
187 uiEvent( item->message,value ); | 203 uiEvent( item->message,value ); |
188 | 204 |
189 itemtype=0; | 205 itemtype=0; |
193 case wsP4MouseButton: value= 2.5f; | 209 case wsP4MouseButton: value= 2.5f; |
194 rollerhandled: | 210 rollerhandled: |
195 if (currentselected != - 1) | 211 if (currentselected != - 1) |
196 { | 212 { |
197 item=&guiApp.playbarItems[currentselected]; | 213 item=&guiApp.playbarItems[currentselected]; |
198 if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter ) ) | 214 if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itRPotmeter ) ) |
199 { | 215 { |
200 item->value=constrain(item->value + value); | 216 item->value=constrain(item->value + value); |
201 uiEvent( item->message,item->value ); | 217 uiEvent( item->message,item->value ); |
202 } | 218 } |
203 } | 219 } |
208 switch ( itemtype ) | 224 switch ( itemtype ) |
209 { | 225 { |
210 case itPRMButton: | 226 case itPRMButton: |
211 if (guiApp.menuIsPresent) guiApp.menuWindow.MouseHandler( 0,RX,RY,0,0 ); | 227 if (guiApp.menuIsPresent) guiApp.menuWindow.MouseHandler( 0,RX,RY,0,0 ); |
212 break; | 228 break; |
229 case itRPotmeter: | |
230 point=appRadian( item, X - item->x, Y - item->y ) - item->zeropoint; | |
231 if ( point < 0.0 ) point+=2*M_PI; | |
232 if ( item->arclength < 2 * M_PI ) | |
233 /* a potmeter with separated 0% and 100% positions */ | |
234 { | |
235 value=item->value; | |
236 if ( point - prev_point > M_PI ) | |
237 /* turned beyond the 0% position */ | |
238 { | |
239 if ( !endstop ) | |
240 { | |
241 endstop=STOPPED_AT_0; | |
242 value=0.0f; | |
243 } | |
244 } | |
245 else if ( prev_point - point > M_PI ) | |
246 /* turned back from beyond the 0% position */ | |
247 { | |
248 if ( endstop == STOPPED_AT_0 ) endstop=False; | |
249 } | |
250 else if ( prev_point <= item->arclength && point > item->arclength ) | |
251 /* turned beyond the 100% position */ | |
252 { | |
253 if ( !endstop ) | |
254 { | |
255 endstop=STOPPED_AT_100; | |
256 value=100.0f; | |
257 } | |
258 } | |
259 else if ( prev_point > item->arclength && point <= item->arclength ) | |
260 /* turned back from beyond the 100% position */ | |
261 { | |
262 if ( endstop == STOPPED_AT_100 ) endstop=False; | |
263 } | |
264 } | |
265 if ( !endstop ) value=100.0 * point / item->arclength; | |
266 prev_point=point; | |
267 goto potihandled; | |
213 case itVPotmeter: | 268 case itVPotmeter: |
214 value=100.0 - 100.0 * ( Y - item->y ) / item->height; | 269 value=100.0 - 100.0 * ( Y - item->y ) / item->height; |
215 goto potihandled; | 270 goto potihandled; |
216 case itHPotmeter: | 271 case itHPotmeter: |
217 value=100.0 * ( X - item->x ) / item->width; | 272 value=100.0 * ( X - item->x ) / item->width; |