synced with r24386
[mplayer/glamo.git] / gui / app.c
blob3558320d6ef16badbb7694fb158a7529620d5a59
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <string.h>
7 #include "config.h"
8 #include "mp_msg.h"
9 #include "help_mp.h"
11 #include "app.h"
12 #include "wm/wskeys.h"
13 #include "skin/skin.h"
14 #include "mplayer/gmplayer.h"
15 #include "interface.h"
17 evName evNames[] =
19 { evNone, "evNone" },
20 { evPlay, "evPlay" },
21 { evStop, "evStop" },
22 { evPause, "evPause" },
23 { evPrev, "evPrev" },
24 { evNext, "evNext" },
25 { evLoad, "evLoad" },
26 { evEqualizer, "evEqualizer" },
27 { evEqualizer, "evEqualeaser" },
28 { evPlayList, "evPlaylist" },
29 { evExit, "evExit" },
30 { evIconify, "evIconify" },
31 { evIncBalance, "evIncBalance" },
32 { evDecBalance, "evDecBalance" },
33 { evFullScreen, "evFullScreen" },
34 { evFName, "evFName" },
35 { evMovieTime, "evMovieTime" },
36 { evAbout, "evAbout" },
37 { evLoadPlay, "evLoadPlay" },
38 { evPreferences, "evPreferences" },
39 { evSkinBrowser, "evSkinBrowser" },
40 { evBackward10sec, "evBackward10sec" },
41 { evForward10sec, "evForward10sec" },
42 { evBackward1min, "evBackward1min" },
43 { evForward1min, "evForward1min" },
44 { evBackward10min, "evBackward10min" },
45 { evForward10min, "evForward10min" },
46 { evIncVolume, "evIncVolume" },
47 { evDecVolume, "evDecVolume" },
48 { evMute, "evMute" },
49 { evIncAudioBufDelay, "evIncAudioBufDelay" },
50 { evDecAudioBufDelay, "evDecAudioBufDelay" },
51 { evPlaySwitchToPause, "evPlaySwitchToPause" },
52 { evPauseSwitchToPlay, "evPauseSwitchToPlay" },
53 { evNormalSize, "evHalfSize" },
54 { evNormalSize, "evNormalSize" },
55 { evDoubleSize, "evDoubleSize" },
56 { evSetMoviePosition, "evSetMoviePosition" },
57 { evSetVolume, "evSetVolume" },
58 { evSetBalance, "evSetBalance" },
59 { evHelp, "evHelp" },
60 { evLoadSubtitle, "evLoadSubtitle" },
61 { evPlayDVD, "evPlayDVD" },
62 { evPlayVCD, "evPlayVCD" },
63 { evSetURL, "evSetURL" },
64 { evLoadAudioFile, "evLoadAudioFile" },
65 { evDropSubtitle, "evDropSubtitle" },
66 { evSetAspect, "evSetAspect" }
69 int evBoxs = sizeof( evNames ) / sizeof( evName );
71 // ---
73 listItems appMPlayer;
75 /* FIXME: Eventually remove the obsolete directory names. */
76 char * skinDirInHome=NULL;
77 char * skinDirInHome_obsolete=NULL;
78 char * skinMPlayerDir=NULL;
79 char * skinMPlayerDir_obsolete=NULL;
80 char * skinName = NULL;
82 void appClearItem( wItem * item )
84 item->type=0;
85 // ---
86 item->x=0; item->y=0; item->width=0; item->height=0;
87 // ---
88 item->px=0; item->py=0; item->psx=0; item->psy=0;
89 // ---
90 item->msg=0; item->msg2=0;
91 item->pressed=btnReleased;
92 item->tmp=0;
93 item->key=0; item->key2=0;
94 item->Bitmap.Width=0; item->Bitmap.Height=0; item->Bitmap.BPP=0; item->Bitmap.ImageSize=0;
95 if ( item->Bitmap.Image ) free( item->Bitmap.Image );
96 item->Bitmap.Image=NULL;
97 // ---
98 item->fontid=0;
99 if ( item->label ) free( item->label ); item->label=NULL;
100 item->event=0;
103 void appCopy( listItems * dest,listItems * source )
105 dest->NumberOfItems=source->NumberOfItems;
106 memcpy( &dest->Items,&source->Items,128 * sizeof( wItem ) );
108 dest->NumberOfMenuItems=source->NumberOfMenuItems;
109 memcpy( &dest->MenuItems,&source->MenuItems,32 * sizeof( wItem ) );
111 memcpy( &dest->main,&source->main,sizeof( wItem ) );
112 memcpy( &dest->sub,&source->sub,sizeof( wItem ) );
113 memcpy( &dest->menuBase,&source->menuBase,sizeof( wItem ) );
114 memcpy( &dest->menuSelected,&source->menuSelected,sizeof( wItem ) );
117 void appInitStruct( listItems * item )
119 int i;
120 for ( i=0;i<item->NumberOfItems;i++ )
121 appClearItem( &item->Items[i] );
122 for ( i=0;i<item->NumberOfMenuItems;i++ )
123 appClearItem( &item->MenuItems[i] );
124 for ( i=0;i<item->NumberOfBarItems;i++ )
125 appClearItem( &item->barItems[i] );
127 item->NumberOfItems=-1;
128 memset( item->Items,0,256 * sizeof( wItem ) );
129 item->NumberOfMenuItems=-1;
130 memset( item->MenuItems,0,64 * sizeof( wItem ) );
131 item->NumberOfBarItems=-1;
132 memset( item->barItems,0,256 * sizeof( wItem ) );
134 appClearItem( &item->main );
135 item->mainDecoration=0;
136 appClearItem( &item->sub );
137 item->sub.width=0; item->sub.height=0;
138 item->sub.x=-1; item->sub.y=-1;
139 appClearItem( &item->menuBase );
140 appClearItem( &item->menuSelected );
141 item->sub.R=item->sub.G=item->sub.B=0;
142 item->bar.R=item->bar.G=item->bar.B=0;
143 item->main.R=item->main.G=item->main.B=0;
144 item->barIsPresent=0;
145 item->menuIsPresent=0;
148 int appFindKey( unsigned char * name )
150 int i;
151 for ( i=0;i<wsKeyNumber;i++ )
152 if ( !strcmp( wsKeyNames[i].name,name ) ) return wsKeyNames[i].code;
153 return -1;
156 int appFindMessage( unsigned char * str )
158 int i;
159 for ( i=0;i<evBoxs;i++ )
160 if ( !strcmp( evNames[i].name,str ) ) return evNames[i].msg;
161 return -1;
164 void btnModify( int event,float state )
166 int j;
167 for ( j=0;j < appMPlayer.NumberOfItems + 1;j++ )
168 if ( appMPlayer.Items[j].msg == event )
170 switch ( appMPlayer.Items[j].type )
172 case itButton:
173 appMPlayer.Items[j].pressed=(int)state;
174 appMPlayer.Items[j].tmp=(int)state;
175 break;
176 case itPotmeter:
177 case itVPotmeter:
178 case itHPotmeter:
179 if ( state < 0.0f ) state=0.0f;
180 if ( state > 100.f ) state=100.0f;
181 appMPlayer.Items[j].value=state;
182 break;
186 for ( j=0;j < appMPlayer.NumberOfBarItems + 1;j++ )
187 if ( appMPlayer.barItems[j].msg == event )
189 switch ( appMPlayer.barItems[j].type )
191 case itButton:
192 appMPlayer.barItems[j].pressed=(int)state;
193 appMPlayer.barItems[j].tmp=(int)state;
194 break;
195 case itPotmeter:
196 case itVPotmeter:
197 case itHPotmeter:
198 if ( state < 0.0f ) state=0.0f;
199 if ( state > 100.f ) state=100.0f;
200 appMPlayer.barItems[j].value=state;
201 break;
206 float btnGetValue( int event )
208 int j;
209 for ( j=0;j<appMPlayer.NumberOfItems + 1;j++ )
210 if ( appMPlayer.Items[j].msg == event ) return appMPlayer.Items[j].value;
211 return 0;
214 void btnSet( int event,int set )
216 int j;
217 for ( j=0;j<appMPlayer.NumberOfItems + 1;j++ )
218 if ( appMPlayer.Items[j].msg == event )
219 { appMPlayer.Items[j].pressed=set; appMPlayer.barItems[j].tmp=0; }
220 for ( j=0;j<appMPlayer.NumberOfBarItems + 1;j++ )
221 if ( appMPlayer.barItems[j].msg == event )
222 { appMPlayer.barItems[j].pressed=set; appMPlayer.barItems[j].tmp=0; }