Refactor app to use 'screen with widgets' rather than 'widgets'

This commit is contained in:
Pim van Pelt
2017-11-26 15:01:59 +01:00
parent 3e2e9d4e5b
commit fd68b1ec03
11 changed files with 134 additions and 104 deletions

View File

@ -2,6 +2,7 @@
#define __MONGOOSE_TOUCH_H
#include "widget.h"
#include "screen.h"
void widget_time_ev(int ev, struct widget_t *w, void *ev_data);

View File

@ -24,5 +24,6 @@ struct widget_t *screen_widget_add_from_file(struct screen_t *s, char *fn);
bool screen_widget_destroy(struct screen_t *s, struct widget_t **w);
uint16_t screen_get_num_widgets(struct screen_t *s);
struct widget_t *screen_widget_find_by_xy(struct screen_t *s, uint16_t x, uint16_t y);
#endif //__SCREEN_H

View File

@ -17,6 +17,7 @@ struct widget_t;
typedef void (*widget_event_fn)(int ev, struct widget_t *w, void *ev_data);
struct widget_t {
char *name;
uint16_t x, y, w, h;
uint32_t timer_msec; // 0 to disable
@ -32,14 +33,14 @@ struct widget_list_t {
SLIST_ENTRY(widget_list_t) entries;
};
struct widget_t *widget_add(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint32_t timer_msec, widget_event_fn handler, void *user_data);
struct widget_t *widget_add_from_file(const char *fn, uint32_t timer_msec, widget_event_fn handler, void *user_data);
/*
struct widget_t *widget_find(uint16_t x, uint16_t y);
void widget_remove(struct widget_t *widget);
*/
struct widget_t *widget_create(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint32_t timer_msec, widget_event_fn handler, void *user_data);
struct widget_t *widget_create_from_file(const char *fn);
struct widget_t *widget_create(char *name, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint32_t timer_msec, widget_event_fn handler, void *user_data);
struct widget_t *widget_create_from_json(const char *json);
struct widget_t *widget_create_from_file(const char *fn);
void widget_destroy(struct widget_t **widget);