Mercurial > mplayer.hg
annotate gui/ui/menu.c @ 34755:1ce66378ae1e
Move mp_ao_resume_refill to audio_out.h to avoid compiler
warning about missing prototype in audio_out.c.
Including audio_out_internal.h is not an option since
that causes warnings about "play" etc. functions being
declared but not defined.
author | reimar |
---|---|
date | Fri, 06 Apr 2012 21:26:02 +0000 |
parents | ed0e00db4306 |
children | 31a5320909f7 |
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 |
34699
ed0e00db4306
Cosmetic: Move, change and add some comments on GUI windows.
ib
parents:
34684
diff
changeset
|
19 /* menu window */ |
ed0e00db4306
Cosmetic: Move, change and add some comments on GUI windows.
ib
parents:
34684
diff
changeset
|
20 |
23077 | 21 #include <stdlib.h> |
22 #include <stdio.h> | |
33123
9566100d88a1
Replace inttypes.h by stdint.h and remove inttypes.h where unneeded.
ib
parents:
33084
diff
changeset
|
23 #include <stdint.h> |
33738 | 24 #include <string.h> |
23077 | 25 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
26 #include "config.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
27 #include "help_mp.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
28 #include "mp_msg.h" |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
29 #include "gui/app.h" |
23154
e564b9cd7290
Fix several implicit declarations of functions warnings.
diego
parents:
23077
diff
changeset
|
30 #include "gmplayer.h" |
23077 | 31 |
32 #include "widgets.h" | |
33 | |
33555 | 34 unsigned char * menuDrawBuffer = NULL; |
35 int menuRender = 1; | |
36 int menuItem = -1; | |
37 int oldMenuItem = -1; | |
38 int menuX,menuY; | |
39 static int menuIsInitialized = 0; | |
23077 | 40 |
33555 | 41 static void uiMenuDraw( void ) |
23077 | 42 { |
43 uint32_t * buf = NULL; | |
44 uint32_t * drw = NULL; | |
45 int x,y,tmp; | |
46 | |
33555 | 47 if ( !guiApp.menuIsPresent || !guiApp.menu.Bitmap.Image ) return; |
48 if ( !menuRender && !guiApp.menuWindow.Visible ) return; | |
23077 | 49 |
33555 | 50 if ( menuRender || menuItem != oldMenuItem ) |
23077 | 51 { |
33555 | 52 memcpy( menuDrawBuffer,guiApp.menu.Bitmap.Image,guiApp.menu.Bitmap.ImageSize ); |
34684 | 53 /* --- */ |
33555 | 54 if ( menuItem != -1 ) |
23077 | 55 { |
33555 | 56 buf=(uint32_t *)menuDrawBuffer; |
57 drw=(uint32_t *)guiApp.menuSelected.Bitmap.Image; | |
58 for ( y=guiApp.menuItems[ menuItem ].y; y < guiApp.menuItems[ menuItem ].y + guiApp.menuItems[ menuItem ].height; y++ ) | |
59 for ( x=guiApp.menuItems[ menuItem ].x; x < guiApp.menuItems[ menuItem ].x + guiApp.menuItems[ menuItem ].width; x++ ) | |
23077 | 60 { |
33555 | 61 tmp=drw[ y * guiApp.menuSelected.width + x ]; |
62 if ( !IS_TRANSPARENT ( tmp ) ) buf[ y * guiApp.menu.width + x ]=tmp; | |
23077 | 63 } |
64 } | |
33555 | 65 oldMenuItem=menuItem; |
34684 | 66 /* --- */ |
33555 | 67 wsConvert( &guiApp.menuWindow,menuDrawBuffer ); |
68 menuRender=0; | |
23077 | 69 } |
33555 | 70 wsPutImage( &guiApp.menuWindow ); |
23077 | 71 } |
72 | |
34472 | 73 void uiMenuMouseHandle( int RX,int RY ) |
23077 | 74 { |
75 int x,y,i; | |
76 | |
33555 | 77 if ( !guiApp.menu.Bitmap.Image ) return; |
23077 | 78 |
33555 | 79 menuItem=-1; |
80 x=RX - guiApp.menuWindow.X; | |
81 y=RY - guiApp.menuWindow.Y; | |
82 if ( ( x < 0 ) || ( y < 0 ) || ( x > guiApp.menu.width ) || ( y > guiApp.menu.height ) ) | |
23077 | 83 { |
33555 | 84 wsPostRedisplay( &guiApp.menuWindow ); |
23077 | 85 return; |
86 } | |
87 | |
33555 | 88 for( i=0;i<=guiApp.IndexOfMenuItems;i++ ) |
23077 | 89 { |
90 if ( wgIsRect( x,y, | |
33555 | 91 guiApp.menuItems[i].x,guiApp.menuItems[i].y, |
92 guiApp.menuItems[i].x+guiApp.menuItems[i].width,guiApp.menuItems[i].y+guiApp.menuItems[i].height ) ) { menuItem=i; break; } | |
23077 | 93 } |
33555 | 94 wsPostRedisplay( &guiApp.menuWindow ); |
23077 | 95 } |
96 | |
33555 | 97 void uiShowMenu( int mx,int my ) |
23077 | 98 { |
99 int x,y; | |
100 | |
33555 | 101 if ( !guiApp.menuIsPresent || !guiApp.menu.Bitmap.Image ) return; |
23077 | 102 |
103 x=mx; | |
33555 | 104 if ( x + guiApp.menuWindow.Width > wsMaxX ) x=wsMaxX - guiApp.menuWindow.Width - 1 + wsOrgX; |
23077 | 105 y=my; |
33555 | 106 if ( y + guiApp.menuWindow.Height > wsMaxY ) y=wsMaxY - guiApp.menuWindow.Height - 1 + wsOrgY; |
23077 | 107 |
33555 | 108 menuX=x; menuY=y; |
23077 | 109 |
33555 | 110 menuItem = 0; |
23077 | 111 |
33993 | 112 wsMoveWindow( &guiApp.menuWindow,True,x,y ); |
33990
3a93b9227b01
Cosmetic: Rename wsMoveTopWindow() wsRaiseWindowTop().
ib
parents:
33738
diff
changeset
|
113 wsRaiseWindowTop( wsDisplay,guiApp.menuWindow.WindowID ); |
33555 | 114 wsSetLayer( wsDisplay,guiApp.menuWindow.WindowID,1 ); |
115 menuRender=1; | |
116 wsVisibleWindow( &guiApp.menuWindow,wsShowWindow ); | |
117 wsPostRedisplay( &guiApp.menuWindow ); | |
23077 | 118 } |
119 | |
33555 | 120 void uiHideMenu( int mx,int my,int w ) |
23077 | 121 { |
33555 | 122 int x,y,i=menuItem; |
23077 | 123 |
33555 | 124 if ( !guiApp.menuIsPresent || !guiApp.menu.Bitmap.Image ) return; |
23077 | 125 |
33555 | 126 x=mx-menuX; |
127 y=my-menuY; | |
128 // x=RX - guiApp.menuWindow.X; | |
129 // y=RY - guiApp.menuWindow.Y; | |
23077 | 130 |
33555 | 131 wsVisibleWindow( &guiApp.menuWindow,wsHideWindow ); |
23077 | 132 |
133 if ( ( x < 0 ) || ( y < 0 ) ) return; | |
134 | |
135 // printf( "---------> %d %d,%d\n",i,x,y ); | |
33555 | 136 // printf( "--------> mi: %d,%d %dx%d\n",guiApp.menuItems[i].x,guiApp.menuItems[i].y,guiApp.menuItems[i].width,guiApp.menuItems[i].height ); |
23077 | 137 if ( wgIsRect( x,y, |
33555 | 138 guiApp.menuItems[i].x,guiApp.menuItems[i].y, |
139 guiApp.menuItems[i].x+guiApp.menuItems[i].width, | |
140 guiApp.menuItems[i].y+guiApp.menuItems[i].height ) ) | |
23077 | 141 { |
33555 | 142 uiEventHandling( guiApp.menuItems[i].message,(float)w ); |
23077 | 143 } |
144 } | |
145 | |
33555 | 146 void uiMenuInit( void ) |
23077 | 147 { |
148 | |
33555 | 149 if ( menuIsInitialized || !guiApp.menuIsPresent || !guiApp.menu.Bitmap.Image ) return; |
23077 | 150 |
33555 | 151 guiApp.menu.x=0; |
152 guiApp.menu.y=0; | |
23077 | 153 |
33555 | 154 if ( ( menuDrawBuffer = calloc( 1,guiApp.menu.Bitmap.ImageSize ) ) == NULL ) |
23077 | 155 { |
30531
704903d34069
Rename gui/mplayer/gtk/menu.[ch] --> gui/mplayer/gtk/gtkmenu.[ch].
diego
parents:
26458
diff
changeset
|
156 mp_msg( MSGT_GPLAYER,MSGL_DBG2,MSGTR_NEMFMR ); |
23077 | 157 gtkMessageBox( GTK_MB_FATAL,MSGTR_NEMFMR ); |
158 return; | |
159 } | |
160 | |
33555 | 161 wsCreateWindow( &guiApp.menuWindow, |
162 guiApp.menu.x,guiApp.menu.y,guiApp.menu.width,guiApp.menu.height, | |
23077 | 163 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsOverredirect|wsHideFrame|wsMaxSize|wsMinSize|wsHideWindow,"MPlayer menu" ); |
164 | |
33555 | 165 wsSetShape( &guiApp.menuWindow,guiApp.menu.Mask.Image ); |
23077 | 166 |
34425 | 167 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[menu] menuWindow ID: 0x%x\n",(int)guiApp.menuWindow.WindowID ); |
23077 | 168 |
33555 | 169 menuIsInitialized=1; |
170 guiApp.menuWindow.ReDraw=uiMenuDraw; | |
171 // guiApp.menuWindow.MouseHandler=uiMenuMouseHandle; | |
172 // guiApp.menuWindow.KeyHandler=uiMainKeyHandle; | |
173 menuRender=1; wsPostRedisplay( &guiApp.menuWindow ); | |
23077 | 174 } |