495 lines
24 KiB
C
495 lines
24 KiB
C
/**
|
|
* @file lv_demo_widgets_profile.c
|
|
*
|
|
*/
|
|
|
|
/*********************
|
|
* INCLUDES
|
|
*********************/
|
|
#include "lv_demo_widgets_profile.h"
|
|
#if LV_USE_DEMO_WIDGETS
|
|
|
|
#include "lv_demo_widgets_components.h"
|
|
|
|
/*********************
|
|
* DEFINES
|
|
*********************/
|
|
|
|
/**********************
|
|
* TYPEDEFS
|
|
**********************/
|
|
|
|
/**********************
|
|
* STATIC PROTOTYPES
|
|
**********************/
|
|
static void ta_event_cb(lv_event_t * e);
|
|
static void slider_event_cb(lv_event_t * e);
|
|
static void birthday_event_cb(lv_event_t * e);
|
|
static void calendar_event_cb(lv_event_t * e);
|
|
|
|
/**********************
|
|
* STATIC VARIABLES
|
|
**********************/
|
|
static lv_obj_t * calendar;
|
|
|
|
/**********************
|
|
* GLOBAL VARIABLES
|
|
**********************/
|
|
extern lv_obj_t * tv;
|
|
|
|
/**********************
|
|
* MACROS
|
|
**********************/
|
|
|
|
/**********************
|
|
* GLOBAL FUNCTIONS
|
|
**********************/
|
|
|
|
void lv_demo_widgets_profile_create(lv_obj_t * parent)
|
|
{
|
|
|
|
lv_obj_t * panel1 = lv_obj_create(parent);
|
|
lv_obj_set_height(panel1, LV_SIZE_CONTENT);
|
|
|
|
LV_IMAGE_DECLARE(img_demo_widgets_avatar);
|
|
lv_obj_t * avatar = lv_image_create(panel1);
|
|
lv_image_set_src(avatar, &img_demo_widgets_avatar);
|
|
|
|
lv_obj_t * name = lv_demo_widgets_title_create(panel1, "Elena Smith");
|
|
|
|
lv_obj_t * dsc = lv_label_create(panel1);
|
|
lv_obj_add_style(dsc, &style_text_muted, 0);
|
|
lv_label_set_text_static(dsc, "This is a short description of me. Take a look at my profile!");
|
|
lv_label_set_long_mode(dsc, LV_LABEL_LONG_MODE_WRAP);
|
|
|
|
lv_obj_t * email_icn = lv_label_create(panel1);
|
|
lv_obj_add_style(email_icn, &style_icon, 0);
|
|
lv_label_set_text_static(email_icn, LV_SYMBOL_ENVELOPE);
|
|
|
|
lv_obj_t * email_label = lv_label_create(panel1);
|
|
lv_label_set_text_static(email_label, "elena@smith.com");
|
|
|
|
lv_obj_t * call_icn = lv_label_create(panel1);
|
|
lv_obj_add_style(call_icn, &style_icon, 0);
|
|
lv_label_set_text_static(call_icn, LV_SYMBOL_CALL);
|
|
|
|
lv_obj_t * call_label = lv_label_create(panel1);
|
|
lv_label_set_text_static(call_label, "+79 246 123 4567");
|
|
|
|
lv_obj_t * log_out_btn = lv_button_create(panel1);
|
|
lv_obj_set_height(log_out_btn, LV_SIZE_CONTENT);
|
|
|
|
lv_obj_t * label = lv_label_create(log_out_btn);
|
|
lv_label_set_text_static(label, "Log out");
|
|
lv_obj_center(label);
|
|
|
|
lv_obj_t * invite_btn = lv_button_create(panel1);
|
|
lv_obj_add_state(invite_btn, LV_STATE_DISABLED);
|
|
lv_obj_set_height(invite_btn, LV_SIZE_CONTENT);
|
|
|
|
label = lv_label_create(invite_btn);
|
|
lv_label_set_text_static(label, "Invite");
|
|
lv_obj_center(label);
|
|
|
|
/*Create a keyboard*/
|
|
lv_obj_t * kb = lv_keyboard_create(lv_screen_active());
|
|
lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
|
|
|
|
/*Create the second panel*/
|
|
lv_obj_t * panel2 = lv_obj_create(parent);
|
|
lv_obj_set_height(panel2, LV_SIZE_CONTENT);
|
|
|
|
lv_obj_t * panel2_title = lv_demo_widgets_title_create(panel2, "Your profile");
|
|
|
|
lv_obj_t * user_name_label = lv_label_create(panel2);
|
|
lv_label_set_text_static(user_name_label, "User name");
|
|
lv_obj_add_style(user_name_label, &style_text_muted, 0);
|
|
|
|
lv_obj_t * user_name = lv_textarea_create(panel2);
|
|
lv_textarea_set_one_line(user_name, true);
|
|
lv_textarea_set_placeholder_text(user_name, "Your name");
|
|
lv_obj_add_event_cb(user_name, ta_event_cb, LV_EVENT_ALL, kb);
|
|
|
|
lv_obj_t * password_label = lv_label_create(panel2);
|
|
lv_label_set_text_static(password_label, "Password");
|
|
lv_obj_add_style(password_label, &style_text_muted, 0);
|
|
|
|
lv_obj_t * password = lv_textarea_create(panel2);
|
|
lv_textarea_set_one_line(password, true);
|
|
lv_textarea_set_password_mode(password, true);
|
|
lv_textarea_set_placeholder_text(password, "Min. 8 chars.");
|
|
lv_obj_add_event_cb(password, ta_event_cb, LV_EVENT_ALL, kb);
|
|
|
|
lv_obj_t * gender_label = lv_label_create(panel2);
|
|
lv_label_set_text_static(gender_label, "Gender");
|
|
lv_obj_add_style(gender_label, &style_text_muted, 0);
|
|
|
|
lv_obj_t * gender = lv_dropdown_create(panel2);
|
|
lv_dropdown_set_options_static(gender, "Male\nFemale\nOther");
|
|
|
|
lv_obj_t * birthday_label = lv_label_create(panel2);
|
|
lv_label_set_text_static(birthday_label, "Birthday");
|
|
lv_obj_add_style(birthday_label, &style_text_muted, 0);
|
|
|
|
lv_obj_t * birthdate = lv_textarea_create(panel2);
|
|
lv_textarea_set_one_line(birthdate, true);
|
|
lv_obj_add_event_cb(birthdate, birthday_event_cb, LV_EVENT_ALL, NULL);
|
|
|
|
/*Create the third panel*/
|
|
lv_obj_t * panel3 = lv_obj_create(parent);
|
|
lv_obj_t * panel3_title = lv_demo_widgets_title_create(panel3, "Your skills");
|
|
|
|
lv_obj_t * experience_label = lv_label_create(panel3);
|
|
lv_label_set_text_static(experience_label, "Experience");
|
|
lv_obj_add_style(experience_label, &style_text_muted, 0);
|
|
|
|
lv_obj_t * slider1 = lv_slider_create(panel3);
|
|
lv_obj_set_width(slider1, LV_PCT(95));
|
|
lv_obj_add_event_cb(slider1, slider_event_cb, LV_EVENT_ALL, NULL);
|
|
lv_obj_add_flag(slider1, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS);
|
|
lv_obj_refresh_ext_draw_size(slider1);
|
|
|
|
lv_obj_t * team_player_label = lv_label_create(panel3);
|
|
lv_label_set_text_static(team_player_label, "Team player");
|
|
lv_obj_add_style(team_player_label, &style_text_muted, 0);
|
|
|
|
lv_obj_t * sw1 = lv_switch_create(panel3);
|
|
|
|
lv_obj_t * hard_working_label = lv_label_create(panel3);
|
|
lv_label_set_text_static(hard_working_label, "Hard-working");
|
|
lv_obj_add_style(hard_working_label, &style_text_muted, 0);
|
|
|
|
lv_obj_t * sw2 = lv_switch_create(panel3);
|
|
|
|
if(disp_size == DISP_LARGE) {
|
|
static int32_t grid_main_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
|
static int32_t grid_main_row_dsc[] = {LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
|
|
|
|
/*Create the top panel*/
|
|
static int32_t grid_1_col_dsc[] = {LV_GRID_CONTENT, 5, LV_GRID_CONTENT, LV_GRID_FR(2), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
|
static int32_t grid_1_row_dsc[] = {LV_GRID_CONTENT, LV_GRID_CONTENT, 10, LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
|
|
|
|
static int32_t grid_2_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
|
static int32_t grid_2_row_dsc[] = {
|
|
LV_GRID_CONTENT, /*Title*/
|
|
5, /*Separator*/
|
|
LV_GRID_CONTENT, /*Box title*/
|
|
30, /*Boxes*/
|
|
5, /*Separator*/
|
|
LV_GRID_CONTENT, /*Box title*/
|
|
30, /*Boxes*/
|
|
LV_GRID_TEMPLATE_LAST
|
|
};
|
|
|
|
lv_obj_set_grid_dsc_array(parent, grid_main_col_dsc, grid_main_row_dsc);
|
|
|
|
lv_obj_set_grid_cell(panel1, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1);
|
|
|
|
lv_obj_set_grid_dsc_array(panel1, grid_1_col_dsc, grid_1_row_dsc);
|
|
lv_obj_set_grid_cell(avatar, LV_GRID_ALIGN_CENTER, 0, 1, LV_GRID_ALIGN_CENTER, 0, 5);
|
|
lv_obj_set_grid_cell(name, LV_GRID_ALIGN_START, 2, 2, LV_GRID_ALIGN_CENTER, 0, 1);
|
|
lv_obj_set_grid_cell(dsc, LV_GRID_ALIGN_STRETCH, 2, 4, LV_GRID_ALIGN_START, 1, 1);
|
|
lv_obj_set_grid_cell(email_icn, LV_GRID_ALIGN_CENTER, 2, 1, LV_GRID_ALIGN_CENTER, 3, 1);
|
|
lv_obj_set_grid_cell(email_label, LV_GRID_ALIGN_START, 3, 1, LV_GRID_ALIGN_CENTER, 3, 1);
|
|
lv_obj_set_grid_cell(call_icn, LV_GRID_ALIGN_CENTER, 2, 1, LV_GRID_ALIGN_CENTER, 4, 1);
|
|
lv_obj_set_grid_cell(call_label, LV_GRID_ALIGN_START, 3, 1, LV_GRID_ALIGN_CENTER, 4, 1);
|
|
lv_obj_set_grid_cell(log_out_btn, LV_GRID_ALIGN_STRETCH, 4, 1, LV_GRID_ALIGN_CENTER, 3, 2);
|
|
lv_obj_set_grid_cell(invite_btn, LV_GRID_ALIGN_STRETCH, 5, 1, LV_GRID_ALIGN_CENTER, 3, 2);
|
|
|
|
lv_obj_set_grid_cell(panel2, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_START, 1, 1);
|
|
lv_obj_set_grid_dsc_array(panel2, grid_2_col_dsc, grid_2_row_dsc);
|
|
lv_obj_set_grid_cell(panel2_title, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1);
|
|
lv_obj_set_grid_cell(user_name, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_CENTER, 3, 1);
|
|
lv_obj_set_grid_cell(user_name_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 2, 1);
|
|
lv_obj_set_grid_cell(password, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_CENTER, 3, 1);
|
|
lv_obj_set_grid_cell(password_label, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_START, 2, 1);
|
|
lv_obj_set_grid_cell(birthdate, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_CENTER, 6, 1);
|
|
lv_obj_set_grid_cell(birthday_label, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_START, 5, 1);
|
|
lv_obj_set_grid_cell(gender, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_CENTER, 6, 1);
|
|
lv_obj_set_grid_cell(gender_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 5, 1);
|
|
|
|
lv_obj_set_grid_cell(panel3, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_STRETCH, 1, 1);
|
|
lv_obj_set_grid_dsc_array(panel3, grid_2_col_dsc, grid_2_row_dsc);
|
|
lv_obj_set_grid_cell(panel3_title, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1);
|
|
lv_obj_set_grid_cell(slider1, LV_GRID_ALIGN_CENTER, 0, 2, LV_GRID_ALIGN_CENTER, 3, 1);
|
|
lv_obj_set_grid_cell(experience_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 2, 1);
|
|
lv_obj_set_grid_cell(sw2, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_CENTER, 6, 1);
|
|
lv_obj_set_grid_cell(hard_working_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 5, 1);
|
|
lv_obj_set_grid_cell(sw1, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_CENTER, 6, 1);
|
|
lv_obj_set_grid_cell(team_player_label, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_START, 5, 1);
|
|
}
|
|
else if(disp_size == DISP_MEDIUM) {
|
|
static int32_t grid_main_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
|
static int32_t grid_main_row_dsc[] = {LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
|
|
|
|
/*Create the top panel*/
|
|
static int32_t grid_1_col_dsc[] = {LV_GRID_CONTENT, 1, LV_GRID_CONTENT, LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
|
static int32_t grid_1_row_dsc[] = {
|
|
LV_GRID_CONTENT, /*Name*/
|
|
LV_GRID_CONTENT, /*Description*/
|
|
LV_GRID_CONTENT, /*Email*/
|
|
-20,
|
|
LV_GRID_CONTENT, /*Phone*/
|
|
LV_GRID_CONTENT, /*Buttons*/
|
|
LV_GRID_TEMPLATE_LAST
|
|
};
|
|
|
|
static int32_t grid_2_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
|
static int32_t grid_2_row_dsc[] = {
|
|
LV_GRID_CONTENT, /*Title*/
|
|
5, /*Separator*/
|
|
LV_GRID_CONTENT, /*Box title*/
|
|
40, /*Box*/
|
|
LV_GRID_CONTENT, /*Box title*/
|
|
40, /*Box*/
|
|
LV_GRID_CONTENT, /*Box title*/
|
|
40, /*Box*/
|
|
LV_GRID_CONTENT, /*Box title*/
|
|
40, /*Box*/
|
|
LV_GRID_TEMPLATE_LAST
|
|
};
|
|
|
|
lv_obj_set_grid_dsc_array(parent, grid_main_col_dsc, grid_main_row_dsc);
|
|
lv_obj_set_grid_cell(panel1, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1);
|
|
|
|
lv_obj_set_width(log_out_btn, 120);
|
|
lv_obj_set_width(invite_btn, 120);
|
|
|
|
lv_obj_set_grid_dsc_array(panel1, grid_1_col_dsc, grid_1_row_dsc);
|
|
lv_obj_set_grid_cell(avatar, LV_GRID_ALIGN_CENTER, 0, 1, LV_GRID_ALIGN_START, 0, 4);
|
|
lv_obj_set_grid_cell(name, LV_GRID_ALIGN_START, 2, 2, LV_GRID_ALIGN_CENTER, 0, 1);
|
|
lv_obj_set_grid_cell(dsc, LV_GRID_ALIGN_STRETCH, 2, 2, LV_GRID_ALIGN_START, 1, 1);
|
|
lv_obj_set_grid_cell(email_label, LV_GRID_ALIGN_START, 3, 1, LV_GRID_ALIGN_CENTER, 2, 1);
|
|
lv_obj_set_grid_cell(email_icn, LV_GRID_ALIGN_CENTER, 2, 1, LV_GRID_ALIGN_CENTER, 2, 1);
|
|
lv_obj_set_grid_cell(call_icn, LV_GRID_ALIGN_CENTER, 2, 1, LV_GRID_ALIGN_CENTER, 4, 1);
|
|
lv_obj_set_grid_cell(call_label, LV_GRID_ALIGN_START, 3, 1, LV_GRID_ALIGN_CENTER, 4, 1);
|
|
lv_obj_set_grid_cell(log_out_btn, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_CENTER, 5, 1);
|
|
lv_obj_set_grid_cell(invite_btn, LV_GRID_ALIGN_END, 3, 1, LV_GRID_ALIGN_CENTER, 5, 1);
|
|
|
|
lv_obj_set_grid_cell(panel2, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_START, 1, 1);
|
|
lv_obj_set_grid_dsc_array(panel2, grid_2_col_dsc, grid_2_row_dsc);
|
|
lv_obj_set_grid_cell(panel2_title, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1);
|
|
lv_obj_set_grid_cell(user_name_label, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 2, 1);
|
|
lv_obj_set_grid_cell(user_name, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 3, 1);
|
|
lv_obj_set_grid_cell(password_label, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 4, 1);
|
|
lv_obj_set_grid_cell(password, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 5, 1);
|
|
lv_obj_set_grid_cell(birthday_label, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 6, 1);
|
|
lv_obj_set_grid_cell(birthdate, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 7, 1);
|
|
lv_obj_set_grid_cell(gender_label, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 8, 1);
|
|
lv_obj_set_grid_cell(gender, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 9, 1);
|
|
|
|
lv_obj_set_grid_cell(panel3, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_STRETCH, 1, 1);
|
|
lv_obj_set_grid_dsc_array(panel3, grid_2_col_dsc, grid_2_row_dsc);
|
|
lv_obj_set_grid_cell(panel3_title, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1);
|
|
lv_obj_set_grid_cell(slider1, LV_GRID_ALIGN_CENTER, 0, 2, LV_GRID_ALIGN_CENTER, 3, 1);
|
|
lv_obj_set_grid_cell(experience_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 2, 1);
|
|
lv_obj_set_grid_cell(hard_working_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 4, 1);
|
|
lv_obj_set_grid_cell(sw2, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 5, 1);
|
|
lv_obj_set_grid_cell(team_player_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 6, 1);
|
|
lv_obj_set_grid_cell(sw1, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 7, 1);
|
|
}
|
|
else if(disp_size == DISP_SMALL) {
|
|
static int32_t grid_main_col_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
|
static int32_t grid_main_row_dsc[] = {LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
|
|
lv_obj_set_grid_dsc_array(parent, grid_main_col_dsc, grid_main_row_dsc);
|
|
|
|
/*Create the top panel*/
|
|
static int32_t grid_1_col_dsc[] = {LV_GRID_CONTENT, LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
|
static int32_t grid_1_row_dsc[] = {LV_GRID_CONTENT, /*Avatar*/
|
|
LV_GRID_CONTENT, /*Name*/
|
|
LV_GRID_CONTENT, /*Description*/
|
|
LV_GRID_CONTENT, /*Email*/
|
|
LV_GRID_CONTENT, /*Phone number*/
|
|
LV_GRID_CONTENT, /*Button1*/
|
|
LV_GRID_CONTENT, /*Button2*/
|
|
LV_GRID_TEMPLATE_LAST
|
|
};
|
|
|
|
lv_obj_set_grid_dsc_array(panel1, grid_1_col_dsc, grid_1_row_dsc);
|
|
|
|
static int32_t grid_2_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
|
static int32_t grid_2_row_dsc[] = {
|
|
LV_GRID_CONTENT, /*Title*/
|
|
5, /*Separator*/
|
|
LV_GRID_CONTENT, /*Box title*/
|
|
40, /*Box*/
|
|
LV_GRID_CONTENT, /*Box title*/
|
|
40, /*Box*/
|
|
LV_GRID_CONTENT, /*Box title*/
|
|
40, /*Box*/
|
|
LV_GRID_CONTENT, /*Box title*/
|
|
40, LV_GRID_TEMPLATE_LAST /*Box*/
|
|
};
|
|
|
|
lv_obj_set_grid_dsc_array(panel2, grid_2_col_dsc, grid_2_row_dsc);
|
|
lv_obj_set_grid_dsc_array(panel3, grid_2_col_dsc, grid_2_row_dsc);
|
|
|
|
lv_obj_set_grid_cell(panel1, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
|
|
|
lv_obj_set_style_text_align(dsc, LV_TEXT_ALIGN_CENTER, 0);
|
|
|
|
lv_obj_set_grid_cell(avatar, LV_GRID_ALIGN_CENTER, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1);
|
|
lv_obj_set_grid_cell(name, LV_GRID_ALIGN_CENTER, 0, 2, LV_GRID_ALIGN_CENTER, 1, 1);
|
|
lv_obj_set_grid_cell(dsc, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 2, 1);
|
|
lv_obj_set_grid_cell(email_icn, LV_GRID_ALIGN_CENTER, 0, 1, LV_GRID_ALIGN_CENTER, 3, 1);
|
|
lv_obj_set_grid_cell(email_label, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_CENTER, 3, 1);
|
|
lv_obj_set_grid_cell(call_icn, LV_GRID_ALIGN_CENTER, 0, 1, LV_GRID_ALIGN_CENTER, 4, 1);
|
|
lv_obj_set_grid_cell(call_label, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_CENTER, 4, 1);
|
|
lv_obj_set_grid_cell(log_out_btn, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_CENTER, 5, 1);
|
|
lv_obj_set_grid_cell(invite_btn, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_CENTER, 6, 1);
|
|
|
|
lv_obj_set_grid_cell(panel2, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_START, 1, 1);
|
|
lv_obj_set_grid_cell(panel2_title, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1);
|
|
lv_obj_set_grid_cell(user_name_label, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 2, 1);
|
|
lv_obj_set_grid_cell(user_name, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 3, 1);
|
|
lv_obj_set_grid_cell(password_label, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 4, 1);
|
|
lv_obj_set_grid_cell(password, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 5, 1);
|
|
lv_obj_set_grid_cell(birthday_label, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 6, 1);
|
|
lv_obj_set_grid_cell(birthdate, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 7, 1);
|
|
lv_obj_set_grid_cell(gender_label, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 8, 1);
|
|
lv_obj_set_grid_cell(gender, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 9, 1);
|
|
|
|
lv_obj_set_height(panel3, LV_SIZE_CONTENT);
|
|
lv_obj_set_grid_cell(panel3, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_START, 2, 1);
|
|
lv_obj_set_grid_cell(panel3_title, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1);
|
|
lv_obj_set_grid_cell(experience_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 2, 1);
|
|
lv_obj_set_grid_cell(slider1, LV_GRID_ALIGN_CENTER, 0, 2, LV_GRID_ALIGN_CENTER, 3, 1);
|
|
lv_obj_set_grid_cell(hard_working_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 4, 1);
|
|
lv_obj_set_grid_cell(sw1, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 5, 1);
|
|
lv_obj_set_grid_cell(team_player_label, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_START, 4, 1);
|
|
lv_obj_set_grid_cell(sw2, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_START, 5, 1);
|
|
}
|
|
}
|
|
|
|
/**********************
|
|
* STATIC FUNCTIONS
|
|
**********************/
|
|
|
|
static void ta_event_cb(lv_event_t * e)
|
|
{
|
|
lv_event_code_t code = lv_event_get_code(e);
|
|
lv_obj_t * ta = lv_event_get_target(e);
|
|
lv_obj_t * kb = lv_event_get_user_data(e);
|
|
if(code == LV_EVENT_FOCUSED) {
|
|
if(lv_indev_get_type(lv_indev_active()) != LV_INDEV_TYPE_KEYPAD) {
|
|
lv_keyboard_set_textarea(kb, ta);
|
|
lv_obj_set_style_max_height(kb, LV_HOR_RES * 2 / 3, 0);
|
|
lv_obj_update_layout(tv); /*Be sure the sizes are recalculated*/
|
|
lv_obj_set_height(tv, LV_VER_RES - lv_obj_get_height(kb));
|
|
lv_obj_remove_flag(kb, LV_OBJ_FLAG_HIDDEN);
|
|
lv_obj_scroll_to_view_recursive(ta, LV_ANIM_OFF);
|
|
lv_indev_wait_release(lv_event_get_param(e));
|
|
}
|
|
}
|
|
else if(code == LV_EVENT_DEFOCUSED) {
|
|
lv_keyboard_set_textarea(kb, NULL);
|
|
lv_obj_set_height(tv, LV_VER_RES);
|
|
lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
|
|
lv_indev_reset(NULL, ta);
|
|
|
|
}
|
|
else if(code == LV_EVENT_READY || code == LV_EVENT_CANCEL) {
|
|
lv_obj_set_height(tv, LV_VER_RES);
|
|
lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
|
|
lv_indev_reset(NULL, ta); /*To forget the last clicked object to make it focusable again*/
|
|
}
|
|
}
|
|
|
|
static void birthday_event_cb(lv_event_t * e)
|
|
{
|
|
lv_event_code_t code = lv_event_get_code(e);
|
|
lv_obj_t * ta = lv_event_get_target(e);
|
|
|
|
if(code == LV_EVENT_FOCUSED) {
|
|
if(lv_indev_get_type(lv_indev_active()) == LV_INDEV_TYPE_POINTER) {
|
|
if(calendar == NULL) {
|
|
lv_obj_add_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE);
|
|
calendar = lv_calendar_create(lv_layer_top());
|
|
lv_obj_set_style_bg_opa(lv_layer_top(), LV_OPA_50, 0);
|
|
lv_obj_set_style_bg_color(lv_layer_top(), lv_palette_main(LV_PALETTE_GREY), 0);
|
|
if(disp_size == DISP_SMALL) lv_obj_set_size(calendar, 180, 200);
|
|
else if(disp_size == DISP_MEDIUM) lv_obj_set_size(calendar, 200, 220);
|
|
else lv_obj_set_size(calendar, 300, 330);
|
|
lv_calendar_set_month_shown(calendar, 1990, 01);
|
|
lv_obj_align(calendar, LV_ALIGN_CENTER, 0, 30);
|
|
lv_obj_add_event_cb(calendar, calendar_event_cb, LV_EVENT_ALL, ta);
|
|
|
|
lv_calendar_add_header_dropdown(calendar);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
static void calendar_event_cb(lv_event_t * e)
|
|
{
|
|
lv_event_code_t code = lv_event_get_code(e);
|
|
lv_obj_t * ta = lv_event_get_user_data(e);
|
|
lv_obj_t * obj = lv_event_get_current_target(e);
|
|
if(code == LV_EVENT_VALUE_CHANGED) {
|
|
lv_calendar_date_t d;
|
|
lv_calendar_get_pressed_date(obj, &d);
|
|
char buf[32];
|
|
lv_snprintf(buf, sizeof(buf), "%02d.%02d.%d", d.day, d.month, d.year);
|
|
lv_textarea_set_text(ta, buf);
|
|
|
|
lv_obj_delete(calendar);
|
|
calendar = NULL;
|
|
lv_obj_remove_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE);
|
|
lv_obj_set_style_bg_opa(lv_layer_top(), LV_OPA_TRANSP, 0);
|
|
}
|
|
}
|
|
|
|
static void slider_event_cb(lv_event_t * e)
|
|
{
|
|
lv_event_code_t code = lv_event_get_code(e);
|
|
lv_obj_t * obj = lv_event_get_target(e);
|
|
|
|
if(code == LV_EVENT_REFR_EXT_DRAW_SIZE) {
|
|
int32_t * s = lv_event_get_param(e);
|
|
*s = LV_MAX(*s, 60);
|
|
}
|
|
else if(code == LV_EVENT_DRAW_TASK_ADDED) {
|
|
lv_draw_task_t * draw_task = lv_event_get_param(e);
|
|
if(draw_task == NULL || lv_draw_task_get_type(draw_task) != LV_DRAW_TASK_TYPE_FILL) return;
|
|
lv_draw_rect_dsc_t * draw_rect_dsc = lv_draw_task_get_draw_dsc(draw_task);
|
|
|
|
if(draw_rect_dsc->base.part == LV_PART_KNOB && lv_obj_has_state(obj, LV_STATE_PRESSED)) {
|
|
char buf[8];
|
|
lv_snprintf(buf, sizeof(buf), "%"LV_PRId32, lv_slider_get_value(obj));
|
|
|
|
lv_point_t text_size;
|
|
lv_text_get_size(&text_size, buf, font_normal, 0, 0, LV_COORD_MAX, LV_TEXT_FLAG_NONE);
|
|
|
|
lv_area_t txt_area;
|
|
lv_area_t draw_task_area;
|
|
lv_draw_task_get_area(draw_task, &draw_task_area);
|
|
txt_area.x1 = draw_task_area.x1 + lv_area_get_width(&draw_task_area) / 2 - text_size.x / 2;
|
|
txt_area.x2 = txt_area.x1 + text_size.x;
|
|
txt_area.y2 = draw_task_area.y1 - 10;
|
|
txt_area.y1 = txt_area.y2 - text_size.y;
|
|
|
|
lv_area_t bg_area;
|
|
bg_area.x1 = txt_area.x1 - LV_DPX(8);
|
|
bg_area.x2 = txt_area.x2 + LV_DPX(8);
|
|
bg_area.y1 = txt_area.y1 - LV_DPX(8);
|
|
bg_area.y2 = txt_area.y2 + LV_DPX(8);
|
|
|
|
lv_draw_rect_dsc_t rect_dsc;
|
|
lv_draw_rect_dsc_init(&rect_dsc);
|
|
rect_dsc.bg_color = lv_palette_darken(LV_PALETTE_GREY, 3);
|
|
rect_dsc.radius = LV_DPX(5);
|
|
lv_draw_rect(draw_rect_dsc->base.layer, &rect_dsc, &bg_area);
|
|
|
|
lv_draw_label_dsc_t label_dsc;
|
|
lv_draw_label_dsc_init(&label_dsc);
|
|
label_dsc.color = lv_color_white();
|
|
label_dsc.font = font_normal;
|
|
label_dsc.text = buf;
|
|
label_dsc.text_local = 1;
|
|
lv_draw_label(draw_rect_dsc->base.layer, &label_dsc, &txt_area);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif /* LV_USE_DEMO_WIDGETS */
|