Updated the watch's settings screen so that the selected item in the list on the left side is highlighted.
This commit is contained in:
parent
d1f1481f13
commit
1f43db8e18
@ -170,6 +170,8 @@ static void vibration_duration_roller_cb(lv_event_t *e)
|
||||
uint8_t index = lv_roller_get_selected(roller);
|
||||
|
||||
settingsScreen->settingsScreenAPIInterface.setDisplayVibrationDurationSettingsCb(&index, SETTING_MODE_SET);
|
||||
|
||||
common_screen_onclick_vibration();
|
||||
}
|
||||
|
||||
static void vibration_strength_roller_cb(lv_event_t *e)
|
||||
@ -181,6 +183,8 @@ static void vibration_strength_roller_cb(lv_event_t *e)
|
||||
uint8_t index = lv_roller_get_selected(roller);
|
||||
|
||||
settingsScreen->settingsScreenAPIInterface.setDisplayVibrationStrengthSettingsCb(&index, SETTING_MODE_SET);
|
||||
|
||||
common_screen_onclick_vibration();
|
||||
}
|
||||
|
||||
static void timeout_roller_cb(lv_event_t * e)
|
||||
@ -760,7 +764,7 @@ void settings_screen_create(SettingsScreen_t * const settingsScreen)
|
||||
lv_obj_set_style_radius(menu_list, 0, LV_PART_MAIN);
|
||||
lv_obj_set_style_border_width(menu_list, 0, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_right(menu_list, 0, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_left(menu_list, 7, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_left(menu_list, 0, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_bottom(menu_list, 50, LV_PART_MAIN);
|
||||
|
||||
//We add the side screen containing the settings
|
||||
@ -806,21 +810,25 @@ void settings_screen_destroy(SettingsScreen_t * const settingsScreen)
|
||||
settingsScreen->year_roller = NULL;
|
||||
settingsScreen->display = NULL;
|
||||
settingsScreen->about_refresh_timer = NULL;
|
||||
settingsScreen->last_selected_item = NULL;
|
||||
}
|
||||
|
||||
static void _simulate_side_screen_item_click(SettingsScreen_t * const settingsScreen, lv_obj_t *item)
|
||||
{
|
||||
static lv_obj_t *last_target = NULL;
|
||||
if(settingsScreen->last_selected_item == item) return;
|
||||
|
||||
if(last_target == item) return;
|
||||
|
||||
if(last_target == settingsScreen->about_item)
|
||||
if(settingsScreen->last_selected_item == settingsScreen->about_item)
|
||||
{
|
||||
lv_timer_del(settingsScreen->about_refresh_timer);
|
||||
settingsScreen->about_refresh_timer = NULL;
|
||||
}
|
||||
|
||||
last_target = item;
|
||||
//Updating the background of the selected category
|
||||
lv_obj_set_style_bg_color(item, lv_color_make(178, 223, 219), LV_PART_MAIN);
|
||||
if(settingsScreen->last_selected_item)
|
||||
lv_obj_set_style_bg_color(settingsScreen->last_selected_item, lv_color_white(), LV_PART_MAIN);
|
||||
|
||||
settingsScreen->last_selected_item = item;
|
||||
|
||||
if(item == settingsScreen->time_and_date_item)
|
||||
{
|
||||
@ -949,8 +957,9 @@ static lv_obj_t *add_menu_list_item(lv_obj_t *list, const char *text, lv_event_c
|
||||
lv_obj_t *label = lv_obj_get_child(btn, 0);
|
||||
if(label)
|
||||
{
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP);
|
||||
lv_obj_set_style_pad_right(btn, 0, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_left(label, 7, LV_PART_MAIN);
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP);
|
||||
}
|
||||
|
||||
lv_obj_add_event_cb(btn, event_cb, LV_EVENT_CLICKED, user_data);
|
||||
|
@ -43,6 +43,8 @@ typedef struct SettingsScreen
|
||||
lv_obj_t *connectivity_item;
|
||||
lv_obj_t *language_item;
|
||||
lv_obj_t *about_item;
|
||||
/* Remember the last clicked item needed for the background color logic */
|
||||
lv_obj_t *last_selected_item;
|
||||
|
||||
lv_obj_t *side_screen;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user