if (pad < 0)
pad = 0;
break;
+ case ALIGN_AUTOMATIC:
+ if (len <= width) {
+ pad = 0;
+ break;
+ }
case ALIGN_MARQUEE:
pad = width - T->scroll;
T->scroll++;
/* 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);
}
}
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;
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));
}
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);
}
#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 */
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 */