57 lines
1.2 KiB
C
57 lines
1.2 KiB
C
|
|
#ifndef BLINKY_UI_SETTINGS_PAGE_H_
|
||
|
|
#define BLINKY_UI_SETTINGS_PAGE_H_
|
||
|
|
|
||
|
|
#include <stdint.h>
|
||
|
|
|
||
|
|
#include <lvgl.h>
|
||
|
|
|
||
|
|
#include "ui_page.h"
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
extern "C" {
|
||
|
|
#endif
|
||
|
|
|
||
|
|
struct ui_settings_page;
|
||
|
|
struct ui_settings_item;
|
||
|
|
|
||
|
|
typedef void (*ui_settings_item_draw_fn)(const struct ui_settings_item *item,
|
||
|
|
lv_obj_t *container);
|
||
|
|
|
||
|
|
struct ui_settings_item {
|
||
|
|
const char *icon;
|
||
|
|
const char *title;
|
||
|
|
const char *value;
|
||
|
|
ui_settings_item_draw_fn draw;
|
||
|
|
void *user_data;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct ui_settings_page_ops {
|
||
|
|
struct ui_page_ops base;
|
||
|
|
|
||
|
|
uint8_t (*get_count)(struct ui_settings_page *page);
|
||
|
|
void (*get_item)(struct ui_settings_page *page, uint8_t index,
|
||
|
|
struct ui_settings_item *item);
|
||
|
|
void (*on_enter)(struct ui_settings_page *page);
|
||
|
|
void (*on_select)(struct ui_settings_page *page, uint8_t index);
|
||
|
|
void (*on_back)(struct ui_settings_page *page);
|
||
|
|
};
|
||
|
|
|
||
|
|
struct ui_settings_page {
|
||
|
|
struct ui_page base;
|
||
|
|
const struct ui_settings_page_ops *ops;
|
||
|
|
const char *title;
|
||
|
|
const char *hint;
|
||
|
|
uint8_t selected;
|
||
|
|
};
|
||
|
|
|
||
|
|
static inline struct ui_settings_page *ui_page_to_settings(struct ui_page *page)
|
||
|
|
{
|
||
|
|
return (struct ui_settings_page *)page;
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#endif /* BLINKY_UI_SETTINGS_PAGE_H_ */
|