]> git.webhop.me Git - lcd4linux.git/commitdiff
automatic marquee patch from Manuel Grot
authormichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 3 Oct 2007 05:12:11 +0000 (05:12 +0000)
committermichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 3 Oct 2007 05:12:11 +0000 (05:12 +0000)
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@845 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

widget_text.c
widget_text.h

index 5f3c2c9c9a3fe01f6763982e9959ecaa503d187a..2bbb7aeeb50eb240f6905af752c6c983d8b3048b 100644 (file)
@@ -85,6 +85,11 @@ void widget_text_scroll(void *Self)
        if (pad < 0)
            pad = 0;
        break;
+    case ALIGN_AUTOMATIC:
+       if (len <= width) {
+           pad = 0;
+           break;
+       }
     case ALIGN_MARQUEE:
        pad = width - T->scroll;
        T->scroll++;
@@ -219,7 +224,7 @@ void widget_text_update(void *Self)
        /* if there's a marquee scroller active, it has its own */
        /* update callback timer, so we do nothing here; otherwise */
        /* we simply call this scroll callback directly */
-       if (T->align != ALIGN_MARQUEE) {
+       if (T->align != ALIGN_MARQUEE || T->align != ALIGN_AUTOMATIC) {
            widget_text_scroll(Self);
        }
     }
@@ -279,6 +284,9 @@ int widget_text_init(WIDGET * Self)
     case 'M':
        Text->align = ALIGN_MARQUEE;
        break;
+    case 'A':
+       Text->align = ALIGN_AUTOMATIC;
+       break;
     default:
        error("widget %s has unknown alignment '%s', using 'Left'", section, c);
        Text->align = ALIGN_LEFT;
@@ -292,7 +300,7 @@ int widget_text_init(WIDGET * Self)
        Text->update = 10;
 
     /* marquee scroller speed: interval (msec), default 500msec */
-    if (Text->align == ALIGN_MARQUEE) {
+    if (Text->align == ALIGN_MARQUEE || Text->align == ALIGN_AUTOMATIC) {
        cfg_number(section, "speed", 500, 10, -1, &(Text->speed));
     }
 
@@ -306,7 +314,7 @@ int widget_text_init(WIDGET * Self)
     timer_add(widget_text_update, Self, Text->update, Text->update == 0);
 
     /* a marquee scroller has its own timer and callback */
-    if (Text->align == ALIGN_MARQUEE) {
+    if (Text->align == ALIGN_MARQUEE || Text->align == ALIGN_AUTOMATIC) {
        timer_add(widget_text_scroll, Self, Text->speed, 0);
     }
 
index 17dd9d46d5b37761de8094f3e3d249a8d52ca5e2..b3bd0a661c99b45f7eb415b123c3fadfbb1f6451 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "property.h"
 
-typedef enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_MARQUEE } TEXT_ALIGN;
+typedef enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_MARQUEE, ALIGN_AUTOMATIC } TEXT_ALIGN;
 
 typedef struct WIDGET_TEXT {
     PROPERTY prefix;           /* label on the left side */
@@ -41,7 +41,7 @@ typedef struct WIDGET_TEXT {
     char *buffer;              /* string with 'width+1' bytes allocated  */
     int width;                 /* field width */
     int precision;             /* number of digits after the decimal point */
-    TEXT_ALIGN align;          /* alignment: L(eft), C(enter), R(ight), M(arquee) */
+    TEXT_ALIGN align;          /* alignment: L(eft), C(enter), R(ight), M(arquee), A(utomatic) */
     int update;                        /* update interval */
     int scroll;                        /* marquee starting point */
     int speed;                 /* marquee scrolling speed */