Mercurial > mplayer.hg
comparison gui/mplayer/menu.c @ 33555:c5a19bbeac2b
Cosmetic: Rename some GUI variables and functions.
The new names are more intelligible and consistent.
List of changes:
guiIntfStruct -> guiInfo
appMPlayer -> guiApp
txSample -> guiImage (and member BPP -> Bpp)
mplDrawBuffer -> mainDrawBuffer
mplPBDrawBuffer -> playbarDrawBuffer
mplMenuDrawBuffer -> menuDrawBuffer
mpl.* -> ui.* (or mpl dropped)
.*bar.* -> .*playbar.*
URLItem -> urlItem
ChangeSkin -> uiChangeSkin
Convert32to1 -> bpRenderMask
author | ib |
---|---|
date | Sat, 18 Jun 2011 14:33:41 +0000 |
parents | 55b8f5d5df15 |
children |
comparison
equal
deleted
inserted
replaced
33554:02d94048970e | 33555:c5a19bbeac2b |
---|---|
26 #include "gui/app.h" | 26 #include "gui/app.h" |
27 #include "gmplayer.h" | 27 #include "gmplayer.h" |
28 | 28 |
29 #include "widgets.h" | 29 #include "widgets.h" |
30 | 30 |
31 unsigned char * mplMenuDrawBuffer = NULL; | 31 unsigned char * menuDrawBuffer = NULL; |
32 int mplMenuRender = 1; | 32 int menuRender = 1; |
33 int mplMenuItem = -1; | 33 int menuItem = -1; |
34 int mplOldMenuItem = -1; | 34 int oldMenuItem = -1; |
35 int mplMenuX,mplMenuY; | 35 int menuX,menuY; |
36 static int mplMenuIsInitialized = 0; | 36 static int menuIsInitialized = 0; |
37 | 37 |
38 static void mplMenuDraw( void ) | 38 static void uiMenuDraw( void ) |
39 { | 39 { |
40 uint32_t * buf = NULL; | 40 uint32_t * buf = NULL; |
41 uint32_t * drw = NULL; | 41 uint32_t * drw = NULL; |
42 int x,y,tmp; | 42 int x,y,tmp; |
43 | 43 |
44 if ( !appMPlayer.menuIsPresent || !appMPlayer.menu.Bitmap.Image ) return; | 44 if ( !guiApp.menuIsPresent || !guiApp.menu.Bitmap.Image ) return; |
45 if ( !mplMenuRender && !appMPlayer.menuWindow.Visible ) return; | 45 if ( !menuRender && !guiApp.menuWindow.Visible ) return; |
46 | 46 |
47 if ( mplMenuRender || mplMenuItem != mplOldMenuItem ) | 47 if ( menuRender || menuItem != oldMenuItem ) |
48 { | 48 { |
49 memcpy( mplMenuDrawBuffer,appMPlayer.menu.Bitmap.Image,appMPlayer.menu.Bitmap.ImageSize ); | 49 memcpy( menuDrawBuffer,guiApp.menu.Bitmap.Image,guiApp.menu.Bitmap.ImageSize ); |
50 // --- | 50 // --- |
51 if ( mplMenuItem != -1 ) | 51 if ( menuItem != -1 ) |
52 { | 52 { |
53 buf=(uint32_t *)mplMenuDrawBuffer; | 53 buf=(uint32_t *)menuDrawBuffer; |
54 drw=(uint32_t *)appMPlayer.menuSelected.Bitmap.Image; | 54 drw=(uint32_t *)guiApp.menuSelected.Bitmap.Image; |
55 for ( y=appMPlayer.menuItems[ mplMenuItem ].y; y < appMPlayer.menuItems[ mplMenuItem ].y + appMPlayer.menuItems[ mplMenuItem ].height; y++ ) | 55 for ( y=guiApp.menuItems[ menuItem ].y; y < guiApp.menuItems[ menuItem ].y + guiApp.menuItems[ menuItem ].height; y++ ) |
56 for ( x=appMPlayer.menuItems[ mplMenuItem ].x; x < appMPlayer.menuItems[ mplMenuItem ].x + appMPlayer.menuItems[ mplMenuItem ].width; x++ ) | 56 for ( x=guiApp.menuItems[ menuItem ].x; x < guiApp.menuItems[ menuItem ].x + guiApp.menuItems[ menuItem ].width; x++ ) |
57 { | 57 { |
58 tmp=drw[ y * appMPlayer.menuSelected.width + x ]; | 58 tmp=drw[ y * guiApp.menuSelected.width + x ]; |
59 if ( !IS_TRANSPARENT ( tmp ) ) buf[ y * appMPlayer.menu.width + x ]=tmp; | 59 if ( !IS_TRANSPARENT ( tmp ) ) buf[ y * guiApp.menu.width + x ]=tmp; |
60 } | 60 } |
61 } | 61 } |
62 mplOldMenuItem=mplMenuItem; | 62 oldMenuItem=menuItem; |
63 // --- | 63 // --- |
64 wsConvert( &appMPlayer.menuWindow,mplMenuDrawBuffer ); | 64 wsConvert( &guiApp.menuWindow,menuDrawBuffer ); |
65 mplMenuRender=0; | 65 menuRender=0; |
66 } | 66 } |
67 wsPutImage( &appMPlayer.menuWindow ); | 67 wsPutImage( &guiApp.menuWindow ); |
68 } | 68 } |
69 | 69 |
70 void mplMenuMouseHandle( int X,int Y,int RX,int RY ) | 70 void uiMenuMouseHandle( int X,int Y,int RX,int RY ) |
71 { | 71 { |
72 int x,y,i; | 72 int x,y,i; |
73 | 73 |
74 if ( !appMPlayer.menu.Bitmap.Image ) return; | 74 if ( !guiApp.menu.Bitmap.Image ) return; |
75 | 75 |
76 mplMenuItem=-1; | 76 menuItem=-1; |
77 x=RX - appMPlayer.menuWindow.X; | 77 x=RX - guiApp.menuWindow.X; |
78 y=RY - appMPlayer.menuWindow.Y; | 78 y=RY - guiApp.menuWindow.Y; |
79 if ( ( x < 0 ) || ( y < 0 ) || ( x > appMPlayer.menu.width ) || ( y > appMPlayer.menu.height ) ) | 79 if ( ( x < 0 ) || ( y < 0 ) || ( x > guiApp.menu.width ) || ( y > guiApp.menu.height ) ) |
80 { | 80 { |
81 wsPostRedisplay( &appMPlayer.menuWindow ); | 81 wsPostRedisplay( &guiApp.menuWindow ); |
82 return; | 82 return; |
83 } | 83 } |
84 | 84 |
85 for( i=0;i<=appMPlayer.IndexOfMenuItems;i++ ) | 85 for( i=0;i<=guiApp.IndexOfMenuItems;i++ ) |
86 { | 86 { |
87 if ( wgIsRect( x,y, | 87 if ( wgIsRect( x,y, |
88 appMPlayer.menuItems[i].x,appMPlayer.menuItems[i].y, | 88 guiApp.menuItems[i].x,guiApp.menuItems[i].y, |
89 appMPlayer.menuItems[i].x+appMPlayer.menuItems[i].width,appMPlayer.menuItems[i].y+appMPlayer.menuItems[i].height ) ) { mplMenuItem=i; break; } | 89 guiApp.menuItems[i].x+guiApp.menuItems[i].width,guiApp.menuItems[i].y+guiApp.menuItems[i].height ) ) { menuItem=i; break; } |
90 } | 90 } |
91 wsPostRedisplay( &appMPlayer.menuWindow ); | 91 wsPostRedisplay( &guiApp.menuWindow ); |
92 } | 92 } |
93 | 93 |
94 void mplShowMenu( int mx,int my ) | 94 void uiShowMenu( int mx,int my ) |
95 { | 95 { |
96 int x,y; | 96 int x,y; |
97 | 97 |
98 if ( !appMPlayer.menuIsPresent || !appMPlayer.menu.Bitmap.Image ) return; | 98 if ( !guiApp.menuIsPresent || !guiApp.menu.Bitmap.Image ) return; |
99 | 99 |
100 x=mx; | 100 x=mx; |
101 if ( x + appMPlayer.menuWindow.Width > wsMaxX ) x=wsMaxX - appMPlayer.menuWindow.Width - 1 + wsOrgX; | 101 if ( x + guiApp.menuWindow.Width > wsMaxX ) x=wsMaxX - guiApp.menuWindow.Width - 1 + wsOrgX; |
102 y=my; | 102 y=my; |
103 if ( y + appMPlayer.menuWindow.Height > wsMaxY ) y=wsMaxY - appMPlayer.menuWindow.Height - 1 + wsOrgY; | 103 if ( y + guiApp.menuWindow.Height > wsMaxY ) y=wsMaxY - guiApp.menuWindow.Height - 1 + wsOrgY; |
104 | 104 |
105 mplMenuX=x; mplMenuY=y; | 105 menuX=x; menuY=y; |
106 | 106 |
107 mplMenuItem = 0; | 107 menuItem = 0; |
108 | 108 |
109 wsMoveWindow( &appMPlayer.menuWindow,False,x,y ); | 109 wsMoveWindow( &guiApp.menuWindow,False,x,y ); |
110 wsMoveTopWindow( wsDisplay,appMPlayer.menuWindow.WindowID ); | 110 wsMoveTopWindow( wsDisplay,guiApp.menuWindow.WindowID ); |
111 wsSetLayer( wsDisplay,appMPlayer.menuWindow.WindowID,1 ); | 111 wsSetLayer( wsDisplay,guiApp.menuWindow.WindowID,1 ); |
112 mplMenuRender=1; | 112 menuRender=1; |
113 wsVisibleWindow( &appMPlayer.menuWindow,wsShowWindow ); | 113 wsVisibleWindow( &guiApp.menuWindow,wsShowWindow ); |
114 wsPostRedisplay( &appMPlayer.menuWindow ); | 114 wsPostRedisplay( &guiApp.menuWindow ); |
115 } | 115 } |
116 | 116 |
117 void mplHideMenu( int mx,int my,int w ) | 117 void uiHideMenu( int mx,int my,int w ) |
118 { | 118 { |
119 int x,y,i=mplMenuItem; | 119 int x,y,i=menuItem; |
120 | 120 |
121 if ( !appMPlayer.menuIsPresent || !appMPlayer.menu.Bitmap.Image ) return; | 121 if ( !guiApp.menuIsPresent || !guiApp.menu.Bitmap.Image ) return; |
122 | 122 |
123 x=mx-mplMenuX; | 123 x=mx-menuX; |
124 y=my-mplMenuY; | 124 y=my-menuY; |
125 // x=RX - appMPlayer.menuWindow.X; | 125 // x=RX - guiApp.menuWindow.X; |
126 // y=RY - appMPlayer.menuWindow.Y; | 126 // y=RY - guiApp.menuWindow.Y; |
127 | 127 |
128 wsVisibleWindow( &appMPlayer.menuWindow,wsHideWindow ); | 128 wsVisibleWindow( &guiApp.menuWindow,wsHideWindow ); |
129 | 129 |
130 if ( ( x < 0 ) || ( y < 0 ) ) return; | 130 if ( ( x < 0 ) || ( y < 0 ) ) return; |
131 | 131 |
132 // printf( "---------> %d %d,%d\n",i,x,y ); | 132 // printf( "---------> %d %d,%d\n",i,x,y ); |
133 // printf( "--------> mi: %d,%d %dx%d\n",appMPlayer.menuItems[i].x,appMPlayer.menuItems[i].y,appMPlayer.menuItems[i].width,appMPlayer.menuItems[i].height ); | 133 // printf( "--------> mi: %d,%d %dx%d\n",guiApp.menuItems[i].x,guiApp.menuItems[i].y,guiApp.menuItems[i].width,guiApp.menuItems[i].height ); |
134 if ( wgIsRect( x,y, | 134 if ( wgIsRect( x,y, |
135 appMPlayer.menuItems[i].x,appMPlayer.menuItems[i].y, | 135 guiApp.menuItems[i].x,guiApp.menuItems[i].y, |
136 appMPlayer.menuItems[i].x+appMPlayer.menuItems[i].width, | 136 guiApp.menuItems[i].x+guiApp.menuItems[i].width, |
137 appMPlayer.menuItems[i].y+appMPlayer.menuItems[i].height ) ) | 137 guiApp.menuItems[i].y+guiApp.menuItems[i].height ) ) |
138 { | 138 { |
139 mplEventHandling( appMPlayer.menuItems[i].message,(float)w ); | 139 uiEventHandling( guiApp.menuItems[i].message,(float)w ); |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 void mplMenuInit( void ) | 143 void uiMenuInit( void ) |
144 { | 144 { |
145 | 145 |
146 if ( mplMenuIsInitialized || !appMPlayer.menuIsPresent || !appMPlayer.menu.Bitmap.Image ) return; | 146 if ( menuIsInitialized || !guiApp.menuIsPresent || !guiApp.menu.Bitmap.Image ) return; |
147 | 147 |
148 appMPlayer.menu.x=0; | 148 guiApp.menu.x=0; |
149 appMPlayer.menu.y=0; | 149 guiApp.menu.y=0; |
150 | 150 |
151 if ( ( mplMenuDrawBuffer = calloc( 1,appMPlayer.menu.Bitmap.ImageSize ) ) == NULL ) | 151 if ( ( menuDrawBuffer = calloc( 1,guiApp.menu.Bitmap.ImageSize ) ) == NULL ) |
152 { | 152 { |
153 #ifdef DEBUG | 153 #ifdef DEBUG |
154 mp_msg( MSGT_GPLAYER,MSGL_DBG2,MSGTR_NEMFMR ); | 154 mp_msg( MSGT_GPLAYER,MSGL_DBG2,MSGTR_NEMFMR ); |
155 #endif | 155 #endif |
156 gtkMessageBox( GTK_MB_FATAL,MSGTR_NEMFMR ); | 156 gtkMessageBox( GTK_MB_FATAL,MSGTR_NEMFMR ); |
157 return; | 157 return; |
158 } | 158 } |
159 | 159 |
160 wsCreateWindow( &appMPlayer.menuWindow, | 160 wsCreateWindow( &guiApp.menuWindow, |
161 appMPlayer.menu.x,appMPlayer.menu.y,appMPlayer.menu.width,appMPlayer.menu.height, | 161 guiApp.menu.x,guiApp.menu.y,guiApp.menu.width,guiApp.menu.height, |
162 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsOverredirect|wsHideFrame|wsMaxSize|wsMinSize|wsHideWindow,"MPlayer menu" ); | 162 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsOverredirect|wsHideFrame|wsMaxSize|wsMinSize|wsHideWindow,"MPlayer menu" ); |
163 | 163 |
164 wsSetShape( &appMPlayer.menuWindow,appMPlayer.menu.Mask.Image ); | 164 wsSetShape( &guiApp.menuWindow,guiApp.menu.Mask.Image ); |
165 | 165 |
166 #ifdef DEBUG | 166 #ifdef DEBUG |
167 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"menu: 0x%x\n",(int)appMPlayer.menuWindow.WindowID ); | 167 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"menu: 0x%x\n",(int)guiApp.menuWindow.WindowID ); |
168 #endif | 168 #endif |
169 | 169 |
170 mplMenuIsInitialized=1; | 170 menuIsInitialized=1; |
171 appMPlayer.menuWindow.ReDraw=mplMenuDraw; | 171 guiApp.menuWindow.ReDraw=uiMenuDraw; |
172 // appMPlayer.menuWindow.MouseHandler=mplMenuMouseHandle; | 172 // guiApp.menuWindow.MouseHandler=uiMenuMouseHandle; |
173 // appMPlayer.menuWindow.KeyHandler=mplMainKeyHandle; | 173 // guiApp.menuWindow.KeyHandler=uiMainKeyHandle; |
174 mplMenuRender=1; wsPostRedisplay( &appMPlayer.menuWindow ); | 174 menuRender=1; wsPostRedisplay( &guiApp.menuWindow ); |
175 } | 175 } |