annotate gui/mplayer/pb.c @ 33107:eda3df3e4a9d

Prevent an out-of-bounds array access. This out-of-bounds array access was of not much effect until r33190, because the variables falsely changed (set to 1) were either almost always unused (the last member of the mainItems array) or variable menuIsPresent which only has effect if there is a menu present (in which case it is set anyway). With r33190 the wItem (and thus the guiItems) structure size changed and now variables were accessed whose changings have visible effect. After releasing the moved main (or playbar) window, the IndexOfItems values got destroyed and items disappeared.
author ib
date Sun, 03 Apr 2011 14:24:36 +0000
parents 21e0de9c355f
children 5450a92ac4bd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26458
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
1 /*
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
2 * main window
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
3 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
4 * This file is part of MPlayer.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
5 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
6 * MPlayer is free software; you can redistribute it and/or modify
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
7 * it under the terms of the GNU General Public License as published by
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
9 * (at your option) any later version.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
10 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
11 * MPlayer is distributed in the hope that it will be useful,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
14 * GNU General Public License for more details.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
15 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
16 * You should have received a copy of the GNU General Public License along
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
19 */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
20
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
21 #include <stdlib.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
22 #include <stdio.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
23 #include <inttypes.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
24 #include <sys/stat.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
25 #include <unistd.h>
23305
22d3d12c6dfb Include string.h for memcpy, fastmemcpy.h alone is not enough.
reimar
parents: 23077
diff changeset
26 #include <string.h>
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
27
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
28 #include "config.h"
26365
10dfbc523184 Add gui/ prefix to some #include paths so that compilation from the
diego
parents: 26203
diff changeset
29 #include "gui/app.h"
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"
10dfbc523184 Add gui/ prefix to some #include paths so that compilation from the
diego
parents: 26203
diff changeset
32 #include "gui/wm/ws.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
33
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
34 #include "help_mp.h"
33024
21e0de9c355f Show GUI message when GUI must exit.
ib
parents: 32931
diff changeset
35 #include "mp_core.h"
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
36 #include "libvo/x11_common.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
37 #include "libvo/fastmemcpy.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
38
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
39 #include "stream/stream.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
40 #include "mixer.h"
32467
fbe5c829c69b Move libvo/sub.[ch] from libvo to sub.
cigaes
parents: 30535
diff changeset
41 #include "sub/sub.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
42
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
43 #include "libmpdemux/demuxer.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
44 #include "libmpdemux/stheader.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
45 #include "codec-cfg.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
46
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
47 #include "gmplayer.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
48 #include "play.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
49 #include "widgets.h"
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents: 23457
diff changeset
50 #include "gui_common.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
51
28051
9e739bdb049c Get rid of pointless 'extern' keywords.
diego
parents: 26458
diff changeset
52 unsigned int GetTimerMS( void );
9e739bdb049c Get rid of pointless 'extern' keywords.
diego
parents: 26458
diff changeset
53 unsigned int GetTimer( void );
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
54
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
55 unsigned char * mplPBDrawBuffer = NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
56 int mplPBVisible = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
57 int mplPBLength = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
58 int mplPBFade = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
59
30535
016e5fc1dead GUI: Mark functions that are not used outside their files as static.
diego
parents: 29263
diff changeset
60 static void mplPBDraw( void )
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
61 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
62 int x;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
63
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
64 if ( !appMPlayer.subWindow.isFullScreen ) return;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
65 if ( !mplPBVisible || !appMPlayer.barIsPresent ) return;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
66
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
67 // appMPlayer.bar.x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ) / 2;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
68 switch( appMPlayer.bar.x )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
69 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
70 case -1: x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ) / 2; break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
71 case -2: x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ); break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
72 default: x=appMPlayer.bar.x;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
73 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
74
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
75 switch ( mplPBFade )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
76 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
77 case 1: // fade in
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
78 mplPBLength--;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
79 if ( appMPlayer.subWindow.Height - appMPlayer.bar.height >= mplPBLength )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
80 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
81 mplPBLength=appMPlayer.subWindow.Height - appMPlayer.bar.height;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
82 mplPBFade=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
83 vo_mouse_autohide=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
84 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
85 wsMoveWindow( &appMPlayer.barWindow,0,x,mplPBLength );
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
86 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
87 case 2: // fade out
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
88 mplPBLength+=10;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
89 if ( mplPBLength > appMPlayer.subWindow.Height )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
90 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
91 mplPBLength=appMPlayer.subWindow.Height;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
92 mplPBFade=mplPBVisible=0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
93 vo_mouse_autohide=1;
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
94 wsVisibleWindow( &appMPlayer.barWindow,wsHideWindow );
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
95 return;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
96 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
97 wsMoveWindow( &appMPlayer.barWindow,0,x,mplPBLength );
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
98 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
99 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
100
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
101 // --- render
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
102 if ( appMPlayer.barWindow.State == wsWindowExpose )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
103 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
104 btnModify( evSetMoviePosition,guiIntfStruct.Position );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
105 btnModify( evSetVolume,guiIntfStruct.Volume );
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
106
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
107 vo_mouse_autohide=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
108
23457
a124f3abc1ec Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents: 23305
diff changeset
109 fast_memcpy( mplPBDrawBuffer,appMPlayer.bar.Bitmap.Image,appMPlayer.bar.Bitmap.ImageSize );
32931
03b1051bed5c Rename the 'NumberOf' members of the listItems structure.
ib
parents: 32919
diff changeset
110 Render( &appMPlayer.barWindow,appMPlayer.barItems,appMPlayer.IndexOfBarItems,mplPBDrawBuffer,appMPlayer.bar.Bitmap.ImageSize );
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
111 wsConvert( &appMPlayer.barWindow,mplPBDrawBuffer,appMPlayer.bar.Bitmap.ImageSize );
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
112 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
113 wsPutImage( &appMPlayer.barWindow );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
114 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
115
30535
016e5fc1dead GUI: Mark functions that are not used outside their files as static.
diego
parents: 29263
diff changeset
116 static void mplPBMouseHandle( int Button, int X, int Y, int RX, int RY )
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
117 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
118 static int itemtype = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
119 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
120 wItem * item = NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
121 float value = 0.0f;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
122
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
123 static int SelectedItem = -1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
124 int currentselected = -1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
125
32931
03b1051bed5c Rename the 'NumberOf' members of the listItems structure.
ib
parents: 32919
diff changeset
126 for ( i=0;i <= appMPlayer.IndexOfBarItems;i++ )
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
127 if ( ( appMPlayer.barItems[i].pressed != btnDisabled )&&
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
128 ( wgIsRect( X,Y,appMPlayer.barItems[i].x,appMPlayer.barItems[i].y,appMPlayer.barItems[i].x+appMPlayer.barItems[i].width,appMPlayer.barItems[i].y+appMPlayer.barItems[i].height ) ) )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
129 { currentselected=i; break; }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
130
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
131 switch ( Button )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
132 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
133 case wsPMMouseButton:
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
134 gtkShow( evHidePopUpMenu,NULL );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
135 mplShowMenu( RX,RY );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
136 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
137 case wsRMMouseButton:
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
138 mplHideMenu( RX,RY,0 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
139 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
140 case wsRRMouseButton:
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
141 gtkShow( evShowPopUpMenu,NULL );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
142 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
143 // ---
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
144 case wsPLMouseButton:
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
145 gtkShow( evHidePopUpMenu,NULL );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
146 SelectedItem=currentselected;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
147 if ( SelectedItem == -1 ) break; // yeees, i'm move the fucking window
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
148 item=&appMPlayer.barItems[SelectedItem];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
149 itemtype=item->type;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
150 item->pressed=btnPressed;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
151
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
152 switch( item->type )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
153 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
154 case itButton:
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
155 if ( ( SelectedItem > -1 ) &&
32911
e06fbdd8eb46 Clean up the wItem structure.
ib
parents: 32467
diff changeset
156 ( ( ( item->message == evPlaySwitchToPause && item->message == evPauseSwitchToPlay ) ) ||
e06fbdd8eb46 Clean up the wItem structure.
ib
parents: 32467
diff changeset
157 ( ( item->message == evPauseSwitchToPlay && item->message == evPlaySwitchToPause ) ) ) )
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
158 { item->pressed=btnDisabled; }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
159 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
160 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
161
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
162 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
163 case wsRLMouseButton:
33107
eda3df3e4a9d Prevent an out-of-bounds array access.
ib
parents: 33024
diff changeset
164 if ( SelectedItem != -1 ) // NOTE TO MYSELF: only if itButton, itHPotmeter or itVPotmeter
eda3df3e4a9d Prevent an out-of-bounds array access.
ib
parents: 33024
diff changeset
165 {
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
166 item=&appMPlayer.barItems[SelectedItem];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
167 item->pressed=btnReleased;
33107
eda3df3e4a9d Prevent an out-of-bounds array access.
ib
parents: 33024
diff changeset
168 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
169 SelectedItem=-1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
170 if ( currentselected == - 1 ) { itemtype=0; break; }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
171 value=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
172
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
173 switch( itemtype )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
174 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
175 case itPotmeter:
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
176 case itHPotmeter:
32911
e06fbdd8eb46 Clean up the wItem structure.
ib
parents: 32467
diff changeset
177 btnModify( item->message,(float)( X - item->x ) / item->width * 100.0f );
e06fbdd8eb46 Clean up the wItem structure.
ib
parents: 32467
diff changeset
178 mplEventHandling( item->message,item->value );
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
179 value=item->value;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
180 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
181 case itVPotmeter:
32911
e06fbdd8eb46 Clean up the wItem structure.
ib
parents: 32467
diff changeset
182 btnModify( item->message, ( 1. - (float)( Y - item->y ) / item->height) * 100.0f );
e06fbdd8eb46 Clean up the wItem structure.
ib
parents: 32467
diff changeset
183 mplEventHandling( item->message,item->value );
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
184 value=item->value;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
185 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
186 }
32911
e06fbdd8eb46 Clean up the wItem structure.
ib
parents: 32467
diff changeset
187 mplEventHandling( item->message,value );
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
188
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
189 itemtype=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
190 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
191 // ---
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
192 case wsP5MouseButton: value=-2.5f; goto rollerhandled;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
193 case wsP4MouseButton: value= 2.5f;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
194 rollerhandled:
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
195 item=&appMPlayer.barItems[currentselected];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
196 if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
197 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
198 item->value+=value;
32911
e06fbdd8eb46 Clean up the wItem structure.
ib
parents: 32467
diff changeset
199 btnModify( item->message,item->value );
e06fbdd8eb46 Clean up the wItem structure.
ib
parents: 32467
diff changeset
200 mplEventHandling( item->message,item->value );
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
201 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
202 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
203 // ---
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
204 case wsMoveMouse:
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
205 item=&appMPlayer.barItems[SelectedItem];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
206 switch ( itemtype )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
207 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
208 case itPRMButton:
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
209 mplMenuMouseHandle( X,Y,RX,RY );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
210 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
211 case itPotmeter:
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
212 item->value=(float)( X - item->x ) / item->width * 100.0f;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
213 goto potihandled;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
214 case itVPotmeter:
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
215 item->value=(1. - (float)( Y - item->y ) / item->height) * 100.0f;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
216 goto potihandled;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
217 case itHPotmeter:
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
218 item->value=(float)( X - item->x ) / item->width * 100.0f;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
219 potihandled:
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
220 if ( item->value > 100.0f ) item->value=100.0f;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
221 if ( item->value < 0.0f ) item->value=0.0f;
32911
e06fbdd8eb46 Clean up the wItem structure.
ib
parents: 32467
diff changeset
222 mplEventHandling( item->message,item->value );
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
223 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
224 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
225 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
226 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
227 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
228
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
229 void mplPBShow( int x, int y )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
230 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
231 if ( !appMPlayer.barIsPresent || !gtkEnablePlayBar ) return;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
232 if ( !appMPlayer.subWindow.isFullScreen ) return;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
233
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
234 if ( y > appMPlayer.subWindow.Height - appMPlayer.bar.height )
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
235 {
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
236 if ( !mplPBFade ) wsVisibleWindow( &appMPlayer.barWindow,wsShowWindow );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
237 mplPBFade=1; mplPBVisible=1; wsPostRedisplay( &appMPlayer.barWindow );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
238 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
239 else if ( !mplPBFade ) mplPBFade=2;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
240 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
241
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
242 void mplPBInit( void )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
243 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
244 if ( !appMPlayer.barIsPresent ) return;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
245
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
246 gfree( (void**)&mplPBDrawBuffer );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
247
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
248 if ( ( mplPBDrawBuffer = malloc( appMPlayer.bar.Bitmap.ImageSize ) ) == NULL )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
249 {
33024
21e0de9c355f Show GUI message when GUI must exit.
ib
parents: 32931
diff changeset
250 gmp_msg( MSGT_GPLAYER,MSGL_FATAL,MSGTR_NEMDB );
21e0de9c355f Show GUI message when GUI must exit.
ib
parents: 32931
diff changeset
251 exit_player( EXIT_ERROR );
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
252 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
253
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
254 appMPlayer.barWindow.Parent=appMPlayer.subWindow.WindowID;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
255 wsCreateWindow( &appMPlayer.barWindow,
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
256 appMPlayer.bar.x,appMPlayer.bar.y,appMPlayer.bar.width,appMPlayer.bar.height,
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
257 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsHideFrame|wsHideWindow,"PlayBar" );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
258
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
259 wsSetShape( &appMPlayer.barWindow,appMPlayer.bar.Mask.Image );
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
260
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
261 appMPlayer.barWindow.ReDraw=(void *)mplPBDraw;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
262 appMPlayer.barWindow.MouseHandler=mplPBMouseHandle;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
263 appMPlayer.barWindow.KeyHandler=mplMainKeyHandle;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
264
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
265 mplPBLength=appMPlayer.subWindow.Height;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
266 }