summaryrefslogtreecommitdiff
path: root/code/fe310/eos/eve/widget
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2020-07-02 23:25:35 +0200
committerUros Majstorovic <majstor@majstor.org>2020-07-02 23:25:35 +0200
commitf550a31fda2cb7d76e917ab69d075daa1557bf99 (patch)
tree107b6e78f23ede2054dfcf879345480788a85f29 /code/fe310/eos/eve/widget
parentc25bf68c4702b20aea6ca99eb1edd5aca5f6d391 (diff)
string init/draw implemented; page to screen coordinates implemented
Diffstat (limited to 'code/fe310/eos/eve/widget')
-rw-r--r--code/fe310/eos/eve/widget/str.c31
-rw-r--r--code/fe310/eos/eve/widget/text.c2
2 files changed, 32 insertions, 1 deletions
diff --git a/code/fe310/eos/eve/widget/str.c b/code/fe310/eos/eve/widget/str.c
index bf86d49..a0caa9d 100644
--- a/code/fe310/eos/eve/widget/str.c
+++ b/code/fe310/eos/eve/widget/str.c
@@ -29,7 +29,13 @@
#define CHAR_VALID_INPUT(c) ((c >= 0x20) && (c < 0x7f))
void eve_strw_init(EVEStrWidget *widget, EVERect *g, EVEFont *font, char *str, uint16_t str_size) {
+ EVEWidget *_widget = &widget->w;
+ memset(widget, 0, sizeof(EVEStrWidget));
+ eve_widget_init(_widget, EVE_WIDGET_TYPE_STR, g, eve_strw_touch, eve_strw_draw, eve_strw_putc);
+ widget->font = font;
+ widget->str = str;
+ widget->str_size = str_size;
}
static EVEStrCursor *cursor_prox(EVEStrWidget *widget, EVEStrCursor *cursor, EVEPage *page, EVETouch *t, short *dx) {
@@ -142,7 +148,32 @@ int eve_strw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_id
}
uint8_t eve_strw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
+ EVEStrWidget *widget = (EVEStrWidget *)_widget;
+ int16_t x = _widget->g.x - widget->str_g.x;
+ char cut = widget->str_g.x || (widget->str_g.w > _widget->g.w);
+
+ widget->tag = tag0;
+ if (tag0 != EVE_TAG_NOTAG) {
+ eve_cmd_dl(TAG(tag0));
+ tag0++;
+ }
+
+ if (cut && page) {
+ int16_t x = eve_page_scrx(page, _widget->g.x);
+ int16_t y = eve_page_scrx(page, _widget->g.y);
+
+ if (x < 0) x = 0;
+ if (y < 0) y = 0;
+ eve_cmd_dl(SAVE_CONTEXT());
+ eve_cmd_dl(SCISSOR_XY(x, y));
+ eve_cmd_dl(SCISSOR_SIZE(_widget->g.w, _widget->g.h));
+ }
+ eve_cmd(CMD_TEXT, "hhhhs", x, _widget->g.y, widget->font->id, 0, widget->str);
+ if (cut && page) {
+ eve_cmd_dl(RESTORE_CONTEXT());
+ }
+ return tag0;
}
void eve_strw_putc(void *_page, int c) {
diff --git a/code/fe310/eos/eve/widget/text.c b/code/fe310/eos/eve/widget/text.c
index a424b9d..a389fa7 100644
--- a/code/fe310/eos/eve/widget/text.c
+++ b/code/fe310/eos/eve/widget/text.c
@@ -37,11 +37,11 @@ void eve_textw_init(EVETextWidget *widget, EVERect *g, EVEFont *font, char *text
memset(widget, 0, sizeof(EVETextWidget));
eve_widget_init(_widget, EVE_WIDGET_TYPE_TEXT, g, eve_textw_touch, eve_textw_draw, eve_textw_putc);
+ widget->font = font;
widget->text = text;
widget->text_size = text_size;
widget->line = line;
widget->line_size = line_size;
- widget->font = font;
if (text_size && line_size) eve_textw_update(widget, NULL, 0);
}