Mercurial > mplayer.hg
annotate gui/ui/menu.c @ 34684:b03481253518
Cosmetic: Prefer C style for single line comments.
Additionally, slightly revise some of these comments.
author | ib |
---|---|
date | Fri, 24 Feb 2012 17:16:54 +0000 |
parents | f866092d51cd |
children | ed0e00db4306 |
rev | line source |
---|---|
26458 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
4 * MPlayer is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * MPlayer is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License along | |
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 */ | |
23077 | 18 |
19 #include <stdlib.h> | |
20 #include <stdio.h> | |
33123
9566100d88a1
Replace inttypes.h by stdint.h and remove inttypes.h where unneeded.
ib
parents:
33084
diff
changeset
|
21 #include <stdint.h> |
33738 | 22 #include <string.h> |
23077 | 23 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
24 #include "config.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
25 #include "help_mp.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
26 #include "mp_msg.h" |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
27 #include "gui/app.h" |
23154
e564b9cd7290
Fix several implicit declarations of functions warnings.
diego
parents:
23077
diff
changeset
|
28 #include "gmplayer.h" |
23077 | 29 |
30 #include "widgets.h" | |
31 | |
33555 | 32 unsigned char * menuDrawBuffer = NULL; |
33 int menuRender = 1; | |
34 int menuItem = -1; | |
35 int oldMenuItem = -1; | |
36 int menuX,menuY; | |
37 static int menuIsInitialized = 0; | |
23077 | 38 |
33555 | 39 static void uiMenuDraw( void ) |
23077 | 40 { |
41 uint32_t * buf = NULL; | |
42 uint32_t * drw = NULL; | |
43 int x,y,tmp; | |
44 | |
33555 | 45 if ( !guiApp.menuIsPresent || !guiApp.menu.Bitmap.Image ) return; |
46 if ( !menuRender && !guiApp.menuWindow.Visible ) return; | |
23077 | 47 |
33555 | 48 if ( menuRender || menuItem != oldMenuItem ) |
23077 | 49 { |
33555 | 50 memcpy( menuDrawBuffer,guiApp.menu.Bitmap.Image,guiApp.menu.Bitmap.ImageSize ); |
34684 | 51 /* --- */ |
33555 | 52 if ( menuItem != -1 ) |
23077 | 53 { |
33555 | 54 buf=(uint32_t *)menuDrawBuffer; |
55 drw=(uint32_t *)guiApp.menuSelected.Bitmap.Image; | |
56 for ( y=guiApp.menuItems[ menuItem ].y; y < guiApp.menuItems[ menuItem ].y + guiApp.menuItems[ menuItem ].height; y++ ) | |
57 for ( x=guiApp.menuItems[ menuItem ].x; x < guiApp.menuItems[ menuItem ].x + guiApp.menuItems[ menuItem ].width; x++ ) | |
23077 | 58 { |
33555 | 59 tmp=drw[ y * guiApp.menuSelected.width + x ]; |
60 if ( !IS_TRANSPARENT ( tmp ) ) buf[ y * guiApp.menu.width + x ]=tmp; | |
23077 | 61 } |
62 } | |
33555 | 63 oldMenuItem=menuItem; |
34684 | 64 /* --- */ |
33555 | 65 wsConvert( &guiApp.menuWindow,menuDrawBuffer ); |
66 menuRender=0; | |
23077 | 67 } |
33555 | 68 wsPutImage( &guiApp.menuWindow ); |
23077 | 69 } |
70 | |
34472 | 71 void uiMenuMouseHandle( int RX,int RY ) |
23077 | 72 { |
73 int x,y,i; | |
74 | |
33555 | 75 if ( !guiApp.menu.Bitmap.Image ) return; |
23077 | 76 |
33555 | 77 menuItem=-1; |
78 x=RX - guiApp.menuWindow.X; | |
79 y=RY - guiApp.menuWindow.Y; | |
80 if ( ( x < 0 ) || ( y < 0 ) || ( x > guiApp.menu.width ) || ( y > guiApp.menu.height ) ) | |
23077 | 81 { |
33555 | 82 wsPostRedisplay( &guiApp.menuWindow ); |
23077 | 83 return; |
84 } | |
85 | |
33555 | 86 for( i=0;i<=guiApp.IndexOfMenuItems;i++ ) |
23077 | 87 { |
88 if ( wgIsRect( x,y, | |
33555 | 89 guiApp.menuItems[i].x,guiApp.menuItems[i].y, |
90 guiApp.menuItems[i].x+guiApp.menuItems[i].width,guiApp.menuItems[i].y+guiApp.menuItems[i].height ) ) { menuItem=i; break; } | |
23077 | 91 } |
33555 | 92 wsPostRedisplay( &guiApp.menuWindow ); |
23077 | 93 } |
94 | |
33555 | 95 void uiShowMenu( int mx,int my ) |
23077 | 96 { |
97 int x,y; | |
98 | |
33555 | 99 if ( !guiApp.menuIsPresent || !guiApp.menu.Bitmap.Image ) return; |
23077 | 100 |
101 x=mx; | |
33555 | 102 if ( x + guiApp.menuWindow.Width > wsMaxX ) x=wsMaxX - guiApp.menuWindow.Width - 1 + wsOrgX; |
23077 | 103 y=my; |
33555 | 104 if ( y + guiApp.menuWindow.Height > wsMaxY ) y=wsMaxY - guiApp.menuWindow.Height - 1 + wsOrgY; |
23077 | 105 |
33555 | 106 menuX=x; menuY=y; |
23077 | 107 |
33555 | 108 menuItem = 0; |
23077 | 109 |
33993 | 110 wsMoveWindow( &guiApp.menuWindow,True,x,y ); |
33990
3a93b9227b01
Cosmetic: Rename wsMoveTopWindow() wsRaiseWindowTop().
ib
parents:
33738
diff
changeset
|
111 wsRaiseWindowTop( wsDisplay,guiApp.menuWindow.WindowID ); |
33555 | 112 wsSetLayer( wsDisplay,guiApp.menuWindow.WindowID,1 ); |
113 menuRender=1; | |
114 wsVisibleWindow( &guiApp.menuWindow,wsShowWindow ); | |
115 wsPostRedisplay( &guiApp.menuWindow ); | |
23077 | 116 } |
117 | |
33555 | 118 void uiHideMenu( int mx,int my,int w ) |
23077 | 119 { |
33555 | 120 int x,y,i=menuItem; |
23077 | 121 |
33555 | 122 if ( !guiApp.menuIsPresent || !guiApp.menu.Bitmap.Image ) return; |
23077 | 123 |
33555 | 124 x=mx-menuX; |
125 y=my-menuY; | |
126 // x=RX - guiApp.menuWindow.X; | |
127 // y=RY - guiApp.menuWindow.Y; | |
23077 | 128 |
33555 | 129 wsVisibleWindow( &guiApp.menuWindow,wsHideWindow ); |
23077 | 130 |
131 if ( ( x < 0 ) || ( y < 0 ) ) return; | |
132 | |
133 // printf( "---------> %d %d,%d\n",i,x,y ); | |
33555 | 134 // printf( "--------> mi: %d,%d %dx%d\n",guiApp.menuItems[i].x,guiApp.menuItems[i].y,guiApp.menuItems[i].width,guiApp.menuItems[i].height ); |
23077 | 135 if ( wgIsRect( x,y, |
33555 | 136 guiApp.menuItems[i].x,guiApp.menuItems[i].y, |
137 guiApp.menuItems[i].x+guiApp.menuItems[i].width, | |
138 guiApp.menuItems[i].y+guiApp.menuItems[i].height ) ) | |
23077 | 139 { |
33555 | 140 uiEventHandling( guiApp.menuItems[i].message,(float)w ); |
23077 | 141 } |
142 } | |
143 | |
33555 | 144 void uiMenuInit( void ) |
23077 | 145 { |
146 | |
33555 | 147 if ( menuIsInitialized || !guiApp.menuIsPresent || !guiApp.menu.Bitmap.Image ) return; |
23077 | 148 |
33555 | 149 guiApp.menu.x=0; |
150 guiApp.menu.y=0; | |
23077 | 151 |
33555 | 152 if ( ( menuDrawBuffer = calloc( 1,guiApp.menu.Bitmap.ImageSize ) ) == NULL ) |
23077 | 153 { |
30531
704903d34069
Rename gui/mplayer/gtk/menu.[ch] --> gui/mplayer/gtk/gtkmenu.[ch].
diego
parents:
26458
diff
changeset
|
154 mp_msg( MSGT_GPLAYER,MSGL_DBG2,MSGTR_NEMFMR ); |
23077 | 155 gtkMessageBox( GTK_MB_FATAL,MSGTR_NEMFMR ); |
156 return; | |
157 } | |
158 | |
33555 | 159 wsCreateWindow( &guiApp.menuWindow, |
160 guiApp.menu.x,guiApp.menu.y,guiApp.menu.width,guiApp.menu.height, | |
23077 | 161 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsOverredirect|wsHideFrame|wsMaxSize|wsMinSize|wsHideWindow,"MPlayer menu" ); |
162 | |
33555 | 163 wsSetShape( &guiApp.menuWindow,guiApp.menu.Mask.Image ); |
23077 | 164 |
34425 | 165 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[menu] menuWindow ID: 0x%x\n",(int)guiApp.menuWindow.WindowID ); |
23077 | 166 |
33555 | 167 menuIsInitialized=1; |
168 guiApp.menuWindow.ReDraw=uiMenuDraw; | |
169 // guiApp.menuWindow.MouseHandler=uiMenuMouseHandle; | |
170 // guiApp.menuWindow.KeyHandler=uiMainKeyHandle; | |
171 menuRender=1; wsPostRedisplay( &guiApp.menuWindow ); | |
23077 | 172 } |