diff options
author | Uros Majstorovic <majstor@majstor.org> | 2021-03-24 23:13:42 +0100 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2021-03-24 23:13:42 +0100 |
commit | 95f69d4f83ad8f7fbb56349f29e902928510362b (patch) | |
tree | 51f4848b0518d138368af30f8e7abeebb89ebd5f /fw/fe310/eos/app | |
parent | 8c61343677d2ed8f929372863016524707b8ab93 (diff) |
window hierarchy
Diffstat (limited to 'fw/fe310/eos/app')
-rw-r--r-- | fw/fe310/eos/app/Makefile | 2 | ||||
-rw-r--r-- | fw/fe310/eos/app/app_form.c | 5 | ||||
-rw-r--r-- | fw/fe310/eos/app/app_root.c | 86 | ||||
-rw-r--r-- | fw/fe310/eos/app/app_root.h (renamed from fw/fe310/eos/app/app_screen.h) | 7 | ||||
-rw-r--r-- | fw/fe310/eos/app/app_screen.c | 94 | ||||
-rw-r--r-- | fw/fe310/eos/app/app_status.c | 10 |
6 files changed, 96 insertions, 108 deletions
diff --git a/fw/fe310/eos/app/Makefile b/fw/fe310/eos/app/Makefile index f1dbf70..9560fd7 100644 --- a/fw/fe310/eos/app/Makefile +++ b/fw/fe310/eos/app/Makefile @@ -2,7 +2,7 @@ include ../../common.mk CFLAGS += -I.. -obj = app_screen.o app_status.o app_form.o +obj = app_root.o app_status.o app_form.o %.o: %.c %.h diff --git a/fw/fe310/eos/app/app_form.c b/fw/fe310/eos/app/app_form.c index c7056e0..5d59833 100644 --- a/fw/fe310/eos/app/app_form.c +++ b/fw/fe310/eos/app/app_form.c @@ -6,15 +6,12 @@ #include "eve/eve_kbd.h" #include "eve/eve_font.h" -#include "eve/screen/screen.h" #include "eve/screen/window.h" -#include "eve/screen/view.h" #include "eve/screen/page.h" #include "eve/screen/form.h" #include "eve/widget/widgets.h" -#include "app_screen.h" #include "app_form.h" static EVEFont font; @@ -77,7 +74,7 @@ EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, EVEWidgetSpec s if (label->g.w == 0) label->g.w = eve_font_str_w(_font, label->title); } 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); + if (widget->g.w == 0) widget->g.w = window->g.w - (widget->label ? widget->label->g.w : 0); widget = eve_widget_next(widget); } diff --git a/fw/fe310/eos/app/app_root.c b/fw/fe310/eos/app/app_root.c new file mode 100644 index 0000000..f30c8d4 --- /dev/null +++ b/fw/fe310/eos/app/app_root.c @@ -0,0 +1,86 @@ +#include <stdlib.h> + +#include "net.h" +#include "unicode.h" + +#include "eve/eve.h" +#include "eve/eve_kbd.h" +#include "eve/eve_font.h" + +#include "eve/screen/window.h" +#include "eve/screen/page.h" +#include "eve/screen/form.h" + +#include "eve/widget/widgets.h" + +#include "app_status.h" +#include "app_root.h" + +#define KBD_X 0 +#define KBD_Y 575 +#define KBD_W 480 +#define KBD_H 225 + +static EVEKbd kbd; +static EVEWindowRoot win_root; +static EVEWindowKbd win_kbd; +static EVEWindow win_status; +static EVEWindow win_main; +static EVEView view_status; +static EVEViewStack view_stack; + +EVEWindow *app_root(void) { + return (EVEWindow *)&win_root; +} + +void app_root_refresh(void) { + eve_spi_start(); + eve_window_root_draw(app_root()); + eve_spi_stop(); +} + +void app_root_init(eve_view_constructor_t home_page) { + EVERect g; + + eve_spi_start(); + + eve_brightness(0x40); + + g.x = 0; + g.y = 0; + g.w = APP_SCREEN_W; + g.h = APP_SCREEN_H; + eve_window_init_root(&win_root, &g, "root"); + + g.x = KBD_X; + g.y = KBD_Y; + g.w = KBD_W; + g.h = KBD_H; + eve_kbd_init(&kbd, &g, win_root.mem_next, &win_root.mem_next); + eve_window_init_kbd(&win_kbd, &g, &win_root, "kbd", &kbd); + + g.x = 0; + g.y = 0; + g.w = APP_SCREEN_W; + g.h = APP_STATUS_H; + eve_window_init(&win_status, &g, (EVEWindow *)&win_root, "status"); + eve_view_init(&view_status, &win_status, app_status_draw, app_status_touch, 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, (EVEWindow *)&win_root, "main"); + + 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_root_draw((EVEWindow *)&win_root); + + eve_spi_stop(); + + eos_net_acquire_for_evt(EOS_EVT_UI | EVE_ETYPE_INTR, 1); +} diff --git a/fw/fe310/eos/app/app_screen.h b/fw/fe310/eos/app/app_root.h index 1e266d4..2a51c77 100644 --- a/fw/fe310/eos/app/app_screen.h +++ b/fw/fe310/eos/app/app_root.h @@ -4,6 +4,7 @@ #define APP_SCREEN_H 800 #define APP_STATUS_H 60 -EVEScreen *app_screen(void); -void app_screen_init(eve_view_constructor_t home_page); -void app_screen_refresh(void); +EVEWindow *app_root(void); +void app_root_refresh(void); + +void app_root_init(eve_view_constructor_t home_page); diff --git a/fw/fe310/eos/app/app_screen.c b/fw/fe310/eos/app/app_screen.c deleted file mode 100644 index 9f3a236..0000000 --- a/fw/fe310/eos/app/app_screen.c +++ /dev/null @@ -1,94 +0,0 @@ -#include <stdlib.h> - -#include "net.h" -#include "unicode.h" - -#include "eve/eve.h" -#include "eve/eve_kbd.h" -#include "eve/eve_font.h" - -#include "eve/screen/screen.h" -#include "eve/screen/window.h" -#include "eve/screen/view.h" -#include "eve/screen/page.h" -#include "eve/screen/form.h" - -#include "eve/widget/widgets.h" - -#include "app_status.h" -#include "app_screen.h" - -static EVEKbd kbd; -static EVEScreen screen; -static EVEWindow win_status; -static EVEWindow win_main; -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, EVETouch *touch, uint16_t evt, uint8_t tag0) { - EVEKbd *kbd = v->param; - - return eve_kbd_touch(kbd, touch, evt, tag0); -} - -static uint8_t kbd_draw(EVEView *v, uint8_t tag0) { - EVEKbd *kbd = v->param; - - eve_kbd_draw(kbd); - return tag0; -} - -void app_screen_refresh(void) { - eve_spi_start(); - eve_screen_draw(app_screen()); - eve_spi_stop(); -} - -void app_screen_init(eve_view_constructor_t home_page) { - EVERect g; - - eve_spi_start(); - - eve_brightness(0x40); - - 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); - - eve_spi_stop(); - - eos_net_acquire_for_evt(EOS_EVT_UI | EVE_ETYPE_INTR, 1); -} diff --git a/fw/fe310/eos/app/app_status.c b/fw/fe310/eos/app/app_status.c index 3fdb45a..11cc36d 100644 --- a/fw/fe310/eos/app/app_status.c +++ b/fw/fe310/eos/app/app_status.c @@ -5,16 +5,14 @@ #include "eve/eve.h" #include "eve/eve_kbd.h" -#include "eve/screen/screen.h" #include "eve/screen/window.h" -#include "eve/screen/view.h" #include "app_status.h" -int app_status_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0) { - return 0; +uint8_t app_status_draw(EVEView *view, uint8_t tag0) { + return eve_view_clear(view, tag0); } -uint8_t app_status_draw(EVEView *view, uint8_t tag0) { - return tag0; +int app_status_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0) { + return 0; } |