aboutsummaryrefslogtreecommitdiffhomepage
path: root/gui/app.c
blob: d375296dc4215f5c5eb409ecaff504e50d20a211 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225


#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "config.h"
#include "mp_msg.h"
#include "help_mp.h"

#include "app.h"
#include "wm/wskeys.h"
#include "skin/skin.h"
#include "mplayer/gmplayer.h"
#include "interface.h"

evName evNames[] =
 {
  { evNone,              "evNone"              },
  { evPlay,              "evPlay"              },
  { evStop,              "evStop"              },
  { evPause,             "evPause"             },
  { evPrev,              "evPrev"              },
  { evNext,              "evNext"              },
  { evLoad,              "evLoad"              },
  { evEqualizer,         "evEqualizer"         },
  { evEqualizer,         "evEqualeaser"        },
  { evPlayList,          "evPlaylist"          },
  { evExit,              "evExit"              },
  { evIconify,           "evIconify"           },
  { evIncBalance,        "evIncBalance"        },
  { evDecBalance,        "evDecBalance"        },
  { evFullScreen,        "evFullScreen"        },
  { evFName,             "evFName"             },
  { evMovieTime,         "evMovieTime"         },
  { evAbout,             "evAbout"             },
  { evLoadPlay,          "evLoadPlay"          },
  { evPreferences,       "evPreferences"       },
  { evSkinBrowser,       "evSkinBrowser"       },
  { evBackward10sec,     "evBackward10sec"     },
  { evForward10sec,      "evForward10sec"      },
  { evBackward1min,      "evBackward1min"      },
  { evForward1min,       "evForward1min"       },
  { evBackward10min,     "evBackward10min"     },
  { evForward10min,      "evForward10min"      },
  { evIncVolume,         "evIncVolume"         },
  { evDecVolume,         "evDecVolume"         },
  { evMute,              "evMute"              },
  { evIncAudioBufDelay,  "evIncAudioBufDelay"  },
  { evDecAudioBufDelay,  "evDecAudioBufDelay"  },
  { evPlaySwitchToPause, "evPlaySwitchToPause" },
  { evPauseSwitchToPlay, "evPauseSwitchToPlay" },
  { evNormalSize,        "evHalfSize"          },
  { evNormalSize,        "evNormalSize"        },
  { evDoubleSize,        "evDoubleSize"        },
  { evSetMoviePosition,  "evSetMoviePosition"  },
  { evSetVolume,         "evSetVolume"         },
  { evSetBalance,        "evSetBalance"        },
  { evHelp,		 "evHelp"	       },	
  { evLoadSubtitle,      "evLoadSubtitle"      },
  { evPlayDVD,		 "evPlayDVD"	       },
  { evPlayVCD,		 "evPlayVCD"	       },
  { evSetURL,		 "evSetURL"	       },
  { evLoadAudioFile,	 "evLoadAudioFile"     },
  { evDropSubtitle,      "evDropSubtitle"      },
  { evSetAspect,	 "evSetAspect"	       }
 };

int evBoxs = sizeof( evNames ) / sizeof( evName );

// ---

extern char *get_path(const char *);

listItems   appMPlayer;

/* FIXME: Eventually remove the obsolete directory names. */
char      * skinDirInHome=NULL;
char      * skinDirInHome_obsolete=NULL;
char      * skinMPlayerDir=NULL;
char      * skinMPlayerDir_obsolete=NULL;
char      * skinName = NULL;

void appClearItem( wItem * item )
{
 item->type=0;
// ---
 item->x=0; item->y=0; item->width=0; item->height=0;
// ---
 item->px=0; item->py=0; item->psx=0; item->psy=0;
// ---
 item->msg=0; item->msg2=0;
 item->pressed=btnReleased;
 item->tmp=0;
 item->key=0; item->key2=0;
 item->Bitmap.Width=0; item->Bitmap.Height=0; item->Bitmap.BPP=0; item->Bitmap.ImageSize=0;
 if ( item->Bitmap.Image ) free( item->Bitmap.Image ); 
 item->Bitmap.Image=NULL;
// ---
 item->fontid=0;
 if ( item->label ) free( item->label ); item->label=NULL;
 item->event=0;
}

void appCopy( listItems * dest,listItems * source )
{
 dest->NumberOfItems=source->NumberOfItems;
 memcpy( &dest->Items,&source->Items,128 * sizeof( wItem ) );

 dest->NumberOfMenuItems=source->NumberOfMenuItems;
 memcpy( &dest->MenuItems,&source->MenuItems,32 * sizeof( wItem ) );

 memcpy( &dest->main,&source->main,sizeof( wItem ) );
 memcpy( &dest->sub,&source->sub,sizeof( wItem ) );
 memcpy( &dest->menuBase,&source->menuBase,sizeof( wItem ) );
 memcpy( &dest->menuSelected,&source->menuSelected,sizeof( wItem ) );
}

void appInitStruct( listItems * item )
{
 int i;
 for ( i=0;i<item->NumberOfItems;i++ )
  appClearItem( &item->Items[i] );
 for ( i=0;i<item->NumberOfMenuItems;i++ )
  appClearItem( &item->MenuItems[i] );
 for ( i=0;i<item->NumberOfBarItems;i++ )
  appClearItem( &item->barItems[i] );

 item->NumberOfItems=-1;
 memset( item->Items,0,256 * sizeof( wItem ) );
 item->NumberOfMenuItems=-1;
 memset( item->MenuItems,0,64 * sizeof( wItem ) );
 item->NumberOfBarItems=-1;
 memset( item->barItems,0,256 * sizeof( wItem ) );

 appClearItem( &item->main );
 item->mainDecoration=0;
 appClearItem( &item->sub );
 item->sub.width=0; item->sub.height=0;
 item->sub.x=-1; item->sub.y=-1;
 appClearItem( &item->menuBase );
 appClearItem( &item->menuSelected );
 item->sub.R=item->sub.G=item->sub.B=0;
 item->bar.R=item->bar.G=item->bar.B=0;
 item->main.R=item->main.G=item->main.B=0;
 item->barIsPresent=0;
 item->menuIsPresent=0;
}

int appFindKey( unsigned char * name )
{
 int i;
 for ( i=0;i<wsKeyNumber;i++ )
  if ( !strcmp( wsKeyNames[i].name,name ) ) return wsKeyNames[i].code;
 return -1;
}

int appFindMessage( unsigned char * str )
{
 int i;
 for ( i=0;i<evBoxs;i++ )
  if ( !strcmp( evNames[i].name,str ) ) return evNames[i].msg;
 return -1;
}

void btnModify( int event,float state )
{
 int j;
 for ( j=0;j < appMPlayer.NumberOfItems + 1;j++ )
  if ( appMPlayer.Items[j].msg == event )
   {
    switch ( appMPlayer.Items[j].type )
     {
      case itButton:
            appMPlayer.Items[j].pressed=(int)state;
            appMPlayer.Items[j].tmp=(int)state;
            break;
      case itPotmeter:
      case itVPotmeter:
      case itHPotmeter:
    	    if ( state < 0.0f ) state=0.0f;
	    if ( state > 100.f ) state=100.0f;
	    appMPlayer.Items[j].value=state;
	    break;
     }
   }

 for ( j=0;j < appMPlayer.NumberOfBarItems + 1;j++ )
  if ( appMPlayer.barItems[j].msg == event )
   {
    switch ( appMPlayer.barItems[j].type )
     {
      case itButton:
            appMPlayer.barItems[j].pressed=(int)state;
            appMPlayer.barItems[j].tmp=(int)state;
            break;
      case itPotmeter:
      case itVPotmeter:
      case itHPotmeter:
    	    if ( state < 0.0f ) state=0.0f;
	    if ( state > 100.f ) state=100.0f;
	    appMPlayer.barItems[j].value=state;
	    break;
     }
   }
}

float btnGetValue( int event )
{
 int j;
 for ( j=0;j<appMPlayer.NumberOfItems + 1;j++ )
   if ( appMPlayer.Items[j].msg == event ) return appMPlayer.Items[j].value;
 return 0;
}

void btnSet( int event,int set )
{
 int j;
 for ( j=0;j<appMPlayer.NumberOfItems + 1;j++ )
   if ( appMPlayer.Items[j].msg == event )
    { appMPlayer.Items[j].pressed=set; appMPlayer.barItems[j].tmp=0; }
 for ( j=0;j<appMPlayer.NumberOfBarItems + 1;j++ )
   if ( appMPlayer.barItems[j].msg == event )
    { appMPlayer.barItems[j].pressed=set; appMPlayer.barItems[j].tmp=0; } 
}