mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
change custom drawer to event
This commit is contained in:
parent
c64810dac4
commit
1d6d2eb9d9
4
lvgl.h
4
lvgl.h
@ -59,9 +59,7 @@ extern "C" {
|
||||
#include "src/lv_widgets/lv_roller.h"
|
||||
#include "src/lv_widgets/lv_textarea.h"
|
||||
#include "src/lv_widgets/lv_canvas.h"
|
||||
#include "src/lv_widgets/lv_objmask.h"
|
||||
#include "src/lv_widgets/lv_gauge.h"
|
||||
#include "src/lv_widgets/lv_linemeter.h"
|
||||
#include "src/lv_widgets/lv_meter.h"
|
||||
#include "src/lv_widgets/lv_switch.h"
|
||||
#include "src/lv_widgets/lv_arc.h"
|
||||
|
||||
|
@ -41,7 +41,8 @@ const lv_flex_t lv_flex_center = {
|
||||
.item_main_place = LV_FLEX_PLACE_CENTER,
|
||||
.item_cross_place = LV_FLEX_PLACE_CENTER,
|
||||
.track_place = LV_FLEX_PLACE_CENTER,
|
||||
.dir = LV_FLEX_FLOW_COLUMN
|
||||
.dir = LV_FLEX_FLOW_ROW,
|
||||
.wrap = 1
|
||||
};
|
||||
|
||||
const lv_flex_t lv_flex_stacked = {
|
||||
|
@ -70,7 +70,7 @@ typedef struct {
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_drawer_res_t lv_obj_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_obj_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
static void lv_event_mark_deleted(lv_obj_t * obj);
|
||||
static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find);
|
||||
@ -78,7 +78,7 @@ static void lv_obj_del_async_cb(void * obj);
|
||||
static void obj_del_core(lv_obj_t * obj);
|
||||
static void base_dir_refr_children(lv_obj_t * obj);
|
||||
static void lv_obj_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_obj_destructor(void * obj);
|
||||
static void lv_obj_destructor(lv_obj_t * obj);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -90,7 +90,7 @@ const lv_obj_class_t lv_obj = {
|
||||
.constructor = lv_obj_constructor,
|
||||
.destructor = lv_obj_destructor,
|
||||
.signal_cb = lv_obj_signal,
|
||||
.drawer_cb = lv_obj_drawer,
|
||||
.draw_cb = lv_obj_draw,
|
||||
.instance_size = (sizeof(lv_obj_t)),
|
||||
.base_class = NULL,
|
||||
};
|
||||
@ -797,6 +797,10 @@ lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, const void * data)
|
||||
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
/*Nothing to do if no event function and not bubbled*/
|
||||
if(lv_obj_get_event_cb(obj) == NULL && lv_obj_has_flag(obj, LV_OBJ_FLAG_EVENT_BUBBLE) == false) {
|
||||
return LV_RES_OK;
|
||||
}
|
||||
lv_res_t res;
|
||||
res = lv_event_send_func(lv_obj_get_event_cb(obj), obj, event, data);
|
||||
return res;
|
||||
@ -857,13 +861,11 @@ void lv_event_send_refresh_recursive(lv_obj_t * obj)
|
||||
*/
|
||||
lv_res_t lv_event_send_func(lv_event_cb_t event_xcb, lv_obj_t * obj, lv_event_t event, const void * data)
|
||||
{
|
||||
if(obj != NULL) {
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
}
|
||||
|
||||
/* Build a simple linked list from the objects used in the events
|
||||
* It's important to know if an this object was deleted by a nested event
|
||||
* called from this `even_cb`. */
|
||||
* called from this `event_cb`. */
|
||||
lv_event_temp_data_t event_temp_data;
|
||||
event_temp_data.obj = obj;
|
||||
event_temp_data.deleted = false;
|
||||
@ -892,17 +894,13 @@ lv_res_t lv_event_send_func(lv_event_cb_t event_xcb, lv_obj_t * obj, lv_event_t
|
||||
/*Remove this element from the list*/
|
||||
event_temp_data_head = event_temp_data_head->prev;
|
||||
|
||||
if(event_temp_data.deleted) {
|
||||
return LV_RES_INV;
|
||||
}
|
||||
if(event_temp_data.deleted) return LV_RES_INV;
|
||||
|
||||
if(obj) {
|
||||
if(lv_obj_has_flag(obj, LV_OBJ_FLAG_EVENT_BUBBLE) && obj->parent) {
|
||||
|
||||
lv_res_t res = lv_event_send(obj->parent, event, data);
|
||||
if(res != LV_RES_OK) {
|
||||
return LV_RES_INV;
|
||||
}
|
||||
if(res != LV_RES_OK) return LV_RES_INV;
|
||||
}
|
||||
}
|
||||
|
||||
@ -913,7 +911,7 @@ lv_res_t lv_event_send_func(lv_event_cb_t event_xcb, lv_obj_t * obj, lv_event_t
|
||||
* Get the `data` parameter of the current event
|
||||
* @return the `data` parameter
|
||||
*/
|
||||
const void * lv_event_get_data(void)
|
||||
void * lv_event_get_data(void)
|
||||
{
|
||||
return event_act_data;
|
||||
}
|
||||
@ -1529,7 +1527,7 @@ static void lv_obj_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t
|
||||
LV_LOG_INFO("Object create ready");
|
||||
}
|
||||
|
||||
static void lv_obj_destructor(void * p)
|
||||
static void lv_obj_destructor(lv_obj_t * p)
|
||||
{
|
||||
lv_obj_t * obj = p;
|
||||
lv_obj_remove_all_styles(obj);
|
||||
@ -1541,15 +1539,15 @@ static void lv_obj_destructor(void * p)
|
||||
* Handle the drawing related tasks of the base objects.
|
||||
* @param obj pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_obj_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_obj_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DRAWER_MODE_COVER_CHECK) {
|
||||
if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) return LV_DRAWER_RES_MASKED;
|
||||
if(mode == LV_DRAW_MODE_COVER_CHECK) {
|
||||
if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) return LV_DRAW_RES_MASKED;
|
||||
|
||||
/*Most trivial test. Is the mask fully IN the object? If no it surely doesn't cover it*/
|
||||
lv_coord_t r = lv_obj_get_style_radius(obj, LV_PART_MAIN);
|
||||
@ -1562,18 +1560,18 @@ static lv_drawer_res_t lv_obj_drawer(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
coords.y1 -= h;
|
||||
coords.y2 += h;
|
||||
|
||||
if(_lv_area_is_in(clip_area, &coords, r) == false) return LV_DRAWER_RES_NOT_COVER;
|
||||
if(_lv_area_is_in(clip_area, &coords, r) == false) return LV_DRAW_RES_NOT_COVER;
|
||||
|
||||
if(lv_obj_get_style_bg_opa(obj, LV_PART_MAIN) < LV_OPA_MAX) return LV_DRAWER_RES_NOT_COVER;
|
||||
if(lv_obj_get_style_bg_opa(obj, LV_PART_MAIN) < LV_OPA_MAX) return LV_DRAW_RES_NOT_COVER;
|
||||
|
||||
if(lv_obj_get_style_bg_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAWER_RES_NOT_COVER;
|
||||
if(lv_obj_get_style_border_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAWER_RES_NOT_COVER;
|
||||
if(lv_obj_get_style_opa(obj, LV_PART_MAIN) < LV_OPA_MAX) return LV_DRAWER_RES_NOT_COVER;
|
||||
if(lv_obj_get_style_bg_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAW_RES_NOT_COVER;
|
||||
if(lv_obj_get_style_border_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAW_RES_NOT_COVER;
|
||||
if(lv_obj_get_style_opa(obj, LV_PART_MAIN) < LV_OPA_MAX) return LV_DRAW_RES_NOT_COVER;
|
||||
|
||||
return LV_DRAWER_RES_COVER;
|
||||
return LV_DRAW_RES_COVER;
|
||||
|
||||
}
|
||||
else if(mode == LV_DRAWER_MODE_MAIN_DRAW) {
|
||||
else if(mode == LV_DRAW_MODE_MAIN_DRAW) {
|
||||
lv_draw_rect_dsc_t draw_dsc;
|
||||
lv_draw_rect_dsc_init(&draw_dsc);
|
||||
/*If the border is drawn later disable loading its properties*/
|
||||
@ -1583,10 +1581,6 @@ static lv_drawer_res_t lv_obj_drawer(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_MAIN, &draw_dsc);
|
||||
|
||||
lv_drawer_res_t res;
|
||||
res = lv_drawer_part_before(obj, LV_PART_MAIN, clip_area, &obj->coords);
|
||||
if(res != LV_DRAWER_RES_OK) return res;
|
||||
|
||||
lv_coord_t w = lv_obj_get_style_transform_width(obj, LV_PART_MAIN);
|
||||
lv_coord_t h = lv_obj_get_style_transform_height(obj, LV_PART_MAIN);
|
||||
lv_area_t coords;
|
||||
@ -1596,6 +1590,12 @@ static lv_drawer_res_t lv_obj_drawer(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
coords.y1 -= h;
|
||||
coords.y2 += h;
|
||||
|
||||
lv_obj_draw_hook_dsc_t hook_dsc;
|
||||
lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area);
|
||||
hook_dsc.draw_area = &coords;
|
||||
hook_dsc.part = LV_PART_MAIN;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
|
||||
|
||||
lv_draw_rect(&coords, clip_area, &draw_dsc);
|
||||
|
||||
if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) {
|
||||
@ -1606,9 +1606,9 @@ static lv_drawer_res_t lv_obj_drawer(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
lv_draw_mask_add(mp, obj + 8);
|
||||
}
|
||||
|
||||
res = lv_drawer_part_after(obj, LV_PART_MAIN, clip_area, &obj->coords);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc);
|
||||
}
|
||||
else if(mode == LV_DRAWER_MODE_POST_DRAW) {
|
||||
else if(mode == LV_DRAW_MODE_POST_DRAW) {
|
||||
_lv_obj_draw_scrollbar(obj, clip_area);
|
||||
|
||||
if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) {
|
||||
@ -1681,7 +1681,7 @@ static lv_drawer_res_t lv_obj_drawer(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
#endif
|
||||
}
|
||||
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
static void base_dir_refr_children(lv_obj_t * obj)
|
||||
|
@ -57,11 +57,6 @@ extern "C" {
|
||||
|
||||
struct _lv_obj_t;
|
||||
|
||||
/**
|
||||
* The drawer callback is used to draw the object on the screen.
|
||||
* It accepts the object, a mask area, and the mode in which to draw the object.
|
||||
*/
|
||||
typedef lv_drawer_res_t (*lv_main_drawer_cb_t)(struct _lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
|
||||
enum {
|
||||
LV_EVENT_PRESSED, /**< The object has been pressed*/
|
||||
@ -87,6 +82,17 @@ enum {
|
||||
LV_EVENT_APPLY, /**< "Ok", "Apply" or similar specific button has clicked*/
|
||||
LV_EVENT_CANCEL, /**< "Close", "Cancel" or similar specific button has clicked*/
|
||||
LV_EVENT_DELETE, /**< Object is being deleted */
|
||||
|
||||
LV_EVENT_COVER_CHECK, /**< Check if the object fully covers the 'mask_p' area */
|
||||
LV_EVENT_REFR_EXT_SIZE, /**< Draw extras on the object */
|
||||
|
||||
LV_EVENT_DRAW_MAIN_BEGIN,
|
||||
LV_EVENT_DRAW_MAIN_FINISH,
|
||||
LV_EVENT_DRAW_POST_BEGIN,
|
||||
LV_EVENT_DRAW_POST_END,
|
||||
LV_EVENT_DRAW_PART_BEGIN,
|
||||
LV_EVENT_DRAW_PART_END,
|
||||
|
||||
_LV_EVENT_LAST /** Number of events*/
|
||||
};
|
||||
typedef uint8_t lv_event_t; /**< Type of event being sent to the object. */
|
||||
@ -181,7 +187,6 @@ enum {
|
||||
};
|
||||
typedef uint32_t lv_obj_flag_t;
|
||||
|
||||
|
||||
#include "lv_obj_pos.h"
|
||||
#include "lv_obj_scroll.h"
|
||||
#include "lv_obj_style.h"
|
||||
@ -222,7 +227,7 @@ typedef struct lv_obj_class{
|
||||
void (*constructor)(struct _lv_obj_t * obj, struct _lv_obj_t * parent, const struct _lv_obj_t * copy);
|
||||
void (*destructor)(struct _lv_obj_t * obj);
|
||||
lv_signal_cb_t signal_cb; /**< Object type specific signal function*/
|
||||
lv_main_drawer_cb_t drawer_cb; /**< Object type specific drawer function*/
|
||||
lv_draw_cb_t draw_cb; /**< Object type specific draw function*/
|
||||
uint32_t instance_size;
|
||||
}lv_obj_class_t;
|
||||
|
||||
@ -515,15 +520,7 @@ lv_res_t lv_event_send_func(lv_event_cb_t event_xcb, lv_obj_t * obj, lv_event_t
|
||||
* Get the `data` parameter of the current event
|
||||
* @return the `data` parameter
|
||||
*/
|
||||
const void * lv_event_get_data(void);
|
||||
|
||||
/**
|
||||
* Set the a signal function of an object. Used internally by the library.
|
||||
* Always call the previous signal function in the new.
|
||||
* @param obj pointer to an object
|
||||
* @param signal_cb the new signal function
|
||||
*/
|
||||
void lv_obj_set_signal_cb(lv_obj_t * obj, lv_signal_cb_t signal_cb);
|
||||
void * lv_event_get_data(void);
|
||||
|
||||
/**
|
||||
* Send an event to the object
|
||||
@ -533,13 +530,6 @@ void lv_obj_set_signal_cb(lv_obj_t * obj, lv_signal_cb_t signal_cb);
|
||||
*/
|
||||
lv_res_t lv_signal_send(lv_obj_t * obj, lv_signal_t signal, void * param);
|
||||
|
||||
/**
|
||||
* Set a new drawer function for an object
|
||||
* @param obj pointer to an object
|
||||
* @param drawer_cb the new drawer function
|
||||
*/
|
||||
void lv_obj_set_drawer_cb(lv_obj_t * obj, lv_main_drawer_cb_t drawer_cb);
|
||||
|
||||
/*----------------
|
||||
* Other set
|
||||
*--------------*/
|
||||
@ -661,11 +651,11 @@ lv_state_t lv_obj_get_state(const lv_obj_t * obj);
|
||||
lv_signal_cb_t lv_obj_get_signal_cb(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the drawer function of an object
|
||||
* Get the draw function of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the drawer function
|
||||
* @return the draw function
|
||||
*/
|
||||
lv_main_drawer_cb_t lv_obj_get_drawer_cb(const lv_obj_t * obj);
|
||||
lv_draw_cb_t lv_obj_get_draw_cb(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the event function of an object
|
||||
|
@ -346,25 +346,13 @@ lv_coord_t _lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part)
|
||||
if(content_src) {
|
||||
lv_opa_t content_opa;
|
||||
lv_point_t content_size;
|
||||
if(lv_img_src_get_type(content_src) == LV_IMG_SRC_SYMBOL) {
|
||||
content_opa = lv_obj_get_style_text_opa(obj, part);
|
||||
if(content_opa > 0) {
|
||||
lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, part);
|
||||
lv_coord_t line_space = lv_obj_get_style_text_letter_space(obj, part);
|
||||
const lv_font_t * font = lv_obj_get_style_text_font(obj, part);
|
||||
_lv_txt_get_size(&content_size, content_src, font, letter_space, line_space, LV_COORD_MAX, LV_TEXT_FLAG_NONE);
|
||||
}
|
||||
} else {
|
||||
content_opa = lv_obj_get_style_img_opa(obj, part);
|
||||
if(content_opa > 0) {
|
||||
lv_img_header_t header;
|
||||
lv_img_decoder_get_info(content_src, &header);
|
||||
content_size.x = header.w;
|
||||
content_size.y = header.h;
|
||||
}
|
||||
}
|
||||
|
||||
if(content_opa > 0) {
|
||||
lv_area_t content_area;
|
||||
content_area.x1 = 0;
|
||||
content_area.y1 = 0;
|
||||
@ -397,83 +385,10 @@ lv_coord_t _lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part)
|
||||
return s;
|
||||
}
|
||||
|
||||
lv_drawer_res_t lv_drawer_part_before(lv_obj_t * obj, uint8_t part, const lv_area_t * clip_area, void * param)
|
||||
void lv_obj_draw_hook_dsc_init(lv_obj_draw_hook_dsc_t * hook_dsc, const lv_area_t * clip_area)
|
||||
{
|
||||
lv_obj_style_list_t * list = &obj->style_list;
|
||||
if(list->cache_drawer_zero) return LV_DRAWER_RES_OK;
|
||||
if(list->style_cnt == 0) return LV_DRAWER_RES_OK;
|
||||
|
||||
lv_drawer_res_t res = LV_DRAWER_RES_OK;
|
||||
int32_t i;
|
||||
for(i = 0; i < list->style_cnt; i++) {
|
||||
const lv_obj_style_t * style = &obj->style_list.styles[i];
|
||||
if(style->is_trans) continue;
|
||||
if(style->state & ~(obj->state)) continue;
|
||||
|
||||
lv_style_value_t v;
|
||||
if(lv_style_get_prop(style->style, LV_STYLE_DRAWER, &v) == false) continue;
|
||||
const lv_drawer_t * d = v.ptr;
|
||||
|
||||
if(d->drawer_cb == NULL) continue;
|
||||
|
||||
lv_drawer_res_t sub_res = d->drawer_cb(d, obj, LV_DRAWER_MODE_PART_BEFORE, clip_area, param);
|
||||
if(sub_res == LV_DRAWER_RES_STOP) res = LV_DRAWER_RES_STOP;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
lv_drawer_res_t lv_drawer_part_after(lv_obj_t * obj, uint8_t part, const lv_area_t * clip_area, void * param)
|
||||
{
|
||||
lv_obj_style_list_t * list = &obj->style_list;
|
||||
if(list->cache_drawer_zero) return LV_DRAWER_RES_OK;
|
||||
if(list->style_cnt == 0) return LV_DRAWER_RES_OK;
|
||||
|
||||
lv_drawer_res_t res = LV_DRAWER_RES_STOP;
|
||||
int32_t i;
|
||||
for(i = list->style_cnt - 1; i >= 0; i--) {
|
||||
const lv_obj_style_t * style = &obj->style_list.styles[i];
|
||||
if(style->is_trans) continue;
|
||||
if(style->part != part) continue;
|
||||
if(style->state & ~(obj->state)) continue;
|
||||
|
||||
lv_style_value_t v;
|
||||
if(lv_style_get_prop(style->style, LV_STYLE_DRAWER, &v) == false) continue;
|
||||
const lv_drawer_t * d = v.ptr;
|
||||
|
||||
if(d->drawer_cb == NULL) continue;
|
||||
|
||||
lv_drawer_res_t sub_res = d->drawer_cb(d, obj, LV_DRAWER_MODE_PART_AFTER, clip_area, param);
|
||||
if(sub_res == LV_DRAWER_RES_OK) res = LV_DRAWER_RES_OK;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void lv_drawer_section(lv_obj_t * obj, lv_drawer_mode_t mode, const lv_area_t * clip_area, bool rev)
|
||||
{
|
||||
lv_obj_style_list_t * list = &obj->style_list;
|
||||
if(list->cache_drawer_zero) return;
|
||||
if(list->style_cnt == 0) return;
|
||||
|
||||
int32_t i;
|
||||
int32_t start = rev ? list->style_cnt - 1 : 0;
|
||||
int32_t end = rev ? 0 : list->style_cnt - 1;
|
||||
int32_t step = rev ? -1 : 1;
|
||||
for(i = start; i != end; i += step) {
|
||||
const lv_obj_style_t * style = &obj->style_list.styles[i];
|
||||
if(style->is_trans) continue;
|
||||
if(style->part != LV_PART_MAIN) continue;
|
||||
if(style->state & ~(obj->state)) continue;
|
||||
|
||||
lv_style_value_t v;
|
||||
if(lv_style_get_prop(style->style, LV_STYLE_DRAWER, &v) == false) continue;
|
||||
const lv_drawer_t * d = v.ptr;
|
||||
|
||||
if(d->drawer_cb == NULL) continue;
|
||||
|
||||
d->drawer_cb(d, obj, mode, clip_area, NULL);
|
||||
}
|
||||
_lv_memset_00(hook_dsc, sizeof(lv_obj_draw_hook_dsc_t));
|
||||
hook_dsc->clip_area = clip_area;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -503,7 +418,7 @@ void _lv_obj_refresh_ext_draw_pad(lv_obj_t * obj)
|
||||
/**
|
||||
* Draw scrollbars on an object is required
|
||||
* @param obj pointer to an object
|
||||
* @param clip_area the clip area coming from the drawer function
|
||||
* @param clip_area the clip area coming from the draw function
|
||||
*/
|
||||
void _lv_obj_draw_scrollbar(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
{
|
||||
|
@ -25,7 +25,40 @@ extern "C" {
|
||||
|
||||
struct _lv_obj_t;
|
||||
|
||||
/** Design results */
|
||||
typedef enum {
|
||||
LV_DRAW_RES_OK, /**< Draw ready */
|
||||
LV_DRAW_RES_COVER, /**< Returned on `LV_DRAW_COVER_CHK` if the areas is fully covered*/
|
||||
LV_DRAW_RES_NOT_COVER, /**< Returned on `LV_DRAW_COVER_CHK` if the areas is not covered*/
|
||||
LV_DRAW_RES_MASKED, /**< Returned on `LV_DRAW_COVER_CHK` if the areas is masked out (children also not cover)*/
|
||||
}lv_draw_res_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
lv_draw_rect_dsc_t * rect_dsc;
|
||||
lv_draw_label_dsc_t * label_dsc;
|
||||
lv_draw_line_dsc_t * line_dsc;
|
||||
lv_draw_img_dsc_t * img_dsc;
|
||||
const lv_area_t * draw_area;
|
||||
const lv_area_t * clip_area;
|
||||
uint32_t id;
|
||||
uint8_t part;
|
||||
}lv_obj_draw_hook_dsc_t;
|
||||
|
||||
/** Design modes */
|
||||
enum {
|
||||
LV_DRAW_MODE_COVER_CHECK, /**< Check if the object fully covers the 'mask_p' area */
|
||||
LV_DRAW_MODE_MAIN_DRAW, /**< Draw the main portion of the object */
|
||||
LV_DRAW_MODE_POST_DRAW, /**< Draw extras on the object */
|
||||
};
|
||||
typedef uint8_t lv_draw_mode_t;
|
||||
|
||||
/**
|
||||
* The draw callback is used to draw the object on the screen.
|
||||
* It accepts the object, a mask area, and the mode in which to draw the object.
|
||||
*/
|
||||
typedef lv_draw_res_t (*lv_draw_cb_t)(struct _lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@ -73,11 +106,7 @@ void lv_obj_init_draw_img_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_img_
|
||||
void lv_obj_init_draw_line_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_line_dsc_t * draw_dsc);
|
||||
|
||||
|
||||
lv_drawer_res_t lv_drawer_part_before(struct _lv_obj_t * obj, uint8_t part, const lv_area_t * clip_area, void * param);
|
||||
|
||||
lv_drawer_res_t lv_drawer_part_after(struct _lv_obj_t * obj, uint8_t part, const lv_area_t * clip_area, void * param);
|
||||
|
||||
void lv_drawer_section(struct _lv_obj_t * obj, lv_drawer_mode_t mode, const lv_area_t * clip_area, bool rev);
|
||||
bool lv_obj_draw_has_custom(const struct _lv_obj_t * obj, uint8_t part);
|
||||
|
||||
/**
|
||||
* Get the required extra size (around the object's part) to draw shadow, outline, value etc.
|
||||
@ -92,12 +121,12 @@ lv_coord_t _lv_obj_get_draw_rect_ext_pad_size(struct _lv_obj_t * obj, uint8_t pa
|
||||
* The result will be written into `obj->ext_draw_pad`
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void _lv_obj_refresh_ext_draw_pad(struct _lv_obj_t * obj);
|
||||
void lv_obj_draw_hook_dsc_init(lv_obj_draw_hook_dsc_t * hook_dsc, const lv_area_t * clip_area);
|
||||
|
||||
/**
|
||||
* Draw scrollbars on an object is required
|
||||
* @param obj pointer to an object
|
||||
* @param clip_area the clip area coming from the drawer function
|
||||
* @param clip_area the clip area coming from the draw function
|
||||
*/
|
||||
void _lv_obj_draw_scrollbar(struct _lv_obj_t * obj, const lv_area_t * clip_area);
|
||||
|
||||
|
@ -764,12 +764,6 @@ static void update_cache(lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop)
|
||||
else list->cache_filter_zero = 0;
|
||||
}
|
||||
|
||||
if(prop == LV_STYLE_PROP_ALL || prop == LV_STYLE_DRAWER) {
|
||||
if(get_prop_core(obj, part, LV_STYLE_DRAWER, &v) == false) v.ptr = NULL;
|
||||
if(v.ptr == NULL) list->cache_drawer_zero = 1;
|
||||
else list->cache_drawer_zero = 0;
|
||||
}
|
||||
|
||||
/*1 or 0*/
|
||||
if(prop == LV_STYLE_PROP_ALL || prop == LV_STYLE_BORDER_POST) {
|
||||
if(get_prop_core(obj, part, LV_STYLE_BORDER_POST, &v) == false) v.num = 0;
|
||||
@ -887,11 +881,6 @@ static cache_t read_cache(const lv_obj_t * obj, lv_part_t part, lv_style_prop_t
|
||||
else return CACHE_NEED_CHECK;
|
||||
break;
|
||||
|
||||
case LV_STYLE_DRAWER:
|
||||
if(list->cache_drawer_zero) return CACHE_ZERO;
|
||||
else return CACHE_NEED_CHECK;
|
||||
break;
|
||||
|
||||
/*1 or 0*/
|
||||
case LV_STYLE_BORDER_POST:
|
||||
if(list->cache_border_post_enable) return CACHE_TRUE;
|
||||
|
@ -55,7 +55,6 @@ typedef struct {
|
||||
uint32_t cache_transform_zero:1;
|
||||
uint32_t cache_blend_mode_zero:1;
|
||||
uint32_t cache_filter_zero:1;
|
||||
uint32_t cache_drawer_zero:1;
|
||||
uint32_t cache_clip_corner_enable:1;
|
||||
|
||||
uint32_t cache_bg_opa_cover:1;
|
||||
|
@ -594,12 +594,12 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj)
|
||||
|
||||
/*If this object is fully cover the draw area check the children too */
|
||||
if(_lv_area_is_in(area_p, &obj->coords, 0) && lv_obj_has_flag(obj, LV_OBJ_FLAG_HIDDEN) == false) {
|
||||
lv_drawer_res_t drawer_res = obj->class_p->drawer_cb(obj, area_p, LV_DRAWER_MODE_COVER_CHECK);
|
||||
if(drawer_res == LV_DRAWER_RES_MASKED) return NULL;
|
||||
lv_draw_res_t draw_res = obj->class_p->draw_cb(obj, area_p, LV_DRAW_MODE_COVER_CHECK);
|
||||
if(draw_res == LV_DRAW_RES_MASKED) return NULL;
|
||||
|
||||
#if LV_USE_OPA_SCALE
|
||||
if(drawer_res == LV_DRAWER_RES_COVER && lv_obj_get_style_opa(obj, LV_PART_MAIN) != LV_OPA_COVER) {
|
||||
drawer_res = LV_DRAWER_RES_NOT_COVER;
|
||||
if(draw_res == LV_DRAW_RES_COVER && lv_obj_get_style_opa(obj, LV_PART_MAIN) != LV_OPA_COVER) {
|
||||
draw_res = LV_DRAW_RES_NOT_COVER;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -616,7 +616,7 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj)
|
||||
|
||||
/*If no better children use this object*/
|
||||
if(found_p == NULL) {
|
||||
if(drawer_res == LV_DRAWER_RES_COVER) {
|
||||
if(draw_res == LV_DRAW_RES_COVER) {
|
||||
found_p = obj;
|
||||
}
|
||||
}
|
||||
@ -661,10 +661,10 @@ static void lv_refr_obj_and_children(lv_obj_t * top_p, const lv_area_t * mask_p)
|
||||
}
|
||||
}
|
||||
|
||||
/*Call the post draw drawer function of the parents of the to object*/
|
||||
lv_drawer_section(par, LV_DRAWER_MODE_FINISH, mask_p, false);
|
||||
par->class_p->drawer_cb(par, mask_p, LV_DRAWER_MODE_POST_DRAW);
|
||||
lv_drawer_section(par, LV_DRAWER_MODE_FINISH, mask_p, true);
|
||||
/*Call the post draw draw function of the parents of the to object*/
|
||||
lv_event_send(par, LV_EVENT_DRAW_POST_BEGIN, NULL);
|
||||
par->class_p->draw_cb(par, mask_p, LV_DRAW_MODE_POST_DRAW);
|
||||
lv_event_send(par, LV_EVENT_DRAW_POST_END, NULL);
|
||||
|
||||
/*The new border will be the last parents,
|
||||
*so the 'younger' brothers of parent will be refreshed*/
|
||||
@ -701,8 +701,9 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
|
||||
/*Draw the parent and its children only if they ore on 'mask_parent'*/
|
||||
if(union_ok != false) {
|
||||
/* Redraw the object */
|
||||
lv_drawer_section(obj, LV_DRAWER_MODE_FINISH, &obj_ext_mask, false);
|
||||
obj->class_p->drawer_cb(obj, &obj_ext_mask, LV_DRAWER_MODE_MAIN_DRAW);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_MAIN_BEGIN, NULL);
|
||||
obj->class_p->draw_cb(obj, &obj_ext_mask, LV_DRAW_MODE_MAIN_DRAW);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_MAIN_BEGIN, NULL);
|
||||
|
||||
#if MASK_AREA_DEBUG
|
||||
static lv_color_t debug_color = LV_COLOR_RED;
|
||||
@ -748,10 +749,10 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
|
||||
}
|
||||
}
|
||||
|
||||
/* If all the children are redrawn make 'post draw' drawer */
|
||||
lv_drawer_section(obj, LV_DRAWER_MODE_FINISH, &obj_ext_mask, false);
|
||||
obj->class_p->drawer_cb(obj, &obj_ext_mask, LV_DRAWER_MODE_POST_DRAW);
|
||||
lv_drawer_section(obj, LV_DRAWER_MODE_FINISH, &obj_ext_mask, true);
|
||||
/* If all the children are redrawn make 'post draw' draw */
|
||||
lv_event_send(obj, LV_EVENT_DRAW_POST_BEGIN, NULL);
|
||||
obj->class_p->draw_cb(obj, &obj_ext_mask, LV_DRAW_MODE_POST_DRAW);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_POST_END, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,13 +21,15 @@ extern "C" {
|
||||
#include "../lv_misc/lv_types.h"
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_draw/lv_draw_blend.h"
|
||||
#include "../lv_draw/lv_draw_rect.h"
|
||||
#include "../lv_draw/lv_draw_line.h"
|
||||
#include "../lv_draw/lv_draw_label.h"
|
||||
#include "../lv_draw/lv_draw_img.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define LV_RADIUS_CIRCLE (0x7F) /**< A very big radius to always draw as circle*/
|
||||
LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE);
|
||||
|
||||
#define LV_DEBUG_STYLE_SENTINEL_VALUE 0xAABBCCDD
|
||||
|
||||
#define LV_STYLE_PROP_INHERIT (1 << 10)
|
||||
@ -39,84 +41,6 @@ LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE);
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Border types (Use 'OR'ed values)*/
|
||||
enum {
|
||||
LV_BORDER_SIDE_NONE = 0x00,
|
||||
LV_BORDER_SIDE_BOTTOM = 0x01,
|
||||
LV_BORDER_SIDE_TOP = 0x02,
|
||||
LV_BORDER_SIDE_LEFT = 0x04,
|
||||
LV_BORDER_SIDE_RIGHT = 0x08,
|
||||
LV_BORDER_SIDE_FULL = 0x0F,
|
||||
LV_BORDER_SIDE_INTERNAL = 0x10, /**< FOR matrix-like objects (e.g. Button matrix)*/
|
||||
_LV_BORDER_SIDE_LAST
|
||||
};
|
||||
typedef uint8_t lv_border_side_t;
|
||||
|
||||
enum {
|
||||
LV_GRAD_DIR_NONE,
|
||||
LV_GRAD_DIR_VER,
|
||||
LV_GRAD_DIR_HOR,
|
||||
_LV_GRAD_DIR_LAST
|
||||
};
|
||||
|
||||
typedef uint8_t lv_grad_dir_t;
|
||||
|
||||
/*Text decorations (Use 'OR'ed values)*/
|
||||
enum {
|
||||
LV_TEXT_DECOR_NONE = 0x00,
|
||||
LV_TEXT_DECOR_UNDERLINE = 0x01,
|
||||
LV_TEXT_DECOR_STRIKETHROUGH = 0x02,
|
||||
_LV_TEXT_DECOR_LAST
|
||||
};
|
||||
|
||||
typedef uint8_t lv_text_decor_t;
|
||||
/** Label align policy*/
|
||||
enum {
|
||||
LV_TEXT_ALIGN_LEFT, /**< Align text to left */
|
||||
LV_TEXT_ALIGN_CENTER, /**< Align text to center */
|
||||
LV_TEXT_ALIGN_RIGHT, /**< Align text to right */
|
||||
LV_TEXT_ALIGN_AUTO, /**< */
|
||||
};
|
||||
typedef uint8_t lv_text_align_t;
|
||||
|
||||
|
||||
/** Design modes */
|
||||
enum {
|
||||
LV_DRAWER_MODE_COVER_CHECK, /**< Check if the object fully covers the 'mask_p' area */
|
||||
LV_DRAWER_MODE_REFER_EXT_SIZE, /**< Draw extras on the object */
|
||||
|
||||
LV_DRAWER_MODE_START_MAIN,
|
||||
LV_DRAWER_MODE_START_CHILDREN,
|
||||
LV_DRAWER_MODE_MAIN_DRAW, /**< Draw the main portion of the object */
|
||||
LV_DRAWER_MODE_POST_DRAW, /**< Draw extras on the object */
|
||||
LV_DRAWER_MODE_FINISH,
|
||||
|
||||
LV_DRAWER_MODE_PART_BEFORE,
|
||||
LV_DRAWER_MODE_PART_AFTER,
|
||||
};
|
||||
typedef uint8_t lv_drawer_mode_t;
|
||||
|
||||
|
||||
/** Design results */
|
||||
enum {
|
||||
LV_DRAWER_RES_OK, /**< Draw ready */
|
||||
LV_DRAWER_RES_COVER, /**< Returned on `LV_DRAWER_COVER_CHK` if the areas is fully covered*/
|
||||
LV_DRAWER_RES_NOT_COVER, /**< Returned on `LV_DRAWER_COVER_CHK` if the areas is not covered*/
|
||||
LV_DRAWER_RES_MASKED, /**< Returned on `LV_DRAWER_COVER_CHK` if the areas is masked out (children also not cover)*/
|
||||
LV_DRAWER_RES_STOP,
|
||||
};
|
||||
typedef uint8_t lv_drawer_res_t;
|
||||
|
||||
struct _lv_obj_t;
|
||||
|
||||
struct lv_drawer;
|
||||
|
||||
typedef lv_drawer_res_t (*lv_drawer_cb_t)(const struct lv_drawer * drawer, struct _lv_obj_t * obj, lv_drawer_mode_t mode, const lv_area_t * clip_area, void * param);
|
||||
|
||||
typedef struct lv_drawer {
|
||||
lv_drawer_cb_t drawer_cb;
|
||||
void * user_data;
|
||||
}lv_drawer_t;
|
||||
|
||||
typedef union {
|
||||
int32_t num;
|
||||
@ -139,7 +63,6 @@ typedef enum {
|
||||
LV_STYLE_ANIM_TIME = 10,
|
||||
LV_STYLE_TRANSITION = 11,
|
||||
LV_STYLE_SIZE = 12,
|
||||
LV_STYLE_DRAWER = 13,
|
||||
|
||||
LV_STYLE_PAD_TOP = 20 | LV_STYLE_PROP_LAYOUT_REFR,
|
||||
LV_STYLE_PAD_BOTTOM = 21 | LV_STYLE_PROP_LAYOUT_REFR,
|
||||
|
@ -216,7 +216,7 @@ lv_img_src_t lv_img_src_get_type(const void * src)
|
||||
img_src_type = LV_IMG_SRC_SYMBOL; /*Symbols begins after 0x7F*/
|
||||
}
|
||||
else {
|
||||
img_src_type = LV_IMG_SRC_VARIABLE; /*`lv_img_dsc_t` is drawer to the first byte < 0x20*/
|
||||
img_src_type = LV_IMG_SRC_VARIABLE; /*`lv_img_dsc_t` is draw to the first byte < 0x20*/
|
||||
}
|
||||
|
||||
if(LV_IMG_SRC_UNKNOWN == img_src_type) {
|
||||
|
@ -15,6 +15,7 @@ extern "C" {
|
||||
*********************/
|
||||
#include "lv_img_decoder.h"
|
||||
#include "lv_img_buf.h"
|
||||
#include "lv_draw_blend.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
@ -110,7 +110,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc)
|
||||
* @param dsc pointer to draw descriptor
|
||||
* @param txt `\0` terminated text to write
|
||||
* @param hint pointer to a `lv_draw_label_hint_t` variable.
|
||||
* It is managed by the drawer to speed up the drawing of very long texts (thousands of lines).
|
||||
* It is managed by the draw to speed up the drawing of very long texts (thousands of lines).
|
||||
*/
|
||||
LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_draw_label_dsc_t * dsc,
|
||||
|
@ -13,9 +13,10 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw_blend.h"
|
||||
#include "../lv_misc/lv_bidi.h"
|
||||
#include "../lv_misc/lv_txt.h"
|
||||
#include "../lv_core/lv_style.h"
|
||||
#include "../lv_misc/lv_color.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -26,6 +27,25 @@ extern "C" {
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Text decorations (Use 'OR'ed values)*/
|
||||
enum {
|
||||
LV_TEXT_DECOR_NONE = 0x00,
|
||||
LV_TEXT_DECOR_UNDERLINE = 0x01,
|
||||
LV_TEXT_DECOR_STRIKETHROUGH = 0x02,
|
||||
_LV_TEXT_DECOR_LAST
|
||||
};
|
||||
|
||||
typedef uint8_t lv_text_decor_t;
|
||||
/** Label align policy*/
|
||||
enum {
|
||||
LV_TEXT_ALIGN_LEFT, /**< Align text to left */
|
||||
LV_TEXT_ALIGN_CENTER, /**< Align text to center */
|
||||
LV_TEXT_ALIGN_RIGHT, /**< Align text to right */
|
||||
LV_TEXT_ALIGN_AUTO, /**< */
|
||||
};
|
||||
typedef uint8_t lv_text_align_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
lv_color_t color;
|
||||
lv_color_t sel_color;
|
||||
@ -76,7 +96,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc);
|
||||
* @param dsc pointer to draw descriptor
|
||||
* @param txt `\0` terminated text to write
|
||||
* @param hint pointer to a `lv_draw_label_hint_t` variable.
|
||||
* It is managed by the drawer to speed up the drawing of very long texts (thousands of lines).
|
||||
* It is managed by the draw to speed up the drawing of very long texts (thousands of lines).
|
||||
*/
|
||||
LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_draw_label_dsc_t * dsc,
|
||||
|
@ -13,7 +13,7 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_core/lv_style.h"
|
||||
#include "lv_draw_blend.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
@ -13,16 +13,42 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_core/lv_style.h"
|
||||
#include "lv_draw_blend.h"
|
||||
#include "../lv_font/lv_font.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_RADIUS_CIRCLE 0x7FFF /**< A very big radius to always draw as circle*/
|
||||
LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE);
|
||||
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Border types (Use 'OR'ed values)*/
|
||||
enum {
|
||||
LV_BORDER_SIDE_NONE = 0x00,
|
||||
LV_BORDER_SIDE_BOTTOM = 0x01,
|
||||
LV_BORDER_SIDE_TOP = 0x02,
|
||||
LV_BORDER_SIDE_LEFT = 0x04,
|
||||
LV_BORDER_SIDE_RIGHT = 0x08,
|
||||
LV_BORDER_SIDE_FULL = 0x0F,
|
||||
LV_BORDER_SIDE_INTERNAL = 0x10, /**< FOR matrix-like objects (e.g. Button matrix)*/
|
||||
_LV_BORDER_SIDE_LAST
|
||||
};
|
||||
typedef uint8_t lv_border_side_t;
|
||||
|
||||
enum {
|
||||
LV_GRAD_DIR_NONE,
|
||||
LV_GRAD_DIR_VER,
|
||||
LV_GRAD_DIR_HOR,
|
||||
_LV_GRAD_DIR_LAST
|
||||
};
|
||||
|
||||
typedef uint8_t lv_grad_dir_t;
|
||||
|
||||
typedef struct {
|
||||
lv_coord_t radius;
|
||||
|
||||
@ -96,7 +122,7 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_dra
|
||||
* @param mask the pixel will be drawn only in this mask
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_style_t * style);
|
||||
//void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_style_t * style);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -298,7 +298,7 @@ lv_res_t lv_img_decoder_built_in_info(lv_img_decoder_t * decoder, const void * s
|
||||
* function*/
|
||||
header->w = 1;
|
||||
header->h = 1;
|
||||
/* Symbols always have transparent parts. Important because of cover check in the drawer
|
||||
/* Symbols always have transparent parts. Important because of cover check in the draw
|
||||
* function. The actual value doesn't matter because lv_draw_label will draw it*/
|
||||
header->cf = LV_IMG_CF_ALPHA_1BIT;
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ extern "C" {
|
||||
#include "../lv_misc/lv_fs.h"
|
||||
#include "../lv_misc/lv_types.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
#include "../lv_core/lv_style.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "lv_mem.h"
|
||||
#include "lv_math.h"
|
||||
#include "lv_gc.h"
|
||||
#include "lv_debug.h"
|
||||
#include <string.h>
|
||||
|
||||
#if LV_MEM_CUSTOM != 0
|
||||
|
@ -116,11 +116,6 @@ typedef struct {
|
||||
lv_style_t arc_indic_primary;
|
||||
#endif
|
||||
|
||||
|
||||
#if LV_USE_BTNMATRIX
|
||||
lv_style_t btnmatrix_btn;
|
||||
#endif
|
||||
|
||||
#if LV_USE_CHART
|
||||
lv_style_t chart_series, chart_ticks;
|
||||
#endif
|
||||
@ -187,9 +182,6 @@ static void basic_init(void)
|
||||
static lv_style_transiton_t trans_delayed;
|
||||
lv_style_transition_init(&trans_delayed, trans_props, &lv_anim_path_def, TRANSITION_TIME, 70);
|
||||
|
||||
static lv_style_transiton_t trans_slow;
|
||||
lv_style_transition_init(&trans_slow, trans_props, &lv_anim_path_def, TRANSITION_TIME * 4, 0);
|
||||
|
||||
static lv_style_transiton_t trans_normal;
|
||||
lv_style_transition_init(&trans_normal, trans_props, &lv_anim_path_def, TRANSITION_TIME, 0);
|
||||
|
||||
@ -208,7 +200,7 @@ static void basic_init(void)
|
||||
lv_style_set_pad_right(&styles->scrollbar, LV_DPX(7));
|
||||
lv_style_set_pad_top(&styles->scrollbar, LV_DPX(7));
|
||||
lv_style_set_bg_opa(&styles->scrollbar, LV_OPA_40);
|
||||
lv_style_set_transition(&styles->scrollbar, &trans_slow);
|
||||
lv_style_set_transition(&styles->scrollbar, &trans_normal);
|
||||
|
||||
style_init_reset(&styles->scrollbar_scrolled);
|
||||
lv_style_set_bg_opa(&styles->scrollbar_scrolled, LV_OPA_COVER);
|
||||
@ -217,6 +209,9 @@ static void basic_init(void)
|
||||
lv_style_set_bg_opa(&styles->scr, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&styles->scr, COLOR_SCR);
|
||||
lv_style_set_text_color(&styles->scr, COLOR_SCR_TEXT);
|
||||
lv_style_set_pad_all(&styles->scr, PAD_DEF);
|
||||
lv_style_set_pad_row(&styles->scr, PAD_DEF);
|
||||
lv_style_set_pad_column(&styles->scr, PAD_DEF);
|
||||
|
||||
style_init_reset(&styles->card);
|
||||
lv_style_set_radius(&styles->card, RADIUS_DEFAULT);
|
||||
@ -227,6 +222,8 @@ static void basic_init(void)
|
||||
lv_style_set_border_post(&styles->card, true);
|
||||
lv_style_set_text_color(&styles->card, CARD_TEXT_COLOR);
|
||||
lv_style_set_pad_all(&styles->card, PAD_DEF);
|
||||
lv_style_set_pad_row(&styles->card, PAD_DEF);
|
||||
lv_style_set_pad_column(&styles->card, PAD_DEF);
|
||||
lv_style_set_line_color(&styles->card, COLOR_GRAY);
|
||||
lv_style_set_line_width(&styles->card, LV_DPX(1));
|
||||
|
||||
@ -368,6 +365,13 @@ static void basic_init(void)
|
||||
lv_style_set_bg_opa(&styles->meter_indic, LV_OPA_COVER);
|
||||
lv_style_set_size(&styles->meter_indic, LV_DPX(15));
|
||||
#endif
|
||||
|
||||
|
||||
#if LV_USE_TABLE
|
||||
style_init_reset(&styles->table_cell);
|
||||
lv_style_set_border_width(&styles->table_cell, LV_DPX(1));
|
||||
lv_style_set_border_color(&styles->table_cell, CARD_BORDER_COLOR);
|
||||
#endif
|
||||
}
|
||||
//
|
||||
//static void linemeter_init(void)
|
||||
@ -388,41 +392,6 @@ static void basic_init(void)
|
||||
//#endif
|
||||
//}
|
||||
//
|
||||
//static void gauge_init(void)
|
||||
//{
|
||||
//#if LV_USE_GAUGE != 0
|
||||
// style_init_reset(&styles->gauge_main);
|
||||
// lv_style_set_line_color(&styles->gauge_main, LV_STATE_DEFAULT, lv_color_hex3(0x888));
|
||||
// lv_style_set_scale_grad_color(&styles->gauge_main, LV_STATE_DEFAULT, lv_color_hex3(0x888));
|
||||
// lv_style_set_scale_end_color(&styles->gauge_main, LV_STATE_DEFAULT, theme.color_primary);
|
||||
// lv_style_set_line_width(&styles->gauge_main, LV_STATE_DEFAULT, LV_DPX(5));
|
||||
// lv_style_set_scale_end_line_width(&styles->gauge_main, LV_STATE_DEFAULT, LV_DPX(4));
|
||||
// lv_style_set_scale_end_border_width(&styles->gauge_main, LV_STATE_DEFAULT, LV_DPX(8));
|
||||
// lv_style_set_pad_left(&styles->gauge_main, LV_STATE_DEFAULT, LV_DPX(20));
|
||||
// lv_style_set_pad_right(&styles->gauge_main, LV_STATE_DEFAULT, LV_DPX(20));
|
||||
// lv_style_set_pad_top(&styles->gauge_main, LV_STATE_DEFAULT, LV_DPX(20));
|
||||
// lv_style_set_pad_all(&styles->gauge_main, LV_STATE_DEFAULT, LV_DPX(20));
|
||||
// lv_style_set_scale_width(&styles->gauge_main, LV_STATE_DEFAULT, LV_DPX(15));
|
||||
// lv_style_set_radius(&styles->gauge_main, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
|
||||
//
|
||||
// style_init_reset(&styles->gauge_strong);
|
||||
// lv_style_set_line_color(&styles->gauge_strong, LV_STATE_DEFAULT, lv_color_hex3(0x888));
|
||||
// lv_style_set_scale_grad_color(&styles->gauge_strong, LV_STATE_DEFAULT, lv_color_hex3(0x888));
|
||||
// lv_style_set_scale_end_color(&styles->gauge_strong, LV_STATE_DEFAULT, theme.color_primary);
|
||||
// lv_style_set_line_width(&styles->gauge_strong, LV_STATE_DEFAULT, LV_DPX(8));
|
||||
// lv_style_set_scale_end_line_width(&styles->gauge_strong, LV_STATE_DEFAULT, LV_DPX(8));
|
||||
// lv_style_set_scale_width(&styles->gauge_strong, LV_STATE_DEFAULT, LV_DPX(25));
|
||||
//
|
||||
// style_init_reset(&styles->gauge_needle);
|
||||
// lv_style_set_line_color(&styles->gauge_needle, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x464b5b) : LV_COLOR_WHITE);
|
||||
// lv_style_set_line_width(&styles->gauge_needle, LV_STATE_DEFAULT, LV_DPX(8));
|
||||
// lv_style_set_bg_opa(&styles->gauge_needle, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||
// lv_style_set_bg_color(&styles->gauge_needle, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x464b5b) : LV_COLOR_WHITE);
|
||||
// lv_style_set_radius(&styles->gauge_needle, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
|
||||
// lv_style_set_size(&styles->gauge_needle, LV_STATE_DEFAULT, LV_DPX(30));
|
||||
// lv_style_set_pad_all(&styles->gauge_needle, LV_STATE_DEFAULT, LV_DPX(10));
|
||||
//#endif
|
||||
//}
|
||||
|
||||
static void textarea_init(void)
|
||||
{
|
||||
@ -470,21 +439,6 @@ static void textarea_init(void)
|
||||
//}
|
||||
|
||||
|
||||
//static void table_init(void)
|
||||
//{
|
||||
//#if LV_USE_TABLE != 0
|
||||
// style_init_reset(&styles->table_cell);
|
||||
// lv_style_set_border_color(&styles->table_cell, LV_STATE_DEFAULT, CARD_BORDER_COLOR);
|
||||
// lv_style_set_border_width(&styles->table_cell, LV_STATE_DEFAULT, 1);
|
||||
// lv_style_set_border_side(&styles->table_cell, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM);
|
||||
// lv_style_set_pad_left(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
|
||||
// lv_style_set_pad_right(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
|
||||
// lv_style_set_pad_top(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
|
||||
// lv_style_set_pad_bottom(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
|
||||
//
|
||||
//#endif
|
||||
//}
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
static void lv_arc_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_arc_destructor(lv_obj_t * obj);
|
||||
static lv_drawer_res_t lv_arc_drawer(lv_obj_t * arc, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_arc_draw(lv_obj_t * arc, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_arc_signal(lv_obj_t * arc, lv_signal_t sign, void * param);
|
||||
static void inv_arc_area(lv_obj_t * arc, uint16_t start_angle, uint16_t end_angle, uint8_t part);
|
||||
static void get_center(lv_obj_t * obj, lv_point_t * center, lv_coord_t * arc_r);
|
||||
@ -45,7 +45,7 @@ const lv_obj_class_t lv_arc = {
|
||||
.constructor = lv_arc_constructor,
|
||||
.destructor = lv_arc_destructor,
|
||||
.signal_cb = lv_arc_signal,
|
||||
.drawer_cb = lv_arc_drawer,
|
||||
.draw_cb = lv_arc_draw,
|
||||
.instance_size = sizeof(lv_arc_t),
|
||||
.base_class = &lv_obj
|
||||
};
|
||||
@ -488,28 +488,27 @@ static void lv_arc_destructor(lv_obj_t * obj)
|
||||
* Handle the drawing related tasks of the arcs
|
||||
* @param arc pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_arc_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_arc_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DRAWER_MODE_COVER_CHECK) {
|
||||
return lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
if(mode == LV_DRAW_MODE_COVER_CHECK) {
|
||||
return lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DRAWER_MODE_MAIN_DRAW) {
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
else if(mode == LV_DRAW_MODE_MAIN_DRAW) {
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
lv_draw_rect_dsc_t bg_dsc;
|
||||
lv_draw_rect_dsc_init(&bg_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_MAIN, &bg_dsc);
|
||||
lv_obj_draw_hook_dsc_t hook_dsc;
|
||||
lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area);
|
||||
|
||||
lv_draw_rect(&obj->coords, clip_area, &bg_dsc);
|
||||
|
||||
lv_point_t center;
|
||||
lv_coord_t arc_r;
|
||||
@ -521,9 +520,15 @@ static lv_drawer_res_t lv_arc_drawer(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
lv_draw_line_dsc_init(&arc_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_PART_MAIN, &arc_dsc);
|
||||
|
||||
hook_dsc.part = LV_PART_MAIN;
|
||||
hook_dsc.line_dsc = &arc_dsc;
|
||||
lv_event_send(obj,LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
|
||||
|
||||
lv_draw_arc(center.x, center.y, arc_r,arc->bg_angle_start +arc->angle_ofs,
|
||||
arc->bg_angle_end +arc->angle_ofs, clip_area,
|
||||
arc->bg_angle_end + arc->angle_ofs, clip_area,
|
||||
&arc_dsc);
|
||||
|
||||
lv_event_send(obj,LV_EVENT_DRAW_PART_END, &hook_dsc);
|
||||
}
|
||||
|
||||
|
||||
@ -538,9 +543,15 @@ static lv_drawer_res_t lv_arc_drawer(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
lv_draw_line_dsc_init(&arc_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_PART_INDICATOR, &arc_dsc);
|
||||
|
||||
hook_dsc.part = LV_PART_INDICATOR;
|
||||
hook_dsc.line_dsc = &arc_dsc;
|
||||
lv_event_send(obj,LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
|
||||
|
||||
lv_draw_arc(center.x, center.y, indic_r,arc->indic_angle_start +arc->angle_ofs,
|
||||
arc->indic_angle_end +arc->angle_ofs, clip_area,
|
||||
&arc_dsc);
|
||||
|
||||
lv_event_send(obj,LV_EVENT_DRAW_PART_END, &hook_dsc);
|
||||
}
|
||||
|
||||
if(arc->adjustable) {
|
||||
@ -551,15 +562,21 @@ static lv_drawer_res_t lv_arc_drawer(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
lv_draw_rect_dsc_init(&knob_rect_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_KNOB, &knob_rect_dsc);
|
||||
|
||||
hook_dsc.part = LV_PART_KNOB;
|
||||
hook_dsc.rect_dsc = &knob_rect_dsc;
|
||||
lv_event_send(obj,LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
|
||||
|
||||
lv_draw_rect(&knob_area, clip_area, &knob_rect_dsc);
|
||||
|
||||
lv_event_send(obj,LV_EVENT_DRAW_PART_END, &hook_dsc);
|
||||
}
|
||||
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DRAWER_MODE_POST_DRAW) {
|
||||
else if(mode == LV_DRAW_MODE_POST_DRAW) {
|
||||
}
|
||||
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,7 +38,7 @@
|
||||
**********************/
|
||||
static void lv_bar_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_bar_destructor(lv_obj_t * obj);
|
||||
static lv_drawer_res_t lv_bar_drawer(lv_obj_t * bar, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_bar_draw(lv_obj_t * bar, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param);
|
||||
static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area);
|
||||
|
||||
@ -57,7 +57,7 @@ const lv_obj_class_t lv_bar = {
|
||||
.constructor = lv_bar_constructor,
|
||||
.destructor = lv_bar_destructor,
|
||||
.signal_cb = lv_bar_signal,
|
||||
.drawer_cb = lv_bar_drawer,
|
||||
.draw_cb = lv_bar_draw,
|
||||
.instance_size = sizeof(lv_bar_t),
|
||||
.base_class = &lv_obj
|
||||
};
|
||||
@ -314,35 +314,31 @@ static void lv_bar_destructor(lv_obj_t * obj)
|
||||
* Handle the drawing related tasks of the bars
|
||||
* @param bar pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_bar_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_bar_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DRAWER_MODE_COVER_CHECK) {
|
||||
if(mode == LV_DRAW_MODE_COVER_CHECK) {
|
||||
/*Return false if the object is not covers the mask area*/
|
||||
return lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
return lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
else if(mode == LV_DRAWER_MODE_MAIN_DRAW) {
|
||||
else if(mode == LV_DRAW_MODE_MAIN_DRAW) {
|
||||
/*Draw the background*/
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
draw_indic(obj, clip_area);
|
||||
}
|
||||
else if(mode == LV_DRAWER_MODE_POST_DRAW) {
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
else if(mode == LV_DRAW_MODE_POST_DRAW) {
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
{
|
||||
lv_drawer_res_t res;
|
||||
res = lv_drawer_part_before(obj, LV_PART_INDICATOR, clip_area, &obj->coords);
|
||||
if(res != LV_DRAWER_RES_OK) return;
|
||||
|
||||
lv_bar_t * bar = (lv_bar_t *)obj;
|
||||
|
||||
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(obj);
|
||||
@ -485,6 +481,17 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
lv_draw_rect_dsc_init(&draw_indic_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_INDICATOR, &draw_indic_dsc);
|
||||
|
||||
lv_area_t indic_area;
|
||||
lv_area_copy(&indic_area, &bar->indic_area);
|
||||
|
||||
/*Handle custom drawer*/
|
||||
lv_obj_draw_hook_dsc_t hook_dsc;
|
||||
lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area);
|
||||
hook_dsc.draw_area = &indic_area;
|
||||
hook_dsc.part = LV_PART_INDICATOR;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
|
||||
|
||||
|
||||
/* Draw only the shadow if the indicator is long enough.
|
||||
* The radius of the bg and the indicator can make a strange shape where
|
||||
* it'd be very difficult to draw shadow. */
|
||||
@ -554,7 +561,7 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
draw_indic_dsc.border_opa = LV_OPA_TRANSP;
|
||||
lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc);
|
||||
|
||||
lv_drawer_part_after(obj, LV_PART_INDICATOR, clip_area, &obj->coords);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc);
|
||||
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
**********************/
|
||||
static void lv_btn_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_btn_destructor(lv_obj_t * obj);
|
||||
static lv_drawer_res_t lv_btn_drawer(lv_obj_t * bar, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_btn_draw(lv_obj_t * bar, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_btn_signal(lv_obj_t * bar, lv_signal_t sign, void * param);
|
||||
|
||||
/**********************
|
||||
@ -43,7 +43,7 @@ const lv_obj_class_t lv_btn = {
|
||||
.constructor = lv_btn_constructor,
|
||||
.destructor = lv_btn_destructor,
|
||||
.signal_cb = lv_btn_signal,
|
||||
.drawer_cb = lv_btn_drawer,
|
||||
.draw_cb = lv_btn_draw,
|
||||
.instance_size = sizeof(lv_btn_t),
|
||||
.base_class = &lv_obj
|
||||
};
|
||||
@ -106,9 +106,9 @@ static void lv_btn_destructor(lv_obj_t * obj)
|
||||
|
||||
// lv_btn.base_p->destructor(obj);
|
||||
}
|
||||
static lv_drawer_res_t lv_btn_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_btn_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
return lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
return lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
|
||||
static lv_res_t lv_btn_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
|
@ -34,7 +34,7 @@ static void lv_btnmatrix_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv
|
||||
static void lv_btnmatrix_destructor(lv_obj_t * obj);
|
||||
|
||||
static lv_res_t lv_btnmatrix_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
static lv_drawer_res_t lv_btnmatrix_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_btnmatrix_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
|
||||
static uint8_t get_button_width(lv_btnmatrix_ctrl_t ctrl_bits);
|
||||
static bool button_is_hidden(lv_btnmatrix_ctrl_t ctrl_bits);
|
||||
@ -57,7 +57,7 @@ const lv_obj_class_t lv_btnmatrix = {
|
||||
.constructor = lv_btnmatrix_constructor,
|
||||
.destructor = lv_btnmatrix_destructor,
|
||||
.signal_cb = lv_btnmatrix_signal,
|
||||
.drawer_cb = lv_btnmatrix_drawer,
|
||||
.draw_cb = lv_btnmatrix_draw,
|
||||
.instance_size = sizeof(lv_btnmatrix_t),
|
||||
.base_class = &lv_obj
|
||||
};
|
||||
@ -537,23 +537,23 @@ static void lv_btnmatrix_destructor(lv_obj_t * obj)
|
||||
* Handle the drawing related tasks of the button matrix
|
||||
* @param obj pointer to a button matrix object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_btnmatrix_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_btnmatrix_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DRAWER_MODE_COVER_CHECK) {
|
||||
return lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
if(mode == LV_DRAW_MODE_COVER_CHECK) {
|
||||
return lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DRAWER_MODE_MAIN_DRAW) {
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
else if(mode == LV_DRAW_MODE_MAIN_DRAW) {
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;
|
||||
if(btnm->btn_cnt == 0) return LV_DRAWER_RES_OK;
|
||||
if(btnm->btn_cnt == 0) return LV_DRAW_RES_OK;
|
||||
|
||||
obj->style_list.skip_trans = 1;
|
||||
|
||||
@ -564,26 +564,23 @@ static lv_drawer_res_t lv_btnmatrix_drawer(lv_obj_t * obj, const lv_area_t * cli
|
||||
|
||||
uint16_t btn_i = 0;
|
||||
uint16_t txt_i = 0;
|
||||
lv_text_flag_t txt_flag = LV_TEXT_FLAG_NONE;
|
||||
if(btnm->recolor) txt_flag |= LV_TEXT_FLAG_RECOLOR;
|
||||
lv_text_align_t align = lv_obj_get_style_text_align(obj, LV_PART_ITEMS);
|
||||
if(align == LV_TEXT_ALIGN_CENTER) txt_flag |= LV_TEXT_FLAG_CENTER;
|
||||
if(align == LV_TEXT_ALIGN_RIGHT) txt_flag |= LV_TEXT_FLAG_RIGHT;
|
||||
|
||||
lv_draw_rect_dsc_t draw_rect_def_dsc;
|
||||
lv_draw_label_dsc_t draw_label_def_dsc;
|
||||
lv_draw_rect_dsc_t draw_rect_dsc_act;
|
||||
lv_draw_label_dsc_t draw_label_dsc_act;
|
||||
|
||||
lv_draw_rect_dsc_t draw_rect_tmp_dsc;
|
||||
lv_draw_label_dsc_t draw_label_tmp_dsc;
|
||||
lv_draw_rect_dsc_t draw_rect_def_default;
|
||||
lv_draw_label_dsc_t draw_label_def_default;
|
||||
|
||||
lv_text_flag_t recolor_flag = btnm->recolor ? LV_TEXT_FLAG_RECOLOR : 0;
|
||||
|
||||
lv_state_t state_ori = obj->state;
|
||||
obj->state = LV_STATE_DEFAULT;
|
||||
obj->style_list.skip_trans = 1;
|
||||
lv_draw_rect_dsc_init(&draw_rect_def_dsc);
|
||||
lv_draw_label_dsc_init(&draw_label_def_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_ITEMS, &draw_rect_def_dsc);
|
||||
lv_obj_init_draw_label_dsc(obj, LV_PART_ITEMS, &draw_label_def_dsc);
|
||||
draw_label_def_dsc.flag = txt_flag;
|
||||
lv_draw_rect_dsc_init(&draw_rect_dsc_act);
|
||||
lv_draw_label_dsc_init(&draw_label_dsc_act);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_ITEMS, &draw_rect_dsc_act);
|
||||
lv_obj_init_draw_label_dsc(obj, LV_PART_ITEMS, &draw_label_dsc_act);
|
||||
draw_label_dsc_act.flag |= recolor_flag;
|
||||
obj->style_list.skip_trans = 0;
|
||||
obj->state = state_ori;
|
||||
|
||||
@ -597,6 +594,12 @@ static lv_drawer_res_t lv_btnmatrix_drawer(lv_obj_t * obj, const lv_area_t * cli
|
||||
char * txt_ap = _lv_mem_buf_get(txt_ap_size);
|
||||
#endif
|
||||
|
||||
lv_obj_draw_hook_dsc_t hook_dsc;
|
||||
lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area);
|
||||
hook_dsc.part = LV_PART_ITEMS;
|
||||
hook_dsc.rect_dsc = &draw_rect_dsc_act;
|
||||
hook_dsc.label_dsc = &draw_label_dsc_act;
|
||||
|
||||
for(btn_i = 0; btn_i < btnm->btn_cnt; btn_i++, txt_i++) {
|
||||
/*Search the next valid text in the map*/
|
||||
while(strcmp(btnm->map_p[txt_i], "\n") == 0) {
|
||||
@ -607,8 +610,6 @@ static lv_drawer_res_t lv_btnmatrix_drawer(lv_obj_t * obj, const lv_area_t * cli
|
||||
if(button_is_hidden(btnm->ctrl_bits[btn_i])) continue;
|
||||
|
||||
/*Get the state of the button*/
|
||||
lv_draw_rect_dsc_t * draw_rect_dsc_act;
|
||||
lv_draw_label_dsc_t * draw_label_dsc_act;
|
||||
lv_state_t btn_state = LV_STATE_DEFAULT;
|
||||
if(button_get_checked(btnm->ctrl_bits[btn_i])) btn_state |= LV_STATE_CHECKED;
|
||||
if(button_is_inactive(btnm->ctrl_bits[btn_i])) btn_state |= LV_STATE_DISABLED;
|
||||
@ -625,53 +626,49 @@ static lv_drawer_res_t lv_btnmatrix_drawer(lv_obj_t * obj, const lv_area_t * cli
|
||||
btn_area.x2 += area_obj.x1;
|
||||
btn_area.y2 += area_obj.y1;
|
||||
|
||||
/*Use the custom drawer if any*/
|
||||
if(btnm->custom_drawer_cb) {
|
||||
/*Use the custom draw if any*/
|
||||
if(btnm->custom_draw_cb) {
|
||||
obj->state = btn_state;
|
||||
bool drawn = btnm->custom_drawer_cb(obj, btn_i, &btn_area, clip_area);
|
||||
bool drawn = btnm->custom_draw_cb(obj, btn_i, &btn_area, clip_area);
|
||||
obj->state = state_ori;
|
||||
if(drawn) continue;
|
||||
}
|
||||
|
||||
/*Set up the draw descriptors*/
|
||||
if(btn_state == LV_STATE_DEFAULT) {
|
||||
obj->state = btn_state;
|
||||
draw_rect_dsc_act = &draw_rect_def_dsc;
|
||||
draw_label_dsc_act = &draw_label_def_dsc;
|
||||
obj->state = state_ori;
|
||||
_lv_memcpy(&draw_rect_dsc_act, &draw_rect_def_default, sizeof(lv_draw_rect_dsc_t));
|
||||
_lv_memcpy(&draw_label_dsc_act, &draw_label_def_default, sizeof(lv_draw_label_dsc_t));
|
||||
}
|
||||
/*In other cases get the styles directly without caching them*/
|
||||
else {
|
||||
obj->state = btn_state;
|
||||
lv_draw_rect_dsc_init(&draw_rect_tmp_dsc);
|
||||
lv_draw_label_dsc_init(&draw_label_tmp_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_ITEMS, &draw_rect_tmp_dsc);
|
||||
lv_obj_init_draw_label_dsc(obj, LV_PART_ITEMS, &draw_label_tmp_dsc);
|
||||
draw_label_tmp_dsc.flag = txt_flag;
|
||||
draw_rect_dsc_act = &draw_rect_tmp_dsc;
|
||||
draw_label_dsc_act = &draw_label_tmp_dsc;
|
||||
lv_draw_rect_dsc_init(&draw_rect_dsc_act);
|
||||
lv_draw_label_dsc_init(&draw_label_dsc_act);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_ITEMS, &draw_rect_dsc_act);
|
||||
lv_obj_init_draw_label_dsc(obj, LV_PART_ITEMS, &draw_label_dsc_act);
|
||||
draw_label_dsc_act.flag = recolor_flag;
|
||||
obj->state = state_ori;
|
||||
}
|
||||
|
||||
lv_coord_t border_part_ori = draw_rect_dsc_act->border_side;
|
||||
hook_dsc.draw_area = &btn_area;
|
||||
hook_dsc.id = btn_i;
|
||||
lv_event_send(obj,LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
|
||||
|
||||
/*Remove borders on the edges if `LV_BORDER_INTERNAL`*/
|
||||
if(border_part_ori & LV_BORDER_SIDE_INTERNAL) {
|
||||
if(btn_area.x1 == obj->coords.x1 + pleft) draw_rect_dsc_act->border_side &= ~LV_BORDER_SIDE_LEFT;
|
||||
if(btn_area.y2 == obj->coords.x2 - pright) draw_rect_dsc_act->border_side &= ~LV_BORDER_SIDE_RIGHT;
|
||||
if(btn_area.y1 == obj->coords.y1 + ptop) draw_rect_dsc_act->border_side &= ~LV_BORDER_SIDE_TOP;
|
||||
if(btn_area.y2 == obj->coords.y2 - pbottom) draw_rect_dsc_act->border_side &= ~LV_BORDER_SIDE_BOTTOM;
|
||||
/*Remove borders on the edges if `LV_BORDER_SIDE_INTERNAL`*/
|
||||
if(draw_rect_dsc_act.border_side & LV_BORDER_SIDE_INTERNAL) {
|
||||
if(btn_area.x1 == obj->coords.x1 + pleft) draw_rect_dsc_act.border_side &= ~LV_BORDER_SIDE_LEFT;
|
||||
if(btn_area.y2 == obj->coords.x2 - pright) draw_rect_dsc_act.border_side &= ~LV_BORDER_SIDE_RIGHT;
|
||||
if(btn_area.y1 == obj->coords.y1 + ptop) draw_rect_dsc_act.border_side &= ~LV_BORDER_SIDE_TOP;
|
||||
if(btn_area.y2 == obj->coords.y2 - pbottom) draw_rect_dsc_act.border_side &= ~LV_BORDER_SIDE_BOTTOM;
|
||||
}
|
||||
|
||||
/*Draw the background*/
|
||||
lv_draw_rect(&btn_area, clip_area, draw_rect_dsc_act);
|
||||
|
||||
draw_rect_dsc_act->border_side = border_part_ori; /*REstore the original border for the next button*/
|
||||
lv_draw_rect(&btn_area, clip_area, &draw_rect_dsc_act);
|
||||
|
||||
/*Calculate the size of the text*/
|
||||
const lv_font_t * font = draw_label_dsc_act->font;
|
||||
lv_coord_t letter_space = draw_label_dsc_act->letter_space;
|
||||
lv_coord_t line_space = draw_label_dsc_act->line_space;
|
||||
const lv_font_t * font = draw_label_dsc_act.font;
|
||||
lv_coord_t letter_space = draw_label_dsc_act.letter_space;
|
||||
lv_coord_t line_space = draw_label_dsc_act.line_space;
|
||||
const char * txt = btnm->map_p[txt_i];
|
||||
|
||||
#if LV_USE_ARABIC_PERSIAN_CHARS
|
||||
@ -685,7 +682,7 @@ static lv_drawer_res_t lv_btnmatrix_drawer(lv_obj_t * obj, const lv_area_t * cli
|
||||
|
||||
lv_point_t txt_size;
|
||||
_lv_txt_get_size(&txt_size, txt, font, letter_space,
|
||||
line_space, lv_area_get_width(&area_obj), txt_flag);
|
||||
line_space, lv_area_get_width(&area_obj), recolor_flag);
|
||||
|
||||
btn_area.x1 += (lv_area_get_width(&btn_area) - txt_size.x) / 2;
|
||||
btn_area.y1 += (lv_area_get_height(&btn_area) - txt_size.y) / 2;
|
||||
@ -693,7 +690,10 @@ static lv_drawer_res_t lv_btnmatrix_drawer(lv_obj_t * obj, const lv_area_t * cli
|
||||
btn_area.y2 = btn_area.y1 + txt_size.y;
|
||||
|
||||
/*Draw the text*/
|
||||
lv_draw_label(&btn_area, clip_area, draw_label_dsc_act, txt, NULL);
|
||||
lv_draw_label(&btn_area, clip_area, &draw_label_dsc_act, txt, NULL);
|
||||
|
||||
|
||||
lv_event_send(obj,LV_EVENT_DRAW_PART_END, &hook_dsc);
|
||||
}
|
||||
|
||||
obj->style_list.skip_trans = 0;
|
||||
@ -701,10 +701,10 @@ static lv_drawer_res_t lv_btnmatrix_drawer(lv_obj_t * obj, const lv_area_t * cli
|
||||
_lv_mem_buf_release(txt_ap);
|
||||
#endif
|
||||
}
|
||||
else if(mode == LV_DRAWER_MODE_POST_DRAW) {
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
else if(mode == LV_DRAW_MODE_POST_DRAW) {
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ enum {
|
||||
};
|
||||
typedef uint16_t lv_btnmatrix_ctrl_t;
|
||||
|
||||
typedef bool (*lv_btnmatrix_btn_drawer_cb_t)(lv_obj_t * btnm, uint32_t btn_id, const lv_area_t * draw_area, const lv_area_t * clip_area);
|
||||
typedef bool (*lv_btnmatrix_btn_draw_cb_t)(lv_obj_t * btnm, uint32_t btn_id, const lv_area_t * draw_area, const lv_area_t * clip_area);
|
||||
|
||||
/*Data of button matrix*/
|
||||
typedef struct {
|
||||
@ -53,7 +53,7 @@ typedef struct {
|
||||
const char ** map_p; /*Pointer to the current map*/
|
||||
lv_area_t * button_areas; /*Array of areas of buttons*/
|
||||
lv_btnmatrix_ctrl_t * ctrl_bits; /*Array of control bytes*/
|
||||
lv_btnmatrix_btn_drawer_cb_t custom_drawer_cb;
|
||||
lv_btnmatrix_btn_draw_cb_t custom_draw_cb;
|
||||
uint16_t btn_cnt; /*Number of button in 'map_p'(Handled by the library)*/
|
||||
uint16_t btn_id_pr; /*Index of the currently pressed button or LV_BTNMATRIX_BTN_NONE*/
|
||||
uint16_t btn_id_focused; /*Index of the currently focused button or LV_BTNMATRIX_BTN_NONE*/
|
||||
|
@ -28,6 +28,9 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void lv_canvas_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_canvas_destructor(lv_obj_t * obj);
|
||||
static lv_draw_res_t lv_canvas_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_canvas_signal(lv_obj_t * canvas, lv_signal_t sign, void * param);
|
||||
static void set_set_px_cb(lv_disp_drv_t * disp_drv, lv_img_cf_t cf);
|
||||
|
||||
@ -53,8 +56,14 @@ static void set_px_alpha_generic(lv_img_dsc_t * d, lv_coord_t x, lv_coord_t y, l
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_drawer_cb_t ancestor_drawer;
|
||||
const lv_obj_class_t lv_canvas = {
|
||||
.constructor = lv_canvas_constructor,
|
||||
.destructor = lv_canvas_destructor,
|
||||
.signal_cb = lv_canvas_signal,
|
||||
.draw_cb = lv_canvas_draw,
|
||||
.instance_size = sizeof(lv_canvas_t),
|
||||
.base_class = &lv_img
|
||||
};
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -70,52 +79,9 @@ static lv_drawer_cb_t ancestor_drawer;
|
||||
* @param copy pointer to a canvas object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created canvas
|
||||
*/
|
||||
lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_t * lv_canvas_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
{
|
||||
LV_LOG_TRACE("canvas create started");
|
||||
|
||||
/*Create the ancestor of canvas*/
|
||||
lv_obj_t * new_canvas = lv_img_create(par, copy);
|
||||
LV_ASSERT_MEM(new_canvas);
|
||||
if(new_canvas == NULL) return NULL;
|
||||
|
||||
/*Allocate the canvas type specific extended data*/
|
||||
lv_canvas_ext_t * ext = lv_obj_allocate_ext_attr(new_canvas, sizeof(lv_canvas_ext_t));
|
||||
LV_ASSERT_MEM(ext);
|
||||
if(ext == NULL) {
|
||||
lv_obj_del(new_canvas);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_canvas);
|
||||
if(ancestor_drawer == NULL) ancestor_drawer = lv_obj_get_drawer_cb(new_canvas);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
ext->dsc.header.always_zero = 0;
|
||||
ext->dsc.header.cf = LV_IMG_CF_TRUE_COLOR;
|
||||
ext->dsc.header.h = 0;
|
||||
ext->dsc.header.w = 0;
|
||||
ext->dsc.data_size = 0;
|
||||
ext->dsc.data = NULL;
|
||||
|
||||
lv_img_set_src(new_canvas, &ext->dsc);
|
||||
|
||||
/*The signal and drawer functions are not copied so set them here*/
|
||||
lv_obj_set_signal_cb(new_canvas, lv_canvas_signal);
|
||||
|
||||
/*Init the new canvas canvas*/
|
||||
if(copy == NULL) {
|
||||
lv_theme_apply(new_canvas, LV_THEME_CANVAS);
|
||||
}
|
||||
/*Copy an existing canvas*/
|
||||
else {
|
||||
/*Do not copy the image data because each canvas needs it's own buffer*/
|
||||
|
||||
}
|
||||
|
||||
LV_LOG_INFO("canvas created");
|
||||
|
||||
return new_canvas;
|
||||
return lv_obj_create_from_class(&lv_canvas, parent, copy);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -136,19 +102,19 @@ lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
* LV_IMG_CF_TRUE_COLOR, LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED, LV_IMG_CF_INDEXES_1/2/4/8BIT
|
||||
*
|
||||
*/
|
||||
void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
|
||||
void lv_canvas_set_buffer(lv_obj_t * obj, void * buf, lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
|
||||
{
|
||||
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(buf);
|
||||
|
||||
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
||||
lv_canvas_t * canvas = (lv_canvas_t *) obj;
|
||||
|
||||
ext->dsc.header.cf = cf;
|
||||
ext->dsc.header.w = w;
|
||||
ext->dsc.header.h = h;
|
||||
ext->dsc.data = buf;
|
||||
canvas->dsc.header.cf = cf;
|
||||
canvas->dsc.header.w = w;
|
||||
canvas->dsc.header.h = h;
|
||||
canvas->dsc.data = buf;
|
||||
|
||||
lv_img_set_src(canvas, &ext->dsc);
|
||||
lv_img_set_src(obj, &canvas->dsc);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,14 +124,14 @@ void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_
|
||||
* @param y x coordinate of the point to set
|
||||
* @param c color of the point
|
||||
*/
|
||||
void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t c)
|
||||
void lv_canvas_set_px(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_color_t c)
|
||||
{
|
||||
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
||||
lv_canvas_t * canvas = (lv_canvas_t *) obj;
|
||||
|
||||
lv_img_buf_set_px_color(&ext->dsc, x, y, c);
|
||||
lv_obj_invalidate(canvas);
|
||||
lv_img_buf_set_px_color(&canvas->dsc, x, y, c);
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -178,14 +144,14 @@ void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t
|
||||
* - for `LV_IMG_CF_INDEXED8`: 0..255
|
||||
* @param c the color to set
|
||||
*/
|
||||
void lv_canvas_set_palette(lv_obj_t * canvas, uint8_t id, lv_color_t c)
|
||||
void lv_canvas_set_palette(lv_obj_t * obj, uint8_t id, lv_color_t c)
|
||||
{
|
||||
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
||||
lv_canvas_t * canvas = (lv_canvas_t *) obj;
|
||||
|
||||
lv_img_buf_set_palette(&ext->dsc, id, c);
|
||||
lv_obj_invalidate(canvas);
|
||||
lv_img_buf_set_palette(&canvas->dsc, id, c);
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -199,14 +165,14 @@ void lv_canvas_set_palette(lv_obj_t * canvas, uint8_t id, lv_color_t c)
|
||||
* @param y x coordinate of the point to set
|
||||
* @return color of the point
|
||||
*/
|
||||
lv_color_t lv_canvas_get_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y)
|
||||
lv_color_t lv_canvas_get_px(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
|
||||
{
|
||||
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
||||
lv_color_t color = lv_obj_get_style_image_recolor(canvas, LV_CANVAS_PART_MAIN);
|
||||
lv_canvas_t * canvas = (lv_canvas_t *) obj;
|
||||
lv_color_t color = lv_obj_get_style_img_recolor(obj, LV_PART_MAIN);
|
||||
|
||||
return lv_img_buf_get_px_color(&ext->dsc, x, y, color);
|
||||
return lv_img_buf_get_px_color(&canvas->dsc, x, y, color);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -214,13 +180,12 @@ lv_color_t lv_canvas_get_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y)
|
||||
* @param canvas pointer to a canvas object
|
||||
* @return pointer to the image descriptor.
|
||||
*/
|
||||
lv_img_dsc_t * lv_canvas_get_img(lv_obj_t * canvas)
|
||||
lv_img_dsc_t * lv_canvas_get_img(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
||||
|
||||
return &ext->dsc;
|
||||
lv_canvas_t * canvas = (lv_canvas_t *) obj;
|
||||
return &canvas->dsc;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -237,24 +202,25 @@ lv_img_dsc_t * lv_canvas_get_img(lv_obj_t * canvas)
|
||||
* @param x left side of the destination position
|
||||
* @param y top side of the destination position
|
||||
*/
|
||||
void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h)
|
||||
void lv_canvas_copy_buf(lv_obj_t * obj, const void * to_copy, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h)
|
||||
{
|
||||
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(to_copy);
|
||||
|
||||
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
||||
if(x + w >= (lv_coord_t)ext->dsc.header.w || y + h >= (lv_coord_t)ext->dsc.header.h) {
|
||||
lv_canvas_t * canvas = (lv_canvas_t *) obj;
|
||||
|
||||
if(x + w >= (lv_coord_t)canvas->dsc.header.w || y + h >= (lv_coord_t)canvas->dsc.header.h) {
|
||||
LV_LOG_WARN("lv_canvas_copy_buf: x or y out of the canvas");
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t px_size = lv_img_cf_get_px_size(ext->dsc.header.cf) >> 3;
|
||||
uint32_t px = ext->dsc.header.w * y * px_size + x * px_size;
|
||||
uint32_t px_size = lv_img_cf_get_px_size(canvas->dsc.header.cf) >> 3;
|
||||
uint32_t px = canvas->dsc.header.w * y * px_size + x * px_size;
|
||||
uint8_t * to_copy8 = (uint8_t *)to_copy;
|
||||
lv_coord_t i;
|
||||
for(i = 0; i < h; i++) {
|
||||
_lv_memcpy((void *)&ext->dsc.data[px], to_copy8, w * px_size);
|
||||
px += ext->dsc.header.w * px_size;
|
||||
_lv_memcpy((void *)&canvas->dsc.data[px], to_copy8, w * px_size);
|
||||
px += canvas->dsc.header.w * px_size;
|
||||
to_copy8 += w * px_size;
|
||||
}
|
||||
}
|
||||
@ -274,19 +240,19 @@ void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t x, l
|
||||
* Set to `source height / 2` to rotate around the center
|
||||
* @param antialias apply anti-aliasing during the transformation. Looks better but slower.
|
||||
*/
|
||||
void lv_canvas_transform(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, uint16_t zoom, lv_coord_t offset_x,
|
||||
void lv_canvas_transform(lv_obj_t * obj, lv_img_dsc_t * img, int16_t angle, uint16_t zoom, lv_coord_t offset_x,
|
||||
lv_coord_t offset_y,
|
||||
int32_t pivot_x, int32_t pivot_y, bool antialias)
|
||||
{
|
||||
#if LV_USE_IMG_TRANSFORM
|
||||
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(img);
|
||||
|
||||
lv_canvas_ext_t * ext_dst = lv_obj_get_ext_attr(canvas);
|
||||
lv_color_t color = lv_obj_get_style_image_recolor(canvas, LV_CANVAS_PART_MAIN);
|
||||
lv_canvas_t * canvas = (lv_canvas_t *) obj;
|
||||
lv_color_t color = lv_obj_get_style_img_recolor(obj, LV_PART_MAIN);
|
||||
|
||||
int32_t dest_width = ext_dst->dsc.header.w;
|
||||
int32_t dest_height = ext_dst->dsc.header.h;
|
||||
int32_t dest_width = canvas->dsc.header.w;
|
||||
int32_t dest_height = canvas->dsc.header.h;
|
||||
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
@ -315,30 +281,30 @@ void lv_canvas_transform(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, u
|
||||
if(x + offset_x >= 0 && x + offset_x < dest_width && y + offset_y >= 0 && y + offset_y < dest_height) {
|
||||
/*If the image has no alpha channel just simple set the result color on the canvas*/
|
||||
if(lv_img_cf_has_alpha(img->header.cf) == false) {
|
||||
lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, dsc.res.color);
|
||||
lv_img_buf_set_px_color(&canvas->dsc, x + offset_x, y + offset_y, dsc.res.color);
|
||||
}
|
||||
else {
|
||||
lv_color_t bg_color = lv_img_buf_get_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, dsc.cfg.color);
|
||||
lv_color_t bg_color = lv_img_buf_get_px_color(&canvas->dsc, x + offset_x, y + offset_y, dsc.cfg.color);
|
||||
|
||||
/*If the canvas has no alpha but the image has mix the image's color with
|
||||
* canvas*/
|
||||
if(lv_img_cf_has_alpha(ext_dst->dsc.header.cf) == false) {
|
||||
if(lv_img_cf_has_alpha(canvas->dsc.header.cf) == false) {
|
||||
if(dsc.res.opa < LV_OPA_MAX) dsc.res.color = lv_color_mix(dsc.res.color, bg_color, dsc.res.opa);
|
||||
lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, dsc.res.color);
|
||||
lv_img_buf_set_px_color(&canvas->dsc, x + offset_x, y + offset_y, dsc.res.color);
|
||||
}
|
||||
/*Both the image and canvas has alpha channel. Some extra calculation is
|
||||
required*/
|
||||
else {
|
||||
lv_opa_t bg_opa = lv_img_buf_get_px_alpha(&ext_dst->dsc, x + offset_x, y + offset_y);
|
||||
lv_opa_t bg_opa = lv_img_buf_get_px_alpha(&canvas->dsc, x + offset_x, y + offset_y);
|
||||
/* Pick the foreground if it's fully opaque or the Background is fully
|
||||
* transparent*/
|
||||
if(dsc.res.opa >= LV_OPA_MAX || bg_opa <= LV_OPA_MIN) {
|
||||
lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, dsc.res.color);
|
||||
lv_img_buf_set_px_alpha(&ext_dst->dsc, x + offset_x, y + offset_y, dsc.res.opa);
|
||||
lv_img_buf_set_px_color(&canvas->dsc, x + offset_x, y + offset_y, dsc.res.color);
|
||||
lv_img_buf_set_px_alpha(&canvas->dsc, x + offset_x, y + offset_y, dsc.res.opa);
|
||||
}
|
||||
/*Opaque background: use simple mix*/
|
||||
else if(bg_opa >= LV_OPA_MAX) {
|
||||
lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y,
|
||||
lv_img_buf_set_px_color(&canvas->dsc, x + offset_x, y + offset_y,
|
||||
lv_color_mix(dsc.res.color, bg_color, dsc.res.opa));
|
||||
}
|
||||
/*Both colors have alpha. Expensive calculation need to be applied*/
|
||||
@ -352,9 +318,9 @@ void lv_canvas_transform(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, u
|
||||
}
|
||||
lv_opa_t ratio = (uint16_t)((uint16_t)dsc.res.opa * 255) / opa_res_2;
|
||||
|
||||
lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y,
|
||||
lv_img_buf_set_px_color(&canvas->dsc, x + offset_x, y + offset_y,
|
||||
lv_color_mix(dsc.res.color, bg_color, ratio));
|
||||
lv_img_buf_set_px_alpha(&ext_dst->dsc, x + offset_x, y + offset_y, opa_res_2);
|
||||
lv_img_buf_set_px_alpha(&canvas->dsc, x + offset_x, y + offset_y, opa_res_2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -362,7 +328,7 @@ void lv_canvas_transform(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, u
|
||||
}
|
||||
}
|
||||
|
||||
lv_obj_invalidate(canvas);
|
||||
lv_obj_invalidate(obj);
|
||||
#else
|
||||
LV_UNUSED(canvas);
|
||||
LV_UNUSED(img);
|
||||
@ -384,47 +350,47 @@ void lv_canvas_transform(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, u
|
||||
* @param area the area to blur. If `NULL` the whole canvas will be blurred.
|
||||
* @param r radius of the blur
|
||||
*/
|
||||
void lv_canvas_blur_hor(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
|
||||
void lv_canvas_blur_hor(lv_obj_t * obj, const lv_area_t * area, uint16_t r)
|
||||
{
|
||||
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
if(r == 0) return;
|
||||
|
||||
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
||||
lv_canvas_t * canvas = (lv_canvas_t *) obj;
|
||||
|
||||
lv_area_t a;
|
||||
if(area) {
|
||||
lv_area_copy(&a, area);
|
||||
if(a.x1 < 0) a.x1 = 0;
|
||||
if(a.y1 < 0) a.y1 = 0;
|
||||
if(a.x2 > ext->dsc.header.w - 1) a.x2 = ext->dsc.header.w - 1;
|
||||
if(a.y2 > ext->dsc.header.h - 1) a.y2 = ext->dsc.header.h - 1;
|
||||
if(a.x2 > canvas->dsc.header.w - 1) a.x2 = canvas->dsc.header.w - 1;
|
||||
if(a.y2 > canvas->dsc.header.h - 1) a.y2 = canvas->dsc.header.h - 1;
|
||||
}
|
||||
else {
|
||||
a.x1 = 0;
|
||||
a.y1 = 0;
|
||||
a.x2 = ext->dsc.header.w - 1;
|
||||
a.y2 = ext->dsc.header.h - 1;
|
||||
a.x2 = canvas->dsc.header.w - 1;
|
||||
a.y2 = canvas->dsc.header.h - 1;
|
||||
}
|
||||
|
||||
lv_color_t color = lv_obj_get_style_image_recolor(canvas, LV_CANVAS_PART_MAIN);
|
||||
lv_color_t color = lv_obj_get_style_img_recolor(obj, LV_PART_MAIN);
|
||||
|
||||
uint16_t r_back = r / 2;
|
||||
uint16_t r_front = r / 2;
|
||||
|
||||
if((r & 0x1) == 0) r_back--;
|
||||
|
||||
bool has_alpha = lv_img_cf_has_alpha(ext->dsc.header.cf);
|
||||
bool has_alpha = lv_img_cf_has_alpha(canvas->dsc.header.cf);
|
||||
|
||||
lv_coord_t line_w = lv_img_buf_get_img_size(ext->dsc.header.w, 1, ext->dsc.header.cf);
|
||||
lv_coord_t line_w = lv_img_buf_get_img_size(canvas->dsc.header.w, 1, canvas->dsc.header.cf);
|
||||
uint8_t * line_buf = _lv_mem_buf_get(line_w);
|
||||
|
||||
lv_img_dsc_t line_img;
|
||||
line_img.data = line_buf;
|
||||
line_img.header.always_zero = 0;
|
||||
line_img.header.w = ext->dsc.header.w;
|
||||
line_img.header.w = canvas->dsc.header.w;
|
||||
line_img.header.h = 1;
|
||||
line_img.header.cf = ext->dsc.header.cf;
|
||||
line_img.header.cf = canvas->dsc.header.cf;
|
||||
|
||||
lv_coord_t x;
|
||||
lv_coord_t y;
|
||||
@ -438,12 +404,12 @@ void lv_canvas_blur_hor(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
|
||||
|
||||
lv_color_t c;
|
||||
lv_opa_t opa = LV_OPA_TRANSP;
|
||||
_lv_memcpy(line_buf, &ext->dsc.data[y * line_w], line_w);
|
||||
_lv_memcpy(line_buf, &canvas->dsc.data[y * line_w], line_w);
|
||||
|
||||
|
||||
for(x = a.x1 - r_back; x <= a.x1 + r_front; x++) {
|
||||
x_safe = x < 0 ? 0 : x;
|
||||
x_safe = x_safe > ext->dsc.header.w - 1 ? ext->dsc.header.w - 1 : x_safe;
|
||||
x_safe = x_safe > canvas->dsc.header.w - 1 ? canvas->dsc.header.w - 1 : x_safe;
|
||||
|
||||
c = lv_img_buf_get_px_color(&line_img, x_safe, 0, color);
|
||||
if(has_alpha) opa = lv_img_buf_get_px_alpha(&line_img, x_safe, 0);
|
||||
@ -475,9 +441,9 @@ void lv_canvas_blur_hor(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
|
||||
c.ch.blue = bsum / r;
|
||||
if(has_alpha) opa = asum / r;
|
||||
|
||||
lv_img_buf_set_px_color(&ext->dsc, x, y, c);
|
||||
lv_img_buf_set_px_color(&canvas->dsc, x, y, c);
|
||||
}
|
||||
if(has_alpha) lv_img_buf_set_px_alpha(&ext->dsc, x, y, opa);
|
||||
if(has_alpha) lv_img_buf_set_px_alpha(&canvas->dsc, x, y, opa);
|
||||
|
||||
x_safe = x - r_back;
|
||||
x_safe = x_safe < 0 ? 0 : x_safe;
|
||||
@ -494,7 +460,7 @@ void lv_canvas_blur_hor(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
|
||||
if(has_alpha) asum -= opa;
|
||||
|
||||
x_safe = x + 1 + r_front;
|
||||
x_safe = x_safe > ext->dsc.header.w - 1 ? ext->dsc.header.w - 1 : x_safe;
|
||||
x_safe = x_safe > canvas->dsc.header.w - 1 ? canvas->dsc.header.w - 1 : x_safe;
|
||||
c = lv_img_buf_get_px_color(&line_img, x_safe, 0, LV_COLOR_RED);
|
||||
if(has_alpha) opa = lv_img_buf_get_px_alpha(&line_img, x_safe, 0);
|
||||
|
||||
@ -508,7 +474,7 @@ void lv_canvas_blur_hor(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
|
||||
if(has_alpha) asum += opa;
|
||||
}
|
||||
}
|
||||
lv_obj_invalidate(canvas);
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
_lv_mem_buf_release(line_buf);
|
||||
}
|
||||
@ -520,46 +486,46 @@ void lv_canvas_blur_hor(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
|
||||
* @param area the area to blur. If `NULL` the whole canvas will be blurred.
|
||||
* @param r radius of the blur
|
||||
*/
|
||||
void lv_canvas_blur_ver(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
|
||||
void lv_canvas_blur_ver(lv_obj_t * obj, const lv_area_t * area, uint16_t r)
|
||||
{
|
||||
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
if(r == 0) return;
|
||||
|
||||
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
||||
lv_canvas_t * canvas = (lv_canvas_t *) obj;
|
||||
|
||||
lv_area_t a;
|
||||
if(area) {
|
||||
lv_area_copy(&a, area);
|
||||
if(a.x1 < 0) a.x1 = 0;
|
||||
if(a.y1 < 0) a.y1 = 0;
|
||||
if(a.x2 > ext->dsc.header.w - 1) a.x2 = ext->dsc.header.w - 1;
|
||||
if(a.y2 > ext->dsc.header.h - 1) a.y2 = ext->dsc.header.h - 1;
|
||||
if(a.x2 > canvas->dsc.header.w - 1) a.x2 = canvas->dsc.header.w - 1;
|
||||
if(a.y2 > canvas->dsc.header.h - 1) a.y2 = canvas->dsc.header.h - 1;
|
||||
}
|
||||
else {
|
||||
a.x1 = 0;
|
||||
a.y1 = 0;
|
||||
a.x2 = ext->dsc.header.w - 1;
|
||||
a.y2 = ext->dsc.header.h - 1;
|
||||
a.x2 = canvas->dsc.header.w - 1;
|
||||
a.y2 = canvas->dsc.header.h - 1;
|
||||
}
|
||||
|
||||
lv_color_t color = lv_obj_get_style_image_recolor(canvas, LV_CANVAS_PART_MAIN);
|
||||
lv_color_t color = lv_obj_get_style_img_recolor(obj, LV_PART_MAIN);
|
||||
|
||||
uint16_t r_back = r / 2;
|
||||
uint16_t r_front = r / 2;
|
||||
|
||||
if((r & 0x1) == 0) r_back--;
|
||||
|
||||
bool has_alpha = lv_img_cf_has_alpha(ext->dsc.header.cf);
|
||||
lv_coord_t col_w = lv_img_buf_get_img_size(1, ext->dsc.header.h, ext->dsc.header.cf);
|
||||
bool has_alpha = lv_img_cf_has_alpha(canvas->dsc.header.cf);
|
||||
lv_coord_t col_w = lv_img_buf_get_img_size(1, canvas->dsc.header.h, canvas->dsc.header.cf);
|
||||
uint8_t * col_buf = _lv_mem_buf_get(col_w);
|
||||
lv_img_dsc_t line_img;
|
||||
|
||||
line_img.data = col_buf;
|
||||
line_img.header.always_zero = 0;
|
||||
line_img.header.w = 1;
|
||||
line_img.header.h = ext->dsc.header.h;
|
||||
line_img.header.cf = ext->dsc.header.cf;
|
||||
line_img.header.h = canvas->dsc.header.h;
|
||||
line_img.header.cf = canvas->dsc.header.cf;
|
||||
|
||||
lv_coord_t x;
|
||||
lv_coord_t y;
|
||||
@ -576,10 +542,10 @@ void lv_canvas_blur_ver(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
|
||||
|
||||
for(y = a.y1 - r_back; y <= a.y1 + r_front; y++) {
|
||||
y_safe = y < 0 ? 0 : y;
|
||||
y_safe = y_safe > ext->dsc.header.h - 1 ? ext->dsc.header.h - 1 : y_safe;
|
||||
y_safe = y_safe > canvas->dsc.header.h - 1 ? canvas->dsc.header.h - 1 : y_safe;
|
||||
|
||||
c = lv_img_buf_get_px_color(&ext->dsc, x, y_safe, color);
|
||||
if(has_alpha) opa = lv_img_buf_get_px_alpha(&ext->dsc, x, y_safe);
|
||||
c = lv_img_buf_get_px_color(&canvas->dsc, x, y_safe, color);
|
||||
if(has_alpha) opa = lv_img_buf_get_px_alpha(&canvas->dsc, x, y_safe);
|
||||
|
||||
lv_img_buf_set_px_color(&line_img, 0, y_safe, c);
|
||||
if(has_alpha) lv_img_buf_set_px_alpha(&line_img, 0, y_safe, opa);
|
||||
@ -610,9 +576,9 @@ void lv_canvas_blur_ver(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
|
||||
c.ch.blue = bsum / r;
|
||||
if(has_alpha) opa = asum / r;
|
||||
|
||||
lv_img_buf_set_px_color(&ext->dsc, x, y, c);
|
||||
lv_img_buf_set_px_color(&canvas->dsc, x, y, c);
|
||||
}
|
||||
if(has_alpha) lv_img_buf_set_px_alpha(&ext->dsc, x, y, opa);
|
||||
if(has_alpha) lv_img_buf_set_px_alpha(&canvas->dsc, x, y, opa);
|
||||
|
||||
y_safe = y - r_back;
|
||||
y_safe = y_safe < 0 ? 0 : y_safe;
|
||||
@ -629,10 +595,10 @@ void lv_canvas_blur_ver(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
|
||||
if(has_alpha) asum -= opa;
|
||||
|
||||
y_safe = y + 1 + r_front;
|
||||
y_safe = y_safe > ext->dsc.header.h - 1 ? ext->dsc.header.h - 1 : y_safe;
|
||||
y_safe = y_safe > canvas->dsc.header.h - 1 ? canvas->dsc.header.h - 1 : y_safe;
|
||||
|
||||
c = lv_img_buf_get_px_color(&ext->dsc, x, y_safe, color);
|
||||
if(has_alpha) opa = lv_img_buf_get_px_alpha(&ext->dsc, x, y_safe);
|
||||
c = lv_img_buf_get_px_color(&canvas->dsc, x, y_safe, color);
|
||||
if(has_alpha) opa = lv_img_buf_get_px_alpha(&canvas->dsc, x, y_safe);
|
||||
|
||||
lv_img_buf_set_px_color(&line_img, 0, y_safe, c);
|
||||
if(has_alpha) lv_img_buf_set_px_alpha(&line_img, 0, y_safe, opa);
|
||||
@ -648,7 +614,7 @@ void lv_canvas_blur_ver(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
|
||||
}
|
||||
}
|
||||
|
||||
lv_obj_invalidate(canvas);
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
_lv_mem_buf_release(col_buf);
|
||||
}
|
||||
@ -766,11 +732,9 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
|
||||
* @param max_w max width of the text. The text will be wrapped to fit into this size
|
||||
* @param label_draw_dsc pointer to a valid label descriptor `lv_draw_label_dsc_t`
|
||||
* @param txt text to display
|
||||
* @param align align of the text (`LV_TEXT_ALIGN_LEFT/RIGHT/CENTER`)
|
||||
*/
|
||||
void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w,
|
||||
lv_draw_label_dsc_t * label_draw_dsc,
|
||||
const char * txt, lv_text_align_t align)
|
||||
lv_draw_label_dsc_t * label_draw_dsc, const char * txt)
|
||||
{
|
||||
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||
|
||||
@ -813,24 +777,6 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
|
||||
lv_disp_t * refr_ori = _lv_refr_get_disp_refreshing();
|
||||
_lv_refr_set_disp_refreshing(&disp);
|
||||
|
||||
lv_txt_flag_t flag;
|
||||
switch(align) {
|
||||
case LV_TEXT_ALIGN_LEFT:
|
||||
flag = LV_TEXT_FLAG_NONE;
|
||||
break;
|
||||
case LV_TEXT_ALIGN_RIGHT:
|
||||
flag = LV_TEXT_FLAG_RIGHT;
|
||||
break;
|
||||
case LV_TEXT_ALIGN_CENTER:
|
||||
flag = LV_TEXT_FLAG_CENTER;
|
||||
break;
|
||||
default:
|
||||
flag = LV_TEXT_FLAG_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
label_draw_dsc->flag = flag;
|
||||
|
||||
lv_draw_label(&coords, &mask, label_draw_dsc, txt, NULL);
|
||||
|
||||
_lv_refr_set_disp_refreshing(refr_ori);
|
||||
@ -1094,6 +1040,44 @@ void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void lv_canvas_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy)
|
||||
{
|
||||
LV_LOG_TRACE("canvas create started");
|
||||
|
||||
lv_canvas_t * canvas = (lv_canvas_t *) obj;
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
canvas->dsc.header.always_zero = 0;
|
||||
canvas->dsc.header.cf = LV_IMG_CF_TRUE_COLOR;
|
||||
canvas->dsc.header.h = 0;
|
||||
canvas->dsc.header.w = 0;
|
||||
canvas->dsc.data_size = 0;
|
||||
canvas->dsc.data = NULL;
|
||||
|
||||
lv_img_set_src(obj, &canvas->dsc);
|
||||
|
||||
LV_LOG_INFO("canvas created");
|
||||
}
|
||||
|
||||
static void lv_canvas_destructor(lv_obj_t * obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the bars
|
||||
* @param canvas pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_draw_res_t lv_canvas_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
return lv_img.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
/**
|
||||
* Signal function of the canvas
|
||||
* @param canvas pointer to a canvas object
|
||||
@ -1103,19 +1087,7 @@ void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_
|
||||
*/
|
||||
static lv_res_t lv_canvas_signal(lv_obj_t * canvas, lv_signal_t sign, void * param)
|
||||
{
|
||||
lv_res_t res;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
res = ancestor_signal(canvas, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
return _lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||
}
|
||||
|
||||
return res;
|
||||
return lv_img.signal_cb(canvas, sign, param);
|
||||
}
|
||||
|
||||
static void set_set_px_cb(lv_disp_drv_t * disp_drv, lv_img_cf_t cf)
|
||||
|
@ -30,16 +30,9 @@ extern "C" {
|
||||
**********************/
|
||||
/*Data of canvas*/
|
||||
typedef struct {
|
||||
lv_img_ext_t img; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_img_t img;
|
||||
lv_img_dsc_t dsc;
|
||||
} lv_canvas_ext_t;
|
||||
|
||||
/*Canvas part*/
|
||||
enum {
|
||||
LV_CANVAS_PART_MAIN,
|
||||
};
|
||||
typedef uint8_t lv_canvas_part_t;
|
||||
} lv_canvas_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@ -197,8 +190,7 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
|
||||
* @param align align of the text (`LV_TEXT_ALIGN_LEFT/RIGHT/CENTER`)
|
||||
*/
|
||||
void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w,
|
||||
lv_draw_label_dsc_t * label_draw_dsc,
|
||||
const char * txt, lv_text_align_t align);
|
||||
lv_draw_label_dsc_t * label_draw_dsc, const char * txt);
|
||||
|
||||
/**
|
||||
* Draw an image on the canvas
|
||||
|
@ -39,7 +39,7 @@
|
||||
**********************/
|
||||
static void lv_chart_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_chart_destructor(lv_obj_t * obj);
|
||||
static lv_drawer_res_t lv_chart_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_chart_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_chart_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
|
||||
static void draw_div_lines(lv_obj_t * obj , const lv_area_t * mask);
|
||||
@ -57,7 +57,7 @@ const lv_obj_class_t lv_chart = {
|
||||
.constructor = lv_chart_constructor,
|
||||
.destructor = lv_chart_destructor,
|
||||
.signal_cb = lv_chart_signal,
|
||||
.drawer_cb = lv_chart_drawer,
|
||||
.draw_cb = lv_chart_draw,
|
||||
.instance_size = sizeof(lv_chart_t),
|
||||
.base_class = &lv_obj
|
||||
};
|
||||
@ -813,19 +813,19 @@ static void lv_chart_destructor(lv_obj_t * obj)
|
||||
* Handle the drawing related tasks of the chart backgrounds
|
||||
* @param chart pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_chart_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_chart_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DRAWER_MODE_COVER_CHECK) {
|
||||
return lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
if(mode == LV_DRAW_MODE_COVER_CHECK) {
|
||||
return lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
else if(mode == LV_DRAWER_MODE_MAIN_DRAW) {
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
else if(mode == LV_DRAW_MODE_MAIN_DRAW) {
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
|
||||
draw_div_lines(obj, clip_area);
|
||||
draw_axes(obj, clip_area);
|
||||
@ -835,10 +835,10 @@ static lv_drawer_res_t lv_chart_drawer(lv_obj_t * obj, const lv_area_t * clip_ar
|
||||
if(chart->type & LV_CHART_TYPE_COLUMN) draw_series_column(obj, clip_area);
|
||||
draw_cursors(obj, clip_area);
|
||||
}
|
||||
else if(mode == LV_DRAWER_MODE_POST_DRAW) {
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
else if(mode == LV_DRAW_MODE_POST_DRAW) {
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -870,7 +870,7 @@ static lv_res_t lv_chart_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
/**
|
||||
* Draw the division lines on chart background
|
||||
* @param chart pointer to chart object
|
||||
* @param clip_area mask, inherited from the drawer function
|
||||
* @param clip_area mask, inherited from the draw function
|
||||
*/
|
||||
static void draw_div_lines(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
{
|
||||
@ -1072,7 +1072,7 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
/**
|
||||
* Draw the data lines as columns on a chart
|
||||
* @param chart pointer to chart object
|
||||
* @param mask mask, inherited from the drawer function
|
||||
* @param mask mask, inherited from the draw function
|
||||
*/
|
||||
static void draw_series_column(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
{
|
||||
@ -1441,7 +1441,7 @@ static void invalidate_lines(lv_obj_t * obj, uint16_t i)
|
||||
/**
|
||||
* invalid area of the new column data lines on a chart
|
||||
* @param chart pointer to chart object
|
||||
* @param mask mask, inherited from the drawer function
|
||||
* @param mask mask, inherited from the draw function
|
||||
*/
|
||||
static void invalidate_columns(lv_obj_t * obj, uint16_t i)
|
||||
{
|
||||
|
@ -28,7 +28,7 @@
|
||||
**********************/
|
||||
static void lv_checkbox_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_checkbox_destructor(lv_obj_t * obj);
|
||||
static lv_drawer_res_t lv_checkbox_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_checkbox_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_checkbox_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
|
||||
/**********************
|
||||
@ -38,7 +38,7 @@ const lv_obj_class_t lv_checkbox = {
|
||||
.constructor = lv_checkbox_constructor,
|
||||
.destructor = lv_checkbox_destructor,
|
||||
.signal_cb = lv_checkbox_signal,
|
||||
.drawer_cb = lv_checkbox_drawer,
|
||||
.draw_cb = lv_checkbox_draw,
|
||||
.instance_size = sizeof(lv_checkbox_t),
|
||||
.base_class = &lv_obj
|
||||
};
|
||||
@ -172,20 +172,20 @@ static void lv_checkbox_destructor(lv_obj_t * obj)
|
||||
* Handle the drawing related tasks of the check box
|
||||
* @param cb pointer to a check box object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_checkbox_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_checkbox_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
/* A label never covers an area */
|
||||
if(mode == LV_DRAWER_MODE_COVER_CHECK)
|
||||
return lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
else if(mode == LV_DRAWER_MODE_MAIN_DRAW) {
|
||||
if(mode == LV_DRAW_MODE_COVER_CHECK)
|
||||
return lv_obj.draw_cb(obj, clip_area, mode);
|
||||
else if(mode == LV_DRAW_MODE_MAIN_DRAW) {
|
||||
/*Draw the background*/
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
|
||||
lv_checkbox_t * cb = (lv_checkbox_t *) obj;
|
||||
|
||||
@ -241,10 +241,10 @@ static lv_drawer_res_t lv_checkbox_drawer(lv_obj_t * obj, const lv_area_t * clip
|
||||
lv_draw_label(&txt_area, clip_area, &txt_dsc, cb->txt, NULL);
|
||||
|
||||
} else {
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
/**
|
||||
* Signal function of the check box
|
||||
|
@ -42,8 +42,8 @@
|
||||
**********************/
|
||||
static void lv_dropdown_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_dropdown_destructor(void * obj);
|
||||
static lv_drawer_res_t lv_dropdown_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_drawer_res_t lv_dropdown_list_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_dropdown_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_draw_res_t lv_dropdown_list_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_dropdown_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
static lv_res_t lv_dropdown_list_signal(lv_obj_t * list, lv_signal_t sign, void * param);
|
||||
static void draw_box(lv_obj_t * dropdown_obj, const lv_area_t * clip_area, uint16_t id, lv_state_t state);
|
||||
@ -82,7 +82,7 @@ lv_obj_t * lv_dropdown_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
LV_CLASS_INIT(lv_dropdown, lv_obj);
|
||||
lv_dropdown.constructor = lv_dropdown_constructor;
|
||||
lv_dropdown.destructor = lv_dropdown_destructor;
|
||||
lv_dropdown.drawer_cb = lv_dropdown_drawer;
|
||||
lv_dropdown.draw_cb = lv_dropdown_draw;
|
||||
lv_dropdown.signal_cb = lv_dropdown_signal;
|
||||
}
|
||||
|
||||
@ -601,7 +601,7 @@ lv_obj_t * lv_dropdown_list_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
LV_CLASS_INIT(lv_dropdown_list, lv_obj);
|
||||
lv_dropdown_list.constructor = lv_obj.constructor;
|
||||
lv_dropdown_list.destructor = lv_obj.destructor;
|
||||
lv_dropdown_list.drawer_cb = lv_dropdown_list_drawer;
|
||||
lv_dropdown_list.draw_cb = lv_dropdown_list_draw;
|
||||
lv_dropdown_list.signal_cb = lv_dropdown_list_signal;
|
||||
}
|
||||
|
||||
@ -681,21 +681,21 @@ static void lv_dropdown_destructor(void * obj)
|
||||
* Handle the drawing related tasks of the drop down list
|
||||
* @param ddlist pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_dropdown_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_dropdown_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DRAWER_COVER_CHK) {
|
||||
return lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
if(mode == LV_DRAW_COVER_CHK) {
|
||||
return lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DRAWER_DRAW_MAIN) {
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
else if(mode == LV_DRAW_DRAW_MAIN) {
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
|
||||
lv_dropdown_t * dropdown = (lv_dropdown_t *) obj;
|
||||
|
||||
@ -770,32 +770,32 @@ static lv_drawer_res_t lv_dropdown_drawer(lv_obj_t * obj, const lv_area_t * clip
|
||||
}
|
||||
|
||||
}
|
||||
else if(mode == LV_DRAWER_DRAW_POST) {
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
else if(mode == LV_DRAW_DRAW_POST) {
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the drop down list's list
|
||||
* @param list pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_dropdown_list_drawer(lv_obj_t * list_obj, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_dropdown_list_draw(lv_obj_t * list_obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DRAWER_COVER_CHK) {
|
||||
return lv_obj.drawer_cb(list_obj, clip_area, mode);
|
||||
if(mode == LV_DRAW_COVER_CHK) {
|
||||
return lv_obj.draw_cb(list_obj, clip_area, mode);
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DRAWER_DRAW_MAIN) {
|
||||
lv_obj.drawer_cb(list_obj, clip_area, mode);
|
||||
else if(mode == LV_DRAW_DRAW_MAIN) {
|
||||
lv_obj.draw_cb(list_obj, clip_area, mode);
|
||||
|
||||
lv_dropdown_list_t * list = (lv_dropdown_list_t *)list_obj;
|
||||
lv_obj_t * dropdown_obj = list->dropdown;
|
||||
@ -818,8 +818,8 @@ static lv_drawer_res_t lv_dropdown_list_drawer(lv_obj_t * list_obj, const lv_are
|
||||
}
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DRAWER_DRAW_POST) {
|
||||
lv_obj.drawer_cb(list_obj, clip_area, mode);
|
||||
else if(mode == LV_DRAW_DRAW_POST) {
|
||||
lv_obj.draw_cb(list_obj, clip_area, mode);
|
||||
|
||||
lv_dropdown_list_t * list = (lv_dropdown_list_t *)list_obj;
|
||||
lv_obj_t * dropdown_obj = list->dropdown;
|
||||
@ -842,7 +842,7 @@ static lv_drawer_res_t lv_dropdown_list_drawer(lv_obj_t * list_obj, const lv_are
|
||||
}
|
||||
}
|
||||
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,650 +0,0 @@
|
||||
///**
|
||||
//* @file lv_gauge.c
|
||||
//*
|
||||
//*/
|
||||
//
|
||||
///*********************
|
||||
// * INCLUDES
|
||||
// *********************/
|
||||
//#include "lv_gauge.h"
|
||||
//#if LV_USE_GAUGE != 0
|
||||
//
|
||||
//#include "../lv_misc/lv_debug.h"
|
||||
//#include "../lv_draw/lv_draw.h"
|
||||
//#include "../lv_themes/lv_theme.h"
|
||||
//#include "../lv_misc/lv_txt.h"
|
||||
//#include "../lv_misc/lv_math.h"
|
||||
//#include "../lv_misc/lv_utils.h"
|
||||
//#include "lv_img.h"
|
||||
//#include <stdio.h>
|
||||
//#include <string.h>
|
||||
//
|
||||
///*********************
|
||||
// * DEFINES
|
||||
// *********************/
|
||||
//#define LV_OBJX_NAME "lv_gauge"
|
||||
//
|
||||
//#define LV_GAUGE_DEF_NEEDLE_COLOR LV_COLOR_RED
|
||||
//#define LV_GAUGE_DEF_LABEL_COUNT 6
|
||||
//#define LV_GAUGE_DEF_LINE_COUNT 21 /*Should be: ((label_cnt - 1) * internal_lines) + 1*/
|
||||
//#define LV_GAUGE_DEF_ANGLE 270
|
||||
//
|
||||
///**********************
|
||||
// * TYPEDEFS
|
||||
// **********************/
|
||||
//
|
||||
///**********************
|
||||
// * STATIC PROTOTYPES
|
||||
// **********************/
|
||||
//static lv_drawer_res_t lv_gauge_drawer(lv_obj_t * gauge, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
//static lv_res_t lv_gauge_signal(lv_obj_t * gauge, lv_signal_t sign, void * param);
|
||||
//static lv_style_list_t * lv_gauge_get_style(lv_obj_t * gauge, uint8_t part);
|
||||
//static void lv_gauge_draw_labels(lv_obj_t * gauge, const lv_area_t * mask);
|
||||
//static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * clip_area);
|
||||
//
|
||||
///**********************
|
||||
// * STATIC VARIABLES
|
||||
// **********************/
|
||||
//static lv_drawer_cb_t ancestor_drawer;
|
||||
//static lv_signal_cb_t ancestor_signal;
|
||||
//
|
||||
///**********************
|
||||
// * MACROS
|
||||
// **********************/
|
||||
//
|
||||
///**********************
|
||||
// * GLOBAL FUNCTIONS
|
||||
// **********************/
|
||||
//
|
||||
///**
|
||||
// * Create a gauge objects
|
||||
// * @param par pointer to an object, it will be the parent of the new gauge
|
||||
// * @param copy pointer to a gauge object, if not NULL then the new object will be copied from it
|
||||
// * @return pointer to the created gauge
|
||||
// */
|
||||
//lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
//{
|
||||
// LV_LOG_TRACE("gauge create started");
|
||||
//
|
||||
// /*Create the ancestor gauge*/
|
||||
// lv_obj_t * gauge = lv_linemeter_create(par, copy);
|
||||
// LV_ASSERT_MEM(gauge);
|
||||
// if(gauge == NULL) return NULL;
|
||||
//
|
||||
// /*Allocate the gauge type specific extended data*/
|
||||
// lv_gauge_ext_t * ext = lv_obj_allocate_ext_attr(gauge, sizeof(lv_gauge_ext_t));
|
||||
// LV_ASSERT_MEM(ext);
|
||||
// if(ext == NULL) {
|
||||
// lv_obj_del(gauge);
|
||||
// return NULL;
|
||||
// }
|
||||
//
|
||||
// /*Initialize the allocated 'ext' */
|
||||
// ext->needle_count = 0;
|
||||
// ext->values = NULL;
|
||||
// ext->needle_colors = NULL;
|
||||
// ext->label_count = LV_GAUGE_DEF_LABEL_COUNT;
|
||||
// ext->format_cb = NULL;
|
||||
//
|
||||
// ext->needle_img = 0;
|
||||
// ext->needle_img_pivot.x = 0;
|
||||
// ext->needle_img_pivot.y = 0;
|
||||
// if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(gauge);
|
||||
// if(ancestor_drawer == NULL) ancestor_drawer = lv_obj_get_drawer_cb(gauge);
|
||||
//
|
||||
// lv_style_list_init(&ext->style_strong);
|
||||
// lv_style_list_init(&ext->style_needle);
|
||||
//
|
||||
// /*The signal and drawer functions are not copied so set them here*/
|
||||
// lv_obj_set_signal_cb(gauge, lv_gauge_signal);
|
||||
// lv_obj_set_drawer_cb(gauge, lv_gauge_drawer);
|
||||
//
|
||||
// /*Init the new gauge gauge*/
|
||||
// if(copy == NULL) {
|
||||
// lv_gauge_set_scale(gauge, LV_GAUGE_DEF_ANGLE, LV_GAUGE_DEF_LINE_COUNT, LV_GAUGE_DEF_LABEL_COUNT);
|
||||
// lv_gauge_set_needle_count(gauge, 1, NULL);
|
||||
// lv_gauge_set_critical_value(gauge, 80);
|
||||
//
|
||||
// lv_theme_apply(gauge, LV_THEME_GAUGE);
|
||||
//
|
||||
// }
|
||||
// /*Copy an existing gauge*/
|
||||
// else {
|
||||
// lv_gauge_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
// lv_gauge_set_needle_count(gauge, copy_ext->needle_count, copy_ext->needle_colors);
|
||||
//
|
||||
// lv_style_list_copy(&ext->style_strong, ©_ext->style_strong);
|
||||
// lv_style_list_copy(&ext->style_needle, ©_ext->style_needle);
|
||||
//
|
||||
// uint8_t i;
|
||||
// for(i = 0; i < ext->needle_count; i++) {
|
||||
// ext->values[i] = copy_ext->values[i];
|
||||
// }
|
||||
// ext->label_count = copy_ext->label_count;
|
||||
// ext->format_cb = copy_ext->format_cb;
|
||||
//
|
||||
// /*Refresh the style with new signal function*/
|
||||
// _lv_obj_refresh_style(gauge, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
// }
|
||||
//
|
||||
// LV_LOG_INFO("gauge created");
|
||||
//
|
||||
// return gauge;
|
||||
//}
|
||||
//
|
||||
///*=====================
|
||||
// * Setter functions
|
||||
// *====================*/
|
||||
//
|
||||
///**
|
||||
// * Set the number of needles
|
||||
// * @param gauge pointer to gauge object
|
||||
// * @param needle_cnt new count of needles
|
||||
// * @param colors an array of colors for needles (with 'num' elements)
|
||||
// */
|
||||
//void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_color_t colors[])
|
||||
//{
|
||||
// LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||
//
|
||||
// lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
//
|
||||
// if(ext->needle_count != needle_cnt) {
|
||||
// if(ext->values != NULL) {
|
||||
// lv_mem_free(ext->values);
|
||||
// ext->values = NULL;
|
||||
// }
|
||||
//
|
||||
// ext->values = lv_mem_realloc(ext->values, needle_cnt * sizeof(ext->values[0]));
|
||||
// LV_ASSERT_MEM(ext->values);
|
||||
// if(ext->values == NULL) return;
|
||||
//
|
||||
// int16_t min = lv_gauge_get_min_value(gauge);
|
||||
// uint8_t n;
|
||||
// for(n = ext->needle_count; n < needle_cnt; n++) {
|
||||
// ext->values[n] = min;
|
||||
// }
|
||||
//
|
||||
// ext->needle_count = needle_cnt;
|
||||
// }
|
||||
//
|
||||
// ext->needle_colors = colors;
|
||||
// lv_obj_invalidate(gauge);
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Set the value of a needle
|
||||
// * @param gauge pointer to a gauge
|
||||
// * @param needle_id the id of the needle
|
||||
// * @param value the new value
|
||||
// */
|
||||
//void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int32_t value)
|
||||
//{
|
||||
// LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||
//
|
||||
// lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
//
|
||||
// if(needle_id >= ext->needle_count) return;
|
||||
// if(ext->values[needle_id] == value) return;
|
||||
//
|
||||
// int16_t min = lv_gauge_get_min_value(gauge);
|
||||
// int16_t max = lv_gauge_get_max_value(gauge);
|
||||
//
|
||||
// if(value > max)
|
||||
// value = max;
|
||||
// else if(value < min)
|
||||
// value = min;
|
||||
//
|
||||
// int32_t old_value = ext->values[needle_id];
|
||||
// ext->values[needle_id] = value;
|
||||
//
|
||||
// // lv_obj_invalidate(gauge);
|
||||
//
|
||||
// lv_coord_t pad = lv_obj_get_style_pad_left(gauge, LV_GAUGE_PART_NEEDLE);
|
||||
// lv_coord_t left = lv_obj_get_style_pad_left(gauge, LV_GAUGE_PART_MAIN);
|
||||
// lv_coord_t right = lv_obj_get_style_pad_right(gauge, LV_GAUGE_PART_MAIN);
|
||||
// lv_coord_t top = lv_obj_get_style_pad_top(gauge, LV_GAUGE_PART_MAIN);
|
||||
// lv_coord_t r = (lv_obj_get_width(gauge) - left - right) / 2 - pad;
|
||||
// lv_coord_t x_ofs = gauge->coords.x1 + r + left + pad;
|
||||
// lv_coord_t y_ofs = gauge->coords.y1 + r + top + pad;
|
||||
// uint16_t angle = lv_linemeter_get_scale_angle(gauge);
|
||||
// int16_t angle_ofs = 90 + (360 - angle) / 2 + lv_gauge_get_angle_offset(gauge);
|
||||
// lv_point_t p_mid;
|
||||
// lv_point_t p_end;
|
||||
// lv_coord_t needle_w;
|
||||
//
|
||||
// if(ext->needle_img) {
|
||||
// lv_img_header_t info;
|
||||
// lv_img_decoder_get_info(ext->needle_img, &info);
|
||||
// needle_w = info.h;
|
||||
// }
|
||||
// else {
|
||||
// needle_w = lv_obj_get_style_line_width(gauge, LV_GAUGE_PART_NEEDLE);
|
||||
// }
|
||||
//
|
||||
// p_mid.x = x_ofs;
|
||||
// p_mid.y = y_ofs;
|
||||
// /*Calculate the end point of a needle*/
|
||||
// int16_t needle_angle = (old_value - min) * angle / (max - min) + angle_ofs;
|
||||
//
|
||||
// p_end.y = (_lv_trigo_sin(needle_angle) * r) / LV_TRIGO_SIN_MAX + y_ofs;
|
||||
// p_end.x = (_lv_trigo_sin(needle_angle + 90) * r) / LV_TRIGO_SIN_MAX + x_ofs;
|
||||
//
|
||||
// lv_area_t a;
|
||||
// a.x1 = LV_MATH_MIN(p_mid.x, p_end.x) - needle_w;
|
||||
// a.y1 = LV_MATH_MIN(p_mid.y, p_end.y) - needle_w;
|
||||
// a.x2 = LV_MATH_MAX(p_mid.x, p_end.x) + needle_w;
|
||||
// a.y2 = LV_MATH_MAX(p_mid.y, p_end.y) + needle_w;
|
||||
// lv_obj_invalidate_area(gauge, &a);
|
||||
//
|
||||
// needle_angle = (value - min) * angle / (max - min) + angle_ofs;
|
||||
// p_end.y = (_lv_trigo_sin(needle_angle) * r) / LV_TRIGO_SIN_MAX + y_ofs;
|
||||
// p_end.x = (_lv_trigo_sin(needle_angle + 90) * r) / LV_TRIGO_SIN_MAX + x_ofs;
|
||||
//
|
||||
// a.x1 = LV_MATH_MIN(p_mid.x, p_end.x) - needle_w;
|
||||
// a.y1 = LV_MATH_MIN(p_mid.y, p_end.y) - needle_w;
|
||||
// a.x2 = LV_MATH_MAX(p_mid.x, p_end.x) + needle_w;
|
||||
// a.y2 = LV_MATH_MAX(p_mid.y, p_end.y) + needle_w;
|
||||
// lv_obj_invalidate_area(gauge, &a);
|
||||
//
|
||||
//
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Set the scale settings of a gauge
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @param angle angle of the scale (0..360)
|
||||
// * @param line_cnt count of scale lines.
|
||||
// * To get a given "subdivision" lines between labels:
|
||||
// * `line_cnt = (sub_div + 1) * (label_cnt - 1) + 1 `
|
||||
// * @param label_cnt count of scale labels.
|
||||
// */
|
||||
//void lv_gauge_set_scale(lv_obj_t * gauge, uint16_t angle, uint8_t line_cnt, uint8_t label_cnt)
|
||||
//{
|
||||
// LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||
//
|
||||
// lv_linemeter_set_scale(gauge, angle, line_cnt);
|
||||
//
|
||||
// lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
// ext->label_count = label_cnt;
|
||||
// lv_obj_invalidate(gauge);
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Set an image to display as needle(s).
|
||||
// * The needle image should be horizontal and pointing to the right (`--->`).
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @param img_src pointer to an `lv_img_dsc_t` variable or a path to an image
|
||||
// * (not an `lv_img` object)
|
||||
// * @param pivot_x the X coordinate of rotation center of the image
|
||||
// * @param pivot_y the Y coordinate of rotation center of the image
|
||||
// */
|
||||
//void lv_gauge_set_needle_img(lv_obj_t * gauge, const void * img, lv_coord_t pivot_x, lv_coord_t pivot_y)
|
||||
//{
|
||||
// LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||
//
|
||||
// lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
//
|
||||
// ext->needle_img = img;
|
||||
// ext->needle_img_pivot.x = pivot_x;
|
||||
// ext->needle_img_pivot.y = pivot_y;
|
||||
//
|
||||
// lv_obj_invalidate(gauge);
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Assign a function to format gauge values
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @param format_cb pointer to function of lv_gauge_format_cb_t
|
||||
// */
|
||||
//void lv_gauge_set_formatter_cb(lv_obj_t * gauge, lv_gauge_format_cb_t format_cb)
|
||||
//{
|
||||
// LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||
//
|
||||
// lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
//
|
||||
// ext->format_cb = format_cb;
|
||||
//}
|
||||
//
|
||||
///*=====================
|
||||
// * Getter functions
|
||||
// *====================*/
|
||||
//
|
||||
///**
|
||||
// * Get the value of a needle
|
||||
// * @param gauge pointer to gauge object
|
||||
// * @param needle the id of the needle
|
||||
// * @return the value of the needle [min,max]
|
||||
// */
|
||||
//int32_t lv_gauge_get_value(const lv_obj_t * gauge, uint8_t needle)
|
||||
//{
|
||||
// LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||
//
|
||||
// lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
// int16_t min = lv_gauge_get_min_value(gauge);
|
||||
//
|
||||
// if(needle >= ext->needle_count) return min;
|
||||
//
|
||||
// return ext->values[needle];
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Get the count of needles on a gauge
|
||||
// * @param gauge pointer to gauge
|
||||
// * @return count of needles
|
||||
// */
|
||||
//uint8_t lv_gauge_get_needle_count(const lv_obj_t * gauge)
|
||||
//{
|
||||
// LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||
//
|
||||
// lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
// return ext->needle_count;
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Set the number of labels (and the thicker lines too)
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @return count of labels
|
||||
// */
|
||||
//uint8_t lv_gauge_get_label_count(const lv_obj_t * gauge)
|
||||
//{
|
||||
// LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||
//
|
||||
// lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
// return ext->label_count;
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Get an image to display as needle(s).
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @return pointer to an `lv_img_dsc_t` variable or a path to an image
|
||||
// * (not an `lv_img` object). `NULL` if not used.
|
||||
// */
|
||||
//const void * lv_gauge_get_needle_img(lv_obj_t * gauge)
|
||||
//{
|
||||
// LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||
//
|
||||
// lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
//
|
||||
// return ext->needle_img;
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Get the X coordinate of the rotation center of the needle image
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @return the X coordinate of rotation center of the image
|
||||
// */
|
||||
//lv_coord_t lv_gauge_get_needle_img_pivot_x(lv_obj_t * gauge)
|
||||
//{
|
||||
// LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||
//
|
||||
// lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
//
|
||||
// return ext->needle_img_pivot.x;
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Get the Y coordinate of the rotation center of the needle image
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @return the X coordinate of rotation center of the image
|
||||
// */
|
||||
//lv_coord_t lv_gauge_get_needle_img_pivot_y(lv_obj_t * gauge)
|
||||
//{
|
||||
// LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||
//
|
||||
// lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
//
|
||||
// return ext->needle_img_pivot.y;
|
||||
//}
|
||||
//
|
||||
//
|
||||
///**********************
|
||||
// * STATIC FUNCTIONS
|
||||
// **********************/
|
||||
//
|
||||
///**
|
||||
// * Handle the drawing related tasks of the gauges
|
||||
// * @param gauge pointer to an object
|
||||
// * @param clip_area the object will be drawn only in this area
|
||||
// * @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
// * (return 'true' if yes)
|
||||
// * LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
// * LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
// * @param return an element of `lv_drawer_res_t`
|
||||
// */
|
||||
//static lv_drawer_res_t lv_gauge_drawer(lv_obj_t * gauge, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
//{
|
||||
// /*Return false if the object is not covers the mask_p area*/
|
||||
// if(mode == LV_DRAWER_COVER_CHK) {
|
||||
// return LV_DRAWER_RES_NOT_COVER;
|
||||
// }
|
||||
// /*Draw the object*/
|
||||
// else if(mode == LV_DRAWER_DRAW_MAIN) {
|
||||
// ancestor_drawer(gauge, clip_area, mode);
|
||||
//
|
||||
// lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
// lv_gauge_draw_labels(gauge, clip_area);
|
||||
//
|
||||
// /*Add the strong lines*/
|
||||
// uint16_t line_cnt_tmp = ext->lmeter.line_cnt;
|
||||
// ext->lmeter.line_cnt = ext->label_count; /*Only to labels*/
|
||||
// lv_linemeter_draw_scale(gauge, clip_area, LV_GAUGE_PART_MAJOR);
|
||||
// ext->lmeter.line_cnt = line_cnt_tmp; /*Restore the parameters*/
|
||||
//
|
||||
// lv_gauge_draw_needle(gauge, clip_area);
|
||||
// }
|
||||
// /*Post draw when the children are drawn*/
|
||||
// else if(mode == LV_DRAWER_DRAW_POST) {
|
||||
// ancestor_drawer(gauge, clip_area, mode);
|
||||
// }
|
||||
//
|
||||
// return LV_DRAWER_RES_OK;
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Signal function of the gauge
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @param sign a signal type from lv_signal_t enum
|
||||
// * @param param pointer to a signal specific variable
|
||||
// * @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
|
||||
// */
|
||||
//static lv_res_t lv_gauge_signal(lv_obj_t * gauge, lv_signal_t sign, void * param)
|
||||
//{
|
||||
// lv_res_t res;
|
||||
// if(sign == LV_SIGNAL_GET_STYLE) {
|
||||
// lv_get_style_info_t * info = param;
|
||||
// info->result = lv_gauge_get_style(gauge, info->part);
|
||||
// if(info->result != NULL) return LV_RES_OK;
|
||||
// else return ancestor_signal(gauge, sign, param);
|
||||
// }
|
||||
//
|
||||
// /* Include the ancient signal function */
|
||||
// res = ancestor_signal(gauge, sign, param);
|
||||
// if(res != LV_RES_OK) return res;
|
||||
// if(sign == LV_SIGNAL_GET_TYPE) return _lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||
//
|
||||
// lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
// if(sign == LV_SIGNAL_CLEANUP) {
|
||||
// lv_mem_free(ext->values);
|
||||
// ext->values = NULL;
|
||||
// _lv_obj_reset_style_list_no_refr(gauge, LV_GAUGE_PART_NEEDLE);
|
||||
// _lv_obj_reset_style_list_no_refr(gauge, LV_GAUGE_PART_MAJOR);
|
||||
// }
|
||||
//
|
||||
// return res;
|
||||
//}
|
||||
///**
|
||||
// * Get the style descriptor of a part of the object
|
||||
// * @param page pointer the object
|
||||
// * @param part the part from `lv_gauge_part_t`. (LV_GAUGE_PART_...)
|
||||
// * @return pointer to the style descriptor of the specified part
|
||||
// */
|
||||
//static lv_style_list_t * lv_gauge_get_style(lv_obj_t * gauge, uint8_t part)
|
||||
//{
|
||||
// LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||
//
|
||||
// lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
// lv_style_list_t * style_dsc_p;
|
||||
//
|
||||
// switch(part) {
|
||||
// case LV_GAUGE_PART_MAIN:
|
||||
// style_dsc_p = &gauge->style_list;
|
||||
// break;
|
||||
// case LV_GAUGE_PART_MAJOR:
|
||||
// style_dsc_p = &ext->style_strong;
|
||||
// break;
|
||||
// case LV_GAUGE_PART_NEEDLE:
|
||||
// style_dsc_p = &ext->style_needle;
|
||||
// break;
|
||||
// default:
|
||||
// style_dsc_p = NULL;
|
||||
// }
|
||||
//
|
||||
// return style_dsc_p;
|
||||
//}
|
||||
///**
|
||||
// * Draw the scale on a gauge
|
||||
// * @param gauge pointer to gauge object
|
||||
// * @param mask mask of drawing
|
||||
// */
|
||||
//static void lv_gauge_draw_labels(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
//{
|
||||
// lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
// lv_coord_t scale_width = lv_obj_get_style_scale_width(gauge, LV_GAUGE_PART_MAJOR);
|
||||
// lv_coord_t left = lv_obj_get_style_pad_left(gauge, LV_GAUGE_PART_MAIN);
|
||||
// lv_coord_t right = lv_obj_get_style_pad_right(gauge, LV_GAUGE_PART_MAIN);
|
||||
// lv_coord_t top = lv_obj_get_style_pad_top(gauge, LV_GAUGE_PART_MAIN);
|
||||
// lv_coord_t txt_pad = left;
|
||||
// lv_coord_t r = (lv_obj_get_width(gauge) - left - right) / 2 - scale_width - txt_pad;
|
||||
// lv_coord_t x_ofs = gauge->coords.x1 + r + left + scale_width + txt_pad;
|
||||
// lv_coord_t y_ofs = gauge->coords.y1 + r + top + scale_width + txt_pad;
|
||||
// int16_t scale_angle = lv_linemeter_get_scale_angle(gauge);
|
||||
// uint16_t label_num = ext->label_count;
|
||||
// int16_t angle_ofs = 90 + (360 - scale_angle) / 2 + lv_gauge_get_angle_offset(gauge);
|
||||
// int32_t min = lv_gauge_get_min_value(gauge);
|
||||
// int32_t max = lv_gauge_get_max_value(gauge);
|
||||
//
|
||||
// lv_draw_label_dsc_t label_dsc;
|
||||
// lv_draw_label_dsc_init(&label_dsc);
|
||||
// lv_obj_init_draw_label_dsc(gauge, LV_GAUGE_PART_MAJOR, &label_dsc);
|
||||
//
|
||||
// uint8_t i;
|
||||
// for(i = 0; i < label_num; i++) {
|
||||
// /*Calculate the position a scale label*/
|
||||
// int16_t angle = (i * scale_angle) / (label_num - 1) + angle_ofs;
|
||||
//
|
||||
// lv_coord_t y = (int32_t)((int32_t)_lv_trigo_sin(angle) * r) / LV_TRIGO_SIN_MAX;
|
||||
// y += y_ofs;
|
||||
//
|
||||
// lv_coord_t x = (int32_t)((int32_t)_lv_trigo_sin(angle + 90) * r) / LV_TRIGO_SIN_MAX;
|
||||
// x += x_ofs;
|
||||
//
|
||||
// int32_t scale_act = (int32_t)((int32_t)(max - min) * i) / (label_num - 1);
|
||||
// scale_act += min;
|
||||
// char scale_txt[16];
|
||||
// if(ext->format_cb == NULL)
|
||||
// _lv_utils_num_to_str(scale_act, scale_txt);
|
||||
// else
|
||||
// ext->format_cb(gauge, scale_txt, sizeof(scale_txt), scale_act);
|
||||
//
|
||||
// lv_area_t label_cord;
|
||||
// lv_point_t label_size;
|
||||
// _lv_txt_get_size(&label_size, scale_txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space,
|
||||
// LV_COORD_MAX, LV_TEXT_FLAG_NONE);
|
||||
//
|
||||
// /*Draw the label*/
|
||||
// label_cord.x1 = x - label_size.x / 2;
|
||||
// label_cord.y1 = y - label_size.y / 2;
|
||||
// label_cord.x2 = label_cord.x1 + label_size.x;
|
||||
// label_cord.y2 = label_cord.y1 + label_size.y;
|
||||
//
|
||||
// lv_draw_label(&label_cord, mask, &label_dsc, scale_txt, NULL);
|
||||
// }
|
||||
//}
|
||||
///**
|
||||
// * Draw the needles of a gauge
|
||||
// * @param gauge pointer to gauge object
|
||||
// * @param mask mask of drawing
|
||||
// */
|
||||
//static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * clip_area)
|
||||
//{
|
||||
// lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
//
|
||||
// lv_coord_t pad = lv_obj_get_style_pad_left(gauge, LV_GAUGE_PART_NEEDLE);
|
||||
// lv_coord_t left = lv_obj_get_style_pad_left(gauge, LV_GAUGE_PART_MAIN);
|
||||
// lv_coord_t right = lv_obj_get_style_pad_right(gauge, LV_GAUGE_PART_MAIN);
|
||||
// lv_coord_t top = lv_obj_get_style_pad_top(gauge, LV_GAUGE_PART_MAIN);
|
||||
//
|
||||
// lv_coord_t r = (lv_obj_get_width(gauge) - left - right) / 2 - pad;
|
||||
// lv_coord_t x_ofs = gauge->coords.x1 + r + left + pad;
|
||||
// lv_coord_t y_ofs = gauge->coords.y1 + r + top + pad;
|
||||
// uint16_t angle = lv_linemeter_get_scale_angle(gauge);
|
||||
// int16_t angle_ofs = 90 + (360 - angle) / 2 + lv_gauge_get_angle_offset(gauge);
|
||||
// int16_t min = lv_gauge_get_min_value(gauge);
|
||||
// int16_t max = lv_gauge_get_max_value(gauge);
|
||||
// lv_point_t p_mid;
|
||||
// lv_point_t p_end;
|
||||
// uint8_t i;
|
||||
//
|
||||
// lv_draw_line_dsc_t line_dsc;
|
||||
// lv_draw_img_dsc_t img_dsc;
|
||||
// if(ext->needle_img == NULL) {
|
||||
// lv_draw_line_dsc_init(&line_dsc);
|
||||
// lv_obj_init_draw_line_dsc(gauge, LV_GAUGE_PART_NEEDLE, &line_dsc);
|
||||
// }
|
||||
// else {
|
||||
// lv_draw_img_dsc_init(&img_dsc);
|
||||
// lv_obj_init_draw_img_dsc(gauge, LV_GAUGE_PART_NEEDLE, &img_dsc);
|
||||
// }
|
||||
//
|
||||
// p_mid.x = x_ofs;
|
||||
// p_mid.y = y_ofs;
|
||||
// for(i = 0; i < ext->needle_count; i++) {
|
||||
// /*Calculate the end point of a needle*/
|
||||
// int16_t needle_angle =
|
||||
// (ext->values[i] - min) * angle / (max - min) + angle_ofs;
|
||||
//
|
||||
// /*Draw line*/
|
||||
// if(ext->needle_img == NULL) {
|
||||
// p_end.y = (_lv_trigo_sin(needle_angle) * r) / LV_TRIGO_SIN_MAX + y_ofs;
|
||||
// p_end.x = (_lv_trigo_sin(needle_angle + 90) * r) / LV_TRIGO_SIN_MAX + x_ofs;
|
||||
//
|
||||
// /*Draw the needle with the corresponding color*/
|
||||
// if(ext->needle_colors != NULL) line_dsc.color = ext->needle_colors[i];
|
||||
//
|
||||
// lv_draw_line(&p_mid, &p_end, clip_area, &line_dsc);
|
||||
// }
|
||||
// /*Draw image*/
|
||||
// else {
|
||||
// lv_img_header_t info;
|
||||
// lv_img_decoder_get_info(ext->needle_img, &info);
|
||||
//
|
||||
// lv_area_t a;
|
||||
// a.x1 = gauge->coords.x1 + lv_area_get_width(&gauge->coords) / 2 - ext->needle_img_pivot.x;
|
||||
// a.y1 = gauge->coords.y1 + lv_area_get_height(&gauge->coords) / 2 - ext->needle_img_pivot.y;
|
||||
// a.x2 = a.x1 + info.w - 1;
|
||||
// a.y2 = a.y1 + info.h - 1;
|
||||
// img_dsc.pivot.x = ext->needle_img_pivot.x;
|
||||
// img_dsc.pivot.y = ext->needle_img_pivot.y;
|
||||
//
|
||||
// if(ext->needle_colors != NULL) img_dsc.recolor = ext->needle_colors[i];
|
||||
//
|
||||
// needle_angle = (needle_angle * 10);
|
||||
// if(needle_angle > 3600) needle_angle -= 3600;
|
||||
// img_dsc.angle = needle_angle;
|
||||
// lv_draw_img(&a, clip_area, ext->needle_img, &img_dsc);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// lv_draw_rect_dsc_t mid_dsc;
|
||||
// lv_draw_rect_dsc_init(&mid_dsc);
|
||||
// lv_obj_init_draw_rect_dsc(gauge, LV_GAUGE_PART_NEEDLE, &mid_dsc);
|
||||
// lv_coord_t size = lv_obj_get_style_size(gauge, LV_GAUGE_PART_NEEDLE) / 2;
|
||||
// lv_area_t nm_cord;
|
||||
// nm_cord.x1 = x_ofs - size;
|
||||
// nm_cord.y1 = y_ofs - size;
|
||||
// nm_cord.x2 = x_ofs + size;
|
||||
// nm_cord.y2 = y_ofs + size;
|
||||
// lv_draw_rect(&nm_cord, clip_area, &mid_dsc);
|
||||
//}
|
||||
//
|
||||
//#endif
|
@ -1,264 +0,0 @@
|
||||
///**
|
||||
// * @file lv_gauge.h
|
||||
// *
|
||||
// */
|
||||
//
|
||||
//#ifndef LV_GAUGE_H
|
||||
//#define LV_GAUGE_H
|
||||
//
|
||||
//#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
//#endif
|
||||
//
|
||||
///*********************
|
||||
// * INCLUDES
|
||||
// *********************/
|
||||
//#include "../lv_conf_internal.h"
|
||||
//
|
||||
//#if LV_USE_GAUGE != 0
|
||||
//
|
||||
///*Testing of dependencies*/
|
||||
//#if LV_USE_LINEMETER == 0
|
||||
//#error "lv_gauge: lv_linemeter is required. Enable it in lv_conf.h (LV_USE_LINEMETER 1) "
|
||||
//#endif
|
||||
//
|
||||
//#include "../lv_core/lv_obj.h"
|
||||
//#include "lv_linemeter.h"
|
||||
//#include "lv_label.h"
|
||||
//#include "lv_line.h"
|
||||
//
|
||||
///*********************
|
||||
// * DEFINES
|
||||
// *********************/
|
||||
//
|
||||
///**********************
|
||||
// * TYPEDEFS
|
||||
// **********************/
|
||||
//
|
||||
//typedef void (*lv_gauge_format_cb_t)(lv_obj_t * gauge, char * buf, int bufsize, int32_t value);
|
||||
//
|
||||
///*Data of gauge*/
|
||||
//typedef struct {
|
||||
// lv_linemeter_ext_t lmeter; /*Ext. of ancestor*/
|
||||
// /*New data for this type */
|
||||
// int32_t * values; /*Array of the set values (for needles) */
|
||||
// const lv_color_t * needle_colors; /*Color of the needles (lv_color_t my_colors[needle_num])*/
|
||||
// const void * needle_img;
|
||||
// lv_point_t needle_img_pivot;
|
||||
// uint8_t needle_count; /*Number of needles*/
|
||||
// uint8_t label_count; /*Number of labels on the scale*/
|
||||
// lv_gauge_format_cb_t format_cb;
|
||||
//} lv_gauge_ext_t;
|
||||
//
|
||||
//
|
||||
///**********************
|
||||
// * GLOBAL PROTOTYPES
|
||||
// **********************/
|
||||
//
|
||||
///**
|
||||
// * Create a gauge objects
|
||||
// * @param par pointer to an object, it will be the parent of the new gauge
|
||||
// * @param copy pointer to a gauge object, if not NULL then the new object will be copied from it
|
||||
// * @return pointer to the created gauge
|
||||
// */
|
||||
//lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
//
|
||||
///*=====================
|
||||
// * Setter functions
|
||||
// *====================*/
|
||||
//
|
||||
///**
|
||||
// * Set the number of needles
|
||||
// * @param gauge pointer to gauge object
|
||||
// * @param needle_cnt new count of needles
|
||||
// * @param colors an array of colors for needles (with 'num' elements)
|
||||
// */
|
||||
//void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_color_t colors[]);
|
||||
//
|
||||
///**
|
||||
// * Set the value of a needle
|
||||
// * @param gauge pointer to a gauge
|
||||
// * @param needle_id the id of the needle
|
||||
// * @param value the new value
|
||||
// */
|
||||
//void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int32_t value);
|
||||
//
|
||||
///**
|
||||
// * Set minimum and the maximum values of a gauge
|
||||
// * @param gauge pointer to he gauge object
|
||||
// * @param min minimum value
|
||||
// * @param max maximum value
|
||||
// */
|
||||
//static inline void lv_gauge_set_range(lv_obj_t * gauge, int32_t min, int32_t max)
|
||||
//{
|
||||
// lv_linemeter_set_range(gauge, min, max);
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Set a critical value on the scale. After this value 'line.color' scale lines will be drawn
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @param value the critical value
|
||||
// */
|
||||
//static inline void lv_gauge_set_critical_value(lv_obj_t * gauge, int32_t value)
|
||||
//{
|
||||
// lv_linemeter_set_value(gauge, value);
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Set the scale settings of a gauge
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @param angle angle of the scale (0..360)
|
||||
// * @param line_cnt count of scale lines.
|
||||
// * To get a given "subdivision" lines between labels:
|
||||
// * `line_cnt = (sub_div + 1) * (label_cnt - 1) + 1 `
|
||||
// * @param label_cnt count of scale labels.
|
||||
// */
|
||||
//void lv_gauge_set_scale(lv_obj_t * gauge, uint16_t angle, uint8_t line_cnt, uint8_t label_cnt);
|
||||
//
|
||||
///**
|
||||
// * Set the set an offset for the gauge's angles to rotate it.
|
||||
// * @param gauge pointer to a line meter object
|
||||
// * @param angle angle offset (0..360), rotates clockwise
|
||||
// */
|
||||
//static inline void lv_gauge_set_angle_offset(lv_obj_t * gauge, uint16_t angle)
|
||||
//{
|
||||
// lv_linemeter_set_angle_offset(gauge, angle);
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Set an image to display as needle(s).
|
||||
// * The needle image should be horizontal and pointing to the right (`--->`).
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @param img_src pointer to an `lv_img_dsc_t` variable or a path to an image
|
||||
// * (not an `lv_img` object)
|
||||
// * @param pivot_x the X coordinate of rotation center of the image
|
||||
// * @param pivot_y the Y coordinate of rotation center of the image
|
||||
// */
|
||||
//void lv_gauge_set_needle_img(lv_obj_t * gauge, const void * img, lv_coord_t pivot_x, lv_coord_t pivot_y);
|
||||
//
|
||||
///**
|
||||
// * Assign a function to format gauge values
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @param format_cb pointer to function of lv_gauge_format_cb_t
|
||||
// */
|
||||
//void lv_gauge_set_formatter_cb(lv_obj_t * gauge, lv_gauge_format_cb_t format_cb);
|
||||
//
|
||||
///*=====================
|
||||
// * Getter functions
|
||||
// *====================*/
|
||||
//
|
||||
///**
|
||||
// * Get the value of a needle
|
||||
// * @param gauge pointer to gauge object
|
||||
// * @param needle the id of the needle
|
||||
// * @return the value of the needle [min,max]
|
||||
// */
|
||||
//int32_t lv_gauge_get_value(const lv_obj_t * gauge, uint8_t needle);
|
||||
//
|
||||
///**
|
||||
// * Get the count of needles on a gauge
|
||||
// * @param gauge pointer to gauge
|
||||
// * @return count of needles
|
||||
// */
|
||||
//uint8_t lv_gauge_get_needle_count(const lv_obj_t * gauge);
|
||||
//
|
||||
///**
|
||||
// * Get the minimum value of a gauge
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @return the minimum value of the gauge
|
||||
// */
|
||||
//static inline int32_t lv_gauge_get_min_value(const lv_obj_t * lmeter)
|
||||
//{
|
||||
// return lv_linemeter_get_min_value(lmeter);
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Get the maximum value of a gauge
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @return the maximum value of the gauge
|
||||
// */
|
||||
//static inline int32_t lv_gauge_get_max_value(const lv_obj_t * lmeter)
|
||||
//{
|
||||
// return lv_linemeter_get_max_value(lmeter);
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Get a critical value on the scale.
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @return the critical value
|
||||
// */
|
||||
//static inline int32_t lv_gauge_get_critical_value(const lv_obj_t * gauge)
|
||||
//{
|
||||
// return lv_linemeter_get_value(gauge);
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Set the number of labels (and the thicker lines too)
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @return count of labels
|
||||
// */
|
||||
//uint8_t lv_gauge_get_label_count(const lv_obj_t * gauge);
|
||||
//
|
||||
///**
|
||||
// * Get the scale number of a gauge
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @return number of the scale units
|
||||
// */
|
||||
//static inline uint16_t lv_gauge_get_line_count(const lv_obj_t * gauge)
|
||||
//{
|
||||
// return lv_linemeter_get_line_count(gauge);
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Get the scale angle of a gauge
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @return angle of the scale
|
||||
// */
|
||||
//static inline uint16_t lv_gauge_get_scale_angle(const lv_obj_t * gauge)
|
||||
//{
|
||||
// return lv_linemeter_get_scale_angle(gauge);
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Get the offset for the gauge.
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @return angle offset (0..360)
|
||||
// */
|
||||
//static inline uint16_t lv_gauge_get_angle_offset(lv_obj_t * gauge)
|
||||
//{
|
||||
// return lv_linemeter_get_angle_offset(gauge);
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Get an image to display as needle(s).
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @return pointer to an `lv_img_dsc_t` variable or a path to an image
|
||||
// * (not an `lv_img` object). `NULL` if not used.
|
||||
// */
|
||||
//const void * lv_gauge_get_needle_img(lv_obj_t * gauge);
|
||||
//
|
||||
///**
|
||||
// * Get the X coordinate of the rotation center of the needle image
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @return the X coordinate of rotation center of the image
|
||||
// */
|
||||
//lv_coord_t lv_gauge_get_needle_img_pivot_x(lv_obj_t * gauge);
|
||||
//
|
||||
///**
|
||||
// * Get the Y coordinate of the rotation center of the needle image
|
||||
// * @param gauge pointer to a gauge object
|
||||
// * @return the X coordinate of rotation center of the image
|
||||
// */
|
||||
//lv_coord_t lv_gauge_get_needle_img_pivot_y(lv_obj_t * gauge);
|
||||
//
|
||||
///**********************
|
||||
// * MACROS
|
||||
// **********************/
|
||||
//
|
||||
//#endif /*LV_USE_GAUGE*/
|
||||
//
|
||||
//#ifdef __cplusplus
|
||||
//} /* extern "C" */
|
||||
//#endif
|
||||
//
|
||||
//#endif /*LV_GAUGE_H*/
|
@ -36,7 +36,7 @@
|
||||
**********************/
|
||||
static void lv_img_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_img_destructor(lv_obj_t * obj);
|
||||
static lv_drawer_res_t lv_img_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_img_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_img_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
|
||||
/**********************
|
||||
@ -46,7 +46,7 @@ const lv_obj_class_t lv_img = {
|
||||
.constructor = lv_img_constructor,
|
||||
.destructor = lv_img_destructor,
|
||||
.signal_cb = lv_img_signal,
|
||||
.drawer_cb = lv_img_drawer,
|
||||
.draw_cb = lv_img_draw,
|
||||
.instance_size = sizeof(lv_img_t),
|
||||
.base_class = &lv_obj
|
||||
};
|
||||
@ -506,36 +506,36 @@ static void lv_img_destructor(lv_obj_t * obj)
|
||||
* Handle the drawing related tasks of the images
|
||||
* @param img pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_img_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_img_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
lv_img_t * img = (lv_img_t *)obj;
|
||||
if(mode == LV_DRAWER_MODE_COVER_CHECK) {
|
||||
if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) return LV_DRAWER_RES_MASKED;
|
||||
if(mode == LV_DRAW_MODE_COVER_CHECK) {
|
||||
if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) return LV_DRAW_RES_MASKED;
|
||||
|
||||
if(img->src_type == LV_IMG_SRC_UNKNOWN || img->src_type == LV_IMG_SRC_SYMBOL) return LV_DRAWER_RES_NOT_COVER;
|
||||
if(img->src_type == LV_IMG_SRC_UNKNOWN || img->src_type == LV_IMG_SRC_SYMBOL) return LV_DRAW_RES_NOT_COVER;
|
||||
|
||||
/*Non true color format might have "holes"*/
|
||||
if(img->cf != LV_IMG_CF_TRUE_COLOR && img->cf != LV_IMG_CF_RAW) return LV_DRAWER_RES_NOT_COVER;
|
||||
if(img->cf != LV_IMG_CF_TRUE_COLOR && img->cf != LV_IMG_CF_RAW) return LV_DRAW_RES_NOT_COVER;
|
||||
|
||||
/*With not LV_OPA_COVER images can't cover an area */
|
||||
if(lv_obj_get_style_img_opa(obj, LV_PART_MAIN) != LV_OPA_COVER) return LV_DRAWER_RES_NOT_COVER;
|
||||
if(lv_obj_get_style_img_opa(obj, LV_PART_MAIN) != LV_OPA_COVER) return LV_DRAW_RES_NOT_COVER;
|
||||
|
||||
int32_t angle_final = lv_obj_get_style_transform_angle(obj, LV_PART_MAIN);
|
||||
angle_final += img->angle;
|
||||
|
||||
if(angle_final != 0) return LV_DRAWER_RES_NOT_COVER;
|
||||
if(angle_final != 0) return LV_DRAW_RES_NOT_COVER;
|
||||
|
||||
int32_t zoom_final = lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN);
|
||||
zoom_final = (zoom_final * img->zoom) >> 8;
|
||||
|
||||
if(zoom_final == LV_IMG_ZOOM_NONE) {
|
||||
if(_lv_area_is_in(clip_area, &obj->coords, 0) == false) return LV_DRAWER_RES_NOT_COVER;
|
||||
if(_lv_area_is_in(clip_area, &obj->coords, 0) == false) return LV_DRAW_RES_NOT_COVER;
|
||||
}
|
||||
else {
|
||||
lv_area_t a;
|
||||
@ -545,15 +545,15 @@ static lv_drawer_res_t lv_img_drawer(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
a.x2 += obj->coords.x1;
|
||||
a.y2 += obj->coords.y1;
|
||||
|
||||
if(_lv_area_is_in(clip_area, &a, 0) == false) return LV_DRAWER_RES_NOT_COVER;
|
||||
if(_lv_area_is_in(clip_area, &a, 0) == false) return LV_DRAW_RES_NOT_COVER;
|
||||
}
|
||||
|
||||
#if LV_USE_BLEND_MODES
|
||||
if(lv_obj_get_style_bg_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAWER_RES_NOT_COVER;
|
||||
if(lv_obj_get_style_img_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAWER_RES_NOT_COVER;
|
||||
if(lv_obj_get_style_bg_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAW_RES_NOT_COVER;
|
||||
if(lv_obj_get_style_img_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAW_RES_NOT_COVER;
|
||||
#endif
|
||||
|
||||
return LV_DRAWER_RES_COVER;
|
||||
return LV_DRAW_RES_COVER;
|
||||
}
|
||||
|
||||
int32_t zoom_final = lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN);
|
||||
@ -579,14 +579,14 @@ static lv_drawer_res_t lv_img_drawer(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
lv_area_copy(&ori_coords, &obj->coords);
|
||||
lv_area_copy(&obj->coords, &bg_coords);
|
||||
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
lv_area_copy(&obj->coords, &ori_coords);
|
||||
|
||||
if(mode == LV_DRAWER_MODE_MAIN_DRAW) {
|
||||
if(mode == LV_DRAW_MODE_MAIN_DRAW) {
|
||||
if(img->h == 0 || img->w == 0) return true;
|
||||
|
||||
|
||||
if(zoom_final == 0) return LV_DRAWER_RES_OK;
|
||||
if(zoom_final == 0) return LV_DRAW_RES_OK;
|
||||
|
||||
lv_area_t img_coords;
|
||||
lv_area_copy(&img_coords, &bg_coords);
|
||||
@ -596,7 +596,7 @@ static lv_drawer_res_t lv_img_drawer(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
img_coords.y2 -= lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN);
|
||||
|
||||
if(img->src_type == LV_IMG_SRC_FILE || img->src_type == LV_IMG_SRC_VARIABLE) {
|
||||
LV_LOG_TRACE("lv_img_drawer: start to draw image");
|
||||
LV_LOG_TRACE("lv_img_draw: start to draw image");
|
||||
|
||||
lv_draw_img_dsc_t img_dsc;
|
||||
lv_draw_img_dsc_init(&img_dsc);
|
||||
@ -609,9 +609,9 @@ static lv_drawer_res_t lv_img_drawer(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
img_dsc.antialias = img->antialias;
|
||||
|
||||
lv_coord_t zoomed_src_w = (int32_t)((int32_t)img->w * zoom_final) >> 8;
|
||||
if(zoomed_src_w <= 0) return LV_DRAWER_RES_OK;
|
||||
if(zoomed_src_w <= 0) return LV_DRAW_RES_OK;
|
||||
lv_coord_t zoomed_src_h = (int32_t)((int32_t)img->h * zoom_final) >> 8;
|
||||
if(zoomed_src_h <= 0) return LV_DRAWER_RES_OK;
|
||||
if(zoomed_src_h <= 0) return LV_DRAW_RES_OK;
|
||||
lv_area_t zoomed_coords;
|
||||
lv_area_copy(&zoomed_coords, &img_coords);
|
||||
lv_coord_t img_w = lv_area_get_width(&img_coords);
|
||||
@ -633,7 +633,7 @@ static lv_drawer_res_t lv_img_drawer(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
clip_real.y1 += img_coords.y1;
|
||||
clip_real.y2 += img_coords.y1;
|
||||
|
||||
if(_lv_area_intersect(&clip_real, &clip_real, clip_area) == false) return LV_DRAWER_RES_OK;
|
||||
if(_lv_area_intersect(&clip_real, &clip_real, clip_area) == false) return LV_DRAW_RES_OK;
|
||||
|
||||
lv_area_t coords_tmp;
|
||||
coords_tmp.y1 = zoomed_coords.y1;
|
||||
@ -648,7 +648,7 @@ static lv_drawer_res_t lv_img_drawer(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
}
|
||||
}
|
||||
else if(img->src_type == LV_IMG_SRC_SYMBOL) {
|
||||
LV_LOG_TRACE("lv_img_drawer: start to draw symbol");
|
||||
LV_LOG_TRACE("lv_img_draw: start to draw symbol");
|
||||
lv_draw_label_dsc_t label_dsc;
|
||||
lv_draw_label_dsc_init(&label_dsc);
|
||||
lv_obj_init_draw_label_dsc(obj, LV_PART_MAIN, &label_dsc);
|
||||
@ -657,13 +657,13 @@ static lv_drawer_res_t lv_img_drawer(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
lv_draw_label(&obj->coords, clip_area, &label_dsc, img->src, NULL);
|
||||
}
|
||||
else {
|
||||
/*Trigger the error handler of image drawer*/
|
||||
LV_LOG_WARN("lv_img_drawer: image source type is unknown");
|
||||
/*Trigger the error handler of image draw*/
|
||||
LV_LOG_WARN("lv_img_draw: image source type is unknown");
|
||||
lv_draw_img(&obj->coords, clip_area, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,7 +27,7 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_drawer_res_t lv_imgbtn_drawer(lv_obj_t * imgbtn, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_imgbtn_draw(lv_obj_t * imgbtn, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_imgbtn_signal(lv_obj_t * imgbtn, lv_signal_t sign, void * param);
|
||||
static void refr_img(lv_obj_t * imgbtn);
|
||||
static lv_imgbtn_state_t suggest_state(lv_obj_t * imgbtn, lv_imgbtn_state_t state);
|
||||
@ -37,7 +37,7 @@ lv_imgbtn_state_t get_state(const lv_obj_t * imgbtn);
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_drawer_cb_t ancestor_drawer;
|
||||
static lv_draw_cb_t ancestor_draw;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -72,7 +72,7 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
}
|
||||
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(imgbtn);
|
||||
if(ancestor_drawer == NULL) ancestor_drawer = lv_obj_get_drawer_cb(imgbtn);
|
||||
if(ancestor_draw == NULL) ancestor_draw = lv_obj_get_draw_cb(imgbtn);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
_lv_memset_00((void *)ext->img_src_mid, sizeof(ext->img_src_mid));
|
||||
@ -84,9 +84,9 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
ext->act_cf = LV_IMG_CF_UNKNOWN;
|
||||
|
||||
/*The signal and drawer functions are not copied so set them here*/
|
||||
/*The signal and draw functions are not copied so set them here*/
|
||||
lv_obj_set_signal_cb(imgbtn, lv_imgbtn_signal);
|
||||
lv_obj_set_drawer_cb(imgbtn, lv_imgbtn_drawer);
|
||||
lv_obj_set_draw_cb(imgbtn, lv_imgbtn_draw);
|
||||
|
||||
/*Init the new image button image button*/
|
||||
if(copy == NULL) {
|
||||
@ -255,26 +255,26 @@ const void * lv_imgbtn_get_src_right(lv_obj_t * imgbtn, lv_imgbtn_state_t state)
|
||||
* Handle the drawing related tasks of the image buttons
|
||||
* @param imgbtn pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_imgbtn_drawer(lv_obj_t * imgbtn, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_imgbtn_draw(lv_obj_t * imgbtn, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DRAWER_COVER_CHK) {
|
||||
if(mode == LV_DRAW_COVER_CHK) {
|
||||
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
|
||||
lv_drawer_res_t cover = LV_DRAWER_RES_NOT_COVER;
|
||||
lv_draw_res_t cover = LV_DRAW_RES_NOT_COVER;
|
||||
if(ext->act_cf == LV_IMG_CF_TRUE_COLOR || ext->act_cf == LV_IMG_CF_RAW) {
|
||||
cover = _lv_area_is_in(clip_area, &imgbtn->coords, 0) ? LV_DRAWER_RES_COVER : LV_DRAWER_RES_NOT_COVER;
|
||||
cover = _lv_area_is_in(clip_area, &imgbtn->coords, 0) ? LV_DRAW_RES_COVER : LV_DRAW_RES_NOT_COVER;
|
||||
}
|
||||
|
||||
return cover;
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DRAWER_DRAW_MAIN) {
|
||||
else if(mode == LV_DRAW_DRAW_MAIN) {
|
||||
lv_area_t img_coords;
|
||||
|
||||
lv_obj_get_coords(imgbtn, &img_coords);
|
||||
@ -331,8 +331,8 @@ static lv_drawer_res_t lv_imgbtn_drawer(lv_obj_t * imgbtn, const lv_area_t * cli
|
||||
#if LV_IMGBTN_TILED
|
||||
const void * src = ext->img_src_left[state];
|
||||
if(lv_img_src_get_type(src) == LV_IMG_SRC_SYMBOL) {
|
||||
LV_LOG_WARN("lv_imgbtn_drawer: SYMBOLS are not supported in tiled mode")
|
||||
return LV_DRAWER_RES_OK;
|
||||
LV_LOG_WARN("lv_imgbtn_draw: SYMBOLS are not supported in tiled mode")
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
lv_coord_t w = lv_obj_get_style_transform_width(imgbtn, LV_OBJ_PART_MAIN);
|
||||
@ -406,7 +406,7 @@ static lv_drawer_res_t lv_imgbtn_drawer(lv_obj_t * imgbtn, const lv_area_t * cli
|
||||
}
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DRAWER_DRAW_POST) {
|
||||
else if(mode == LV_DRAW_DRAW_POST) {
|
||||
if(lv_obj_get_style_clip_corner(imgbtn, LV_OBJ_PART_MAIN)) {
|
||||
lv_draw_mask_radius_param_t * param = lv_draw_mask_remove_custom(imgbtn + 8);
|
||||
_lv_mem_buf_release(param);
|
||||
@ -433,7 +433,7 @@ static lv_drawer_res_t lv_imgbtn_drawer(lv_obj_t * imgbtn, const lv_area_t * cli
|
||||
}
|
||||
}
|
||||
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@
|
||||
static void lv_label_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_label_destructor(lv_obj_t * obj);
|
||||
static lv_res_t lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param);
|
||||
static lv_drawer_res_t lv_label_drawer(lv_obj_t * label, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_label_draw(lv_obj_t * label, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static void lv_label_revert_dots(lv_obj_t * label);
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
@ -57,7 +57,7 @@ const lv_obj_class_t lv_label = {
|
||||
.constructor = lv_label_constructor,
|
||||
.destructor = lv_label_destructor,
|
||||
.signal_cb = lv_label_signal,
|
||||
.drawer_cb = lv_label_drawer,
|
||||
.draw_cb = lv_label_draw,
|
||||
.instance_size = sizeof(lv_label_t),
|
||||
.base_class = &lv_obj
|
||||
};
|
||||
@ -1092,20 +1092,20 @@ static void lv_label_destructor(lv_obj_t * obj)
|
||||
* Handle the drawing related tasks of the labels
|
||||
* @param label pointer to a label object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_label_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_label_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
/* A label never covers an area */
|
||||
if(mode == LV_DRAWER_MODE_COVER_CHECK)
|
||||
return LV_DRAWER_RES_NOT_COVER;
|
||||
else if(mode == LV_DRAWER_MODE_MAIN_DRAW) {
|
||||
if(mode == LV_DRAW_MODE_COVER_CHECK)
|
||||
return LV_DRAW_RES_NOT_COVER;
|
||||
else if(mode == LV_DRAW_MODE_MAIN_DRAW) {
|
||||
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
|
||||
lv_label_t * label = (lv_label_t *)obj;
|
||||
lv_area_t txt_coords;
|
||||
@ -1113,7 +1113,7 @@ static lv_drawer_res_t lv_label_drawer(lv_obj_t * obj, const lv_area_t * clip_ar
|
||||
|
||||
lv_area_t txt_clip;
|
||||
bool is_common = _lv_area_intersect(&txt_clip, clip_area, &txt_coords);
|
||||
if(!is_common) return LV_DRAWER_RES_OK;
|
||||
if(!is_common) return LV_DRAW_RES_OK;
|
||||
|
||||
lv_text_align_t align = lv_obj_get_style_text_align(obj, LV_PART_MAIN);
|
||||
lv_text_flag_t flag = LV_TEXT_FLAG_NONE;
|
||||
@ -1184,11 +1184,11 @@ static lv_drawer_res_t lv_label_drawer(lv_obj_t * obj, const lv_area_t * clip_ar
|
||||
lv_draw_label(&txt_coords, &txt_clip, &label_draw_dsc, label->text, hint);
|
||||
}
|
||||
}
|
||||
} else if(mode == LV_DRAWER_MODE_POST_DRAW) {
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
} else if(mode == LV_DRAW_MODE_POST_DRAW) {
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@
|
||||
**********************/
|
||||
static void lv_line_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_line_destructor(lv_obj_t * obj);
|
||||
static lv_drawer_res_t lv_line_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_line_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_line_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
|
||||
/**********************
|
||||
@ -41,7 +41,7 @@ const lv_obj_class_t lv_line = {
|
||||
.constructor = lv_line_constructor,
|
||||
.destructor = lv_line_destructor,
|
||||
.signal_cb = lv_line_signal,
|
||||
.drawer_cb = lv_line_drawer,
|
||||
.draw_cb = lv_line_draw,
|
||||
.instance_size = sizeof(lv_line_t),
|
||||
.base_class = &lv_obj
|
||||
};
|
||||
@ -166,19 +166,19 @@ static void lv_line_destructor(lv_obj_t * obj)
|
||||
* Handle the drawing related tasks of the lines
|
||||
* @param line pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_line_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_line_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
/*A line never covers an area*/
|
||||
if(mode == LV_DRAWER_MODE_COVER_CHECK)
|
||||
return LV_DRAWER_RES_NOT_COVER;
|
||||
else if(mode == LV_DRAWER_MODE_MAIN_DRAW) {
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
if(mode == LV_DRAW_MODE_COVER_CHECK)
|
||||
return LV_DRAW_RES_NOT_COVER;
|
||||
else if(mode == LV_DRAW_MODE_MAIN_DRAW) {
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
lv_line_t * line = (lv_line_t *) obj;
|
||||
|
||||
if(line->point_num == 0 || line->point_array == NULL) return false;
|
||||
@ -213,10 +213,10 @@ static lv_drawer_res_t lv_line_drawer(lv_obj_t * obj, const lv_area_t * clip_are
|
||||
lv_draw_line(&p1, &p2, clip_area, &line_dsc);
|
||||
line_dsc.round_start = 0; /*Draw the rounding only on the end points after the first line*/
|
||||
}
|
||||
} else if (mode == LV_DRAWER_MODE_POST_DRAW) {
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
} else if (mode == LV_DRAW_MODE_POST_DRAW) {
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,7 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_linemeter.h"
|
||||
#include <lvgl/src/lv_widgets/lv_meter.h>
|
||||
#if LV_USE_METER != 0
|
||||
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
@ -30,7 +30,7 @@
|
||||
**********************/
|
||||
static void lv_meter_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_meter_destructor(lv_obj_t * obj);
|
||||
static lv_drawer_res_t lv_meter_drawer(lv_obj_t * lmeter, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_meter_draw(lv_obj_t * lmeter, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_meter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * param);
|
||||
static void draw_arcs(lv_obj_t * obj, const lv_area_t * clip_area, const lv_area_t * scale_area);
|
||||
static void draw_lines_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, const lv_area_t * scale_area);
|
||||
@ -43,7 +43,7 @@ const lv_obj_class_t lv_meter = {
|
||||
.constructor = lv_meter_constructor,
|
||||
.destructor = lv_meter_destructor,
|
||||
.signal_cb = lv_meter_signal,
|
||||
.drawer_cb = lv_meter_drawer,
|
||||
.draw_cb = lv_meter_draw,
|
||||
.instance_size = sizeof(lv_meter_t),
|
||||
.base_class = &lv_obj
|
||||
};
|
||||
@ -356,21 +356,21 @@ static void lv_meter_destructor(lv_obj_t * obj)
|
||||
* Handle the drawing related tasks of the line meters
|
||||
* @param lmeter pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_meter_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_meter_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DRAWER_MODE_COVER_CHECK) {
|
||||
return lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
if(mode == LV_DRAW_MODE_COVER_CHECK) {
|
||||
return lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DRAWER_MODE_MAIN_DRAW) {
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
else if(mode == LV_DRAW_MODE_MAIN_DRAW) {
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
|
||||
lv_area_t scale_area;
|
||||
lv_obj_get_coords(obj, &scale_area);
|
||||
@ -384,11 +384,11 @@ static lv_drawer_res_t lv_meter_drawer(lv_obj_t * obj, const lv_area_t * clip_ar
|
||||
draw_needles(obj, clip_area, &scale_area);
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DRAWER_MODE_POST_DRAW) {
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
else if(mode == LV_DRAW_MODE_POST_DRAW) {
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @file lv_linemeter.h
|
||||
* @file lv_meter.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_LINEMETER_H
|
||||
#define LV_LINEMETER_H
|
||||
#ifndef LV_METER_H
|
||||
#define LV_METER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
@ -1,369 +0,0 @@
|
||||
/**
|
||||
* @file lv_objmask.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_objmask.h"
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
|
||||
#if defined(LV_USE_OBJMASK) && LV_USE_OBJMASK != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_OBJX_NAME "lv_objmask"
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_drawer_res_t lv_objmask_drawer(lv_obj_t * objmask, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_res_t lv_objmask_signal(lv_obj_t * objmask, lv_signal_t sign, void * param);
|
||||
static uint16_t get_param_size(lv_draw_mask_type_t type);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_drawer_cb_t ancestor_drawer;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a object mask object
|
||||
* @param par pointer to an object, it will be the parent of the new object mask
|
||||
* @param copy pointer to a object mask object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created object mask
|
||||
*/
|
||||
lv_obj_t * lv_objmask_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
{
|
||||
LV_LOG_TRACE("object mask create started");
|
||||
|
||||
/*Create the ancestor of object mask*/
|
||||
lv_obj_t * objmask = lv_obj_create(par, copy);
|
||||
LV_ASSERT_MEM(objmask);
|
||||
if(objmask == NULL) return NULL;
|
||||
|
||||
/*Allocate the object mask type specific extended data*/
|
||||
lv_objmask_ext_t * ext = lv_obj_allocate_ext_attr(objmask, sizeof(lv_objmask_ext_t));
|
||||
LV_ASSERT_MEM(ext);
|
||||
if(ext == NULL) {
|
||||
lv_obj_del(objmask);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(objmask);
|
||||
if(ancestor_drawer == NULL) ancestor_drawer = lv_obj_get_drawer_cb(objmask);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
_lv_ll_init(&ext->mask_ll, sizeof(lv_objmask_mask_t));
|
||||
|
||||
/*The signal and drawer functions are not copied so set them here*/
|
||||
lv_obj_set_signal_cb(objmask, lv_objmask_signal);
|
||||
lv_obj_set_drawer_cb(objmask, lv_objmask_drawer);
|
||||
|
||||
/*Init the new object mask object mask*/
|
||||
if(copy == NULL) {
|
||||
lv_theme_apply(objmask, LV_THEME_OBJMASK);
|
||||
|
||||
}
|
||||
/*TODO: Copy an existing object mask*/
|
||||
else {
|
||||
/* lv_objmask_ext_t * copy_ext = lv_obj_get_ext_attr(copy); */
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
_lv_obj_refresh_style(objmask, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("object mask created");
|
||||
|
||||
return objmask;
|
||||
}
|
||||
|
||||
/*======================
|
||||
* Add/remove functions
|
||||
*=====================*/
|
||||
|
||||
/**
|
||||
* Add a mask
|
||||
* @param objmask pointer to an Object mask object
|
||||
* @param param an initialized mask parameter
|
||||
* @return pointer to the added mask
|
||||
*/
|
||||
lv_objmask_mask_t * lv_objmask_add_mask(lv_obj_t * objmask, void * param)
|
||||
{
|
||||
LV_ASSERT_OBJ(objmask, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(param);
|
||||
|
||||
lv_objmask_ext_t * ext = lv_obj_get_ext_attr(objmask);
|
||||
|
||||
lv_draw_mask_common_dsc_t * dsc = param;
|
||||
uint16_t param_size = get_param_size(dsc->type);
|
||||
|
||||
lv_objmask_mask_t * m = _lv_ll_ins_head(&ext->mask_ll);
|
||||
LV_ASSERT_MEM(m);
|
||||
if(m == NULL) return NULL;
|
||||
m->param = lv_mem_alloc(param_size);
|
||||
LV_ASSERT_MEM(m->param);
|
||||
if(m->param == NULL) return NULL;
|
||||
|
||||
_lv_memcpy(m->param, param, param_size);
|
||||
|
||||
lv_obj_invalidate(objmask);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an already created mask
|
||||
* @param objmask pointer to an Object mask object
|
||||
* @param mask pointer to created mask (returned by `lv_objmask_add_mask`)
|
||||
* @param param an initialized mask parameter (initialized by `lv_draw_mask_line/angle/.../_init`)
|
||||
*/
|
||||
void lv_objmask_update_mask(lv_obj_t * objmask, lv_objmask_mask_t * mask, void * param)
|
||||
{
|
||||
LV_ASSERT_OBJ(objmask, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(mask);
|
||||
LV_ASSERT_NULL(param);
|
||||
lv_draw_mask_common_dsc_t * dsc = param;
|
||||
|
||||
memcpy(mask->param, param, get_param_size(dsc->type));
|
||||
|
||||
lv_obj_invalidate(objmask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a mask
|
||||
* @param objmask pointer to an Object mask object
|
||||
* @param mask pointer to created mask (returned by `lv_objmask_add_mask`)
|
||||
* If `NULL` passed all masks will be deleted.
|
||||
*/
|
||||
void lv_objmask_remove_mask(lv_obj_t * objmask, lv_objmask_mask_t * mask)
|
||||
{
|
||||
LV_ASSERT_OBJ(objmask, LV_OBJX_NAME);
|
||||
|
||||
lv_objmask_ext_t * ext = lv_obj_get_ext_attr(objmask);
|
||||
|
||||
/*Remove all masks*/
|
||||
if(mask == NULL) {
|
||||
lv_objmask_mask_t * m;
|
||||
_LV_LL_READ(&ext->mask_ll, m) {
|
||||
lv_mem_free(m->param);
|
||||
}
|
||||
|
||||
_lv_ll_clear(&ext->mask_ll);
|
||||
}
|
||||
/*Remove only the specified mask*/
|
||||
else {
|
||||
lv_mem_free(mask->param);
|
||||
_lv_ll_remove(&ext->mask_ll, mask);
|
||||
lv_mem_free(mask);
|
||||
}
|
||||
|
||||
lv_obj_invalidate(objmask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the object masks
|
||||
* @param objmask pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_objmask_drawer(lv_obj_t * objmask, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DRAWER_COVER_CHK) {
|
||||
lv_objmask_ext_t * ext = lv_obj_get_ext_attr(objmask);
|
||||
if(_lv_ll_get_len(&ext->mask_ll) > 0) return LV_DRAWER_RES_MASKED;
|
||||
else return ancestor_drawer(objmask, clip_area, mode);
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DRAWER_DRAW_MAIN) {
|
||||
ancestor_drawer(objmask, clip_area, mode);
|
||||
|
||||
lv_objmask_ext_t * ext = lv_obj_get_ext_attr(objmask);
|
||||
|
||||
lv_coord_t xofs = objmask->coords.x1;
|
||||
lv_coord_t yofs = objmask->coords.y1;
|
||||
|
||||
lv_objmask_mask_t * m;
|
||||
|
||||
_LV_LL_READ(&ext->mask_ll, m) {
|
||||
lv_draw_mask_common_dsc_t * dsc = m->param;
|
||||
|
||||
if(dsc->type == LV_DRAW_MASK_TYPE_LINE) {
|
||||
lv_draw_mask_line_param_t * p_ori = m->param;
|
||||
lv_draw_mask_line_param_t * p_new = _lv_mem_buf_get(sizeof(lv_draw_mask_line_param_t));
|
||||
|
||||
lv_draw_mask_line_points_init(p_new, p_ori->cfg.p1.x + xofs, p_ori->cfg.p1.y + yofs,
|
||||
p_ori->cfg.p2.x + xofs, p_ori->cfg.p2.y + yofs,
|
||||
p_ori->cfg.side);
|
||||
lv_draw_mask_add(p_new, m->param);
|
||||
}
|
||||
else if(dsc->type == LV_DRAW_MASK_TYPE_ANGLE) {
|
||||
lv_draw_mask_angle_param_t * p_ori = m->param;
|
||||
lv_draw_mask_angle_param_t * p_new = _lv_mem_buf_get(sizeof(lv_draw_mask_angle_param_t));
|
||||
|
||||
lv_draw_mask_angle_init(p_new, p_ori->cfg.vertex_p.x + xofs, p_ori->cfg.vertex_p.y + yofs,
|
||||
p_ori->cfg.start_angle, p_ori->cfg.end_angle);
|
||||
lv_draw_mask_add(p_new, m->param);
|
||||
}
|
||||
else if(dsc->type == LV_DRAW_MASK_TYPE_RADIUS) {
|
||||
lv_draw_mask_radius_param_t * p_ori = m->param;
|
||||
lv_draw_mask_radius_param_t * p_new = _lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t));
|
||||
|
||||
lv_area_t rect;
|
||||
rect.x1 = p_ori->cfg.rect.x1 + xofs;
|
||||
rect.y1 = p_ori->cfg.rect.y1 + yofs;
|
||||
rect.x2 = p_ori->cfg.rect.x2 + xofs;
|
||||
rect.y2 = p_ori->cfg.rect.y2 + yofs;
|
||||
|
||||
lv_draw_mask_radius_init(p_new, &rect, p_ori->cfg.radius, p_ori->cfg.outer);
|
||||
lv_draw_mask_add(p_new, m->param);
|
||||
}
|
||||
else if(dsc->type == LV_DRAW_MASK_TYPE_FADE) {
|
||||
lv_draw_mask_fade_param_t * p_ori = m->param;
|
||||
lv_draw_mask_fade_param_t * p_new = _lv_mem_buf_get(sizeof(lv_draw_mask_fade_param_t));
|
||||
|
||||
lv_area_t rect;
|
||||
rect.x1 = p_ori->cfg.coords.x1 + xofs;
|
||||
rect.y1 = p_ori->cfg.coords.y1 + yofs;
|
||||
rect.x2 = p_ori->cfg.coords.x2 + xofs;
|
||||
rect.y2 = p_ori->cfg.coords.y2 + yofs;
|
||||
|
||||
lv_draw_mask_fade_init(p_new, &rect, p_ori->cfg.opa_top, p_ori->cfg.y_top + yofs,
|
||||
p_ori->cfg.opa_bottom, p_ori->cfg.y_bottom + yofs);
|
||||
lv_draw_mask_add(p_new, m->param);
|
||||
}
|
||||
else if(dsc->type == LV_DRAW_MASK_TYPE_MAP) {
|
||||
lv_draw_mask_map_param_t * p_ori = m->param;
|
||||
lv_draw_mask_map_param_t * p_new = _lv_mem_buf_get(sizeof(lv_draw_mask_map_param_t));
|
||||
|
||||
lv_area_t rect;
|
||||
rect.x1 = p_ori->cfg.coords.x1 + xofs;
|
||||
rect.y1 = p_ori->cfg.coords.y1 + yofs;
|
||||
rect.x2 = p_ori->cfg.coords.x2 + xofs;
|
||||
rect.y2 = p_ori->cfg.coords.y2 + yofs;
|
||||
|
||||
lv_draw_mask_map_init(p_new, &rect, p_ori->cfg.map);
|
||||
lv_draw_mask_add(p_new, m->param);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DRAWER_DRAW_POST) {
|
||||
lv_objmask_ext_t * ext = lv_obj_get_ext_attr(objmask);
|
||||
lv_objmask_mask_t * m;
|
||||
|
||||
_LV_LL_READ(&ext->mask_ll, m) {
|
||||
void * param;
|
||||
param = lv_draw_mask_remove_custom(m->param);
|
||||
_lv_mem_buf_release(param);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return LV_DRAWER_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the object mask
|
||||
* @param objmask pointer to a object mask object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
|
||||
*/
|
||||
static lv_res_t lv_objmask_signal(lv_obj_t * objmask, lv_signal_t sign, void * param)
|
||||
{
|
||||
lv_res_t res;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
res = ancestor_signal(objmask, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
if(sign == LV_SIGNAL_GET_TYPE) return _lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
lv_objmask_ext_t * ext = lv_obj_get_ext_attr(objmask);
|
||||
lv_objmask_mask_t * i;
|
||||
_LV_LL_READ(&ext->mask_ll, i) {
|
||||
if(i->param) {
|
||||
lv_mem_free(i->param);
|
||||
i->param = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
_lv_ll_clear(&ext->mask_ll);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static uint16_t get_param_size(lv_draw_mask_type_t type)
|
||||
{
|
||||
uint16_t param_size;
|
||||
switch(type) {
|
||||
case LV_DRAW_MASK_TYPE_LINE:
|
||||
param_size = sizeof(lv_draw_mask_line_param_t);
|
||||
break;
|
||||
case LV_DRAW_MASK_TYPE_ANGLE:
|
||||
param_size = sizeof(lv_draw_mask_angle_param_t);
|
||||
break;
|
||||
case LV_DRAW_MASK_TYPE_RADIUS:
|
||||
param_size = sizeof(lv_draw_mask_radius_param_t);
|
||||
break;
|
||||
case LV_DRAW_MASK_TYPE_FADE:
|
||||
param_size = sizeof(lv_draw_mask_fade_param_t);
|
||||
break;
|
||||
case LV_DRAW_MASK_TYPE_MAP:
|
||||
param_size = sizeof(lv_draw_mask_map_param_t);
|
||||
break;
|
||||
default:
|
||||
param_size = 0;
|
||||
}
|
||||
|
||||
return param_size;
|
||||
}
|
||||
|
||||
#else /* Enable this file at the top */
|
||||
|
||||
#endif
|
@ -1,109 +0,0 @@
|
||||
/**
|
||||
* @file lv_objmask.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OBJMASK_H
|
||||
#define LV_OBJMASK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
|
||||
#if LV_USE_OBJMASK != 0
|
||||
|
||||
#include "../lv_core/lv_obj.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
void * param;
|
||||
} lv_objmask_mask_t;
|
||||
|
||||
/*Data of object mask*/
|
||||
typedef struct {
|
||||
/*New data for this type */
|
||||
lv_ll_t mask_ll; /*Store the created masks*/
|
||||
|
||||
} lv_objmask_ext_t;
|
||||
|
||||
/*Parts of the object*/
|
||||
enum {
|
||||
LV_OBJMASK_PART_MAIN,
|
||||
};
|
||||
typedef uint8_t lv_objmask_part_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a object mask objects
|
||||
* @param par pointer to an object, it will be the parent of the new object mask
|
||||
* @param copy pointer to a object mask object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created object mask
|
||||
*/
|
||||
lv_obj_t * lv_objmask_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
|
||||
/*======================
|
||||
* Add/remove functions
|
||||
*=====================*/
|
||||
|
||||
/**
|
||||
* Add a mask
|
||||
* @param objmask pointer to an Object mask object
|
||||
* @param param an initialized mask parameter
|
||||
* @return pointer to the added mask
|
||||
*/
|
||||
lv_objmask_mask_t * lv_objmask_add_mask(lv_obj_t * objmask, void * param);
|
||||
|
||||
/**
|
||||
* Update an already created mask
|
||||
* @param objmask pointer to an Object mask object
|
||||
* @param mask pointer to created mask (returned by `lv_objmask_add_mask`)
|
||||
* @param param an initialized mask parameter (initialized by `lv_draw_mask_line/angle/.../_init`)
|
||||
*/
|
||||
void lv_objmask_update_mask(lv_obj_t * objmask, lv_objmask_mask_t * mask, void * param);
|
||||
|
||||
/**
|
||||
* Remove a mask
|
||||
* @param objmask pointer to an Object mask object
|
||||
* @param mask pointer to created mask (returned by `lv_objmask_add_mask`)
|
||||
* If `NULL` passed all masks will be deleted.
|
||||
*/
|
||||
void lv_objmask_remove_mask(lv_obj_t * objmask, lv_objmask_mask_t * mask);
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_OBJMASK*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_OBJMASK_H*/
|
@ -32,14 +32,14 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_drawer_res_t lv_templ_drawer(lv_obj_t * templ, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_templ_draw(lv_obj_t * templ, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_templ_signal(lv_obj_t * templ, lv_signal_t sign, void * param);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_drawer_cb_t ancestor_drawer;
|
||||
static lv_draw_cb_t ancestor_draw;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -74,14 +74,14 @@ lv_obj_t * lv_templ_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
}
|
||||
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_templ);
|
||||
if(ancestor_drawer == NULL) ancestor_drawer = lv_obj_get_drawer_cb(new_templ);
|
||||
if(ancestor_draw == NULL) ancestor_draw = lv_obj_get_draw_cb(new_templ);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
ext->xyz = 0;
|
||||
|
||||
/*The signal and drawer functions are not copied so set them here*/
|
||||
/*The signal and draw functions are not copied so set them here*/
|
||||
lv_obj_set_signal_cb(new_templ, lv_templ_signal);
|
||||
lv_obj_set_drawer_cb(new_templ, lv_templ_drawer);
|
||||
lv_obj_set_draw_cb(new_templ, lv_templ_draw);
|
||||
|
||||
/*Init the new template template*/
|
||||
if(copy == NULL) {
|
||||
@ -185,27 +185,27 @@ lv_style_t * lv_templ_get_style(const lv_obj_t * templ, lv_templ_style_t type)
|
||||
* Handle the drawing related tasks of the templates
|
||||
* @param templ pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_templ_drawer(lv_obj_t * templ, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_templ_draw(lv_obj_t * templ, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DRAWER_COVER_CHK) {
|
||||
return LV_DRAWER_RES_NOT_COVER;
|
||||
if(mode == LV_DRAW_COVER_CHK) {
|
||||
return LV_DRAW_RES_NOT_COVER;
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DRAWER_DRAW_MAIN) {
|
||||
else if(mode == LV_DRAW_DRAW_MAIN) {
|
||||
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DRAWER_DRAW_POST) {
|
||||
else if(mode == LV_DRAW_DRAW_POST) {
|
||||
}
|
||||
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,8 +35,8 @@
|
||||
**********************/
|
||||
static void lv_roller_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_roller_destructor(lv_obj_t * obj);
|
||||
static lv_drawer_res_t lv_roller_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_drawer_res_t lv_roller_label_drawer(lv_obj_t * label, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_roller_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_draw_res_t lv_roller_label_draw(lv_obj_t * label, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static void lv_roller_label_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_roller_label_destructor(lv_obj_t * obj);
|
||||
static lv_res_t lv_roller_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
@ -57,7 +57,7 @@ const lv_obj_class_t lv_roller = {
|
||||
.constructor = lv_roller_constructor,
|
||||
.destructor = lv_roller_destructor,
|
||||
.signal_cb = lv_roller_signal,
|
||||
.drawer_cb = lv_roller_drawer,
|
||||
.draw_cb = lv_roller_draw,
|
||||
.instance_size = sizeof(lv_roller_t),
|
||||
.base_class = &lv_obj
|
||||
};
|
||||
@ -66,7 +66,7 @@ const lv_obj_class_t lv_roller_label = {
|
||||
.constructor = lv_roller_label_constructor,
|
||||
.destructor = lv_roller_label_destructor,
|
||||
.signal_cb = lv_roller_label_signal,
|
||||
.drawer_cb = lv_roller_label_drawer,
|
||||
.draw_cb = lv_roller_label_draw,
|
||||
.instance_size = sizeof(lv_label_t),
|
||||
.base_class = &lv_label
|
||||
};;
|
||||
@ -356,20 +356,20 @@ static void lv_roller_label_destructor(lv_obj_t * obj)
|
||||
* Handle the drawing related tasks of the rollers
|
||||
* @param roller pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after all children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after all children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_roller_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_roller_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DRAWER_MODE_COVER_CHECK) {
|
||||
return lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
if(mode == LV_DRAW_MODE_COVER_CHECK) {
|
||||
return lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DRAWER_MODE_MAIN_DRAW) {
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
else if(mode == LV_DRAW_MODE_MAIN_DRAW) {
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
|
||||
/*Draw the selected rectangle*/
|
||||
const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN);
|
||||
@ -390,7 +390,7 @@ static lv_drawer_res_t lv_roller_drawer(lv_obj_t * obj, const lv_area_t * clip_a
|
||||
lv_draw_rect(&rect_area, clip_area, &sel_dsc);
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DRAWER_MODE_POST_DRAW) {
|
||||
else if(mode == LV_DRAW_MODE_POST_DRAW) {
|
||||
lv_draw_label_dsc_t label_dsc;
|
||||
lv_draw_label_dsc_init(&label_dsc);
|
||||
lv_obj_init_draw_label_dsc(obj, LV_PART_HIGHLIGHT, &label_dsc);
|
||||
@ -450,10 +450,10 @@ static lv_drawer_res_t lv_roller_drawer(lv_obj_t * obj, const lv_area_t * clip_a
|
||||
lv_draw_label(&label_sel_area, &mask_sel, &label_dsc, lv_label_get_text(label), NULL);
|
||||
}
|
||||
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -461,19 +461,19 @@ static lv_drawer_res_t lv_roller_drawer(lv_obj_t * obj, const lv_area_t * clip_a
|
||||
* Handle the drawing related tasks of the roller's label
|
||||
* @param roller pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after all children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after all children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_roller_label_drawer(lv_obj_t * label, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_roller_label_draw(lv_obj_t * label, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DRAWER_MODE_COVER_CHECK) {
|
||||
return lv_label.drawer_cb(label, clip_area, mode);
|
||||
if(mode == LV_DRAW_MODE_COVER_CHECK) {
|
||||
return lv_label.draw_cb(label, clip_area, mode);
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DRAWER_MODE_MAIN_DRAW) {
|
||||
else if(mode == LV_DRAW_MODE_MAIN_DRAW) {
|
||||
/* Split the drawing of the label into an upper (above the selected area)
|
||||
* and a lower (below the selected area)*/
|
||||
lv_obj_t * roller = lv_obj_get_parent(label);
|
||||
@ -497,7 +497,7 @@ static lv_drawer_res_t lv_roller_label_drawer(lv_obj_t * label, const lv_area_t
|
||||
clip2.x2 = label->coords.x2;
|
||||
clip2.y2 = rect_area.y1;
|
||||
if(_lv_area_intersect(&clip2, clip_area, &clip2)) {
|
||||
lv_label.drawer_cb(label, &clip2, mode);
|
||||
lv_label.draw_cb(label, &clip2, mode);
|
||||
}
|
||||
|
||||
clip2.x1 = label->coords.x1;
|
||||
@ -505,11 +505,11 @@ static lv_drawer_res_t lv_roller_label_drawer(lv_obj_t * label, const lv_area_t
|
||||
clip2.x2 = label->coords.x2;
|
||||
clip2.y2 = label->coords.y2;
|
||||
if(_lv_area_intersect(&clip2, clip_area, &clip2)) {
|
||||
lv_label.drawer_cb(label, &clip2, mode);
|
||||
lv_label.draw_cb(label, &clip2, mode);
|
||||
}
|
||||
}
|
||||
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@
|
||||
**********************/
|
||||
static void lv_slider_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_slider_destructor(lv_obj_t * obj);
|
||||
static lv_drawer_res_t lv_slider_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_slider_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
static void position_knob(lv_obj_t * obj, lv_area_t * knob_area, lv_coord_t knob_size, bool hor);
|
||||
static void draw_knob(lv_obj_t * obj, const lv_area_t * clip_area);
|
||||
@ -47,7 +47,7 @@ const lv_obj_class_t lv_slider = {
|
||||
.constructor = lv_slider_constructor,
|
||||
.destructor = lv_slider_destructor,
|
||||
.signal_cb = lv_slider_signal,
|
||||
.drawer_cb = lv_slider_drawer,
|
||||
.draw_cb = lv_slider_draw,
|
||||
.instance_size = sizeof(lv_slider_t),
|
||||
.base_class = &lv_bar
|
||||
};
|
||||
@ -135,33 +135,33 @@ static void lv_slider_destructor(lv_obj_t * obj)
|
||||
* Handle the drawing related tasks of the sliders
|
||||
* @param slider pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_slider_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_slider_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DRAWER_MODE_COVER_CHECK) {
|
||||
return LV_DRAWER_RES_NOT_COVER;
|
||||
if(mode == LV_DRAW_MODE_COVER_CHECK) {
|
||||
return LV_DRAW_RES_NOT_COVER;
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DRAWER_MODE_MAIN_DRAW) {
|
||||
/* The ancestor drawer function will draw the background and the indicator.
|
||||
else if(mode == LV_DRAW_MODE_MAIN_DRAW) {
|
||||
/* The ancestor draw function will draw the background and the indicator.
|
||||
* It also sets slider->bar.indic_area*/
|
||||
lv_bar.drawer_cb(obj, clip_area, mode);
|
||||
lv_bar.draw_cb(obj, clip_area, mode);
|
||||
|
||||
draw_knob(obj, clip_area);
|
||||
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DRAWER_MODE_POST_DRAW) {
|
||||
return lv_bar.drawer_cb(obj, clip_area, mode);
|
||||
else if(mode == LV_DRAW_MODE_POST_DRAW) {
|
||||
return lv_bar.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -391,10 +391,6 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
|
||||
void draw_knob(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
{
|
||||
lv_drawer_res_t res;
|
||||
res = lv_drawer_part_before(obj, LV_PART_KNOB, clip_area, &obj->coords);
|
||||
if(res != LV_DRAWER_RES_OK) return;
|
||||
|
||||
lv_slider_t * slider = (lv_slider_t *)obj;
|
||||
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(obj);
|
||||
|
||||
@ -442,8 +438,18 @@ void draw_knob(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
|
||||
position_knob(obj, &knob_area, knob_size, hor);
|
||||
lv_area_copy(&slider->right_knob_area, &knob_area);
|
||||
|
||||
/*Handle custom drawer*/
|
||||
lv_obj_draw_hook_dsc_t hook_dsc;
|
||||
lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area);
|
||||
hook_dsc.draw_area = &slider->right_knob_area;
|
||||
hook_dsc.part = LV_PART_KNOB;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
|
||||
|
||||
lv_draw_rect(&slider->right_knob_area, clip_area, &knob_rect_dsc);
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc);
|
||||
|
||||
if(lv_slider_get_type(obj) == LV_SLIDER_TYPE_RANGE) {
|
||||
/* Draw a second knob for the start_value side */
|
||||
if(hor) {
|
||||
@ -455,10 +461,15 @@ void draw_knob(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
position_knob(obj, &knob_area, knob_size, hor);
|
||||
|
||||
lv_area_copy(&slider->left_knob_area, &knob_area);
|
||||
|
||||
hook_dsc.draw_area = &slider->left_knob_area;
|
||||
hook_dsc.id = 1;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
|
||||
/*Draw the knob if the custom drawer allows it*/
|
||||
lv_draw_rect(&slider->left_knob_area, clip_area, &knob_rect_dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc);
|
||||
}
|
||||
|
||||
lv_drawer_part_after(obj, LV_PART_KNOB, clip_area, &obj->coords);
|
||||
}
|
||||
|
||||
static void position_knob(lv_obj_t * obj, lv_area_t * knob_area, lv_coord_t knob_size, bool hor)
|
||||
|
@ -37,7 +37,7 @@
|
||||
static void lv_switch_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_switch_destructor(void * obj);
|
||||
static lv_res_t lv_switch_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
static lv_drawer_res_t lv_switch_drawer(lv_obj_t * sw, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_switch_draw(lv_obj_t * sw, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -65,7 +65,7 @@ lv_obj_t * lv_switch_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
LV_CLASS_INIT(lv_switch, lv_obj);
|
||||
lv_switch.constructor = lv_switch_constructor;
|
||||
lv_switch.destructor = lv_switch_destructor;
|
||||
lv_switch.drawer_cb = lv_switch_drawer;
|
||||
lv_switch.draw_cb = lv_switch_draw;
|
||||
lv_switch.signal_cb = lv_switch_signal;
|
||||
}
|
||||
|
||||
@ -115,23 +115,23 @@ static void lv_switch_destructor(void * obj)
|
||||
* Handle the drawing related tasks of the sliders
|
||||
* @param slider pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_switch_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_switch_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DRAWER_COVER_CHK) {
|
||||
return LV_DRAWER_RES_NOT_COVER;
|
||||
if(mode == LV_DRAW_COVER_CHK) {
|
||||
return LV_DRAW_RES_NOT_COVER;
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DRAWER_DRAW_MAIN) {
|
||||
else if(mode == LV_DRAW_DRAW_MAIN) {
|
||||
|
||||
/*The ancestor drawer function will draw the background.*/
|
||||
lv_switch.base_p->drawer_cb(obj, clip_area, mode);
|
||||
/*The ancestor draw function will draw the background.*/
|
||||
lv_switch.base_p->draw_cb(obj, clip_area, mode);
|
||||
|
||||
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(obj);
|
||||
|
||||
@ -197,11 +197,11 @@ static lv_drawer_res_t lv_switch_drawer(lv_obj_t * obj, const lv_area_t * clip_a
|
||||
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DRAWER_DRAW_POST) {
|
||||
return lv_switch.base_p->drawer_cb(obj, clip_area, mode);
|
||||
else if(mode == LV_DRAW_DRAW_POST) {
|
||||
return lv_switch.base_p->draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
**********************/
|
||||
static void lv_table_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_table_destructor(lv_obj_t * obj);
|
||||
static lv_drawer_res_t lv_table_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_table_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_table_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
static lv_coord_t get_row_height(lv_obj_t * obj, uint16_t row_id, const lv_font_t * font,
|
||||
lv_coord_t letter_space, lv_coord_t line_space,
|
||||
@ -46,7 +46,7 @@ const lv_obj_class_t lv_table = {
|
||||
.constructor = lv_table_constructor,
|
||||
.destructor = lv_table_destructor,
|
||||
.signal_cb = lv_table_signal,
|
||||
.drawer_cb = lv_table_drawer,
|
||||
.draw_cb = lv_table_draw,
|
||||
.base_class = &lv_obj,
|
||||
.instance_size = sizeof(lv_table_t),
|
||||
};
|
||||
@ -365,14 +365,6 @@ void lv_table_set_cell_merge_right(lv_obj_t * obj, uint16_t row, uint16_t col, b
|
||||
refr_size(obj) ;
|
||||
}
|
||||
|
||||
void lv_table_set_cell_drawer(lv_obj_t * obj, lv_table_cell_drawer_cb_t drawer_cb)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_table_t * table = (lv_table_t *) obj;
|
||||
table->drawer_cb = drawer_cb;
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
@ -617,22 +609,22 @@ static void lv_table_destructor(lv_obj_t * obj)
|
||||
* Handle the drawing related tasks of the tables
|
||||
* @param table pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_table_drawer(lv_obj_t * obj, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_table_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DRAWER_MODE_COVER_CHECK) {
|
||||
return lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
if(mode == LV_DRAW_MODE_COVER_CHECK) {
|
||||
return lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DRAWER_MODE_MAIN_DRAW) {
|
||||
else if(mode == LV_DRAW_MODE_MAIN_DRAW) {
|
||||
/*Draw the background*/
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
|
||||
lv_table_t * table = (lv_table_t *) obj;
|
||||
|
||||
@ -652,12 +644,12 @@ static lv_drawer_res_t lv_table_drawer(lv_obj_t * obj, const lv_area_t * clip_ar
|
||||
lv_coord_t cell_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_ITEMS);
|
||||
|
||||
lv_draw_rect_dsc_t rect_dsc_base;
|
||||
lv_draw_rect_dsc_t rect_dsc_drawer; /*Passed to the drawer_cb to modify it*/
|
||||
lv_draw_rect_dsc_t rect_dsc_act; /*Passed to the draw_cb to modify it*/
|
||||
lv_draw_rect_dsc_init(&rect_dsc_base);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_ITEMS, &rect_dsc_base);
|
||||
|
||||
lv_draw_label_dsc_t label_dsc_base;
|
||||
lv_draw_label_dsc_t label_dsc_drawer; /*Passed to the drawer_cb to modify it*/
|
||||
lv_draw_label_dsc_t label_dsc_act; /*Passed to the draw_cb to modify it*/
|
||||
lv_draw_label_dsc_init(&label_dsc_base);
|
||||
lv_obj_init_draw_label_dsc(obj, LV_PART_ITEMS, &label_dsc_base);
|
||||
|
||||
@ -669,13 +661,20 @@ static lv_drawer_res_t lv_table_drawer(lv_obj_t * obj, const lv_area_t * clip_ar
|
||||
lv_coord_t scroll_x = lv_obj_get_scroll_x(obj) ;
|
||||
bool rtl = lv_obj_get_base_dir(obj) == LV_BIDI_DIR_RTL ? true : false;
|
||||
|
||||
/*Handle custom drawer*/
|
||||
lv_obj_draw_hook_dsc_t hook_dsc;
|
||||
lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area);
|
||||
hook_dsc.part = LV_PART_ITEMS;
|
||||
hook_dsc.rect_dsc = &rect_dsc_act;
|
||||
hook_dsc.label_dsc = &label_dsc_act;
|
||||
|
||||
for(row = 0; row < table->row_cnt; row++) {
|
||||
lv_coord_t h_row = table->row_h[row];
|
||||
|
||||
cell_area.y1 = cell_area.y2 + 1;
|
||||
cell_area.y2 = cell_area.y1 + h_row - 1;
|
||||
|
||||
if(cell_area.y1 > clip_area->y2) return LV_DRAWER_RES_OK;
|
||||
if(cell_area.y1 > clip_area->y2) return LV_DRAW_RES_OK;
|
||||
|
||||
if(rtl) cell_area.x1 = obj->coords.x2 - bg_right - 1 - scroll_x;
|
||||
else cell_area.x2 = obj->coords.x1 + bg_left - 1 - scroll_x;
|
||||
@ -738,20 +737,13 @@ static lv_drawer_res_t lv_table_drawer(lv_obj_t * obj, const lv_area_t * clip_ar
|
||||
cell_area_border.y2 += rect_dsc_base.border_width / 2 + (rect_dsc_base.border_width & 0x1);
|
||||
}
|
||||
|
||||
lv_draw_rect_dsc_t * rect_dsc_act = &rect_dsc_base;
|
||||
lv_draw_label_dsc_t * label_dsc_act = &label_dsc_base;
|
||||
_lv_memcpy(&rect_dsc_act, &rect_dsc_base, sizeof(lv_draw_rect_dsc_t));
|
||||
_lv_memcpy(&label_dsc_act, &label_dsc_base, sizeof(lv_draw_label_dsc_t));
|
||||
hook_dsc.draw_area = &cell_area_border;
|
||||
hook_dsc.id = row * table->col_cnt + col;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
|
||||
|
||||
if(table->drawer_cb) {
|
||||
_lv_memcpy(&rect_dsc_drawer, &rect_dsc_base, sizeof(lv_draw_rect_dsc_t));
|
||||
_lv_memcpy(&label_dsc_drawer, &label_dsc_base, sizeof(lv_draw_label_dsc_t));
|
||||
bool drawn = table->drawer_cb(obj, row, col, &rect_dsc_drawer, &label_dsc_drawer, &cell_area_border, clip_area);
|
||||
if(drawn) continue;
|
||||
|
||||
rect_dsc_act = &rect_dsc_drawer;
|
||||
label_dsc_act = &label_dsc_drawer;
|
||||
}
|
||||
|
||||
lv_draw_rect(&cell_area_border, clip_area, rect_dsc_act);
|
||||
lv_draw_rect(&cell_area_border, clip_area, &rect_dsc_act);
|
||||
|
||||
if(table->cell_data[cell]) {
|
||||
txt_area.x1 = cell_area.x1 + cell_left;
|
||||
@ -778,21 +770,23 @@ static lv_drawer_res_t lv_table_drawer(lv_obj_t * obj, const lv_area_t * clip_ar
|
||||
bool label_mask_ok;
|
||||
label_mask_ok = _lv_area_intersect(&label_mask, clip_area, &cell_area);
|
||||
if(label_mask_ok) {
|
||||
lv_draw_label(&txt_area, &label_mask, label_dsc_act, table->cell_data[cell] + 1, NULL);
|
||||
lv_draw_label(&txt_area, &label_mask, &label_dsc_act, table->cell_data[cell] + 1, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc);
|
||||
|
||||
cell += col_merge + 1;
|
||||
col += col_merge;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DRAWER_MODE_POST_DRAW) {
|
||||
lv_obj.drawer_cb(obj, clip_area, mode);
|
||||
else if(mode == LV_DRAW_MODE_POST_DRAW) {
|
||||
lv_obj.draw_cb(obj, clip_area, mode);
|
||||
}
|
||||
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ extern "C" {
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef bool (*lv_table_cell_drawer_cb_t)(lv_obj_t * table, uint32_t row, uint32_t cell, lv_draw_rect_dsc_t * rect_draw_dsc, lv_draw_label_dsc_t * label_draw_dsc, const lv_area_t * draw_area, const lv_area_t * clip_area);
|
||||
typedef bool (*lv_table_cell_draw_cb_t)(lv_obj_t * table, uint32_t row, uint32_t cell, lv_draw_rect_dsc_t * rect_draw_dsc, lv_draw_label_dsc_t * label_draw_dsc, const lv_area_t * draw_area, const lv_area_t * clip_area);
|
||||
|
||||
/**
|
||||
* Internal table cell format structure.
|
||||
@ -50,13 +50,12 @@ typedef union {
|
||||
|
||||
/*Data of table*/
|
||||
typedef struct {
|
||||
/*New data for this type */
|
||||
lv_obj_t obj;
|
||||
uint16_t col_cnt;
|
||||
uint16_t row_cnt;
|
||||
char ** cell_data;
|
||||
lv_coord_t * row_h;
|
||||
lv_coord_t * col_w;
|
||||
lv_table_cell_drawer_cb_t drawer_cb;
|
||||
} lv_table_t;
|
||||
|
||||
extern const lv_obj_class_t lv_table;
|
||||
@ -136,8 +135,6 @@ void lv_table_set_cell_crop(lv_obj_t * table, uint16_t row, uint16_t col, bool c
|
||||
*/
|
||||
void lv_table_set_cell_merge_right(lv_obj_t * table, uint16_t row, uint16_t col, bool en);
|
||||
|
||||
void lv_table_set_cell_drawer(lv_obj_t * obj, lv_table_cell_drawer_cb_t drawer_cb);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
@ -46,7 +46,7 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_drawer_res_t lv_textarea_drawer(lv_obj_t * ta, const lv_area_t * clip_area, lv_drawer_mode_t mode);
|
||||
static lv_draw_res_t lv_textarea_draw(lv_obj_t * ta, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_textarea_signal(lv_obj_t * ta, lv_signal_t sign, void * param);
|
||||
static lv_style_list_t * lv_textarea_get_style(lv_obj_t * ta, uint8_t part);
|
||||
#if LV_USE_ANIMATION
|
||||
@ -65,7 +65,7 @@ static void draw_cursor(lv_obj_t * ta, const lv_area_t * clip_area);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_drawer_cb_t ancestor_drawer;
|
||||
static lv_draw_cb_t ancestor_draw;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static const char * ta_insert_replace;
|
||||
|
||||
@ -93,7 +93,7 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
if(ta == NULL) return NULL;
|
||||
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(ta);
|
||||
if(ancestor_drawer == NULL) ancestor_drawer = lv_obj_get_drawer_cb(ta);
|
||||
if(ancestor_draw == NULL) ancestor_draw = lv_obj_get_draw_cb(ta);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_textarea_ext_t * ext = lv_obj_allocate_ext_attr(ta, sizeof(lv_textarea_ext_t));
|
||||
@ -130,7 +130,7 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
#endif
|
||||
|
||||
lv_obj_set_signal_cb(ta, lv_textarea_signal);
|
||||
lv_obj_set_drawer_cb(ta, lv_textarea_drawer);
|
||||
lv_obj_set_draw_cb(ta, lv_textarea_draw);
|
||||
|
||||
/*Init the new text area object*/
|
||||
if(copy == NULL) {
|
||||
@ -1213,29 +1213,29 @@ void lv_textarea_cursor_up(lv_obj_t * ta)
|
||||
* Handle the drawing related tasks of the text areas
|
||||
* @param ta pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DRAWER_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAWER_DRAW_MAIN: draw the object (always return 'true')
|
||||
* LV_DRAWER_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_drawer_res_t`
|
||||
* LV_DRAW_DRAW_MAIN: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @param return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_drawer_res_t lv_textarea_drawer(lv_obj_t * ta, const lv_area_t * clip_area, lv_drawer_mode_t mode)
|
||||
static lv_draw_res_t lv_textarea_draw(lv_obj_t * ta, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DRAWER_COVER_CHK) {
|
||||
if(mode == LV_DRAW_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return ancestor_drawer(ta, clip_area, mode);
|
||||
return ancestor_draw(ta, clip_area, mode);
|
||||
}
|
||||
else if(mode == LV_DRAWER_DRAW_MAIN) {
|
||||
else if(mode == LV_DRAW_DRAW_MAIN) {
|
||||
/*Draw the object*/
|
||||
ancestor_drawer(ta, clip_area, mode);
|
||||
ancestor_draw(ta, clip_area, mode);
|
||||
draw_placeholder(ta, clip_area);
|
||||
|
||||
}
|
||||
else if(mode == LV_DRAWER_DRAW_POST) {
|
||||
ancestor_drawer(ta, clip_area, mode);
|
||||
else if(mode == LV_DRAW_DRAW_POST) {
|
||||
ancestor_draw(ta, clip_area, mode);
|
||||
draw_cursor(ta, clip_area);
|
||||
}
|
||||
return LV_DRAWER_RES_OK;
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user