diff options
author | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2001-08-25 21:04:29 +0000 |
---|---|---|
committer | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2001-08-25 21:04:29 +0000 |
commit | 9f6529b3d3a1ec681a84735d57a9f2d8656809af (patch) | |
tree | 4943e4a95c68932a956ce7a693c58f5b2ed79b37 | |
parent | 05f7ab93841eef7bf50c31b64bf723c100e0c123 (diff) | |
download | mpv-9f6529b3d3a1ec681a84735d57a9f2d8656809af.tar.bz2 mpv-9f6529b3d3a1ec681a84735d57a9f2d8656809af.tar.xz |
GUI version n-1
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1694 b3059339-0415-0410-9bf9-f77b7e298cf2
67 files changed, 8957 insertions, 0 deletions
diff --git a/Gui/Makefile b/Gui/Makefile new file mode 100644 index 0000000000..765b66b483 --- /dev/null +++ b/Gui/Makefile @@ -0,0 +1,57 @@ + +LIB = libgui.a + +include ../config.mak +include config.mak + +include bitmap/bitmap.mak +MPLAYERDIR = mplayer/ +include gui.mak + +INCDIR = -I. -I./event -I./wm -I./skin $(GTKINC) + +OPTIMIZE = $(OPTFLAGS) -fomit-frame-pointer \ + -fexpensive-optimizations -malign-double -fschedule-insns2 -mwide-multiply -Wall + +CFLAGS = $(OPTIMIZE) $(INCDIR) $(DEBUG) + +.SUFFIXES: .c .o + +.c.o: + $(CC) -c $(CFLAGS) -o $@ $< + +### TARGETS ### + +$(LIB): .depend $(OBJS) + $(MAKE) -C mplayer + rm -f $(LIB) + ar rc $(LIB) $(OBJS) $(MPLAYEROBJS) + +all: $(LIB) + +clean: + $(MAKE) -C mplayer clean + rm -rf $(OBJS) *.o *~ *.bak main $(PRG) $(LIB) .depend + +#dep: depend +# +#depend: +# makedepend -- $(CFLAGS) -- $(SRCS) &>/dev/null +# + +distclean: clean + +dep: depend + +depend: .depend + +.depend: Makefile config.mak config.h gui.mak bitmap/bitmap.mak + $(MAKE) -C mplayer depend + $(CC) -MM $(CFLAGS) $(SRCS) 1>.depend + +# +# include dependency files if they exist +# +ifneq ($(wildcard .depend),) +include .depend +endif diff --git a/Gui/app.c b/Gui/app.c new file mode 100644 index 0000000000..3c0e04f1bb --- /dev/null +++ b/Gui/app.c @@ -0,0 +1,124 @@ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "app.h" +#include "../config.h" +#include "config.h" +#include "error.h" +#include "wm/wskeys.h" +#include "skin/skin.h" +#include "mplayer/mplayer.h" + +listItems appMPlayer; +listItems appTV; +listItems appRadio; + +char * appMPlayerDirInHome=NULL; +char * appMPlayerDir=NULL; +char * skinDirInHome=NULL; +char * skinMPlayerDir=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=0; + 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->eq,&source->eq,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] ); + + item->NumberOfItems=-1; + memset( item->Items,0,128 * sizeof( wItem ) ); + item->NumberOfMenuItems=-1; + memset( item->MenuItems,0,32 * sizeof( wItem ) ); + + appClearItem( &item->main ); + appClearItem( &item->sub ); + item->sub.Bitmap.Width=256; item->sub.Bitmap.Height=256; + item->sub.width=256; item->sub.height=256; + appClearItem( &item->menuBase ); + appClearItem( &item->menuSelected ); + item->subR=0; + item->subG=0; + item->subB=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 appInit( int argc,char* argv[], char *envp[] ) +{ + if ( ( appMPlayerDirInHome=(char *)calloc( 1,strlen( getenv( "HOME" ) ) + 9 ) ) != NULL ) + { strcpy( appMPlayerDirInHome,getenv( "HOME" ) ); strcat( appMPlayerDirInHome,"/.mplayer" ); } + if ( ( skinDirInHome=(char *)calloc( 1,strlen( appMPlayerDirInHome ) + 5 ) ) != NULL ) + { strcpy( skinDirInHome,appMPlayerDirInHome ); strcat( skinDirInHome,"/Skin" ); } + if ( ( appMPlayerDir=(char *)calloc( 1,strlen( PREFIX ) + 14 ) ) != NULL ) + { strcpy( appMPlayerDir,PREFIX ); strcat( appMPlayerDir,"/share/mplayer" ); } + if ( ( skinMPlayerDir=(char *)calloc( 1,strlen( appMPlayerDir ) + 5 ) ) != NULL ) + { strcpy( skinMPlayerDir,appMPlayerDir ); strcat( skinMPlayerDir,"/Skin" ); } + + initDebug(); + + cfgDefaults(); + cfgRead(); + if ( !strcmp( cfgAppName,"movieplayer" ) ) + { + appMPlayer.sub.x=-1; appMPlayer.sub.y=-1; appMPlayer.sub.width=512; appMPlayer.sub.height=256; + switch ( skinRead( cfgSkin ) ) + { + case -1: dbprintf( 0,"[app] skin configfile not found.\n" ); exit( 0 ); + case -2: dbprintf( 0,"[app] skin configfile read error.\n" ); exit( 0 ); + } + mplInit( argc,argv,envp ); + } +} diff --git a/Gui/app.h b/Gui/app.h new file mode 100644 index 0000000000..498d1b262c --- /dev/null +++ b/Gui/app.h @@ -0,0 +1,89 @@ + +#ifndef __MY_APPS +#define __MY_APPS + +#include "bitmap/bitmap.h" +#include "wm/ws.h" +#include "wm/wskeys.h" +#include "events.h" + +#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 itBase 106 +#define itPotmeter 107 +#define itFont 108 +// --- +#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,disabled,tmp; + int key,key2; + int phases; + float value; + txSample Bitmap; + txSample Mask; +// --- + int fontid; + int align; + char * label; +// --- + int event; +} wItem; + +typedef struct +{ + wItem main; + wsTWindow mainWindow; + + wItem sub; + wsTWindow subWindow; + int subR,subG,subB; + int subPixel; + + wItem eq; + wsTWindow eqWindow; + + wItem menuBase; + wItem menuSelected; + wsTWindow menuWindow; + +// --- + int NumberOfItems; + wItem Items[256]; +// --- + int NumberOfMenuItems; + wItem MenuItems[32]; +} listItems; + +extern listItems appMPlayer; +extern listItems appTV; +extern listItems appRadio; + +extern char * appMPlayerDirInHome; +extern char * appMPlayerDir; +extern char * skinDirInHome; +extern char * skinMPlayerDir; + +extern void appInit( int argc,char* argv[], char *envp[] ); +extern void appInitStruct( listItems * item ); +extern void appClearItem( wItem * item ); +extern void appCopy( listItems * item1,listItems * item2 ); +extern int appFindMessage( unsigned char * str ); +extern int appFindKey( unsigned char * name ); + +#endif diff --git a/Gui/bitmap.c b/Gui/bitmap.c new file mode 100644 index 0000000000..8343058ce2 --- /dev/null +++ b/Gui/bitmap.c @@ -0,0 +1,174 @@ + +#include <stdlib.h> +#include <stdio.h> + +#include "bitmap.h" +#include "../error.h" + +#define BMP 1 +#define TGA 2 +#define PNG 3 +#define TGAPACKED 4 + +extern char * strcat( char * dest,const char * src ); + +int conv24to32( txSample * bf ) +{ + unsigned char * tmpImage; + int i,c; + + if ( bf->BPP == 24 ) + { + tmpImage=bf->Image; + bf->ImageSize=bf->Width * bf->Height * 4; + bf->BPP=32; + if ( ( bf->Image=malloc( bf->ImageSize ) ) == NULL ) + { + #ifdef DEBUG + dbprintf( 4,"[bitmap] Not enough memory for image.\n" ); + #endif + return 1; + } + memset( bf->Image,0,bf->ImageSize ); + for ( c=0,i=0;i < bf->Width * bf->Height * 3; ) + { + bf->Image[c++]=tmpImage[i++]; + bf->Image[c++]=tmpImage[i++]; + bf->Image[c++]=tmpImage[i++]; c++; + } + free( tmpImage ); + } + return 0; +} + +void bgr2rgb( txSample * bf ) +{ + unsigned char c; + int i; + + for ( i=0;i < bf->ImageSize;i+=4 ) + { + c=bf->Image[i]; + bf->Image[i]=bf->Image[i+2]; + bf->Image[i+2]=c; + } +} + +void Normalize( txSample * bf ) +{ + int i; + + for ( i=0;i < bf->ImageSize;i+=4 ) bf->Image[i+3]=0; +} + +unsigned char tmp[512]; + +unsigned char * fExist( unsigned char * fname ) +{ + FILE * fl; + unsigned char ext[][6] = { ".tga\0",".TGA\0",".png\0",".PNG\0",".bmp\0",".BMP\0" }; + int i; + + fl=fopen( fname,"rb" ); + if ( fl != NULL ) + { + fclose( fl ); + return fname; + } + for ( i=0;i<10;i++ ) + { + strcpy( tmp,fname ); + strcat( tmp,ext[i] ); + fl=fopen( tmp,"rb" ); + if ( fl != NULL ) + { + fclose( fl ); + return tmp; + } + } + return NULL; +} + +int aComp( unsigned char * b1,unsigned char * b2,int size ) +{ + int i; + for( i=0;i<size;i++ ) if ( b1[i] != b2[i] ) return 0; + return 1; +} + +int GetFileType( char * fname ) +{ + FILE * fl; + unsigned char buffer[10]; + unsigned char bmp[2] = { 0x42,0x4d }; + unsigned char tga[7] = { 0x00,0x02,0x00,0x00,0x00,0x00,0x00 }; + unsigned char ptga[7] = { 0x00,0x0a,0x00,0x00,0x00,0x00,0x00 }; + unsigned char png[8] = { 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a }; + + if ( ( fl=fopen( fname,"rb" ) ) == NULL ) return -1; + fread( buffer,1,10,fl ); + fclose( fl ); + + if ( aComp( buffer,bmp,2 ) ) return BMP; // --- bmp + if ( aComp( &buffer[1],tga,8 ) ) return TGA; // --- tga + if ( aComp( &buffer[1],ptga,7 ) ) return TGAPACKED; // --- tga + if ( aComp( buffer,png,8 ) ) return PNG; // --- png + return 0; // --- others +} + +int bpRead( char * fname, txSample * bf ) +{ + int bgr = 0; + int i; + + fname=fExist( fname ); + if ( fname == NULL ) return -2; + switch ( GetFileType( fname ) ) + { + case BMP: + i=bmpRead( fname,bf ); + switch ( i ) + { + case 0: break; + case 3: return -1; + default: return -3; + } + break; + case TGA: + i=tgaRead( fname,bf ); + switch ( i ) + { + case 0: break; + case 3: return -1; + default: return -4; + } + break; + case PNG: + if ( pngRead( fname,bf ) ) return -5; + bgr=1; + break; + case TGAPACKED: + #ifdef DEBUG + dbprintf( 4,"[bitmap] sorry, packed TGA not supported.\n" ); + #endif + return -6; + default: + { + #ifdef DEBUG + dbprintf( 4,"[bitmap] Unknown file type ( %s ).\n",fname ); + #endif + return -7; + } + } + if ( bf->BPP < 24 ) + { + #ifdef DEBUG + dbprintf( 4,"[bitmap] sorry, 16 or less bitmaps not supported.\n" ); + #endif + return -1; + } + if ( conv24to32( bf ) ) return -8; + if ( bgr ) bgr2rgb( bf ); + Normalize( bf ); + return 0; +} diff --git a/Gui/bitmap.h b/Gui/bitmap.h new file mode 100644 index 0000000000..c9d18b123c --- /dev/null +++ b/Gui/bitmap.h @@ -0,0 +1,21 @@ + +#ifndef __MYSAMPLE +#define __MYSAMPLE + +typedef struct _txSample +{ + unsigned int Width; + unsigned int Height; + unsigned int BPP; + unsigned long ImageSize; + char * Image; +} txSample; + +#include "tga/tga.h" +#include "bmp/bmp.h" +#include "png/png.h" + +extern int bpRead( char * fname, txSample * bf ); +extern int conv24to32( txSample * bf ); + +#endif
\ No newline at end of file diff --git a/Gui/bitmap/Makefile b/Gui/bitmap/Makefile new file mode 100644 index 0000000000..da6bf55618 --- /dev/null +++ b/Gui/bitmap/Makefile @@ -0,0 +1,89 @@ + +include ../config.mak + +SRCS = bitmap.c tga/tga.c jpeg/jpeg.c bmp/bmp.c +OBJS = bitmap.o tga/tga.o jpeg/jpeg.o bmp/bmp.o + +.SUFFIXES: .c .o + +.c.o: + $(CC) -c $(CFLAGS) -o $@ $< + +### TARGETS ### + +all: + @( [ -e $(JPEGLIB) ] || \ + make -C jpeg/jpeg-6b libjpeg.a ) +# ( make -C jpeg/jpeg-6b libjpeg.a && mv jpeg/jpeg-6b/libjpeg.a "$(JPEGLIB)" ) ) + $(MAKE) $(OBJS) + ar rc libbitmap.a $(OBJS) jpeg/jpeg-6b/*.o + ranlib libbitmap.a + mv libbitmap.a ../libs + +#comp: +# $(MAKE) $(OBJS) + +clean: + $(MAKE) -C jpeg/jpeg-6b clean + -rm -rf $(OBJS) *.o *~ *.bak $(JPEGLIB) + +dep: depend + +depend: + makedepend -- $(CFLAGS) -- $(SRCS) &>/dev/null + +# DO NOT DELETE + +bitmap.o: /usr/include/stdlib.h /usr/include/features.h +bitmap.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h +bitmap.o: /usr/lib/gcc-lib/i386-linux/2.95.2/include/stddef.h +bitmap.o: /usr/include/sys/types.h /usr/include/bits/types.h +bitmap.o: /usr/include/time.h /usr/include/endian.h +bitmap.o: /usr/include/bits/endian.h /usr/include/sys/select.h +bitmap.o: /usr/include/bits/select.h /usr/include/bits/sigset.h +bitmap.o: /usr/include/sys/sysmacros.h /usr/include/alloca.h +bitmap.o: /usr/include/stdio.h +bitmap.o: /usr/lib/gcc-lib/i386-linux/2.95.2/include/stdarg.h +bitmap.o: /usr/include/libio.h /usr/include/_G_config.h +bitmap.o: /usr/include/bits/stdio_lim.h bitmap.h tga/tga.h bitmap.h +bitmap.o: jpeg/jpeg.h bmp/bmp.h +tga/tga.o: /usr/include/string.h /usr/include/features.h +tga/tga.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h +tga/tga.o: /usr/lib/gcc-lib/i386-linux/2.95.2/include/stddef.h +tga/tga.o: /usr/include/stdio.h +tga/tga.o: /usr/lib/gcc-lib/i386-linux/2.95.2/include/stdarg.h +tga/tga.o: /usr/include/bits/types.h /usr/include/libio.h +tga/tga.o: /usr/include/_G_config.h /usr/include/bits/stdio_lim.h +tga/tga.o: /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h +tga/tga.o: /usr/include/endian.h /usr/include/bits/endian.h +tga/tga.o: /usr/include/sys/select.h /usr/include/bits/select.h +tga/tga.o: /usr/include/bits/sigset.h /usr/include/sys/sysmacros.h +tga/tga.o: /usr/include/alloca.h tga/tga.h bitmap.h +jpeg/jpeg.o: /usr/include/setjmp.h /usr/include/features.h +jpeg/jpeg.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h +jpeg/jpeg.o: /usr/include/bits/setjmp.h /usr/include/bits/sigset.h +jpeg/jpeg.o: /usr/include/string.h +jpeg/jpeg.o: /usr/lib/gcc-lib/i386-linux/2.95.2/include/stddef.h +jpeg/jpeg.o: /usr/include/stdlib.h /usr/include/sys/types.h +jpeg/jpeg.o: /usr/include/bits/types.h /usr/include/time.h +jpeg/jpeg.o: /usr/include/endian.h /usr/include/bits/endian.h +jpeg/jpeg.o: /usr/include/sys/select.h /usr/include/bits/select.h +jpeg/jpeg.o: /usr/include/sys/sysmacros.h /usr/include/alloca.h +jpeg/jpeg.o: /usr/include/stdio.h +jpeg/jpeg.o: /usr/lib/gcc-lib/i386-linux/2.95.2/include/stdarg.h +jpeg/jpeg.o: /usr/include/libio.h /usr/include/_G_config.h +jpeg/jpeg.o: /usr/include/bits/stdio_lim.h jpeg/jpeg-6b/jpeglib.h +jpeg/jpeg.o: jpeg/jpeg-6b/jconfig.h jpeg/jpeg-6b/jmorecfg.h bitmap.h +jpeg/jpeg.o: jpeg/jpeg.h +bmp/bmp.o: /usr/include/stdlib.h /usr/include/features.h +bmp/bmp.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h +bmp/bmp.o: /usr/lib/gcc-lib/i386-linux/2.95.2/include/stddef.h +bmp/bmp.o: /usr/include/sys/types.h /usr/include/bits/types.h +bmp/bmp.o: /usr/include/time.h /usr/include/endian.h +bmp/bmp.o: /usr/include/bits/endian.h /usr/include/sys/select.h +bmp/bmp.o: /usr/include/bits/select.h /usr/include/bits/sigset.h +bmp/bmp.o: /usr/include/sys/sysmacros.h /usr/include/alloca.h +bmp/bmp.o: /usr/include/stdio.h +bmp/bmp.o: /usr/lib/gcc-lib/i386-linux/2.95.2/include/stdarg.h +bmp/bmp.o: /usr/include/libio.h /usr/include/_G_config.h +bmp/bmp.o: /usr/include/bits/stdio_lim.h bmp/bmp.h bitmap.h diff --git a/Gui/bitmap/bitmap.c b/Gui/bitmap/bitmap.c new file mode 100644 index 0000000000..8343058ce2 --- /dev/null +++ b/Gui/bitmap/bitmap.c @@ -0,0 +1,174 @@ + +#include <stdlib.h> +#include <stdio.h> + +#include "bitmap.h" +#include "../error.h" + +#define BMP 1 +#define TGA 2 +#define PNG 3 +#define TGAPACKED 4 + +extern char * strcat( char * dest,const char * src ); + +int conv24to32( txSample * bf ) +{ + unsigned char * tmpImage; + int i,c; + + if ( bf->BPP == 24 ) + { + tmpImage=bf->Image; + bf->ImageSize=bf->Width * bf->Height * 4; + bf->BPP=32; + if ( ( bf->Image=malloc( bf->ImageSize ) ) == NULL ) + { + |