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