Kestrel Interface
Loading...
Searching...
No Matches
kest_profile_settings.c
Go to the documentation of this file.
1#include "kest_int.h"
2
3#ifndef PRINTLINES_ALLOWED
4#define PRINTLINES_ALLOWED 0
5#endif
6
7static const char *FNAME = "kest_profile_settings.c";
8
10{
11 if (!page)
12 return ERR_NULL_PTR;
13
15
16 if (!str)
17 return ERR_ALLOC_FAIL;
18
19 init_ui_page(page);
20 page->panel = new_panel();
21
22 if (!page->panel)
23 return ERR_NULL_PTR;
24
25 page->data_struct = str;
26
27 str->profile = NULL;
28 page->container = NULL;
29
34 page->enter_page = NULL;//enter_profile_settings_page;
36
37 page->panel = new_panel();
38
39 if (!page->panel)
40 return ERR_ALLOC_FAIL;
41
42 return NO_ERROR;
43}
44
46{
47 if (!page)
48 return ERR_NULL_PTR;
49
51
52 kest_profile *profile = (kest_profile*)data;
53
54 if (!profile)
55 return ERR_BAD_ARGS;
56
57 if (!profile->name)
58 {
60 }
61
62 char buf[128];
63 snprintf(buf, 128, "%s Settings", profile->name);
64
65 page->panel->text = kest_strndup(buf, 128);
66
68
69 if (!str)
70 return ERR_BAD_ARGS;
71
72 str->volume_widget.profile = profile;
73 str->volume_widget.param = &profile->volume;
74 str->volume_widget.id = profile->volume.id;
75
76 str->profile = profile;
77
78 if (profile)
79 {
80 page->parent = profile->view_page;
81 }
82
83 page->configured = 1;
84
85 return NO_ERROR;
86}
87
89{
90 kest_ui_page *page = lv_event_get_user_data(e);
91
92 if (!page)
93 return;
94
96
97 if (!str)
98 return;
99
100 save_profile(str->profile);
101
102 lv_obj_add_flag(str->save_button, LV_OBJ_FLAG_HIDDEN);
103}
104
105void default_profile_button_cb(lv_event_t *e)
106{
107 kest_ui_page *page = lv_event_get_user_data(e);
108
109 if (!page)
110 return;
111
113
114 if (!str)
115 return;
116
117 //set_profile_as_default(&global_cxt, str->profile);
118
119 lv_obj_add_flag(str->default_button, LV_OBJ_FLAG_HIDDEN);
120}
121
123{
124 KEST_PRINTF("create_profile_settings_page_ui\n");
125 if (!page)
126 return ERR_NULL_PTR;
127
128 if (page->ui_created)
129 {
130 KEST_PRINTF("Profile settings page: UI already created...\n");
131 return NO_ERROR;
132 }
133
135
136 if (!str)
137 {
138 KEST_PRINTF("Error! Profile settings page has no data struct!\n");
139 return ERR_BAD_ARGS;
140 }
141
142 if (!str->profile)
143 {
144 KEST_PRINTF("Error! Profile settings page has no profile!\n");
145 return ERR_BAD_ARGS;
146 }
147
149
150 lv_obj_set_flex_align(page->container,
151 LV_FLEX_ALIGN_SPACE_EVENLY,
152 LV_FLEX_ALIGN_CENTER,
153 LV_FLEX_ALIGN_CENTER);
154
156
157 //str->default_button = lv_btn_create(page->screen);
158 //lv_obj_set_size(str->default_button, KEST_BUTTON_WIDTH / 3, KEST_BUTTON_WIDTH);
159 //lv_obj_align(str->default_button, LV_ALIGN_BOTTOM_MID, -STANDARD_CONTAINER_WIDTH / 3, -50);
160
161 //str->default_button_label = lv_label_create(str->default_button);
162 //lv_label_set_text(str->default_button_label, "Set Default");
163 //lv_obj_center(str->default_button_label);
164
165 //if (str->profile->default_profile)
166 //{
167 // lv_obj_add_flag(str->default_button, LV_OBJ_FLAG_HIDDEN);
168 //}
169
170 //lv_obj_add_event_cb(str->default_button, default_profile_button_cb, LV_EVENT_CLICKED, page);
171
172 /*str->plus_button = lv_btn_create(page->screen);
173 lv_obj_set_size(str->plus_button, PROFILE_VIEW_BUTTON_WIDTH / 3, PROFILE_VIEW_BUTTON_HEIGHT);
174 lv_obj_align(str->plus_button, LV_ALIGN_BOTTOM_MID, 0, -50);
175
176 str->plus_button_label = lv_label_create(str->plus_button);
177 lv_label_set_text(str->plus_button_label, "+");
178 lv_obj_center(str->plus_button_label);
179
180 lv_obj_add_event_cb(str->plus_button, enter_effect_selector_cb, LV_EVENT_CLICKED, page);
181
182 str->save_button = lv_btn_create(page->screen);
183 lv_obj_set_size(str->save_button, PROFILE_VIEW_BUTTON_WIDTH / 3, PROFILE_VIEW_BUTTON_HEIGHT);
184 lv_obj_align(str->save_button, LV_ALIGN_BOTTOM_MID, PROFILE_VIEW_TRANSFORMER_LIST_WIDTH / 3, -50);
185
186 str->save_button_label = lv_label_create(str->save_button);
187 lv_label_set_text(str->save_button_label, "Save");
188 lv_obj_center(str->save_button_label);
189
190 lv_obj_add_event_cb(str->save_button, profile_settings_save_button_cb, LV_EVENT_CLICKED, page);*/
191
192 page->ui_created = 1;
193
194 return NO_ERROR;
195}
196
197
199{
200 if (!page)
201 return ERR_NULL_PTR;
202
203 return NO_ERROR;
204}
205
207{
208 if (!page)
209 return ERR_NULL_PTR;
210
211 return NO_ERROR;
212}
213
215{
216 if (!page)
217 return ERR_NULL_PTR;
218
219 return NO_ERROR;
220}
221
223{
224 if (!page)
225 return ERR_NULL_PTR;
226
227 return NO_ERROR;
228}
229
231{
232 if (!page)
233 return ERR_NULL_PTR;
234
235 return NO_ERROR;
236}
237
239{
240 if (!page)
241 return ERR_NULL_PTR;
242
243 return NO_ERROR;
244}
char * kest_strndup(const char *str, size_t n)
Definition kest_alloc.c:73
#define ERR_ALLOC_FAIL
#define ERR_BAD_ARGS
#define NO_ERROR
#define ERR_NULL_PTR
int save_profile(kest_profile *profile)
Definition kest_files.c:883
int parameter_widget_create_ui(kest_parameter_widget *pw, lv_obj_t *parent)
#define KEST_PRINTF(...)
Definition kest_printf.h:10
int kest_profile_set_default_name_from_id(kest_profile *profile)
int init_profile_settings_page(kest_ui_page *page)
int enter_profile_settings_page_back(kest_ui_page *page)
int enter_profile_settings_page_forward(kest_ui_page *page)
void profile_settings_save_button_cb(lv_event_t *e)
int enter_profile_settings_page(kest_ui_page *page)
int refresh_profile_settings_page(kest_ui_page *page)
int create_profile_settings_page_ui(kest_ui_page *page)
int free_profile_settings_page_ui(kest_ui_page *page)
int profile_settings_page_free_all(kest_ui_page *page)
int configure_profile_settings_page(kest_ui_page *page, void *data)
void default_profile_button_cb(lv_event_t *e)
kest_ui_page_panel * new_panel()
Definition kest_ui.c:991
int ui_page_add_back_button(kest_ui_page *page)
Definition kest_ui.c:1129
int ui_page_create_base_ui(kest_ui_page *page)
Definition kest_ui.c:1207
int init_ui_page(kest_ui_page *page)
Definition kest_ui.c:152
struct kest_profile * profile
kest_parameter_id id
kest_parameter_widget volume_widget
kest_parameter volume
int(* free_ui)(struct kest_ui_page *page)
Definition kest_ui.h:98
int ui_created
Definition kest_ui.h:107
kest_ui_page_panel * panel
Definition kest_ui.h:94
int(* create_ui)(struct kest_ui_page *page)
Definition kest_ui.h:97
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