Changeset 849
- Timestamp:
- 01/28/08 18:03:27 (10 months ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
widget_text.c (modified) (6 diffs)
-
widget_text.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/widget_text.c
r845 r849 6 6 * Copyright (C) 2003, 2004 Michael Reinelt <michael@reinelt.co.at> 7 7 * Copyright (C) 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net> 8 * Copyright (C) 2008 Michael Vogt <michu@neophob.com> 8 9 * 9 10 * This program is free software; you can redistribute it and/or modify … … 96 97 if (T->scroll >= width + len) 97 98 T->scroll = 0; 99 break; 100 case ALIGN_PINGPONG: 101 #define PINGPONGWAIT 2 102 103 /* scrolling is not necessary - center the string */ 104 if (len <= width) { 105 pad = (width - len) / 2; 106 } 107 else { 108 if (T->direction == 1) 109 T->scroll++; /* scroll right */ 110 else 111 T->scroll--; /* scroll left */ 112 113 /*pad = if positive, add leading space characters, else offset of string begin */ 114 pad = 0-T->scroll; 115 116 if (pad < 0-(len-width)) { 117 if (T->delay-- < 1) { /* wait before switch direction */ 118 T->direction = 0; /* change scroll direction */ 119 T->delay = PINGPONGWAIT; 120 T->scroll -= PINGPONGWAIT; 121 } /* else debug("wait1"); */ 122 pad = 0-(len-width); 123 } 124 else 125 if (pad > 0) { 126 if (T->delay-- < 1) { 127 T->direction = 1; 128 T->delay = PINGPONGWAIT; 129 T->scroll += PINGPONGWAIT; 130 } /* else debug("wait2"); */ 131 pad = 0; 132 } 133 134 } 98 135 break; 99 136 default: /* not reached */ … … 220 257 /* something has changed and should be updated */ 221 258 if (update) { 222 /* reset marquee counter if content has changed */ 259 /* reset marquee counter if content has changed */ 223 260 T->scroll = 0; 261 262 /* Init pingpong scroller. start scrolling left (wrong way) to get a delay */ 263 if (T->align == ALIGN_PINGPONG) { 264 T->direction = 0; 265 T->delay = PINGPONGWAIT; 266 } 224 267 /* if there's a marquee scroller active, it has its own */ 225 268 /* update callback timer, so we do nothing here; otherwise */ 226 269 /* we simply call this scroll callback directly */ 227 if (T->align != ALIGN_MARQUEE || T->align != ALIGN_AUTOMATIC ) {270 if (T->align != ALIGN_MARQUEE || T->align != ALIGN_AUTOMATIC || T->align != ALIGN_PINGPONG) { 228 271 widget_text_scroll(Self); 229 272 } … … 288 331 Text->align = ALIGN_AUTOMATIC; 289 332 break; 333 case 'P': 334 Text->align = ALIGN_PINGPONG; 335 break; 290 336 default: 291 337 error("widget %s has unknown alignment '%s', using 'Left'", section, c); … … 301 347 302 348 /* marquee scroller speed: interval (msec), default 500msec */ 303 if (Text->align == ALIGN_MARQUEE || Text->align == ALIGN_AUTOMATIC ) {349 if (Text->align == ALIGN_MARQUEE || Text->align == ALIGN_AUTOMATIC || Text->align == ALIGN_PINGPONG) { 304 350 cfg_number(section, "speed", 500, 10, -1, &(Text->speed)); 305 351 } … … 315 361 316 362 /* a marquee scroller has its own timer and callback */ 317 if (Text->align == ALIGN_MARQUEE || Text->align == ALIGN_AUTOMATIC ) {363 if (Text->align == ALIGN_MARQUEE || Text->align == ALIGN_AUTOMATIC || Text->align == ALIGN_PINGPONG) { 318 364 timer_add(widget_text_scroll, Self, Text->speed, 0); 319 365 } -
trunk/widget_text.h
r845 r849 31 31 #include "property.h" 32 32 33 typedef enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_MARQUEE, ALIGN_AUTOMATIC } TEXT_ALIGN;33 typedef enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_MARQUEE, ALIGN_AUTOMATIC, ALIGN_PINGPONG } TEXT_ALIGN; 34 34 35 35 typedef struct WIDGET_TEXT { … … 46 46 int scroll; /* marquee starting point */ 47 47 int speed; /* marquee scrolling speed */ 48 int direction; /* pingpong direction, 0=right, 1=left */ 49 int delay; /* pingpong scrolling, wait before switch direction */ 48 50 } WIDGET_TEXT; 49 51
