Mercurial > mplayer.hg
annotate gui/ui/menu.c @ 35760:1aedd24c032b
Cosmetic: Rename ReDraw DrawHandler.
author | ib |
---|---|
date | Thu, 24 Jan 2013 16:56:44 +0000 |
parents | b4599f797483 |
children | 6742a91ba28a |
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 "help_mp.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
27 #include "mp_msg.h" |
35525 | 28 #include "gui/app/app.h" |
29 #include "gui/app/gui.h" | |
35528 | 30 #include "ui.h" |
23077 | 31 |
35529 | 32 #include "gui/dialog/dialog.h" |
23077 | 33 |
33555 | 34 unsigned char * menuDrawBuffer = NULL; |
35750 | 35 static int uiMenuRender = True; |
33555 | 36 int menuItem = -1; |
37 int oldMenuItem = -1; | |
38 int menuX,menuY; | |
35493 | 39 static int menuIsInitialized = False; |
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; |
35750 | 48 if ( !uiMenuRender && !guiApp.menuWindow.Visible ) return; |
23077 | 49 |
35750 | 50 if ( uiMenuRender || 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 /* --- */ |
35744 | 67 wsImageRender( &guiApp.menuWindow,menuDrawBuffer ); |
35750 | 68 uiMenuRender=False; |
23077 | 69 } |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
70 wsImageDraw( &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 { |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
84 wsWindowRedraw( &guiApp.menuWindow ); |
23077 | 85 return; |
86 } | |
87 | |
33555 | 88 for( i=0;i<=guiApp.IndexOfMenuItems;i++ ) |
23077 | 89 { |
35675 | 90 if ( isInside( 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 } |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
94 wsWindowRedraw( &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 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
112 wsWindowMove( &guiApp.menuWindow,True,x,y ); |
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
113 wsWindowRaiseTop( wsDisplay,guiApp.menuWindow.WindowID ); |
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
114 wsWindowLayer( wsDisplay,guiApp.menuWindow.WindowID,1 ); |
35750 | 115 uiMenuRender=True; |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
116 wsWindowVisibility( &guiApp.menuWindow,wsShowWindow ); |
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
117 wsWindowRedraw( &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 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
131 wsWindowVisibility( &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 ); |
35675 | 137 if ( isInside( 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 | |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
161 wsWindowCreate( &guiApp.menuWindow, |
33555 | 162 guiApp.menu.x,guiApp.menu.y,guiApp.menu.width,guiApp.menu.height, |
35683
75155d8a9c7e
Remove parameter for border_width from wsWindowCreate().
ib
parents:
35681
diff
changeset
|
163 wsOverredirect|wsHideFrame|wsMaxSize|wsMinSize|wsHideWindow,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,"MPlayer menu" ); |
23077 | 164 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35675
diff
changeset
|
165 wsWindowShape( &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 |
35493 | 169 menuIsInitialized=True; |
35760 | 170 guiApp.menuWindow.DrawHandler=uiMenuDraw; |
33555 | 171 // guiApp.menuWindow.MouseHandler=uiMenuMouseHandle; |
172 // guiApp.menuWindow.KeyHandler=uiMainKeyHandle; | |
35750 | 173 uiMenuRender=True; wsWindowRedraw( &guiApp.menuWindow ); |
23077 | 174 } |