aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drv_generic_graphic.c12
-rw-r--r--drv_generic_text.c8
-rw-r--r--widget_icon.c50
-rw-r--r--widget_icon.h13
4 files changed, 32 insertions, 51 deletions
diff --git a/drv_generic_graphic.c b/drv_generic_graphic.c
index 9cbb11f..037d878 100644
--- a/drv_generic_graphic.c
+++ b/drv_generic_graphic.c
@@ -343,7 +343,8 @@ int drv_generic_graphic_icon_draw(WIDGET * W)
unsigned char *bitmap = Icon->bitmap + YRES * Icon->curmap;
int layer, row, col;
int x, y;
-
+ int visible;
+
layer = W->layer;
row = YRES * W->row;
col = XRES * W->col;
@@ -360,13 +361,16 @@ int drv_generic_graphic_icon_draw(WIDGET * W)
/* maybe grow layout framebuffer */
drv_generic_graphic_resizeFB(row + YRES, col + XRES);
+ /* Icon visible? */
+ visible = P2N(&Icon->visible) > 0;
+
/* render icon */
for (y = 0; y < YRES; y++) {
int mask = 1 << XRES;
for (x = 0; x < XRES; x++) {
int i = (row + y) * LCOLS + col + x;
mask >>= 1;
- if (Icon->visible) {
+ if (visible) {
if (bitmap[y] & mask)
drv_generic_graphic_FB[layer][i] = fg;
else
@@ -376,10 +380,10 @@ int drv_generic_graphic_icon_draw(WIDGET * W)
}
}
}
-
+
/* flush area */
drv_generic_graphic_blit(row, col, YRES, XRES);
-
+
return 0;
}
diff --git a/drv_generic_text.c b/drv_generic_text.c
index 52986c0..430137e 100644
--- a/drv_generic_text.c
+++ b/drv_generic_text.c
@@ -449,6 +449,7 @@ int drv_generic_text_icon_draw(WIDGET * W)
static int icon_counter = 0;
WIDGET_ICON *Icon = W->data;
int row, col;
+ int visible;
int invalidate = 0;
unsigned char ascii;
@@ -473,8 +474,11 @@ int drv_generic_text_icon_draw(WIDGET * W)
Icon->ascii = CHAR0 + CHARS - icon_counter;
}
+ /* Icon visible? */
+ visible = P2N(&Icon->visible) > 0;
+
/* maybe redefine icon */
- if (Icon->curmap != Icon->prvmap && Icon->visible) {
+ if (Icon->curmap != Icon->prvmap && visible) {
Icon->prvmap = Icon->curmap;
if (drv_generic_text_real_defchar)
drv_generic_text_real_defchar(Icon->ascii, Icon->bitmap + YRES * Icon->curmap);
@@ -482,7 +486,7 @@ int drv_generic_text_icon_draw(WIDGET * W)
}
/* use blank if invisible */
- ascii = Icon->visible ? Icon->ascii : ' ';
+ ascii = visible ? Icon->ascii : ' ';
/* transfer icon into layout buffer */
LayoutFB[row * LCOLS + col] = ascii;
diff --git a/widget_icon.c b/widget_icon.c
index a11ad33..1f751f7 100644
--- a/widget_icon.c
+++ b/widget_icon.c
@@ -41,7 +41,7 @@
#include "debug.h"
#include "cfg.h"
#include "qprintf.h"
-#include "evaluator.h"
+#include "property.h"
#include "timer.h"
#include "widget.h"
#include "widget_icon.h"
@@ -94,31 +94,13 @@ void widget_icon_update(void *Self)
{
WIDGET *W = (WIDGET *) Self;
WIDGET_ICON *Icon = W->data;
- RESULT result = { 0, 0, 0, NULL };
/* process the parent only */
if (W->parent == NULL) {
- /* evaluate expressions */
- Icon->speed = 100;
- if (Icon->speed_tree != NULL) {
- Eval(Icon->speed_tree, &result);
- Icon->speed = R2N(&result);
- if (Icon->speed <= 0)
- Icon->speed = 0;
- else if (Icon->speed < 10)
- Icon->speed = 10;
- DelResult(&result);
- }
-
- Icon->visible = 1;
- if (Icon->visible_tree != NULL) {
- Eval(Icon->visible_tree, &result);
- Icon->visible = R2N(&result);
- if (Icon->visible < 0)
- Icon->visible = 0;
- DelResult(&result);
- }
+ /* evaluate properties */
+ property_eval(&Icon->speed);
+ property_eval(&Icon->visible);
/* rotate icon bitmap */
Icon->curmap++;
@@ -131,8 +113,8 @@ void widget_icon_update(void *Self)
W->class->draw(W);
/* add a new one-shot timer */
- if (Icon->speed > 0) {
- timer_add(widget_icon_update, Self, Icon->speed, 1);
+ if (P2N(&Icon->speed) > 0) {
+ timer_add(widget_icon_update, Self, P2N(&Icon->speed), 1);
}
}
@@ -155,19 +137,9 @@ int widget_icon_init(WIDGET * Self)
Icon = malloc(sizeof(WIDGET_ICON));
memset(Icon, 0, sizeof(WIDGET_ICON));
- /* get raw expressions (we evaluate them ourselves) */
- Icon->speed_expr = cfg_get_raw(section, "speed", NULL);
- Icon->visible_expr = cfg_get_raw(section, "visible", NULL);
-
- /* sanity check */
- if (Icon->speed_expr == NULL || *Icon->speed_expr == '\0') {
- error("Icon %s has no speed, using '100'", Self->name);
- Icon->speed_expr = "100";
- }
-
- /* compile'em */
- Compile(Icon->speed_expr, &Icon->speed_tree);
- Compile(Icon->visible_expr, &Icon->visible_tree);
+ /* load properties */
+ property_load(section, "speed", "100", &Icon->speed);
+ property_load(section, "visible", "1", &Icon->visible);
/* read bitmap */
widget_icon_read_bitmap(section, Icon);
@@ -204,8 +176,8 @@ int widget_icon_quit(WIDGET * Self)
if (Self->parent == NULL) {
if (Self->data) {
WIDGET_ICON *Icon = Self->data;
- DelTree(Icon->speed_tree);
- DelTree(Icon->visible_tree);
+ property_free(&Icon->speed);
+ property_free(&Icon->visible);
if (Icon->bitmap)
free(Icon->bitmap);
free(Self->data);
diff --git a/widget_icon.h b/widget_icon.h
index 66e7c53..77154f5 100644
--- a/widget_icon.h
+++ b/widget_icon.h
@@ -28,13 +28,13 @@
#ifndef _WIDGET_ICON_H_
#define _WIDGET_ICON_H_
+
+#include "property.h"
+
+
typedef struct WIDGET_ICON {
- char *speed_expr; /* expression for update interval */
- void *speed_tree; /* pre-compiled expression for update interval */
- int speed; /* update interval (msec) */
- char *visible_expr; /* expression for visibility */
- void *visible_tree; /* pre-compiled expression for visibility */
- int visible; /* icon visible? */
+ PROPERTY speed; /* update interval (msec) */
+ PROPERTY visible; /* icon visible? */
int ascii; /* ascii code of icon (depends on the driver) */
int curmap; /* current bitmap sequence */
int prvmap; /* previous bitmap sequence */
@@ -42,6 +42,7 @@ typedef struct WIDGET_ICON {
unsigned char *bitmap; /* bitmaps of (animated) icon */
} WIDGET_ICON;
+
extern WIDGET_CLASS Widget_Icon;
#endif