Kestrel Interface
Loading...
Searching...
No Matches
kest_ui.h
Go to the documentation of this file.
1#ifndef KEST_ESP_UI_H_
2#define KEST_ESP_UI_H_
3
4#include "kest_linked_list.h"
5#include "kest_button.h"
6
7#ifdef USE_5A
8#define DISPLAY_VRES 1280
9#define DISPLAY_HRES 720
10#else
11#define DISPLAY_VRES 1024
12#define DISPLAY_HRES 600
13#endif
14
15#define TOP_PANEL_HEIGHT ((int)(0.08 * DISPLAY_VRES))
16#define TOP_PANEL_COLOUR 0x313131
17
18#define GLOBAL_MAIN_TEXT_COLOUR 0xFFFFFF
19#define GLOBAL_MAIN_FONT &lv_font_montserrat_28
20
21#define GLOBAL_BACKGROUND_COLOUR 0x222222
22
23#define UI_PAGE_TRANSITION_ANIM_MS 175
24
25#define BACK_BUTTON_VSIZE ((int)(0.06 * DISPLAY_VRES))
26#define BACK_BUTTON_HSIZE BACK_BUTTON_HSIZE
27
28#define STANDARD_TOP_PANEL_BUTTON_WIDTH (TOP_PANEL_HEIGHT * 0.7)
29#define STANDARD_TOP_PANEL_BUTTON_HEIGHT (TOP_PANEL_HEIGHT * 0.7)
30
31#define GLOBAL_PAD_WIDTH ((int)(0.02 * DISPLAY_VRES))
32
33#define H_PAD ((int)(0.067 * DISPLAY_HRES))
34#define V_PAD ((int)(0.04 * DISPLAY_VRES))
35
36#define STANDARD_YPOS (-(int)(0.02 * DISPLAY_VRES))
37
38#define STANDARD_CONTAINER_WIDTH ((int)(0.83 * DISPLAY_HRES))
39#define STANDARD_CONTAINER_HEIGHT ((int)(0.75 * DISPLAY_VRES))
40#define STANDARD_CONTAINER_TALL_HEIGHT ((int)(0.85 * DISPLAY_VRES))
41
43
44#define TOP_PANEL_FLAG_RW_TITLE 0b1
45
46typedef struct
47{
48 int flags;
49
50 lv_obj_t *panel;
51 lv_obj_t *title;
52
55
56 lv_obj_t *left_button;
58 lv_obj_t *right_button;
60 char *text;
61
62 lv_event_cb_t rw_save_cb;
63 lv_event_cb_t rw_cancel_cb;
65
67
68#define MAX_BOTTOM_BUTTONS 6
69#define BOTTOM_BUTTON_PADDING GLOBAL_PAD_WIDTH
70
71#define CONTAINER_TYPE_STD 0
72#define CONTAINER_TYPE_STD_BTN_LIST 1
73#define CONTAINER_TYPE_STD_MENU 2
74
75#define KEST_UI_PAGE_GENERIC 0
76#define KEST_UI_PAGE_MAIN_MENU 1
77#define KEST_UI_PAGE_SEQ_LIST 2
78#define KEST_UI_PAGE_MSV 3
79#define KEST_UI_PAGE_SEQ_VIEW 4
80#define KEST_UI_PAGE_PROF_VIEW 5
81#define KEST_UI_PAGE_TRANS_VIEW 6
82#define KEST_UI_PAGE_TRANS_SET 7
83
84typedef struct kest_ui_page
85{
86 int type;
87 int id;
88
89 lv_obj_t *screen;
90
92 lv_obj_t *container;
93
95
96 int (*configure) (struct kest_ui_page *page, void *data);
97 int (*create_ui) (struct kest_ui_page *page);
98 int (*free_ui) (struct kest_ui_page *page);
99 int (*free_all) (struct kest_ui_page *page);
100 int (*enter_page) (struct kest_ui_page *page);
101 int (*enter_page_from) (struct kest_ui_page *page, struct kest_ui_page *prev);
102 int (*refresh) (struct kest_ui_page *page);
103
105
108
110
113
114void kest_create_ui(lv_disp_t *disp);
115
116int init_ui_page(kest_ui_page *page);
118
119int configure_ui_page(kest_ui_page *page, void *data);
121
122int enter_ui_page(kest_ui_page *page);
125
126void enter_ui_page_cb(lv_event_t *e);
127void enter_ui_page_forwards_cb(lv_event_t *e);
133
135
137
141
142int ui_page_add_left_panel_button(kest_ui_page *page, const char *label, lv_event_cb_t cb);
143int ui_page_add_right_panel_button(kest_ui_page *page, const char *label, lv_event_cb_t cb);
144
147
148int ui_page_set_title(kest_ui_page *page, const char *text);
149int ui_page_update_title(kest_ui_page *page, const char *text);
150
151int ui_page_set_title_rw(kest_ui_page *page, lv_event_cb_t ok_cb, lv_event_cb_t cancel_cb);
152
153kest_button *ui_page_add_bottom_button(kest_ui_page *page, const char *label, lv_event_cb_t cb);
154
155int create_standard_container(lv_obj_t **cont, lv_obj_t *parent);
156int create_standard_container_tall(lv_obj_t **cont, lv_obj_t *parent);
157int create_standard_menu_container(lv_obj_t **cont, lv_obj_t *parent);
158int create_standard_menu_container_tall(lv_obj_t **cont, lv_obj_t *parent);
159int create_standard_button_list(lv_obj_t **cont, lv_obj_t *parent);
160int create_standard_button_list_tall(lv_obj_t **cont, lv_obj_t *parent);
161
162int create_standard_button_click(lv_obj_t **obj, lv_obj_t **label, lv_obj_t *parent,
163 char *text, lv_event_cb_t click_cb, void *click_cb_arg);
164int create_standard_button_click_short(lv_obj_t **obj, lv_obj_t **label, lv_obj_t *parent,
165 char *text, lv_event_cb_t click_cb, void *click_cb_arg);
166int create_standard_button_long_press_release(lv_obj_t **obj, lv_obj_t **label, lv_obj_t *parent,
167 char *text, lv_event_cb_t press_cb, void *press_cb_arg, lv_event_cb_t release_cb, void *release_cb_arg);
168
169int create_panel(kest_ui_page *page);
170int set_panel_text(kest_ui_page *page, const char *text);
171int set_panel_text_rw(kest_ui_page *page, const char *text);
172int create_panel_rw_title(kest_ui_page *page, const char *text);
173int create_panel_left_button(kest_ui_page *page, const char *button_text, lv_event_cb_t cb, void *cb_arg);
174int create_panel_right_button(kest_ui_page *page, const char *button_text, lv_event_cb_t cb, void *cb_arg);
175int create_panel_rw_title_and_left_button(kest_ui_page *page, const char *text, const char *left_button_text, lv_event_cb_t left_cb, void *left_cb_arg);
178int create_panel_with_back_button_and_right_button(kest_ui_page *page, const char *right_button_text, lv_event_cb_t right_cb, void *cb_arg);
179int create_panel_with_left_button(kest_ui_page *page, const char *left_button_text, lv_event_cb_t left_cb, void *cb_arg);
180int create_panel_with_right_button(kest_ui_page *page, const char *right_button_text, lv_event_cb_t right_cb, void *cb_arg);
181int create_panel_with_back_button_and_page_button(kest_ui_page *page, const char *right_button_text, kest_ui_page *right_button_page);
183 const char *left_button_text, lv_event_cb_t left_cb, void *left_cb_arg,
184 const char *right_button_text, lv_event_cb_t right_cb, void *right_cb_arg);
185
186void spawn_keyboard(lv_obj_t *parent, lv_obj_t *text_area, void (*ok_cb)(lv_event_t*), void *ok_arg, void (*cancel_cb)(lv_event_t*), void *cancel_arg);
187void spawn_numerical_keyboard(lv_obj_t *parent, lv_obj_t *text_area, void (*ok_cb)(lv_event_t*), void *ok_arg, void (*cancel_cb)(lv_event_t*), void *cancel_arg);
188void hide_keyboard_cb(lv_event_t *e);
189void hide_keyboard();
190
191#define PAGE_HISTORY_LEN 64
192
205
207
208typedef lv_obj_t_pll lv_obj_ll;
209
210void enter_parent_page_cb(lv_event_t *e);
211
212extern lv_obj_t *keyboard;
213
214#endif
#define DECLARE_LINKED_PTR_LIST(X)
lv_obj_t * keyboard
Definition kest_ui.c:20
kest_ui_page_panel * new_panel()
Definition kest_ui.c:991
int ui_page_create_container(kest_ui_page *page)
Definition kest_ui.c:1230
int ui_page_add_left_panel_button(kest_ui_page *page, const char *label, lv_event_cb_t cb)
Definition kest_ui.c:1171
int enter_ui_page_forwards(kest_ui_page *page)
Definition kest_ui.c:299
int ui_page_add_back_button(kest_ui_page *page)
Definition kest_ui.c:1129
int create_panel_with_left_and_right_buttons(kest_ui_page *page, const char *left_button_text, lv_event_cb_t left_cb, void *left_cb_arg, const char *right_button_text, lv_event_cb_t right_cb, void *right_cb_arg)
Definition kest_ui.c:721
int create_standard_button_click_short(lv_obj_t **obj, lv_obj_t **label, lv_obj_t *parent, char *text, lv_event_cb_t click_cb, void *click_cb_arg)
Definition kest_ui.c:928
kest_button * ui_page_add_bottom_button(kest_ui_page *page, const char *label, lv_event_cb_t cb)
Definition kest_ui.c:1308
void hide_keyboard()
Definition kest_ui.c:769
int create_panel_rw_title_and_left_button(kest_ui_page *page, const char *text, const char *left_button_text, lv_event_cb_t left_cb, void *left_cb_arg)
Definition kest_ui.c:656
int ui_page_update_title(kest_ui_page *page, const char *text)
Definition kest_ui.c:1014
int ui_page_set_title(kest_ui_page *page, const char *text)
Definition kest_ui.c:1066
int create_standard_menu_container(lv_obj_t **cont, lv_obj_t *parent)
Definition kest_ui.c:820
void enter_ui_page_backwards_forwards_cb(lv_event_t *e)
int create_panel_with_back_and_settings_buttons(kest_ui_page *page, kest_ui_page *settings_page)
Definition kest_ui.c:675
int ui_page_create_base_ui(kest_ui_page *page)
Definition kest_ui.c:1207
int enter_ui_page_indirect(kest_ui_page **_page)
Definition kest_ui.c:411
int create_standard_container_tall(lv_obj_t **cont, lv_obj_t *parent)
Definition kest_ui.c:802
void spawn_numerical_keyboard(lv_obj_t *parent, lv_obj_t *text_area, void(*ok_cb)(lv_event_t *), void *ok_arg, void(*cancel_cb)(lv_event_t *), void *cancel_arg)
Definition kest_ui.c:759
int create_panel_with_right_button(kest_ui_page *page, const char *right_button_text, lv_event_cb_t right_cb, void *cb_arg)
Definition kest_ui.c:697
int create_standard_button_list_tall(lv_obj_t **cont, lv_obj_t *parent)
Definition kest_ui.c:886
int create_standard_menu_container_tall(lv_obj_t **cont, lv_obj_t *parent)
Definition kest_ui.c:841
int create_page_ui(kest_ui_page *page)
Definition kest_ui.c:226
int create_panel_left_button(kest_ui_page *page, const char *button_text, lv_event_cb_t cb, void *cb_arg)
Definition kest_ui.c:612
int enter_ui_page_indirect_forwards(kest_ui_page **_page)
Definition kest_ui.c:421
int create_panel_rw_title(kest_ui_page *page, const char *text)
Definition kest_ui.c:600
int kest_ui_page_add_child(kest_ui_page *page, kest_ui_page *child)
int set_panel_text_rw(kest_ui_page *page, const char *text)
Definition kest_ui.c:573
int create_panel_with_back_button(kest_ui_page *page)
Definition kest_ui.c:670
void kest_ui_page_return_to_parent(kest_ui_page *page)
Definition kest_ui.c:485
int enter_ui_page_indirect_backwards(kest_ui_page **_page)
void spawn_keyboard(lv_obj_t *parent, lv_obj_t *text_area, void(*ok_cb)(lv_event_t *), void *ok_arg, void(*cancel_cb)(lv_event_t *), void *cancel_arg)
Definition kest_ui.c:737
void enter_ui_page_forwards_cb(lv_event_t *e)
Definition kest_ui.c:450
int set_panel_text(kest_ui_page *page, const char *text)
Definition kest_ui.c:541
int enter_ui_page_backwards(kest_ui_page *page)
Definition kest_ui.c:354
int create_panel_with_back_button_and_page_button(kest_ui_page *page, const char *right_button_text, kest_ui_page *right_button_page)
Definition kest_ui.c:709
void hide_keyboard_cb(lv_event_t *e)
Definition kest_ui.c:777
int create_standard_button_click(lv_obj_t **obj, lv_obj_t **label, lv_obj_t *parent, char *text, lv_event_cb_t click_cb, void *click_cb_arg)
Definition kest_ui.c:907
int init_ui_page(kest_ui_page *page)
Definition kest_ui.c:152
int enter_ui_page(kest_ui_page *page)
Definition kest_ui.c:244
int kest_init_global_pages(kest_global_pages *pages)
Definition kest_ui.c:78
int ui_page_create_bottom_buttons(kest_ui_page *page)
Definition kest_ui.c:1271
int create_panel_with_left_button(kest_ui_page *page, const char *left_button_text, lv_event_cb_t left_cb, void *cb_arg)
Definition kest_ui.c:685
void enter_ui_page_cb(lv_event_t *e)
Definition kest_ui.c:441
int create_standard_button_list(lv_obj_t **cont, lv_obj_t *parent)
Definition kest_ui.c:866
#define MAX_BOTTOM_BUTTONS
Definition kest_ui.h:68
int ui_page_add_right_panel_button(kest_ui_page *page, const char *label, lv_event_cb_t cb)
Definition kest_ui.c:1189
void kest_create_ui(lv_disp_t *disp)
Definition kest_ui.c:121
lv_obj_t_pll lv_obj_ll
Definition kest_ui.h:208
int create_standard_button_long_press_release(lv_obj_t **obj, lv_obj_t **label, lv_obj_t *parent, char *text, lv_event_cb_t press_cb, void *press_cb_arg, lv_event_cb_t release_cb, void *release_cb_arg)
Definition kest_ui.c:949
int create_standard_container(lv_obj_t **cont, lv_obj_t *parent)
Definition kest_ui.c:785
int kest_ui_page_set_background_default(kest_ui_page *page)
Definition kest_ui.c:64
int init_ui_page_dp(kest_ui_page **page)
int create_panel_right_button(kest_ui_page *page, const char *button_text, lv_event_cb_t cb, void *cb_arg)
Definition kest_ui.c:634
int ui_page_set_title_rw(kest_ui_page *page, lv_event_cb_t ok_cb, lv_event_cb_t cancel_cb)
Definition kest_ui.c:1335
int create_panel_with_back_button_and_right_button(kest_ui_page *page, const char *right_button_text, lv_event_cb_t right_cb, void *cb_arg)
Definition kest_ui.c:680
int ui_page_add_parent_button(kest_ui_page *page)
Definition kest_ui.c:1150
void enter_parent_page_cb(lv_event_t *e)
Definition kest_ui.c:468
int create_panel(kest_ui_page *page)
Definition kest_ui.c:514
int configure_ui_page(kest_ui_page *page, void *data)
Definition kest_ui.c:197
kest_ui_page * current_page
Definition kest_ui.h:203
kest_ui_page effect_selector
Definition kest_ui.h:195
kest_ui_page main_sequence_view
Definition kest_ui.h:201
kest_ui_page sequence_list
Definition kest_ui.h:200
lv_obj_t * backstage
Definition kest_ui.h:197
kest_ui_page main_menu
Definition kest_ui.h:199
lv_obj_t * right_button_symbol
Definition kest_ui.h:59
lv_obj_t * right_button
Definition kest_ui.h:58
kest_button * lb
Definition kest_ui.h:53
lv_obj_t * panel
Definition kest_ui.h:50
lv_obj_t * title
Definition kest_ui.h:51
lv_obj_t * left_button_symbol
Definition kest_ui.h:57
lv_event_cb_t rw_save_cb
Definition kest_ui.h:62
lv_obj_t * left_button
Definition kest_ui.h:56
lv_event_cb_t rw_cancel_cb
Definition kest_ui.h:63
kest_button * rb
Definition kest_ui.h:54
int(* free_ui)(struct kest_ui_page *page)
Definition kest_ui.h:98
int ui_created
Definition kest_ui.h:107
lv_obj_t * screen
Definition kest_ui.h:89
kest_ui_page_panel * panel
Definition kest_ui.h:94
kest_button * bottom_buttons[MAX_BOTTOM_BUTTONS]
Definition kest_ui.h:111
int(* enter_page_from)(struct kest_ui_page *page, struct kest_ui_page *prev)
Definition kest_ui.h:101
int(* create_ui)(struct kest_ui_page *page)
Definition kest_ui.h:97
int container_type
Definition kest_ui.h:91
lv_obj_t * container
Definition kest_ui.h:92
struct kest_ui_page * parent
Definition kest_ui.h:109
void * data_struct
Definition kest_ui.h:104
int configured
Definition kest_ui.h:106
int(* enter_page)(struct kest_ui_page *page)
Definition kest_ui.h:100
int(* refresh)(struct kest_ui_page *page)
Definition kest_ui.h:102
int(* free_all)(struct kest_ui_page *page)
Definition kest_ui.h:99
int(* configure)(struct kest_ui_page *page, void *data)
Definition kest_ui.h:96