Mercurial > mplayer.hg
changeset 32897:14af78beac02
Cosmetic: Format to MPlayer coding style.
author | ib |
---|---|
date | Mon, 28 Feb 2011 13:25:45 +0000 |
parents | c39348b4064a |
children | eeb36d798219 |
files | gui/app.c gui/app.h |
diffstat | 2 files changed, 293 insertions(+), 274 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/app.c Mon Feb 28 13:05:01 2011 +0000 +++ b/gui/app.c Mon Feb 28 13:25:45 2011 +0000 @@ -17,226 +17,252 @@ */ #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" + +listItems appMPlayer; + +char *skinDirInHome = NULL; +char *skinMPlayerDir = NULL; +char *skinName = NULL; -static const 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" } - }; +static const evName evNames[] = { + { evNone, "evNone" }, + { evPlay, "evPlay" }, + { evStop, "evStop" }, + { evPause, "evPause" }, + { evPrev, "evPrev" }, + { evNext, "evNext" }, + { evLoad, "evLoad" }, + { evEqualizer, "evEqualizer" }, + { evEqualizer, "evEqualeaser" }, // NOTE TO MYSELF: any skin using this? + { evPlayList, "evPlaylist" }, + { evExit, "evExit" }, + { evIconify, "evIconify" }, + { evIncBalance, "evIncBalance" }, // NOTE TO MYSELF: not all of these events + { evDecBalance, "evDecBalance" }, // are actually implemented, and update doc + { 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" } +}; -static const int evBoxs = sizeof( evNames ) / sizeof( evName ); - -// --- - -listItems appMPlayer; +static const int evBoxs = sizeof(evNames) / sizeof(evName); -char * skinDirInHome=NULL; -char * skinMPlayerDir=NULL; -char * skinName = NULL; - -void appClearItem( wItem * item ) +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; - free(item->Bitmap.Image); - item->Bitmap.Image=NULL; -// --- - item->fontid=0; - free(item->label); - item->label=NULL; - free(item->text); - item->text=NULL; - item->textwidth=0; - item->starttime=0; - item->last_x=0; - item->event=0; + 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; + free(item->Bitmap.Image); + item->Bitmap.Image = NULL; + item->fontid = 0; + free(item->label); + item->label = NULL; + free(item->text); + item->text = NULL; + item->textwidth = 0; + item->starttime = 0; + item->last_x = 0; + item->event = 0; } -void appCopy( listItems * dest,listItems * source ) +void appCopy(listItems *dest, listItems *source) { - dest->NumberOfItems=source->NumberOfItems; - memcpy( &dest->Items,&source->Items,128 * sizeof( wItem ) ); + dest->NumberOfItems = source->NumberOfItems; + memcpy(&dest->Items, &source->Items, 128 * sizeof(wItem)); - dest->NumberOfMenuItems=source->NumberOfMenuItems; - memcpy( &dest->MenuItems,&source->MenuItems,32 * 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 ) ); + 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 ) +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] ); + 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->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 ) ); + item->NumberOfBarItems = -1; + memset(item->barItems, 0, 256 * sizeof(wItem)); + + appClearItem(&item->main); + item->mainDecoration = 0; - 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; + 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 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 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 appFindMessage(unsigned char *str) { - int i; - for ( i=0;i<evBoxs;i++ ) - if ( !strcmp( evNames[i].name,str ) ) return evNames[i].msg; - return -1; + 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 ) +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; - } - } + int i; + + for (i = 0; i < appMPlayer.NumberOfItems + 1; i++) { + if (appMPlayer.Items[i].msg == event) { + switch (appMPlayer.Items[i].type) { + case itButton: + appMPlayer.Items[i].pressed = (int)state; + appMPlayer.Items[i].tmp = (int)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; - } - } + case itPotmeter: + case itVPotmeter: + case itHPotmeter: + if (state < 0.0) + state = 0.0; + if (state > 100.0) + state = 100.0; + appMPlayer.Items[i].value = state; + break; + } + } + } + + for (i = 0; i < appMPlayer.NumberOfBarItems + 1; i++) { + if (appMPlayer.barItems[i].msg == event) { + switch (appMPlayer.barItems[i].type) { + case itButton: + appMPlayer.barItems[i].pressed = (int)state; + appMPlayer.barItems[i].tmp = (int)state; + break; + + case itPotmeter: + case itVPotmeter: + case itHPotmeter: + if (state < 0.0) + state = 0.0; + if (state > 100.0) + state = 100.0; + appMPlayer.barItems[i].value = state; + break; + } + } + } } -float btnGetValue( int event ) +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; + int i; + + for (i = 0; i < appMPlayer.NumberOfItems + 1; i++) + if (appMPlayer.Items[i].msg == event) + return appMPlayer.Items[i].value; + + return 0; } -void btnSet( int event,int set ) +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; } + int i; + + for (i = 0; i < appMPlayer.NumberOfItems + 1; i++) { + if (appMPlayer.Items[i].msg == event) { + appMPlayer.Items[i].pressed = set; + appMPlayer.barItems[i].tmp = 0; + } + } + + for (i = 0; i < appMPlayer.NumberOfBarItems + 1; i++) { + if (appMPlayer.barItems[i].msg == event) { + appMPlayer.barItems[i].pressed = set; + appMPlayer.barItems[i].tmp = 0; + } + } }
--- a/gui/app.h Mon Feb 28 13:05:01 2011 +0000 +++ b/gui/app.h Mon Feb 28 13:25:45 2011 +0000 @@ -21,9 +21,8 @@ #include "bitmap.h" #include "wm/ws.h" -#include "wm/wskeys.h" -// --- User events ------ +// User events #define evNone 0 #define evPlay 1 @@ -61,8 +60,8 @@ #define evIncVolume 31 #define evDecVolume 32 -#define evIncAudioBufDelay 33 -#define evDecAudioBufDelay 34 +#define evIncAudioBufDelay 33 // NOTE TO MYSELF: not all of these events +#define evDecAudioBufDelay 34 // are actually implemented, and update doc #define evIncBalance 35 #define evDecBalance 36 @@ -71,18 +70,17 @@ #define evLoadSubtitle 38 #define evDropSubtitle 43 #define evPlayDVD 39 -#define evPlayVCD 40 +#define evPlayVCD 40 #define evPlayNetwork 41 -#define evLoadAudioFile 42 +#define evLoadAudioFile 42 #define evSetAspect 44 -#define evSetAudio 45 -#define evSetVideo 46 +#define evSetAudio 45 +#define evSetVideo 46 #define evSetSubtitle 47 -// 48 ... #define evExit 1000 -// --- General events --- +// General events #define evFileLoaded 5000 #define evHideMouseCursor 5001 @@ -106,100 +104,95 @@ #define evShowWindow 7004 #define evFirstLoad 7005 -// ---------------------- - -typedef struct -{ - int msg; - const char * name; +typedef struct { + int msg; + const char *name; } evName; +// Skin items + #define itNULL 0 -#define itButton 101 // button -#define itHPotmeter 102 // horizontal potmeter -#define itVPotmeter 103 // vertical potmeter -#define itSLabel 104 // static label -#define itDLabel 105 // dynamic label +#define itButton 101 +#define itHPotmeter 102 +#define itVPotmeter 103 +#define itSLabel 104 +#define itDLabel 105 #define itBase 106 #define itPotmeter 107 #define itFont 108 -// --- + +// Button states + #define btnPressed 0 #define btnReleased 1 #define btnDisabled 2 -// --- -typedef struct -{ - int type; -// --- - int x,y; - int width,height; -// --- - int px,py,psx,psy; -// --- - int msg,msg2; - int pressed,tmp; - int key,key2; - int phases; - float value; - txSample Bitmap; - txSample Mask; -// --- - int fontid; - int align; - char * label; - char * text; - int textwidth; - unsigned int starttime; - int last_x; -// --- - int event; -// --- - int R,G,B; + +typedef struct { + int type; + + int x, y; + int width, height; + + int px, py, psx, psy; + + int msg, msg2; + int pressed, tmp; + int key, key2; + int phases; + float value; + + txSample Bitmap; + txSample Mask; + + int fontid; + int align; + char *label; + + char *text; + int textwidth; + unsigned int starttime; + int last_x; + + int event; + + int R, G, B; } wItem; -typedef struct -{ - wItem main; - wsTWindow mainWindow; - int mainDecoration; +typedef struct { + wItem main; + wsTWindow mainWindow; + int mainDecoration; - wItem sub; - wsTWindow subWindow; + wItem sub; + wsTWindow subWindow; - wItem bar; - wsTWindow barWindow; - int barIsPresent; + wItem bar; + wsTWindow barWindow; + int barIsPresent; - wItem menuBase; - wItem menuSelected; - wsTWindow menuWindow; - int menuIsPresent; + wItem menuBase; + wItem menuSelected; + wsTWindow menuWindow; + int menuIsPresent; -// --- - int NumberOfItems; - wItem Items[256]; -// --- - int NumberOfMenuItems; - wItem MenuItems[64]; -// --- - int NumberOfBarItems; - wItem barItems[256]; + int NumberOfItems; + wItem Items[256]; + + int NumberOfMenuItems; + wItem MenuItems[64]; + + int NumberOfBarItems; + wItem barItems[256]; } listItems; -extern listItems appMPlayer; +extern listItems appMPlayer; -extern char * skinDirInHome; -extern char * skinMPlayerDir; +extern char *skinDirInHome; +extern char *skinMPlayerDir; -void appInitStruct( listItems * item ); -void appClearItem( wItem * item ); -void appCopy( listItems * item1, listItems * item2 ); -int appFindMessage( unsigned char * str ); -int appFindKey( unsigned char * name ); - -void btnModify( int event, float state ); -float btnGetValue( int event ); -void btnSet( int event, int set ); +int appFindMessage(unsigned char *); +void appInitStruct(listItems *); +void btnModify(int, float); +void btnSet(int, int); #endif /* MPLAYER_GUI_APP_H */