comparison gui/mplayer/gui_common.c @ 32761:3ceeb62a1125

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.
author ib
date Thu, 03 Feb 2011 14:44:46 +0000
parents 63844ef43932
children e06fbdd8eb46
comparison
equal deleted inserted replaced
32760:6b394b24f81c 32761:3ceeb62a1125
296 case itSLabel: 296 case itSLabel:
297 image=fntRender( item,0,item->label ); 297 image=fntRender( item,0,item->label );
298 if ( image ) PutImage( image,item->x,item->y,1,0 ); 298 if ( image ) PutImage( image,item->x,item->y,1,0 );
299 case itDLabel: 299 case itDLabel:
300 { 300 {
301 int x;
302 unsigned int d;
301 char * t = Translate( item->label ); 303 char * t = Translate( item->label );
302 int l = fntTextWidth( item->fontid,t ); 304 if ( g_strcmp0( item->text, t ) != 0 )
303 l=(l?l:item->width); 305 {
304 image=fntRender( item,l-(GetTimerMS() / 20)%l,t ); 306 g_free( item->text );
307 item->text = g_strdup( t );
308 item->textwidth = fntTextWidth( item->fontid, t );
309 item->starttime = GetTimerMS();
310 item->last_x = 0;
311 }
312 d = GetTimerMS() - item->starttime;
313 if ( d < DELAYTIME ) x = item->last_x; // don't scroll yet
314 else
315 {
316 int l;
317 char c[2];
318 l = (item->textwidth ? item->textwidth : item->width);
319 x = l - ((d - DELAYTIME) / 20) % l - 1;
320 c[0] = *item->text;
321 c[1] = '\0';
322 if ( x < (fntTextWidth( item->fontid, c ) + 1) >> 1)
323 {
324 item->starttime = GetTimerMS(); // stop again
325 item->last_x = x; // at current x pos
326 }
327 }
328 image = fntRender( item, x, t );
305 } 329 }
306 if ( image ) PutImage( image,item->x,item->y,1,0 ); 330 if ( image ) PutImage( image,item->x,item->y,1,0 );
307 break; 331 break;
308 } 332 }
309 } 333 }