summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2021-02-28 21:00:13 +0100
committerUros Majstorovic <majstor@majstor.org>2021-02-28 21:00:13 +0100
commit82a6206422ed658a99716fbd18e33942cebc833b (patch)
treef849699cd7a31175c57c3d9583d2162786138e3c
parent6a4c8a1f11f6a7bd57b0fd618f455bcdecbfe538 (diff)
font property moved to widget base
-rw-r--r--fw/fe310/eos/app/root.c15
-rw-r--r--fw/fe310/eos/app/root.h17
-rw-r--r--fw/fe310/eos/eve/Makefile2
-rw-r--r--fw/fe310/eos/eve/clipb.c (renamed from fw/fe310/eos/eve/widget/clipb.c)0
-rw-r--r--fw/fe310/eos/eve/clipb.h (renamed from fw/fe310/eos/eve/widget/clipb.h)0
-rw-r--r--fw/fe310/eos/eve/eve_font.c (renamed from fw/fe310/eos/eve/widget/font.c)4
-rw-r--r--fw/fe310/eos/eve/eve_font.h (renamed from fw/fe310/eos/eve/widget/font.h)0
-rw-r--r--fw/fe310/eos/eve/screen/form.c5
-rw-r--r--fw/fe310/eos/eve/screen/page.c5
-rw-r--r--fw/fe310/eos/eve/widget/Makefile2
-rw-r--r--fw/fe310/eos/eve/widget/freew.c13
-rw-r--r--fw/fe310/eos/eve/widget/freew.h4
-rw-r--r--fw/fe310/eos/eve/widget/label.c6
-rw-r--r--fw/fe310/eos/eve/widget/pagew.c21
-rw-r--r--fw/fe310/eos/eve/widget/pagew.h4
-rw-r--r--fw/fe310/eos/eve/widget/selectw.c24
-rw-r--r--fw/fe310/eos/eve/widget/selectw.h4
-rw-r--r--fw/fe310/eos/eve/widget/spacerw.c9
-rw-r--r--fw/fe310/eos/eve/widget/spacerw.h2
-rw-r--r--fw/fe310/eos/eve/widget/strw.c55
-rw-r--r--fw/fe310/eos/eve/widget/strw.h4
-rw-r--r--fw/fe310/eos/eve/widget/textw.c60
-rw-r--r--fw/fe310/eos/eve/widget/textw.h5
-rw-r--r--fw/fe310/eos/eve/widget/widget.c11
-rw-r--r--fw/fe310/eos/eve/widget/widget.h3
-rw-r--r--fw/fe310/eos/eve/widget/widgets.h23
-rw-r--r--fw/fe310/test/cell_pdp.c14
-rw-r--r--fw/fe310/test/main.c9
-rw-r--r--fw/fe310/test/modem.c1
-rw-r--r--fw/fe310/test/phone.c13
-rw-r--r--fw/fe310/test/status.c3
-rw-r--r--fw/fe310/test/wifi.c15
32 files changed, 168 insertions, 185 deletions
diff --git a/fw/fe310/eos/app/root.c b/fw/fe310/eos/app/root.c
index 43bab11..ec0e4ea 100644
--- a/fw/fe310/eos/app/root.c
+++ b/fw/fe310/eos/app/root.c
@@ -5,6 +5,7 @@
#include "eve/eve.h"
#include "eve/eve_kbd.h"
+#include "eve/eve_font.h"
#include "eve/screen/screen.h"
#include "eve/screen/window.h"
@@ -17,8 +18,6 @@
#include "status.h"
#include "root.h"
-EVEFont *_app_font_default;
-
static EVEKbd kbd;
static EVEFont font;
static EVEScreen screen;
@@ -49,7 +48,6 @@ static uint8_t kbd_draw(EVEView *v, uint8_t tag0) {
void app_screen_init(eve_view_constructor_t home_page) {
EVERect g;
- _app_font_default = &font;
eve_spi_start();
eve_brightness(0x40);
@@ -107,11 +105,12 @@ static void widgets_destroy(EVEWidget *widget, uint16_t widget_size) {
}
}
-EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, APPWidgetSpec spec[], uint16_t spec_size, eve_form_action_t action, eve_form_destructor_t destructor) {
+EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, EVEWidgetSpec spec[], uint16_t spec_size, eve_form_action_t action, eve_form_destructor_t destructor) {
EVEWidget *widgets;
EVEWidget *widget;
EVELabel *label;
EVEForm *form;
+ EVEFont *_font;
int w_size = 0;
int i, r;
@@ -131,7 +130,8 @@ EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, APPWidgetSpec s
widget = widgets;
for (i=0; i<spec_size; i++) {
- r = eve_widget_create(widget, spec[i].widget.type, &spec[i].widget.g, &spec[i].widget.spec);
+ _font = spec[i].widget.font ? spec[i].widget.font : &font;
+ r = eve_widget_create(widget, spec[i].widget.type, &spec[i].widget.g, _font, &spec[i].widget.spec);
if (r) {
widgets_destroy(widgets, i);
eve_free(widgets);
@@ -139,6 +139,7 @@ EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, APPWidgetSpec s
return NULL;
}
if (spec[i].label.title) {
+ _font = spec[i].label.font ? spec[i].label.font : &font;
label = eve_malloc(sizeof(EVELabel));
if (label == NULL) {
eve_widget_destroy(widget);
@@ -147,9 +148,11 @@ EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, APPWidgetSpec s
eve_free(form);
return NULL;
}
- eve_label_init(label, &spec[i].label.g, spec[i].label.font, spec[i].label.title);
+ eve_label_init(label, &spec[i].label.g, _font, spec[i].label.title);
eve_widget_set_label(widget, label);
}
+ if (widget->label && (widget->label->g.w == 0)) eve_font_str_w(label->font, label->title) + APP_LABEL_MARGIN;
+ if (widget->g.w == 0) widget->g.w = APP_SCREEN_W - (widget->label ? widget->label->g.w : 0);
widget = eve_widget_next(widget);
}
diff --git a/fw/fe310/eos/app/root.h b/fw/fe310/eos/app/root.h
index 69624e7..9468e6e 100644
--- a/fw/fe310/eos/app/root.h
+++ b/fw/fe310/eos/app/root.h
@@ -6,24 +6,11 @@
#define APP_FONT_HANDLE 31
-typedef struct APPLabelSpec {
- EVERect g;
- EVEFont *font;
- char *title;
-} APPLabelSpec;
-
-typedef struct APPWidgetSpec {
- APPLabelSpec label;
- struct {
- EVERect g;
- EVEWidgetSpec spec;
- uint8_t type;
- } widget;
-} APPWidgetSpec;
+#define APP_LABEL_MARGIN 10
EVEScreen *app_screen(void);
void app_screen_init(eve_view_constructor_t home_page);
void app_screen_refresh(void);
-EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, APPWidgetSpec spec[], uint16_t spec_size, eve_form_action_t action, eve_form_destructor_t destructor);
+EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, EVEWidgetSpec spec[], uint16_t spec_size, eve_form_action_t action, eve_form_destructor_t destructor);
void app_form_destroy(EVEForm *form);
diff --git a/fw/fe310/eos/eve/Makefile b/fw/fe310/eos/eve/Makefile
index 68d406a..8183c31 100644
--- a/fw/fe310/eos/eve/Makefile
+++ b/fw/fe310/eos/eve/Makefile
@@ -2,7 +2,7 @@ include ../../common.mk
CFLAGS += -I.. -I../../bsp/include
-obj = eve.o eve_touch.o eve_track.o eve_kbd.o eve_text.o eve_platform.o
+obj = eve.o eve_platform.o eve_touch.o eve_track.o eve_kbd.o eve_text.o eve_font.o clipb.o
%.o: %.c %.h
diff --git a/fw/fe310/eos/eve/widget/clipb.c b/fw/fe310/eos/eve/clipb.c
index 04c9a46..04c9a46 100644
--- a/fw/fe310/eos/eve/widget/clipb.c
+++ b/fw/fe310/eos/eve/clipb.c
diff --git a/fw/fe310/eos/eve/widget/clipb.h b/fw/fe310/eos/eve/clipb.h
index 2d6fae6..2d6fae6 100644
--- a/fw/fe310/eos/eve/widget/clipb.h
+++ b/fw/fe310/eos/eve/clipb.h
diff --git a/fw/fe310/eos/eve/widget/font.c b/fw/fe310/eos/eve/eve_font.c
index da02983..d71607c 100644
--- a/fw/fe310/eos/eve/widget/font.c
+++ b/fw/fe310/eos/eve/eve_font.c
@@ -1,9 +1,9 @@
#include <stdlib.h>
-#include "eve.h"
#include "unicode.h"
-#include "font.h"
+#include "eve.h"
+#include "eve_font.h"
void eve_font_init(EVEFont *font, uint8_t font_id) {
uint32_t p;
diff --git a/fw/fe310/eos/eve/widget/font.h b/fw/fe310/eos/eve/eve_font.h
index aff038c..aff038c 100644
--- a/fw/fe310/eos/eve/widget/font.h
+++ b/fw/fe310/eos/eve/eve_font.h
diff --git a/fw/fe310/eos/eve/screen/form.c b/fw/fe310/eos/eve/screen/form.c
index 4aef803..c8a8bba 100644
--- a/fw/fe310/eos/eve/screen/form.c
+++ b/fw/fe310/eos/eve/screen/form.c
@@ -1,9 +1,11 @@
#include <stdlib.h>
#include <string.h>
+#include "unicode.h"
+
#include "eve.h"
#include "eve_kbd.h"
-#include "unicode.h"
+#include "eve_font.h"
#include "screen.h"
#include "window.h"
@@ -11,7 +13,6 @@
#include "page.h"
#include "form.h"
-#include "widget/font.h"
#include "widget/label.h"
#include "widget/widget.h"
diff --git a/fw/fe310/eos/eve/screen/page.c b/fw/fe310/eos/eve/screen/page.c
index 980cf33..51e2637 100644
--- a/fw/fe310/eos/eve/screen/page.c
+++ b/fw/fe310/eos/eve/screen/page.c
@@ -1,16 +1,17 @@
#include <stdlib.h>
#include <string.h>
+#include "unicode.h"
+
#include "eve.h"
#include "eve_kbd.h"
-#include "unicode.h"
+#include "eve_font.h"
#include "screen.h"
#include "window.h"
#include "view.h"
#include "page.h"
-#include "widget/font.h"
#include "widget/label.h"
#include "widget/widget.h"
diff --git a/fw/fe310/eos/eve/widget/Makefile b/fw/fe310/eos/eve/widget/Makefile
index fa5b41c..95af16d 100644
--- a/fw/fe310/eos/eve/widget/Makefile
+++ b/fw/fe310/eos/eve/widget/Makefile
@@ -2,7 +2,7 @@ include ../../../common.mk
CFLAGS += -I.. -I../..
-obj = clipb.o font.o label.o widget.o freew.o spacerw.o pagew.o strw.o textw.o selectw.o
+obj = label.o widget.o freew.o spacerw.o pagew.o strw.o textw.o selectw.o
%.o: %.c %.h
diff --git a/fw/fe310/eos/eve/widget/freew.c b/fw/fe310/eos/eve/widget/freew.c
index 8fcc2f6..2100fce 100644
--- a/fw/fe310/eos/eve/widget/freew.c
+++ b/fw/fe310/eos/eve/widget/freew.c
@@ -1,31 +1,32 @@
#include <stdlib.h>
#include <string.h>
+#include "unicode.h"
+
#include "eve.h"
#include "eve_kbd.h"
-#include "unicode.h"
+#include "eve_font.h"
#include "screen/screen.h"
#include "screen/window.h"
#include "screen/view.h"
#include "screen/page.h"
-#include "font.h"
#include "label.h"
#include "widget.h"
#include "freew.h"
-int eve_freew_create(EVEFreeWidget *widget, EVERect *g, EVEFreeSpec *spec) {
- eve_freew_init(widget, g, spec->touch, spec->draw, spec->putc);
+int eve_freew_create(EVEFreeWidget *widget, EVERect *g, EVEFont *font, EVEFreeSpec *spec) {
+ eve_freew_init(widget, g, font, spec->touch, spec->draw, spec->putc);
return EVE_OK;
}
-void eve_freew_init(EVEFreeWidget *widget, EVERect *g, eve_freew_touch_t touch, eve_freew_draw_t draw, eve_kbd_input_handler_t putc) {
+void eve_freew_init(EVEFreeWidget *widget, EVERect *g, EVEFont *font, eve_freew_touch_t touch, eve_freew_draw_t draw, eve_kbd_input_handler_t putc) {
EVEWidget *_widget = &widget->w;
memset(widget, 0, sizeof(EVEFreeWidget));
- eve_widget_init(_widget, EVE_WIDGET_TYPE_FREE, g, eve_freew_touch, eve_freew_draw, putc);
+ eve_widget_init(_widget, EVE_WIDGET_TYPE_FREE, g, font, eve_freew_touch, eve_freew_draw, putc);
eve_freew_update(widget, touch, draw, NULL);
}
diff --git a/fw/fe310/eos/eve/widget/freew.h b/fw/fe310/eos/eve/widget/freew.h
index c7d8076..a237e88 100644
--- a/fw/fe310/eos/eve/widget/freew.h
+++ b/fw/fe310/eos/eve/widget/freew.h
@@ -17,8 +17,8 @@ typedef struct EVEFreeSpec {
eve_kbd_input_handler_t putc;
} EVEFreeSpec;
-int eve_freew_create(EVEFreeWidget *widget, EVERect *g, EVEFreeSpec *spec);
-void eve_freew_init(EVEFreeWidget *widget, EVERect *g, eve_freew_touch_t touch, eve_freew_draw_t draw, eve_kbd_input_handler_t putc);
+int eve_freew_create(EVEFreeWidget *widget, EVERect *g, EVEFont *font, EVEFreeSpec *spec);
+void eve_freew_init(EVEFreeWidget *widget, EVERect *g, EVEFont *font, eve_freew_touch_t touch, eve_freew_draw_t draw, eve_kbd_input_handler_t putc);
void eve_freew_update(EVEFreeWidget *widget, eve_freew_touch_t touch, eve_freew_draw_t draw, eve_kbd_input_handler_t putc);
void eve_freew_tag(EVEFreeWidget *widget);
diff --git a/fw/fe310/eos/eve/widget/label.c b/fw/fe310/eos/eve/widget/label.c
index 728f0bb..c52027c 100644
--- a/fw/fe310/eos/eve/widget/label.c
+++ b/fw/fe310/eos/eve/widget/label.c
@@ -1,16 +1,17 @@
#include <stdlib.h>
#include <string.h>
+#include "unicode.h"
+
#include "eve.h"
#include "eve_kbd.h"
-#include "unicode.h"
+#include "eve_font.h"
#include "screen/screen.h"
#include "screen/window.h"
#include "screen/view.h"
#include "screen/page.h"
-#include "font.h"
#include "label.h"
void eve_label_init(EVELabel *label, EVERect *g, EVEFont *font, char *title) {
@@ -18,7 +19,6 @@ void eve_label_init(EVELabel *label, EVERect *g, EVEFont *font, char *title) {
if (g) label->g = *g;
label->font = font;
label->title = title;
- if (label->g.w == 0) label->g.w = eve_font_str_w(font, label->title);
if (label->g.h == 0) label->g.h = eve_font_h(font);
}
diff --git a/fw/fe310/eos/eve/widget/pagew.c b/fw/fe310/eos/eve/widget/pagew.c
index 2142cb9..51528da 100644
--- a/fw/fe310/eos/eve/widget/pagew.c
+++ b/fw/fe310/eos/eve/widget/pagew.c
@@ -1,22 +1,23 @@
#include <stdlib.h>
#include <string.h>
+#include "unicode.h"
+
#include "eve.h"
#include "eve_kbd.h"
-#include "unicode.h"
+#include "eve_font.h"
#include "screen/screen.h"
#include "screen/window.h"
#include "screen/view.h"
#include "screen/page.h"
-#include "font.h"
#include "label.h"
#include "widget.h"
#include "pagew.h"
-int eve_pagew_create(EVEPageWidget *widget, EVERect *g, EVEPageSpec *spec) {
- eve_pagew_init(widget, g, spec->font, spec->title, spec->constructor);
+int eve_pagew_create(EVEPageWidget *widget, EVERect *g, EVEFont *font, EVEPageSpec *spec) {
+ eve_pagew_init(widget, g, font, spec->title, spec->constructor);
return EVE_OK;
}
@@ -25,18 +26,16 @@ void eve_pagew_init(EVEPageWidget *widget, EVERect *g, EVEFont *font, char *titl
EVEWidget *_widget = &widget->w;
memset(widget, 0, sizeof(EVEPageWidget));
- eve_widget_init(_widget, EVE_WIDGET_TYPE_PAGE, g, eve_pagew_touch, eve_pagew_draw, NULL);
- eve_pagew_update(widget, font, title, constructor);
+ eve_widget_init(_widget, EVE_WIDGET_TYPE_PAGE, g, font, eve_pagew_touch, eve_pagew_draw, NULL);
+ eve_pagew_update(widget, title, constructor);
}
-void eve_pagew_update(EVEPageWidget *widget, EVEFont *font, char *title, eve_view_constructor_t constructor) {
+void eve_pagew_update(EVEPageWidget *widget, char *title, eve_view_constructor_t constructor) {
EVEWidget *_widget = &widget->w;
- if (font) widget->font = font;
if (title) widget->title = title;
if (constructor) widget->constructor = constructor;
- if (_widget->g.w == 0) _widget->g.w = eve_font_str_w(font, widget->title);
- if (_widget->g.h == 0) _widget->g.h = eve_font_h(font);
+ if (_widget->g.h == 0) _widget->g.h = eve_font_h(_widget->font);
}
int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt) {
@@ -60,7 +59,7 @@ uint8_t eve_pagew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
}
_widget->tagN = tag0;
- eve_cmd(CMD_TEXT, "hhhhs", _widget->g.x, _widget->g.y, widget->font->id, 0, widget->title);
+ eve_cmd(CMD_TEXT, "hhhhs", _widget->g.x, _widget->g.y, _widget->font->id, 0, widget->title);
return _widget->tagN;
}
diff --git a/fw/fe310/eos/eve/widget/pagew.h b/fw/fe310/eos/eve/widget/pagew.h
index 6560654..3678d9c 100644
--- a/fw/fe310/eos/eve/widget/pagew.h
+++ b/fw/fe310/eos/eve/widget/pagew.h
@@ -13,9 +13,9 @@ typedef struct EVEPageSpec {
eve_view_constructor_t constructor;
} EVEPageSpec;
-int eve_pagew_create(EVEPageWidget *widget, EVERect *g, EVEPageSpec *spec);
+int eve_pagew_create(EVEPageWidget *widget, EVERect *g, EVEFont *font, EVEPageSpec *spec);
void eve_pagew_init(EVEPageWidget *widget, EVERect *g, EVEFont *font, char *title, eve_view_constructor_t constructor);
-void eve_pagew_update(EVEPageWidget *widget, EVEFont *font, char *title, eve_view_constructor_t constructor);
+void eve_pagew_update(EVEPageWidget *widget, char *title, eve_view_constructor_t constructor);
int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt);
uint8_t eve_pagew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
diff --git a/fw/fe310/eos/eve/widget/selectw.c b/fw/fe310/eos/eve/widget/selectw.c
index 432b5a4..7157e85 100644
--- a/fw/fe310/eos/eve/widget/selectw.c
+++ b/fw/fe310/eos/eve/widget/selectw.c
@@ -1,16 +1,17 @@
#include <stdlib.h>
#include <string.h>
+#include "unicode.h"
+
#include "eve.h"
#include "eve_kbd.h"
-#include "unicode.h"
+#include "eve_font.h"
#include "screen/screen.h"
#include "screen/window.h"
#include "screen/view.h"
#include "screen/page.h"
-#include "font.h"
#include "label.h"
#include "widget.h"
#include "selectw.h"
@@ -33,7 +34,7 @@ static int selectw_option_verify(utf8_t *opt, uint16_t size) {
return EVE_OK;
}
-int eve_selectw_create(EVESelectWidget *widget, EVERect *g, EVESelectSpec *spec) {
+int eve_selectw_create(EVESelectWidget *widget, EVERect *g, EVEFont *font, EVESelectSpec *spec) {
utf8_t *option;
option = eve_malloc(spec->option_size);
@@ -42,7 +43,7 @@ int eve_selectw_create(EVESelectWidget *widget, EVERect *g, EVESelectSpec *spec)
}
memset(option, 0, spec->option_size);
- eve_selectw_init(widget, g, spec->font, option, spec->option_size, spec->multi);
+ eve_selectw_init(widget, g, font, option, spec->option_size, spec->multi);
return EVE_OK;
}
@@ -55,15 +56,14 @@ void eve_selectw_init(EVESelectWidget *widget, EVERect *g, EVEFont *font, utf8_t
EVEWidget *_widget = &widget->w;
memset(widget, 0, sizeof(EVESelectWidget));
- eve_widget_init(_widget, EVE_WIDGET_TYPE_SELECT, g, eve_selectw_touch, eve_selectw_draw, NULL);
- eve_selectw_update(widget, font, option, option_size);
+ eve_widget_init(_widget, EVE_WIDGET_TYPE_SELECT, g, font, eve_selectw_touch, eve_selectw_draw, NULL);
+ eve_selectw_update(widget, option, option_size);
widget->multi = multi;
}
-void eve_selectw_update(EVESelectWidget *widget, EVEFont *font, utf8_t *option, uint16_t option_size) {
+void eve_selectw_update(EVESelectWidget *widget, utf8_t *option, uint16_t option_size) {
int rv, text_len;
- if (font) widget->font = font;
if (option) {
int rv = selectw_option_verify(option, option_size);
if (rv == EVE_OK) {
@@ -121,8 +121,8 @@ uint8_t eve_selectw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
s = widget->multi ? widget->select & (0x1 << i) : widget->select == i;
x1 = _widget->g.x;
x2 = x1 + _widget->g.w;
- y1 = _widget->g.y + i * widget->font->h;
- y2 = y1 + widget->font->h;
+ y1 = _widget->g.y + i * _widget->font->h;
+ y2 = y1 + _widget->font->h;
eve_cmd_dl(BEGIN(EVE_RECTS));
if (!s) eve_cmd_dl(COLOR_MASK(0 ,0 ,0 ,0));
eve_cmd_dl(VERTEX2F(x1, y1));
@@ -135,14 +135,14 @@ uint8_t eve_selectw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
}
eve_cmd_dl(END());
if (s) eve_cmd_dl(COLOR_RGBC(page->v.window->color_bg));
- eve_cmd(CMD_TEXT, "hhhhs", x1, y1, widget->font->id, 0, widget->option + o_curr);
+ eve_cmd(CMD_TEXT, "hhhhs", x1, y1, _widget->font->id, 0, widget->option + o_curr);
if (s) eve_cmd_dl(COLOR_RGBC(page->v.window->color_fg));
o_curr += o_len + 1;
i++;
} while (o_len);
- _widget->g.h = i * widget->font->h;
+ _widget->g.h = i * _widget->font->h;
return _widget->tagN;
}
diff --git a/fw/fe310/eos/eve/widget/selectw.h b/fw/fe310/eos/eve/widget/selectw.h
index 8a02c84..0045228 100644
--- a/fw/fe310/eos/eve/widget/selectw.h
+++ b/fw/fe310/eos/eve/widget/selectw.h
@@ -15,10 +15,10 @@ typedef struct EVESelectSpec {
uint8_t multi;
} EVESelectSpec;
-int eve_selectw_create(EVESelectWidget *widget, EVERect *g, EVESelectSpec *spec);
+int eve_selectw_create(EVESelectWidget *widget, EVERect *g, EVEFont *font, EVESelectSpec *spec);
void eve_selectw_destroy(EVESelectWidget *widget);
void eve_selectw_init(EVESelectWidget *widget, EVERect *g, EVEFont *font, utf8_t *option, uint16_t option_size, uint8_t multi);
-void eve_selectw_update(EVESelectWidget *widget, EVEFont *font, utf8_t *option, uint16_t option_size);
+void eve_selectw_update(EVESelectWidget *widget, utf8_t *option, uint16_t option_size);
int eve_selectw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt);
uint8_t eve_selectw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
diff --git a/fw/fe310/eos/eve/widget/spacerw.c b/fw/fe310/eos/eve/widget/spacerw.c
index 3a0216f..3affe24 100644
--- a/fw/fe310/eos/eve/widget/spacerw.c
+++ b/fw/fe310/eos/eve/widget/spacerw.c
@@ -1,21 +1,22 @@
#include <stdlib.h>
#include <string.h>
+#include "unicode.h"
+
#include "eve.h"
#include "eve_kbd.h"
-#include "unicode.h"
+#include "eve_font.h"
#include "screen/screen.h"
#include "screen/window.h"
#include "screen/view.h"
#include "screen/page.h"
-#include "font.h"
#include "label.h"
#include "widget.h"
#include "spacerw.h"
-int eve_spacerw_create(EVESpacerWidget *widget, EVERect *g, EVESpacerSpec *spec) {
+int eve_spacerw_create(EVESpacerWidget *widget, EVERect *g, EVEFont *font, EVESpacerSpec *spec) {
eve_spacerw_init(widget, g);
return EVE_OK;
@@ -25,7 +26,7 @@ void eve_spacerw_init(EVESpacerWidget *widget, EVERect *g) {
EVEWidget *_widget = &widget->w;
memset(widget, 0, sizeof(EVESpacerWidget));
- eve_widget_init(_widget, EVE_WIDGET_TYPE_SPACER, g, eve_spacerw_touch, eve_spacerw_draw, NULL);
+ eve_widget_init(_widget, EVE_WIDGET_TYPE_SPACER, g, NULL, eve_spacerw_touch, eve_spacerw_draw, NULL);
}
int eve_spacerw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt) {
diff --git a/fw/fe310/eos/eve/widget/spacerw.h b/fw/fe310/eos/eve/widget/spacerw.h
index 073f134..0722ce2 100644
--- a/fw/fe310/eos/eve/widget/spacerw.h
+++ b/fw/fe310/eos/eve/widget/spacerw.h
@@ -7,7 +7,7 @@ typedef struct EVESpacerWidget {
typedef struct EVESpacerSpec {
} EVESpacerSpec;
-int eve_spacerw_create(EVESpacerWidget *widget, EVERect *g, EVESpacerSpec *spec);
+int eve_spacerw_create(EVESpacerWidget *widget, EVERect *g, EVEFont *font, EVESpacerSpec *spec);
void eve_spacerw_init(EVESpacerWidget *widget, EVERect *g);
int eve_spacerw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt);
diff --git a/fw/fe310/eos/eve/widget/strw.c b/fw/fe310/eos/eve/widget/strw.c
index 20d3292..65baf67 100644
--- a/fw/fe310/eos/eve/widget/strw.c
+++ b/fw/fe310/eos/eve/widget/strw.c
@@ -1,17 +1,18 @@
#include <stdlib.h>
#include <string.h>
+#include "unicode.h"
+#include "clipb.h"
+
#include "eve.h"
#include "eve_kbd.h"
-#include "unicode.h"
+#include "eve_font.h"
#include "screen/screen.h"
#include "screen/window.h"
#include "screen/view.h"
#include "screen/page.h"
-#include "clipb.h"
-#include "font.h"
#include "label.h"
#include "widget.h"
#include "strw.h"
@@ -32,7 +33,7 @@
#define CHAR_VALID_INPUT(c) ((c >= 0x20) && (c < 0x7f))
-int eve_strw_create(EVEStrWidget *widget, EVERect *g, EVEStrSpec *spec) {
+int eve_strw_create(EVEStrWidget *widget, EVERect *g, EVEFont *font, EVEStrSpec *spec) {
utf8_t *str;
uint16_t *line;
@@ -40,7 +41,7 @@ int eve_strw_create(EVEStrWidget *widget, EVERect *g, EVEStrSpec *spec) {
if (str == NULL) return EVE_ERR_NOMEM;
str[0] = '\0';
- eve_strw_init(widget, g, spec->font, str, spec->str_size);
+ eve_strw_init(widget, g, font, str, spec->str_size);
return EVE_OK;
}
@@ -53,15 +54,14 @@ void eve_strw_init(EVEStrWidget *widget, EVERect *g, EVEFont *font, utf8_t *str,
EVEWidget *_widget = &widget->w;
memset(widget, 0, sizeof(EVEStrWidget));
- eve_widget_init(_widget, EVE_WIDGET_TYPE_STR, g, eve_strw_touch, eve_strw_draw, eve_strw_putc);
- eve_strw_update(widget, font, str, str_size);
+ eve_widget_init(_widget, EVE_WIDGET_TYPE_STR, g, font, eve_strw_touch, eve_strw_draw, eve_strw_putc);
+ eve_strw_update(widget, str, str_size);
}
-void eve_strw_update(EVEStrWidget *widget, EVEFont *font, utf8_t *str, uint16_t str_size) {
+void eve_strw_update(EVEStrWidget *widget, utf8_t *str, uint16_t str_size) {
int rv, str_len;
EVEWidget *_widget = &widget->w;
- if (font) widget->font = font;
if (str) {
widget->str = str;
widget->str_size = str_size;
@@ -71,9 +71,9 @@ void eve_strw_update(EVEStrWidget *widget, EVEFont *font, utf8_t *str, uint16_t
widget->str[str_len] = '\0';
}
widget->str_len = str_len;
- widget->str_g.w = eve_font_str_w(font, str);
+ widget->str_g.w = eve_font_str_w(_widget->font, str);
}
- if (_widget->g.h == 0) _widget->g.h = eve_font_h(font);
+ if (_widget->g.h == 0) _widget->g.h = eve_font_h(_widget->font);
}
static void set_focus(EVEStrWidget *widget, EVEPage *page) {
@@ -83,7 +83,7 @@ static void set_focus(EVEStrWidget *widget, EVEPage *page) {
focus.x = _widget->g.x;
focus.y = _widget->g.y;
focus.w = _widget->g.w;
- focus.h = 2 * widget->font->h;
+ focus.h = 2 * _widget->font->h;
eve_page_set_focus(page, _widget, &focus);
}
@@ -95,7 +95,7 @@ static EVEStrCursor *cursor_prox(EVEStrWidget *widget, EVEStrCursor *cursor, EVE
*dx = cursor->x - x;
_dx = *dx < 0 ? -(*dx) : *dx;
- if (_dx <= widget->font->w) return cursor;
+ if (_dx <= _widget->font->w) return cursor;
return NULL;
}
@@ -132,7 +132,7 @@ int eve_strw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt)
widget->str_g.x0 = widget->str_g.x;
}
x = widget->str_g.x0 + t->x0 - t->x;
- w1 = widget->w.g.w - widget->font->w;
+ w1 = _widget->g.w - _widget->font->w;
if (x > widget->str_g.w - w1) x = widget->str_g.w - w1;
if (x < 0) x = 0;
widget->str_g.x = x;
@@ -181,17 +181,17 @@ static void _draw_str(EVEStrWidget *widget, EVEWindow *window, uint16_t ch, uint
eve_cmd_dl(BEGIN(EVE_RECTS));
if (!s) eve_cmd_dl(COLOR_MASK(0 ,0 ,0 ,0));
eve_cmd_dl(VERTEX2F(x + x1, _widget->g.y));
- eve_cmd_dl(VERTEX2F(x + x2, _widget->g.y + widget->font->h));
+ eve_cmd_dl(VERTEX2F(x + x2, _widget->g.y + _widget->font->h));
if (!s) {
eve_cmd_dl(COLOR_MASK(1 ,1 ,1 ,1));
eve_cmd_dl(BEGIN(EVE_LINES));
- eve_cmd_dl(VERTEX2F(x + x1, _widget->g.y + widget->font->h));
- eve_cmd_dl(VERTEX2F(x + x2, _widget->g.y + widget->font->h));
+ eve_cmd_dl(VERTEX2F(x + x1, _widget->g.y + _widget->font->h));
+ eve_cmd_dl(VERTEX2F(x + x2, _widget->g.y + _widget->font->h));
}
eve_cmd_dl(END());
if (len) {
if (s) eve_cmd_dl(COLOR_RGBC(window->color_bg));
- eve_cmd(CMD_TEXT, "hhhhpb", x + x1, _widget->g.y, widget->font->id, 0, widget->str + ch, len, 0);
+ eve_cmd(CMD_TEXT, "hhhhpb", x + x1, _widget->g.y, _widget->font->id, 0, widget->str + ch, len, 0);
if (s) eve_cmd_dl(COLOR_RGBC(window->color_fg));
}
}
@@ -205,7 +205,7 @@ static void _draw_cursor(EVEStrWidget *widget, EVEStrCursor *cursor) {
y = _widget->g.y;
eve_cmd_dl(BEGIN(EVE_LINES));
eve_cmd_dl(VERTEX2F(x, y));
- eve_cmd_dl(VERTEX2F(x, y + widget->font->h));
+ eve_cmd_dl(VERTEX2F(x, y + _widget->font->h));
eve_cmd_dl(END());
}
@@ -286,12 +286,13 @@ uint8_t eve_strw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
void eve_strw_putc(void *_page, int c) {
EVEPage *page = _page;
EVEStrWidget *widget = (EVEStrWidget *)eve_page_get_focus(page);
+ EVEWidget *_widget = &widget->w;
EVEStrCursor *cursor1 = &widget->cursor1;
EVEStrCursor *cursor2 = &widget->cursor2;
utf8_t *str;
utf8_t *clipb = NULL;
- int w0 = widget->font->w;
- int w1 = widget->w.g.w - widget->font->w;
+ int w0 = _widget->font->w;
+ int w1 = _widget->g.w - _widget->font->w;
int ins_c = 0, del_c = 0;
int ins_w = 0, del_w = 0;
@@ -312,7 +313,7 @@ void eve_strw_putc(void *_page, int c) {
case CH_BS:
if (cursor1->ch > 0) {
del_c = -utf8_seek(str, -1, &uc);
- del_w = eve_font_ch_w(widget->font, uc);
+ del_w = eve_font_ch_w(_widget->font, uc);
memmove(str - del_c, str, widget->str_len - cursor1->ch + 1);
widget->str_len -= del_c;
widget->str_g.w -= del_w;
@@ -324,7 +325,7 @@ void eve_strw_putc(void *_page, int c) {
case CH_DEL:
if (cursor1->ch < widget->str_len) {
del_c = utf8_dec(str, &uc);
- del_w = eve_font_ch_w(widget->font, uc);
+ del_w = eve_font_ch_w(_widget->font, uc);
memmove(str, str + del_c, widget->str_len - cursor1->ch - del_c + 1);
widget->str_len -= del_c;
widget->str_g.w -= del_w;
@@ -347,7 +348,7 @@ void eve_strw_putc(void *_page, int c) {
c1 = cursor2;
}
del_c = c2->ch - c1->ch;
- del_w = eve_font_buf_w(widget->font, str, del_c);
+ del_w = eve_font_buf_w(_widget->font, str, del_c);
if ((c == CH_CTRLX) || (c == CH_CTRLC)) {
eve_clipb_push(str, del_c);
if (c == CH_CTRLC) return;
@@ -357,7 +358,7 @@ void eve_strw_putc(void *_page, int c) {
str = widget->str + c1->ch;
if (CHAR_VALID_INPUT(c)) {
ins_c = utf8_enc(c, utf8_buf);
- ins_w = eve_font_ch_w(widget->font, c);
+ ins_w = eve_font_ch_w(_widget->font, c);
} else if (c == CH_CTRLV) {
int rv, clipb_len = 0;
@@ -370,7 +371,7 @@ void eve_strw_putc(void *_page, int c) {
}
}
ins_c = clipb_len;
- ins_w = eve_font_str_w(widget->font, clipb);
+ ins_w = eve_font_str_w(_widget->font, clipb);
}
if (widget->str_len + ins_c >= widget->str_size + del_c) {
ins_c = 0;
@@ -413,7 +414,7 @@ void eve_strw_cursor_set(EVEStrWidget *widget, EVEStrCursor *cursor, int16_t x)
i = 0;
while (i < widget->str_len) {
ch_l = utf8_dec(widget->str + i, &ch);
- ch_w = eve_font_ch_w(widget->font, ch);
+ ch_w = eve_font_ch_w(_widget->font, ch);
_x += ch_w;
i += ch_l;
if (_x >= x) {
diff --git a/fw/fe310/eos/eve/widget/strw.h b/fw/fe310/eos/eve/widget/strw.h
index dcb34c1..fa1faf8 100644
--- a/fw/fe310/eos/eve/widget/strw.h
+++ b/fw/fe310/eos/eve/widget/strw.h
@@ -31,10 +31,10 @@ typedef struct EVEStrSpec {
uint16_t str_size;
} EVEStrSpec;
-int eve_strw_create(EVEStrWidget *widget, EVERect *g, EVEStrSpec *spec);
+int eve_strw_create(EVEStrWidget *widget, EVERect *g, EVEFont *font, EVEStrSpec *spec);
void eve_strw_destroy(EVEStrWidget *widget);
void eve_strw_init(EVEStrWidget *widget, EVERect *g, EVEFont *font, utf8_t *str, uint16_t str_size);
-void eve_strw_update(EVEStrWidget *widget, EVEFont *font, utf8_t *str, uint16_t str_size);
+void eve_strw_update(EVEStrWidget *widget, utf8_t *str, uint16_t str_size);
int eve_strw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt);
uint8_t eve_strw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
diff --git a/fw/fe310/eos/eve/widget/textw.c b/fw/fe310/eos/eve/widget/textw.c
index 33eb2b0..a650415 100644
--- a/fw/fe310/eos/eve/widget/textw.c
+++ b/fw/fe310/eos/eve/widget/textw.c
@@ -1,17 +1,18 @@
#include <stdlib.h>
#include <string.h>
+#include "unicode.h"
+#include "clipb.h"
+
#include "eve.h"
#include "eve_kbd.h"
-#include "unicode.h"
+#include "eve_font.h"
#include "screen/screen.h"
#include "screen/window.h"
#include "screen/view.h"
#include "screen/page.h"
-#include "clipb.h"
-#include "font.h"
#include "label.h"
#include "widget.h"
#include "textw.h"
@@ -35,7 +36,7 @@
#define DIVC(x,y) ((x) / (y) + ((x) % (y) != 0))
-int eve_textw_create(EVETextWidget *widget, EVERect *g, EVETextSpec *spec) {
+int eve_textw_create(EVETextWidget *widget, EVERect *g, EVEFont *font, EVETextSpec *spec) {
utf8_t *text;
uint16_t *line;
@@ -50,7 +51,7 @@ int eve_textw_create(EVETextWidget *widget, EVERect *g, EVETextSpec *spec) {
return EVE_ERR_NOMEM;
}
- eve_textw_init(widget, g, spec->font, text, spec->text_size, line, spec->line_size);
+ eve_textw_init(widget, g, font, text, spec->text_size, line, spec->line_size);
return EVE_OK;
}
@@ -64,14 +65,13 @@ void eve_textw_init(EVETextWidget *widget, EVERect *g, EVEFont *font, utf8_t *te
EVEWidget *_widget = &widget->w;
memset(widget, 0, sizeof(EVETextWidget));
- eve_widget_init(_widget, EVE_WIDGET_TYPE_TEXT, g, eve_textw_touch, eve_textw_draw, eve_textw_putc);
- eve_textw_update(widget, font, text, text_size, line, line_size);
+ eve_widget_init(_widget, EVE_WIDGET_TYPE_TEXT, g, font, eve_textw_touch, eve_textw_draw, eve_textw_putc);
+ eve_textw_update(widget, text, text_size, line, line_size);
}
-void eve_textw_update(EVETextWidget *widget, EVEFont *font, utf8_t *text, uint16_t text_size, uint16_t *line, uint16_t line_size) {
+void eve_textw_update(EVETextWidget *widget, utf8_t *text, uint16_t text_size, uint16_t *line, uint16_t line_size) {
int rv, text_len;
- if (font) widget->font = font;
if (text) {
widget->text = text;
widget->text_size = text_size;
@@ -95,9 +95,9 @@ static void set_focus(EVETextWidget *widget, EVETextCursor *cursor, EVEPage *pag
EVEWidget *_widget = &widget->w;
focus.x = _widget->g.x;
- focus.y = _widget->g.y + cursor->line * widget->font->h;
+ focus.y = _widget->g.y + cursor->line * _widget->font->h;
focus.w = _widget->g.w;
- focus.h = 2 * widget->font->h;
+ focus.h = 2 * _widget->font->h;
eve_page_set_focus(page, _widget, &focus);
}
@@ -113,7 +113,7 @@ static EVETextCursor *cursor_prox(EVETextWidget *widget, EVETextCursor *cursor,
_dx = *dx < 0 ? -(*dx) : *dx;
_dl = *dl < 0 ? -(*dl) : *dl;
- if ((_dx <= widget->font->h) && (_dl <= 1)) return cursor;
+ if ((_dx <= _widget->font->h) && (_dl <= 1)) return cursor;
return NULL;
}
@@ -175,18 +175,18 @@ static void _draw_line(EVETextWidget *widget, EVEWindow *window, uint16_t l, uin
if (x1 != x2) {
eve_cmd_dl(BEGIN(EVE_RECTS));
if (!s) eve_cmd_dl(COLOR_MASK(0 ,0 ,0 ,0));
- eve_cmd_dl(VERTEX2F(_widget->g.x + x1, _widget->g.y + l * widget->font->h));
- eve_cmd_dl(VERTEX2F(_widget->g.x + x2, _widget->g.y + (l + 1) * widget->font->h));
+ eve_cmd_dl(VERTEX2F(_widget->g.x + x1, _widget->g.y + l * _widget->font->h));
+ eve_cmd_dl(VERTEX2F(_widget->g.x + x2, _widget->g.y + (l + 1) * _widget->font->h));
if (!s) {
eve_cmd_dl(COLOR_MASK(1 ,1 ,1 ,1));
eve_cmd_dl(BEGIN(EVE_LINES));
- eve_cmd_dl(VERTEX2F(_widget->g.x + x1, _widget->g.y + (l + 1) * widget->font->h));
- eve_cmd_dl(VERTEX2F(_widget->g.x + x2, _widget->g.y + (l + 1) * widget->font->h));
+ eve_cmd_dl(VERTEX2F(_widget->g.x + x1, _widget->g.y + (l + 1) * _widget->font->h));
+ eve_cmd_dl(VERTEX2F(_widget->g.x + x2, _widget->g.y + (l + 1) * _widget->font->h));
}
eve_cmd_dl(END());
if (len) {
if (s) eve_cmd_dl(COLOR_RGBC(window->color_bg));
- eve_cmd(CMD_TEXT, "hhhhpb", _widget->g.x + x1, _widget->g.y + l * widget->font->h, widget->font->id, 0, widget->text + ch, len, 0);
+ eve_cmd(CMD_TEXT, "hhhhpb", _widget->g.x + x1, _widget->g.y + l * _widget->font->h, _widget->font->id, 0, widget->text + ch, len, 0);
if (s) eve_cmd_dl(COLOR_RGBC(window->color_fg));
}
}
@@ -197,10 +197,10 @@ static void _draw_cursor(EVETextWidget *widget, EVETextCursor *cursor) {
EVEWidget *_widget = &widget->w;
x = _widget->g.x + cursor->x;
- y = _widget->g.y + cursor->line * widget->font->h;
+ y = _widget->g.y + cursor->line * _widget->font->h;
eve_cmd_dl(BEGIN(EVE_LINES));
eve_cmd_dl(VERTEX2F(x, y));
- eve_cmd_dl(VERTEX2F(x, y + widget->font->h));
+ eve_cmd_dl(VERTEX2F(x, y + _widget->font->h));
eve_cmd_dl(END());
}
@@ -210,8 +210,8 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
int _line0, _lineN;
char lineNvisible;
- _line0 = line0 = ((int)page->win_y - _widget->g.y) / widget->font->h;
- _lineN = lineN = DIVC(((int)page->win_y - _widget->g.y + page->v.window->g.h), widget->font->h);
+ _line0 = line0 = ((int)page->win_y - _widget->g.y) / _widget->font->h;
+ _lineN = lineN = DIVC(((int)page->win_y - _widget->g.y + page->v.window->g.h), _widget->font->h);
if (line0 < 0) line0 = 0;
if (lineN < 0) lineN = 0;
if (line0 > widget->line_len) line0 = widget->line_len;
@@ -293,7 +293,7 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
_widget->tagN = EVE_TAG_NOTAG;
}
- _widget->g.h = (widget->line_len + 1) * widget->font->h;
+ _widget->g.h = (widget->line_len + 1) * _widget->font->h;
return _widget->tagN;
}
@@ -301,6 +301,7 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
void eve_textw_putc(void *_page, int c) {
EVEPage *page = _page;
EVETextWidget *widget = (EVETextWidget *)eve_page_get_focus(page);
+ EVEWidget *_widget = &widget->w;
EVETextCursor *cursor1 = &widget->cursor1;
EVETextCursor *cursor2 = &widget->cursor2;
utf8_t *text;
@@ -325,7 +326,7 @@ void eve_textw_putc(void *_page, int c) {
case CH_BS:
if (cursor1->ch > 0) {
del_c = -utf8_seek(text, -1, &uc);
- ch_w = eve_font_ch_w(widget->font, uc);
+ ch_w = eve_font_ch_w(_widget->font, uc);
memmove(text - del_c, text, widget->text_len - cursor1->ch + 1);
cursor1->ch -= del_c;
}
@@ -334,7 +335,7 @@ void eve_textw_putc(void *_page, int c) {
case CH_DEL:
if (cursor1->ch < widget->text_len) {
del_c = utf8_dec(text, &uc);
- ch_w = eve_font_ch_w(widget->font, uc);
+ ch_w = eve_font_ch_w(_widget->font, uc);
memmove(text, text + del_c, widget->text_len - cursor1->ch - del_c + 1);
}
break;
@@ -360,7 +361,7 @@ void eve_textw_putc(void *_page, int c) {
text = widget->text + c1->ch;
if (CHAR_VALID_INPUT(c)) {
ins_c = utf8_enc(c, utf8_buf);
- ch_w = eve_font_ch_w(widget->font, c);
+ ch_w = eve_font_ch_w(_widget->font, c);
} else if (c == CH_CTRLV) {
int rv, clipb_len = 0;
@@ -373,7 +374,7 @@ void eve_textw_putc(void *_page, int c) {
}
}
ins_c = clipb_len;
- ch_w = eve_font_str_w(widget->font, clipb);
+ ch_w = eve_font_str_w(_widget->font, clipb);
}
if (widget->text_len + ins_c >= widget->text_size + del_c) {
ins_c = 0;
@@ -441,7 +442,7 @@ uint16_t eve_textw_text_update(EVETextWidget *widget, uint16_t line) {
widget->line[line] = LINE_EMPTY;
}
- ch_w = eve_font_ch_w(widget->font, ch);
+ ch_w = eve_font_ch_w(_widget->font, ch);
if (ch <= 0x20) {
if ((ch == '\n') || (ch == '\0')) {
if (widget->line[line] == i) return line;
@@ -487,10 +488,11 @@ void eve_textw_cursor_update(EVETextWidget *widget, EVETextCursor *cursor) {
uint16_t x = 0;
utf32_t ch;
uint8_t ch_l;
+ EVEWidget *_widget = &widget->w;
while ((i < cursor->ch) && (i < LINE_END(widget, cursor->line))) {
ch_l = utf8_dec(widget->text + i, &ch);
- x += eve_font_ch_w(widget->font, ch);
+ x += eve_font_ch_w(_widget->font, ch);
i += ch_l;
}
cursor->x = x;
@@ -521,7 +523,7 @@ void eve_textw_cursor_set(EVETextWidget *widget, EVETextCursor *cursor, uint8_t
i = LINE_START(widget, cursor->line);
while (i < LINE_END(widget, cursor->line)) {
ch_l = utf8_dec(widget->text + i, &ch);
- ch_w = eve_font_ch_w(widget->font, ch);
+ ch_w = eve_font_ch_w(_widget->font, ch);
_x += ch_w;
i += ch_l;
if (_x >= x) {
diff --git a/fw/fe310/eos/eve/widget/textw.h b/fw/fe310/eos/eve/widget/textw.h
index 95f0091..abf8f33 100644
--- a/fw/fe310/eos/eve/widget/textw.h
+++ b/fw/fe310/eos/eve/widget/textw.h
@@ -9,7 +9,6 @@ typedef struct EVETextCursor {
typedef struct EVETextWidget {
EVEWidget w;
- EVEFont *font;
utf8_t *text;
uint16_t text_size;
uint16_t text_len;
@@ -32,10 +31,10 @@ typedef struct EVETextSpec {
uint16_t line_size;
} EVETextSpec;
-int eve_textw_create(EVETextWidget *widget, EVERect *g, EVETextSpec *spec);
+int eve_textw_create(EVETextWidget *widget, EVERect *g, EVEFont *font, EVETextSpec *spec);
void eve_textw_destroy(EVETextWidget *widget);
void eve_textw_init(EVETextWidget *widget, EVERect *g, EVEFont *font, utf8_t *text, uint16_t text_size, uint16_t *line, uint16_t line_size);
-void eve_textw_update(EVETextWidget *widget, EVEFont *font, utf8_t *text, uint16_t text_size, uint16_t *line, uint16_t line_size);
+void eve_textw_update(EVETextWidget *widget, utf8_t *text, uint16_t text_size, uint16_t *line, uint16_t line_size);
int eve_textw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt);
uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
diff --git a/fw/fe310/eos/eve/widget/widget.c b/fw/fe310/eos/eve/widget/widget.c
index a223169..9f1e888 100644
--- a/fw/fe310/eos/eve/widget/widget.c
+++ b/fw/fe310/eos/eve/widget/widget.c
@@ -1,9 +1,11 @@
#include <stdlib.h>
#include <string.h>
+#include "unicode.h"
+
#include "eve.h"
#include "eve_kbd.h"
-#include "unicode.h"
+#include "eve_font.h"
#include "screen/screen.h"
#include "screen/window.h"
@@ -42,8 +44,9 @@ static const eve_widget_destroy_t _widget_destroy[] = {
(eve_widget_destroy_t)eve_selectw_destroy,
};
-void eve_widget_init(EVEWidget *widget, uint8_t type, EVERect *g, eve_widget_touch_t touch, eve_widget_draw_t draw, eve_kbd_input_handler_t putc) {
+void eve_widget_init(EVEWidget *widget, uint8_t type, EVERect *g, EVEFont *font, eve_widget_touch_t touch, eve_widget_draw_t draw, eve_kbd_input_handler_t putc) {
if (g) widget->g = *g;
+ widget->font = font;
widget->touch = touch;
widget->draw = draw;
widget->putc = putc;
@@ -63,8 +66,8 @@ EVEWidget *eve_widget_next(EVEWidget *widget) {
return (EVEWidget *)(_w + _widget_size[widget->type]);
}
-int eve_widget_create(EVEWidget *widget, uint8_t type, EVERect *g, EVEWidgetSpec *spec) {
- return _widget_create[type](widget, g, spec);
+int eve_widget_create(EVEWidget *widget, uint8_t type, EVERect *g, EVEFont *font, EVEWidgetSpecT *spec) {
+ return _widget_create[type](widget, g, font, spec);
}
void eve_widget_destroy(EVEWidget *widget) {
diff --git a/fw/fe310/eos/eve/widget/widget.h b/fw/fe310/eos/eve/widget/widget.h
index 3e04f3e..5dc8abe 100644
--- a/fw/fe310/eos/eve/widget/widget.h
+++ b/fw/fe310/eos/eve/widget/widget.h
@@ -14,6 +14,7 @@ typedef uint8_t (*eve_widget_draw_t) (struct EVEWidget *, EVEPage *, uint8_t);
typedef struct EVEWidget {
EVERect g;
+ EVEFont *font;
eve_widget_touch_t touch;
eve_widget_draw_t draw;
eve_kbd_input_handler_t putc;
@@ -23,7 +24,7 @@ typedef struct EVEWidget {
uint8_t tagN;
} EVEWidget;
-void eve_widget_init(EVEWidget *widget, uint8_t type, EVERect *g, eve_widget_touch_t touch, eve_widget_draw_t draw, eve_kbd_input_handler_t putc);
+void eve_widget_init(EVEWidget *widget, uint8_t type, EVERect *g, EVEFont *font, eve_widget_touch_t touch, eve_widget_draw_t draw, eve_kbd_input_handler_t putc);
size_t eve_widget_size(uint8_t type);
void eve_widget_set_label(EVEWidget *widget, EVELabel *label);
EVEWidget *eve_widget_next(EVEWidget *widget);
diff --git a/fw/fe310/eos/eve/widget/widgets.h b/fw/fe310/eos/eve/widget/widgets.h
index 542b350..c33fc03 100644
--- a/fw/fe310/eos/eve/widget/widgets.h
+++ b/fw/fe310/eos/eve/widget/widgets.h
@@ -1,4 +1,3 @@
-#include "font.h"
#include "label.h"
#include "widget.h"
@@ -9,17 +8,33 @@
#include "textw.h"
#include "selectw.h"
-typedef union EVEWidgetSpec {
+typedef union EVEWidgetSpecT {
EVEFreeSpec free;
EVESpacerSpec spacer;
EVEPageSpec page;
EVEStrSpec str;
EVETextSpec text;
EVESelectSpec select;
+} EVEWidgetSpecT;
+
+typedef struct EVELabelSpec {
+ EVERect g;
+ EVEFont *font;
+ char *title;
+} APPLabelSpec;
+
+typedef struct EVEWidgetSpec {
+ APPLabelSpec label;
+ struct {
+ EVERect g;
+ EVEFont *font;
+ EVEWidgetSpecT spec;
+ uint8_t type;
+ } widget;
} EVEWidgetSpec;
-typedef int (*eve_widget_create_t) (EVEWidget *, EVERect *g, EVEWidgetSpec *);
+typedef int (*eve_widget_create_t) (EVEWidget *, EVERect *g, EVEFont *, EVEWidgetSpecT *);
typedef void (*eve_widget_destroy_t) (EVEWidget *);
-int eve_widget_create(EVEWidget *widget, uint8_t type, EVERect *g, EVEWidgetSpec *spec);
+int eve_widget_create(EVEWidget *widget, uint8_t type, EVERect *g, EVEFont *font, EVEWidgetSpecT *spec);
void eve_widget_destroy(EVEWidget *widget);
diff --git a/fw/fe310/test/cell_pdp.c b/fw/fe310/test/cell_pdp.c
index 955b42e..43c8579 100644
--- a/fw/fe310/test/cell_pdp.c
+++ b/fw/fe310/test/cell_pdp.c
@@ -14,6 +14,7 @@
#include <eve/eve.h>
#include <eve/eve_kbd.h>
+#include <eve/eve_font.h>
#include <eve/screen/screen.h>
#include <eve/screen/window.h>
@@ -28,8 +29,6 @@
#include "status.h"
#include "cell_pdp.h"
-extern EVEFont *_app_font_default;
-
static void cell_pdp_connect(char *apn, char *user, char *pass) {
unsigned char *buffer, *p;
@@ -72,35 +71,26 @@ static void cell_pdp_handler(unsigned char type, unsigned char *buffer, uint16_t
}
void app_cell_pdp(EVEWindow *window, EVEViewStack *stack) {
- APPWidgetSpec spec[] = {
+ EVEWidgetSpec spec[] = {
{
.label.g.w = APP_SCREEN_W / 3,
- .label.font = _app_font_default,
.label.title = "APN:",
.widget.type = EVE_WIDGET_TYPE_STR,
- .widget.g.w = APP_SCREEN_W - APP_SCREEN_W / 3,
- .widget.spec.str.font = _app_font_default,
.widget.spec.str.str_size = 128,
},
{
.label.g.w = APP_SCREEN_W / 3,
- .label.font = _app_font_default,
.label.title = "User:",
.widget.type = EVE_WIDGET_TYPE_STR,
- .widget.g.w = APP_SCREEN_W - APP_SCREEN_W / 3,
- .widget.spec.str.font = _app_font_default,
.widget.spec.str.str_size = 128,
},
{
.label.g.w = APP_SCREEN_W / 3,
- .label.font = _app_font_default,
.label.title = "Pass:",
.widget.type = EVE_WIDGET_TYPE_STR,
- .widget.g.w = APP_SCREEN_W - APP_SCREEN_W / 3,
- .widget.spec.str.font = _app_font_default,
.widget.spec.str.str_size = 128,
},
};
diff --git a/fw/fe310/test/main.c b/fw/fe310/test/main.c
index 7516fe8..934995c 100644
--- a/fw/fe310/test/main.c
+++ b/fw/fe310/test/main.c
@@ -14,6 +14,7 @@
#include <eve/eve.h>
#include <eve/eve_kbd.h>
+#include <eve/eve_font.h>
#include <eve/screen/screen.h>
#include <eve/screen/window.h>
@@ -32,35 +33,29 @@
#include "modem.h"
#include "wifi.h"
-extern EVEFont *_app_font_default;
-
void app_home_page(EVEWindow *window, EVEViewStack *stack) {
- APPWidgetSpec spec[] = {
+ EVEWidgetSpec spec[] = {
{
.widget.type = EVE_WIDGET_TYPE_PAGE,
.widget.g.w = APP_SCREEN_W,
- .widget.spec.page.font = _app_font_default,
.widget.spec.page.title = "Phone",
.widget.spec.page.constructor = app_phone
},
{
.widget.type = EVE_WIDGET_TYPE_PAGE,
.widget.g.w = APP_SCREEN_W,
- .widget.spec.page.font = _app_font_default,
.widget.spec.page.title = "WiFi",
.widget.spec.page.constructor = app_wifi
},
{
.widget.type = EVE_WIDGET_TYPE_PAGE,
.widget.g.w = APP_SCREEN_W,
- .widget.spec.page.font = _app_font_default,
.widget.spec.page.title = "Cellular data",
.widget.spec.page.constructor = app_cell_pdp
},
{
.widget.type = EVE_WIDGET_TYPE_PAGE,
.widget.g.w = APP_SCREEN_W,
- .widget.spec.page.font = _app_font_default,
.widget.spec.page.title = "Modem",
.widget.spec.page.constructor = app_modem
},
diff --git a/fw/fe310/test/modem.c b/fw/fe310/test/modem.c
index 2a2ee7c..4ed7c81 100644
--- a/fw/fe310/test/modem.c
+++ b/fw/fe310/test/modem.c
@@ -15,6 +15,7 @@
#include <eve/eve.h>
#include <eve/eve_kbd.h>
#include <eve/eve_text.h>
+#include <eve/eve_font.h>
#include <eve/screen/screen.h>
#include <eve/screen/window.h>
diff --git a/fw/fe310/test/phone.c b/fw/fe310/test/phone.c
index 2832fc4..b3a08b1 100644
--- a/fw/fe310/test/phone.c
+++ b/fw/fe310/test/phone.c
@@ -14,6 +14,7 @@
#include <eve/eve.h>
#include <eve/eve_kbd.h>
+#include <eve/eve_font.h>
#include <eve/screen/screen.h>
#include <eve/screen/window.h>
@@ -28,8 +29,6 @@
#include "status.h"
#include "phone.h"
-extern EVEFont *_app_font_default;
-
#define ABUF_SIZE 512
#define MIC_WM 128
@@ -88,17 +87,11 @@ static void cell_voice_handler(unsigned char type, unsigned char *buffer, uint16
}
void app_phone(EVEWindow *window, EVEViewStack *stack) {
- char *title = "Phone:";
- uint16_t w = eve_font_str_w(_app_font_default, title) + 10;
- APPWidgetSpec spec[] = {
+ EVEWidgetSpec spec[] = {
{
- .label.g.w = w,
- .label.font = _app_font_default,
- .label.title = title,
+ .label.title = "Phone:",
.widget.type = EVE_WIDGET_TYPE_STR,
- .widget.g.w = APP_SCREEN_W - w,
- .widget.spec.str.font = _app_font_default,
.widget.spec.str.str_size = 128,
},
};
diff --git a/fw/fe310/test/status.c b/fw/fe310/test/status.c
index 2f44842..b61fc13 100644
--- a/fw/fe310/test/status.c
+++ b/fw/fe310/test/status.c
@@ -14,6 +14,7 @@
#include <eve/eve.h>
#include <eve/eve_kbd.h>
+#include <eve/eve_font.h>
#include <eve/screen/screen.h>
#include <eve/screen/window.h>
@@ -28,8 +29,6 @@
#include "phone.h"
#include "status.h"
-extern EVEFont *_app_font_default;
-
static char status_msg[128];
static int status_touch(EVEView *v, uint8_t tag0, int touch_idx) {
diff --git a/fw/fe310/test/wifi.c b/fw/fe310/test/wifi.c
index 5306d37..f7ca24d 100644
--- a/fw/fe310/test/wifi.c
+++ b/fw/fe310/test/wifi.c
@@ -14,6 +14,7 @@
#include <eve/eve.h>
#include <eve/eve_kbd.h>
+#include <eve/eve_font.h>
#include <eve/screen/screen.h>
#include <eve/screen/window.h>
@@ -28,8 +29,6 @@
#include "status.h"
#include "wifi.h"
-extern EVEFont *_app_font_default;
-
static void wifi_scan(void) {
unsigned char *buffer = eos_net_alloc();
buffer[0] = EOS_WIFI_MTYPE_SCAN;
@@ -82,17 +81,13 @@ static void wifi_disconnect_handler(unsigned char type, unsigned char *buffer, u
}
void app_wifi(EVEWindow *window, EVEViewStack *stack) {
- char *title = "Password:";
- uint16_t w = eve_font_str_w(_app_font_default, title) + 10;
- APPWidgetSpec spec[] = {
+ EVEWidgetSpec spec[] = {
{
.label.g.w = APP_SCREEN_W,
- .label.font = _app_font_default,
.label.title = "Select network:",
.widget.type = EVE_WIDGET_TYPE_SELECT,
.widget.g.w = APP_SCREEN_W,
- .widget.spec.select.font = _app_font_default,
.widget.spec.select.option_size = 1500,
},
{
@@ -101,13 +96,9 @@ void app_wifi(EVEWindow *window, EVEViewStack *stack) {
.widget.g.h = 50,
},
{
- .label.g.w = w,
- .label.font = _app_font_default,
- .label.title = title,
+ .label.title = "Password:",
.widget.type = EVE_WIDGET_TYPE_STR,
- .widget.g.w = APP_SCREEN_W - w,
- .widget.spec.str.font = _app_font_default,
.widget.spec.str.str_size = 128,
},
};