Mercurial > mplayer.hg
annotate gui/ui/playbar.c @ 35683:75155d8a9c7e
Remove parameter for border_width from wsWindowCreate().
It's nothing but 0 anyway.
Additionally, switch position of mouse cursor and window properties
parameters.
author | ib |
---|---|
date | Fri, 18 Jan 2013 01:13:50 +0000 |
parents | 80c5c89f77d6 |
children | 6fd886ce32b9 |
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 |
34699
ed0e00db4306
Cosmetic: Move, change and add some comments on GUI windows.
ib
parents:
34697
diff
changeset
|
19 /* playbar window */ |
ed0e00db4306
Cosmetic: Move, change and add some comments on GUI windows.
ib
parents:
34697
diff
changeset
|
20 |
23077 | 21 #include <stdlib.h> |
22 #include <stdio.h> | |
23 #include <sys/stat.h> | |
24 #include <unistd.h> | |
23305
22d3d12c6dfb
Include string.h for memcpy, fastmemcpy.h alone is not enough.
reimar
parents:
23077
diff
changeset
|
25 #include <string.h> |
23077 | 26 |
35525 | 27 #include "gui/app/app.h" |
28 #include "gui/app/gui.h" | |
33738 | 29 #include "gui/interface.h" |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
30 #include "gui/skin/font.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
31 #include "gui/skin/skin.h" |
33739 | 32 #include "gui/util/mem.h" |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
33 #include "gui/wm/ws.h" |
23077 | 34 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
35 #include "help_mp.h" |
33024 | 36 #include "mp_core.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
37 #include "libvo/x11_common.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
38 #include "libvo/fastmemcpy.h" |
23077 | 39 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
40 #include "stream/stream.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
41 #include "mixer.h" |
32467 | 42 #include "sub/sub.h" |
23077 | 43 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
44 #include "libmpdemux/demuxer.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
45 #include "libmpdemux/stheader.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
46 #include "codec-cfg.h" |
23077 | 47 |
35528 | 48 #include "ui.h" |
33556 | 49 #include "actions.h" |
35529 | 50 #include "gui/dialog/dialog.h" |
33556 | 51 #include "render.h" |
23077 | 52 |
28051 | 53 unsigned int GetTimerMS( void ); |
54 unsigned int GetTimer( void ); | |
23077 | 55 |
33555 | 56 unsigned char * playbarDrawBuffer = NULL; |
35493 | 57 int playbarVisible = False; |
33555 | 58 int playbarLength = 0; |
59 int uiPlaybarFade = 0; | |
23077 | 60 |
33555 | 61 static void uiPlaybarDraw( void ) |
23077 | 62 { |
63 int x; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
64 |
34697 | 65 if ( !guiApp.videoWindow.isFullScreen ) return; |
33555 | 66 if ( !playbarVisible || !guiApp.playbarIsPresent ) return; |
23077 | 67 |
34697 | 68 // guiApp.playbar.x=( guiApp.videoWindow.Width - guiApp.playbar.width ) / 2; |
33555 | 69 switch( guiApp.playbar.x ) |
23077 | 70 { |
34697 | 71 case -1: x=( guiApp.videoWindow.Width - guiApp.playbar.width ) / 2; break; |
72 case -2: x=( guiApp.videoWindow.Width - guiApp.playbar.width ); break; | |
33555 | 73 default: x=guiApp.playbar.x; |
23077 | 74 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
75 |
33555 | 76 switch ( uiPlaybarFade ) |
23077 | 77 { |
78 case 1: // fade in | |
33555 | 79 playbarLength--; |
34697 | 80 if ( guiApp.videoWindow.Height - guiApp.playbar.height >= playbarLength ) |
23077 | 81 { |
34697 | 82 playbarLength=guiApp.videoWindow.Height - guiApp.playbar.height; |
33555 | 83 uiPlaybarFade=0; |
35493 | 84 vo_mouse_autohide=False; |
23077 | 85 } |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
86 wsWindowMove( &guiApp.playbarWindow,True,x,playbarLength ); |
23077 | 87 break; |
88 case 2: // fade out | |
33555 | 89 playbarLength+=10; |
34697 | 90 if ( playbarLength > guiApp.videoWindow.Height ) |
23077 | 91 { |
34697 | 92 playbarLength=guiApp.videoWindow.Height; |
35493 | 93 uiPlaybarFade=0; |
94 playbarVisible=False; | |
95 vo_mouse_autohide=True; | |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
96 wsWindowVisibility( &guiApp.playbarWindow,wsHideWindow ); |
23077 | 97 return; |
98 } | |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
99 wsWindowMove( &guiApp.playbarWindow,True,x,playbarLength ); |
23077 | 100 break; |
101 } | |
102 | |
34684 | 103 /* render */ |
33555 | 104 if ( guiApp.playbarWindow.State == wsWindowExpose ) |
23077 | 105 { |
33555 | 106 btnModify( evSetMoviePosition,guiInfo.Position ); |
107 btnModify( evSetVolume,guiInfo.Volume ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
108 |
35493 | 109 vo_mouse_autohide=False; |
23077 | 110 |
33555 | 111 fast_memcpy( playbarDrawBuffer,guiApp.playbar.Bitmap.Image,guiApp.playbar.Bitmap.ImageSize ); |
112 RenderAll( &guiApp.playbarWindow,guiApp.playbarItems,guiApp.IndexOfPlaybarItems,playbarDrawBuffer ); | |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
113 wsImageConvert( &guiApp.playbarWindow,playbarDrawBuffer ); |
23077 | 114 } |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
115 wsImageDraw( &guiApp.playbarWindow ); |
23077 | 116 } |
117 | |
33555 | 118 static void uiPlaybarMouseHandle( int Button, int X, int Y, int RX, int RY ) |
23077 | 119 { |
120 static int itemtype = 0; | |
121 int i; | |
122 wItem * item = NULL; | |
123 float value = 0.0f; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
124 |
23077 | 125 static int SelectedItem = -1; |
126 int currentselected = -1; | |
127 | |
33555 | 128 for ( i=0;i <= guiApp.IndexOfPlaybarItems;i++ ) |
129 if ( ( guiApp.playbarItems[i].pressed != btnDisabled )&& | |
35675 | 130 ( 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 ) ) ) |
23077 | 131 { currentselected=i; break; } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
132 |
23077 | 133 switch ( Button ) |
134 { | |
135 case wsPMMouseButton: | |
34333 | 136 gtkShow( ivHidePopUpMenu,NULL ); |
33555 | 137 uiShowMenu( RX,RY ); |
23077 | 138 break; |
139 case wsRMMouseButton: | |
33555 | 140 uiHideMenu( RX,RY,0 ); |
23077 | 141 break; |
142 case wsRRMouseButton: | |
34333 | 143 gtkShow( ivShowPopUpMenu,NULL ); |
23077 | 144 break; |
34684 | 145 /* --- */ |
23077 | 146 case wsPLMouseButton: |
34333 | 147 gtkShow( ivHidePopUpMenu,NULL ); |
23077 | 148 SelectedItem=currentselected; |
149 if ( SelectedItem == -1 ) break; // yeees, i'm move the fucking window | |
33555 | 150 item=&guiApp.playbarItems[SelectedItem]; |
23077 | 151 itemtype=item->type; |
152 item->pressed=btnPressed; | |
153 | |
154 switch( item->type ) | |
155 { | |
156 case itButton: | |
157 if ( ( SelectedItem > -1 ) && | |
32911 | 158 ( ( ( item->message == evPlaySwitchToPause && item->message == evPauseSwitchToPlay ) ) || |
159 ( ( item->message == evPauseSwitchToPlay && item->message == evPlaySwitchToPause ) ) ) ) | |
23077 | 160 { item->pressed=btnDisabled; } |
161 break; | |
162 } | |
163 | |
164 break; | |
165 case wsRLMouseButton: | |
33107 | 166 if ( SelectedItem != -1 ) // NOTE TO MYSELF: only if itButton, itHPotmeter or itVPotmeter |
167 { | |
33555 | 168 item=&guiApp.playbarItems[SelectedItem]; |
33108 | 169 item->pressed=btnReleased; |
33107 | 170 } |
35367 | 171 if ( currentselected == - 1 || SelectedItem == -1 ) { itemtype=0; break; } |
23077 | 172 SelectedItem=-1; |
173 value=0; | |
174 | |
175 switch( itemtype ) | |
176 { | |
177 case itPotmeter: | |
178 case itHPotmeter: | |
32911 | 179 btnModify( item->message,(float)( X - item->x ) / item->width * 100.0f ); |
33555 | 180 uiEventHandling( item->message,item->value ); |
23077 | 181 value=item->value; |
182 break; | |
183 case itVPotmeter: | |
32911 | 184 btnModify( item->message, ( 1. - (float)( Y - item->y ) / item->height) * 100.0f ); |
33555 | 185 uiEventHandling( item->message,item->value ); |
23077 | 186 value=item->value; |
187 break; | |
188 } | |
33555 | 189 uiEventHandling( item->message,value ); |
23077 | 190 |
191 itemtype=0; | |
192 break; | |
34684 | 193 /* --- */ |
23077 | 194 case wsP5MouseButton: value=-2.5f; goto rollerhandled; |
195 case wsP4MouseButton: value= 2.5f; | |
196 rollerhandled: | |
35365 | 197 if (currentselected != - 1) |
198 { | |
35366 | 199 item=&guiApp.playbarItems[currentselected]; |
200 if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) ) | |
201 { | |
202 item->value+=value; | |
203 btnModify( item->message,item->value ); | |
204 uiEventHandling( item->message,item->value ); | |
205 } | |
35365 | 206 } |
23077 | 207 break; |
34684 | 208 /* --- */ |
23077 | 209 case wsMoveMouse: |
33555 | 210 item=&guiApp.playbarItems[SelectedItem]; |
23077 | 211 switch ( itemtype ) |
212 { | |
213 case itPRMButton: | |
34472 | 214 uiMenuMouseHandle( RX,RY ); |
23077 | 215 break; |
216 case itPotmeter: | |
217 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
218 goto potihandled; | |
219 case itVPotmeter: | |
220 item->value=(1. - (float)( Y - item->y ) / item->height) * 100.0f; | |
221 goto potihandled; | |
222 case itHPotmeter: | |
223 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
224 potihandled: | |
225 if ( item->value > 100.0f ) item->value=100.0f; | |
226 if ( item->value < 0.0f ) item->value=0.0f; | |
33555 | 227 uiEventHandling( item->message,item->value ); |
23077 | 228 break; |
229 } | |
230 break; | |
231 } | |
232 } | |
233 | |
34471 | 234 void uiPlaybarShow( int y ) |
23077 | 235 { |
33555 | 236 if ( !guiApp.playbarIsPresent || !gtkEnablePlayBar ) return; |
34697 | 237 if ( !guiApp.videoWindow.isFullScreen ) return; |
23077 | 238 |
34697 | 239 if ( y > guiApp.videoWindow.Height - guiApp.playbar.height ) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
240 { |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
241 if ( !uiPlaybarFade ) wsWindowVisibility( &guiApp.playbarWindow,wsShowWindow ); |
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
242 uiPlaybarFade=1; playbarVisible=True; wsWindowRedraw( &guiApp.playbarWindow ); |
23077 | 243 } |
33555 | 244 else if ( !uiPlaybarFade ) uiPlaybarFade=2; |
23077 | 245 } |
246 | |
33555 | 247 void uiPlaybarInit( void ) |
23077 | 248 { |
33555 | 249 if ( !guiApp.playbarIsPresent ) return; |
23077 | 250 |
33739 | 251 nfree( playbarDrawBuffer ); |
23077 | 252 |
33555 | 253 if ( ( playbarDrawBuffer = malloc( guiApp.playbar.Bitmap.ImageSize ) ) == NULL ) |
23077 | 254 { |
33024 | 255 gmp_msg( MSGT_GPLAYER,MSGL_FATAL,MSGTR_NEMDB ); |
33768 | 256 mplayer( MPLAYER_EXIT_GUI, EXIT_ERROR, 0 ); |
23077 | 257 } |
258 | |
34697 | 259 guiApp.playbarWindow.Parent=guiApp.videoWindow.WindowID; |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
260 wsWindowCreate( &guiApp.playbarWindow, |
33555 | 261 guiApp.playbar.x,guiApp.playbar.y,guiApp.playbar.width,guiApp.playbar.height, |
35683
75155d8a9c7e
Remove parameter for border_width from wsWindowCreate().
ib
parents:
35681
diff
changeset
|
262 wsHideFrame|wsHideWindow,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,"PlayBar" ); |
23077 | 263 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
264 wsWindowShape( &guiApp.playbarWindow,guiApp.playbar.Mask.Image ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
265 |
33555 | 266 guiApp.playbarWindow.ReDraw=(void *)uiPlaybarDraw; |
267 guiApp.playbarWindow.MouseHandler=uiPlaybarMouseHandle; | |
268 guiApp.playbarWindow.KeyHandler=uiMainKeyHandle; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
269 |
34697 | 270 playbarLength=guiApp.videoWindow.Height; |
23077 | 271 } |