Mercurial > mplayer.hg
annotate Gui/mplayer/menu.c @ 8389:e8c51ec86340
fixed in/out framesize rounding bug (causing low-rate QCLP hangup/looping)
disabled TerminateQTML(), as it does carshing (due to patched InitializeQTML)
author | arpi |
---|---|
date | Sat, 07 Dec 2002 02:26:45 +0000 |
parents | 9246adcf95f0 |
children | d07ab8e088a9 |
rev | line source |
---|---|
8058 | 1 |
2 #include <stdlib.h> | |
3 #include <stdio.h> | |
4 #include <inttypes.h> | |
5 | |
6 #include "../app.h" | |
7 #include "../../config.h" | |
8 #include "../../help_mp.h" | |
9 #include "../../mp_msg.h" | |
10 | |
11 #include "widgets.h" | |
1693 | 12 |
13 unsigned char * mplMenuDrawBuffer = NULL; | |
14 int mplMenuRender = 1; | |
15 int mplMenuItem = -1; | |
16 int mplOldMenuItem = -1; | |
17 int mplMenuX,mplMenuY; | |
18 | |
5919 | 19 void mplHideMenu( int mx,int my,int w ); |
1693 | 20 |
8058 | 21 void mplMenuDraw( void ) |
1693 | 22 { |
6159
dcf195b784bf
applied 64bit patch from Ulrich Hecht <uli@suse.de>
pontscho
parents:
6146
diff
changeset
|
23 uint32_t * buf = NULL; |
dcf195b784bf
applied 64bit patch from Ulrich Hecht <uli@suse.de>
pontscho
parents:
6146
diff
changeset
|
24 uint32_t * drw = NULL; |
4465 | 25 int x,y,tmp; |
1693 | 26 |
27 if ( !appMPlayer.menuBase.Bitmap.Image ) return; | |
3476 | 28 if ( !mplMenuRender && !appMPlayer.menuWindow.Visible ) return; |
1693 | 29 |
30 if ( mplMenuRender || mplMenuItem != mplOldMenuItem ) | |
31 { | |
32 memcpy( mplMenuDrawBuffer,appMPlayer.menuBase.Bitmap.Image,appMPlayer.menuBase.Bitmap.ImageSize ); | |
33 // --- | |
34 if ( mplMenuItem != -1 ) | |
35 { | |
6159
dcf195b784bf
applied 64bit patch from Ulrich Hecht <uli@suse.de>
pontscho
parents:
6146
diff
changeset
|
36 buf=(uint32_t *)mplMenuDrawBuffer; |
dcf195b784bf
applied 64bit patch from Ulrich Hecht <uli@suse.de>
pontscho
parents:
6146
diff
changeset
|
37 drw=(uint32_t *)appMPlayer.menuSelected.Bitmap.Image; |
1693 | 38 for ( y=appMPlayer.MenuItems[ mplMenuItem ].y; y < appMPlayer.MenuItems[ mplMenuItem ].y + appMPlayer.MenuItems[ mplMenuItem ].height; y++ ) |
39 for ( x=appMPlayer.MenuItems[ mplMenuItem ].x; x < appMPlayer.MenuItems[ mplMenuItem ].x + appMPlayer.MenuItems[ mplMenuItem ].width; x++ ) | |
40 { | |
41 tmp=drw[ y * appMPlayer.menuSelected.width + x ]; | |
42 if ( tmp != 0x00ff00ff ) buf[ y * appMPlayer.menuBase.width + x ]=tmp; | |
43 } | |
44 } | |
45 mplOldMenuItem=mplMenuItem; | |
46 // --- | |
47 wsConvert( &appMPlayer.menuWindow,mplMenuDrawBuffer,appMPlayer.menuBase.Bitmap.ImageSize ); | |
48 mplMenuRender=0; | |
49 } | |
50 wsPutImage( &appMPlayer.menuWindow ); | |
51 } | |
52 | |
53 void mplMenuMouseHandle( int X,int Y,int RX,int RY ) | |
54 { | |
55 int x,y,i; | |
56 | |
57 if ( !appMPlayer.menuBase.Bitmap.Image ) return; | |
58 | |
59 mplMenuItem=-1; | |
60 x=RX - appMPlayer.menuWindow.X; | |
61 y=RY - appMPlayer.menuWindow.Y; | |
62 if ( ( x < 0 ) || ( y < 0 ) || ( x > appMPlayer.menuBase.width ) || ( y > appMPlayer.menuBase.height ) ) | |
63 { | |
64 wsPostRedisplay( &appMPlayer.menuWindow ); | |
65 return; | |
66 } | |
67 | |
1823 | 68 for( i=0;i<=appMPlayer.NumberOfMenuItems;i++ ) |
1693 | 69 { |
70 if ( wgIsRect( x,y, | |
71 appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y, | |
1823 | 72 appMPlayer.MenuItems[i].x+appMPlayer.MenuItems[i].width,appMPlayer.MenuItems[i].y+appMPlayer.MenuItems[i].height ) ) { mplMenuItem=i; break; } |
1693 | 73 } |
74 wsPostRedisplay( &appMPlayer.menuWindow ); | |
75 } | |
76 | |
77 void mplShowMenu( int mx,int my ) | |
78 { | |
79 int x,y; | |
80 | |
81 if ( !appMPlayer.menuBase.Bitmap.Image ) return; | |
82 | |
83 x=mx; | |
84 if ( x + appMPlayer.menuWindow.Width > wsMaxX ) x=wsMaxX - appMPlayer.menuWindow.Width - 1; | |
85 y=my; | |
86 if ( y + appMPlayer.menuWindow.Height > wsMaxY ) y=wsMaxY - appMPlayer.menuWindow.Height - 1; | |
87 | |
88 mplMenuX=x; mplMenuY=y; | |
89 | |
90 mplMenuItem = 0; | |
91 | |
2854 | 92 wsMoveWindow( &appMPlayer.menuWindow,False,x,y ); |
6146 | 93 wsMoveTopWindow( wsDisplay,appMPlayer.menuWindow.WindowID ); |
6221 | 94 wsSetLayer( wsDisplay,appMPlayer.menuWindow.WindowID,1 ); |
3476 | 95 mplMenuRender=1; |
1693 | 96 wsVisibleWindow( &appMPlayer.menuWindow,wsShowWindow ); |
3476 | 97 wsPostRedisplay( &appMPlayer.menuWindow ); |
1693 | 98 } |
99 | |
5919 | 100 void mplHideMenu( int mx,int my,int w ) |
1693 | 101 { |
102 int x,y,i=mplMenuItem; | |
103 | |
104 if ( !appMPlayer.menuBase.Bitmap.Image ) return; | |
105 | |
106 x=mx-mplMenuX; | |
107 y=my-mplMenuY; | |
1823 | 108 // x=RX - appMPlayer.menuWindow.X; |
109 // y=RY - appMPlayer.menuWindow.Y; | |
1693 | 110 |
111 wsVisibleWindow( &appMPlayer.menuWindow,wsHideWindow ); | |
112 | |
113 if ( ( x < 0 ) || ( y < 0 ) ) return; | |
114 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4465
diff
changeset
|
115 // printf( "---------> %d %d,%d\n",i,x,y ); |
3476 | 116 // printf( "--------> mi: %d,%d %dx%d\n",appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y,appMPlayer.MenuItems[i].width,appMPlayer.MenuItems[i].height ); |
1693 | 117 if ( wgIsRect( x,y, |
118 appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y, | |
119 appMPlayer.MenuItems[i].x+appMPlayer.MenuItems[i].width, | |
120 appMPlayer.MenuItems[i].y+appMPlayer.MenuItems[i].height ) ) | |
121 { | |
5919 | 122 mplEventHandling( appMPlayer.MenuItems[i].msg,(float)w ); |
1693 | 123 } |
124 } | |
125 | |
126 void mplMenuInit( void ) | |
127 { | |
128 | |
129 if ( !appMPlayer.menuBase.Bitmap.Image ) return; | |
130 | |
131 appMPlayer.menuBase.x=0; | |
132 appMPlayer.menuBase.y=0; | |
133 | |
134 if ( ( mplMenuDrawBuffer = calloc( 1,appMPlayer.menuBase.Bitmap.ImageSize ) ) == NULL ) | |
135 { | |
136 #ifdef DEBUG | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4465
diff
changeset
|
137 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[menu.h] %s",MSGTR_NEMFMR ); |
1693 | 138 #endif |
1907 | 139 gtkMessageBox( GTK_MB_FATAL,MSGTR_NEMFMR ); |
1693 | 140 return; |
141 } | |
142 | |
143 wsCreateWindow( &appMPlayer.menuWindow, | |
144 appMPlayer.menuBase.x,appMPlayer.menuBase.y,appMPlayer.menuBase.width,appMPlayer.menuBase.height, | |
4411 | 145 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsOverredirect|wsHideFrame|wsMaxSize|wsMinSize|wsHideWindow,"MPlayer menu" ); |
1693 | 146 |
6221 | 147 wsSetShape( &appMPlayer.menuWindow,appMPlayer.menuBase.Mask.Image ); |
148 | |
1693 | 149 #ifdef DEBUG |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4465
diff
changeset
|
150 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[menu.h] menu: 0x%x\n",(int)appMPlayer.menuWindow.WindowID ); |
1693 | 151 #endif |
152 | |
153 appMPlayer.menuWindow.ReDraw=mplMenuDraw; | |
154 // appMPlayer.menuWindow.MouseHandler=mplMenuMouseHandle; | |
155 // appMPlayer.menuWindow.KeyHandler=mplMainKeyHandle; | |
3476 | 156 mplMenuRender=1; wsPostRedisplay( &appMPlayer.menuWindow ); |
1693 | 157 } |