[MPlayer-cvslog] r32848 - in trunk/gui: app.c app.h mplayer/gui_common.c mplayer/gui_common.h
ib
subversion at mplayerhq.hu
Thu Feb 3 15:44:46 CET 2011
Author: ib
Date: Thu Feb 3 15:44:46 2011
New Revision: 32848
Log:
Improve the readability of dynamic labels which scroll.
If the text of a dynamic label to be displayed is wider than the given
length, it will be scrolled. Currently such a label starts scrolling
immediately after it is placed and - even more unpleasant - the start of the
text is randomly somewhere within the specified space of the label. Both
makes it hard to track and to read.
Now such a dynamic label starts left-aligned and begins scrolling through the
specified space only after a short delay (2.5 seconds). Every time the start
of the text nears the left margin again during the scrolling process it will
stop and everything starts all over again, i.e. scrolling after a short
delay.
Modified:
trunk/gui/app.c
trunk/gui/app.h
trunk/gui/mplayer/gui_common.c
trunk/gui/mplayer/gui_common.h
Modified: trunk/gui/app.c
==============================================================================
--- trunk/gui/app.c Thu Feb 3 15:26:58 2011 (r32847)
+++ trunk/gui/app.c Thu Feb 3 15:44:46 2011 (r32848)
@@ -114,6 +114,11 @@ void appClearItem( wItem * item )
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;
}
Modified: trunk/gui/app.h
==============================================================================
--- trunk/gui/app.h Thu Feb 3 15:26:58 2011 (r32847)
+++ trunk/gui/app.h Thu Feb 3 15:44:46 2011 (r32848)
@@ -148,6 +148,10 @@ typedef struct
int fontid;
int align;
char * label;
+ char * text;
+ int textwidth;
+ unsigned int starttime;
+ int last_x;
// ---
int event;
// ---
Modified: trunk/gui/mplayer/gui_common.c
==============================================================================
--- trunk/gui/mplayer/gui_common.c Thu Feb 3 15:26:58 2011 (r32847)
+++ trunk/gui/mplayer/gui_common.c Thu Feb 3 15:44:46 2011 (r32848)
@@ -298,10 +298,34 @@ void Render( wsTWindow * window,wItem *
if ( image ) PutImage( image,item->x,item->y,1,0 );
case itDLabel:
{
+ int x;
+ unsigned int d;
char * t = Translate( item->label );
- int l = fntTextWidth( item->fontid,t );
- l=(l?l:item->width);
- image=fntRender( item,l-(GetTimerMS() / 20)%l,t );
+ if ( g_strcmp0( item->text, t ) != 0 )
+ {
+ g_free( item->text );
+ item->text = g_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
+ }
+ }
+ image = fntRender( item, x, t );
}
if ( image ) PutImage( image,item->x,item->y,1,0 );
break;
Modified: trunk/gui/mplayer/gui_common.h
==============================================================================
--- trunk/gui/mplayer/gui_common.h Thu Feb 3 15:26:58 2011 (r32847)
+++ trunk/gui/mplayer/gui_common.h Thu Feb 3 15:44:46 2011 (r32848)
@@ -29,6 +29,8 @@
#include "gui/bitmap.h"
#include "gui/wm/ws.h"
+#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 );
More information about the MPlayer-cvslog
mailing list