From d6a8caa7e27dd08180f6a5a45a080c2e4cfc1fe4 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Wed, 26 Aug 2020 02:07:48 +0200 Subject: kbdwin removed; stack and contructor moved to view --- fw/fe310/eos/app/root.c | 113 +++++++++++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 44 deletions(-) (limited to 'fw/fe310/eos/app/root.c') diff --git a/fw/fe310/eos/app/root.c b/fw/fe310/eos/app/root.c index 8f7ad94..6eb3fa6 100644 --- a/fw/fe310/eos/app/root.c +++ b/fw/fe310/eos/app/root.c @@ -8,7 +8,7 @@ #include "eve/screen/screen.h" #include "eve/screen/window.h" -#include "eve/screen/kbdwin.h" +#include "eve/screen/view.h" #include "eve/screen/page.h" #include "eve/screen/form.h" @@ -19,17 +19,77 @@ EVEFont *_app_font_default; +static EVEKbd kbd; static EVEFont font; static EVEScreen screen; static EVEWindow win_status; static EVEWindow win_main; -static EVEKbdWin win_kbd; -static EVEView view_status = { - app_status_touch, - app_status_draw, - NULL -}; -static EVEPageStack page_stack; +static EVEWindow win_kbd; +static EVEView view_kbd; +static EVEView view_status; +static EVEViewStack view_stack; + +EVEScreen *app_screen(void) { + return &screen; +} + +static int kbd_touch(EVEView *v, uint8_t tag0, int touch_idx) { + EVEKbd *kbd = v->param; + + return eve_kbd_touch(kbd, tag0, touch_idx); +} + +static uint8_t kbd_draw(EVEView *v, uint8_t tag0) { + EVEKbd *kbd = v->param; + + eve_kbd_draw(kbd); + return tag0; +} + +void app_root_init(eve_view_constructor_t home_page) { + EVERect g; + + _app_font_default = &font; + eos_spi_dev_start(EOS_DEV_DISP); + + eve_brightness(0x40); + + eve_font_init(&font, APP_FONT_HANDLE); + eve_screen_init(&screen, APP_SCREEN_W, APP_SCREEN_H); + + eve_kbd_init(&kbd, NULL, screen.mem_next, &screen.mem_next); + eve_screen_set_kbd(&screen, &kbd); + + g.x = 0; + g.y = 0; + g.w = APP_SCREEN_W; + g.h = APP_STATUS_H; + eve_window_init(&win_status, &g, &screen, "status"); + eve_view_init(&view_status, &win_status, app_status_touch, app_status_draw, NULL); + + g.x = 0; + g.y = APP_STATUS_H; + g.w = APP_SCREEN_W; + g.h = APP_SCREEN_H - APP_STATUS_H; + eve_window_init(&win_main, &g, &screen, "main"); + + eve_window_init(&win_kbd, &kbd.g, &screen, "kbd"); + eve_view_init(&view_kbd, &win_kbd, kbd_touch, kbd_draw, &kbd); + + eve_view_stack_init(&view_stack); + eve_view_create(&win_main, &view_stack, home_page); + + eve_window_append(&win_status); + eve_window_append(&win_main); + eve_window_append(&win_kbd); + + eve_screen_hide_kbd(&screen); + eve_screen_draw(&screen); + + eos_spi_dev_stop(); + + eos_net_acquire_for_evt(EOS_EVT_UI | EVE_ETYPE_INTR, 1); +} static void widgets_destroy(EVEWidget *widget, uint16_t widget_size) { int i; @@ -40,7 +100,7 @@ static void widgets_destroy(EVEWidget *widget, uint16_t widget_size) { } } -EVEForm *app_form_create(EVEWindow *window, EVEPageStack *stack, APPWidgetSpec spec[], uint16_t spec_size, eve_page_destructor_t destructor) { +EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, APPWidgetSpec spec[], uint16_t spec_size, eve_page_destructor_t destructor) { EVEWidget *widgets; EVEWidget *widget; EVELabel *label; @@ -97,38 +157,3 @@ void app_form_destroy(EVEForm *form) { eve_free(form->widget); eve_free(form); } - -void app_root_init(eve_page_constructor_t home_page) { - EVERect g; - - _app_font_default = &font; - eos_spi_dev_start(EOS_DEV_DISP); - - eve_brightness(0x40); - eve_font_init(&font, APP_FONT_HANDLE); - eve_screen_init(&screen, APP_SCREEN_W, APP_SCREEN_H); - - g.x = 0; - g.y = 0; - g.w = APP_SCREEN_W; - g.h = APP_STATUS_H; - eve_window_init(&win_status, &g, &view_status, &screen); - g.x = 0; - g.y = APP_STATUS_H; - g.w = APP_SCREEN_W; - g.h = APP_SCREEN_H - APP_STATUS_H; - eve_window_init(&win_main, &g, NULL, &screen); - eve_kbdwin_init(&win_kbd, &screen); - - eve_page_stack_init(&page_stack); - eve_page_create(&win_main, &page_stack, home_page); - - eve_window_append(&win_status); - eve_window_append(&win_main); - eve_kbdwin_append(&win_kbd); - eve_screen_draw(&screen); - - eos_spi_dev_stop(); - - eos_net_acquire_for_evt(EOS_EVT_UI | EVE_ETYPE_INTR, 1); -} -- cgit v1.2.3