summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/eve/widget/widget.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2020-08-23 22:37:16 +0200
committerUros Majstorovic <majstor@majstor.org>2020-08-23 22:37:16 +0200
commit1e5eb7cb910e6f23c69c2c986b6373e9f9abb980 (patch)
tree5e8ed0ad6b2fcba747c626c1c51afebbf76b3b9d /fw/fe310/eos/eve/widget/widget.c
parent57c1824affca858023c65c84e188ea7dc6c0a5f2 (diff)
dynamic memory alloc for gui added; page navigation added
Diffstat (limited to 'fw/fe310/eos/eve/widget/widget.c')
-rw-r--r--fw/fe310/eos/eve/widget/widget.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/fw/fe310/eos/eve/widget/widget.c b/fw/fe310/eos/eve/widget/widget.c
index ab121d8..7c1fcad 100644
--- a/fw/fe310/eos/eve/widget/widget.c
+++ b/fw/fe310/eos/eve/widget/widget.c
@@ -8,19 +8,34 @@
#include "screen/screen.h"
#include "screen/window.h"
#include "screen/page.h"
-#include "screen/font.h"
-#include "label.h"
-#include "widget.h"
-#include "pagew.h"
-#include "strw.h"
-#include "textw.h"
+#include "widgets.h"
-static const size_t _eve_wsize[] = {
+static const size_t _widget_size[] = {
0,
+ sizeof(EVEFreeWidget),
+ sizeof(EVESpacerWidget),
sizeof(EVEPageWidget),
sizeof(EVEStrWidget),
- sizeof(EVETextWidget)
+ sizeof(EVETextWidget),
+};
+
+static const eve_widget_create_t _widget_create[] = {
+ NULL,
+ (eve_widget_create_t)eve_freew_create,
+ (eve_widget_create_t)eve_spacerw_create,
+ (eve_widget_create_t)eve_pagew_create,
+ (eve_widget_create_t)eve_strw_create,
+ (eve_widget_create_t)eve_textw_create,
+};
+
+static const eve_widget_destroy_t _widget_destroy[] = {
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ (eve_widget_destroy_t)eve_strw_destroy,
+ (eve_widget_destroy_t)eve_textw_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) {
@@ -31,11 +46,23 @@ void eve_widget_init(EVEWidget *widget, uint8_t type, EVERect *g, eve_widget_tou
widget->type = type;
}
+size_t eve_widget_size(uint8_t type) {
+ return _widget_size[type];
+}
+
void eve_widget_set_label(EVEWidget *widget, EVELabel *label) {
widget->label = label;
}
EVEWidget *eve_widget_next(EVEWidget *widget) {
char *_w = (char *)widget;
- return (EVEWidget *)(_w + _eve_wsize[widget->type]);
+ 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);
}
+
+void eve_widget_destroy(EVEWidget *widget) {
+ if (_widget_destroy[widget->type]) _widget_destroy[widget->type](widget);
+} \ No newline at end of file