Mercurial > mplayer.hg
annotate gui/ui/playbar.c @ 36472:c431f2e17a19
Update year in copyright notes.
author | ib |
---|---|
date | Thu, 02 Jan 2014 09:16:57 +0000 |
parents | b2edfe1a11a6 |
children | 7d250553d451 |
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" |
35783 | 36 #include "mp_msg.h" |
33024 | 37 #include "mp_core.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
38 #include "libvo/x11_common.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
39 #include "libvo/fastmemcpy.h" |
23077 | 40 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
41 #include "stream/stream.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
42 #include "mixer.h" |
32467 | 43 #include "sub/sub.h" |
23077 | 44 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
45 #include "libmpdemux/demuxer.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
46 #include "libmpdemux/stheader.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
47 #include "codec-cfg.h" |
23077 | 48 |
35528 | 49 #include "ui.h" |
33556 | 50 #include "actions.h" |
35529 | 51 #include "gui/dialog/dialog.h" |
33556 | 52 #include "render.h" |
23077 | 53 |
28051 | 54 unsigned int GetTimerMS( void ); |
55 unsigned int GetTimer( void ); | |
23077 | 56 |
33555 | 57 unsigned char * playbarDrawBuffer = NULL; |
35493 | 58 int playbarVisible = False; |
33555 | 59 int playbarLength = 0; |
60 int uiPlaybarFade = 0; | |
23077 | 61 |
33555 | 62 static void uiPlaybarDraw( void ) |
23077 | 63 { |
64 int x; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
65 |
34697 | 66 if ( !guiApp.videoWindow.isFullScreen ) return; |
33555 | 67 if ( !playbarVisible || !guiApp.playbarIsPresent ) return; |
23077 | 68 |
34697 | 69 // guiApp.playbar.x=( guiApp.videoWindow.Width - guiApp.playbar.width ) / 2; |
33555 | 70 switch( guiApp.playbar.x ) |
23077 | 71 { |
34697 | 72 case -1: x=( guiApp.videoWindow.Width - guiApp.playbar.width ) / 2; break; |
73 case -2: x=( guiApp.videoWindow.Width - guiApp.playbar.width ); break; | |
33555 | 74 default: x=guiApp.playbar.x; |
23077 | 75 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
76 |
33555 | 77 switch ( uiPlaybarFade ) |
23077 | 78 { |
79 case 1: // fade in | |
33555 | 80 playbarLength--; |
34697 | 81 if ( guiApp.videoWindow.Height - guiApp.playbar.height >= playbarLength ) |
23077 | 82 { |
34697 | 83 playbarLength=guiApp.videoWindow.Height - guiApp.playbar.height; |
33555 | 84 uiPlaybarFade=0; |
35493 | 85 vo_mouse_autohide=False; |
23077 | 86 } |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
87 wsWindowMove( &guiApp.playbarWindow,True,x,playbarLength ); |
23077 | 88 break; |
89 case 2: // fade out | |
33555 | 90 playbarLength+=10; |
34697 | 91 if ( playbarLength > guiApp.videoWindow.Height ) |
23077 | 92 { |
34697 | 93 playbarLength=guiApp.videoWindow.Height; |
35493 | 94 uiPlaybarFade=0; |
95 playbarVisible=False; | |
96 vo_mouse_autohide=True; | |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
97 wsWindowVisibility( &guiApp.playbarWindow,wsHideWindow ); |
23077 | 98 return; |
99 } | |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
100 wsWindowMove( &guiApp.playbarWindow,True,x,playbarLength ); |
23077 | 101 break; |
102 } | |
103 | |
34684 | 104 /* render */ |
33555 | 105 if ( guiApp.playbarWindow.State == wsWindowExpose ) |
23077 | 106 { |
33555 | 107 btnModify( evSetMoviePosition,guiInfo.Position ); |
108 btnModify( evSetVolume,guiInfo.Volume ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
109 |
35493 | 110 vo_mouse_autohide=False; |
23077 | 111 |
33555 | 112 fast_memcpy( playbarDrawBuffer,guiApp.playbar.Bitmap.Image,guiApp.playbar.Bitmap.ImageSize ); |
113 RenderAll( &guiApp.playbarWindow,guiApp.playbarItems,guiApp.IndexOfPlaybarItems,playbarDrawBuffer ); | |
35744 | 114 wsImageRender( &guiApp.playbarWindow,playbarDrawBuffer ); |
23077 | 115 } |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
116 wsImageDraw( &guiApp.playbarWindow ); |
23077 | 117 } |
118 | |
35762 | 119 static void uiPlaybarMouse( int Button, int X, int Y, int RX, int RY ) |
23077 | 120 { |
121 static int itemtype = 0; | |
122 int i; | |
35688 | 123 guiItem * item = NULL; |
23077 | 124 float value = 0.0f; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
125 |
23077 | 126 static int SelectedItem = -1; |
127 int currentselected = -1; | |
128 | |
33555 | 129 for ( i=0;i <= guiApp.IndexOfPlaybarItems;i++ ) |
130 if ( ( guiApp.playbarItems[i].pressed != btnDisabled )&& | |
35675 | 131 ( 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 | 132 { currentselected=i; break; } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
133 |
23077 | 134 switch ( Button ) |
135 { | |
136 case wsPMMouseButton: | |
34333 | 137 gtkShow( ivHidePopUpMenu,NULL ); |
35766
16ed8155439b
Rename uiShowMenu() uiMenuShow() and uiHideMenu() uiMenuHide().
ib
parents:
35765
diff
changeset
|
138 uiMenuShow( RX,RY ); |
23077 | 139 break; |
140 case wsRMMouseButton: | |
35766
16ed8155439b
Rename uiShowMenu() uiMenuShow() and uiHideMenu() uiMenuHide().
ib
parents:
35765
diff
changeset
|
141 uiMenuHide( RX,RY,0 ); |
23077 | 142 break; |
143 case wsRRMouseButton: | |
34333 | 144 gtkShow( ivShowPopUpMenu,NULL ); |
23077 | 145 break; |
34684 | 146 /* --- */ |
23077 | 147 case wsPLMouseButton: |
34333 | 148 gtkShow( ivHidePopUpMenu,NULL ); |
23077 | 149 SelectedItem=currentselected; |
150 if ( SelectedItem == -1 ) break; // yeees, i'm move the fucking window | |
33555 | 151 item=&guiApp.playbarItems[SelectedItem]; |
23077 | 152 itemtype=item->type; |
153 item->pressed=btnPressed; | |
154 | |
155 switch( item->type ) | |
156 { | |
157 case itButton: | |
158 if ( ( SelectedItem > -1 ) && | |
32911 | 159 ( ( ( item->message == evPlaySwitchToPause && item->message == evPauseSwitchToPlay ) ) || |
160 ( ( item->message == evPauseSwitchToPlay && item->message == evPlaySwitchToPause ) ) ) ) | |
23077 | 161 { item->pressed=btnDisabled; } |
162 break; | |
163 } | |
164 | |
165 break; | |
166 case wsRLMouseButton: | |
33107 | 167 if ( SelectedItem != -1 ) // NOTE TO MYSELF: only if itButton, itHPotmeter or itVPotmeter |
168 { | |
33555 | 169 item=&guiApp.playbarItems[SelectedItem]; |
33108 | 170 item->pressed=btnReleased; |
33107 | 171 } |
35367 | 172 if ( currentselected == - 1 || SelectedItem == -1 ) { itemtype=0; break; } |
23077 | 173 SelectedItem=-1; |
174 value=0; | |
175 | |
176 switch( itemtype ) | |
177 { | |
178 case itPotmeter: | |
179 case itHPotmeter: | |
36283
ebbd9730a8c6
Increase precision of calculation by using constants of type double.
ib
parents:
36281
diff
changeset
|
180 btnModify( item->message,(float)( X - item->x ) / item->width * 100.0 ); |
35773 | 181 uiEvent( item->message,item->value ); |
23077 | 182 value=item->value; |
183 break; | |
184 case itVPotmeter: | |
36283
ebbd9730a8c6
Increase precision of calculation by using constants of type double.
ib
parents:
36281
diff
changeset
|
185 btnModify( item->message, ( 1.0 - (float)( Y - item->y ) / item->height) * 100.0 ); |
35773 | 186 uiEvent( item->message,item->value ); |
23077 | 187 value=item->value; |
188 break; | |
189 } | |
35773 | 190 uiEvent( item->message,value ); |
23077 | 191 |
192 itemtype=0; | |
193 break; | |
34684 | 194 /* --- */ |
23077 | 195 case wsP5MouseButton: value=-2.5f; goto rollerhandled; |
196 case wsP4MouseButton: value= 2.5f; | |
197 rollerhandled: | |
35365 | 198 if (currentselected != - 1) |
199 { | |
35366 | 200 item=&guiApp.playbarItems[currentselected]; |
201 if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) ) | |
202 { | |
203 item->value+=value; | |
204 btnModify( item->message,item->value ); | |
35773 | 205 uiEvent( item->message,item->value ); |
35366 | 206 } |
35365 | 207 } |
23077 | 208 break; |
34684 | 209 /* --- */ |
23077 | 210 case wsMoveMouse: |
33555 | 211 item=&guiApp.playbarItems[SelectedItem]; |
23077 | 212 switch ( itemtype ) |
213 { | |
214 case itPRMButton: | |
35779 | 215 if (guiApp.menuIsPresent) guiApp.menuWindow.MouseHandler( 0,RX,RY,0,0 ); |
23077 | 216 break; |
217 case itPotmeter: | |
36283
ebbd9730a8c6
Increase precision of calculation by using constants of type double.
ib
parents:
36281
diff
changeset
|
218 item->value=(float)( X - item->x ) / item->width * 100.0; |
23077 | 219 goto potihandled; |
220 case itVPotmeter: | |
36283
ebbd9730a8c6
Increase precision of calculation by using constants of type double.
ib
parents:
36281
diff
changeset
|
221 item->value=(1.0 - (float)( Y - item->y ) / item->height) * 100.0; |
23077 | 222 goto potihandled; |
223 case itHPotmeter: | |
36283
ebbd9730a8c6
Increase precision of calculation by using constants of type double.
ib
parents:
36281
diff
changeset
|
224 item->value=(float)( X - item->x ) / item->width * 100.0; |
23077 | 225 potihandled: |
226 if ( item->value > 100.0f ) item->value=100.0f; | |
227 if ( item->value < 0.0f ) item->value=0.0f; | |
35773 | 228 uiEvent( item->message,item->value ); |
23077 | 229 break; |
230 } | |
231 break; | |
232 } | |
233 } | |
234 | |
33555 | 235 void uiPlaybarInit( void ) |
23077 | 236 { |
33555 | 237 if ( !guiApp.playbarIsPresent ) return; |
23077 | 238 |
33555 | 239 if ( ( playbarDrawBuffer = malloc( guiApp.playbar.Bitmap.ImageSize ) ) == NULL ) |
23077 | 240 { |
33024 | 241 gmp_msg( MSGT_GPLAYER,MSGL_FATAL,MSGTR_NEMDB ); |
33768 | 242 mplayer( MPLAYER_EXIT_GUI, EXIT_ERROR, 0 ); |
23077 | 243 } |
244 | |
34697 | 245 guiApp.playbarWindow.Parent=guiApp.videoWindow.WindowID; |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
246 wsWindowCreate( &guiApp.playbarWindow, |
33555 | 247 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
|
248 wsHideFrame|wsHideWindow,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,"PlayBar" ); |
23077 | 249 |
35783 | 250 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[playbar] playbarWindow ID: 0x%x\n",(int)guiApp.playbarWindow.WindowID ); |
251 | |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
252 wsWindowShape( &guiApp.playbarWindow,guiApp.playbar.Mask.Image ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
253 |
35761 | 254 guiApp.playbarWindow.DrawHandler=uiPlaybarDraw; |
35762 | 255 guiApp.playbarWindow.MouseHandler=uiPlaybarMouse; |
35780 | 256 guiApp.playbarWindow.KeyHandler=guiApp.mainWindow.KeyHandler; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
257 |
34697 | 258 playbarLength=guiApp.videoWindow.Height; |
23077 | 259 } |
35765 | 260 |
35796
497a1c45a597
Add uiMainDone(), uiVideoDone(), uiPlaybarDone() and uiMenuDone().
ib
parents:
35783
diff
changeset
|
261 void uiPlaybarDone( void ) |
497a1c45a597
Add uiMainDone(), uiVideoDone(), uiPlaybarDone() and uiMenuDone().
ib
parents:
35783
diff
changeset
|
262 { |
497a1c45a597
Add uiMainDone(), uiVideoDone(), uiPlaybarDone() and uiMenuDone().
ib
parents:
35783
diff
changeset
|
263 nfree(playbarDrawBuffer); |
497a1c45a597
Add uiMainDone(), uiVideoDone(), uiPlaybarDone() and uiMenuDone().
ib
parents:
35783
diff
changeset
|
264 wsWindowDestroy(&guiApp.playbarWindow); |
36291 | 265 wsEvents(); |
35796
497a1c45a597
Add uiMainDone(), uiVideoDone(), uiPlaybarDone() and uiMenuDone().
ib
parents:
35783
diff
changeset
|
266 } |
497a1c45a597
Add uiMainDone(), uiVideoDone(), uiPlaybarDone() and uiMenuDone().
ib
parents:
35783
diff
changeset
|
267 |
35765 | 268 void uiPlaybarShow( int y ) |
269 { | |
270 if ( !guiApp.playbarIsPresent || !gtkEnablePlayBar ) return; | |
271 if ( !guiApp.videoWindow.isFullScreen ) return; | |
272 | |
273 if ( y > guiApp.videoWindow.Height - guiApp.playbar.height ) | |
274 { | |
275 if ( !uiPlaybarFade ) wsWindowVisibility( &guiApp.playbarWindow,wsShowWindow ); | |
276 uiPlaybarFade=1; playbarVisible=True; wsWindowRedraw( &guiApp.playbarWindow ); | |
277 } | |
278 else if ( !uiPlaybarFade ) uiPlaybarFade=2; | |
279 } |