Mercurial > mplayer.hg
annotate gui/mplayer/menu.c @ 24938:328a5d99203e
Fix previous incorrect commit, +/- has higher precedence than shifts.
author | diego |
---|---|
date | Sun, 04 Nov 2007 13:41:07 +0000 |
parents | 1cb14b091f46 |
children | 0d255d03016f |
rev | line source |
---|---|
23077 | 1 |
2 #include <stdlib.h> | |
3 #include <stdio.h> | |
4 #include <inttypes.h> | |
5 | |
6 #include "app.h" | |
23154
e564b9cd7290
Fix several implicit declarations of functions warnings.
diego
parents:
23077
diff
changeset
|
7 #include "gmplayer.h" |
23077 | 8 #include "../config.h" |
9 #include "../help_mp.h" | |
10 #include "../mp_msg.h" | |
11 | |
12 #include "widgets.h" | |
13 | |
14 unsigned char * mplMenuDrawBuffer = NULL; | |
15 int mplMenuRender = 1; | |
16 int mplMenuItem = -1; | |
17 int mplOldMenuItem = -1; | |
18 int mplMenuX,mplMenuY; | |
19 static int mplMenuIsInitialized = 0; | |
20 | |
21 void mplMenuDraw( void ) | |
22 { | |
23 uint32_t * buf = NULL; | |
24 uint32_t * drw = NULL; | |
25 int x,y,tmp; | |
26 | |
27 if ( !appMPlayer.menuIsPresent || !appMPlayer.menuBase.Bitmap.Image ) return; | |
28 if ( !mplMenuRender && !appMPlayer.menuWindow.Visible ) return; | |
29 | |
30 if ( mplMenuRender || mplMenuItem != mplOldMenuItem ) | |
31 { | |
32 memcpy( mplMenuDrawBuffer,appMPlayer.menuBase.Bitmap.Image,appMPlayer.menuBase.Bitmap.ImageSize ); | |
33 // --- | |
34 if ( mplMenuItem != -1 ) | |
35 { | |
36 buf=(uint32_t *)mplMenuDrawBuffer; | |
37 drw=(uint32_t *)appMPlayer.menuSelected.Bitmap.Image; | |
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 | |
68 for( i=0;i<=appMPlayer.NumberOfMenuItems;i++ ) | |
69 { | |
70 if ( wgIsRect( x,y, | |
71 appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y, | |
72 appMPlayer.MenuItems[i].x+appMPlayer.MenuItems[i].width,appMPlayer.MenuItems[i].y+appMPlayer.MenuItems[i].height ) ) { mplMenuItem=i; break; } | |
73 } | |
74 wsPostRedisplay( &appMPlayer.menuWindow ); | |
75 } | |
76 | |
77 void mplShowMenu( int mx,int my ) | |
78 { | |
79 int x,y; | |
80 | |
81 if ( !appMPlayer.menuIsPresent || !appMPlayer.menuBase.Bitmap.Image ) return; | |
82 | |
83 x=mx; | |
84 if ( x + appMPlayer.menuWindow.Width > wsMaxX ) x=wsMaxX - appMPlayer.menuWindow.Width - 1 + wsOrgX; | |
85 y=my; | |
86 if ( y + appMPlayer.menuWindow.Height > wsMaxY ) y=wsMaxY - appMPlayer.menuWindow.Height - 1 + wsOrgY; | |
87 | |
88 mplMenuX=x; mplMenuY=y; | |
89 | |
90 mplMenuItem = 0; | |
91 | |
92 wsMoveWindow( &appMPlayer.menuWindow,False,x,y ); | |
93 wsMoveTopWindow( wsDisplay,appMPlayer.menuWindow.WindowID ); | |
94 wsSetLayer( wsDisplay,appMPlayer.menuWindow.WindowID,1 ); | |
95 mplMenuRender=1; | |
96 wsVisibleWindow( &appMPlayer.menuWindow,wsShowWindow ); | |
97 wsPostRedisplay( &appMPlayer.menuWindow ); | |
98 } | |
99 | |
100 void mplHideMenu( int mx,int my,int w ) | |
101 { | |
102 int x,y,i=mplMenuItem; | |
103 | |
104 if ( !appMPlayer.menuIsPresent || !appMPlayer.menuBase.Bitmap.Image ) return; | |
105 | |
106 x=mx-mplMenuX; | |
107 y=my-mplMenuY; | |
108 // x=RX - appMPlayer.menuWindow.X; | |
109 // y=RY - appMPlayer.menuWindow.Y; | |
110 | |
111 wsVisibleWindow( &appMPlayer.menuWindow,wsHideWindow ); | |
112 | |
113 if ( ( x < 0 ) || ( y < 0 ) ) return; | |
114 | |
115 // printf( "---------> %d %d,%d\n",i,x,y ); | |
116 // printf( "--------> mi: %d,%d %dx%d\n",appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y,appMPlayer.MenuItems[i].width,appMPlayer.MenuItems[i].height ); | |
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 { | |
122 mplEventHandling( appMPlayer.MenuItems[i].msg,(float)w ); | |
123 } | |
124 } | |
125 | |
126 void mplMenuInit( void ) | |
127 { | |
128 | |
129 if ( mplMenuIsInitialized || !appMPlayer.menuIsPresent || !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 | |
137 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[menu.h] %s",MSGTR_NEMFMR ); | |
138 #endif | |
139 gtkMessageBox( GTK_MB_FATAL,MSGTR_NEMFMR ); | |
140 return; | |
141 } | |
142 | |
143 wsCreateWindow( &appMPlayer.menuWindow, | |
144 appMPlayer.menuBase.x,appMPlayer.menuBase.y,appMPlayer.menuBase.width,appMPlayer.menuBase.height, | |
145 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsOverredirect|wsHideFrame|wsMaxSize|wsMinSize|wsHideWindow,"MPlayer menu" ); | |
146 | |
147 wsSetShape( &appMPlayer.menuWindow,appMPlayer.menuBase.Mask.Image ); | |
148 | |
149 #ifdef DEBUG | |
150 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[menu.h] menu: 0x%x\n",(int)appMPlayer.menuWindow.WindowID ); | |
151 #endif | |
152 | |
153 mplMenuIsInitialized=1; | |
154 appMPlayer.menuWindow.ReDraw=mplMenuDraw; | |
155 // appMPlayer.menuWindow.MouseHandler=mplMenuMouseHandle; | |
156 // appMPlayer.menuWindow.KeyHandler=mplMainKeyHandle; | |
157 mplMenuRender=1; wsPostRedisplay( &appMPlayer.menuWindow ); | |
158 } |