[MPlayer-cvslog] r33050 - in trunk/gui/mplayer: gui_common.c gui_common.h

ib subversion at mplayerhq.hu
Tue Mar 8 13:29:45 CET 2011


Author: ib
Date: Tue Mar  8 13:29:44 2011
New Revision: 33050

Log:
Cosmetic: Format to MPlayer coding style.

Additionally: sort prototype declarations, remove useless comment at top of
file, add comment to include file, group and sort includes, move assignment
outside condition, group statements by adding or removing new lines to ease
reading and remove needless parentheses and braces.

Modified:
   trunk/gui/mplayer/gui_common.c
   trunk/gui/mplayer/gui_common.h

Modified: trunk/gui/mplayer/gui_common.c
==============================================================================
--- trunk/gui/mplayer/gui_common.c	Tue Mar  8 13:12:37 2011	(r33049)
+++ trunk/gui/mplayer/gui_common.c	Tue Mar  8 13:29:44 2011	(r33050)
@@ -1,6 +1,4 @@
 /*
- * main window
- *
  * This file is part of MPlayer.
  *
  * MPlayer is free software; you can redistribute it and/or modify
@@ -18,307 +16,451 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include <stdlib.h>
-#include <stdio.h>
 #include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include "gui_common.h"
 #include "gui/interface.h"
 #include "gui/skin/font.h"
 
+#include "access_mpcontext.h"
+#include "codec-cfg.h"             // this should be in libmpdemux/stheader.h
 #include "config.h"
 #include "help_mp.h"
-
-#include "stream/stream.h"
+#include "libavutil/avstring.h"
+#include "libmpdemux/stheader.h"
 #include "mixer.h"
 #include "osdep/timer.h"
-#include "libmpdemux/stheader.h"
-#include "codec-cfg.h"
-#include "access_mpcontext.h"
-#include "libavutil/avstring.h"
+#include "stream/stream.h"
 
-static char * image_buffer;
-static int    image_width;
+static char *image_buffer;
+static int image_width;
 
-static void TranslateFilename( int c,char * tmp,size_t tmplen )
+static void TranslateFilename(int c, char *tmp, size_t tmplen)
 {
- int i;
- char * p;
- size_t len;
+    int i;
+    char *p;
+    size_t len;
 
- switch ( guiIntfStruct.StreamType )
-  {
-   case STREAMTYPE_STREAM:
+    switch (guiIntfStruct.StreamType) {
+    case STREAMTYPE_STREAM:
         av_strlcpy(tmp, guiIntfStruct.Filename, tmplen);
         break;
-   case STREAMTYPE_FILE:
-          if ( ( guiIntfStruct.Filename )&&( guiIntfStruct.Filename[0] ) )
-           {
-            if ( (p = strrchr(guiIntfStruct.Filename, '/')) )
-              av_strlcpy(tmp, p + 1, tmplen);
+
+    case STREAMTYPE_FILE:
+        if (guiIntfStruct.Filename && guiIntfStruct.Filename[0]) {
+            p = strrchr(guiIntfStruct.Filename, '/');
+
+            if (p)
+                av_strlcpy(tmp, p + 1, tmplen);
             else
-              av_strlcpy(tmp, guiIntfStruct.Filename, tmplen);
-            len=strlen( tmp );
-            if ( ( len > 3 )&&( tmp[len - 3] == '.' ) ) tmp[len - 3]=0;
-            else if ( ( len > 4 )&&( tmp[len - 4] == '.' ) ) tmp[len - 4]=0;
-            else if ( ( len > 5 )&&( tmp[len - 5] == '.' ) ) tmp[len - 5]=0;
-           } else av_strlcpy( tmp,MSGTR_NoFileLoaded,tmplen );
-          break;
+                av_strlcpy(tmp, guiIntfStruct.Filename, tmplen);
+
+            len = strlen(tmp);
+
+            if (len > 3 && tmp[len - 3] == '.')
+                tmp[len - 3] = 0;
+            else if (len > 4 && tmp[len - 4] == '.')
+                tmp[len - 4] = 0;
+            else if (len > 5 && tmp[len - 5] == '.')
+                tmp[len - 5] = 0;
+        } else
+            av_strlcpy(tmp, MSGTR_NoFileLoaded, tmplen);
+        break;
+
 #ifdef CONFIG_DVDREAD
-   case STREAMTYPE_DVD:
-          if ( guiIntfStruct.DVD.current_chapter ) snprintf(tmp,tmplen,MSGTR_Chapter,guiIntfStruct.DVD.current_chapter );
-            else av_strlcat( tmp,MSGTR_NoChapter,tmplen );
-          break;
+    case STREAMTYPE_DVD:
+        if (guiIntfStruct.DVD.current_chapter)
+            snprintf(tmp, tmplen, MSGTR_Chapter, guiIntfStruct.DVD.current_chapter);
+        else
+            av_strlcat(tmp, MSGTR_NoChapter, tmplen);
+        break;
 #endif
+
 #ifdef CONFIG_VCD
-   case STREAMTYPE_VCD:
-        snprintf( tmp,tmplen,MSGTR_VCDTrack,guiIntfStruct.Track );
-	break;
+    case STREAMTYPE_VCD:
+        snprintf(tmp, tmplen, MSGTR_VCDTrack, guiIntfStruct.Track);
+        break;
 #endif
-   default: av_strlcpy( tmp,MSGTR_NoMediaOpened,tmplen );
-  }
- if ( c )
-  {
-   for ( i=0;i < (int)strlen( tmp );i++ )
-    {
-     int t=0;
-     if ( c == 1 ) { if ( ( tmp[i] >= 'A' )&&( tmp[i] <= 'Z' ) ) t=32; }
-     if ( c == 2 ) { if ( ( tmp[i] >= 'a' )&&( tmp[i] <= 'z' ) ) t=-32; }
-     tmp[i]=(char)( tmp[i] + t );
+
+    default:
+        av_strlcpy(tmp, MSGTR_NoMediaOpened, tmplen);
+    }
+
+    if (c) {
+        for (i = 0; i < (int)strlen(tmp); i++) {
+            int t = 0;
+
+            if (c == 1)
+                if (tmp[i] >= 'A' && tmp[i] <= 'Z')
+                    t = 32;
+
+            if (c == 2)
+                if (tmp[i] >= 'a' && tmp[i] <= 'z')
+                    t = -32;
+
+            tmp[i] = (char)(tmp[i] + t);
+        }
     }
-  }
 }
 
 /* Unsafe!  Pass only null-terminated strings as (char *)str. */
-char * Translate( char * str )
+char *Translate(char *str)
 {
- mixer_t *mixer = mpctx_get_mixer(guiIntfStruct.mpcontext);
- static char   trbuf[512];
-        char   tmp[512];
-        int    i,c;
-        int    t;
-        int    strsize = 0;
- memset( trbuf,0,512 );
- memset( tmp,0,128 );
- strsize = strlen(str);
- for ( c=0,i=0;i < strsize;i++ )
-  {
-   if ( str[i] != '$' ) { trbuf[c++]=str[i]; trbuf[c]=0; }
-    else
-    {
-     switch ( str[++i] )
-      {
-       case 't': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.Track );
-		 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
-       case 'o': TranslateFilename( 0,tmp,sizeof( tmp ) );
-		 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
-       case 'f': TranslateFilename( 1,tmp,sizeof( tmp ) );
-		 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
-       case 'F': TranslateFilename( 2,tmp,sizeof( tmp ) );
-		 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
-       case '6': t=guiIntfStruct.LengthInSec; goto calclengthhhmmss;
-       case '1': t=guiIntfStruct.TimeSec;
+    mixer_t *mixer = mpctx_get_mixer(guiIntfStruct.mpcontext);
+    static char trbuf[512];
+    char tmp[512];
+    int i, c;
+    int t;
+    int strsize = 0;
+
+    memset(trbuf, 0, 512);
+    memset(tmp, 0, 128);
+    strsize = strlen(str);
+
+    for (c = 0, i = 0; i < strsize; i++) {
+        if (str[i] != '$') {
+            trbuf[c++] = str[i];
+            trbuf[c]   = 0;
+        } else {
+            switch (str[++i]) {
+            case 't':
+                snprintf(tmp, sizeof(tmp), "%02d", guiIntfStruct.Track);
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case 'o':
+                TranslateFilename(0, tmp, sizeof(tmp));
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case 'f':
+                TranslateFilename(1, tmp, sizeof(tmp));
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case 'F':
+                TranslateFilename(2, tmp, sizeof(tmp));
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case '6':
+                t = guiIntfStruct.LengthInSec;
+                goto calclengthhhmmss;
+
+            case '1':
+                t = guiIntfStruct.TimeSec;
 calclengthhhmmss:
-            snprintf( tmp,sizeof( tmp ),"%02d:%02d:%02d",t/3600,t/60%60,t%60 );
-            av_strlcat( trbuf,tmp,sizeof( trbuf ) );
-            break;
-       case '7': t=guiIntfStruct.LengthInSec; goto calclengthmmmmss;
-       case '2': t=guiIntfStruct.TimeSec;
+                snprintf(tmp, sizeof(tmp), "%02d:%02d:%02d", t / 3600, t / 60 % 60, t % 60);
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case '7':
+                t = guiIntfStruct.LengthInSec;
+                goto calclengthmmmmss;
+
+            case '2':
+                t = guiIntfStruct.TimeSec;
 calclengthmmmmss:
-            snprintf( tmp,sizeof( tmp ),"%04d:%02d",t/60,t%60 );
-            av_strlcat( trbuf,tmp,sizeof( trbuf ) );
-            break;
-       case '3': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.TimeSec / 3600 );
-		 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
-       case '4': snprintf( tmp,sizeof( tmp ),"%02d",( ( guiIntfStruct.TimeSec / 60 ) % 60 ) );
-		 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
-       case '5': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.TimeSec % 60 );
-		 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
-       case '8': snprintf( tmp,sizeof( tmp ),"%01d:%02d:%02d",guiIntfStruct.TimeSec / 3600,( guiIntfStruct.TimeSec / 60 ) % 60,guiIntfStruct.TimeSec % 60 ); av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
-       case 'v': snprintf( tmp,sizeof( tmp ),"%3.2f%%",guiIntfStruct.Volume );
-		 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
-       case 'V': snprintf( tmp,sizeof( tmp ),"%3.1f",guiIntfStruct.Volume );
-		 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
-       case 'b': snprintf( tmp,sizeof( tmp ),"%3.2f%%",guiIntfStruct.Balance );
-		 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
-       case 'B': snprintf( tmp,sizeof( tmp ),"%3.1f",guiIntfStruct.Balance );
-		 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
-       case 'd': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.FrameDrop );
-		 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
-       case 'x': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.MovieWidth );
-		 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
-       case 'y': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.MovieHeight );
-		 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
-       case 'C': snprintf( tmp,sizeof( tmp ),"%s", guiIntfStruct.sh_video? ((sh_video_t *)guiIntfStruct.sh_video)->codec->name : "");
-                 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
-       case 's': if ( guiIntfStruct.Playing == 0 ) av_strlcat( trbuf,"s",sizeof( trbuf ) ); break;
-       case 'l': if ( guiIntfStruct.Playing == 1 ) av_strlcat( trbuf,"p",sizeof( trbuf ) ); break;
-       case 'e': if ( guiIntfStruct.Playing == 2 ) av_strlcat( trbuf,"e",sizeof( trbuf ) ); break;
-       case 'a':
-            if ( mixer->muted ) { av_strlcat( trbuf,"n",sizeof( trbuf ) ); break; }
-            switch ( guiIntfStruct.AudioType )
-             {
-              case 0: av_strlcat( trbuf,"n",sizeof( trbuf ) ); break;
-              case 1: av_strlcat( trbuf,"m",sizeof( trbuf ) ); break;
-              case 2: av_strlcat( trbuf,"t",sizeof( trbuf ) ); break;
-             }
-            break;
-       case 'T':
-           switch ( guiIntfStruct.StreamType )
-            {
-             case STREAMTYPE_FILE:   av_strlcat( trbuf,"f",sizeof( trbuf ) ); break;
+                snprintf(tmp, sizeof(tmp), "%04d:%02d", t / 60, t % 60);
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case '3':
+                snprintf(tmp, sizeof(tmp), "%02d", guiIntfStruct.TimeSec / 3600);
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case '4':
+                snprintf(tmp, sizeof(tmp), "%02d", (guiIntfStruct.TimeSec / 60) % 60);
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case '5':
+                snprintf(tmp, sizeof(tmp), "%02d", guiIntfStruct.TimeSec % 60);
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case '8':
+                snprintf(tmp, sizeof(tmp), "%01d:%02d:%02d", guiIntfStruct.TimeSec / 3600, (guiIntfStruct.TimeSec / 60) % 60, guiIntfStruct.TimeSec % 60);
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case 'v':
+                snprintf(tmp, sizeof(tmp), "%3.2f%%", guiIntfStruct.Volume);
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case 'V':
+                snprintf(tmp, sizeof(tmp), "%3.1f", guiIntfStruct.Volume);
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case 'b':
+                snprintf(tmp, sizeof(tmp), "%3.2f%%", guiIntfStruct.Balance);
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case 'B':
+                snprintf(tmp, sizeof(tmp), "%3.1f", guiIntfStruct.Balance);
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case 'd':
+                snprintf(tmp, sizeof(tmp), "%d", guiIntfStruct.FrameDrop);
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case 'x':
+                snprintf(tmp, sizeof(tmp), "%d", guiIntfStruct.MovieWidth);
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case 'y':
+                snprintf(tmp, sizeof(tmp), "%d", guiIntfStruct.MovieHeight);
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case 'C':
+                snprintf(tmp, sizeof(tmp), "%s", guiIntfStruct.sh_video ? ((sh_video_t *)guiIntfStruct.sh_video)->codec->name : "");
+                av_strlcat(trbuf, tmp, sizeof(trbuf));
+                break;
+
+            case 's':
+                if (guiIntfStruct.Playing == 0)
+                    av_strlcat(trbuf, "s", sizeof(trbuf));
+                break;
+
+            case 'l':
+                if (guiIntfStruct.Playing == 1)
+                    av_strlcat(trbuf, "p", sizeof(trbuf));
+                break;
+
+            case 'e':
+                if (guiIntfStruct.Playing == 2)
+                    av_strlcat(trbuf, "e", sizeof(trbuf));
+                break;
+
+            case 'a':
+
+                if (mixer->muted) {
+                    av_strlcat(trbuf, "n", sizeof(trbuf));
+                    break;
+                }
+
+                switch (guiIntfStruct.AudioType) {
+                case 0:
+                    av_strlcat(trbuf, "n", sizeof(trbuf));
+                    break;
+
+                case 1:
+                    av_strlcat(trbuf, "m", sizeof(trbuf));
+                    break;
+
+                case 2:
+                    av_strlcat(trbuf, "t", sizeof(trbuf));
+                    break;
+                }
+
+                break;
+
+            case 'T':
+                switch (guiIntfStruct.StreamType) {
+                case STREAMTYPE_FILE:
+                    av_strlcat(trbuf, "f", sizeof(trbuf));
+                    break;
+
 #ifdef CONFIG_VCD
-             case STREAMTYPE_VCD:    av_strlcat( trbuf,"v",sizeof( trbuf ) ); break;
+                case STREAMTYPE_VCD:
+                    av_strlcat(trbuf, "v", sizeof(trbuf));
+                    break;
 #endif
-             case STREAMTYPE_STREAM: av_strlcat( trbuf,"u",sizeof( trbuf ) ); break;
+
+                case STREAMTYPE_STREAM:
+                    av_strlcat(trbuf, "u", sizeof(trbuf));
+                    break;
+
 #ifdef CONFIG_DVDREAD
-             case STREAMTYPE_DVD:    av_strlcat( trbuf,"d",sizeof( trbuf ) ); break;
+                case STREAMTYPE_DVD:
+                    av_strlcat(trbuf, "d", sizeof(trbuf));
+                    break;
 #endif
-             default:                av_strlcat( trbuf," ",sizeof( trbuf ) ); break;
+
+                default:
+                    av_strlcat(trbuf, " ", sizeof(trbuf));
+                    break;
+                }
+                break;
+
+            case '$':
+                av_strlcat(trbuf, "$", sizeof(trbuf));
+                break;
+
+            default:
+                continue;
             }
-           break;
-       case '$': av_strlcat( trbuf,"$",sizeof( trbuf ) ); break;
-       default: continue;
-      }
-     c=strlen( trbuf );
+
+            c = strlen(trbuf);
+        }
     }
-  }
- return trbuf;
+
+    return trbuf;
 }
 
-void PutImage( txSample * bf,int x,int y,int max,int ofs )
+void PutImage(txSample *bf, int x, int y, int max, int ofs)
 {
- int i=0,ix,iy;
- uint32_t * buf = NULL;
- uint32_t * drw = NULL;
- register uint32_t tmp;
- /* register uint32_t yc; */
+    int i = 0, ix, iy;
+    uint32_t *buf = NULL;
+    uint32_t *drw = NULL;
+    register uint32_t tmp;
 
- if ( ( !bf )||( bf->Image == NULL ) ) return;
+    /* register uint32_t yc; */
 
- i=( bf->Width * ( bf->Height / max ) ) * ofs;
- buf=(uint32_t *)image_buffer;
- drw=(uint32_t *)bf->Image;
+    if (!bf || (bf->Image == NULL))
+        return;
+
+    i   = bf->Width * (bf->Height / max) * ofs;
+    buf = (uint32_t *)image_buffer;
+    drw = (uint32_t *)bf->Image;
 
 #if 1
- for ( iy=y;iy < (int)(y+bf->Height / max);iy++ )
-  for ( ix=x;ix < (int)(x+bf->Width);ix++ )
-   {
-    tmp=drw[i++];
-    if ( tmp != 0x00ff00ff ) buf[iy * image_width + ix]=tmp;
-   }
+    for (iy = y; iy < (int)(y + bf->Height / max); iy++)
+        for (ix = x; ix < (int)(x + bf->Width); ix++) {
+            tmp = drw[i++];
+
+            if (tmp != 0x00ff00ff)
+                buf[iy * image_width + ix] = tmp;
+        }
 #else
- yc=y * image_width;
- for ( iy=y;iy < (int)(y+bf->Height / max);iy++ )
-  {
-   for ( ix=x;ix < (int)(x+bf->Width);ix++ )
-    {
-     tmp=drw[i++];
-     if ( tmp != 0x00ff00ff ) buf[yc + ix]=tmp;
+    yc = y * image_width;
+
+    for (iy = y; iy < (int)(y + bf->Height / max); iy++) {
+        for (ix = x; ix < (int)(x + bf->Width); ix++) {
+            tmp = drw[i++];
+
+            if (tmp != 0x00ff00ff)
+                buf[yc + ix] = tmp;
+        }
+
+        yc += image_width;
     }
-   yc+=image_width;
-  }
 #endif
 }
 
-void SimplePotmeterPutImage( txSample * bf,int x,int y,float frac )
+void SimplePotmeterPutImage(txSample *bf, int x, int y, float frac)
 {
- int i=0,w,r,ix,iy;
- uint32_t * buf = NULL;
- uint32_t * drw = NULL;
- register uint32_t tmp;
+    int i = 0, w, r, ix, iy;
+    uint32_t *buf = NULL;
+    uint32_t *drw = NULL;
+    register uint32_t tmp;
 
- if ( ( !bf )||( bf->Image == NULL ) ) return;
+    if (!bf || (bf->Image == NULL))
+        return;
 
- buf=(uint32_t *)image_buffer;
- drw=(uint32_t *)bf->Image;
- w=bf->Width*frac;
- r=bf->Width-w;
- for ( iy=y;iy < (int)(y+bf->Height);iy++ )
- {
-  for ( ix=x;ix < (int)(x+w);ix++ )
-   {
-    tmp=drw[i++];
-    if ( tmp != 0x00ff00ff ) buf[iy * image_width + ix]=tmp;
-   }
-  i+=r;
- }
+    buf = (uint32_t *)image_buffer;
+    drw = (uint32_t *)bf->Image;
+    w   = bf->Width * frac;
+    r   = bf->Width - w;
+
+    for (iy = y; iy < (int)(y + bf->Height); iy++) {
+        for (ix = x; ix < (int)(x + w); ix++) {
+            tmp = drw[i++];
+
+            if (tmp != 0x00ff00ff)
+                buf[iy * image_width + ix] = tmp;
+        }
+
+        i += r;
+    }
 }
 
-void Render( wsTWindow * window,wItem * Items,int nrItems,char * db,int size )
+void Render(wsTWindow *window, wItem *Items, int nrItems, char *db, int size)
 {
- wItem    * item;
- txSample * image = NULL;
- int        i, ofs;
+    wItem *item;
+    txSample *image = NULL;
+    int i, ofs;
 
- image_buffer=db;
- image_width=window->Width;
+    image_buffer = db;
+    image_width  = window->Width;
 
- for( i=0;i < nrItems + 1;i++ )
-  {
-   item=&Items[i];
-   ofs = (item->pressed == btnPressed ? 0 : (item->pressed == btnReleased ? 1 : 2));
-   switch( item->type )
-    {
-     case itButton:
-          PutImage( &item->Bitmap,item->x,item->y,3,ofs );
-          break;
-     case itPotmeter:
-          if (item->numphases == 1)SimplePotmeterPutImage( &item->Bitmap,item->x,item->y, item->value / 100.0f );
-          else PutImage( &item->Bitmap,item->x,item->y,item->numphases,( item->numphases - 1 ) * ( item->value / 100.0f ) );
-          break;
-     case itHPotmeter:
-          if (item->numphases == 1)SimplePotmeterPutImage( &item->Bitmap,item->x,item->y, item->value / 100.0f );
-          else PutImage( &item->Bitmap,item->x,item->y,item->numphases,( item->numphases - 1 ) * ( item->value / 100.0f ) );
-          PutImage( &item->Mask,item->x + (int)( ( item->width - item->pwidth ) * item->value / 100.0f ),item->y,3,ofs );
-          break;
-     case itVPotmeter:
-          PutImage( &item->Bitmap,
-	    item->x,item->y,
-	    item->numphases,
-	    item->numphases * ( 1.0f - item->value / 100.0f ) );
-          PutImage( &item->Mask,
-	    item->x,item->y + (int)( ( item->height - item->pheight ) * ( 1.0f - item->value / 100.0f ) ),
-	    3,ofs );
-          break;
-     case itSLabel:
-          image=fntRender( item,0,item->label );
-          if ( image ) PutImage( image,item->x,item->y,1,0 );
-     case itDLabel:
-          {
-           int x;
-           unsigned int d;
-           char * t = Translate( item->label );
-           if ( !item->text || ( strcmp( item->text, t ) != 0 ) )
-            {
-             free( item->text );
-             item->text = strdup( t );
-             item->textwidth = fntTextWidth( item->fontid, t );
-             item->starttime = GetTimerMS();
-             item->last_x = 0;
+    for (i = 0; i < nrItems + 1; i++) {
+        item = &Items[i];
+        ofs  = (item->pressed == btnPressed ? 0 : (item->pressed == btnReleased ? 1 : 2));
+
+        switch (item->type) {
+        case itButton:
+            PutImage(&item->Bitmap, item->x, item->y, 3, ofs);
+            break;
+
+        case itPotmeter:
+            if (item->numphases == 1)
+                SimplePotmeterPutImage(&item->Bitmap, item->x, item->y, item->value / 100.0f);
+            else
+                PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0f));
+            break;
+
+        case itHPotmeter:
+            if (item->numphases == 1)
+                SimplePotmeterPutImage(&item->Bitmap, item->x, item->y, item->value / 100.0f);
+            else
+                PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0f));
+            PutImage(&item->Mask, item->x + (int)((item->width - item->pwidth) * (item->value / 100.0f)), item->y, 3, ofs);
+            break;
+
+        case itVPotmeter:
+            PutImage(&item->Bitmap, item->x, item->y, item->numphases, item->numphases * (1.0f - item->value / 100.0f));
+            PutImage(&item->Mask, item->x, item->y + (int)((item->height - item->pheight) * (1.0f - item->value / 100.0f)), 3, ofs);
+            break;
+
+        case itSLabel:
+            image = fntRender(item, 0, item->label);
+            if (image)
+                PutImage(image, item->x, item->y, 1, 0);
+
+        case itDLabel:
+        {
+            int x;
+            unsigned int d;
+            char *t = Translate(item->label);
+
+            if (!item->text || (strcmp(item->text, t) != 0)) {
+                free(item->text);
+                item->text      = strdup(t);
+                item->textwidth = fntTextWidth(item->fontid, t);
+                item->starttime = GetTimerMS();
+                item->last_x    = 0;
             }
-           d = GetTimerMS() - item->starttime;
-           if ( d < DELAYTIME ) x = item->last_x;   // don't scroll yet
-           else
-            {
-             int l;
-             char c[2];
-             l = (item->textwidth ? item->textwidth : item->width);
-             x = l - ((d - DELAYTIME) / 20) % l - 1;
-             c[0] = *item->text;
-             c[1] = '\0';
-             if ( x < (fntTextWidth( item->fontid, c ) + 1) >> 1)
-              {
-               item->starttime = GetTimerMS();   // stop again
-               item->last_x = x;                 // at current x pos
-              }
+
+            d = GetTimerMS() - item->starttime;
+
+            if (d < DELAYTIME)
+                x = item->last_x;                     // don't scroll yet
+            else {
+                int l;
+                char c[2];
+
+                l    = (item->textwidth ? item->textwidth : item->width);
+                x    = l - ((d - DELAYTIME) / 20) % l - 1;
+                c[0] = *item->text;
+                c[1] = '\0';
+
+                if (x < (fntTextWidth(item->fontid, c) + 1) >> 1) {
+                    item->starttime = GetTimerMS();   // stop again
+                    item->last_x    = x;              // at current x pos
+                }
             }
-           image = fntRender( item, x, t );
-	  }
-          if ( image ) PutImage( image,item->x,item->y,1,0 );
-          break;
+
+            image = fntRender(item, x, t);
+        }
+
+            if (image)
+                PutImage(image, item->x, item->y, 1, 0);
+
+            break;
+        }
     }
-  }
- wsConvert( window,db,size );
+
+    wsConvert(window, db, size);
 }

Modified: trunk/gui/mplayer/gui_common.h
==============================================================================
--- trunk/gui/mplayer/gui_common.h	Tue Mar  8 13:12:37 2011	(r33049)
+++ trunk/gui/mplayer/gui_common.h	Tue Mar  8 13:29:44 2011	(r33050)
@@ -23,9 +23,9 @@
 
 #define DELAYTIME 2500   // in milliseconds
 
-char * Translate( char * str );
-void PutImage( txSample * bf,int x, int y, int max, int ofs );
-void SimplePotmeterPutImage( txSample * bf, int x, int y, float frac );
-void Render( wsTWindow * window, wItem * Items, int nrItems, char * db, int size );
+void PutImage(txSample *bf, int x, int y, int max, int ofs);
+void Render(wsTWindow *window, wItem *Items, int nrItems, char *db, int size);
+void SimplePotmeterPutImage(txSample *bf, int x, int y, float frac);
+char *Translate(char *str);
 
 #endif /* MPLAYER_GUI_GUI_COMMON_H */


More information about the MPlayer-cvslog mailing list