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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8058
9246adcf95f0 cosmetic
pontscho
parents: 8048
diff changeset
1
9246adcf95f0 cosmetic
pontscho
parents: 8048
diff changeset
2 #include <stdlib.h>
9246adcf95f0 cosmetic
pontscho
parents: 8048
diff changeset
3 #include <stdio.h>
9246adcf95f0 cosmetic
pontscho
parents: 8048
diff changeset
4 #include <inttypes.h>
9246adcf95f0 cosmetic
pontscho
parents: 8048
diff changeset
5
17144
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 10194
diff changeset
6 #include "app.h"
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 10194
diff changeset
7 #include "../config.h"
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 10194
diff changeset
8 #include "../help_mp.h"
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 10194
diff changeset
9 #include "../mp_msg.h"
8058
9246adcf95f0 cosmetic
pontscho
parents: 8048
diff changeset
10
9246adcf95f0 cosmetic
pontscho
parents: 8048
diff changeset
11 #include "widgets.h"
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
12
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
13 unsigned char * mplMenuDrawBuffer = NULL;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
14 int mplMenuRender = 1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
15 int mplMenuItem = -1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
16 int mplOldMenuItem = -1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
17 int mplMenuX,mplMenuY;
8949
d07ab8e088a9 correct skin changing
pontscho
parents: 8058
diff changeset
18 static int mplMenuIsInitialized = 0;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
19
5919
60cf2bca993f some bug fix
pontscho
parents: 4818
diff changeset
20 void mplHideMenu( int mx,int my,int w );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
21
8058
9246adcf95f0 cosmetic
pontscho
parents: 8048
diff changeset
22 void mplMenuDraw( void )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
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
b013d01d9968 small bugfixes, and kill other warning
pontscho
parents: 4411
diff changeset
26 int x,y,tmp;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
27
8949
d07ab8e088a9 correct skin changing
pontscho
parents: 8058
diff changeset
28 if ( !appMPlayer.menuIsPresent || !appMPlayer.menuBase.Bitmap.Image ) return;
3476
d8e46c2576c5 fix black ize
pontscho
parents: 2854
diff changeset
29 if ( !mplMenuRender && !appMPlayer.menuWindow.Visible ) return;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
30
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
31 if ( mplMenuRender || mplMenuItem != mplOldMenuItem )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
32 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
33 memcpy( mplMenuDrawBuffer,appMPlayer.menuBase.Bitmap.Image,appMPlayer.menuBase.Bitmap.ImageSize );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
34 // ---
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
35 if ( mplMenuItem != -1 )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
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
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
39 for ( y=appMPlayer.MenuItems[ mplMenuItem ].y; y < appMPlayer.MenuItems[ mplMenuItem ].y + appMPlayer.MenuItems[ mplMenuItem ].height; y++ )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
40 for ( x=appMPlayer.MenuItems[ mplMenuItem ].x; x < appMPlayer.MenuItems[ mplMenuItem ].x + appMPlayer.MenuItems[ mplMenuItem ].width; x++ )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
41 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
42 tmp=drw[ y * appMPlayer.menuSelected.width + x ];
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
43 if ( tmp != 0x00ff00ff ) buf[ y * appMPlayer.menuBase.width + x ]=tmp;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
44 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
45 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
46 mplOldMenuItem=mplMenuItem;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
47 // ---
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
48 wsConvert( &appMPlayer.menuWindow,mplMenuDrawBuffer,appMPlayer.menuBase.Bitmap.ImageSize );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
49 mplMenuRender=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
50 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
51 wsPutImage( &appMPlayer.menuWindow );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
52 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
53
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
54 void mplMenuMouseHandle( int X,int Y,int RX,int RY )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
55 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
56 int x,y,i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
57
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
58 if ( !appMPlayer.menuBase.Bitmap.Image ) return;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
59
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
60 mplMenuItem=-1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
61 x=RX - appMPlayer.menuWindow.X;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
62 y=RY - appMPlayer.menuWindow.Y;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
63 if ( ( x < 0 ) || ( y < 0 ) || ( x > appMPlayer.menuBase.width ) || ( y > appMPlayer.menuBase.height ) )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
64 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
65 wsPostRedisplay( &appMPlayer.menuWindow );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
66 return;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
67 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
68
1823
a6c67352ccac fix some bug.
pontscho
parents: 1693
diff changeset
69 for( i=0;i<=appMPlayer.NumberOfMenuItems;i++ )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
70 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
71 if ( wgIsRect( x,y,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
72 appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y,
1823
a6c67352ccac fix some bug.
pontscho
parents: 1693
diff changeset
73 appMPlayer.MenuItems[i].x+appMPlayer.MenuItems[i].width,appMPlayer.MenuItems[i].y+appMPlayer.MenuItems[i].height ) ) { mplMenuItem=i; break; }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
74 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
75 wsPostRedisplay( &appMPlayer.menuWindow );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
76 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
77
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
78 void mplShowMenu( int mx,int my )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
79 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
80 int x,y;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
81
8949
d07ab8e088a9 correct skin changing
pontscho
parents: 8058
diff changeset
82 if ( !appMPlayer.menuIsPresent || !appMPlayer.menuBase.Bitmap.Image ) return;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
83
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
84 x=mx;
10194
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 8949
diff changeset
85 if ( x + appMPlayer.menuWindow.Width > wsMaxX ) x=wsMaxX - appMPlayer.menuWindow.Width - 1 + wsOrgX;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
86 y=my;
10194
2608bf0037b6 From: Ben Low <ben@bdlow.net>
pontscho
parents: 8949
diff changeset
87 if ( y + appMPlayer.menuWindow.Height > wsMaxY ) y=wsMaxY - appMPlayer.menuWindow.Height - 1 + wsOrgY;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
88
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
89 mplMenuX=x; mplMenuY=y;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
90
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
91 mplMenuItem = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
92
2854
fd44ecf77f8d move bug meg fileload bug fixed asszem.
pontscho
parents: 1907
diff changeset
93 wsMoveWindow( &appMPlayer.menuWindow,False,x,y );
6146
b9651eb9749e fix some gtk bug...
pontscho
parents: 6145
diff changeset
94 wsMoveTopWindow( wsDisplay,appMPlayer.menuWindow.WindowID );
6221
4b2459557340 add XShape support for gui's submenu
pontscho
parents: 6159
diff changeset
95 wsSetLayer( wsDisplay,appMPlayer.menuWindow.WindowID,1 );
3476
d8e46c2576c5 fix black ize
pontscho
parents: 2854
diff changeset
96 mplMenuRender=1;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
97 wsVisibleWindow( &appMPlayer.menuWindow,wsShowWindow );
3476
d8e46c2576c5 fix black ize
pontscho
parents: 2854
diff changeset
98 wsPostRedisplay( &appMPlayer.menuWindow );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
99 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
100
5919
60cf2bca993f some bug fix
pontscho
parents: 4818
diff changeset
101 void mplHideMenu( int mx,int my,int w )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
102 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
103 int x,y,i=mplMenuItem;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
104
8949
d07ab8e088a9 correct skin changing
pontscho
parents: 8058
diff changeset
105 if ( !appMPlayer.menuIsPresent || !appMPlayer.menuBase.Bitmap.Image ) return;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
106
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
107 x=mx-mplMenuX;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
108 y=my-mplMenuY;
1823
a6c67352ccac fix some bug.
pontscho
parents: 1693
diff changeset
109 // x=RX - appMPlayer.menuWindow.X;
a6c67352ccac fix some bug.
pontscho
parents: 1693
diff changeset
110 // y=RY - appMPlayer.menuWindow.Y;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
111
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
112 wsVisibleWindow( &appMPlayer.menuWindow,wsHideWindow );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
113
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
114 if ( ( x < 0 ) || ( y < 0 ) ) return;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
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
d8e46c2576c5 fix black ize
pontscho
parents: 2854
diff changeset
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
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
118 if ( wgIsRect( x,y,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
119 appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
120 appMPlayer.MenuItems[i].x+appMPlayer.MenuItems[i].width,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
121 appMPlayer.MenuItems[i].y+appMPlayer.MenuItems[i].height ) )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
122 {
5919
60cf2bca993f some bug fix
pontscho
parents: 4818
diff changeset
123 mplEventHandling( appMPlayer.MenuItems[i].msg,(float)w );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
124 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
125 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
126
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
127 void mplMenuInit( void )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
128 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
129
8949
d07ab8e088a9 correct skin changing
pontscho
parents: 8058
diff changeset
130 if ( mplMenuIsInitialized || !appMPlayer.menuIsPresent || !appMPlayer.menuBase.Bitmap.Image ) return;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
131
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
132 appMPlayer.menuBase.x=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
133 appMPlayer.menuBase.y=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
134
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
135 if ( ( mplMenuDrawBuffer = calloc( 1,appMPlayer.menuBase.Bitmap.ImageSize ) ) == NULL )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
136 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
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
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
139 #endif
1907
83291fafe66c add new features. and fix skin error loop.
pontscho
parents: 1884
diff changeset
140 gtkMessageBox( GTK_MB_FATAL,MSGTR_NEMFMR );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
141 return;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
142 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
143
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
144 wsCreateWindow( &appMPlayer.menuWindow,
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
145 appMPlayer.menuBase.x,appMPlayer.menuBase.y,appMPlayer.menuBase.width,appMPlayer.menuBase.height,
4411
a97f908988ed small changes
pontscho
parents: 3476
diff changeset
146 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsOverredirect|wsHideFrame|wsMaxSize|wsMinSize|wsHideWindow,"MPlayer menu" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
147
6221
4b2459557340 add XShape support for gui's submenu
pontscho
parents: 6159
diff changeset
148 wsSetShape( &appMPlayer.menuWindow,appMPlayer.menuBase.Mask.Image );
4b2459557340 add XShape support for gui's submenu
pontscho
parents: 6159
diff changeset
149
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
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
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
152 #endif
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
153
8949
d07ab8e088a9 correct skin changing
pontscho
parents: 8058
diff changeset
154 mplMenuIsInitialized=1;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
155 appMPlayer.menuWindow.ReDraw=mplMenuDraw;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
156 // appMPlayer.menuWindow.MouseHandler=mplMenuMouseHandle;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
157 // appMPlayer.menuWindow.KeyHandler=mplMainKeyHandle;
3476
d8e46c2576c5 fix black ize
pontscho
parents: 2854
diff changeset
158 mplMenuRender=1; wsPostRedisplay( &appMPlayer.menuWindow );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
159 }