kvm/internal/native/eez/src/ui/actions.c

52 lines
1.4 KiB
C

#include "actions.h"
#include "screens.h"
int handle_gesture_screen_switch(lv_event_t *e, lv_dir_t direction, int screenId) {
lv_event_code_t event_code = lv_event_get_code(e);
if (event_code != LV_EVENT_GESTURE) {
return 0;
}
if (lv_indev_get_gesture_dir(lv_indev_get_act()) != direction) {
return 0;
}
lv_indev_wait_release(lv_indev_get_act());
loadScreen(screenId);
return 1;
}
void action_switch_to_menu(lv_event_t *e) {
loadScreen(SCREEN_ID_MENU_SCREEN);
}
void action_switch_to_advanced_menu(lv_event_t *e) {
loadScreen(SCREEN_ID_MENU_ADVANCED_SCREEN);
}
void action_switch_to_status(lv_event_t *e) {
loadScreen(SCREEN_ID_STATUS_SCREEN);
}
void action_switch_to_about(lv_event_t *e) {
loadScreen(SCREEN_ID_ABOUT_SCREEN);
}
void action_menu_screen_gesture(lv_event_t * e) {
handle_gesture_screen_switch(e, LV_DIR_RIGHT, SCREEN_ID_HOME_SCREEN);
}
void action_menu_advanced_screen_gesture(lv_event_t * e) {
handle_gesture_screen_switch(e, LV_DIR_RIGHT, SCREEN_ID_MENU_SCREEN);
}
void action_reset_config_screen_gesture(lv_event_t * e) {
handle_gesture_screen_switch(e, LV_DIR_RIGHT, SCREEN_ID_MENU_ADVANCED_SCREEN);
}
void action_home_screen_gesture(lv_event_t * e) {
handle_gesture_screen_switch(e, LV_DIR_LEFT, SCREEN_ID_MENU_SCREEN);
}
void action_about_screen_gesture(lv_event_t * e) {
handle_gesture_screen_switch(e, LV_DIR_RIGHT, SCREEN_ID_MENU_SCREEN);
}