Merge branch 'master' of github.com:littlevgl/lvgl
This commit is contained in:
@@ -24,17 +24,17 @@
|
||||
**********************/
|
||||
|
||||
static void touchpad_init(void);
|
||||
static bool touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
static bool touchpad_is_pressed(void);
|
||||
static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y);
|
||||
|
||||
static void mouse_init(void);
|
||||
static bool mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
static void mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
static bool mouse_is_pressed(void);
|
||||
static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y);
|
||||
|
||||
static void keypad_init(void);
|
||||
static bool keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
static void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
static uint32_t keypad_get_key(void);
|
||||
|
||||
static void encoder_init(void);
|
||||
@@ -42,7 +42,7 @@ static bool encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
static void encoder_handler(void);
|
||||
|
||||
static void button_init(void);
|
||||
static bool button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
static void button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
static int8_t button_get_pressed_id(void);
|
||||
static bool button_is_pressed(uint8_t id);
|
||||
|
||||
@@ -185,7 +185,7 @@ static void touchpad_init(void)
|
||||
}
|
||||
|
||||
/*Will be called by the library to read the touchpad*/
|
||||
static bool touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
{
|
||||
static lv_coord_t last_x = 0;
|
||||
static lv_coord_t last_y = 0;
|
||||
@@ -201,9 +201,6 @@ static bool touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
/*Set the last pressed coordinates*/
|
||||
data->point.x = last_x;
|
||||
data->point.y = last_y;
|
||||
|
||||
/*Return `false` because we are not buffering and no more data to read*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/*Return true is the touchpad is pressed*/
|
||||
@@ -234,7 +231,7 @@ static void mouse_init(void)
|
||||
}
|
||||
|
||||
/*Will be called by the library to read the mouse*/
|
||||
static bool mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
static void mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
{
|
||||
/*Get the current x and y coordinates*/
|
||||
mouse_get_xy(&data->point.x, &data->point.y);
|
||||
@@ -245,9 +242,6 @@ static bool mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
} else {
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
|
||||
/*Return `false` because we are not buffering and no more data to read*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/*Return true is the mouse button is pressed*/
|
||||
@@ -278,7 +272,7 @@ static void keypad_init(void)
|
||||
}
|
||||
|
||||
/*Will be called by the library to read the mouse*/
|
||||
static bool keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
static void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
{
|
||||
static uint32_t last_key = 0;
|
||||
|
||||
@@ -315,9 +309,6 @@ static bool keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
}
|
||||
|
||||
data->key = last_key;
|
||||
|
||||
/*Return `false` because we are not buffering and no more data to read*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/*Get the currently being pressed key. 0 if no key is pressed*/
|
||||
@@ -339,14 +330,11 @@ static void encoder_init(void)
|
||||
}
|
||||
|
||||
/*Will be called by the library to read the encoder*/
|
||||
static bool encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
static void encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
{
|
||||
|
||||
data->enc_diff = encoder_diff;
|
||||
data->state = encoder_state;
|
||||
|
||||
/*Return `false` because we are not buffering and no more data to read*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/*Call this function in an interrupt to process encoder events (turn, press)*/
|
||||
@@ -369,7 +357,7 @@ static void button_init(void)
|
||||
}
|
||||
|
||||
/*Will be called by the library to read the button*/
|
||||
static bool button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
static void button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
{
|
||||
|
||||
static uint8_t last_btn = 0;
|
||||
@@ -386,9 +374,6 @@ static bool button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
|
||||
/*Save the last pressed button's ID*/
|
||||
data->btn_id = last_btn;
|
||||
|
||||
/*Return `false` because we are not buffering and no more data to read*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/*Get ID (0, 1, 2 ..) of the pressed button*/
|
||||
|
||||
@@ -8,7 +8,7 @@ static void set_value(void *bar, int32_t v)
|
||||
|
||||
static void event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param(e);
|
||||
lv_obj_draw_part_dsc_t * dsc = lv_event_get_param(e);
|
||||
if(dsc->part != LV_PART_INDICATOR) return;
|
||||
|
||||
lv_obj_t * obj= lv_event_get_target(e);
|
||||
|
||||
@@ -47,7 +47,7 @@ void lv_example_btn_2(void)
|
||||
/*Add a transition to the the outline*/
|
||||
static lv_style_transition_dsc_t trans;
|
||||
static lv_style_prop_t props[] = {LV_STYLE_OUTLINE_WIDTH, LV_STYLE_OUTLINE_OPA, 0};
|
||||
lv_style_transition_dsc_init(&trans, props, lv_anim_path_linear, 300, 0);
|
||||
lv_style_transition_dsc_init(&trans, props, lv_anim_path_linear, 300, 0, NULL);
|
||||
|
||||
lv_style_set_transition(&style_pr, &trans);
|
||||
|
||||
|
||||
@@ -14,12 +14,12 @@ void lv_example_btn_3(void)
|
||||
/*Transition descriptor when going back to the default state.
|
||||
*Add some delay to be sure the press transition is visible even if the press was very short*/
|
||||
static lv_style_transition_dsc_t transition_dsc_def;
|
||||
lv_style_transition_dsc_init(&transition_dsc_def, props, lv_anim_path_overshoot, 250, 100);
|
||||
lv_style_transition_dsc_init(&transition_dsc_def, props, lv_anim_path_overshoot, 250, 100, NULL);
|
||||
|
||||
/*Transition descriptor when going to pressed state.
|
||||
*No delay, go to presses state immediately*/
|
||||
static lv_style_transition_dsc_t transition_dsc_pr;
|
||||
lv_style_transition_dsc_init(&transition_dsc_pr, props, lv_anim_path_ease_in_out, 250, 0);
|
||||
lv_style_transition_dsc_init(&transition_dsc_pr, props, lv_anim_path_ease_in_out, 250, 0, NULL);
|
||||
|
||||
/*Add only the new transition to he default state*/
|
||||
static lv_style_t style_def;
|
||||
|
||||
@@ -7,7 +7,7 @@ static void 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_DRAW_PART_BEGIN) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param(e);
|
||||
lv_obj_draw_part_dsc_t * dsc = lv_event_get_param(e);
|
||||
|
||||
/*Change the draw descriptor the 2nd button*/
|
||||
if(dsc->id == 1) {
|
||||
@@ -34,7 +34,7 @@ static void event_cb(lv_event_t * e)
|
||||
}
|
||||
}
|
||||
if(code == LV_EVENT_DRAW_PART_END) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param(e);
|
||||
lv_obj_draw_part_dsc_t * dsc = lv_event_get_param(e);
|
||||
|
||||
/*Add custom content to the 4th button when the button itself was drawn*/
|
||||
if(dsc->id == 3) {
|
||||
|
||||
@@ -10,7 +10,7 @@ static void draw_event_cb(lv_event_t * e)
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
|
||||
/*Add the faded area before the lines are drawn*/
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param(e);
|
||||
lv_obj_draw_part_dsc_t * dsc = lv_event_get_draw_part_dsc(e);
|
||||
if(dsc->part == LV_PART_ITEMS) {
|
||||
if(!dsc->p1 || !dsc->p2) return;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
static void draw_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param(e);
|
||||
lv_obj_draw_part_dsc_t * dsc = lv_event_get_param(e);
|
||||
if(dsc->part == LV_PART_TICKS && dsc->id == LV_CHART_AXIS_X) {
|
||||
const char * month[] = {"Jan", "Febr", "March", "Apr", "May", "Jun", "July", "Aug", "Sept", "Oct", "Nov", "Dec"};
|
||||
lv_snprintf(dsc->text, sizeof(dsc->text), "%s", month[dsc->value]);
|
||||
|
||||
@@ -45,7 +45,7 @@ static void event_cb(lv_event_t * e)
|
||||
a.y1 = chart->coords.y1 + p.y - 30;
|
||||
a.y2 = chart->coords.y1 + p.y - 10;
|
||||
|
||||
const lv_area_t * clip_area = lv_event_get_param(e);
|
||||
const lv_area_t * clip_area = lv_event_get_clip_area(e);
|
||||
lv_draw_rect(&a, clip_area, &draw_rect_dsc);
|
||||
|
||||
ser = lv_chart_get_series_next(chart, ser);
|
||||
|
||||
@@ -20,7 +20,7 @@ static void event_cb(lv_event_t * e)
|
||||
}
|
||||
}
|
||||
else if(code == LV_EVENT_DRAW_PART_END) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param(e);
|
||||
lv_obj_draw_part_dsc_t * dsc = lv_event_get_draw_part_dsc(e);
|
||||
if(dsc->part == LV_PART_CURSOR && dsc->p1 && dsc->p2 && dsc->p1->y == dsc->p2->y && last_id >= 0) {
|
||||
lv_coord_t * data_array = lv_chart_get_array(chart, ser);
|
||||
lv_coord_t v = data_array[last_id];
|
||||
|
||||
@@ -10,7 +10,7 @@ void lv_example_imgbtn_1(void)
|
||||
/*Create a transition animation on width transformation and recolor.*/
|
||||
static lv_style_prop_t tr_prop[] = {LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_IMG_RECOLOR_OPA, 0};
|
||||
static lv_style_transition_dsc_t tr;
|
||||
lv_style_transition_dsc_init(&tr, tr_prop, lv_anim_path_linear, 200, 0);
|
||||
lv_style_transition_dsc_init(&tr, tr_prop, lv_anim_path_linear, 200, 0, NULL);
|
||||
|
||||
static lv_style_t style_def;
|
||||
lv_style_init(&style_def);
|
||||
|
||||
@@ -11,7 +11,7 @@ void lv_example_slider_2(void)
|
||||
/*Create a transition*/
|
||||
static const lv_style_prop_t props[] = {LV_STYLE_BG_COLOR, 0};
|
||||
static lv_style_transition_dsc_t transition_dsc;
|
||||
lv_style_transition_dsc_init(&transition_dsc, props, lv_anim_path_linear, 300, 0);
|
||||
lv_style_transition_dsc_init(&transition_dsc, props, lv_anim_path_linear, 300, 0, NULL);
|
||||
|
||||
static lv_style_t style_main;
|
||||
static lv_style_t style_indicator;
|
||||
|
||||
@@ -33,7 +33,7 @@ static void slider_event_cb(lv_event_t * e)
|
||||
*size = LV_MAX(*size, 50);
|
||||
}
|
||||
else if(code == LV_EVENT_DRAW_PART_END) {
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param(e);
|
||||
lv_obj_draw_part_dsc_t * dsc = lv_event_get_param(e);
|
||||
if(dsc->part == LV_PART_INDICATOR) {
|
||||
char buf[16];
|
||||
lv_snprintf(buf, sizeof(buf), "%d - %d", lv_slider_get_left_value(obj), lv_slider_get_value(obj));
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
static void draw_part_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param(e);
|
||||
lv_obj_draw_part_dsc_t * dsc = lv_event_get_param(e);
|
||||
/*If the cells are drawn...*/
|
||||
if(dsc->part == LV_PART_ITEMS) {
|
||||
uint32_t row = dsc->id / lv_table_get_col_cnt(obj);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
static void draw_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param(e);
|
||||
lv_obj_draw_part_dsc_t * dsc = lv_event_get_draw_part_dsc(e);
|
||||
/*If the cells are drawn...*/
|
||||
if(dsc->part == LV_PART_ITEMS) {
|
||||
bool chk = lv_table_has_cell_ctrl(obj, dsc->id, 0, LV_TABLE_CELL_CTRL_CUSTOM_1);
|
||||
|
||||
@@ -212,6 +212,61 @@ bool lv_obj_remove_event_dsc(lv_obj_t * obj, struct _lv_event_dsc_t * event_dsc)
|
||||
return false;
|
||||
}
|
||||
|
||||
lv_indev_t * lv_event_get_indev(lv_event_t * e)
|
||||
{
|
||||
|
||||
if(e->code == LV_EVENT_PRESSED ||
|
||||
e->code == LV_EVENT_PRESSING ||
|
||||
e->code == LV_EVENT_PRESS_LOST ||
|
||||
e->code == LV_EVENT_SHORT_CLICKED ||
|
||||
e->code == LV_EVENT_LONG_PRESSED ||
|
||||
e->code == LV_EVENT_LONG_PRESSED_REPEAT ||
|
||||
e->code == LV_EVENT_CLICKED ||
|
||||
e->code == LV_EVENT_RELEASED ||
|
||||
e->code == LV_EVENT_SCROLL_BEGIN ||
|
||||
e->code == LV_EVENT_SCROLL_END ||
|
||||
e->code == LV_EVENT_SCROLL ||
|
||||
e->code == LV_EVENT_GESTURE ||
|
||||
e->code == LV_EVENT_KEY ||
|
||||
e->code == LV_EVENT_FOCUSED ||
|
||||
e->code == LV_EVENT_DEFOCUSED ||
|
||||
e->code == LV_EVENT_LEAVE)
|
||||
{
|
||||
return lv_event_get_param(e);
|
||||
} else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
lv_obj_draw_part_dsc_t * lv_event_get_draw_part_dsc(lv_event_t * e)
|
||||
{
|
||||
if(e->code == LV_EVENT_DRAW_PART_BEGIN||
|
||||
e->code == LV_EVENT_DRAW_PART_END)
|
||||
{
|
||||
return lv_event_get_param(e);
|
||||
} else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const lv_area_t * lv_event_get_clip_area(lv_event_t * e)
|
||||
{
|
||||
if(e->code == LV_EVENT_DRAW_MAIN ||
|
||||
e->code == LV_EVENT_DRAW_MAIN_BEGIN ||
|
||||
e->code == LV_EVENT_DRAW_MAIN_END ||
|
||||
e->code == LV_EVENT_DRAW_POST ||
|
||||
e->code == LV_EVENT_DRAW_POST_BEGIN ||
|
||||
e->code == LV_EVENT_DRAW_POST_END)
|
||||
{
|
||||
return lv_event_get_param(e);
|
||||
} else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
|
||||
@@ -206,6 +206,28 @@ bool lv_obj_remove_event_cb(struct _lv_obj_t * obj, lv_event_cb_t event_cb);
|
||||
*/
|
||||
bool lv_obj_remove_event_dsc(struct _lv_obj_t * obj, struct _lv_event_dsc_t * event_dsc);
|
||||
|
||||
/**
|
||||
* Get the input device passed as parameter to indev related events.
|
||||
* @param e pointer to an event
|
||||
* @return the indev that triggered the event or NULL if called on a not indev related event
|
||||
*/
|
||||
lv_indev_t * lv_event_get_indev(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Get the part draw descriptor passed as parameter to `LV_EVENT_DRAW_PART_BEGIN/END`.
|
||||
* @param e pointer to an event
|
||||
* @return the part draw descriptor to hook the drawing or NULL if called on an unrelated event
|
||||
*/
|
||||
lv_obj_draw_part_dsc_t * lv_event_get_draw_part_dsc(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Get the clip area passed as parameter to draw events events.
|
||||
* Namely: `LV_EVENT_DRAW_MAIN/POST`, `LV_EVENT_DRAW_MAIN/POST_BEGIN`, `LV_EVENT_DRAW_MAIN/POST_END`
|
||||
* @param e pointer to an event
|
||||
* @return the clip area to use during drawing or NULL if called on an unrelated event
|
||||
*/
|
||||
const lv_area_t * lv_event_get_clip_area(lv_event_t * e);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
@@ -76,10 +76,11 @@ void lv_indev_read_timer_cb(lv_timer_t * timer)
|
||||
indev_proc_reset_query_handler(indev_act);
|
||||
|
||||
if(indev_act->proc.disabled) return;
|
||||
bool more_to_read;
|
||||
bool continue_reading;
|
||||
do {
|
||||
/*Read the data*/
|
||||
more_to_read = _lv_indev_read(indev_act, &data);
|
||||
_lv_indev_read(indev_act, &data);
|
||||
continue_reading = data.continue_reading;
|
||||
|
||||
/*The active object might deleted even in the read function*/
|
||||
indev_proc_reset_query_handler(indev_act);
|
||||
@@ -109,7 +110,7 @@ void lv_indev_read_timer_cb(lv_timer_t * timer)
|
||||
}
|
||||
/*Handle reset query if it happened in during processing*/
|
||||
indev_proc_reset_query_handler(indev_act);
|
||||
} while(more_to_read);
|
||||
} while(continue_reading);
|
||||
|
||||
/*End of indev processing, so no act indev*/
|
||||
indev_act = NULL;
|
||||
|
||||
@@ -324,9 +324,9 @@ lv_coord_t lv_obj_calculate_ext_draw_size(lv_obj_t * obj, uint32_t part)
|
||||
return s;
|
||||
}
|
||||
|
||||
void lv_obj_draw_dsc_init(lv_obj_draw_dsc_t * dsc, const lv_area_t * clip_area)
|
||||
void lv_obj_draw_dsc_init(lv_obj_draw_part_dsc_t * dsc, const lv_area_t * clip_area)
|
||||
{
|
||||
lv_memset_00(dsc, sizeof(lv_obj_draw_dsc_t));
|
||||
lv_memset_00(dsc, sizeof(lv_obj_draw_part_dsc_t));
|
||||
dsc->clip_area = clip_area;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ typedef struct
|
||||
uint32_t id;
|
||||
uint32_t part;
|
||||
const void * sub_part_ptr;
|
||||
}lv_obj_draw_dsc_t;
|
||||
}lv_obj_draw_part_dsc_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@@ -118,7 +118,7 @@ lv_coord_t lv_obj_calculate_ext_draw_size(struct _lv_obj_t * obj, uint32_t part)
|
||||
* @param dsc pointer to a descriptor. Later it should be passed as parameter to an `LV_EEVNT_DRAW_PART_BEGIN/END` event.
|
||||
* @param clip_area the current clip area of the drawing
|
||||
*/
|
||||
void lv_obj_draw_dsc_init(lv_obj_draw_dsc_t * dsc, const lv_area_t * clip_area);
|
||||
void lv_obj_draw_dsc_init(lv_obj_draw_part_dsc_t * dsc, const lv_area_t * clip_area);
|
||||
|
||||
/**
|
||||
* Send a 'LV_EVENT_REFR_EXT_DRAW_SIZE' Call the ancestor's event handler to the object to refresh the value of the extended draw size.
|
||||
|
||||
@@ -590,21 +590,21 @@ void lv_obj_get_content_coords(const lv_obj_t * obj, lv_area_t * area)
|
||||
|
||||
}
|
||||
|
||||
lv_coord_t lv_obj_get_self_width(struct _lv_obj_t * obj)
|
||||
lv_coord_t lv_obj_get_self_width(const lv_obj_t * obj)
|
||||
{
|
||||
lv_point_t p = {0, LV_COORD_MIN};
|
||||
lv_event_send((lv_obj_t * )obj, LV_EVENT_REFR_SELF_SIZE, &p);
|
||||
return p.x;
|
||||
}
|
||||
|
||||
lv_coord_t lv_obj_get_self_height(struct _lv_obj_t * obj)
|
||||
lv_coord_t lv_obj_get_self_height(const lv_obj_t * obj)
|
||||
{
|
||||
lv_point_t p = {LV_COORD_MIN, 0};
|
||||
lv_event_send((lv_obj_t * )obj, LV_EVENT_REFR_SELF_SIZE, &p);
|
||||
return p.y;
|
||||
}
|
||||
|
||||
bool lv_obj_refresh_self_size(struct _lv_obj_t * obj)
|
||||
bool lv_obj_refresh_self_size(lv_obj_t * obj)
|
||||
{
|
||||
lv_coord_t w_set = lv_obj_get_style_width(obj, LV_PART_MAIN);
|
||||
lv_coord_t h_set = lv_obj_get_style_height(obj, LV_PART_MAIN);
|
||||
|
||||
@@ -277,7 +277,7 @@ void lv_obj_get_content_coords(const struct _lv_obj_t * obj, lv_area_t * area);
|
||||
* @note This size independent from the real size of the widget.
|
||||
* It just tells how large the internal ("virtual") content is.
|
||||
*/
|
||||
lv_coord_t lv_obj_get_self_width(struct _lv_obj_t * obj);
|
||||
lv_coord_t lv_obj_get_self_width(const struct _lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the height occupied by the "parts" of the widget. E.g. the height of all rows of a table.
|
||||
@@ -286,7 +286,7 @@ lv_coord_t lv_obj_get_self_width(struct _lv_obj_t * obj);
|
||||
* @note This size independent from the real size of the widget.
|
||||
* It just tells how large the internal ("virtual") content is.
|
||||
*/
|
||||
lv_coord_t lv_obj_get_self_height(struct _lv_obj_t * obj);
|
||||
lv_coord_t lv_obj_get_self_height(const struct _lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Handle if the size of the internal ("virtual") content of an object has changed.
|
||||
|
||||
@@ -213,10 +213,10 @@ static void style_init(void)
|
||||
color_grey = theme.flags & MODE_DARK ? DARK_COLOR_GREY : LIGHT_COLOR_GREY;
|
||||
|
||||
static lv_style_transition_dsc_t trans_delayed;
|
||||
lv_style_transition_dsc_init(&trans_delayed, trans_props, lv_anim_path_linear, TRANSITION_TIME, 70);
|
||||
lv_style_transition_dsc_init(&trans_delayed, trans_props, lv_anim_path_linear, TRANSITION_TIME, 70, NULL);
|
||||
|
||||
static lv_style_transition_dsc_t trans_normal;
|
||||
lv_style_transition_dsc_init(&trans_normal, trans_props, lv_anim_path_linear, TRANSITION_TIME, 0);
|
||||
lv_style_transition_dsc_init(&trans_normal, trans_props, lv_anim_path_linear, TRANSITION_TIME, 0, NULL);
|
||||
|
||||
style_init_reset(&styles->transition_delayed);
|
||||
lv_style_set_transition(&styles->transition_delayed, &trans_delayed); /*Go back to default state with delay*/
|
||||
|
||||
@@ -255,7 +255,7 @@ static void lv_calendar_constructor(const lv_obj_class_t * class_p, lv_obj_t * o
|
||||
static void draw_part_begin_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
lv_obj_draw_dsc_t * dsc = lv_event_get_param(e);
|
||||
lv_obj_draw_part_dsc_t * dsc = lv_event_get_param(e);
|
||||
if(dsc->part == LV_PART_ITEMS) {
|
||||
/*Day name styles*/
|
||||
if(dsc->id < 7) {
|
||||
|
||||
@@ -682,7 +682,7 @@ static void draw_div_lines(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
lv_draw_line_dsc_init(&line_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_PART_MAIN, &line_dsc);
|
||||
|
||||
lv_obj_draw_dsc_t obj_draw_dsc;
|
||||
lv_obj_draw_part_dsc_t obj_draw_dsc;
|
||||
lv_obj_draw_dsc_init(&obj_draw_dsc, clip_area);
|
||||
obj_draw_dsc.line_dsc = &line_dsc;
|
||||
obj_draw_dsc.part = LV_PART_MAIN;
|
||||
@@ -804,7 +804,7 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
y_tmp = y_tmp / (chart->ymax[ser->y_axis] - chart->ymin[ser->y_axis]);
|
||||
p2.y = h - y_tmp + y_ofs;
|
||||
|
||||
lv_obj_draw_dsc_t dsc;
|
||||
lv_obj_draw_part_dsc_t dsc;
|
||||
lv_obj_draw_dsc_init(&dsc, clip_area);
|
||||
dsc.part = LV_PART_ITEMS;
|
||||
dsc.line_dsc = &line_dsc_default;
|
||||
@@ -941,7 +941,7 @@ static void draw_series_bar(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
bool mask_ret = _lv_area_intersect(&series_mask, &obj->coords, clip_area);
|
||||
if(mask_ret == false) return;
|
||||
|
||||
lv_obj_draw_dsc_t dsc;
|
||||
lv_obj_draw_part_dsc_t dsc;
|
||||
lv_obj_draw_dsc_init(&dsc, &series_mask);
|
||||
dsc.part = LV_PART_ITEMS;
|
||||
|
||||
@@ -1009,7 +1009,7 @@ static void draw_cursors(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
lv_coord_t point_w = lv_obj_get_style_width(obj, LV_PART_CURSOR) / 2;
|
||||
lv_coord_t point_h = lv_obj_get_style_width(obj, LV_PART_CURSOR) / 2;
|
||||
|
||||
lv_obj_draw_dsc_t dsc;
|
||||
lv_obj_draw_part_dsc_t dsc;
|
||||
lv_obj_draw_dsc_init(&dsc, clip_area);
|
||||
dsc.line_dsc = &line_dsc_tmp;
|
||||
dsc.rect_dsc = &point_dsc_tmp;
|
||||
@@ -1106,7 +1106,7 @@ static void draw_y_ticks(lv_obj_t * obj, const lv_area_t * clip_area, lv_chart_a
|
||||
minor_len *= -1;
|
||||
}
|
||||
|
||||
lv_obj_draw_dsc_t dsc;
|
||||
lv_obj_draw_part_dsc_t dsc;
|
||||
lv_obj_draw_dsc_init(&dsc, clip_area);
|
||||
dsc.id = axis;
|
||||
dsc.part = LV_PART_TICKS;
|
||||
@@ -1212,7 +1212,7 @@ static void draw_x_ticks(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
line_dsc.dash_gap = 0;
|
||||
line_dsc.dash_width = 0;
|
||||
|
||||
lv_obj_draw_dsc_t dsc;
|
||||
lv_obj_draw_part_dsc_t dsc;
|
||||
lv_obj_draw_dsc_init(&dsc, clip_area);
|
||||
dsc.id = LV_CHART_AXIS_X;
|
||||
dsc.part = LV_PART_TICKS;
|
||||
|
||||
@@ -359,7 +359,7 @@ static void draw_ticks_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c
|
||||
|
||||
lv_meter_scale_t * scale;
|
||||
|
||||
lv_obj_draw_dsc_t dsc;
|
||||
lv_obj_draw_part_dsc_t dsc;
|
||||
lv_obj_draw_dsc_init(&dsc, clip_area);
|
||||
|
||||
#if LV_DRAW_COMPLEX
|
||||
|
||||
@@ -127,12 +127,9 @@ lv_indev_t * lv_indev_get_next(lv_indev_t * indev)
|
||||
* Read data from an input device.
|
||||
* @param indev pointer to an input device
|
||||
* @param data input device will write its data here
|
||||
* @return false: no more data; true: there more data to read (buffered)
|
||||
*/
|
||||
bool _lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data)
|
||||
void _lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data)
|
||||
{
|
||||
bool cont = false;
|
||||
|
||||
lv_memset_00(data, sizeof(lv_indev_data_t));
|
||||
|
||||
/* For touchpad sometimes users don't set the last pressed coordinate on release.
|
||||
@@ -152,13 +149,11 @@ bool _lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data)
|
||||
|
||||
if(indev->driver->read_cb) {
|
||||
INDEV_TRACE("calling indev_read_cb");
|
||||
cont = indev->driver->read_cb(indev->driver, data);
|
||||
indev->driver->read_cb(indev->driver, data);
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("indev_read_cb is not registered");
|
||||
}
|
||||
|
||||
return cont;
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -81,6 +81,7 @@ typedef struct {
|
||||
int16_t enc_diff; /**< For LV_INDEV_TYPE_ENCODER number of steps since the previous read*/
|
||||
|
||||
lv_indev_state_t state; /**< LV_INDEV_STATE_REL or LV_INDEV_STATE_PR*/
|
||||
bool continue_reading; /**< Call the read callback until it's set to true*/
|
||||
} lv_indev_data_t;
|
||||
|
||||
/** Initialized by the user and registered by 'lv_indev_add()'*/
|
||||
@@ -89,10 +90,8 @@ typedef struct _lv_indev_drv_t {
|
||||
/**< Input device type*/
|
||||
lv_indev_type_t type;
|
||||
|
||||
/**< Function pointer to read input device data.
|
||||
* Return 'true' if there is more data to be read (buffered).
|
||||
* Most drivers can safely return 'false'*/
|
||||
bool (*read_cb)(struct _lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
/**< Function pointer to read input device data.*/
|
||||
void (*read_cb)(struct _lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
|
||||
/** Called when an action happened on the input device.
|
||||
* The second parameter is the event from `lv_event_t`*/
|
||||
@@ -220,9 +219,8 @@ lv_indev_t * lv_indev_get_next(lv_indev_t * indev);
|
||||
* Read data from an input device.
|
||||
* @param indev pointer to an input device
|
||||
* @param data input device will write its data here
|
||||
* @return false: no more data; true: there more data to read (buffered)
|
||||
*/
|
||||
bool _lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data);
|
||||
void _lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
@@ -210,13 +210,18 @@ lv_res_t lv_style_get_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_va
|
||||
return lv_style_get_prop_inlined(style, prop, value);
|
||||
}
|
||||
|
||||
void lv_style_transition_dsc_init(lv_style_transition_dsc_t * tr, const lv_style_prop_t props[], lv_anim_path_cb_t path_cb, uint32_t time, uint32_t delay)
|
||||
void lv_style_transition_dsc_init(lv_style_transition_dsc_t * tr, const lv_style_prop_t props[], lv_anim_path_cb_t path_cb, uint32_t time, uint32_t delay, void * user_data)
|
||||
{
|
||||
lv_memset_00(tr, sizeof(lv_style_transition_dsc_t));
|
||||
tr->props = props;
|
||||
tr->path_xcb = path_cb == NULL ? lv_anim_path_linear : path_cb;
|
||||
tr->time = time;
|
||||
tr->delay = delay;
|
||||
#if LV_USE_USER_DATA
|
||||
tr->user_data = user_data;
|
||||
#else
|
||||
LV_UNUSED(user_data);
|
||||
#endif
|
||||
}
|
||||
|
||||
lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop)
|
||||
|
||||
@@ -385,15 +385,16 @@ static inline lv_res_t lv_style_get_prop_inlined(lv_style_t * style, lv_style_pr
|
||||
* Initialize a transition descriptor.
|
||||
* @param tr pointer to a transition descriptor to initialize
|
||||
* @param props an array with the properties to transition. The last element must be zero.
|
||||
* @param path_cb and animation path (ease) callback. If `NULL` liner path will be used.
|
||||
* @param path_cb an animation path (ease) callback. If `NULL` liner path will be used.
|
||||
* @param time duration of the transition in [ms]
|
||||
* @param delay delay before the transition in [ms]
|
||||
* @param user_data any custom data that will be saved in the transition animation and will be available when `path_cb` is called
|
||||
* @example
|
||||
* const static lv_style_prop_t trans_props[] = { LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR, 0 };
|
||||
* static lv_style_transition_dsc_t trans1;
|
||||
* lv_style_transition_dsc_init(&trans1, trans_props, NULL, 300, 0);
|
||||
* lv_style_transition_dsc_init(&trans1, trans_props, NULL, 300, 0, NULL);
|
||||
*/
|
||||
void lv_style_transition_dsc_init(lv_style_transition_dsc_t * tr, const lv_style_prop_t props[], lv_anim_path_cb_t path_cb, uint32_t time, uint32_t delay);
|
||||
void lv_style_transition_dsc_init(lv_style_transition_dsc_t * tr, const lv_style_prop_t props[], lv_anim_path_cb_t path_cb, uint32_t time, uint32_t delay, void * user_data);
|
||||
|
||||
/**
|
||||
* Get the default value of a property
|
||||
|
||||
@@ -687,7 +687,7 @@ static void lv_arc_draw(lv_event_t * e)
|
||||
lv_coord_t arc_r;
|
||||
get_center(obj, ¢er, &arc_r);
|
||||
|
||||
lv_obj_draw_dsc_t obj_draw_dsc;
|
||||
lv_obj_draw_part_dsc_t obj_draw_dsc;
|
||||
lv_obj_draw_dsc_init(&obj_draw_dsc, clip_area);
|
||||
|
||||
/*Draw the background arc*/
|
||||
|
||||
@@ -382,7 +382,7 @@ static void draw_indic(lv_event_t * e)
|
||||
/*Do not draw a zero length indicator but at least call the draw part events*/
|
||||
if(!sym && indic_length_calc(&bar->indic_area) <= 1) {
|
||||
|
||||
lv_obj_draw_dsc_t obj_draw_dsc;
|
||||
lv_obj_draw_part_dsc_t obj_draw_dsc;
|
||||
lv_obj_draw_dsc_init(&obj_draw_dsc, clip_area);
|
||||
obj_draw_dsc.part = LV_PART_INDICATOR;
|
||||
obj_draw_dsc.draw_area = &bar->indic_area;
|
||||
@@ -403,7 +403,7 @@ static void draw_indic(lv_event_t * e)
|
||||
lv_draw_rect_dsc_init(&draw_rect_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_INDICATOR, &draw_rect_dsc);
|
||||
|
||||
lv_obj_draw_dsc_t obj_draw_dsc;
|
||||
lv_obj_draw_part_dsc_t obj_draw_dsc;
|
||||
lv_obj_draw_dsc_init(&obj_draw_dsc, clip_area);
|
||||
obj_draw_dsc.part = LV_PART_INDICATOR;
|
||||
obj_draw_dsc.rect_dsc = &draw_rect_dsc;
|
||||
|
||||
@@ -661,7 +661,7 @@ static void draw_main(lv_event_t * e)
|
||||
char * txt_ap = lv_mem_buf_get(txt_ap_size);
|
||||
#endif
|
||||
|
||||
lv_obj_draw_dsc_t dsc;
|
||||
lv_obj_draw_part_dsc_t dsc;
|
||||
lv_obj_draw_dsc_init(&dsc, clip_area);
|
||||
dsc.part = LV_PART_ITEMS;
|
||||
dsc.rect_dsc = &draw_rect_dsc_act;
|
||||
|
||||
@@ -234,7 +234,7 @@ static void lv_checkbox_draw(lv_event_t * e)
|
||||
marker_area_transf.y1 -= transf_h;
|
||||
marker_area_transf.y2 += transf_h;
|
||||
|
||||
lv_obj_draw_dsc_t obj_draw_dsc;
|
||||
lv_obj_draw_part_dsc_t obj_draw_dsc;
|
||||
lv_obj_draw_dsc_init(&obj_draw_dsc, clip_area);
|
||||
obj_draw_dsc.rect_dsc = &indic_dsc;
|
||||
obj_draw_dsc.draw_area = &marker_area_transf;
|
||||
|
||||
@@ -372,7 +372,7 @@ static void draw_knob(lv_event_t * e)
|
||||
position_knob(obj, &knob_area, knob_size, hor);
|
||||
lv_area_copy(&slider->right_knob_area, &knob_area);
|
||||
|
||||
lv_obj_draw_dsc_t dsc;
|
||||
lv_obj_draw_part_dsc_t dsc;
|
||||
lv_obj_draw_dsc_init(&dsc, clip_area);
|
||||
dsc.part = LV_PART_KNOB;
|
||||
dsc.id = 0;
|
||||
|
||||
@@ -619,7 +619,7 @@ static void draw_main(lv_event_t * e)
|
||||
bool rtl = lv_obj_get_base_dir(obj) == LV_BIDI_DIR_RTL ? true : false;
|
||||
|
||||
/*Handle custom drawer*/
|
||||
lv_obj_draw_dsc_t dsc;
|
||||
lv_obj_draw_part_dsc_t dsc;
|
||||
lv_obj_draw_dsc_init(&dsc, clip_area);
|
||||
dsc.part = LV_PART_ITEMS;
|
||||
dsc.rect_dsc = &rect_dsc_act;
|
||||
|
||||
Reference in New Issue
Block a user