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