Mercurial > mplayer.hg
annotate gui/mplayer/menu.c @ 33534:22c3241467b3
Remove function Normalize().
This function changed ARGB data as if it had been RGB24 data (not quite
correctly) converted to ARGB with all colors transparent.
Instead now, set the alpha channel for RGB24 data and leave ARGB data
untouched.
For X11, the alpha channel is disregarded, so both approaches are equal,
but the new one is more intelligible as we get correct ARGB PNG data.
For legacy reasons, all kind of fuchsia/magenta must be treated as
transparent, because some skins are using at least both full opaque and
full transparent fuchsia/magenta for transparency.
author | ib |
---|---|
date | Thu, 16 Jun 2011 11:19:15 +0000 |
parents | 5f3171d4d7a4 |
children | 55b8f5d5df15 |
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> |
23077 | 22 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
23 #include "config.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
24 #include "help_mp.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
25 #include "mp_msg.h" |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
26 #include "gui/app.h" |
23154
e564b9cd7290
Fix several implicit declarations of functions warnings.
diego
parents:
23077
diff
changeset
|
27 #include "gmplayer.h" |
23077 | 28 |
29 #include "widgets.h" | |
30 | |
31 unsigned char * mplMenuDrawBuffer = NULL; | |
32 int mplMenuRender = 1; | |
33 int mplMenuItem = -1; | |
34 int mplOldMenuItem = -1; | |
35 int mplMenuX,mplMenuY; | |
36 static int mplMenuIsInitialized = 0; | |
37 | |
30535
016e5fc1dead
GUI: Mark functions that are not used outside their files as static.
diego
parents:
30531
diff
changeset
|
38 static void mplMenuDraw( void ) |
23077 | 39 { |
40 uint32_t * buf = NULL; | |
41 uint32_t * drw = NULL; | |
42 int x,y,tmp; | |
43 | |
33084 | 44 if ( !appMPlayer.menuIsPresent || !appMPlayer.menu.Bitmap.Image ) return; |
23077 | 45 if ( !mplMenuRender && !appMPlayer.menuWindow.Visible ) return; |
46 | |
47 if ( mplMenuRender || mplMenuItem != mplOldMenuItem ) | |
48 { | |
33084 | 49 memcpy( mplMenuDrawBuffer,appMPlayer.menu.Bitmap.Image,appMPlayer.menu.Bitmap.ImageSize ); |
23077 | 50 // --- |
51 if ( mplMenuItem != -1 ) | |
52 { | |
53 buf=(uint32_t *)mplMenuDrawBuffer; | |
54 drw=(uint32_t *)appMPlayer.menuSelected.Bitmap.Image; | |
32912 | 55 for ( y=appMPlayer.menuItems[ mplMenuItem ].y; y < appMPlayer.menuItems[ mplMenuItem ].y + appMPlayer.menuItems[ mplMenuItem ].height; y++ ) |
56 for ( x=appMPlayer.menuItems[ mplMenuItem ].x; x < appMPlayer.menuItems[ mplMenuItem ].x + appMPlayer.menuItems[ mplMenuItem ].width; x++ ) | |
23077 | 57 { |
58 tmp=drw[ y * appMPlayer.menuSelected.width + x ]; | |
33534 | 59 if ( !IS_TRANSPARENT ( tmp ) ) buf[ y * appMPlayer.menu.width + x ]=tmp; |
23077 | 60 } |
61 } | |
62 mplOldMenuItem=mplMenuItem; | |
63 // --- | |
33084 | 64 wsConvert( &appMPlayer.menuWindow,mplMenuDrawBuffer,appMPlayer.menu.Bitmap.ImageSize ); |
23077 | 65 mplMenuRender=0; |
66 } | |
67 wsPutImage( &appMPlayer.menuWindow ); | |
68 } | |
69 | |
70 void mplMenuMouseHandle( int X,int Y,int RX,int RY ) | |
71 { | |
72 int x,y,i; | |
73 | |
33084 | 74 if ( !appMPlayer.menu.Bitmap.Image ) return; |
23077 | 75 |
76 mplMenuItem=-1; | |
77 x=RX - appMPlayer.menuWindow.X; | |
78 y=RY - appMPlayer.menuWindow.Y; | |
33084 | 79 if ( ( x < 0 ) || ( y < 0 ) || ( x > appMPlayer.menu.width ) || ( y > appMPlayer.menu.height ) ) |
23077 | 80 { |
81 wsPostRedisplay( &appMPlayer.menuWindow ); | |
82 return; | |
83 } | |
84 | |
32931
03b1051bed5c
Rename the 'NumberOf' members of the listItems structure.
ib
parents:
32912
diff
changeset
|
85 for( i=0;i<=appMPlayer.IndexOfMenuItems;i++ ) |
23077 | 86 { |
87 if ( wgIsRect( x,y, | |
32912 | 88 appMPlayer.menuItems[i].x,appMPlayer.menuItems[i].y, |
89 appMPlayer.menuItems[i].x+appMPlayer.menuItems[i].width,appMPlayer.menuItems[i].y+appMPlayer.menuItems[i].height ) ) { mplMenuItem=i; break; } | |
23077 | 90 } |
91 wsPostRedisplay( &appMPlayer.menuWindow ); | |
92 } | |
93 | |
94 void mplShowMenu( int mx,int my ) | |
95 { | |
96 int x,y; | |
97 | |
33084 | 98 if ( !appMPlayer.menuIsPresent || !appMPlayer.menu.Bitmap.Image ) return; |
23077 | 99 |
100 x=mx; | |
101 if ( x + appMPlayer.menuWindow.Width > wsMaxX ) x=wsMaxX - appMPlayer.menuWindow.Width - 1 + wsOrgX; | |
102 y=my; | |
103 if ( y + appMPlayer.menuWindow.Height > wsMaxY ) y=wsMaxY - appMPlayer.menuWindow.Height - 1 + wsOrgY; | |
104 | |
105 mplMenuX=x; mplMenuY=y; | |
106 | |
107 mplMenuItem = 0; | |
108 | |
109 wsMoveWindow( &appMPlayer.menuWindow,False,x,y ); | |
110 wsMoveTopWindow( wsDisplay,appMPlayer.menuWindow.WindowID ); | |
111 wsSetLayer( wsDisplay,appMPlayer.menuWindow.WindowID,1 ); | |
112 mplMenuRender=1; | |
113 wsVisibleWindow( &appMPlayer.menuWindow,wsShowWindow ); | |
114 wsPostRedisplay( &appMPlayer.menuWindow ); | |
115 } | |
116 | |
117 void mplHideMenu( int mx,int my,int w ) | |
118 { | |
119 int x,y,i=mplMenuItem; | |
120 | |
33084 | 121 if ( !appMPlayer.menuIsPresent || !appMPlayer.menu.Bitmap.Image ) return; |
23077 | 122 |
123 x=mx-mplMenuX; | |
124 y=my-mplMenuY; | |
125 // x=RX - appMPlayer.menuWindow.X; | |
126 // y=RY - appMPlayer.menuWindow.Y; | |
127 | |
128 wsVisibleWindow( &appMPlayer.menuWindow,wsHideWindow ); | |
129 | |
130 if ( ( x < 0 ) || ( y < 0 ) ) return; | |
131 | |
132 // printf( "---------> %d %d,%d\n",i,x,y ); | |
32912 | 133 // printf( "--------> mi: %d,%d %dx%d\n",appMPlayer.menuItems[i].x,appMPlayer.menuItems[i].y,appMPlayer.menuItems[i].width,appMPlayer.menuItems[i].height ); |
23077 | 134 if ( wgIsRect( x,y, |
32912 | 135 appMPlayer.menuItems[i].x,appMPlayer.menuItems[i].y, |
136 appMPlayer.menuItems[i].x+appMPlayer.menuItems[i].width, | |
137 appMPlayer.menuItems[i].y+appMPlayer.menuItems[i].height ) ) | |
23077 | 138 { |
32912 | 139 mplEventHandling( appMPlayer.menuItems[i].message,(float)w ); |
23077 | 140 } |
141 } | |
142 | |
143 void mplMenuInit( void ) | |
144 { | |
145 | |
33084 | 146 if ( mplMenuIsInitialized || !appMPlayer.menuIsPresent || !appMPlayer.menu.Bitmap.Image ) return; |
23077 | 147 |
33084 | 148 appMPlayer.menu.x=0; |
149 appMPlayer.menu.y=0; | |
23077 | 150 |
33084 | 151 if ( ( mplMenuDrawBuffer = calloc( 1,appMPlayer.menu.Bitmap.ImageSize ) ) == NULL ) |
23077 | 152 { |
153 #ifdef DEBUG | |
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 #endif |
156 gtkMessageBox( GTK_MB_FATAL,MSGTR_NEMFMR ); | |
157 return; | |
158 } | |
159 | |
160 wsCreateWindow( &appMPlayer.menuWindow, | |
33084 | 161 appMPlayer.menu.x,appMPlayer.menu.y,appMPlayer.menu.width,appMPlayer.menu.height, |
23077 | 162 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsOverredirect|wsHideFrame|wsMaxSize|wsMinSize|wsHideWindow,"MPlayer menu" ); |
163 | |
33084 | 164 wsSetShape( &appMPlayer.menuWindow,appMPlayer.menu.Mask.Image ); |
23077 | 165 |
166 #ifdef DEBUG | |
30531
704903d34069
Rename gui/mplayer/gtk/menu.[ch] --> gui/mplayer/gtk/gtkmenu.[ch].
diego
parents:
26458
diff
changeset
|
167 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"menu: 0x%x\n",(int)appMPlayer.menuWindow.WindowID ); |
23077 | 168 #endif |
169 | |
170 mplMenuIsInitialized=1; | |
171 appMPlayer.menuWindow.ReDraw=mplMenuDraw; | |
172 // appMPlayer.menuWindow.MouseHandler=mplMenuMouseHandle; | |
173 // appMPlayer.menuWindow.KeyHandler=mplMainKeyHandle; | |
174 mplMenuRender=1; wsPostRedisplay( &appMPlayer.menuWindow ); | |
175 } |