mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
lpr_rep action added + app styles update
This commit is contained in:
parent
6d85a9c086
commit
ad7868591f
@ -40,7 +40,7 @@ static void lv_app_init_style(void);
|
||||
static ll_dsc_t app_dsc_ll; /*Store a pointer to the app descriptors*/
|
||||
static ll_dsc_t app_inst_ll; /*Store the running apps*/
|
||||
|
||||
static lv_obj_t * menuh; /*Holder of the menu on the top*/
|
||||
static lv_obj_t * menuh; /*Holder of timg_bubbleshe menu on the top*/
|
||||
static lv_obj_t * app_btn; /*The "Apps" button on the menu*/
|
||||
static lv_obj_t * sys_apph; /*Holder of the system app. buttons*/
|
||||
static lv_obj_t * app_list;
|
||||
@ -160,7 +160,10 @@ lv_obj_t * lv_app_sc_open(lv_app_inst_t * app)
|
||||
{
|
||||
app->sc = lv_btn_create(sc_area, NULL);
|
||||
lv_obj_set_free_p(app->sc, app);
|
||||
lv_obj_set_style(app->sc, &app_style.sc_style);
|
||||
lv_obj_set_opa(app->sc, app_style.sc_opa);
|
||||
lv_obj_set_size(app->sc, app_style.sc_w, app_style.sc_h);
|
||||
lv_rect_set_layout(app->sc, LV_RECT_LAYOUT_OFF);
|
||||
lv_btn_set_rel_action(app->sc, lv_app_sc_rel_action);
|
||||
lv_btn_set_pr_action(app->sc, lv_app_sc_pr_action);
|
||||
lv_page_glue_obj(app->sc, true);
|
||||
@ -168,6 +171,12 @@ lv_obj_t * lv_app_sc_open(lv_app_inst_t * app)
|
||||
app->sc_data = dm_alloc(app->dsc->sc_data_size);
|
||||
app->dsc->sc_open(app, app->sc);
|
||||
|
||||
lv_obj_t * sc_title;
|
||||
sc_title = lv_label_create(app->sc, NULL);
|
||||
lv_obj_set_style(sc_title, &app_style.sc_title_style);
|
||||
lv_label_set_text(sc_title, app->dsc->name);
|
||||
lv_obj_align_us(sc_title, NULL, LV_ALIGN_IN_TOP_MID, 0, 3);
|
||||
|
||||
return app->sc;
|
||||
}
|
||||
|
||||
@ -295,13 +304,6 @@ static lv_action_res_t lv_app_menu_rel_action(lv_obj_t * app_btn, lv_dispi_t * d
|
||||
lv_obj_set_free_p(elem, *dsc);
|
||||
lv_obj_set_opa(elem, app_style.menu_btn_opa);
|
||||
|
||||
elem = lv_list_add(app_list, NULL, (*dsc)->name, lv_app_menu_elem_rel_action);
|
||||
lv_obj_set_free_p(elem, *dsc);
|
||||
lv_obj_set_opa(elem, app_style.menu_btn_opa);
|
||||
|
||||
elem = lv_list_add(app_list, NULL, (*dsc)->name, lv_app_menu_elem_rel_action);
|
||||
lv_obj_set_free_p(elem, *dsc);
|
||||
lv_obj_set_opa(elem, app_style.menu_btn_opa);
|
||||
}
|
||||
}
|
||||
return LV_ACTION_RES_OK;
|
||||
@ -460,8 +462,18 @@ static void lv_app_init_style(void)
|
||||
|
||||
/*Shortcut styles*/
|
||||
lv_btns_get(LV_BTNS_DEF,&app_style.sc_style);
|
||||
app_style.sc_style.mcolor[LV_BTN_STATE_REL] = COLOR_MAKE(0xC0, 0xC0, 0xC0);
|
||||
app_style.sc_style.gcolor[LV_BTN_STATE_REL] = COLOR_MAKE(0x20, 0x30, 0x40);
|
||||
app_style.sc_style.bcolor[LV_BTN_STATE_REL] = COLOR_MAKE(0x40, 0x60, 0x80);
|
||||
app_style.sc_style.mcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0x60, 0x80, 0xa0);
|
||||
app_style.sc_style.gcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0x20, 0x30, 0x40);
|
||||
app_style.sc_style.bcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0xB0, 0xD0, 0xF0);
|
||||
app_style.sc_style.rects.bopa = 70;
|
||||
app_style.sc_style.rects.bwidth = 1 * LV_STYLE_MULT;
|
||||
|
||||
lv_labels_get(LV_LABELS_DEF,&app_style.sc_title_style);
|
||||
app_style.sc_title_style.font = app_style.font_small;
|
||||
app_style.sc_title_style.objs.color = COLOR_MAKE(0x30, 0x40, 0x50);
|
||||
|
||||
/*Window styles*/
|
||||
lv_wins_get(LV_WINS_DEF,&app_style.win_style);
|
||||
|
@ -27,6 +27,7 @@ typedef enum
|
||||
LV_APP_MODE_NO_CON = 0x0008, /*No connection to other apps*/
|
||||
LV_APP_MODE_NO_CLOSE = 0x0010, /*No close control button*/
|
||||
LV_APP_MODE_NO_FIX = 0x0020, /*No fix control button*/
|
||||
LV_APP_MODE_NO_SC_TITLE = 0x0040, /*No short cut*/
|
||||
}lv_app_mode_t;
|
||||
|
||||
typedef enum
|
||||
@ -109,7 +110,6 @@ lv_obj_t * lv_app_win_open(lv_app_inst_t * app);
|
||||
void lv_app_win_close(lv_app_inst_t * app);
|
||||
const lv_app_dsc_t * lv_app_get_dsc(const char * name);
|
||||
|
||||
|
||||
lv_app_style_t * lv_app_get_style(void);
|
||||
void lv_app_refr_style(void);
|
||||
|
||||
|
@ -131,6 +131,7 @@ static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
label = lv_label_create(sc, NULL);
|
||||
lv_label_set_text(label, ((app_data_t *)app->app_data)->txt);
|
||||
lv_obj_set_style(label, lv_labels_get(LV_LABELS_BTN, NULL));
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,6 +159,7 @@ static void dispi_proc_point(lv_dispi_t * dispi_p, cord_t x, cord_t y)
|
||||
dispi_p->drag_in_prog = 0;
|
||||
dispi_p->long_press_sent = 0;
|
||||
dispi_p->press_time_stamp = 0;
|
||||
dispi_p->lpr_rep_time_stamp = 0;
|
||||
dispi_p->vect_sum.x = 0;
|
||||
dispi_p->vect_sum.y = 0;
|
||||
}
|
||||
@ -245,7 +246,7 @@ static void dispi_proc_press(lv_dispi_t * dispi_p)
|
||||
}
|
||||
}
|
||||
|
||||
/*The reset can be set in the signal function.
|
||||
/* The reset can be set in the signal function.
|
||||
* In case of reset query ignore the remaining parts.*/
|
||||
if(lv_dispi_reset_qry == false) {
|
||||
dispi_p->act_obj = pr_obj; /*Save the pressed object*/
|
||||
@ -266,9 +267,21 @@ static void dispi_proc_press(lv_dispi_t * dispi_p)
|
||||
pr_obj->signal_f(pr_obj, LV_SIGNAL_LONG_PRESS, dispi_p);
|
||||
|
||||
/*Mark the signal sending to do not send it again*/
|
||||
dispi_p->long_press_sent = 1;
|
||||
dispi_p->long_press_sent = 1;
|
||||
|
||||
/*Save the long press time stamp for the long press repeat handler*/
|
||||
dispi_p->lpr_rep_time_stamp = systick_get();
|
||||
}
|
||||
}
|
||||
/*Send long press repeated signal*/
|
||||
if(dispi_p->drag_in_prog == 0 && dispi_p->long_press_sent == 1) {
|
||||
/*Send a signal about the long press repeate if enough time elapsed*/
|
||||
if(systick_elaps(dispi_p->lpr_rep_time_stamp) > LV_DISPI_LONG_PRESS_REP_TIME) {
|
||||
pr_obj->signal_f(pr_obj, LV_SIGNAL_LONG_PRESS_REP, dispi_p);
|
||||
dispi_p->lpr_rep_time_stamp = systick_get();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -286,6 +299,7 @@ static void disi_proc_release(lv_dispi_t * dispi_p)
|
||||
|
||||
dispi_p->act_obj = NULL;
|
||||
dispi_p->press_time_stamp = 0;
|
||||
dispi_p->lpr_rep_time_stamp = 0;
|
||||
}
|
||||
|
||||
/*The reset can be set in the signal function.
|
||||
|
@ -28,6 +28,7 @@ typedef struct
|
||||
lv_obj_t * act_obj;
|
||||
lv_obj_t * last_obj;
|
||||
uint32_t press_time_stamp;
|
||||
uint32_t lpr_rep_time_stamp;
|
||||
|
||||
/*Flags*/
|
||||
uint8_t drag_in_prog :1;
|
||||
@ -47,4 +48,4 @@ void lv_dispi_get_vect(lv_dispi_t * dispi_p, point_t * point_p);
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -14,6 +14,10 @@
|
||||
#include "lv_refr.h"
|
||||
#include "misc/math/math_base.h"
|
||||
|
||||
#ifdef LV_IMG_DEF_WALLPAPER
|
||||
#include "../lv_objx/lv_img.h"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@ -32,13 +36,17 @@ static bool lv_obj_design(lv_obj_t * obj, const area_t * mask_p, lv_design_mode
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
lv_obj_t * def_scr = NULL;
|
||||
lv_obj_t * act_scr = NULL;
|
||||
ll_dsc_t scr_ll;
|
||||
static lv_obj_t * def_scr = NULL;
|
||||
static lv_obj_t * act_scr = NULL;
|
||||
static ll_dsc_t scr_ll;
|
||||
|
||||
lv_objs_t lv_objs_def = {.color = COLOR_MAKE(0xa0, 0xc0, 0xe0), .transp = 0};
|
||||
lv_objs_t lv_objs_scr = {.color = LV_OBJ_DEF_SCR_COLOR, .transp = 0};
|
||||
lv_objs_t lv_objs_transp = {.transp = 1};
|
||||
static lv_objs_t lv_objs_def = {.color = COLOR_MAKE(0xa0, 0xc0, 0xe0), .transp = 0};
|
||||
static lv_objs_t lv_objs_scr = {.color = LV_OBJ_DEF_SCR_COLOR, .transp = 0};
|
||||
static lv_objs_t lv_objs_transp = {.transp = 1};
|
||||
|
||||
#ifdef LV_IMG_DEF_WALLPAPER
|
||||
LV_IMG_DECLARE(LV_IMG_DEF_WALLPAPER);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -66,7 +74,14 @@ void lv_init(void)
|
||||
|
||||
/*Create the default screen*/
|
||||
ll_init(&scr_ll, sizeof(lv_obj_t));
|
||||
#ifdef LV_IMG_DEF_WALLPAPER
|
||||
lv_img_create_file("def_wp", LV_IMG_DEF_WALLPAPER);
|
||||
def_scr = lv_img_create(NULL, NULL);
|
||||
lv_img_set_auto_size(def_scr, false);
|
||||
lv_img_set_file(def_scr, "U:/def_wp");
|
||||
#else
|
||||
def_scr = lv_obj_create(NULL, NULL);
|
||||
#endif
|
||||
act_scr = def_scr;
|
||||
|
||||
/*Refresh the screen*/
|
||||
|
@ -68,6 +68,7 @@ typedef enum
|
||||
LV_SIGNAL_PRESS_LOST,
|
||||
LV_SIGNAL_RELEASED,
|
||||
LV_SIGNAL_LONG_PRESS,
|
||||
LV_SIGNAL_LONG_PRESS_REP,
|
||||
LV_SIGNAL_DRAG_BEGIN,
|
||||
LV_SIGNAL_DRAG_END,
|
||||
LV_SIGNAL_CHILD_CHG,
|
||||
|
@ -182,6 +182,12 @@ bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void* param)
|
||||
valid = ext->lpr_action(btn, param);
|
||||
}
|
||||
break;
|
||||
case LV_SIGNAL_LONG_PRESS_REP:
|
||||
/*Call the release action, here 'param' is the caller dispi*/
|
||||
if(ext->lpr_rep_action != NULL && state != LV_BTN_STATE_INA) {
|
||||
valid = ext->lpr_rep_action(btn, param);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/*Do nothing*/
|
||||
break;
|
||||
@ -235,7 +241,7 @@ void lv_btn_set_pr_action(lv_obj_t * btn, lv_action_res_t (*pr_action)(lv_obj_t
|
||||
/**
|
||||
* Set a function to call when the button is released
|
||||
* @param btn pointer to a button object
|
||||
* @param pr_action pointer to function
|
||||
* @param rel_action pointer to functionREL
|
||||
*/
|
||||
void lv_btn_set_rel_action(lv_obj_t * btn, lv_action_res_t (*rel_action)(lv_obj_t *, lv_dispi_t *))
|
||||
{
|
||||
@ -247,7 +253,7 @@ void lv_btn_set_rel_action(lv_obj_t * btn, lv_action_res_t (*rel_action)(lv_obj_
|
||||
/**
|
||||
* Set a function to call when the button is long pressed
|
||||
* @param btn pointer to a button object
|
||||
* @param pr_action pointer to function
|
||||
* @param lpr_action pointer to function
|
||||
*/
|
||||
void lv_btn_set_lpr_action(lv_obj_t * btn, lv_action_res_t (*lpr_action)(lv_obj_t *, lv_dispi_t *))
|
||||
{
|
||||
@ -256,6 +262,17 @@ void lv_btn_set_lpr_action(lv_obj_t * btn, lv_action_res_t (*lpr_action)(lv_obj_
|
||||
ext->lpr_action = lpr_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to called periodically after long press.
|
||||
* @param btn pointer to a button object
|
||||
* @param lpr_rep_action pointer to function
|
||||
*/
|
||||
void lv_btn_set_lpr_rep_action(lv_obj_t * btn, lv_action_res_t (*lpr_rep_action)(lv_obj_t *, lv_dispi_t *))
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
|
||||
ext->lpr_rep_action = lpr_rep_action;
|
||||
}
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
@ -76,6 +76,7 @@ typedef struct
|
||||
lv_action_res_t (*pr_action)(lv_obj_t *, lv_dispi_t *);
|
||||
lv_action_res_t (*rel_action)(lv_obj_t *, lv_dispi_t *);
|
||||
lv_action_res_t (*lpr_action)(lv_obj_t *, lv_dispi_t *);
|
||||
lv_action_res_t (*lpr_rep_action)(lv_obj_t *, lv_dispi_t *);
|
||||
|
||||
lv_btn_state_t state;
|
||||
uint8_t tgl :1; /*1: Toggle enabled*/
|
||||
@ -96,6 +97,7 @@ void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state);
|
||||
void lv_btn_set_pr_action(lv_obj_t * btn, lv_action_res_t (*pr_action)(lv_obj_t *, lv_dispi_t *));
|
||||
void lv_btn_set_rel_action(lv_obj_t * btn, lv_action_res_t (*rel_action)(lv_obj_t *, lv_dispi_t *));
|
||||
void lv_btn_set_lpr_action(lv_obj_t * btn, lv_action_res_t (*lpr_action)(lv_obj_t *, lv_dispi_t *));
|
||||
void lv_btn_set_lpr_rep_action(lv_obj_t * btn, lv_action_res_t (*lpr_rep_action)(lv_obj_t *, lv_dispi_t *));
|
||||
|
||||
bool lv_btn_get_tgl(lv_obj_t * btn);
|
||||
lv_btn_state_t lv_btn_get_state(lv_obj_t * btn);
|
||||
|
Loading…
x
Reference in New Issue
Block a user