diff options
author | Uros Majstorovic <majstor@majstor.org> | 2020-06-06 22:58:53 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2020-06-06 22:58:53 +0200 |
commit | 4ed8eb19f573d15b1b0526b2588bf20758b4f374 (patch) | |
tree | ccc78f878103f76a84157fc5ad64e1d3f93cc2e0 /code/fe310/eos/eve/widget | |
parent | 6ec81884f4c22f789a7b77f7eb77e01ada971464 (diff) |
tile -> window; opverlapping windows added
Diffstat (limited to 'code/fe310/eos/eve/widget')
-rw-r--r-- | code/fe310/eos/eve/widget/page.c | 12 | ||||
-rw-r--r-- | code/fe310/eos/eve/widget/page.h | 4 | ||||
-rw-r--r-- | code/fe310/eos/eve/widget/text.c | 49 | ||||
-rw-r--r-- | code/fe310/eos/eve/widget/text.h | 4 | ||||
-rw-r--r-- | code/fe310/eos/eve/widget/widget.c | 10 | ||||
-rw-r--r-- | code/fe310/eos/eve/widget/widget.h | 9 |
6 files changed, 41 insertions, 47 deletions
diff --git a/code/fe310/eos/eve/widget/page.c b/code/fe310/eos/eve/widget/page.c index 4b78b3b..07a59b4 100644 --- a/code/fe310/eos/eve/widget/page.c +++ b/code/fe310/eos/eve/widget/page.c @@ -5,21 +5,21 @@ #include "eve_kbd.h" #include "screen/screen.h" -#include "screen/tile.h" +#include "screen/window.h" #include "screen/page.h" #include "widget.h" #include "page.h" -void eve_pagew_init(EVEPageWidget *widget, int16_t x, int16_t y, uint16_t w, uint16_t h, uint8_t font_id, char *title, EVEPage *page) { +void eve_pagew_init(EVEPageWidget *widget, EVERect *g, uint8_t font_id, char *title, EVEPage *page) { memset(widget, 0, sizeof(EVEPageWidget)); - eve_widget_init(&widget->w, EVE_WIDGET_TYPE_PAGE, x, y, w, h, eve_pagew_touch, eve_pagew_draw, NULL); + eve_widget_init(&widget->w, EVE_WIDGET_TYPE_PAGE, g, eve_pagew_touch, eve_pagew_draw, NULL); widget->font_id = font_id; widget->title = title; widget->page = page; } -int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx, EVEPageFocus *focus) { +int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx, EVERect *focus) { EVEPageWidget *widget = (EVEPageWidget *)_widget; EVETouch *t; uint16_t evt; @@ -33,7 +33,7 @@ int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_i if (page && page->handle_evt) page->handle_evt(page, _widget, t, evt, tag0, touch_idx); } else if (evt & EVE_TOUCH_ETYPE_TAG_UP) { widget->page->open(widget->page, page); - if (focus) eve_page_widget_focus(focus, _widget); + if (focus) *focus = _widget->g; } ret = 1; } @@ -48,7 +48,7 @@ uint8_t eve_pagew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) { if (draw) { widget->tag = tag0; if (widget->tag) eve_cmd_dl(TAG(widget->tag)); - eve_cmd(CMD_TEXT, "hhhhs", _widget->x, _widget->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->tag; diff --git a/code/fe310/eos/eve/widget/page.h b/code/fe310/eos/eve/widget/page.h index 3b6be70..a0b3e02 100644 --- a/code/fe310/eos/eve/widget/page.h +++ b/code/fe310/eos/eve/widget/page.h @@ -8,6 +8,6 @@ typedef struct EVEPageWidget { uint8_t font_id; } EVEPageWidget; -void eve_pagew_init(EVEPageWidget *widget, int16_t x, int16_t y, uint16_t w, uint16_t h, uint8_t font_id, char *title, EVEPage *page); -int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx, EVEPageFocus *focus); +void eve_pagew_init(EVEPageWidget *widget, EVERect *g, uint8_t font_id, char *title, EVEPage *page); +int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx, EVERect *focus); uint8_t eve_pagew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
\ No newline at end of file diff --git a/code/fe310/eos/eve/widget/text.c b/code/fe310/eos/eve/widget/text.c index ecdfb32..2d80bbc 100644 --- a/code/fe310/eos/eve/widget/text.c +++ b/code/fe310/eos/eve/widget/text.c @@ -5,7 +5,7 @@ #include "eve_kbd.h" #include "screen/screen.h" -#include "screen/tile.h" +#include "screen/window.h" #include "screen/page.h" #include "screen/font.h" @@ -26,9 +26,9 @@ #define PAGE_WIN_X(p) (p ? p->win_x : 0) -void eve_textw_init(EVETextWidget *widget, int16_t x, int16_t y, uint16_t w, uint16_t h, EVEFont *font, char *text, uint64_t text_size, uint16_t *line, uint16_t line_size) { +void eve_textw_init(EVETextWidget *widget, EVERect *g, EVEFont *font, char *text, uint64_t text_size, uint16_t *line, uint16_t line_size) { memset(widget, 0, sizeof(EVETextWidget)); - eve_widget_init(&widget->w, EVE_WIDGET_TYPE_TEXT, x, y, w, h, eve_textw_touch, eve_textw_draw, eve_textw_putc); + eve_widget_init(&widget->w, EVE_WIDGET_TYPE_TEXT, g, eve_textw_touch, eve_textw_draw, eve_textw_putc); widget->text = text; widget->text_size = text_size; widget->line = line; @@ -39,7 +39,7 @@ void eve_textw_init(EVETextWidget *widget, int16_t x, int16_t y, uint16_t w, uin static EVETextCursor *cursor_prox(EVETextWidget *widget, EVETextCursor *cursor, EVEPage *page, EVETouch *t, short *dx, short *dl) { EVEWidget *_widget = (EVEWidget *)widget; - int x = t->x0 + PAGE_WIN_X(page) - _widget->x; + int x = t->x0 + PAGE_WIN_X(page) - _widget->g.x; int l = (int)t->tag0 - widget->tag0 + widget->line0; int _dx, _dl; @@ -52,7 +52,7 @@ static EVETextCursor *cursor_prox(EVETextWidget *widget, EVETextCursor *cursor, return NULL; } -int eve_textw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx, EVEPageFocus *focus) { +int eve_textw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx, EVERect *focus) { EVETextWidget *widget = (EVETextWidget *)_widget; EVETouch *t; uint16_t evt; @@ -123,11 +123,10 @@ int eve_textw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_i ret = 1; } if (widget->cursor_f && focus) { - focus->f.x = _widget->x; - focus->f.y = _widget->y + widget->cursor_f->line * widget->font->h; - focus->f.w = _widget->w; - focus->f.h = 2 * widget->font->h; - focus->w = _widget; + focus->x = _widget->g.x; + focus->y = _widget->g.y + widget->cursor_f->line * widget->font->h; + focus->w = _widget->g.w; + focus->h = 2 * widget->font->h; widget->cursor_f = NULL; } return ret; @@ -143,12 +142,12 @@ static void _draw_line(EVETextWidget *widget, uint16_t l, uint16_t ch, uint16_t } eve_cmd_dl(BEGIN(EVE_RECTS)); if (!s) eve_cmd_dl(COLOR_MASK(0 ,0 ,0 ,0)); - eve_cmd_dl(VERTEX2F(_widget->x + x1, _widget->y + l * widget->font->h)); - eve_cmd_dl(VERTEX2F(_widget->x + x2, _widget->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)); if (len) { if (s) eve_cmd_dl(COLOR_RGB(0, 0, 0)); - eve_cmd(CMD_TEXT, "hhhhpb", _widget->x, _widget->y + l * widget->font->h, widget->font->id, 0, widget->text + ch, len, 0); + eve_cmd(CMD_TEXT, "hhhhpb", _widget->g.x, _widget->g.y + l * widget->font->h, widget->font->id, 0, widget->text + ch, len, 0); if (s) eve_cmd_dl(COLOR_RGB(255, 255, 255)); } } @@ -158,8 +157,8 @@ static void _draw_cursor(EVETextWidget *widget, EVETextCursor *cursor) { uint16_t x, y; EVEWidget *_widget = (EVEWidget *)widget; - x = _widget->x + cursor->x; - y = _widget->y + cursor->line * widget->font->h; + x = _widget->g.x + cursor->x; + 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)); @@ -189,8 +188,8 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) { if (page) { int _line0, _lineN; - _line0 = line0 = ((int)page->win_y - _widget->y) / widget->font->h; - _lineN = lineN = ((int)page->win_y + page->tile->h - _widget->y) / widget->font->h + 1; + _line0 = line0 = ((int)page->win_y - _widget->g.y) / widget->font->h; + _lineN = lineN = ((int)page->win_y + page->window->g.h - _widget->g.y) / widget->font->h + 1; if (line0 < 0) line0 = 0; if (lineN < 0) lineN = 0; if (line0 > widget->line_len) line0 = widget->line_len; @@ -226,9 +225,9 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) { s = 1; } _draw_line(widget, i, LINE_START(widget, i), l1, 0, c1->x, 0); - _draw_line(widget, i, c1->ch, l2, c1->x, s ? _widget->w : c2->x, 1); + _draw_line(widget, i, c1->ch, l2, c1->x, s ? _widget->g.w : c2->x, 1); if (!s) { - _draw_line(widget, i, c2->ch, l3, c2->x, _widget->w, 0); + _draw_line(widget, i, c2->ch, l3, c2->x, _widget->g.w, 0); c1 = NULL; c2 = NULL; } @@ -237,12 +236,12 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) { int l2 = LINE_START(widget, i) + LINE_LEN(widget, i) - c2->ch; _draw_line(widget, i, LINE_START(widget, i), l1, 0, c2->x, 1); - _draw_line(widget, i, c2->ch, l2, c2->x, _widget->w, 0); + _draw_line(widget, i, c2->ch, l2, c2->x, _widget->g.w, 0); c1 = NULL; c2 = NULL; s = 0; } else { - _draw_line(widget, i, LINE_START(widget, i), LINE_LEN(widget, i), 0, _widget->w, s); + _draw_line(widget, i, LINE_START(widget, i), LINE_LEN(widget, i), 0, _widget->g.w, s); } if (widget->tagN && (widget->tagN < 0xfe)) widget->tagN++; } @@ -250,7 +249,7 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) { if (widget->cursor1.on && (widget->cursor1.line >= line0) && (widget->cursor1.line < lineN)) _draw_cursor(widget, &widget->cursor1); if (widget->cursor2.on && (widget->cursor2.line >= line0) && (widget->cursor2.line < lineN)) _draw_cursor(widget, &widget->cursor2); if (lineNvisible) { - _draw_line(widget, lineN, 0, 0, 0, _widget->w, 0); + _draw_line(widget, lineN, 0, 0, 0, _widget->g.w, 0); } else if (widget->tagN) { widget->tagN--; } @@ -365,7 +364,7 @@ int eve_textw_update(EVETextWidget *widget, uint16_t line) { } else { return EVE_ERR_TEXT; } - if ((line_w > _widget->w) && (line_b != LINE_EMPTY)) { + if ((line_w > _widget->g.w) && (line_b != LINE_EMPTY)) { if (widget->line[line] == line_b) return line; widget->line[line] = line_b; line++; @@ -383,7 +382,7 @@ int eve_textw_update(EVETextWidget *widget, uint16_t line) { widget->text_len = i; widget->line_len = line; - _widget->h = (line + 1) * widget->font->h; + _widget->g.h = (line + 1) * widget->font->h; for (i=line; i<widget->line_size; i++) { widget->line[i] = LINE_EMPTY; } @@ -417,7 +416,7 @@ void eve_textw_cursor_set(EVETextWidget *widget, EVETextCursor *cursor, uint8_t return; } - x -= _widget->x; + x -= _widget->g.x; _x = 0; _d = x; for (i=LINE_START(widget, cursor->line); i<LINE_END(widget, cursor->line); i++) { diff --git a/code/fe310/eos/eve/widget/text.h b/code/fe310/eos/eve/widget/text.h index 83b131d..57798ee 100644 --- a/code/fe310/eos/eve/widget/text.h +++ b/code/fe310/eos/eve/widget/text.h @@ -30,8 +30,8 @@ typedef struct EVETextWidget { } track; } EVETextWidget; -void eve_textw_init(EVETextWidget *widget, int16_t x, int16_t y, uint16_t w, uint16_t h, EVEFont *font, char *text, uint64_t text_size, uint16_t *line, uint16_t line_size); -int eve_textw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx, EVEPageFocus *focus); +void eve_textw_init(EVETextWidget *widget, EVERect *g, EVEFont *font, char *text, uint64_t text_size, uint16_t *line, uint16_t line_size); +int eve_textw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx, EVERect *focus); uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0); void eve_textw_putc(void *_w, int c); int eve_textw_update(EVETextWidget *widget, uint16_t line); diff --git a/code/fe310/eos/eve/widget/widget.c b/code/fe310/eos/eve/widget/widget.c index 44de4c6..79a1b25 100644 --- a/code/fe310/eos/eve/widget/widget.c +++ b/code/fe310/eos/eve/widget/widget.c @@ -1,10 +1,11 @@ #include <stdlib.h> +#include <string.h> #include "eve.h" #include "eve_kbd.h" #include "screen/screen.h" -#include "screen/tile.h" +#include "screen/window.h" #include "screen/page.h" #include "screen/font.h" @@ -18,12 +19,9 @@ static const size_t _eve_wsize[] = { sizeof(EVEPageWidget) }; -void eve_widget_init(EVEWidget *widget, uint8_t type, int16_t x, int16_t y, uint16_t w, uint16_t h, 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, eve_widget_touch_t touch, eve_widget_draw_t draw, eve_kbd_input_handler_t putc) { widget->type = type; - widget->x = x; - widget->y = y; - widget->w = w; - widget->h = h; + if (g) widget->g = *g; widget->touch = touch; widget->draw = draw; widget->putc = putc; diff --git a/code/fe310/eos/eve/widget/widget.h b/code/fe310/eos/eve/widget/widget.h index 8960e63..e6ea7a7 100644 --- a/code/fe310/eos/eve/widget/widget.h +++ b/code/fe310/eos/eve/widget/widget.h @@ -5,19 +5,16 @@ struct EVEWidget; -typedef int (*eve_widget_touch_t) (struct EVEWidget *, EVEPage *, uint8_t, int, EVEPageFocus *); +typedef int (*eve_widget_touch_t) (struct EVEWidget *, EVEPage *, uint8_t, int, EVERect *); typedef uint8_t (*eve_widget_draw_t) (struct EVEWidget *, EVEPage *, uint8_t); typedef struct EVEWidget { uint8_t type; - int16_t x; - int16_t y; - uint16_t w; - uint16_t h; + EVERect g; eve_widget_touch_t touch; eve_widget_draw_t draw; eve_kbd_input_handler_t putc; } EVEWidget; -void eve_widget_init(EVEWidget *widget, uint8_t type, int16_t x, int16_t y, uint16_t w, uint16_t h, 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, eve_widget_touch_t touch, eve_widget_draw_t draw, eve_kbd_input_handler_t putc); EVEWidget *eve_widget_next(EVEWidget *widget); |