summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/eve/screen
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2020-08-26 02:07:48 +0200
committerUros Majstorovic <majstor@majstor.org>2020-08-26 02:07:48 +0200
commitd6a8caa7e27dd08180f6a5a45a080c2e4cfc1fe4 (patch)
tree52f8010eace6e3e7002f6396297109a15eb8e81b /fw/fe310/eos/eve/screen
parent48d934f5b422d87a59ffb38e6215a851f28c1b0e (diff)
kbdwin removed; stack and contructor moved to view
Diffstat (limited to 'fw/fe310/eos/eve/screen')
-rw-r--r--fw/fe310/eos/eve/screen/Makefile2
-rw-r--r--fw/fe310/eos/eve/screen/form.c3
-rw-r--r--fw/fe310/eos/eve/screen/form.h2
-rw-r--r--fw/fe310/eos/eve/screen/kbdwin.c39
-rw-r--r--fw/fe310/eos/eve/screen/kbdwin.h14
-rw-r--r--fw/fe310/eos/eve/screen/page.c42
-rw-r--r--fw/fe310/eos/eve/screen/page.h19
-rw-r--r--fw/fe310/eos/eve/screen/screen.c2
-rw-r--r--fw/fe310/eos/eve/screen/view.c39
-rw-r--r--fw/fe310/eos/eve/screen/view.h27
-rw-r--r--fw/fe310/eos/eve/screen/window.c18
-rw-r--r--fw/fe310/eos/eve/screen/window.h15
12 files changed, 104 insertions, 118 deletions
diff --git a/fw/fe310/eos/eve/screen/Makefile b/fw/fe310/eos/eve/screen/Makefile
index b1650bd..fc21670 100644
--- a/fw/fe310/eos/eve/screen/Makefile
+++ b/fw/fe310/eos/eve/screen/Makefile
@@ -2,7 +2,7 @@ include ../../../common.mk
CFLAGS += -I.. -I../..
-obj = screen.o window.o kbdwin.o page.o form.o
+obj = screen.o window.o view.o page.o form.o
%.o: %.c %.h
diff --git a/fw/fe310/eos/eve/screen/form.c b/fw/fe310/eos/eve/screen/form.c
index 5837a99..fe1bd0d 100644
--- a/fw/fe310/eos/eve/screen/form.c
+++ b/fw/fe310/eos/eve/screen/form.c
@@ -7,6 +7,7 @@
#include "screen.h"
#include "window.h"
+#include "view.h"
#include "page.h"
#include "form.h"
@@ -17,7 +18,7 @@
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
-int eve_form_init(EVEForm *form, EVEWindow *window, EVEPageStack *stack, EVEWidget *widget, uint16_t widget_size, eve_page_destructor_t destructor) {
+int eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, EVEWidget *widget, uint16_t widget_size, eve_page_destructor_t destructor) {
memset(form, 0, sizeof(EVEForm));
eve_page_init(&form->p, window, stack, eve_form_touch, eve_form_draw, eve_form_handle_evt, eve_form_update_g, destructor);
form->widget = widget;
diff --git a/fw/fe310/eos/eve/screen/form.h b/fw/fe310/eos/eve/screen/form.h
index b6e59ff..cab10b9 100644
--- a/fw/fe310/eos/eve/screen/form.h
+++ b/fw/fe310/eos/eve/screen/form.h
@@ -8,7 +8,7 @@ typedef struct EVEForm {
uint16_t widget_size;
} EVEForm;
-int eve_form_init(EVEForm *form, EVEWindow *window, EVEPageStack *stack, struct EVEWidget *widget, uint16_t widget_size, eve_page_destructor_t destructor);
+int eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, struct EVEWidget *widget, uint16_t widget_size, eve_page_destructor_t destructor);
int eve_form_touch(EVEView *v, uint8_t tag0, int touch_idx);
uint8_t eve_form_draw(EVEView *v, uint8_t tag0);
int eve_form_handle_evt(EVEPage *page, struct EVEWidget *widget, EVETouch *touch, uint16_t evt, uint8_t tag0, int touch_idx);
diff --git a/fw/fe310/eos/eve/screen/kbdwin.c b/fw/fe310/eos/eve/screen/kbdwin.c
deleted file mode 100644
index decedad..0000000
--- a/fw/fe310/eos/eve/screen/kbdwin.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-
-#include "eve.h"
-#include "eve_kbd.h"
-
-#include "screen.h"
-#include "window.h"
-#include "kbdwin.h"
-
-static int kbdwin_touch(EVEView *v, uint8_t tag0, int touch_idx) {
- EVEKbdView *k_view = (EVEKbdView *)v;
-
- return eve_kbd_touch(&k_view->kbd, tag0, touch_idx);
-}
-
-static uint8_t kbdwin_draw(EVEView *v, uint8_t tag0) {
- EVEKbdView *k_view = (EVEKbdView *)v;
-
- eve_kbd_draw(&k_view->kbd);
- return tag0;
-}
-
-void eve_kbdwin_init(EVEKbdWin *kbd_win, EVEScreen *screen) {
- EVEKbd *kbd = &kbd_win->view.kbd;
-
- kbd_win->view.v.touch = kbdwin_touch;
- kbd_win->view.v.draw = kbdwin_draw;
- eve_kbd_init(kbd, NULL, screen->mem_next, &screen->mem_next);
- eve_window_init(&kbd_win->win, &kbd->g, &kbd_win->view.v, screen);
-}
-
-void eve_kbdwin_append(EVEKbdWin *kbd_win) {
- EVEKbd *kbd = &kbd_win->view.kbd;
- EVEWindow *window = &kbd_win->win;
-
- eve_screen_set_kbd(window->screen, kbd);
- eve_window_append(window);
-}
diff --git a/fw/fe310/eos/eve/screen/kbdwin.h b/fw/fe310/eos/eve/screen/kbdwin.h
deleted file mode 100644
index 2cc14d9..0000000
--- a/fw/fe310/eos/eve/screen/kbdwin.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <stdint.h>
-
-typedef struct EVEKbdView {
- EVEView v;
- EVEKbd kbd;
-} EVEKbdView;
-
-typedef struct EVEKbdWin {
- EVEWindow win;
- EVEKbdView view;
-} EVEKbdWin;
-
-void eve_kbdwin_init(EVEKbdWin *kbd_win, EVEScreen *screen);
-void eve_kbdwin_append(EVEKbdWin *kbd_win);
diff --git a/fw/fe310/eos/eve/screen/page.c b/fw/fe310/eos/eve/screen/page.c
index 9579346..9568ce6 100644
--- a/fw/fe310/eos/eve/screen/page.c
+++ b/fw/fe310/eos/eve/screen/page.c
@@ -7,6 +7,7 @@
#include "screen.h"
#include "window.h"
+#include "view.h"
#include "page.h"
#include "widget/font.h"
@@ -15,51 +16,32 @@
#define CH_EOF 0x1a
-void eve_page_init(EVEPage *page, EVEWindow *window, EVEPageStack *stack, eve_view_touch_t touch, eve_view_draw_t draw, eve_page_evt_handler_t handle_evt, eve_page_g_updater_t update_g, eve_page_destructor_t destructor) {
+void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, eve_view_touch_t touch, eve_view_draw_t draw, eve_page_evt_handler_t handle_evt, eve_page_g_updater_t update_g, eve_page_destructor_t destructor) {
memset(page, 0, sizeof(EVEPage));
- page->v.touch = touch;
- page->v.draw = draw;
- page->v.window = window;
+ eve_view_init(&page->v, window, touch, draw, NULL);
page->handle_evt = handle_evt;
page->update_g = update_g;
page->destructor = destructor;
page->stack = stack;
page->widget_f = NULL;
- window->view = (EVEView *)page;
}
-void eve_page_stack_init(EVEPageStack *stack) {
- memset(stack, 0, sizeof(EVEPageStack));
-}
-
-void eve_page_create(EVEWindow *window, EVEPageStack *stack, eve_page_constructor_t constructor) {
- if (stack->level < EVE_PAGE_SIZE_STACK - 1) {
- stack->constructor[stack->level] = constructor;
- stack->level++;
- constructor(window, stack);
- }
-}
-
-void eve_page_open(EVEPage *parent, eve_page_constructor_t constructor) {
+void eve_page_open(EVEPage *parent, eve_view_constructor_t constructor) {
EVEWindow *window = parent->v.window;
- EVEPageStack *stack = parent->stack;
+ EVEViewStack *stack = parent->stack;
+ eve_page_destructor_t destructor = parent->destructor;
- parent->destructor(parent);
- eve_page_create(window, stack, constructor);
+ if (destructor) destructor(parent);
+ eve_view_create(window, stack, constructor);
}
void eve_page_close(EVEPage *page) {
EVEWindow *window = page->v.window;
- EVEPageStack *stack = page->stack;
-
- if (stack->level > 1) {
- eve_page_constructor_t constructor;
+ EVEViewStack *stack = page->stack;
+ eve_page_destructor_t destructor = page->destructor;
- stack->level--;
- constructor = stack->constructor[stack->level - 1];
- page->destructor(page);
- constructor(window, stack);
- }
+ if (destructor) destructor(page);
+ eve_view_destroy(window, stack);
}
int16_t eve_page_x(EVEPage *page, int16_t x) {
diff --git a/fw/fe310/eos/eve/screen/page.h b/fw/fe310/eos/eve/screen/page.h
index 227375c..168a017 100644
--- a/fw/fe310/eos/eve/screen/page.h
+++ b/fw/fe310/eos/eve/screen/page.h
@@ -1,15 +1,11 @@
#include <stdint.h>
-#define EVE_PAGE_SIZE_STACK 16
-
struct EVEPage;
struct EVEWidget;
-struct EVEPageStack;
-typedef void (*eve_page_constructor_t) (EVEWindow *window, struct EVEPageStack *);
-typedef void (*eve_page_destructor_t) (struct EVEPage *);
typedef int (*eve_page_evt_handler_t) (struct EVEPage *, struct EVEWidget *, EVETouch *, uint16_t, uint8_t, int);
typedef void (*eve_page_g_updater_t) (struct EVEPage *, struct EVEWidget *);
+typedef void (*eve_page_destructor_t) (struct EVEPage *);
typedef struct EVEPage {
EVEView v;
@@ -18,19 +14,12 @@ typedef struct EVEPage {
eve_page_evt_handler_t handle_evt;
eve_page_g_updater_t update_g;
eve_page_destructor_t destructor;
- struct EVEPageStack *stack;
+ struct EVEViewStack *stack;
struct EVEWidget *widget_f;
} EVEPage;
-typedef struct EVEPageStack {
- eve_page_constructor_t constructor[EVE_PAGE_SIZE_STACK];
- uint8_t level;
-} EVEPageStack;
-
-void eve_page_init(EVEPage *page, EVEWindow *window, EVEPageStack *stack, eve_view_touch_t touch, eve_view_draw_t draw, eve_page_evt_handler_t handle_evt, eve_page_g_updater_t update_g, eve_page_destructor_t destructor);
-void eve_page_stack_init(EVEPageStack *stack);
-void eve_page_create(EVEWindow *window, EVEPageStack *stack, eve_page_constructor_t constructor);
-void eve_page_open(EVEPage *parent, eve_page_constructor_t constructor);
+void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, eve_view_touch_t touch, eve_view_draw_t draw, eve_page_evt_handler_t handle_evt, eve_page_g_updater_t update_g, eve_page_destructor_t destructor);
+void eve_page_open(EVEPage *parent, eve_view_constructor_t constructor);
void eve_page_close(EVEPage *page);
int16_t eve_page_x(EVEPage *page, int16_t x);
diff --git a/fw/fe310/eos/eve/screen/screen.c b/fw/fe310/eos/eve/screen/screen.c
index f103b48..af5a91f 100644
--- a/fw/fe310/eos/eve/screen/screen.c
+++ b/fw/fe310/eos/eve/screen/screen.c
@@ -6,7 +6,7 @@
#include "screen.h"
#include "window.h"
-#include "kbdwin.h"
+#include "view.h"
int eve_screen_init(EVEScreen *screen, uint16_t w, uint16_t h) {
memset(screen, 0, sizeof(EVEScreen));
diff --git a/fw/fe310/eos/eve/screen/view.c b/fw/fe310/eos/eve/screen/view.c
new file mode 100644
index 0000000..30229e5
--- /dev/null
+++ b/fw/fe310/eos/eve/screen/view.c
@@ -0,0 +1,39 @@
+#include <stdlib.h>
+#include <string.h>
+
+#include "eve.h"
+#include "eve_kbd.h"
+
+#include "screen.h"
+#include "window.h"
+#include "view.h"
+
+void eve_view_init(EVEView *view, EVEWindow *window, eve_view_touch_t touch, eve_view_draw_t draw, void *param) {
+ view->touch = touch;
+ view->draw = draw;
+ view->param = param;
+ view->window = window;
+ window->view = view;
+}
+
+void eve_view_stack_init(EVEViewStack *stack) {
+ memset(stack, 0, sizeof(EVEViewStack));
+}
+
+void eve_view_create(EVEWindow *window, EVEViewStack *stack, eve_view_constructor_t constructor) {
+ if (stack->level < EVE_VIEW_SIZE_STACK - 1) {
+ stack->constructor[stack->level] = constructor;
+ stack->level++;
+ constructor(window, stack);
+ }
+}
+
+void eve_view_destroy(EVEWindow *window, EVEViewStack *stack) {
+ if (stack->level > 1) {
+ eve_view_constructor_t constructor;
+
+ stack->level--;
+ constructor = stack->constructor[stack->level - 1];
+ constructor(window, stack);
+ }
+}
diff --git a/fw/fe310/eos/eve/screen/view.h b/fw/fe310/eos/eve/screen/view.h
new file mode 100644
index 0000000..3b635ef
--- /dev/null
+++ b/fw/fe310/eos/eve/screen/view.h
@@ -0,0 +1,27 @@
+#include <stdint.h>
+
+#define EVE_VIEW_SIZE_STACK 16
+
+struct EVEView;
+struct EVEViewStack;
+
+typedef int (*eve_view_touch_t) (struct EVEView *, uint8_t, int);
+typedef uint8_t (*eve_view_draw_t) (struct EVEView *, uint8_t);
+typedef void (*eve_view_constructor_t) (EVEWindow *window, struct EVEViewStack *);
+
+typedef struct EVEView {
+ eve_view_touch_t touch;
+ eve_view_draw_t draw;
+ EVEWindow *window;
+ void *param;
+} EVEView;
+
+typedef struct EVEViewStack {
+ eve_view_constructor_t constructor[EVE_VIEW_SIZE_STACK];
+ uint8_t level;
+} EVEViewStack;
+
+void eve_view_init(EVEView *view, EVEWindow *window, eve_view_touch_t touch, eve_view_draw_t draw, void *param);
+void eve_view_stack_init(EVEViewStack *stack);
+void eve_view_create(EVEWindow *window, EVEViewStack *stack, eve_view_constructor_t constructor);
+void eve_view_destroy(EVEWindow *window, EVEViewStack *stack); \ No newline at end of file
diff --git a/fw/fe310/eos/eve/screen/window.c b/fw/fe310/eos/eve/screen/window.c
index e49897f..bfa53d1 100644
--- a/fw/fe310/eos/eve/screen/window.c
+++ b/fw/fe310/eos/eve/screen/window.c
@@ -9,15 +9,12 @@
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
-void eve_window_init(EVEWindow *window, EVERect *g, EVEView *view, EVEScreen *screen) {
+void eve_window_init(EVEWindow *window, EVERect *g, EVEScreen *screen, char *name) {
memset(window, 0, sizeof(EVEWindow));
if (g) window->g = *g;
- if (view) {
- window->view = view;
- window->view->window = window;
- }
window->screen = screen;
+ window->name = name;
window->color_fg = 0xffffff;
}
@@ -114,3 +111,14 @@ void eve_window_remove(EVEWindow *window) {
screen->win_tail = window->prev;
}
}
+
+EVEWindow *eve_window_get(EVEScreen *screen, char *name) {
+ EVEWindow *w = screen->win_head;
+
+ while (w) {
+ if (strcmp(name, w->name) == 0) return w;
+ w = w->next;
+ }
+
+ return NULL;
+}
diff --git a/fw/fe310/eos/eve/screen/window.h b/fw/fe310/eos/eve/screen/window.h
index 7f14f18..89c83eb 100644
--- a/fw/fe310/eos/eve/screen/window.h
+++ b/fw/fe310/eos/eve/screen/window.h
@@ -3,19 +3,11 @@
struct EVEView;
struct EVEWindow;
-typedef int (*eve_view_touch_t) (struct EVEView *, uint8_t, int);
-typedef uint8_t (*eve_view_draw_t) (struct EVEView *, uint8_t);
-
-typedef struct EVEView {
- eve_view_touch_t touch;
- eve_view_draw_t draw;
- struct EVEWindow *window;
-} EVEView;
-
typedef struct EVEWindow {
EVERect g;
- EVEView *view;
EVEScreen *screen;
+ char *name;
+ struct EVEView *view;
struct EVEWindow *next;
struct EVEWindow *prev;
uint32_t color_bg;
@@ -23,7 +15,7 @@ typedef struct EVEWindow {
uint8_t tag;
} EVEWindow;
-void eve_window_init(EVEWindow *window, EVERect *g, EVEView *view, EVEScreen *screen);
+void eve_window_init(EVEWindow *window, EVERect *g, EVEScreen *screen, char *name);
void eve_window_set_color_bg(EVEWindow *window, uint8_t r, uint8_t g, uint8_t b);
void eve_window_set_color_fg(EVEWindow *window, uint8_t r, uint8_t g, uint8_t b);
@@ -34,3 +26,4 @@ void eve_window_append(EVEWindow *window);
void eve_window_insert_above(EVEWindow *window, EVEWindow *win_prev);
void eve_window_insert_below(EVEWindow *window, EVEWindow *win_next);
void eve_window_remove(EVEWindow *window);
+EVEWindow *eve_window_get(EVEScreen *screen, char *name);