summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/eve/widget
diff options
context:
space:
mode:
Diffstat (limited to 'fw/fe310/eos/eve/widget')
-rw-r--r--fw/fe310/eos/eve/widget/freew.c17
-rw-r--r--fw/fe310/eos/eve/widget/freew.h3
-rw-r--r--fw/fe310/eos/eve/widget/pagew.c1
-rw-r--r--fw/fe310/eos/eve/widget/selectw.c4
-rw-r--r--fw/fe310/eos/eve/widget/strw.c7
-rw-r--r--fw/fe310/eos/eve/widget/textw.c11
-rw-r--r--fw/fe310/eos/eve/widget/togglew.c18
-rw-r--r--fw/fe310/eos/eve/widget/togglew.h7
-rw-r--r--fw/fe310/eos/eve/widget/widget.c4
-rw-r--r--fw/fe310/eos/eve/widget/widget.h9
10 files changed, 54 insertions, 27 deletions
diff --git a/fw/fe310/eos/eve/widget/freew.c b/fw/fe310/eos/eve/widget/freew.c
index e7591da..11b8e50 100644
--- a/fw/fe310/eos/eve/widget/freew.c
+++ b/fw/fe310/eos/eve/widget/freew.c
@@ -33,7 +33,9 @@ uint8_t eve_freew_draw(EVEWidget *_widget, uint8_t tag0) {
_widget->tag0 = tag0;
_widget->tagN = tag0;
+ eve_cmd_dl(SAVE_CONTEXT());
widget->_draw(widget);
+ eve_cmd_dl(RESTORE_CONTEXT());
return _widget->tagN;
}
@@ -43,15 +45,24 @@ int eve_freew_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
int ret;
ret = widget->_touch(widget, touch, evt);
- if (ret) eve_widget_set_focus(_widget, NULL);
return ret;
}
-void eve_freew_tag(EVEFreeWidget *widget) {
+uint8_t eve_freew_tag(EVEFreeWidget *widget) {
EVEWidget *_widget = &widget->w;
+ uint8_t ret = EVE_NOTAG;
if (_widget->tagN != EVE_NOTAG) {
- eve_cmd_dl(TAG(_widget->tagN));
+ ret = _widget->tagN;
+ eve_cmd_dl(TAG(ret));
_widget->tagN++;
}
+
+ return ret;
}
+
+uint8_t eve_widget_tag_index(EVEFreeWidget *widget, uint8_t tag) {
+ EVEWidget *_widget = &widget->w;
+
+ return tag - _widget->tag0;
+} \ No newline at end of file
diff --git a/fw/fe310/eos/eve/widget/freew.h b/fw/fe310/eos/eve/widget/freew.h
index 324e98d..cbcd08b 100644
--- a/fw/fe310/eos/eve/widget/freew.h
+++ b/fw/fe310/eos/eve/widget/freew.h
@@ -24,4 +24,5 @@ int eve_freew_create(EVEWidget *_widget, struct EVEWidgetSpec *spec, EVEPage *pa
uint8_t eve_freew_draw(EVEWidget *_widget, uint8_t tag0);
int eve_freew_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt);
-void eve_freew_tag(EVEFreeWidget *widget);
+uint8_t eve_freew_tag(EVEFreeWidget *widget);
+uint8_t eve_widget_tag_index(EVEFreeWidget *widget, uint8_t tag); \ No newline at end of file
diff --git a/fw/fe310/eos/eve/widget/pagew.c b/fw/fe310/eos/eve/widget/pagew.c
index c926892..77e8f01 100644
--- a/fw/fe310/eos/eve/widget/pagew.c
+++ b/fw/fe310/eos/eve/widget/pagew.c
@@ -51,7 +51,6 @@ int eve_pagew_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
EVEPageWidget *widget = (EVEPageWidget *)_widget;
if (evt & EVE_TOUCH_ETYPE_TAG_UP) {
- eve_widget_set_focus(_widget, NULL);
eve_page_open(parent, widget->constructor);
return 1;
}
diff --git a/fw/fe310/eos/eve/widget/selectw.c b/fw/fe310/eos/eve/widget/selectw.c
index 5acf998..f5bb6e0 100644
--- a/fw/fe310/eos/eve/widget/selectw.c
+++ b/fw/fe310/eos/eve/widget/selectw.c
@@ -180,7 +180,6 @@ int eve_selectw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
}
}
- eve_widget_set_focus(_widget, NULL);
return 1;
}
@@ -206,7 +205,8 @@ utf8_t *eve_selectw_option(EVESelectWidget *widget, int idx) {
}
utf8_t *eve_selectw_option_selected(EVESelectWidget *widget) {
- return eve_selectw_option(widget, widget->select);
+ if (widget->select != SELECTW_NOSELECT) return eve_selectw_option(widget, widget->select);
+ return NULL;
}
int eve_selectw_add_option(EVESelectWidget *widget, utf8_t *option) {
diff --git a/fw/fe310/eos/eve/widget/strw.c b/fw/fe310/eos/eve/widget/strw.c
index ae9ccab..6bddbe9 100644
--- a/fw/fe310/eos/eve/widget/strw.c
+++ b/fw/fe310/eos/eve/widget/strw.c
@@ -81,7 +81,7 @@ void eve_strw_destroy(EVEWidget *_widget) {
eve_free(widget->str);
}
-static void set_focus(EVEStrWidget *widget) {
+static void show_rect(EVEStrWidget *widget) {
EVEWidget *_widget = &widget->w;
EVERect focus;
@@ -89,7 +89,7 @@ static void set_focus(EVEStrWidget *widget) {
focus.y = _widget->g.y;
focus.w = _widget->g.w;
focus.h = 2 * widget->font->h;
- eve_widget_set_focus(_widget, &focus);
+ eve_page_show_rect(_widget->page, &focus);
}
static EVEStrCursor *cursor_prox(EVEStrWidget *widget, EVEStrCursor *cursor, EVETouch *touch, short *dx) {
@@ -282,7 +282,7 @@ int eve_strw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && !(touch->eevt & (EVE_TOUCH_EETYPE_TRACK_XY | EVE_TOUCH_EETYPE_ABORT | EVE_TOUCH_EETYPE_LPRESS))) {
eve_strw_cursor_set(widget, &widget->cursor1, eve_page_x(page, touch->x0));
if (widget->cursor2.on) eve_strw_cursor_clear(widget, &widget->cursor2);
- set_focus(widget);
+ show_rect(widget);
ret = 1;
}
}
@@ -293,7 +293,6 @@ int eve_strw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
widget->track.dx = 0;
}
- if (ret) eve_widget_set_focus(_widget, NULL);
return ret;
}
diff --git a/fw/fe310/eos/eve/widget/textw.c b/fw/fe310/eos/eve/widget/textw.c
index 70a1e06..a4114ee 100644
--- a/fw/fe310/eos/eve/widget/textw.c
+++ b/fw/fe310/eos/eve/widget/textw.c
@@ -81,7 +81,7 @@ void eve_textw_destroy(EVEWidget *_widget) {
eve_free(widget->text);
}
-static void set_focus(EVETextWidget *widget, EVETextCursor *cursor) {
+static void show_rect(EVETextWidget *widget, EVETextCursor *cursor) {
EVEWidget *_widget = &widget->w;
EVERect focus;
@@ -89,7 +89,7 @@ static void set_focus(EVETextWidget *widget, EVETextCursor *cursor) {
focus.y = _widget->g.y + cursor->line * widget->font->h;
focus.w = _widget->g.w;
focus.h = 2 * widget->font->h;
- eve_widget_set_focus(_widget, &focus);
+ eve_page_show_rect(_widget->page, &focus);
}
static EVETextCursor *cursor_prox(EVETextWidget *widget, EVETextCursor *cursor, EVETouch *touch, short *dx, short *dl) {
@@ -280,7 +280,7 @@ int eve_textw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && !(touch->eevt & (EVE_TOUCH_EETYPE_TRACK_XY | EVE_TOUCH_EETYPE_ABORT | EVE_TOUCH_EETYPE_LPRESS))) {
eve_textw_cursor_set(widget, &widget->cursor1, touch->tag_up, eve_page_x(page, touch->x0));
if (widget->cursor2.on) eve_textw_cursor_clear(widget, &widget->cursor2);
- set_focus(widget, &widget->cursor1);
+ show_rect(widget, &widget->cursor1);
ret = 1;
}
}
@@ -291,7 +291,6 @@ int eve_textw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
widget->track.dl = 0;
}
- if (ret) eve_widget_set_focus(_widget, NULL);
return ret;
}
@@ -405,11 +404,11 @@ void eve_textw_putc(void *w, int c) {
if (cursor1->line && (cursor1->ch < LINE_START(widget, cursor1->line))) {
cursor1->line--;
eve_textw_cursor_update(widget, cursor1);
- set_focus(widget, cursor1);
+ show_rect(widget, cursor1);
} else if (cursor1->ch > LINE_END(widget, cursor1->line)) {
while (cursor1->ch > LINE_END(widget, cursor1->line)) cursor1->line++;
eve_textw_cursor_update(widget, cursor1);
- set_focus(widget, cursor1);
+ show_rect(widget, cursor1);
} else {
cursor1->x += ch_w;
}
diff --git a/fw/fe310/eos/eve/widget/togglew.c b/fw/fe310/eos/eve/widget/togglew.c
index fbebacb..c68e191 100644
--- a/fw/fe310/eos/eve/widget/togglew.c
+++ b/fw/fe310/eos/eve/widget/togglew.c
@@ -13,11 +13,10 @@
void eve_togglew_init(EVEToggleWidget *widget, EVERect *g, EVEPage *page, EVEFont *font, char *labels) {
EVEWidget *_widget = &widget->w;
- memset(widget, 0, sizeof(EVEPageWidget));
+ memset(widget, 0, sizeof(EVEToggleWidget));
eve_widget_init(_widget, EVE_WIDGET_TYPE_TOGGLE, g, page, eve_togglew_draw, eve_togglew_touch, NULL);
widget->font = font;
widget->labels = labels;
- if (_widget->g.w == 0) _widget->g.w = 3 * eve_font_h(widget->font);
if (_widget->g.h == 0) _widget->g.h = eve_font_h(widget->font);
}
@@ -41,8 +40,7 @@ uint8_t eve_togglew_draw(EVEWidget *_widget, uint8_t tag0) {
}
_widget->tagN = tag0;
- eve_cmd(CMD_TOGGLE, "hhhhhhs", _widget->g.x, _widget->g.y, _widget->g.w, widget->font->id, 0, widget->state ? 65535 : 0, widget->labels);
-
+ eve_cmd(CMD_TOGGLE, "hhhhhhs", _widget->g.x - EVE_TOGGLEW_MARGIN, _widget->g.y, _widget->g.w, widget->font->id, 0, widget->state ? 65535 : 0, widget->labels);
return _widget->tagN;
}
@@ -56,3 +54,15 @@ int eve_togglew_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
return 0;
}
+
+void eve_togglew_set(EVEToggleWidget *widget) {
+ widget->state = 1;
+}
+
+void eve_togglew_clr(EVEToggleWidget *widget) {
+ widget->state = 0;
+}
+
+uint8_t eve_togglew_get(EVEToggleWidget *widget) {
+ return widget->state;
+} \ No newline at end of file
diff --git a/fw/fe310/eos/eve/widget/togglew.h b/fw/fe310/eos/eve/widget/togglew.h
index 26ff77c..aa5485d 100644
--- a/fw/fe310/eos/eve/widget/togglew.h
+++ b/fw/fe310/eos/eve/widget/togglew.h
@@ -1,5 +1,7 @@
#include <stdint.h>
+#define EVE_TOGGLEW_MARGIN 50
+
struct EVEWidgetSpec;
typedef struct EVEToggleWidget {
@@ -12,6 +14,7 @@ typedef struct EVEToggleWidget {
typedef struct EVEToggleSpec {
EVEFont *font;
char *labels;
+ uint8_t state;
} EVEToggleSpec;
void eve_togglew_init(EVEToggleWidget *widget, EVERect *g, EVEPage *page, EVEFont *font, char *labels);
@@ -19,3 +22,7 @@ void eve_togglew_init(EVEToggleWidget *widget, EVERect *g, EVEPage *page, EVEFon
int eve_togglew_create(EVEWidget *_widget, struct EVEWidgetSpec *spec, EVEPage *page);
uint8_t eve_togglew_draw(EVEWidget *_widget, uint8_t tag0);
int eve_togglew_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt);
+
+void eve_togglew_set(EVEToggleWidget *widget);
+void eve_togglew_clr(EVEToggleWidget *widget);
+uint8_t eve_togglew_get(EVEToggleWidget *widget); \ No newline at end of file
diff --git a/fw/fe310/eos/eve/widget/widget.c b/fw/fe310/eos/eve/widget/widget.c
index a157301..88b90a9 100644
--- a/fw/fe310/eos/eve/widget/widget.c
+++ b/fw/fe310/eos/eve/widget/widget.c
@@ -49,10 +49,10 @@ void eve_widget_destroy(EVEWidget *widget) {
if (_eve_widget_destroy[widget->type]) _eve_widget_destroy[widget->type](widget);
}
-void eve_widget_set_focus(EVEWidget *widget, EVERect *rect) {
+void eve_widget_set_focus(EVEWidget *widget) {
EVEPage *page = widget->page;
- eve_page_set_focus(page, widget, rect);
+ eve_page_set_focus(page, widget);
}
void eve_widget_set_flags(EVEWidget *widget, uint8_t flags) {
diff --git a/fw/fe310/eos/eve/widget/widget.h b/fw/fe310/eos/eve/widget/widget.h
index 0bef06e..a565b53 100644
--- a/fw/fe310/eos/eve/widget/widget.h
+++ b/fw/fe310/eos/eve/widget/widget.h
@@ -2,9 +2,10 @@
#include "label.h"
-#define EVEP_WIDGET_FLAG_RO 0x01
-#define EVEP_WIDGET_FLAG_HIDDEN 0x02
-#define EVEP_WIDGET_FLAG_BUSY 0x04
+#define EVE_WIDGET_FLAG_SKIP 0x01
+#define EVE_WIDGET_FLAG_HIDDEN 0x02
+#define EVE_WIDGET_FLAG_RO 0x04
+#define EVE_WIDGET_FLAG_BUSY 0x08
struct EVEWidget;
@@ -44,6 +45,6 @@ size_t eve_widget_size(uint8_t type);
void eve_widget_set_label(EVEWidget *widget, EVELabel *label);
EVEWidget *eve_widget_next(EVEWidget *widget);
-void eve_widget_set_focus(EVEWidget *widget, EVERect *rect);
+void eve_widget_set_focus(EVEWidget *widget);
void eve_widget_set_flags(EVEWidget *widget, uint8_t flags);
void eve_widget_clr_flags(EVEWidget *widget, uint8_t flags); \ No newline at end of file