refactor(API): don't expose private symbols in lvgl.h. phase-out "_lv*" names (#6068)

Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
Liam 2024-08-02 01:46:42 -04:00 committed by GitHub
parent a8c8275b56
commit 1d14386b99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
587 changed files with 9411 additions and 5563 deletions

View File

@ -250,7 +250,7 @@ menu "LVGL configuration"
bool "Enable support for I1 color format"
default y
depends on LV_USE_DRAW_SW
config LV_DRAW_SW_DRAW_UNIT_CNT
int "Number of draw units"
default 1

View File

@ -26,9 +26,12 @@
#warning "It's recommended to have at least 128kB RAM for the benchmark"
#endif
#include "../../src/display/lv_display_private.h"
#include "../../src/core/lv_global.h"
#if LV_USE_PERF_MONITOR
#include "../../src/display/lv_display_private.h"
#endif
/**********************
* TYPEDEFS
**********************/

View File

@ -118,33 +118,33 @@ void lv_demo_music(void)
{
lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0x343247), 0);
list = _lv_demo_music_list_create(lv_screen_active());
ctrl = _lv_demo_music_main_create(lv_screen_active());
list = lv_demo_music_list_create(lv_screen_active());
ctrl = lv_demo_music_main_create(lv_screen_active());
#if LV_DEMO_MUSIC_AUTO_PLAY
lv_timer_create(auto_step_cb, 1000, NULL);
#endif
}
const char * _lv_demo_music_get_title(uint32_t track_id)
const char * lv_demo_music_get_title(uint32_t track_id)
{
if(track_id >= sizeof(title_list) / sizeof(title_list[0])) return NULL;
return title_list[track_id];
}
const char * _lv_demo_music_get_artist(uint32_t track_id)
const char * lv_demo_music_get_artist(uint32_t track_id)
{
if(track_id >= sizeof(artist_list) / sizeof(artist_list[0])) return NULL;
return artist_list[track_id];
}
const char * _lv_demo_music_get_genre(uint32_t track_id)
const char * lv_demo_music_get_genre(uint32_t track_id)
{
if(track_id >= sizeof(genre_list) / sizeof(genre_list[0])) return NULL;
return genre_list[track_id];
}
uint32_t _lv_demo_music_get_track_length(uint32_t track_id)
uint32_t lv_demo_music_get_track_length(uint32_t track_id)
{
if(track_id >= sizeof(time_list) / sizeof(time_list[0])) return 0;
return time_list[track_id];
@ -170,17 +170,17 @@ static void auto_step_cb(lv_timer_t * t)
switch(state) {
case 5:
_lv_demo_music_album_next(true);
lv_demo_music_album_next(true);
break;
case 6:
_lv_demo_music_album_next(true);
lv_demo_music_album_next(true);
break;
case 7:
_lv_demo_music_album_next(true);
lv_demo_music_album_next(true);
break;
case 8:
_lv_demo_music_play(0);
lv_demo_music_play(0);
break;
#if LV_DEMO_MUSIC_SQUARE || LV_DEMO_MUSIC_ROUND
case 11:
@ -201,7 +201,7 @@ static void auto_step_cb(lv_timer_t * t)
lv_obj_scroll_by(list, 0, 300, LV_ANIM_ON);
break;
case 18:
_lv_demo_music_play(1);
lv_demo_music_play(1);
break;
case 19:
lv_obj_scroll_by(ctrl, 0, LV_VER_RES, LV_ANIM_ON);
@ -212,7 +212,7 @@ static void auto_step_cb(lv_timer_t * t)
break;
#endif
case 30:
_lv_demo_music_play(2);
lv_demo_music_play(2);
break;
case 40: {
lv_obj_t * bg = lv_layer_top();
@ -247,7 +247,7 @@ static void auto_step_cb(lv_timer_t * t)
}
case 41:
lv_screen_load(lv_obj_create(NULL));
_lv_demo_music_pause();
lv_demo_music_pause();
break;
}
state++;

View File

@ -36,10 +36,10 @@ extern "C" {
**********************/
void lv_demo_music(void);
const char * _lv_demo_music_get_title(uint32_t track_id);
const char * _lv_demo_music_get_artist(uint32_t track_id);
const char * _lv_demo_music_get_genre(uint32_t track_id);
uint32_t _lv_demo_music_get_track_length(uint32_t track_id);
const char * lv_demo_music_get_title(uint32_t track_id);
const char * lv_demo_music_get_artist(uint32_t track_id);
const char * lv_demo_music_get_genre(uint32_t track_id);
uint32_t lv_demo_music_get_track_length(uint32_t track_id);
/**********************
* MACROS

View File

@ -51,7 +51,7 @@ LV_IMAGE_DECLARE(img_lv_demo_music_btn_list_pause);
* GLOBAL FUNCTIONS
**********************/
lv_obj_t * _lv_demo_music_list_create(lv_obj_t * parent)
lv_obj_t * lv_demo_music_list_create(lv_obj_t * parent)
{
font_small = LV_FONT_DEFAULT;
font_medium = LV_FONT_DEFAULT;
@ -138,7 +138,7 @@ lv_obj_t * _lv_demo_music_list_create(lv_obj_t * parent)
lv_obj_set_flex_flow(list, LV_FLEX_FLOW_COLUMN);
uint32_t track_id;
for(track_id = 0; _lv_demo_music_get_title(track_id); track_id++) {
for(track_id = 0; lv_demo_music_get_title(track_id); track_id++) {
add_list_button(list, track_id);
}
@ -146,12 +146,12 @@ lv_obj_t * _lv_demo_music_list_create(lv_obj_t * parent)
lv_obj_set_scroll_snap_y(list, LV_SCROLL_SNAP_CENTER);
#endif
_lv_demo_music_list_button_check(0, true);
lv_demo_music_list_button_check(0, true);
return list;
}
void _lv_demo_music_list_button_check(uint32_t track_id, bool state)
void lv_demo_music_list_button_check(uint32_t track_id, bool state)
{
lv_obj_t * btn = lv_obj_get_child(list, track_id);
lv_obj_t * icon = lv_obj_get_child(btn, 0);
@ -173,11 +173,11 @@ void _lv_demo_music_list_button_check(uint32_t track_id, bool state)
static lv_obj_t * add_list_button(lv_obj_t * parent, uint32_t track_id)
{
uint32_t t = _lv_demo_music_get_track_length(track_id);
uint32_t t = lv_demo_music_get_track_length(track_id);
char time[32];
lv_snprintf(time, sizeof(time), "%"LV_PRIu32":%02"LV_PRIu32, t / 60, t % 60);
const char * title = _lv_demo_music_get_title(track_id);
const char * artist = _lv_demo_music_get_artist(track_id);
const char * title = lv_demo_music_get_title(track_id);
const char * artist = lv_demo_music_get_artist(track_id);
lv_obj_t * btn = lv_obj_create(parent);
lv_obj_remove_style_all(btn);
@ -233,7 +233,7 @@ static void btn_click_event_cb(lv_event_t * e)
uint32_t idx = lv_obj_get_index(btn);
_lv_demo_music_play(idx);
lv_demo_music_play(idx);
}
static void list_delete_event_cb(lv_event_t * e)

View File

@ -27,8 +27,8 @@ extern "C" {
/**********************
* GLOBAL PROTOTYPES
**********************/
lv_obj_t * _lv_demo_music_list_create(lv_obj_t * parent);
void _lv_demo_music_list_button_check(uint32_t track_id, bool state);
lv_obj_t * lv_demo_music_list_create(lv_obj_t * parent);
void lv_demo_music_list_button_check(uint32_t track_id, bool state);
/**********************
* MACROS

View File

@ -124,7 +124,7 @@ static void _obj_set_x_anim_cb(void * obj, int32_t x)
lv_obj_set_x((lv_obj_t *)obj, (int32_t)x);
}
lv_obj_t * _lv_demo_music_main_create(lv_obj_t * parent)
lv_obj_t * lv_demo_music_main_create(lv_obj_t * parent)
{
font_small = LV_FONT_DEFAULT;
font_large = LV_FONT_DEFAULT;
@ -318,7 +318,7 @@ lv_obj_t * _lv_demo_music_main_create(lv_obj_t * parent)
return main_cont;
}
void _lv_demo_music_album_next(bool next)
void lv_demo_music_album_next(bool next)
{
uint32_t id = track_id;
if(next) {
@ -335,21 +335,21 @@ void _lv_demo_music_album_next(bool next)
}
if(playing) {
_lv_demo_music_play(id);
lv_demo_music_play(id);
}
else {
track_load(id);
}
}
void _lv_demo_music_play(uint32_t id)
void lv_demo_music_play(uint32_t id)
{
track_load(id);
_lv_demo_music_resume();
lv_demo_music_resume();
}
void _lv_demo_music_resume(void)
void lv_demo_music_resume(void)
{
playing = true;
spectrum_i = spectrum_i_pause;
@ -364,13 +364,13 @@ void _lv_demo_music_resume(void)
lv_anim_start(&a);
if(sec_counter_timer) lv_timer_resume(sec_counter_timer);
lv_slider_set_range(slider_obj, 0, _lv_demo_music_get_track_length(track_id));
lv_slider_set_range(slider_obj, 0, lv_demo_music_get_track_length(track_id));
lv_obj_add_state(play_obj, LV_STATE_CHECKED);
}
void _lv_demo_music_pause(void)
void lv_demo_music_pause(void)
{
playing = false;
spectrum_i_pause = spectrum_i;
@ -499,18 +499,18 @@ static lv_obj_t * create_title_box(lv_obj_t * parent)
title_label = lv_label_create(cont);
lv_obj_set_style_text_font(title_label, font_large, 0);
lv_obj_set_style_text_color(title_label, lv_color_hex(0x504d6d), 0);
lv_label_set_text(title_label, _lv_demo_music_get_title(track_id));
lv_label_set_text(title_label, lv_demo_music_get_title(track_id));
lv_obj_set_height(title_label, lv_font_get_line_height(font_large) * 3 / 2);
artist_label = lv_label_create(cont);
lv_obj_set_style_text_font(artist_label, font_small, 0);
lv_obj_set_style_text_color(artist_label, lv_color_hex(0x504d6d), 0);
lv_label_set_text(artist_label, _lv_demo_music_get_artist(track_id));
lv_label_set_text(artist_label, lv_demo_music_get_artist(track_id));
genre_label = lv_label_create(cont);
lv_obj_set_style_text_font(genre_label, font_small, 0);
lv_obj_set_style_text_color(genre_label, lv_color_hex(0x8a86b8), 0);
lv_label_set_text(genre_label, _lv_demo_music_get_genre(track_id));
lv_label_set_text(genre_label, lv_demo_music_get_genre(track_id));
return cont;
}
@ -685,15 +685,15 @@ static void track_load(uint32_t id)
bool next = false;
if((track_id + 1) % ACTIVE_TRACK_CNT == id) next = true;
_lv_demo_music_list_button_check(track_id, false);
lv_demo_music_list_button_check(track_id, false);
track_id = id;
_lv_demo_music_list_button_check(id, true);
lv_demo_music_list_button_check(id, true);
lv_label_set_text(title_label, _lv_demo_music_get_title(track_id));
lv_label_set_text(artist_label, _lv_demo_music_get_artist(track_id));
lv_label_set_text(genre_label, _lv_demo_music_get_genre(track_id));
lv_label_set_text(title_label, lv_demo_music_get_title(track_id));
lv_label_set_text(artist_label, lv_demo_music_get_artist(track_id));
lv_label_set_text(genre_label, lv_demo_music_get_genre(track_id));
lv_anim_t a;
lv_anim_init(&a);
@ -801,8 +801,10 @@ static void spectrum_draw_event_cb(lv_event_t * e)
if(opa < LV_OPA_MIN) return;
lv_point_t center;
center.x = obj->coords.x1 + lv_obj_get_width(obj) / 2;
center.y = obj->coords.y1 + lv_obj_get_height(obj) / 2;
lv_area_t obj_coords;
lv_obj_get_coords(obj, &obj_coords);
center.x = obj_coords.x1 + lv_obj_get_width(obj) / 2;
center.y = obj_coords.y1 + lv_obj_get_height(obj) / 2;
lv_draw_triangle_dsc_t draw_dsc;
lv_draw_triangle_dsc_init(&draw_dsc);
@ -975,32 +977,32 @@ static void album_gesture_event_cb(lv_event_t * e)
{
LV_UNUSED(e);
lv_dir_t dir = lv_indev_get_gesture_dir(lv_indev_active());
if(dir == LV_DIR_LEFT) _lv_demo_music_album_next(true);
if(dir == LV_DIR_RIGHT) _lv_demo_music_album_next(false);
if(dir == LV_DIR_LEFT) lv_demo_music_album_next(true);
if(dir == LV_DIR_RIGHT) lv_demo_music_album_next(false);
}
static void play_event_click_cb(lv_event_t * e)
{
lv_obj_t * obj = lv_event_get_target(e);
if(lv_obj_has_state(obj, LV_STATE_CHECKED)) {
_lv_demo_music_resume();
lv_demo_music_resume();
}
else {
_lv_demo_music_pause();
lv_demo_music_pause();
}
}
static void prev_click_event_cb(lv_event_t * e)
{
LV_UNUSED(e);
_lv_demo_music_album_next(false);
lv_demo_music_album_next(false);
}
static void next_click_event_cb(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);
if(code == LV_EVENT_CLICKED) {
_lv_demo_music_album_next(true);
lv_demo_music_album_next(true);
}
}
@ -1015,7 +1017,7 @@ static void timer_cb(lv_timer_t * t)
static void spectrum_end_cb(lv_anim_t * a)
{
LV_UNUSED(a);
_lv_demo_music_album_next(true);
lv_demo_music_album_next(true);
}
static void stop_start_anim(lv_timer_t * t)

View File

@ -32,11 +32,11 @@ extern "C" {
/**********************
* GLOBAL PROTOTYPES
**********************/
lv_obj_t * _lv_demo_music_main_create(lv_obj_t * parent);
void _lv_demo_music_play(uint32_t id);
void _lv_demo_music_resume(void);
void _lv_demo_music_pause(void);
void _lv_demo_music_album_next(bool next);
lv_obj_t * lv_demo_music_main_create(lv_obj_t * parent);
void lv_demo_music_play(uint32_t id);
void lv_demo_music_resume(void);
void lv_demo_music_pause(void);
void lv_demo_music_album_next(bool next);
/**********************
* MACROS

View File

@ -10,7 +10,6 @@
#if LV_USE_DEMO_RENDER
#include "../../src/display/lv_display_private.h"
#include "../../src/core/lv_global.h"
/*********************
@ -531,12 +530,14 @@ static void triangle_draw_event_cb(lv_event_t * e)
lv_point_t * p_rel = lv_event_get_user_data(e);
dsc.p[0].x = p_rel[0].x + obj->coords.x1 + 8;
dsc.p[0].y = p_rel[0].y + obj->coords.y1 + 2;
dsc.p[1].x = p_rel[1].x + obj->coords.x1 + 8;
dsc.p[1].y = p_rel[1].y + obj->coords.y1 + 2;
dsc.p[2].x = p_rel[2].x + obj->coords.x1 + 8;
dsc.p[2].y = p_rel[2].y + obj->coords.y1 + 2;
lv_area_t coords;
lv_obj_get_coords(obj, &coords);
dsc.p[0].x = p_rel[0].x + coords.x1 + 8;
dsc.p[0].y = p_rel[0].y + coords.y1 + 2;
dsc.p[1].x = p_rel[1].x + coords.x1 + 8;
dsc.p[1].y = p_rel[1].y + coords.y1 + 2;
dsc.p[2].x = p_rel[2].x + coords.x1 + 8;
dsc.p[2].y = p_rel[2].y + coords.y1 + 2;
lv_opa_t opa = lv_obj_get_style_opa(obj, 0);
dsc.bg_grad.dir = lv_obj_get_style_bg_grad_dir(obj, 0);
@ -1132,7 +1133,7 @@ void lv_demo_render(lv_demo_render_scene_t id, lv_opa_t opa)
const char * lv_demo_render_get_scene_name(lv_demo_render_scene_t id)
{
if(id > _LV_DEMO_RENDER_SCENE_NUM) return NULL;
if(id > LV_DEMO_RENDER_SCENE_NUM) return NULL;
return scenes[id].name;
}

View File

@ -48,7 +48,7 @@ typedef enum {
LV_DEMO_RENDER_SCENE_RADIAL_GRADIENT,
LV_DEMO_RENDER_SCENE_CONICAL_GRADIENT,
#endif
_LV_DEMO_RENDER_SCENE_NUM,
LV_DEMO_RENDER_SCENE_NUM,
} lv_demo_render_scene_t;
/**********************

View File

@ -438,7 +438,7 @@ static void auto_delete(lv_obj_t * obj, uint32_t delay)
static void msgbox_delete(lv_timer_t * tmr)
{
lv_msgbox_close(tmr->user_data);
lv_msgbox_close(lv_timer_get_user_data(tmr));
}
static void set_y_anim(void * obj, int32_t v)

View File

@ -1049,7 +1049,7 @@ static void color_changer_create(lv_obj_t * parent)
{
static lv_palette_t palette[] = {
LV_PALETTE_BLUE, LV_PALETTE_GREEN, LV_PALETTE_BLUE_GREY, LV_PALETTE_ORANGE,
LV_PALETTE_RED, LV_PALETTE_PURPLE, LV_PALETTE_TEAL, _LV_PALETTE_LAST
LV_PALETTE_RED, LV_PALETTE_PURPLE, LV_PALETTE_TEAL, LV_PALETTE_LAST
};
lv_obj_t * color_cont = lv_obj_create(parent);
@ -1069,7 +1069,7 @@ static void color_changer_create(lv_obj_t * parent)
lv_obj_align(color_cont, LV_ALIGN_BOTTOM_RIGHT, - LV_DPX(10), - LV_DPX(10));
uint32_t i;
for(i = 0; palette[i] != _LV_PALETTE_LAST; i++) {
for(i = 0; palette[i] != LV_PALETTE_LAST; i++) {
lv_obj_t * c = lv_button_create(color_cont);
lv_obj_set_style_bg_color(c, lv_palette_main(palette[i]), 0);
lv_obj_set_style_radius(c, LV_RADIUS_CIRCLE, 0);
@ -1168,7 +1168,7 @@ static void color_event_cb(lv_event_t * e)
else if(code == LV_EVENT_CLICKED) {
lv_palette_t * palette_primary = lv_event_get_user_data(e);
lv_palette_t palette_secondary = (*palette_primary) + 3; /*Use another palette as secondary*/
if(palette_secondary >= _LV_PALETTE_LAST) palette_secondary = 0;
if(palette_secondary >= LV_PALETTE_LAST) palette_secondary = 0;
#if LV_USE_THEME_DEFAULT
lv_theme_default_init(NULL, lv_palette_main(*palette_primary), lv_palette_main(palette_secondary),
LV_THEME_DEFAULT_DARK, font_normal);
@ -1367,8 +1367,8 @@ static void slider_event_cb(lv_event_t * e)
}
else if(code == LV_EVENT_DRAW_TASK_ADDED) {
lv_draw_task_t * draw_task = lv_event_get_param(e);
if(draw_task == NULL || draw_task->type != LV_DRAW_TASK_TYPE_FILL) return;
lv_draw_rect_dsc_t * draw_rect_dsc = draw_task->draw_dsc;
if(draw_task == NULL || lv_draw_task_get_type(draw_task) != LV_DRAW_TASK_TYPE_FILL) return;
lv_draw_rect_dsc_t * draw_rect_dsc = lv_draw_task_get_draw_dsc(draw_task);
if(draw_rect_dsc->base.part == LV_PART_KNOB && lv_obj_has_state(obj, LV_STATE_PRESSED)) {
char buf[8];
@ -1378,9 +1378,11 @@ static void slider_event_cb(lv_event_t * e)
lv_text_get_size(&text_size, buf, font_normal, 0, 0, LV_COORD_MAX, LV_TEXT_FLAG_NONE);
lv_area_t txt_area;
txt_area.x1 = draw_task->area.x1 + lv_area_get_width(&draw_task->area) / 2 - text_size.x / 2;
lv_area_t draw_task_area;
lv_draw_task_get_area(draw_task, &draw_task_area);
txt_area.x1 = draw_task_area.x1 + lv_area_get_width(&draw_task_area) / 2 - text_size.x / 2;
txt_area.x2 = txt_area.x1 + text_size.x;
txt_area.y2 = draw_task->area.y1 - 10;
txt_area.y2 = draw_task_area.y1 - 10;
txt_area.y1 = txt_area.y2 - text_size.y;
lv_area_t bg_area;
@ -1416,10 +1418,12 @@ static void chart_event_cb(lv_event_t * e)
}
else if(code == LV_EVENT_DRAW_TASK_ADDED) {
lv_draw_task_t * draw_task = lv_event_get_param(e);
lv_draw_dsc_base_t * base_dsc = draw_task->draw_dsc;
lv_draw_dsc_base_t * base_dsc = lv_draw_task_get_draw_dsc(draw_task);
lv_draw_line_dsc_t * draw_line_dsc = lv_draw_task_get_line_dsc(draw_task);
if(base_dsc->part == LV_PART_ITEMS && draw_line_dsc) {
lv_area_t obj_coords;
lv_obj_get_coords(obj, &obj_coords);
const lv_chart_series_t * ser = lv_chart_get_series_next(obj, NULL);
if(base_dsc->id1 == 1) ser = lv_chart_get_series_next(obj, ser);
@ -1434,12 +1438,12 @@ static void chart_event_cb(lv_event_t * e)
tri_dsc.bg_grad.dir = LV_GRAD_DIR_VER;
int32_t full_h = lv_obj_get_height(obj);
int32_t fract_uppter = (int32_t)(LV_MIN(draw_line_dsc->p1.y, draw_line_dsc->p2.y) - obj->coords.y1) * 255 / full_h;
int32_t fract_lower = (int32_t)(LV_MAX(draw_line_dsc->p1.y, draw_line_dsc->p2.y) - obj->coords.y1) * 255 / full_h;
tri_dsc.bg_grad.stops[0].color = ser->color;
int32_t fract_uppter = (int32_t)(LV_MIN(draw_line_dsc->p1.y, draw_line_dsc->p2.y) - obj_coords.y1) * 255 / full_h;
int32_t fract_lower = (int32_t)(LV_MAX(draw_line_dsc->p1.y, draw_line_dsc->p2.y) - obj_coords.y1) * 255 / full_h;
tri_dsc.bg_grad.stops[0].color = lv_chart_get_series_color(obj, ser);
tri_dsc.bg_grad.stops[0].opa = 255 - fract_uppter;
tri_dsc.bg_grad.stops[0].frac = 0;
tri_dsc.bg_grad.stops[1].color = ser->color;
tri_dsc.bg_grad.stops[1].color = lv_chart_get_series_color(obj, ser);
tri_dsc.bg_grad.stops[1].opa = 255 - fract_lower;
tri_dsc.bg_grad.stops[1].frac = 255;
@ -1448,10 +1452,10 @@ static void chart_event_cb(lv_event_t * e)
lv_draw_rect_dsc_t rect_dsc;
lv_draw_rect_dsc_init(&rect_dsc);
rect_dsc.bg_grad.dir = LV_GRAD_DIR_VER;
rect_dsc.bg_grad.stops[0].color = ser->color;
rect_dsc.bg_grad.stops[0].color = lv_chart_get_series_color(obj, ser);
rect_dsc.bg_grad.stops[0].frac = 0;
rect_dsc.bg_grad.stops[0].opa = 255 - fract_lower;
rect_dsc.bg_grad.stops[1].color = ser->color;
rect_dsc.bg_grad.stops[1].color = lv_chart_get_series_color(obj, ser);
rect_dsc.bg_grad.stops[1].frac = 255;
rect_dsc.bg_grad.stops[1].opa = 0;
@ -1459,7 +1463,7 @@ static void chart_event_cb(lv_event_t * e)
rect_area.x1 = (int32_t)draw_line_dsc->p1.x;
rect_area.x2 = (int32_t)draw_line_dsc->p2.x;
rect_area.y1 = (int32_t)LV_MAX(draw_line_dsc->p1.y, draw_line_dsc->p2.y);
rect_area.y2 = (int32_t)obj->coords.y2;
rect_area.y2 = (int32_t)obj_coords.y2;
lv_draw_rect(base_dsc->layer, &rect_dsc, &rect_area);
}
@ -1472,7 +1476,9 @@ static void chart_event_cb(lv_event_t * e)
outline_dsc.outline_color = lv_color_white();
outline_dsc.outline_width = 2;
outline_dsc.radius = LV_RADIUS_CIRCLE;
lv_draw_rect(base_dsc->layer, &outline_dsc, &draw_task->area);
lv_area_t draw_task_area;
lv_draw_task_get_area(draw_task, &draw_task_area);
lv_draw_rect(base_dsc->layer, &outline_dsc, &draw_task_area);
add_value = true;
}
}
@ -1481,14 +1487,16 @@ static void chart_event_cb(lv_event_t * e)
if(base_dsc->id1 == 1) ser = lv_chart_get_series_next(obj, ser);
if(lv_chart_get_type(obj) == LV_CHART_TYPE_BAR) {
lv_draw_fill_dsc_t * fill_dsc = draw_task->draw_dsc;
lv_draw_fill_dsc_t * fill_dsc = lv_draw_task_get_draw_dsc(draw_task);
lv_draw_rect_dsc_t shadow_dsc;
lv_draw_rect_dsc_init(&shadow_dsc);
shadow_dsc.radius = fill_dsc->radius;
shadow_dsc.bg_opa = LV_OPA_TRANSP;
shadow_dsc.shadow_color = ser->color;
shadow_dsc.shadow_color = lv_chart_get_series_color(obj, ser);
shadow_dsc.shadow_width = 15;
lv_draw_rect(base_dsc->layer, &shadow_dsc, &draw_task->area);
lv_area_t draw_task_area;
lv_draw_task_get_area(draw_task, &draw_task_area);
lv_draw_rect(base_dsc->layer, &shadow_dsc, &draw_task_area);
add_value = true;
}
}
@ -1500,15 +1508,17 @@ static void chart_event_cb(lv_event_t * e)
}
char buf[8];
lv_snprintf(buf, sizeof(buf), "%"LV_PRIu32, ser->y_points[base_dsc->id2]);
lv_snprintf(buf, sizeof(buf), "%"LV_PRId32, lv_chart_get_y_array(obj, (lv_chart_series_t *)ser)[base_dsc->id2]);
lv_point_t text_size;
lv_text_get_size(&text_size, buf, font_normal, 0, 0, LV_COORD_MAX, LV_TEXT_FLAG_NONE);
lv_area_t txt_area;
txt_area.y2 = draw_task->area.y1 - LV_DPX(15);
lv_area_t draw_task_area;
lv_draw_task_get_area(draw_task, &draw_task_area);
txt_area.y2 = draw_task_area.y1 - LV_DPX(15);
txt_area.y1 = txt_area.y2 - text_size.y;
txt_area.x1 = draw_task->area.x1 + (lv_area_get_width(&draw_task->area) - text_size.x) / 2;
txt_area.x1 = draw_task_area.x1 + (lv_area_get_width(&draw_task_area) - text_size.x) / 2;
txt_area.x2 = txt_area.x1 + text_size.x;
lv_area_t bg_area;
@ -1519,7 +1529,7 @@ static void chart_event_cb(lv_event_t * e)
lv_draw_rect_dsc_t rect_dsc;
lv_draw_rect_dsc_init(&rect_dsc);
rect_dsc.bg_color = ser->color;
rect_dsc.bg_color = lv_chart_get_series_color(obj, ser);
rect_dsc.radius = LV_DPX(5);
lv_draw_rect(base_dsc->layer, &rect_dsc, &bg_area);

View File

@ -7,7 +7,7 @@ static bool size_dec = false;
static void timer_cb(lv_timer_t * timer)
{
lv_obj_invalidate(timer->user_data);
lv_obj_invalidate(lv_timer_get_user_data(timer));
if(size_dec) size--;
else size++;
@ -19,7 +19,7 @@ static void event_cb(lv_event_t * e)
{
lv_obj_t * obj = lv_event_get_target(e);
lv_draw_task_t * draw_task = lv_event_get_draw_task(e);
lv_draw_dsc_base_t * base_dsc = draw_task->draw_dsc;
lv_draw_dsc_base_t * base_dsc = lv_draw_task_get_draw_dsc(draw_task);
if(base_dsc->part == LV_PART_MAIN) {
lv_draw_rect_dsc_t draw_dsc;
lv_draw_rect_dsc_init(&draw_dsc);
@ -36,7 +36,9 @@ static void event_cb(lv_event_t * e)
a.y1 = 0;
a.x2 = size;
a.y2 = size;
lv_area_align(&obj->coords, &a, LV_ALIGN_CENTER, 0, 0);
lv_area_t obj_coords;
lv_obj_get_coords(obj, &obj_coords);
lv_area_align(&obj_coords, &a, LV_ALIGN_CENTER, 0, 0);
lv_draw_rect(base_dsc->layer, &draw_dsc, &a);
}

View File

@ -44,7 +44,7 @@ void lv_example_tiny_ttf_3(void)
static void font_size_observer_cb(lv_observer_t * observer, lv_subject_t * subject)
{
lv_style_t * style = observer->user_data;
lv_style_t * style = lv_observer_get_user_data(observer);
lv_style_value_t v;
lv_style_get_prop(style, LV_STYLE_TEXT_FONT, &v);
lv_font_t * font = (lv_font_t *) v.ptr;

View File

@ -13,7 +13,7 @@ static void event_cb(lv_event_t * e)
}
/*Update the snapshot, we know parent of object is the container.*/
snapshot = lv_snapshot_take(img->parent, LV_COLOR_FORMAT_ARGB8888);
snapshot = lv_snapshot_take(lv_obj_get_parent(img), LV_COLOR_FORMAT_ARGB8888);
if(snapshot == NULL)
return;
lv_image_set_src(snapshot_obj, snapshot);

View File

@ -1,3 +1,4 @@
#include "../../src/themes/lv_theme_private.h"
#include "../lv_examples.h"
#if LV_BUILD_EXAMPLES && LV_USE_IMAGE

View File

@ -1,6 +1,9 @@
#include "../../lv_examples.h"
#if LV_USE_BAR && LV_BUILD_EXAMPLES
#define MAX_VALUE 100
#define MIN_VALUE 0
static void set_value(void * bar, int32_t v)
{
lv_bar_set_value(bar, v, LV_ANIM_OFF);
@ -27,17 +30,18 @@ static void event_cb(lv_event_t * e)
txt_area.y1 = 0;
txt_area.y2 = txt_size.y - 1;
lv_bar_t * bar = (lv_bar_t *) obj;
const lv_area_t * indic_area = &bar->indic_area;
lv_area_t indic_area;
lv_obj_get_coords(obj, &indic_area);
lv_area_set_width(&indic_area, lv_area_get_width(&indic_area) * lv_bar_get_value(obj) / MAX_VALUE);
/*If the indicator is long enough put the text inside on the right*/
if(lv_area_get_width(indic_area) > txt_size.x + 20) {
lv_area_align(indic_area, &txt_area, LV_ALIGN_RIGHT_MID, -10, 0);
if(lv_area_get_width(&indic_area) > txt_size.x + 20) {
lv_area_align(&indic_area, &txt_area, LV_ALIGN_RIGHT_MID, -10, 0);
label_dsc.color = lv_color_white();
}
/*If the indicator is still short put the text out of it on the right*/
else {
lv_area_align(indic_area, &txt_area, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
lv_area_align(&indic_area, &txt_area, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
label_dsc.color = lv_color_black();
}
label_dsc.text = buf;
@ -52,6 +56,7 @@ static void event_cb(lv_event_t * e)
void lv_example_bar_6(void)
{
lv_obj_t * bar = lv_bar_create(lv_screen_active());
lv_bar_set_range(bar, MIN_VALUE, MAX_VALUE);
lv_obj_set_size(bar, 200, 20);
lv_obj_center(bar);
lv_obj_add_event_cb(bar, event_cb, LV_EVENT_DRAW_MAIN_END, NULL);

View File

@ -5,7 +5,7 @@ static void event_cb(lv_event_t * e)
{
lv_obj_t * obj = lv_event_get_target(e);
lv_draw_task_t * draw_task = lv_event_get_draw_task(e);
lv_draw_dsc_base_t * base_dsc = draw_task->draw_dsc;
lv_draw_dsc_base_t * base_dsc = lv_draw_task_get_draw_dsc(draw_task);
/*When the button matrix draws the buttons...*/
if(base_dsc->part == LV_PART_ITEMS) {
bool pressed = false;
@ -47,7 +47,7 @@ static void event_cb(lv_event_t * e)
if(label_draw_dsc) {
label_draw_dsc->opa = 0;
}
if(draw_task->type == LV_DRAW_TASK_TYPE_FILL) {
if(lv_draw_task_get_type(draw_task) == LV_DRAW_TASK_TYPE_FILL) {
LV_IMAGE_DECLARE(img_star);
lv_image_header_t header;
lv_result_t res = lv_image_decoder_get_info(&img_star, &header);
@ -58,7 +58,9 @@ static void event_cb(lv_event_t * e)
a.x2 = header.w - 1;
a.y1 = 0;
a.y2 = header.h - 1;
lv_area_align(&draw_task->area, &a, LV_ALIGN_CENTER, 0, 0);
lv_area_t draw_task_area;
lv_draw_task_get_area(draw_task, &draw_task_area);
lv_area_align(&draw_task_area, &a, LV_ALIGN_CENTER, 0, 0);
lv_draw_image_dsc_t img_draw_dsc;
lv_draw_image_dsc_init(&img_draw_dsc);

View File

@ -1,4 +1,4 @@
#include "../../lv_examples.h"
#include "../../lv_examples.h"
#if LV_USE_CANVAS && LV_BUILD_EXAMPLES
#define CANVAS_WIDTH 50

View File

@ -1,4 +1,4 @@
#include "../../lv_examples.h"
#include "../../lv_examples.h"
#if LV_USE_CANVAS && LV_BUILD_EXAMPLES
#define CANVAS_WIDTH 50

View File

@ -16,6 +16,7 @@ void lv_example_chart_1(void)
/*Add two data series*/
lv_chart_series_t * ser1 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_GREEN), LV_CHART_AXIS_PRIMARY_Y);
lv_chart_series_t * ser2 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_SECONDARY_Y);
int32_t * ser2_y_points = lv_chart_get_y_array(chart, ser2);
uint32_t i;
for(i = 0; i < 10; i++) {
@ -23,7 +24,7 @@ void lv_example_chart_1(void)
lv_chart_set_next_value(chart, ser1, lv_rand(10, 50));
/*Directly set points on 'ser2'*/
ser2->y_points[i] = lv_rand(50, 90);
ser2_y_points[i] = lv_rand(50, 90);
}
lv_chart_refresh(chart); /*Required after direct set*/

View File

@ -38,11 +38,13 @@ static void event_cb(lv_event_t * e)
draw_rect_dsc.bg_image_src = buf;
draw_rect_dsc.bg_image_recolor = lv_color_white();
lv_area_t chart_obj_coords;
lv_obj_get_coords(chart, &chart_obj_coords);
lv_area_t a;
a.x1 = chart->coords.x1 + p.x - 20;
a.x2 = chart->coords.x1 + p.x + 20;
a.y1 = chart->coords.y1 + p.y - 30;
a.y2 = chart->coords.y1 + p.y - 10;
a.x1 = chart_obj_coords.x1 + p.x - 20;
a.x2 = chart_obj_coords.x1 + p.x + 20;
a.y1 = chart_obj_coords.y1 + p.y - 30;
a.y2 = chart_obj_coords.y1 + p.y - 10;
lv_layer_t * layer = lv_event_get_layer(e);
lv_draw_rect(layer, &draw_rect_dsc, &a);

View File

@ -5,7 +5,7 @@
static void draw_event_cb(lv_event_t * e)
{
lv_draw_task_t * draw_task = lv_event_get_draw_task(e);
lv_draw_dsc_base_t * base_dsc = draw_task->draw_dsc;
lv_draw_dsc_base_t * base_dsc = lv_draw_task_get_draw_dsc(draw_task);
if(base_dsc->part != LV_PART_ITEMS) {
return;

View File

@ -35,14 +35,14 @@ void lv_example_chart_5(void)
static void draw_event_cb(lv_event_t * e)
{
lv_draw_task_t * draw_task = lv_event_get_draw_task(e);
lv_draw_dsc_base_t * base_dsc = draw_task->draw_dsc;
lv_draw_dsc_base_t * base_dsc = lv_draw_task_get_draw_dsc(draw_task);
if(base_dsc->part == LV_PART_ITEMS && draw_task->type == LV_DRAW_TASK_TYPE_LINE) {
if(base_dsc->part == LV_PART_ITEMS && lv_draw_task_get_type(draw_task) == LV_DRAW_TASK_TYPE_LINE) {
add_faded_area(e);
}
/*Hook the division lines too*/
if(base_dsc->part == LV_PART_MAIN && draw_task->type == LV_DRAW_TASK_TYPE_LINE) {
if(base_dsc->part == LV_PART_MAIN && lv_draw_task_get_type(draw_task) == LV_DRAW_TASK_TYPE_LINE) {
hook_division_lines(e);
}
}
@ -50,14 +50,17 @@ static void draw_event_cb(lv_event_t * e)
static void add_faded_area(lv_event_t * e)
{
lv_obj_t * obj = lv_event_get_target(e);
lv_area_t coords;
lv_obj_get_coords(obj, &coords);
lv_draw_task_t * draw_task = lv_event_get_draw_task(e);
lv_draw_dsc_base_t * base_dsc = draw_task->draw_dsc;
lv_draw_dsc_base_t * base_dsc = lv_draw_task_get_draw_dsc(draw_task);
const lv_chart_series_t * ser = lv_chart_get_series_next(obj, NULL);
lv_color_t ser_color = lv_chart_get_series_color(obj, ser);
/*Draw a triangle below the line witch some opacity gradient*/
lv_draw_line_dsc_t * draw_line_dsc = draw_task->draw_dsc;
lv_draw_line_dsc_t * draw_line_dsc = lv_draw_task_get_draw_dsc(draw_task);
lv_draw_triangle_dsc_t tri_dsc;
lv_draw_triangle_dsc_init(&tri_dsc);
@ -70,12 +73,12 @@ static void add_faded_area(lv_event_t * e)
tri_dsc.bg_grad.dir = LV_GRAD_DIR_VER;
int32_t full_h = lv_obj_get_height(obj);
int32_t fract_uppter = (int32_t)(LV_MIN(draw_line_dsc->p1.y, draw_line_dsc->p2.y) - obj->coords.y1) * 255 / full_h;
int32_t fract_lower = (int32_t)(LV_MAX(draw_line_dsc->p1.y, draw_line_dsc->p2.y) - obj->coords.y1) * 255 / full_h;
tri_dsc.bg_grad.stops[0].color = ser->color;
int32_t fract_uppter = (int32_t)(LV_MIN(draw_line_dsc->p1.y, draw_line_dsc->p2.y) - coords.y1) * 255 / full_h;
int32_t fract_lower = (int32_t)(LV_MAX(draw_line_dsc->p1.y, draw_line_dsc->p2.y) - coords.y1) * 255 / full_h;
tri_dsc.bg_grad.stops[0].color = ser_color;
tri_dsc.bg_grad.stops[0].opa = 255 - fract_uppter;
tri_dsc.bg_grad.stops[0].frac = 0;
tri_dsc.bg_grad.stops[1].color = ser->color;
tri_dsc.bg_grad.stops[1].color = ser_color;
tri_dsc.bg_grad.stops[1].opa = 255 - fract_lower;
tri_dsc.bg_grad.stops[1].frac = 255;
@ -85,10 +88,10 @@ static void add_faded_area(lv_event_t * e)
lv_draw_rect_dsc_t rect_dsc;
lv_draw_rect_dsc_init(&rect_dsc);
rect_dsc.bg_grad.dir = LV_GRAD_DIR_VER;
rect_dsc.bg_grad.stops[0].color = ser->color;
rect_dsc.bg_grad.stops[0].color = ser_color;
rect_dsc.bg_grad.stops[0].frac = 0;
rect_dsc.bg_grad.stops[0].opa = 255 - fract_lower;
rect_dsc.bg_grad.stops[1].color = ser->color;
rect_dsc.bg_grad.stops[1].color = ser_color;
rect_dsc.bg_grad.stops[1].frac = 255;
rect_dsc.bg_grad.stops[1].opa = 0;
@ -96,15 +99,15 @@ static void add_faded_area(lv_event_t * e)
rect_area.x1 = (int32_t)draw_line_dsc->p1.x;
rect_area.x2 = (int32_t)draw_line_dsc->p2.x - 1;
rect_area.y1 = (int32_t)LV_MAX(draw_line_dsc->p1.y, draw_line_dsc->p2.y) - 1;
rect_area.y2 = (int32_t)obj->coords.y2;
rect_area.y2 = (int32_t)coords.y2;
lv_draw_rect(base_dsc->layer, &rect_dsc, &rect_area);
}
static void hook_division_lines(lv_event_t * e)
{
lv_draw_task_t * draw_task = lv_event_get_draw_task(e);
lv_draw_dsc_base_t * base_dsc = draw_task->draw_dsc;
lv_draw_line_dsc_t * line_dsc = draw_task->draw_dsc;
lv_draw_dsc_base_t * base_dsc = lv_draw_task_get_draw_dsc(draw_task);
lv_draw_line_dsc_t * line_dsc = lv_draw_task_get_draw_dsc(draw_task);
/*Vertical line*/
if(line_dsc->p1.x == line_dsc->p2.x) {

View File

@ -4,11 +4,11 @@
static void draw_event_cb(lv_event_t * e)
{
lv_draw_task_t * draw_task = lv_event_get_draw_task(e);
lv_draw_dsc_base_t * base_dsc = draw_task->draw_dsc;
lv_draw_dsc_base_t * base_dsc = lv_draw_task_get_draw_dsc(draw_task);
if(base_dsc->part == LV_PART_INDICATOR) {
lv_obj_t * obj = lv_event_get_target(e);
lv_chart_series_t * ser = lv_chart_get_series_next(obj, NULL);
lv_draw_rect_dsc_t * rect_draw_dsc = draw_task->draw_dsc;
lv_draw_rect_dsc_t * rect_draw_dsc = lv_draw_task_get_draw_dsc(draw_task);
uint32_t cnt = lv_chart_get_point_count(obj);
/*Make older value more transparent*/
@ -31,8 +31,7 @@ static void draw_event_cb(lv_event_t * e)
static void add_data(lv_timer_t * timer)
{
LV_UNUSED(timer);
lv_obj_t * chart = timer->user_data;
lv_obj_t * chart = lv_timer_get_user_data(timer);
lv_chart_set_next_value2(chart, lv_chart_get_series_next(chart, NULL), lv_rand(0, 200), lv_rand(0, 1000));
}

View File

@ -3,7 +3,7 @@
static void add_data(lv_timer_t * t)
{
lv_obj_t * chart = t->user_data;
lv_obj_t * chart = lv_timer_get_user_data(t);
lv_chart_series_t * ser = lv_chart_get_series_next(chart, NULL);
lv_chart_set_next_value(chart, ser, lv_rand(10, 90));

View File

@ -1,11 +1,10 @@
#include "../../lv_examples.h"
#if LV_USE_MENU && LV_USE_MSGBOX && LV_BUILD_EXAMPLES
enum {
typedef enum {
LV_MENU_ITEM_BUILDER_VARIANT_1,
LV_MENU_ITEM_BUILDER_VARIANT_2
};
typedef uint8_t lv_menu_builder_variant_t;
} lv_menu_builder_variant_t;
static void back_event_handler(lv_event_t * e);
static void switch_handler(lv_event_t * e);

View File

@ -1,6 +1,9 @@
#include "../../lv_examples.h"
#if LV_USE_SLIDER && LV_BUILD_EXAMPLES
#define MAX_VALUE 100
#define MIN_VALUE 0
static void slider_event_cb(lv_event_t * e);
/**
@ -15,6 +18,7 @@ void lv_example_slider_3(void)
lv_obj_center(slider);
lv_slider_set_mode(slider, LV_SLIDER_MODE_RANGE);
lv_slider_set_range(slider, MIN_VALUE, MAX_VALUE);
lv_slider_set_value(slider, 70, LV_ANIM_OFF);
lv_slider_set_left_value(slider, 20, LV_ANIM_OFF);
@ -34,8 +38,11 @@ static void slider_event_cb(lv_event_t * e)
else if(code == LV_EVENT_DRAW_MAIN_END) {
if(!lv_obj_has_state(obj, LV_STATE_PRESSED)) return;
lv_slider_t * slider = (lv_slider_t *) obj;
const lv_area_t * indic_area = &slider->bar.indic_area;
lv_area_t slider_area;
lv_obj_get_coords(obj, &slider_area);
lv_area_t indic_area = slider_area;
lv_area_set_width(&indic_area, lv_area_get_width(&slider_area) * lv_slider_get_value(obj) / MAX_VALUE);
indic_area.x1 += lv_area_get_width(&slider_area) * lv_slider_get_left_value(obj) / MAX_VALUE;
char buf[16];
lv_snprintf(buf, sizeof(buf), "%d - %d", (int)lv_slider_get_left_value(obj), (int)lv_slider_get_value(obj));
@ -47,7 +54,7 @@ static void slider_event_cb(lv_event_t * e)
label_area.y1 = 0;
label_area.y2 = label_size.y - 1;
lv_area_align(indic_area, &label_area, LV_ALIGN_OUT_TOP_MID, 0, -10);
lv_area_align(&indic_area, &label_area, LV_ALIGN_OUT_TOP_MID, 0, -10);
lv_draw_label_dsc_t label_draw_dsc;
lv_draw_label_dsc_init(&label_draw_dsc);

View File

@ -25,32 +25,32 @@ void lv_example_span_1(void)
lv_span_t * span = lv_spangroup_new_span(spans);
lv_span_set_text(span, "China is a beautiful country.");
lv_style_set_text_color(&span->style, lv_palette_main(LV_PALETTE_RED));
lv_style_set_text_decor(&span->style, LV_TEXT_DECOR_UNDERLINE);
lv_style_set_text_opa(&span->style, LV_OPA_50);
lv_style_set_text_color(lv_span_get_style(span), lv_palette_main(LV_PALETTE_RED));
lv_style_set_text_decor(lv_span_get_style(span), LV_TEXT_DECOR_UNDERLINE);
lv_style_set_text_opa(lv_span_get_style(span), LV_OPA_50);
span = lv_spangroup_new_span(spans);
lv_span_set_text_static(span, "good good study, day day up.");
#if LV_FONT_MONTSERRAT_24
lv_style_set_text_font(&span->style, &lv_font_montserrat_24);
lv_style_set_text_font(lv_span_get_style(span), &lv_font_montserrat_24);
#endif
lv_style_set_text_color(&span->style, lv_palette_main(LV_PALETTE_GREEN));
lv_style_set_text_color(lv_span_get_style(span), lv_palette_main(LV_PALETTE_GREEN));
span = lv_spangroup_new_span(spans);
lv_span_set_text_static(span, "LVGL is an open-source graphics library.");
lv_style_set_text_color(&span->style, lv_palette_main(LV_PALETTE_BLUE));
lv_style_set_text_color(lv_span_get_style(span), lv_palette_main(LV_PALETTE_BLUE));
span = lv_spangroup_new_span(spans);
lv_span_set_text_static(span, "the boy no name.");
lv_style_set_text_color(&span->style, lv_palette_main(LV_PALETTE_GREEN));
lv_style_set_text_color(lv_span_get_style(span), lv_palette_main(LV_PALETTE_GREEN));
#if LV_FONT_MONTSERRAT_20
lv_style_set_text_font(&span->style, &lv_font_montserrat_20);
lv_style_set_text_font(lv_span_get_style(span), &lv_font_montserrat_20);
#endif
lv_style_set_text_decor(&span->style, LV_TEXT_DECOR_UNDERLINE);
lv_style_set_text_decor(lv_span_get_style(span), LV_TEXT_DECOR_UNDERLINE);
span = lv_spangroup_new_span(spans);
lv_span_set_text(span, "I have a dream that hope to come true.");
lv_style_set_text_decor(&span->style, LV_TEXT_DECOR_STRIKETHROUGH);
lv_style_set_text_decor(lv_span_get_style(span), LV_TEXT_DECOR_STRIKETHROUGH);
lv_spangroup_refr_mode(spans);
}

View File

@ -4,7 +4,7 @@
static void draw_event_cb(lv_event_t * e)
{
lv_draw_task_t * draw_task = lv_event_get_draw_task(e);
lv_draw_dsc_base_t * base_dsc = draw_task->draw_dsc;
lv_draw_dsc_base_t * base_dsc = lv_draw_task_get_draw_dsc(draw_task);
/*If the cells are drawn...*/
if(base_dsc->part == LV_PART_ITEMS) {
uint32_t row = base_dsc->id1;

View File

@ -8,9 +8,9 @@ static void draw_event_cb(lv_event_t * e)
lv_obj_t * obj = lv_event_get_target(e);
lv_draw_task_t * draw_task = lv_event_get_draw_task(e);
lv_draw_dsc_base_t * base_dsc = draw_task->draw_dsc;
lv_draw_dsc_base_t * base_dsc = lv_draw_task_get_draw_dsc(draw_task);
/*If the cells are drawn...*/
if(base_dsc->part == LV_PART_ITEMS && draw_task->type == LV_DRAW_TASK_TYPE_FILL) {
if(base_dsc->part == LV_PART_ITEMS && lv_draw_task_get_type(draw_task) == LV_DRAW_TASK_TYPE_FILL) {
/*Draw the background*/
bool chk = lv_table_has_cell_ctrl(obj, base_dsc->id1, 0, LV_TABLE_CELL_CTRL_CUSTOM_1);
lv_draw_rect_dsc_t rect_dsc;
@ -23,7 +23,9 @@ static void draw_event_cb(lv_event_t * e)
sw_area.x2 = 40;
sw_area.y1 = 0;
sw_area.y2 = 24;
lv_area_align(&draw_task->area, &sw_area, LV_ALIGN_RIGHT_MID, -15, 0);
lv_area_t draw_task_area;
lv_draw_task_get_area(draw_task, &draw_task_area);
lv_area_align(&draw_task_area, &sw_area, LV_ALIGN_RIGHT_MID, -15, 0);
lv_draw_rect(base_dsc->layer, &rect_dsc, &sw_area);
/*Draw the knob*/

2
lvgl.h
View File

@ -110,6 +110,7 @@ extern "C" {
#include "src/draw/lv_draw.h"
#include "src/draw/lv_draw_buf.h"
#include "src/draw/lv_draw_vector.h"
#include "src/draw/sw/lv_draw_sw.h"
#include "src/themes/lv_theme.h"
@ -118,7 +119,6 @@ extern "C" {
#include "src/lv_api_map_v8.h"
#include "src/lv_api_map_v9_0.h"
#include "src/core/lv_global.h"
/*********************
* DEFINES
*********************/

View File

@ -89,7 +89,7 @@ fout.write(
#endif
#ifdef CONFIG_LV_COLOR_DEPTH
#define _LV_KCONFIG_PRESENT
#define LV_KCONFIG_PRESENT
#endif
/*----------------------------------
@ -131,7 +131,7 @@ for line in fin.read().splitlines():
fout.write(
f'{indent}#ifndef {name}\n'
f'{indent} #ifdef _LV_KCONFIG_PRESENT\n'
f'{indent} #ifdef LV_KCONFIG_PRESENT\n'
f'{indent} #ifdef CONFIG_{name.upper()}\n'
f'{indent} #define {name} CONFIG_{name.upper()}\n'
f'{indent} #else\n'
@ -175,7 +175,7 @@ LV_EXPORT_CONST_INT(LV_DRAW_BUF_STRIDE_ALIGN);
LV_EXPORT_CONST_INT(LV_DRAW_BUF_ALIGN);
#endif
#undef _LV_KCONFIG_PRESENT
#undef LV_KCONFIG_PRESENT
/*Set some defines if a dependency is disabled*/
#if LV_USE_LOG == 0

View File

@ -492,7 +492,7 @@ def obj_style_get(p):
if 'filtered' in p and p['filtered']:
print("static inline " + p['var_type'] + " lv_obj_get_style_" + p['name'].lower() +"_filtered(const lv_obj_t * obj, lv_part_t part)")
print("{")
print(" lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_" + p['name'] + "));")
print(" lv_style_value_t v = lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_" + p['name'] + "));")
print(" return " + cast + "v." + p['style_type'] + ";")
print("}")
print("")
@ -518,15 +518,12 @@ def style_set_c(p):
print(" };")
print(" lv_style_set_prop(style, LV_STYLE_" + p['name'] +", v);")
print("}")
print("")
print("const lv_style_prop_t _lv_style_const_prop_id_" + p['name'] + " = LV_STYLE_" + p['name'] + ";")
def style_set_h(p):
if 'section' in p: return
print("void lv_style_set_" + p['name'].lower() +"(lv_style_t * style, "+ p['var_type'] +" value);")
print("LV_ATTRIBUTE_EXTERN_DATA extern const lv_style_prop_t _lv_style_const_prop_id_" + p['name'] + ";")
def local_style_set_c(p):
@ -555,7 +552,7 @@ def style_const_set(p):
print("")
print("#define LV_STYLE_CONST_" + p['name'] + "(val) \\")
print(" { \\")
print(" .prop_ptr = &_lv_style_const_prop_id_" + p['name'] + ", .value = { ." + p['style_type'] +" = " + cast + "val } \\")
print(" .prop = LV_STYLE_" + p['name'] + ", .value = { ." + p['style_type'] +" = " + cast + "val } \\")
print(" }")
@ -643,6 +640,7 @@ extern "C" {
print("#include \"../misc/lv_area.h\"")
print("#include \"../misc/lv_style.h\"")
print("#include \"../core/lv_obj_style.h\"")
print("#include \"../misc/lv_types.h\"")
print()
guard = ""

View File

@ -32,7 +32,7 @@ extern "C" {
#include "../stdlib/builtin/lv_tlsf.h"
#if LV_USE_FONT_COMPRESSED
#include "../font/lv_font_fmt_txt.h"
#include "../font/lv_font_fmt_txt_private.h"
#endif
#include "../tick/lv_tick.h"
@ -40,6 +40,17 @@ extern "C" {
#include "../misc/lv_types.h"
#include "../misc/lv_timer_private.h"
#include "../misc/lv_anim_private.h"
#include "../tick/lv_tick_private.h"
#include "../draw/lv_draw_buf_private.h"
#include "../draw/lv_draw_private.h"
#include "../draw/sw/lv_draw_sw_private.h"
#include "../draw/sw/lv_draw_sw_mask_private.h"
#include "../stdlib/builtin/lv_tlsf_private.h"
#include "../others/sysmon/lv_sysmon_private.h"
#include "../layouts/lv_layout_private.h"
/*********************
* DEFINES
*********************/
@ -54,18 +65,18 @@ struct _snippet_stack;
#endif
#if LV_USE_FREETYPE
struct _lv_freetype_context_t;
struct lv_freetype_context_t;
#endif
#if LV_USE_PROFILER && LV_USE_PROFILER_BUILTIN
struct _lv_profiler_builtin_ctx_t;
struct lv_profiler_builtin_ctx_t;
#endif
#if LV_USE_NUTTX
struct _lv_nuttx_ctx_t;
struct lv_nuttx_ctx_t;
#endif
typedef struct _lv_global_t {
typedef struct lv_global_t {
bool inited;
bool deinit_in_progress; /**< Can be used e.g. in the LV_EVENT_DELETE to deinit the drivers too */
@ -115,7 +126,7 @@ typedef struct _lv_global_t {
lv_draw_sw_shadow_cache_t sw_shadow_cache;
#endif
#if LV_DRAW_SW_COMPLEX
_lv_draw_sw_mask_radius_circle_dsc_arr_t sw_circle_cache;
lv_draw_sw_mask_radius_circle_dsc_arr_t sw_circle_cache;
#endif
#if LV_USE_LOG
@ -171,7 +182,7 @@ typedef struct _lv_global_t {
#endif
#if LV_USE_FREETYPE
struct _lv_freetype_context_t * ft_context;
struct lv_freetype_context_t * ft_context;
#endif
#if LV_USE_FONT_COMPRESSED
@ -183,7 +194,7 @@ typedef struct _lv_global_t {
#endif
#if LV_USE_PROFILER && LV_USE_PROFILER_BUILTIN
struct _lv_profiler_builtin_ctx_t * profiler_context;
struct lv_profiler_builtin_ctx_t * profiler_context;
#endif
#if LV_USE_FILE_EXPLORER != 0
@ -204,7 +215,7 @@ typedef struct _lv_global_t {
#endif
#if LV_USE_NUTTX
struct _lv_nuttx_ctx_t * nuttx_ctx;
struct lv_nuttx_ctx_t * nuttx_ctx;
#endif
#if LV_USE_OS != LV_OS_NONE

View File

@ -6,8 +6,8 @@
/*********************
* INCLUDES
*********************/
#include "lv_group.h"
#include "../core/lv_obj.h"
#include "lv_group_private.h"
#include "../core/lv_obj_private.h"
#include "../core/lv_global.h"
#include "../indev/lv_indev.h"
#include "../misc/lv_types.h"
@ -42,22 +42,22 @@ static lv_indev_t * get_indev(const lv_group_t * g);
* GLOBAL FUNCTIONS
**********************/
void _lv_group_init(void)
void lv_group_init(void)
{
_lv_ll_init(group_ll_p, sizeof(lv_group_t));
lv_ll_init(group_ll_p, sizeof(lv_group_t));
}
void _lv_group_deinit(void)
void lv_group_deinit(void)
{
_lv_ll_clear(group_ll_p);
lv_ll_clear(group_ll_p);
}
lv_group_t * lv_group_create(void)
{
lv_group_t * group = _lv_ll_ins_head(group_ll_p);
lv_group_t * group = lv_ll_ins_head(group_ll_p);
LV_ASSERT_MALLOC(group);
if(group == NULL) return NULL;
_lv_ll_init(&group->obj_ll, sizeof(lv_obj_t *));
lv_ll_init(&group->obj_ll, sizeof(lv_obj_t *));
group->obj_focus = NULL;
group->frozen = 0;
@ -82,7 +82,7 @@ void lv_group_delete(lv_group_t * group)
/*Remove the objects from the group*/
lv_obj_t ** obj;
_LV_LL_READ(&group->obj_ll, obj) {
LV_LL_READ(&group->obj_ll, obj) {
if((*obj)->spec_attr)(*obj)->spec_attr->group_p = NULL;
}
@ -98,8 +98,8 @@ void lv_group_delete(lv_group_t * group)
/*If the group is the default group, set the default group as NULL*/
if(group == lv_group_get_default()) lv_group_set_default(NULL);
_lv_ll_clear(&(group->obj_ll));
_lv_ll_remove(group_ll_p, group);
lv_ll_clear(&(group->obj_ll));
lv_ll_remove(group_ll_p, group);
lv_free(group);
}
@ -125,14 +125,14 @@ void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
if(obj->spec_attr == NULL) lv_obj_allocate_spec_attr(obj);
obj->spec_attr->group_p = group;
lv_obj_t ** next = _lv_ll_ins_tail(&group->obj_ll);
lv_obj_t ** next = lv_ll_ins_tail(&group->obj_ll);
LV_ASSERT_MALLOC(next);
if(next == NULL) return;
*next = obj;
/*If the head and the tail is equal then there is only one object in the linked list.
*In this case automatically activate it*/
if(_lv_ll_get_head(&group->obj_ll) == next) {
if(lv_ll_get_head(&group->obj_ll) == next) {
lv_group_refocus(group);
}
@ -148,7 +148,7 @@ void lv_group_swap_obj(lv_obj_t * obj1, lv_obj_t * obj2)
/*Do not add the object twice*/
lv_obj_t ** obj_i;
_LV_LL_READ(&g1->obj_ll, obj_i) {
LV_LL_READ(&g1->obj_ll, obj_i) {
if((*obj_i) == obj1)(*obj_i) = obj2;
else if((*obj_i) == obj2)(*obj_i) = obj1;
}
@ -171,7 +171,7 @@ void lv_group_remove_obj(lv_obj_t * obj)
if(g->frozen) g->frozen = 0;
/*If this is the only object in the group then focus to nothing.*/
if(_lv_ll_get_head(&g->obj_ll) == g->obj_focus && _lv_ll_get_tail(&g->obj_ll) == g->obj_focus) {
if(lv_ll_get_head(&g->obj_ll) == g->obj_focus && lv_ll_get_tail(&g->obj_ll) == g->obj_focus) {
lv_obj_send_event(*g->obj_focus, LV_EVENT_DEFOCUSED, get_indev(g));
}
/*If there more objects in the group then focus to the next/prev object*/
@ -189,9 +189,9 @@ void lv_group_remove_obj(lv_obj_t * obj)
/*Search the object and remove it from its group*/
lv_obj_t ** i;
_LV_LL_READ(&g->obj_ll, i) {
LV_LL_READ(&g->obj_ll, i) {
if(*i == obj) {
_lv_ll_remove(&g->obj_ll, i);
lv_ll_remove(&g->obj_ll, i);
lv_free(i);
if(obj->spec_attr) obj->spec_attr->group_p = NULL;
break;
@ -213,11 +213,11 @@ void lv_group_remove_all_objs(lv_group_t * group)
/*Remove the objects from the group*/
lv_obj_t ** obj;
_LV_LL_READ(&group->obj_ll, obj) {
LV_LL_READ(&group->obj_ll, obj) {
if((*obj)->spec_attr)(*obj)->spec_attr->group_p = NULL;
}
_lv_ll_clear(&(group->obj_ll));
lv_ll_clear(&(group->obj_ll));
}
void lv_group_focus_obj(lv_obj_t * obj)
@ -232,7 +232,7 @@ void lv_group_focus_obj(lv_obj_t * obj)
lv_group_set_editing(g, false);
lv_obj_t ** i;
_LV_LL_READ(&g->obj_ll, i) {
LV_LL_READ(&g->obj_ll, i) {
if(*i == obj) {
if(g->obj_focus != NULL && obj != *g->obj_focus) { /*Do not defocus if the same object needs to be focused again*/
lv_result_t res = lv_obj_send_event(*g->obj_focus, LV_EVENT_DEFOCUSED, get_indev(g));
@ -257,7 +257,7 @@ void lv_group_focus_next(lv_group_t * group)
{
LV_ASSERT_NULL(group);
bool focus_changed = focus_next_core(group, _lv_ll_get_head, _lv_ll_get_next);
bool focus_changed = focus_next_core(group, lv_ll_get_head, lv_ll_get_next);
if(group->edge_cb) {
if(!focus_changed)
group->edge_cb(group, true);
@ -268,7 +268,7 @@ void lv_group_focus_prev(lv_group_t * group)
{
LV_ASSERT_NULL(group);
bool focus_changed = focus_next_core(group, _lv_ll_get_tail, _lv_ll_get_prev);
bool focus_changed = focus_next_core(group, lv_ll_get_tail, lv_ll_get_prev);
if(group->edge_cb) {
if(!focus_changed)
group->edge_cb(group, false);
@ -374,12 +374,12 @@ bool lv_group_get_wrap(lv_group_t * group)
uint32_t lv_group_get_obj_count(lv_group_t * group)
{
LV_ASSERT_NULL(group);
return _lv_ll_get_len(&group->obj_ll);
return lv_ll_get_len(&group->obj_ll);
}
uint32_t lv_group_get_count(void)
{
return _lv_ll_get_len(group_ll_p);
return lv_ll_get_len(group_ll_p);
}
lv_group_t * lv_group_by_index(uint32_t index)
@ -387,7 +387,7 @@ lv_group_t * lv_group_by_index(uint32_t index)
uint32_t len = 0;
void * node;
for(node = _lv_ll_get_tail(group_ll_p); node != NULL; node = _lv_ll_get_prev(group_ll_p, node)) {
for(node = lv_ll_get_tail(group_ll_p); node != NULL; node = lv_ll_get_prev(group_ll_p, node)) {
if(len == index) {
return (lv_group_t *) node;
}

View File

@ -22,7 +22,7 @@ extern "C" {
* DEFINES
*********************/
/*Predefined keys to control the focused object via lv_group_send(group, c)*/
enum _lv_key_t {
typedef enum {
LV_KEY_UP = 17, /*0x11*/
LV_KEY_DOWN = 18, /*0x12*/
LV_KEY_RIGHT = 19, /*0x13*/
@ -35,7 +35,7 @@ enum _lv_key_t {
LV_KEY_PREV = 11, /*0x0B, '*/
LV_KEY_HOME = 2, /*0x02, STX*/
LV_KEY_END = 3, /*0x03, ETX*/
};
} lv_key_t;
/**********************
* TYPEDEFS
@ -44,29 +44,6 @@ enum _lv_key_t {
typedef void (*lv_group_focus_cb_t)(lv_group_t *);
typedef void (*lv_group_edge_cb_t)(lv_group_t *, bool);
/**
* Groups can be used to logically hold objects so that they can be individually focused.
* They are NOT for laying out objects on a screen (try layouts for that).
*/
struct _lv_group_t {
lv_ll_t obj_ll; /**< Linked list to store the objects in the group*/
lv_obj_t ** obj_focus; /**< The object in focus*/
lv_group_focus_cb_t focus_cb; /**< A function to call when a new object is focused (optional)*/
lv_group_edge_cb_t edge_cb; /**< A function to call when an edge is reached, no more focus
targets are available in this direction (to allow edge feedback
like a sound or a scroll bounce) */
void * user_data;
uint8_t frozen : 1; /**< 1: can't focus to new object*/
uint8_t editing : 1; /**< 1: Edit mode, 0: Navigate mode*/
uint8_t refocus_policy : 1; /**< 1: Focus prev if focused on deletion. 0: Focus next if focused on
deletion.*/
uint8_t wrap : 1; /**< 1: Focus next/prev can wrap at end of list. 0: Focus next/prev stops at end
of list.*/
};
typedef enum {
LV_GROUP_REFOCUS_POLICY_NEXT = 0,
LV_GROUP_REFOCUS_POLICY_PREV = 1
@ -76,18 +53,6 @@ typedef enum {
* GLOBAL PROTOTYPES
**********************/
/**
* Init the group module
* @remarks Internal function, do not call directly.
*/
void _lv_group_init(void);
/**
* Deinit the group module
* @remarks Internal function, do not call directly.
*/
void _lv_group_deinit(void);
/**
* Create a new object group
* @return pointer to the new object group

View File

@ -0,0 +1,75 @@
/**
* @file lv_group_private.h
*
*/
#ifndef LV_GROUP_PRIVATE_H
#define LV_GROUP_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_group.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**
* Groups can be used to logically hold objects so that they can be individually focused.
* They are NOT for laying out objects on a screen (try layouts for that).
*/
struct lv_group_t {
lv_ll_t obj_ll; /**< Linked list to store the objects in the group*/
lv_obj_t ** obj_focus; /**< The object in focus*/
lv_group_focus_cb_t focus_cb; /**< A function to call when a new object is focused (optional)*/
lv_group_edge_cb_t edge_cb; /**< A function to call when an edge is reached, no more focus
targets are available in this direction (to allow edge feedback
like a sound or a scroll bounce) */
void * user_data;
uint8_t frozen : 1; /**< 1: can't focus to new object*/
uint8_t editing : 1; /**< 1: Edit mode, 0: Navigate mode*/
uint8_t refocus_policy : 1; /**< 1: Focus prev if focused on deletion. 0: Focus next if focused on
deletion.*/
uint8_t wrap : 1; /**< 1: Focus next/prev can wrap at end of list. 0: Focus next/prev stops at end
of list.*/
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Init the group module
* @remarks Internal function, do not call directly.
*/
void lv_group_init(void);
/**
* Deinit the group module
* @remarks Internal function, do not call directly.
*/
void lv_group_deinit(void);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_GROUP_PRIVATE_H*/

View File

@ -6,7 +6,12 @@
/*********************
* INCLUDES
*********************/
#include "lv_obj.h"
#include "../misc/lv_event_private.h"
#include "../misc/lv_area_private.h"
#include "lv_obj_style_private.h"
#include "lv_obj_event_private.h"
#include "lv_obj_class_private.h"
#include "lv_obj_private.h"
#include "../indev/lv_indev.h"
#include "../indev/lv_indev_private.h"
#include "lv_refr.h"
@ -20,6 +25,7 @@
#include "../misc/lv_types.h"
#include "../tick/lv_tick.h"
#include "../stdlib/lv_string.h"
#include "lv_obj_draw_private.h"
/*********************
* DEFINES
@ -140,7 +146,7 @@ static const lv_property_ops_t properties[] = {
},
{
.id = LV_PROPERTY_OBJ_EXT_DRAW_SIZE,
.getter = _lv_obj_get_ext_draw_size,
.getter = lv_obj_get_ext_draw_size,
},
{
.id = LV_PROPERTY_OBJ_EVENT_COUNT,
@ -372,7 +378,7 @@ void lv_obj_allocate_spec_attr(lv_obj_t * obj)
LV_ASSERT_OBJ(obj, MY_CLASS);
if(obj->spec_attr == NULL) {
obj->spec_attr = lv_malloc_zeroed(sizeof(_lv_obj_spec_attr_t));
obj->spec_attr = lv_malloc_zeroed(sizeof(lv_obj_spec_attr_t));
LV_ASSERT_MALLOC(obj->spec_attr);
if(obj->spec_attr == NULL) return;
@ -456,6 +462,16 @@ lv_obj_t * lv_obj_get_child_by_id(const lv_obj_t * obj, void * id)
}
#endif
void lv_obj_set_user_data(lv_obj_t * obj, void * user_data)
{
obj->user_data = user_data;
}
void * lv_obj_get_user_data(lv_obj_t * obj)
{
return obj->user_data;
}
/**********************
* STATIC FUNCTIONS
**********************/
@ -499,7 +515,7 @@ static void lv_obj_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
{
LV_UNUSED(class_p);
_lv_event_mark_deleted(obj);
lv_event_mark_deleted(obj);
/*Remove all style*/
lv_obj_enable_style_refresh(false); /*No need to refresh the style because the object will be deleted*/
@ -550,7 +566,7 @@ static void lv_obj_draw(lv_event_t * e)
lv_area_copy(&coords, &obj->coords);
lv_area_increase(&coords, w, h);
if(_lv_area_is_in(info->area, &coords, r) == false) {
if(lv_area_is_in(info->area, &coords, r) == false) {
info->res = LV_COVER_RES_NOT_COVER;
return;
}
@ -881,9 +897,9 @@ static void update_obj_state(lv_obj_t * obj, lv_state_t new_state)
lv_state_t prev_state = obj->state;
_lv_style_state_cmp_t cmp_res = _lv_obj_style_state_compare(obj, prev_state, new_state);
lv_style_state_cmp_t cmp_res = lv_obj_style_state_compare(obj, prev_state, new_state);
/*If there is no difference in styles there is nothing else to do*/
if(cmp_res == _LV_STYLE_STATE_CMP_SAME) {
if(cmp_res == LV_STYLE_STATE_CMP_SAME) {
obj->state = new_state;
return;
}
@ -892,12 +908,12 @@ static void update_obj_state(lv_obj_t * obj, lv_state_t new_state)
lv_obj_invalidate(obj);
obj->state = new_state;
_lv_obj_update_layer_type(obj);
_lv_obj_style_transition_dsc_t * ts = lv_malloc_zeroed(sizeof(_lv_obj_style_transition_dsc_t) * STYLE_TRANSITION_MAX);
lv_obj_update_layer_type(obj);
lv_obj_style_transition_dsc_t * ts = lv_malloc_zeroed(sizeof(lv_obj_style_transition_dsc_t) * STYLE_TRANSITION_MAX);
uint32_t tsi = 0;
uint32_t i;
for(i = 0; i < obj->style_cnt && tsi < STYLE_TRANSITION_MAX; i++) {
_lv_obj_style_t * obj_style = &obj->styles[i];
lv_obj_style_t * obj_style = &obj->styles[i];
lv_state_t state_act = lv_obj_style_get_selector_state(obj->styles[i].selector);
lv_part_t part_act = lv_obj_style_get_selector_part(obj->styles[i].selector);
if(state_act & (~new_state)) continue; /*Skip unrelated styles*/
@ -933,19 +949,19 @@ static void update_obj_state(lv_obj_t * obj, lv_state_t new_state)
for(i = 0; i < tsi; i++) {
lv_part_t part_act = lv_obj_style_get_selector_part(ts[i].selector);
_lv_obj_style_create_transition(obj, part_act, prev_state, new_state, &ts[i]);
lv_obj_style_create_transition(obj, part_act, prev_state, new_state, &ts[i]);
}
lv_free(ts);
if(cmp_res == _LV_STYLE_STATE_CMP_DIFF_REDRAW) {
if(cmp_res == LV_STYLE_STATE_CMP_DIFF_REDRAW) {
/*Invalidation is not enough, e.g. layer type needs to be updated too*/
lv_obj_refresh_style(obj, LV_PART_ANY, LV_STYLE_PROP_ANY);
}
else if(cmp_res == _LV_STYLE_STATE_CMP_DIFF_LAYOUT) {
else if(cmp_res == LV_STYLE_STATE_CMP_DIFF_LAYOUT) {
lv_obj_refresh_style(obj, LV_PART_ANY, LV_STYLE_PROP_ANY);
}
else if(cmp_res == _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD) {
else if(cmp_res == LV_STYLE_STATE_CMP_DIFF_DRAW_PAD) {
lv_obj_invalidate(obj);
lv_obj_refresh_ext_draw_size(obj);
}

View File

@ -43,7 +43,7 @@ extern "C" {
* Possible states of a widget.
* OR-ed values are possible
*/
enum _lv_state_t {
enum {
LV_STATE_DEFAULT = 0x0000,
LV_STATE_CHECKED = 0x0001,
LV_STATE_FOCUSED = 0x0002,
@ -68,7 +68,7 @@ enum _lv_state_t {
* Not all parts are used by every widget
*/
enum _lv_part_t {
enum {
LV_PART_MAIN = 0x000000, /**< A background like rectangle*/
LV_PART_SCROLLBAR = 0x010000, /**< The scrollbar(s)*/
LV_PART_INDICATOR = 0x020000, /**< Indicator, e.g. for slider, bar, switch, or the tick box of the checkbox*/
@ -125,7 +125,7 @@ typedef enum {
LV_OBJ_FLAG_USER_2 = (1L << 28), /**< Custom flag, free to use by user*/
LV_OBJ_FLAG_USER_3 = (1L << 29), /**< Custom flag, free to use by user*/
LV_OBJ_FLAG_USER_4 = (1L << 30), /**< Custom flag, free to use by user*/
} _lv_obj_flag_t;
} lv_obj_flag_t;
#if LV_USE_OBJ_PROPERTY
enum {
@ -217,54 +217,6 @@ enum {
*/
LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_obj_class;
/**
* Special, rarely used attributes.
* They are allocated automatically if any elements is set.
*/
typedef struct {
lv_obj_t ** children; /**< Store the pointer of the children in an array.*/
lv_group_t * group_p;
lv_event_list_t event_list;
lv_point_t scroll; /**< The current X/Y scroll offset*/
int32_t ext_click_pad; /**< Extra click padding in all direction*/
int32_t ext_draw_size; /**< EXTend the size in every direction for drawing.*/
uint16_t child_cnt; /**< Number of children*/
uint16_t scrollbar_mode : 2; /**< How to display scrollbars, see `lv_scrollbar_mode_t`*/
uint16_t scroll_snap_x : 2; /**< Where to align the snappable children horizontally, see `lv_scroll_snap_t`*/
uint16_t scroll_snap_y : 2; /**< Where to align the snappable children vertically*/
uint16_t scroll_dir : 4; /**< The allowed scroll direction(s), see `lv_dir_t`*/
uint16_t layer_type : 2; /**< Cache the layer type here. Element of @lv_intermediate_layer_type_t */
} _lv_obj_spec_attr_t;
struct _lv_obj_t {
const lv_obj_class_t * class_p;
lv_obj_t * parent;
_lv_obj_spec_attr_t * spec_attr;
_lv_obj_style_t * styles;
#if LV_OBJ_STYLE_CACHE
uint32_t style_main_prop_is_set;
uint32_t style_other_prop_is_set;
#endif
void * user_data;
#if LV_USE_OBJ_ID
void * id;
#endif
lv_area_t coords;
lv_obj_flag_t flags;
lv_state_t state;
uint16_t layout_inv : 1;
uint16_t readjust_scroll_after_layout : 1;
uint16_t scr_layout_inv : 1;
uint16_t skip_trans : 1;
uint16_t style_cnt : 6;
uint16_t h_layout : 1;
uint16_t w_layout : 1;
uint16_t is_deleting : 1;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
@ -331,10 +283,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t state, bool v);
* @param obj pointer to an object
* @param user_data pointer to the new user_data.
*/
static inline void lv_obj_set_user_data(lv_obj_t * obj, void * user_data)
{
obj->user_data = user_data;
}
void lv_obj_set_user_data(lv_obj_t * obj, void * user_data);
/*=======================
* Getter functions
@ -383,10 +332,7 @@ lv_group_t * lv_obj_get_group(const lv_obj_t * obj);
* @param obj pointer to an object
* @return the pointer to the user_data of the object
*/
static inline void * lv_obj_get_user_data(lv_obj_t * obj)
{
return obj->user_data;
}
void * lv_obj_get_user_data(lv_obj_t * obj);
/*=======================
* Other functions

View File

@ -6,7 +6,8 @@
/*********************
* INCLUDES
*********************/
#include "lv_obj.h"
#include "lv_obj_class_private.h"
#include "lv_obj_private.h"
#include "../themes/lv_theme.h"
#include "../display/lv_display.h"
#include "../display/lv_display_private.h"
@ -132,7 +133,7 @@ void lv_obj_class_init_obj(lv_obj_t * obj)
}
}
void _lv_obj_destruct(lv_obj_t * obj)
void lv_obj_destruct(lv_obj_t * obj)
{
if(obj->class_p->destructor_cb) obj->class_p->destructor_cb(obj->class_p, obj);
@ -141,7 +142,7 @@ void _lv_obj_destruct(lv_obj_t * obj)
obj->class_p = obj->class_p->base_class;
/*Call the base class's destructor too*/
_lv_obj_destruct(obj);
lv_obj_destruct(obj);
}
}

View File

@ -43,42 +43,6 @@ typedef enum {
} lv_obj_class_theme_inheritable_t;
typedef void (*lv_obj_class_event_cb_t)(lv_obj_class_t * class_p, lv_event_t * e);
/**
* Describe the common methods of every object.
* Similar to a C++ class.
*/
struct _lv_obj_class_t {
const lv_obj_class_t * base_class;
/*class_p is the final class while obj->class_p is the class currently being [de]constructed.*/
void (*constructor_cb)(const lv_obj_class_t * class_p, lv_obj_t * obj);
void (*destructor_cb)(const lv_obj_class_t * class_p, lv_obj_t * obj);
/*class_p is the class in which event is being processed.*/
void (*event_cb)(const lv_obj_class_t * class_p, lv_event_t * e); /**< Widget type specific event function*/
#if LV_USE_OBJ_PROPERTY
uint32_t prop_index_start;
uint32_t prop_index_end;
const lv_property_ops_t * properties;
uint32_t properties_count;
#if LV_USE_OBJ_PROPERTY_NAME
/* An array of property ID and name */
const lv_property_name_t * property_names;
uint32_t names_count;
#endif
#endif
void * user_data;
const char * name;
int32_t width_def;
int32_t height_def;
uint32_t editable : 2; /**< Value from ::lv_obj_class_editable_t*/
uint32_t group_def : 2; /**< Value from ::lv_obj_class_group_def_t*/
uint32_t instance_size : 16;
uint32_t theme_inheritable : 1; /**< Value from ::lv_obj_class_theme_inheritable_t*/
};
/**********************
* GLOBAL PROTOTYPES
**********************/
@ -93,8 +57,6 @@ lv_obj_t * lv_obj_class_create_obj(const lv_obj_class_t * class_p, lv_obj_t * pa
void lv_obj_class_init_obj(lv_obj_t * obj);
void _lv_obj_destruct(lv_obj_t * obj);
bool lv_obj_is_editable(lv_obj_t * obj);
bool lv_obj_is_group_def(lv_obj_t * obj);

View File

@ -0,0 +1,78 @@
/**
* @file lv_obj_class_private.h
*
*/
#ifndef LV_OBJ_CLASS_PRIVATE_H
#define LV_OBJ_CLASS_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_obj_class.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**
* Describe the common methods of every object.
* Similar to a C++ class.
*/
struct lv_obj_class_t {
const lv_obj_class_t * base_class;
/*class_p is the final class while obj->class_p is the class currently being [de]constructed.*/
void (*constructor_cb)(const lv_obj_class_t * class_p, lv_obj_t * obj);
void (*destructor_cb)(const lv_obj_class_t * class_p, lv_obj_t * obj);
/*class_p is the class in which event is being processed.*/
void (*event_cb)(const lv_obj_class_t * class_p, lv_event_t * e); /**< Widget type specific event function*/
#if LV_USE_OBJ_PROPERTY
uint32_t prop_index_start;
uint32_t prop_index_end;
const lv_property_ops_t * properties;
uint32_t properties_count;
#if LV_USE_OBJ_PROPERTY_NAME
/* An array of property ID and name */
const lv_property_name_t * property_names;
uint32_t names_count;
#endif
#endif
void * user_data;
const char * name;
int32_t width_def;
int32_t height_def;
uint32_t editable : 2; /**< Value from ::lv_obj_class_editable_t*/
uint32_t group_def : 2; /**< Value from ::lv_obj_class_group_def_t*/
uint32_t instance_size : 16;
uint32_t theme_inheritable : 1; /**< Value from ::lv_obj_class_theme_inheritable_t*/
};
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_obj_destruct(lv_obj_t * obj);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_OBJ_CLASS_PRIVATE_H*/

View File

@ -6,8 +6,9 @@
/*********************
* INCLUDES
*********************/
#include "lv_obj_draw.h"
#include "lv_obj.h"
#include "lv_obj_draw_private.h"
#include "lv_obj_private.h"
#include "lv_obj_style.h"
#include "../display/lv_display.h"
#include "../indev/lv_indev.h"
#include "../stdlib/lv_string.h"
@ -288,7 +289,7 @@ void lv_obj_refresh_ext_draw_size(lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
int32_t s_old = _lv_obj_get_ext_draw_size(obj);
int32_t s_old = lv_obj_get_ext_draw_size(obj);
int32_t s_new = 0;
lv_obj_send_event(obj, LV_EVENT_REFR_EXT_DRAW_SIZE, &s_new);
@ -306,13 +307,13 @@ void lv_obj_refresh_ext_draw_size(lv_obj_t * obj)
if(s_new != s_old) lv_obj_invalidate(obj);
}
int32_t _lv_obj_get_ext_draw_size(const lv_obj_t * obj)
int32_t lv_obj_get_ext_draw_size(const lv_obj_t * obj)
{
if(obj->spec_attr) return obj->spec_attr->ext_draw_size;
else return 0;
}
lv_layer_type_t _lv_obj_get_layer_type(const lv_obj_t * obj)
lv_layer_type_t lv_obj_get_layer_type(const lv_obj_t * obj)
{
if(obj->spec_attr) return (lv_layer_type_t)obj->spec_attr->layer_type;

View File

@ -98,15 +98,6 @@ int32_t lv_obj_calculate_ext_draw_size(lv_obj_t * obj, lv_part_t part);
*/
void lv_obj_refresh_ext_draw_size(lv_obj_t * obj);
/**
* Get the extended draw area of an object.
* @param obj pointer to an object
* @return the size extended draw area around the real coordinates
*/
int32_t _lv_obj_get_ext_draw_size(const lv_obj_t * obj);
lv_layer_type_t _lv_obj_get_layer_type(const lv_obj_t * obj);
/**********************
* MACROS
**********************/

View File

@ -0,0 +1,48 @@
/**
* @file lv_obj_draw_private.h
*
*/
#ifndef LV_OBJ_DRAW_PRIVATE_H
#define LV_OBJ_DRAW_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_obj_draw.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Get the extended draw area of an object.
* @param obj pointer to an object
* @return the size extended draw area around the real coordinates
*/
int32_t lv_obj_get_ext_draw_size(const lv_obj_t * obj);
lv_layer_type_t lv_obj_get_layer_type(const lv_obj_t * obj);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_OBJ_DRAW_PRIVATE_H*/

View File

@ -6,7 +6,10 @@
/*********************
* INCLUDES
*********************/
#include "lv_obj.h"
#include "../misc/lv_event_private.h"
#include "lv_obj_event_private.h"
#include "lv_obj_class_private.h"
#include "lv_obj_private.h"
#include "../indev/lv_indev.h"
#include "../indev/lv_indev_private.h"
@ -58,13 +61,13 @@ lv_result_t lv_obj_send_event(lv_obj_t * obj, lv_event_code_t event_code, void *
e.stop_bubbling = 0;
e.stop_processing = 0;
_lv_event_push(&e);
lv_event_push(&e);
/*Send the event*/
lv_result_t res = event_send_core(&e);
/*Remove this element from the list*/
_lv_event_pop(&e);
lv_event_pop(&e);
return res;
}

View File

@ -25,18 +25,6 @@ extern "C" {
* TYPEDEFS
**********************/
/**
* Used as the event parameter of ::LV_EVENT_HIT_TEST to check if an `point` can click the object or not.
* `res` should be set like this:
* - If already set to `false` another event wants that point non clickable. If you want to respect it leave it as `false` or set `true` to overwrite it.
* - If already set `true` and `point` shouldn't be clickable set to `false`
* - If already set to `true` you agree that `point` can click the object leave it as `true`
*/
typedef struct {
const lv_point_t * point; /**< A point relative to screen to check if it can click the object or not*/
bool res; /**< true: `point` can click the object; false: it cannot*/
} lv_hit_test_info_t;
/** Cover check results.*/
typedef enum {
LV_COVER_RES_COVER = 0,
@ -44,16 +32,6 @@ typedef enum {
LV_COVER_RES_MASKED = 2,
} lv_cover_res_t;
/**
* Used as the event parameter of ::LV_EVENT_COVER_CHECK to check if an area is covered by the object or not.
* In the event use `const lv_area_t * area = lv_event_get_cover_area(e)` to get the area to check
* and `lv_event_set_cover_res(e, res)` to set the result.
*/
typedef struct {
lv_cover_res_t res;
const lv_area_t * area;
} lv_cover_check_info_t;
/**********************
* GLOBAL PROTOTYPES
**********************/

View File

@ -0,0 +1,62 @@
/**
* @file lv_obj_event_private.h
*
*/
#ifndef LV_OBJ_EVENT_PRIVATE_H
#define LV_OBJ_EVENT_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_obj_event.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**
* Used as the event parameter of ::LV_EVENT_HIT_TEST to check if an `point` can click the object or not.
* `res` should be set like this:
* - If already set to `false` another event wants that point non clickable. If you want to respect it leave it as `false` or set `true` to overwrite it.
* - If already set `true` and `point` shouldn't be clickable set to `false`
* - If already set to `true` you agree that `point` can click the object leave it as `true`
*/
struct lv_hit_test_info_t {
const lv_point_t * point; /**< A point relative to screen to check if it can click the object or not*/
bool res; /**< true: `point` can click the object; false: it cannot*/
};
/**
* Used as the event parameter of ::LV_EVENT_COVER_CHECK to check if an area is covered by the object or not.
* In the event use `const lv_area_t * area = lv_event_get_cover_area(e)` to get the area to check
* and `lv_event_set_cover_res(e, res)` to set the result.
*/
struct lv_cover_check_info_t {
lv_cover_res_t res;
const lv_area_t * area;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_OBJ_EVENT_PRIVATE_H*/

View File

@ -6,7 +6,8 @@
/*********************
* INCLUDES
*********************/
#include "lv_obj.h"
#include "lv_obj_class_private.h"
#include "lv_obj_private.h"
#include "lv_global.h"
#include "../osal/lv_os.h"
#include "../stdlib/lv_sprintf.h"
@ -92,7 +93,7 @@ const char * lv_obj_stringify_id(lv_obj_t * obj, char * buf, uint32_t len)
name = obj->class_p->name;
if(name == NULL) name = "nameless";
lv_snprintf(buf, len, "%s%" LV_PRId32 "", name, (uint32_t)(lv_uintptr_t)obj->id);
lv_snprintf(buf, len, "%s%" LV_PRIu32 "", name, (uint32_t)(lv_uintptr_t)obj->id);
return buf;
}

View File

@ -6,10 +6,14 @@
/*********************
* INCLUDES
*********************/
#include "lv_obj.h"
#include "../misc/lv_area_private.h"
#include "../layouts/lv_layout_private.h"
#include "lv_obj_event_private.h"
#include "lv_obj_draw_private.h"
#include "lv_obj_private.h"
#include "../display/lv_display.h"
#include "../display/lv_display_private.h"
#include "lv_refr.h"
#include "lv_refr_private.h"
#include "../core/lv_global.h"
/*********************
@ -54,12 +58,12 @@ void lv_obj_set_x(lv_obj_t * obj, int32_t x)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_result_t res_x;
lv_style_res_t res_x;
lv_style_value_t v_x;
res_x = lv_obj_get_local_style_prop(obj, LV_STYLE_X, &v_x, 0);
if((res_x == LV_RESULT_OK && v_x.num != x) || res_x == LV_RESULT_INVALID) {
if((res_x == LV_STYLE_RES_FOUND && v_x.num != x) || res_x == LV_STYLE_RES_NOT_FOUND) {
lv_obj_set_style_x(obj, x, 0);
}
}
@ -68,12 +72,12 @@ void lv_obj_set_y(lv_obj_t * obj, int32_t y)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_result_t res_y;
lv_style_res_t res_y;
lv_style_value_t v_y;
res_y = lv_obj_get_local_style_prop(obj, LV_STYLE_Y, &v_y, 0);
if((res_y == LV_RESULT_OK && v_y.num != y) || res_y == LV_RESULT_INVALID) {
if((res_y == LV_STYLE_RES_FOUND && v_y.num != y) || res_y == LV_STYLE_RES_NOT_FOUND) {
lv_obj_set_style_y(obj, y, 0);
}
}
@ -170,7 +174,7 @@ bool lv_obj_refr_size(lv_obj_t * obj)
/*If the object is already out of the parent and its position is changes
*surely the scrollbars also changes so invalidate them*/
bool on1 = _lv_area_is_in(&ori, &parent_fit_area, 0);
bool on1 = lv_area_is_in(&ori, &parent_fit_area, 0);
if(!on1) lv_obj_scrollbar_invalidate(parent);
/*Set the length and height
@ -196,7 +200,7 @@ bool lv_obj_refr_size(lv_obj_t * obj)
/*If the object was out of the parent invalidate the new scrollbar area too.
*If it wasn't out of the parent but out now, also invalidate the scrollbars*/
bool on2 = _lv_area_is_in(&obj->coords, &parent_fit_area, 0);
bool on2 = lv_area_is_in(&obj->coords, &parent_fit_area, 0);
if(on1 || (!on1 && on2)) lv_obj_scrollbar_invalidate(parent);
lv_obj_refresh_ext_draw_size(obj);
@ -215,12 +219,12 @@ void lv_obj_set_size(lv_obj_t * obj, int32_t w, int32_t h)
void lv_obj_set_width(lv_obj_t * obj, int32_t w)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_result_t res_w;
lv_style_res_t res_w;
lv_style_value_t v_w;
res_w = lv_obj_get_local_style_prop(obj, LV_STYLE_WIDTH, &v_w, 0);
if((res_w == LV_RESULT_OK && v_w.num != w) || res_w == LV_RESULT_INVALID) {
if((res_w == LV_STYLE_RES_FOUND && v_w.num != w) || res_w == LV_STYLE_RES_NOT_FOUND) {
lv_obj_set_style_width(obj, w, 0);
}
}
@ -228,12 +232,12 @@ void lv_obj_set_width(lv_obj_t * obj, int32_t w)
void lv_obj_set_height(lv_obj_t * obj, int32_t h)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_result_t res_h;
lv_style_res_t res_h;
lv_style_value_t v_h;
res_h = lv_obj_get_local_style_prop(obj, LV_STYLE_HEIGHT, &v_h, 0);
if((res_h == LV_RESULT_OK && v_h.num != h) || res_h == LV_RESULT_INVALID) {
if((res_h == LV_STYLE_RES_FOUND && v_h.num != h) || res_h == LV_STYLE_RES_NOT_FOUND) {
lv_obj_set_style_height(obj, h, 0);
}
}
@ -450,6 +454,9 @@ void lv_obj_align_to(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, in
x = lv_obj_get_width(base);
y = lv_obj_get_height(base) - lv_obj_get_height(obj);
break;
case LV_ALIGN_DEFAULT:
break;
}
if(LV_COORD_IS_PCT(x_ofs)) x_ofs = (lv_obj_get_width(base) * LV_COORD_GET_PCT(x_ofs)) / 100;
@ -721,7 +728,7 @@ void lv_obj_move_to(lv_obj_t * obj, int32_t x, int32_t y)
/*If the object is already out of the parent and its position is changes
*surely the scrollbars also changes so invalidate them*/
on1 = _lv_area_is_in(&ori, &parent_fit_area, 0);
on1 = lv_area_is_in(&ori, &parent_fit_area, 0);
if(!on1) lv_obj_scrollbar_invalidate(parent);
}
@ -741,7 +748,7 @@ void lv_obj_move_to(lv_obj_t * obj, int32_t x, int32_t y)
/*If the object was out of the parent invalidate the new scrollbar area too.
*If it wasn't out of the parent but out now, also invalidate the scrollbars*/
if(parent) {
bool on2 = _lv_area_is_in(&obj->coords, &parent_fit_area, 0);
bool on2 = lv_area_is_in(&obj->coords, &parent_fit_area, 0);
if(on1 || (!on1 && on2)) lv_obj_scrollbar_invalidate(parent);
}
}
@ -771,7 +778,7 @@ void lv_obj_transform_point_array(const lv_obj_t * obj, lv_point_t points[], siz
lv_obj_point_transform_flag_t flags)
{
if(obj) {
lv_layer_type_t layer_type = _lv_obj_get_layer_type(obj);
lv_layer_type_t layer_type = lv_obj_get_layer_type(obj);
bool do_tranf = layer_type == LV_LAYER_TYPE_TRANSFORM;
bool recursive = flags & LV_OBJ_POINT_TRANSFORM_FLAG_RECURSIVE;
bool inverse = flags & LV_OBJ_POINT_TRANSFORM_FLAG_INVERSE;
@ -820,7 +827,7 @@ void lv_obj_invalidate_area(const lv_obj_t * obj, const lv_area_t * area)
lv_area_increase(&area_tmp, 5, 5);
}
_lv_inv_area(lv_obj_get_display(obj), &area_tmp);
lv_inv_area(lv_obj_get_display(obj), &area_tmp);
}
void lv_obj_invalidate(const lv_obj_t * obj)
@ -829,7 +836,7 @@ void lv_obj_invalidate(const lv_obj_t * obj)
/*Truncate the area to the object*/
lv_area_t obj_coords;
int32_t ext_size = _lv_obj_get_ext_draw_size(obj);
int32_t ext_size = lv_obj_get_ext_draw_size(obj);
lv_area_copy(&obj_coords, &obj->coords);
obj_coords.x1 -= ext_size;
obj_coords.y1 -= ext_size;
@ -856,12 +863,12 @@ bool lv_obj_area_is_visible(const lv_obj_t * obj, lv_area_t * area)
/*Truncate the area to the object*/
lv_area_t obj_coords;
int32_t ext_size = _lv_obj_get_ext_draw_size(obj);
int32_t ext_size = lv_obj_get_ext_draw_size(obj);
lv_area_copy(&obj_coords, &obj->coords);
lv_area_increase(&obj_coords, ext_size, ext_size);
/*The area is not on the object*/
if(!_lv_area_intersect(area, area, &obj_coords)) return false;
if(!lv_area_intersect(area, area, &obj_coords)) return false;
lv_obj_get_transformed_area(obj, area, LV_OBJ_POINT_TRANSFORM_FLAG_RECURSIVE);
@ -874,12 +881,12 @@ bool lv_obj_area_is_visible(const lv_obj_t * obj, lv_area_t * area)
/*Truncate to the parent and if no common parts break*/
lv_area_t parent_coords = parent->coords;
if(lv_obj_has_flag(parent, LV_OBJ_FLAG_OVERFLOW_VISIBLE)) {
int32_t parent_ext_size = _lv_obj_get_ext_draw_size(parent);
int32_t parent_ext_size = lv_obj_get_ext_draw_size(parent);
lv_area_increase(&parent_coords, parent_ext_size, parent_ext_size);
}
lv_obj_get_transformed_area(parent, &parent_coords, LV_OBJ_POINT_TRANSFORM_FLAG_RECURSIVE);
if(!_lv_area_intersect(area, area, &parent_coords)) return false;
if(!lv_area_intersect(area, area, &parent_coords)) return false;
parent = lv_obj_get_parent(parent);
}
@ -892,7 +899,7 @@ bool lv_obj_is_visible(const lv_obj_t * obj)
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_area_t obj_coords;
int32_t ext_size = _lv_obj_get_ext_draw_size(obj);
int32_t ext_size = lv_obj_get_ext_draw_size(obj);
lv_area_copy(&obj_coords, &obj->coords);
obj_coords.x1 -= ext_size;
obj_coords.y1 -= ext_size;
@ -924,7 +931,7 @@ bool lv_obj_hit_test(lv_obj_t * obj, const lv_point_t * point)
lv_area_t a;
lv_obj_get_click_area(obj, &a);
bool res = _lv_area_is_point_on(&a, point, 0);
bool res = lv_area_is_point_on(&a, point, 0);
if(res == false) return false;
if(lv_obj_has_flag(obj, LV_OBJ_FLAG_ADV_HITTEST)) {
@ -952,6 +959,11 @@ int32_t lv_clamp_height(int32_t height, int32_t min_height, int32_t max_height,
return LV_CLAMP(min_height, height, max_height);
}
void lv_obj_center(lv_obj_t * obj)
{
lv_obj_align(obj, LV_ALIGN_CENTER, 0, 0);
}
/**********************
* STATIC FUNCTIONS
**********************/
@ -1118,7 +1130,7 @@ static void layout_update_core(lv_obj_t * obj)
lv_obj_refr_pos(obj);
if(child_cnt > 0) {
_lv_layout_apply(obj);
lv_layout_apply(obj);
}
}

View File

@ -195,10 +195,7 @@ void lv_obj_align_to(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, in
* @param obj pointer to an object to align
* @note if the parent size changes `obj` needs to be aligned manually again
*/
static inline void lv_obj_center(lv_obj_t * obj)
{
lv_obj_align(obj, LV_ALIGN_CENTER, 0, 0);
}
void lv_obj_center(lv_obj_t * obj);
/**
* Copy the coordinates of an object to an area

88
src/core/lv_obj_private.h Normal file
View File

@ -0,0 +1,88 @@
/**
* @file lv_obj_private.h
*
*/
#ifndef LV_OBJ_PRIVATE_H
#define LV_OBJ_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_obj.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**
* Special, rarely used attributes.
* They are allocated automatically if any elements is set.
*/
struct lv_obj_spec_attr_t {
lv_obj_t ** children; /**< Store the pointer of the children in an array.*/
lv_group_t * group_p;
lv_event_list_t event_list;
lv_point_t scroll; /**< The current X/Y scroll offset*/
int32_t ext_click_pad; /**< Extra click padding in all direction*/
int32_t ext_draw_size; /**< EXTend the size in every direction for drawing.*/
uint16_t child_cnt; /**< Number of children*/
uint16_t scrollbar_mode : 2; /**< How to display scrollbars, see `lv_scrollbar_mode_t`*/
uint16_t scroll_snap_x : 2; /**< Where to align the snappable children horizontally, see `lv_scroll_snap_t`*/
uint16_t scroll_snap_y : 2; /**< Where to align the snappable children vertically*/
uint16_t scroll_dir : 4; /**< The allowed scroll direction(s), see `lv_dir_t`*/
uint16_t layer_type : 2; /**< Cache the layer type here. Element of @lv_intermediate_layer_type_t */
};
struct lv_obj_t {
const lv_obj_class_t * class_p;
lv_obj_t * parent;
lv_obj_spec_attr_t * spec_attr;
lv_obj_style_t * styles;
#if LV_OBJ_STYLE_CACHE
uint32_t style_main_prop_is_set;
uint32_t style_other_prop_is_set;
#endif
void * user_data;
#if LV_USE_OBJ_ID
void * id;
#endif
lv_area_t coords;
lv_obj_flag_t flags;
lv_state_t state;
uint16_t layout_inv : 1;
uint16_t readjust_scroll_after_layout : 1;
uint16_t scr_layout_inv : 1;
uint16_t skip_trans : 1;
uint16_t style_cnt : 6;
uint16_t h_layout : 1;
uint16_t w_layout : 1;
uint16_t is_deleting : 1;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_OBJ_PRIVATE_H*/

View File

@ -10,6 +10,8 @@
#include "../stdlib/lv_string.h"
#include "../misc/lv_utils.h"
#include "lv_obj_property.h"
#include "lv_obj_private.h"
#include "lv_obj_class_private.h"
#if LV_USE_OBJ_PROPERTY

View File

@ -67,11 +67,10 @@ enum {
/*Special ID, use it to extend ID and make sure it's unique and compile time determinant*/
LV_PROPERTY_ID_BUILTIN_LAST = 0xffff, /*ID of 0x10000 ~ 0xfffffff is reserved for user*/
/*Special ID used by lvgl to intercept all setter/getter call.*/
LV_PROPERTY_ID_ANY = 0x7ffffffe,
LV_PROPERTY_ID_ANY = 0x7ffffffe, /*Special ID used by lvgl to intercept all setter/getter call.*/
};
struct _lv_property_name_t {
struct lv_property_name_t {
const char * name;
lv_prop_id_t id;
};

View File

@ -6,11 +6,13 @@
/*********************
* INCLUDES
*********************/
#include "lv_obj_scroll.h"
#include "lv_obj.h"
#include "../misc/lv_anim_private.h"
#include "lv_obj_scroll_private.h"
#include "lv_obj_private.h"
#include "../indev/lv_indev.h"
#include "../indev/lv_indev_scroll.h"
#include "../display/lv_display.h"
#include "../misc/lv_area.h"
/*********************
* DEFINES
@ -350,7 +352,7 @@ void lv_obj_scroll_by(lv_obj_t * obj, int32_t dx, int32_t dy, lv_anim_enable_t a
res = lv_obj_send_event(obj, LV_EVENT_SCROLL_BEGIN, NULL);
if(res != LV_RESULT_OK) return;
res = _lv_obj_scroll_by_raw(obj, dx, dy);
res = lv_obj_scroll_by_raw(obj, dx, dy);
if(res != LV_RESULT_OK) return;
res = lv_obj_send_event(obj, LV_EVENT_SCROLL_END, NULL);
@ -408,7 +410,7 @@ void lv_obj_scroll_to_view_recursive(lv_obj_t * obj, lv_anim_enable_t anim_en)
}
}
lv_result_t _lv_obj_scroll_by_raw(lv_obj_t * obj, int32_t x, int32_t y)
lv_result_t lv_obj_scroll_by_raw(lv_obj_t * obj, int32_t x, int32_t y)
{
if(x == 0 && y == 0) return LV_RESULT_OK;
@ -452,7 +454,7 @@ void lv_obj_get_scrollbar_area(lv_obj_t * obj, lv_area_t * hor_area, lv_area_t *
if(lv_obj_has_flag(obj, LV_OBJ_FLAG_SCROLLABLE) == false) return;
lv_dir_t sm = lv_obj_get_scrollbar_mode(obj);
lv_scrollbar_mode_t sm = lv_obj_get_scrollbar_mode(obj);
if(sm == LV_SCROLLBAR_MODE_OFF) return;
/*If there is no indev scrolling this object but `mode==active` return*/
@ -669,12 +671,12 @@ void lv_obj_readjust_scroll(lv_obj_t * obj, lv_anim_enable_t anim_en)
static void scroll_x_anim(void * obj, int32_t v)
{
_lv_obj_scroll_by_raw(obj, v + lv_obj_get_scroll_x(obj), 0);
lv_obj_scroll_by_raw(obj, v + lv_obj_get_scroll_x(obj), 0);
}
static void scroll_y_anim(void * obj, int32_t v)
{
_lv_obj_scroll_by_raw(obj, 0, v + lv_obj_get_scroll_y(obj));
lv_obj_scroll_by_raw(obj, 0, v + lv_obj_get_scroll_y(obj));
}
static void scroll_end_cb(lv_anim_t * a)
@ -734,6 +736,8 @@ static void scroll_area_into_view(const lv_area_t * area, lv_obj_t * child, lv_p
act = lv_area_get_height(area_tmp) / 2 + area_tmp->y1 + y_scroll;
y_scroll += snap_goal - act;
break;
case LV_SCROLL_SNAP_NONE:
break;
}
int32_t x_scroll = 0;
@ -776,6 +780,8 @@ static void scroll_area_into_view(const lv_area_t * area, lv_obj_t * child, lv_p
act = lv_area_get_width(area_tmp) / 2 + area_tmp->x1 + x_scroll;
x_scroll += snap_goal - act;
break;
case LV_SCROLL_SNAP_NONE:
break;
}
/*Remove any pending scroll animations.*/

View File

@ -28,32 +28,20 @@ extern "C" {
/*Can't include lv_obj.h because it includes this header file*/
/** Scrollbar modes: shows when should the scrollbars be visible*/
enum _lv_scrollbar_mode_t {
typedef enum {
LV_SCROLLBAR_MODE_OFF, /**< Never show scrollbars*/
LV_SCROLLBAR_MODE_ON, /**< Always show scrollbars*/
LV_SCROLLBAR_MODE_ACTIVE, /**< Show scroll bars when object is being scrolled*/
LV_SCROLLBAR_MODE_AUTO, /**< Show scroll bars when the content is large enough to be scrolled*/
};
#ifdef DOXYGEN
typedef _lv_scrollbar_mode_t lv_scrollbar_mode_t;
#else
typedef uint8_t lv_scrollbar_mode_t;
#endif /*DOXYGEN*/
} lv_scrollbar_mode_t;
/** Scroll span align options. Tells where to align the snappable children when scroll stops.*/
enum _lv_scroll_snap_t {
typedef enum {
LV_SCROLL_SNAP_NONE, /**< Do not align, leave where it is*/
LV_SCROLL_SNAP_START, /**< Align to the left/top*/
LV_SCROLL_SNAP_END, /**< Align to the right/bottom*/
LV_SCROLL_SNAP_CENTER /**< Align to the center*/
};
#ifdef DOXYGEN
typedef _lv_scroll_snap_t lv_scroll_snap_t;
#else
typedef uint8_t lv_scroll_snap_t;
#endif /*DOXYGEN*/
} lv_scroll_snap_t;
/**********************
* GLOBAL PROTOTYPES
@ -257,17 +245,6 @@ void lv_obj_scroll_to_view(lv_obj_t * obj, lv_anim_enable_t anim_en);
*/
void lv_obj_scroll_to_view_recursive(lv_obj_t * obj, lv_anim_enable_t anim_en);
/**
* Low level function to scroll by given x and y coordinates.
* `LV_EVENT_SCROLL` is sent.
* @param obj pointer to an object to scroll
* @param x pixels to scroll horizontally
* @param y pixels to scroll vertically
* @return `LV_RESULT_INVALID`: to object was deleted in `LV_EVENT_SCROLL`;
* `LV_RESULT_OK`: if the object is still valid
*/
lv_result_t _lv_obj_scroll_by_raw(lv_obj_t * obj, int32_t x, int32_t y);
/**
* Tell whether an object is being scrolled or not at this moment
* @param obj pointer to an object

View File

@ -0,0 +1,50 @@
/**
* @file lv_obj_scroll_private.h
*
*/
#ifndef LV_OBJ_SCROLL_PRIVATE_H
#define LV_OBJ_SCROLL_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_obj_scroll.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Low level function to scroll by given x and y coordinates.
* `LV_EVENT_SCROLL` is sent.
* @param obj pointer to an object to scroll
* @param x pixels to scroll horizontally
* @param y pixels to scroll vertically
* @return `LV_RESULT_INVALID`: to object was deleted in `LV_EVENT_SCROLL`;
* `LV_RESULT_OK`: if the object is still valid
*/
lv_result_t lv_obj_scroll_by_raw(lv_obj_t * obj, int32_t x, int32_t y);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_OBJ_SCROLL_PRIVATE_H*/

View File

@ -6,7 +6,10 @@
/*********************
* INCLUDES
*********************/
#include "lv_obj.h"
#include "../misc/lv_anim_private.h"
#include "lv_obj_style_private.h"
#include "lv_obj_class_private.h"
#include "lv_obj_private.h"
#include "../display/lv_display.h"
#include "../display/lv_display_private.h"
#include "../misc/lv_color.h"
@ -49,7 +52,7 @@ typedef enum {
* STATIC PROTOTYPES
**********************/
static lv_style_t * get_local_style(lv_obj_t * obj, lv_style_selector_t selector);
static _lv_obj_style_t * get_trans_style(lv_obj_t * obj, lv_part_t part);
static lv_obj_style_t * get_trans_style(lv_obj_t * obj, lv_part_t part);
static lv_style_res_t get_prop_core(const lv_obj_t * obj, lv_style_selector_t selector, lv_style_prop_t prop,
lv_style_value_t * v);
static void report_style_change_core(void * style, lv_obj_t * obj);
@ -78,14 +81,14 @@ static lv_style_res_t get_selector_style_prop(const lv_obj_t * obj, lv_style_sel
* GLOBAL FUNCTIONS
**********************/
void _lv_obj_style_init(void)
void lv_obj_style_init(void)
{
_lv_ll_init(style_trans_ll_p, sizeof(trans_t));
lv_ll_init(style_trans_ll_p, sizeof(trans_t));
}
void _lv_obj_style_deinit(void)
void lv_obj_style_deinit(void)
{
_lv_ll_clear(style_trans_ll_p);
lv_ll_clear(style_trans_ll_p);
if(_style_custom_prop_flag_lookup_table != NULL) {
lv_free(_style_custom_prop_flag_lookup_table);
_style_custom_prop_flag_lookup_table = NULL;
@ -120,7 +123,7 @@ void lv_obj_add_style(lv_obj_t * obj, const lv_style_t * style, lv_style_selecto
/*Allocate space for the new style and shift the rest of the style to the end*/
obj->style_cnt++;
LV_ASSERT(obj->style_cnt != 0);
obj->styles = lv_realloc(obj->styles, obj->style_cnt * sizeof(_lv_obj_style_t));
obj->styles = lv_realloc(obj->styles, obj->style_cnt * sizeof(lv_obj_style_t));
LV_ASSERT_MALLOC(obj->styles);
uint32_t j;
@ -128,7 +131,7 @@ void lv_obj_add_style(lv_obj_t * obj, const lv_style_t * style, lv_style_selecto
obj->styles[j] = obj->styles[j - 1];
}
lv_memzero(&obj->styles[i], sizeof(_lv_obj_style_t));
lv_memzero(&obj->styles[i], sizeof(lv_obj_style_t));
obj->styles[i].style = style;
obj->styles[i].selector = selector;
@ -136,8 +139,8 @@ void lv_obj_add_style(lv_obj_t * obj, const lv_style_t * style, lv_style_selecto
uint32_t * prop_is_set = part == LV_PART_MAIN ? &obj->style_main_prop_is_set : &obj->style_other_prop_is_set;
if(lv_style_is_const(style)) {
lv_style_const_prop_t * props = style->values_and_props;
for(i = 0; props[i].prop_ptr; i++) {
(*prop_is_set) |= STYLE_PROP_SHIFTED(*props[i].prop_ptr);
for(i = 0; props[i].prop != LV_STYLE_PROP_INV; i++) {
(*prop_is_set) |= STYLE_PROP_SHIFTED(props[i].prop);
}
}
else {
@ -183,7 +186,7 @@ bool lv_obj_replace_style(lv_obj_t * obj, const lv_style_t * old_style, const lv
continue;
}
lv_memzero(&obj->styles[i], sizeof(_lv_obj_style_t));
lv_memzero(&obj->styles[i], sizeof(lv_obj_style_t));
obj->styles[i].style = new_style;
obj->styles[i].selector = selector;
@ -237,7 +240,7 @@ void lv_obj_remove_style(lv_obj_t * obj, const lv_style_t * style, lv_style_sele
}
obj->style_cnt--;
obj->styles = lv_realloc(obj->styles, obj->style_cnt * sizeof(_lv_obj_style_t));
obj->styles = lv_realloc(obj->styles, obj->style_cnt * sizeof(lv_obj_style_t));
deleted = true;
/*The style from the current `i` index is removed, so `i` points to the next style.
@ -300,7 +303,7 @@ void lv_obj_refresh_style(lv_obj_t * obj, lv_style_selector_t selector, lv_style
/*Cache the layer type*/
if((part == LV_PART_ANY || part == LV_PART_MAIN) && is_layer_refr) {
_lv_obj_update_layer_type(obj);
lv_obj_update_layer_type(obj);
}
if(prop == LV_STYLE_PROP_ANY || is_ext_draw) {
@ -409,8 +412,8 @@ bool lv_obj_remove_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_sty
return res;
}
void _lv_obj_style_create_transition(lv_obj_t * obj, lv_part_t part, lv_state_t prev_state, lv_state_t new_state,
const _lv_obj_style_transition_dsc_t * tr_dsc)
void lv_obj_style_create_transition(lv_obj_t * obj, lv_part_t part, lv_state_t prev_state, lv_state_t new_state,
const lv_obj_style_transition_dsc_t * tr_dsc)
{
trans_t * tr;
@ -427,7 +430,7 @@ void _lv_obj_style_create_transition(lv_obj_t * obj, lv_part_t part, lv_state_t
v1 = lv_obj_get_style_prop(obj, part, tr_dsc->prop);
obj->state = new_state;
_lv_obj_style_t * style_trans = get_trans_style(obj, part);
lv_obj_style_t * style_trans = get_trans_style(obj, part);
lv_style_set_prop((lv_style_t *)style_trans->style, tr_dsc->prop, v1); /*Be sure `trans_style` has a valid value*/
lv_obj_refresh_style(obj, tr_dsc->selector, tr_dsc->prop);
@ -440,7 +443,7 @@ void _lv_obj_style_create_transition(lv_obj_t * obj, lv_part_t part, lv_state_t
}
}
tr = _lv_ll_ins_head(style_trans_ll_p);
tr = lv_ll_ins_head(style_trans_ll_p);
LV_ASSERT_MALLOC(tr);
if(tr == NULL) return;
tr->start_value = v1;
@ -464,7 +467,7 @@ void _lv_obj_style_create_transition(lv_obj_t * obj, lv_part_t part, lv_state_t
lv_anim_start(&a);
}
lv_style_value_t _lv_obj_style_apply_color_filter(const lv_obj_t * obj, lv_part_t part, lv_style_value_t v)
lv_style_value_t lv_obj_style_apply_color_filter(const lv_obj_t * obj, lv_part_t part, lv_style_value_t v)
{
if(obj == NULL) return v;
const lv_color_filter_dsc_t * f = lv_obj_get_style_color_filter_dsc(obj, part);
@ -475,9 +478,9 @@ lv_style_value_t _lv_obj_style_apply_color_filter(const lv_obj_t * obj, lv_part_
return v;
}
_lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t state1, lv_state_t state2)
lv_style_state_cmp_t lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t state1, lv_state_t state2)
{
_lv_style_state_cmp_t res = _LV_STYLE_STATE_CMP_SAME;
lv_style_state_cmp_t res = LV_STYLE_STATE_CMP_SAME;
/*Are there any new styles for the new state?*/
uint32_t i;
@ -511,25 +514,25 @@ _lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t sta
else if(lv_style_get_prop(style, LV_STYLE_BORDER_WIDTH, &v)) layout_diff = true;
if(layout_diff) {
return _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
return LV_STYLE_STATE_CMP_DIFF_LAYOUT;
}
/*Check for draw pad changes*/
if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_WIDTH, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_HEIGHT, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_ROTATION, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_SCALE_X, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_SCALE_Y, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_OUTLINE_OPA, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_OUTLINE_PAD, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_OUTLINE_WIDTH, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_SHADOW_WIDTH, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_SHADOW_OPA, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_SHADOW_OFFSET_X, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_SHADOW_OFFSET_Y, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_SHADOW_SPREAD, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_LINE_WIDTH, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(res == _LV_STYLE_STATE_CMP_SAME) res = _LV_STYLE_STATE_CMP_DIFF_REDRAW;
if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_WIDTH, &v)) res = LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_HEIGHT, &v)) res = LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_ROTATION, &v)) res = LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_SCALE_X, &v)) res = LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_SCALE_Y, &v)) res = LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_OUTLINE_OPA, &v)) res = LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_OUTLINE_PAD, &v)) res = LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_OUTLINE_WIDTH, &v)) res = LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_SHADOW_WIDTH, &v)) res = LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_SHADOW_OPA, &v)) res = LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_SHADOW_OFFSET_X, &v)) res = LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_SHADOW_OFFSET_Y, &v)) res = LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_SHADOW_SPREAD, &v)) res = LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_LINE_WIDTH, &v)) res = LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(res == LV_STYLE_STATE_CMP_SAME) res = LV_STYLE_STATE_CMP_DIFF_REDRAW;
}
}
@ -602,7 +605,7 @@ lv_opa_t lv_obj_get_style_opa_recursive(const lv_obj_t * obj, lv_part_t part)
return opa_final;
}
void _lv_obj_update_layer_type(lv_obj_t * obj)
void lv_obj_update_layer_type(lv_obj_t * obj)
{
lv_layer_type_t layer_type = calculate_layer_type(obj);
if(obj->spec_attr) obj->spec_attr->layer_type = layer_type;
@ -635,7 +638,7 @@ static lv_style_t * get_local_style(lv_obj_t * obj, lv_style_selector_t selector
obj->style_cnt++;
LV_ASSERT(obj->style_cnt != 0);
obj->styles = lv_realloc(obj->styles, obj->style_cnt * sizeof(_lv_obj_style_t));
obj->styles = lv_realloc(obj->styles, obj->style_cnt * sizeof(lv_obj_style_t));
LV_ASSERT_MALLOC(obj->styles);
for(i = obj->style_cnt - 1; i > 0 ; i--) {
@ -645,7 +648,7 @@ static lv_style_t * get_local_style(lv_obj_t * obj, lv_style_selector_t selector
obj->styles[i] = obj->styles[i - 1];
}
lv_memzero(&obj->styles[i], sizeof(_lv_obj_style_t));
lv_memzero(&obj->styles[i], sizeof(lv_obj_style_t));
obj->styles[i].style = lv_malloc(sizeof(lv_style_t));
lv_style_init((lv_style_t *)obj->styles[i].style);
@ -661,7 +664,7 @@ static lv_style_t * get_local_style(lv_obj_t * obj, lv_style_selector_t selector
* @param selector OR-ed value of parts and state for which the style should be get
* @return pointer to the transition style
*/
static _lv_obj_style_t * get_trans_style(lv_obj_t * obj, lv_style_selector_t selector)
static lv_obj_style_t * get_trans_style(lv_obj_t * obj, lv_style_selector_t selector)
{
uint32_t i;
for(i = 0; i < obj->style_cnt; i++) {
@ -673,13 +676,13 @@ static _lv_obj_style_t * get_trans_style(lv_obj_t * obj, lv_style_selector_t se
obj->style_cnt++;
LV_ASSERT(obj->style_cnt != 0);
obj->styles = lv_realloc(obj->styles, obj->style_cnt * sizeof(_lv_obj_style_t));
obj->styles = lv_realloc(obj->styles, obj->style_cnt * sizeof(lv_obj_style_t));
for(i = obj->style_cnt - 1; i > 0 ; i--) {
obj->styles[i] = obj->styles[i - 1];
}
lv_memzero(&obj->styles[0], sizeof(_lv_obj_style_t));
lv_memzero(&obj->styles[0], sizeof(lv_obj_style_t));
obj->styles[0].style = lv_malloc(sizeof(lv_style_t));
lv_style_init((lv_style_t *)obj->styles[0].style);
@ -692,7 +695,7 @@ static lv_style_res_t get_prop_core(const lv_obj_t * obj, lv_style_selector_t se
lv_style_value_t * v)
{
const uint32_t group = (uint32_t)1 << _lv_style_get_prop_group(prop);
const uint32_t group = (uint32_t)1 << lv_style_get_prop_group(prop);
const lv_part_t part = lv_obj_style_get_selector_part(selector);
const lv_state_t state = lv_obj_style_get_selector_state(selector);
const lv_state_t state_inv = ~state;
@ -701,7 +704,7 @@ static lv_style_res_t get_prop_core(const lv_obj_t * obj, lv_style_selector_t se
lv_style_res_t found;
uint32_t i;
for(i = 0; i < obj->style_cnt; i++) {
_lv_obj_style_t * obj_style = &obj->styles[i];
lv_obj_style_t * obj_style = &obj->styles[i];
if(obj_style->is_trans == false) break;
if(skip_trans) continue;
@ -717,7 +720,7 @@ static lv_style_res_t get_prop_core(const lv_obj_t * obj, lv_style_selector_t se
for(; i < obj->style_cnt; i++) {
if((obj->styles[i].style->has_group & group) == 0) continue;
_lv_obj_style_t * obj_style = &obj->styles[i];
lv_obj_style_t * obj_style = &obj->styles[i];
lv_part_t part_act = lv_obj_style_get_selector_part(obj->styles[i].selector);
if(part_act != part) continue;
@ -785,7 +788,7 @@ static void refresh_children_style(lv_obj_t * obj)
/**
* Remove the transition from object's part's property.
* - Remove the transition from `_lv_obj_style_trans_ll` and free it
* - Remove the transition from `lv_obj_style_trans_ll` and free it
* - Delete pending transitions
* @param obj pointer to an object which transition(s) should be removed
* @param part a part of object or 0xFF to remove from all parts
@ -797,12 +800,12 @@ static bool trans_delete(lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop, t
trans_t * tr;
trans_t * tr_prev;
bool removed = false;
tr = _lv_ll_get_tail(style_trans_ll_p);
tr = lv_ll_get_tail(style_trans_ll_p);
while(tr != NULL) {
if(tr == tr_limit) break;
/*'tr' might be deleted, so get the next object while 'tr' is valid*/
tr_prev = _lv_ll_get_prev(style_trans_ll_p, tr);
tr_prev = lv_ll_get_prev(style_trans_ll_p, tr);
if(tr->obj == obj && (part == tr->selector || part == LV_PART_ANY) && (prop == tr->prop || prop == LV_STYLE_PROP_ANY)) {
/*Remove any transitioned properties from the trans. style
@ -816,7 +819,7 @@ static bool trans_delete(lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop, t
/*Free the transition descriptor too*/
lv_anim_delete(tr, NULL);
_lv_ll_remove(style_trans_ll_p, tr);
lv_ll_remove(style_trans_ll_p, tr);
lv_free(tr);
removed = true;
@ -906,7 +909,7 @@ static void trans_anim_start_cb(lv_anim_t * a)
tr->prop = prop_tmp;
_lv_obj_style_t * style_trans = get_trans_style(tr->obj, tr->selector);
lv_obj_style_t * style_trans = get_trans_style(tr->obj, tr->selector);
/*Be sure `trans_style` has a valid value*/
lv_style_set_prop((lv_style_t *)style_trans->style, tr->prop, tr->start_value);
lv_obj_refresh_style(tr->obj, tr->selector, tr->prop);
@ -924,7 +927,7 @@ static void trans_anim_completed_cb(lv_anim_t * a)
*It allows changing it by normal styles*/
bool running = false;
trans_t * tr_i;
_LV_LL_READ(style_trans_ll_p, tr_i) {
LV_LL_READ(style_trans_ll_p, tr_i) {
if(tr_i != tr && tr_i->obj == tr->obj && tr_i->selector == tr->selector && tr_i->prop == tr->prop) {
running = true;
break;
@ -935,10 +938,10 @@ static void trans_anim_completed_cb(lv_anim_t * a)
uint32_t i;
for(i = 0; i < obj->style_cnt; i++) {
if(obj->styles[i].is_trans && obj->styles[i].selector == tr->selector) {
_lv_ll_remove(style_trans_ll_p, tr);
lv_ll_remove(style_trans_ll_p, tr);
lv_free(tr);
_lv_obj_style_t * obj_style = &obj->styles[i];
lv_obj_style_t * obj_style = &obj->styles[i];
lv_style_remove_prop((lv_style_t *)obj_style->style, prop);
if(lv_style_is_empty(obj->styles[i].style)) {
@ -976,8 +979,8 @@ static void full_cache_refresh(lv_obj_t * obj, lv_part_t part)
uint32_t j;
if(lv_style_is_const(style)) {
lv_style_const_prop_t * props = style->values_and_props;
for(j = 0; props[j].prop_ptr; j++) {
obj->style_main_prop_is_set |= STYLE_PROP_SHIFTED(*props[j].prop_ptr);
for(j = 0; props[j].prop != LV_STYLE_PROP_INV; j++) {
obj->style_main_prop_is_set |= STYLE_PROP_SHIFTED(props[j].prop);
}
}
else {
@ -996,8 +999,8 @@ static void full_cache_refresh(lv_obj_t * obj, lv_part_t part)
uint32_t j;
if(lv_style_is_const(style)) {
lv_style_const_prop_t * props = style->values_and_props;
for(j = 0; props[j].prop_ptr; j++) {
obj->style_other_prop_is_set |= STYLE_PROP_SHIFTED(*props[j].prop_ptr);
for(j = 0; props[j].prop != LV_STYLE_PROP_INV; j++) {
obj->style_other_prop_is_set |= STYLE_PROP_SHIFTED(props[j].prop);
}
}
else {
@ -1029,8 +1032,8 @@ static bool style_has_flag(const lv_style_t * style, uint32_t flag)
if(lv_style_is_const(style)) {
lv_style_const_prop_t * props = style->values_and_props;
uint32_t i;
for(i = 0; props[i].prop_ptr; i++) {
if(lv_style_prop_has_flag(*props[i].prop_ptr, flag)) {
for(i = 0; props[i].prop != LV_STYLE_PROP_INV; i++) {
if(lv_style_prop_has_flag(props[i].prop, flag)) {
return true;
}
}
@ -1063,14 +1066,14 @@ static lv_style_res_t get_selector_style_prop(const lv_obj_t * obj, lv_style_sel
if(found == LV_STYLE_RES_FOUND) return LV_STYLE_RES_FOUND;
}
extern const uint8_t _lv_style_builtin_prop_flag_lookup_table[];
extern const uint8_t lv_style_builtin_prop_flag_lookup_table[];
bool inheritable = false;
if(prop < _LV_STYLE_NUM_BUILT_IN_PROPS) {
inheritable = _lv_style_builtin_prop_flag_lookup_table[prop] & LV_STYLE_PROP_FLAG_INHERITABLE;
if(prop < LV_STYLE_NUM_BUILT_IN_PROPS) {
inheritable = lv_style_builtin_prop_flag_lookup_table[prop] & LV_STYLE_PROP_FLAG_INHERITABLE;
}
else {
if(_style_custom_prop_flag_lookup_table != NULL) {
inheritable = _style_custom_prop_flag_lookup_table[prop - _LV_STYLE_NUM_BUILT_IN_PROPS] &
inheritable = _style_custom_prop_flag_lookup_table[prop - LV_STYLE_NUM_BUILT_IN_PROPS] &
LV_STYLE_PROP_FLAG_INHERITABLE;
}
}

View File

@ -24,60 +24,20 @@ extern "C" {
/**********************
* TYPEDEFS
**********************/
/*Can't include lv_obj.h because it includes this header file*/
#ifndef LV_OBJ_H
/// @cond
/**
* Tells Doxygen to ignore a duplicate declaration
*/
typedef uint32_t lv_part_t;
typedef uint16_t lv_state_t;
/// @endcond
#endif
typedef enum {
_LV_STYLE_STATE_CMP_SAME, /*The style properties in the 2 states are identical*/
_LV_STYLE_STATE_CMP_DIFF_REDRAW, /*The differences can be shown with a simple redraw*/
_LV_STYLE_STATE_CMP_DIFF_DRAW_PAD, /*The differences can be shown with a simple redraw*/
_LV_STYLE_STATE_CMP_DIFF_LAYOUT, /*The differences can be shown with a simple redraw*/
} _lv_style_state_cmp_t;
LV_STYLE_STATE_CMP_SAME, /*The style properties in the 2 states are identical*/
LV_STYLE_STATE_CMP_DIFF_REDRAW, /*The differences can be shown with a simple redraw*/
LV_STYLE_STATE_CMP_DIFF_DRAW_PAD, /*The differences can be shown with a simple redraw*/
LV_STYLE_STATE_CMP_DIFF_LAYOUT, /*The differences can be shown with a simple redraw*/
} lv_style_state_cmp_t;
typedef uint32_t lv_style_selector_t;
typedef struct {
const lv_style_t * style;
uint32_t selector : 24;
uint32_t is_local : 1;
uint32_t is_trans : 1;
} _lv_obj_style_t;
typedef struct {
uint16_t time;
uint16_t delay;
lv_style_selector_t selector;
lv_style_prop_t prop;
lv_anim_path_cb_t path_cb;
void * user_data;
} _lv_obj_style_transition_dsc_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the object related style manager module.
* Called by LVGL in `lv_init()`
*/
void _lv_obj_style_init(void);
/**
* Deinitialize the object related style manager module.
* Called by LVGL in `lv_deinit()`
*/
void _lv_obj_style_deinit(void);
/**
* Add a style to an object.
* @param obj pointer to an object
@ -187,27 +147,7 @@ bool lv_obj_remove_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_sty
/**
* Used internally for color filtering
*/
lv_style_value_t _lv_obj_style_apply_color_filter(const lv_obj_t * obj, lv_part_t part, lv_style_value_t v);
/**
* Used internally to create a style transition
* @param obj
* @param part
* @param prev_state
* @param new_state
* @param tr
*/
void _lv_obj_style_create_transition(lv_obj_t * obj, lv_part_t part, lv_state_t prev_state,
lv_state_t new_state, const _lv_obj_style_transition_dsc_t * tr);
/**
* Used internally to compare the appearance of an object in 2 states
* @param obj
* @param state1
* @param state2
* @return
*/
_lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t state1, lv_state_t state2);
lv_style_value_t lv_obj_style_apply_color_filter(const lv_obj_t * obj, lv_part_t part, lv_style_value_t v);
/**
* Fade in an an object and all its children.
@ -351,13 +291,6 @@ static inline int32_t lv_obj_get_style_transform_scale_y_safe(const lv_obj_t * o
*/
lv_opa_t lv_obj_get_style_opa_recursive(const lv_obj_t * obj, lv_part_t part);
/**
* Update the layer type of a widget bayed on its current styles.
* The result will be stored in `obj->spec_attr->layer_type`
* @param obj the object whose layer should be updated
*/
void _lv_obj_update_layer_type(lv_obj_t * obj);
/**********************
* MACROS
**********************/

View File

@ -17,6 +17,7 @@ extern "C" {
#include "../misc/lv_area.h"
#include "../misc/lv_style.h"
#include "../core/lv_obj_style.h"
#include "../misc/lv_types.h"
static inline int32_t lv_obj_get_style_width(const lv_obj_t * obj, lv_part_t part)
{
@ -212,7 +213,7 @@ static inline lv_color_t lv_obj_get_style_bg_color(const lv_obj_t * obj, lv_part
static inline lv_color_t lv_obj_get_style_bg_color_filtered(const lv_obj_t * obj, lv_part_t part)
{
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_BG_COLOR));
lv_style_value_t v = lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_BG_COLOR));
return v.color;
}
@ -230,7 +231,8 @@ static inline lv_color_t lv_obj_get_style_bg_grad_color(const lv_obj_t * obj, lv
static inline lv_color_t lv_obj_get_style_bg_grad_color_filtered(const lv_obj_t * obj, lv_part_t part)
{
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_COLOR));
lv_style_value_t v = lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part,
LV_STYLE_BG_GRAD_COLOR));
return v.color;
}
@ -290,7 +292,8 @@ static inline lv_color_t lv_obj_get_style_bg_image_recolor(const lv_obj_t * obj,
static inline lv_color_t lv_obj_get_style_bg_image_recolor_filtered(const lv_obj_t * obj, lv_part_t part)
{
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMAGE_RECOLOR));
lv_style_value_t v = lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part,
LV_STYLE_BG_IMAGE_RECOLOR));
return v.color;
}
@ -314,7 +317,8 @@ static inline lv_color_t lv_obj_get_style_border_color(const lv_obj_t * obj, lv_
static inline lv_color_t lv_obj_get_style_border_color_filtered(const lv_obj_t * obj, lv_part_t part)
{
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_COLOR));
lv_style_value_t v = lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part,
LV_STYLE_BORDER_COLOR));
return v.color;
}
@ -356,7 +360,8 @@ static inline lv_color_t lv_obj_get_style_outline_color(const lv_obj_t * obj, lv
static inline lv_color_t lv_obj_get_style_outline_color_filtered(const lv_obj_t * obj, lv_part_t part)
{
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_COLOR));
lv_style_value_t v = lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part,
LV_STYLE_OUTLINE_COLOR));
return v.color;
}
@ -404,7 +409,8 @@ static inline lv_color_t lv_obj_get_style_shadow_color(const lv_obj_t * obj, lv_
static inline lv_color_t lv_obj_get_style_shadow_color_filtered(const lv_obj_t * obj, lv_part_t part)
{
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_COLOR));
lv_style_value_t v = lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part,
LV_STYLE_SHADOW_COLOR));
return v.color;
}
@ -428,7 +434,8 @@ static inline lv_color_t lv_obj_get_style_image_recolor(const lv_obj_t * obj, lv
static inline lv_color_t lv_obj_get_style_image_recolor_filtered(const lv_obj_t * obj, lv_part_t part)
{
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_IMAGE_RECOLOR));
lv_style_value_t v = lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part,
LV_STYLE_IMAGE_RECOLOR));
return v.color;
}
@ -470,7 +477,7 @@ static inline lv_color_t lv_obj_get_style_line_color(const lv_obj_t * obj, lv_pa
static inline lv_color_t lv_obj_get_style_line_color_filtered(const lv_obj_t * obj, lv_part_t part)
{
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_COLOR));
lv_style_value_t v = lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_COLOR));
return v.color;
}
@ -500,7 +507,7 @@ static inline lv_color_t lv_obj_get_style_arc_color(const lv_obj_t * obj, lv_par
static inline lv_color_t lv_obj_get_style_arc_color_filtered(const lv_obj_t * obj, lv_part_t part)
{
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_ARC_COLOR));
lv_style_value_t v = lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_ARC_COLOR));
return v.color;
}
@ -524,7 +531,7 @@ static inline lv_color_t lv_obj_get_style_text_color(const lv_obj_t * obj, lv_pa
static inline lv_color_t lv_obj_get_style_text_color_filtered(const lv_obj_t * obj, lv_part_t part)
{
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_COLOR));
lv_style_value_t v = lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_COLOR));
return v.color;
}

View File

@ -0,0 +1,95 @@
/**
* @file lv_obj_style_private.h
*
*/
#ifndef LV_OBJ_STYLE_PRIVATE_H
#define LV_OBJ_STYLE_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_obj_style.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
struct lv_obj_style_t {
const lv_style_t * style;
uint32_t selector : 24;
uint32_t is_local : 1;
uint32_t is_trans : 1;
};
struct lv_obj_style_transition_dsc_t {
uint16_t time;
uint16_t delay;
lv_style_selector_t selector;
lv_style_prop_t prop;
lv_anim_path_cb_t path_cb;
void * user_data;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the object related style manager module.
* Called by LVGL in `lv_init()`
*/
void lv_obj_style_init(void);
/**
* Deinitialize the object related style manager module.
* Called by LVGL in `lv_deinit()`
*/
void lv_obj_style_deinit(void);
/**
* Used internally to create a style transition
* @param obj
* @param part
* @param prev_state
* @param new_state
* @param tr
*/
void lv_obj_style_create_transition(lv_obj_t * obj, lv_part_t part, lv_state_t prev_state,
lv_state_t new_state, const lv_obj_style_transition_dsc_t * tr);
/**
* Used internally to compare the appearance of an object in 2 states
* @param obj
* @param state1
* @param state2
* @return
*/
lv_style_state_cmp_t lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t state1, lv_state_t state2);
/**
* Update the layer type of a widget bayed on its current styles.
* The result will be stored in `obj->spec_attr->layer_type`
* @param obj the object whose layer should be updated
*/
void lv_obj_update_layer_type(lv_obj_t * obj);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_OBJ_STYLE_PRIVATE_H*/

View File

@ -6,12 +6,13 @@
/*********************
* INCLUDES
*********************/
#include "lv_obj.h"
#include "lv_obj_class_private.h"
#include "lv_obj_private.h"
#include "../indev/lv_indev.h"
#include "../indev/lv_indev_private.h"
#include "../display/lv_display.h"
#include "../display/lv_display_private.h"
#include "../misc/lv_anim.h"
#include "../misc/lv_anim_private.h"
#include "../misc/lv_async.h"
#include "../core/lv_global.h"
@ -308,7 +309,7 @@ lv_display_t * lv_obj_get_display(const lv_obj_t * obj)
lv_display_t * d;
lv_ll_t * disp_head = disp_ll_p;
_LV_LL_READ(disp_head, d) {
LV_LL_READ(disp_head, d) {
uint32_t i;
for(i = 0; i < d->screen_cnt; i++) {
if(d->screens[i] == scr) return d;
@ -555,7 +556,7 @@ static void obj_delete_core(lv_obj_t * obj)
}
/*All children deleted. Now clean up the object specific data*/
_lv_obj_destruct(obj);
lv_obj_destruct(obj);
/*Remove the screen for the screen list*/
if(obj->parent == NULL) {

View File

@ -6,15 +6,21 @@
/*********************
* INCLUDES
*********************/
#include "lv_refr.h"
#include "../misc/lv_area_private.h"
#include "../draw/sw/lv_draw_sw_mask_private.h"
#include "../draw/lv_draw_mask_private.h"
#include "lv_obj_private.h"
#include "lv_obj_event_private.h"
#include "lv_obj_draw_private.h"
#include "lv_refr_private.h"
#include "../display/lv_display.h"
#include "../display/lv_display_private.h"
#include "../tick/lv_tick.h"
#include "../misc/lv_timer.h"
#include "../misc/lv_timer_private.h"
#include "../misc/lv_math.h"
#include "../misc/lv_profiler.h"
#include "../misc/lv_types.h"
#include "../draw/lv_draw.h"
#include "../draw/lv_draw_private.h"
#include "../font/lv_font_fmt_txt.h"
#include "../stdlib/lv_string.h"
#include "lv_global.h"
@ -66,11 +72,11 @@ static void wait_for_flushing(lv_display_t * disp);
/**
* Initialize the screen refresh subsystem
*/
void _lv_refr_init(void)
void lv_refr_init(void)
{
}
void _lv_refr_deinit(void)
void lv_refr_deinit(void)
{
}
@ -79,13 +85,13 @@ void lv_refr_now(lv_display_t * disp)
lv_anim_refr_now();
if(disp) {
if(disp->refr_timer) _lv_display_refr_timer(disp->refr_timer);
if(disp->refr_timer) lv_display_refr_timer(disp->refr_timer);
}
else {
lv_display_t * d;
d = lv_display_get_next(NULL);
while(d) {
if(d->refr_timer) _lv_display_refr_timer(d->refr_timer);
if(d->refr_timer) lv_display_refr_timer(d->refr_timer);
d = lv_display_get_next(d);
}
}
@ -99,10 +105,10 @@ void lv_obj_redraw(lv_layer_t * layer, lv_obj_t * obj)
/*Truncate the clip area to `obj size + ext size` area*/
lv_area_t obj_coords_ext;
lv_obj_get_coords(obj, &obj_coords_ext);
int32_t ext_draw_size = _lv_obj_get_ext_draw_size(obj);
int32_t ext_draw_size = lv_obj_get_ext_draw_size(obj);
lv_area_increase(&obj_coords_ext, ext_draw_size, ext_draw_size);
if(!_lv_area_intersect(&clip_coords_for_obj, &clip_area_ori, &obj_coords_ext)) return;
if(!lv_area_intersect(&clip_coords_for_obj, &clip_area_ori, &obj_coords_ext)) return;
/*If the object is visible on the current clip area*/
layer->_clip_area = clip_coords_for_obj;
@ -130,7 +136,7 @@ void lv_obj_redraw(lv_layer_t * layer, lv_obj_t * obj)
}
lv_area_t clip_coords_for_children;
bool refr_children = true;
if(!_lv_area_intersect(&clip_coords_for_children, &clip_area_ori, obj_coords)) {
if(!lv_area_intersect(&clip_coords_for_children, &clip_area_ori, obj_coords)) {
refr_children = false;
}
@ -183,7 +189,7 @@ void lv_obj_redraw(lv_layer_t * layer, lv_obj_t * obj)
lv_area_t bottom = obj->coords;
bottom.y1 = bottom.y2 - rout + 1;
if(_lv_area_intersect(&bottom, &bottom, &clip_area_ori)) {
if(lv_area_intersect(&bottom, &bottom, &clip_area_ori)) {
layer_children = lv_draw_layer_create(layer, LV_COLOR_FORMAT_ARGB8888, &bottom);
for(i = 0; i < child_cnt; i++) {
@ -204,7 +210,7 @@ void lv_obj_redraw(lv_layer_t * layer, lv_obj_t * obj)
lv_area_t top = obj->coords;
top.y2 = top.y1 + rout - 1;
if(_lv_area_intersect(&top, &top, &clip_area_ori)) {
if(lv_area_intersect(&top, &top, &clip_area_ori)) {
layer_children = lv_draw_layer_create(layer, LV_COLOR_FORMAT_ARGB8888, &top);
for(i = 0; i < child_cnt; i++) {
@ -227,7 +233,7 @@ void lv_obj_redraw(lv_layer_t * layer, lv_obj_t * obj)
lv_area_t mid = obj->coords;
mid.y1 += rout;
mid.y2 -= rout;
if(_lv_area_intersect(&mid, &mid, &clip_area_ori)) {
if(lv_area_intersect(&mid, &mid, &clip_area_ori)) {
layer->_clip_area = mid;
for(i = 0; i < child_cnt; i++) {
lv_obj_t * child = obj->spec_attr->children[i];
@ -248,7 +254,7 @@ void lv_obj_redraw(lv_layer_t * layer, lv_obj_t * obj)
layer->_clip_area = clip_area_ori;
}
void _lv_inv_area(lv_display_t * disp, const lv_area_t * area_p)
void lv_inv_area(lv_display_t * disp, const lv_area_t * area_p)
{
if(!disp) disp = lv_display_get_default();
if(!disp) return;
@ -282,7 +288,7 @@ void _lv_inv_area(lv_display_t * disp, const lv_area_t * area_p)
lv_area_t com_area;
bool suc;
suc = _lv_area_intersect(&com_area, area_p, &scr_area);
suc = lv_area_intersect(&com_area, area_p, &scr_area);
if(suc == false) return; /*Out of the screen*/
/*If there were at least 1 invalid area in full refresh mode, redraw the whole screen*/
@ -299,7 +305,7 @@ void _lv_inv_area(lv_display_t * disp, const lv_area_t * area_p)
/*Save only if this area is not in one of the saved areas*/
uint16_t i;
for(i = 0; i < disp->inv_p; i++) {
if(_lv_area_is_in(&com_area, &disp->inv_areas[i], 0) != false) return;
if(lv_area_is_in(&com_area, &disp->inv_areas[i], 0) != false) return;
}
/*Save the area*/
@ -318,7 +324,7 @@ void _lv_inv_area(lv_display_t * disp, const lv_area_t * area_p)
* Get the display which is being refreshed
* @return the display being refreshed
*/
lv_display_t * _lv_refr_get_disp_refreshing(void)
lv_display_t * lv_refr_get_disp_refreshing(void)
{
return disp_refr;
}
@ -327,12 +333,12 @@ lv_display_t * _lv_refr_get_disp_refreshing(void)
* Get the display which is being refreshed
* @return the display being refreshed
*/
void _lv_refr_set_disp_refreshing(lv_display_t * disp)
void lv_refr_set_disp_refreshing(lv_display_t * disp)
{
disp_refr = disp;
}
void _lv_display_refr_timer(lv_timer_t * tmr)
void lv_display_refr_timer(lv_timer_t * tmr)
{
LV_PROFILER_BEGIN;
LV_TRACE_REFR("begin");
@ -397,7 +403,7 @@ void _lv_display_refr_timer(lv_timer_t * tmr)
if(disp_refr->inv_area_joined[i])
continue;
lv_area_t * sync_area = _lv_ll_ins_tail(&disp_refr->sync_areas);
lv_area_t * sync_area = lv_ll_ins_tail(&disp_refr->sync_areas);
*sync_area = disp_refr->inv_areas[i];
}
}
@ -409,7 +415,7 @@ void _lv_display_refr_timer(lv_timer_t * tmr)
refr_finish:
#if LV_DRAW_SW_COMPLEX == 1
_lv_draw_sw_mask_cleanup();
lv_draw_sw_mask_cleanup();
#endif
lv_display_send_event(disp_refr, LV_EVENT_REFR_READY, NULL);
@ -442,11 +448,11 @@ static void lv_refr_join_area(void)
}
/*Check if the areas are on each other*/
if(_lv_area_is_on(&disp_refr->inv_areas[join_in], &disp_refr->inv_areas[join_from]) == false) {
if(lv_area_is_on(&disp_refr->inv_areas[join_in], &disp_refr->inv_areas[join_from]) == false) {
continue;
}
_lv_area_join(&joined_area, &disp_refr->inv_areas[join_in], &disp_refr->inv_areas[join_from]);
lv_area_join(&joined_area, &disp_refr->inv_areas[join_in], &disp_refr->inv_areas[join_from]);
/*Join two area only if the joined area size is smaller*/
if(lv_area_get_size(&joined_area) < (lv_area_get_size(&disp_refr->inv_areas[join_in]) +
@ -473,7 +479,7 @@ static void refr_sync_areas(void)
if(!lv_display_is_double_buffered(disp_refr)) return;
/*Do not sync if no sync areas*/
if(_lv_ll_is_empty(&disp_refr->sync_areas)) return;
if(lv_ll_is_empty(&disp_refr->sync_areas)) return;
LV_PROFILER_BEGIN;
/*With double buffered direct mode synchronize the rendered areas to the other buffer*/
@ -499,22 +505,22 @@ static void refr_sync_areas(void)
if(disp_refr->inv_area_joined[i]) continue;
/*Iterate over sync areas*/
sync_area = _lv_ll_get_head(&disp_refr->sync_areas);
sync_area = lv_ll_get_head(&disp_refr->sync_areas);
while(sync_area != NULL) {
/*Get next sync area*/
next_area = _lv_ll_get_next(&disp_refr->sync_areas, sync_area);
next_area = lv_ll_get_next(&disp_refr->sync_areas, sync_area);
/*Remove intersect of redraw area from sync area and get remaining areas*/
res_c = _lv_area_diff(res, sync_area, &disp_refr->inv_areas[i]);
res_c = lv_area_diff(res, sync_area, &disp_refr->inv_areas[i]);
/*New sub areas created after removing intersect*/
if(res_c != -1) {
/*Replace old sync area with new areas*/
for(j = 0; j < res_c; j++) {
new_area = _lv_ll_ins_prev(&disp_refr->sync_areas, sync_area);
new_area = lv_ll_ins_prev(&disp_refr->sync_areas, sync_area);
*new_area = res[j];
}
_lv_ll_remove(&disp_refr->sync_areas, sync_area);
lv_ll_remove(&disp_refr->sync_areas, sync_area);
lv_free(sync_area);
}
@ -525,17 +531,17 @@ static void refr_sync_areas(void)
lv_area_t disp_area = {0, 0, (int32_t)hor_res - 1, (int32_t)ver_res - 1};
/*Copy sync areas (if any remaining)*/
for(sync_area = _lv_ll_get_head(&disp_refr->sync_areas); sync_area != NULL;
sync_area = _lv_ll_get_next(&disp_refr->sync_areas, sync_area)) {
for(sync_area = lv_ll_get_head(&disp_refr->sync_areas); sync_area != NULL;
sync_area = lv_ll_get_next(&disp_refr->sync_areas, sync_area)) {
/**
* @todo Resize SDL window will trigger crash because of sync_area is larger than disp_area
*/
_lv_area_intersect(sync_area, sync_area, &disp_area);
lv_area_intersect(sync_area, sync_area, &disp_area);
lv_draw_buf_copy(off_screen, sync_area, on_screen, sync_area);
}
/*Clear sync areas*/
_lv_ll_clear(&disp_refr->sync_areas);
lv_ll_clear(&disp_refr->sync_areas);
LV_PROFILER_END;
}
@ -753,9 +759,9 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj)
{
lv_obj_t * found_p = NULL;
if(_lv_area_is_in(area_p, &obj->coords, 0) == false) return NULL;
if(lv_area_is_in(area_p, &obj->coords, 0) == false) return NULL;
if(lv_obj_has_flag(obj, LV_OBJ_FLAG_HIDDEN)) return NULL;
if(_lv_obj_get_layer_type(obj) != LV_LAYER_TYPE_NONE) return NULL;
if(lv_obj_get_layer_type(obj) != LV_LAYER_TYPE_NONE) return NULL;
/*If this object is fully cover the draw area then check the children too*/
lv_cover_check_info_t info;
@ -840,7 +846,7 @@ static void refr_obj_and_children(lv_layer_t * layer, lv_obj_t * top_obj)
static lv_result_t layer_get_area(lv_layer_t * layer, lv_obj_t * obj, lv_layer_type_t layer_type,
lv_area_t * layer_area_out, lv_area_t * obj_draw_size_out)
{
int32_t ext_draw_size = _lv_obj_get_ext_draw_size(obj);
int32_t ext_draw_size = lv_obj_get_ext_draw_size(obj);
lv_obj_get_coords(obj, obj_draw_size_out);
lv_area_increase(obj_draw_size_out, ext_draw_size, ext_draw_size);
@ -850,7 +856,7 @@ static lv_result_t layer_get_area(lv_layer_t * layer, lv_obj_t * obj, lv_layer_t
lv_area_t clip_coords_for_obj;
lv_area_t tranf_coords = *obj_draw_size_out;
lv_obj_get_transformed_area(obj, &tranf_coords, LV_OBJ_POINT_TRANSFORM_FLAG_NONE);
if(!_lv_area_intersect(&clip_coords_for_obj, &layer->_clip_area, &tranf_coords)) {
if(!lv_area_intersect(&clip_coords_for_obj, &layer->_clip_area, &tranf_coords)) {
return LV_RESULT_INVALID;
}
@ -859,7 +865,7 @@ static lv_result_t layer_get_area(lv_layer_t * layer, lv_obj_t * obj, lv_layer_t
*in order to cover transformed area after transformation.*/
lv_area_t inverse_clip_coords_for_obj = clip_coords_for_obj;
lv_obj_get_transformed_area(obj, &inverse_clip_coords_for_obj, LV_OBJ_POINT_TRANSFORM_FLAG_INVERSE);
if(!_lv_area_intersect(&inverse_clip_coords_for_obj, &inverse_clip_coords_for_obj, obj_draw_size_out)) {
if(!lv_area_intersect(&inverse_clip_coords_for_obj, &inverse_clip_coords_for_obj, obj_draw_size_out)) {
return LV_RESULT_INVALID;
}
@ -868,7 +874,7 @@ static lv_result_t layer_get_area(lv_layer_t * layer, lv_obj_t * obj, lv_layer_t
}
else if(layer_type == LV_LAYER_TYPE_SIMPLE) {
lv_area_t clip_coords_for_obj;
if(!_lv_area_intersect(&clip_coords_for_obj, &layer->_clip_area, obj_draw_size_out)) {
if(!lv_area_intersect(&clip_coords_for_obj, &layer->_clip_area, obj_draw_size_out)) {
return LV_RESULT_INVALID;
}
*layer_area_out = clip_coords_for_obj;
@ -885,7 +891,7 @@ static bool alpha_test_area_on_obj(lv_obj_t * obj, const lv_area_t * area)
{
/*Test for alpha by assuming there is no alpha. If it fails, fall back to rendering with alpha*/
/*If the layer area is not fully on the object, it can't fully cover it*/
if(!_lv_area_is_on(area, &obj->coords)) return true;
if(!lv_area_is_on(area, &obj->coords)) return true;
lv_cover_check_info_t info;
info.res = LV_COVER_RES_COVER;
@ -972,14 +978,14 @@ static bool refr_check_obj_clip_overflow(lv_layer_t * layer, lv_obj_t * obj)
/*Truncate the area to the object*/
lv_area_t obj_coords;
int32_t ext_size = _lv_obj_get_ext_draw_size(obj);
int32_t ext_size = lv_obj_get_ext_draw_size(obj);
lv_area_copy(&obj_coords, &obj->coords);
lv_area_increase(&obj_coords, ext_size, ext_size);
lv_obj_get_transformed_area(obj, &obj_coords, LV_OBJ_POINT_TRANSFORM_FLAG_RECURSIVE);
lv_area_t clip_coords_for_obj;
if(!_lv_area_intersect(&clip_coords_for_obj, &layer->_clip_area, &obj_coords)) {
if(!lv_area_intersect(&clip_coords_for_obj, &layer->_clip_area, &obj_coords)) {
return false;
}
@ -1004,7 +1010,7 @@ static void refr_obj(lv_layer_t * layer, lv_obj_t * obj)
}
#endif /* LV_DRAW_TRANSFORM_USE_MATRIX */
lv_layer_type_t layer_type = _lv_obj_get_layer_type(obj);
lv_layer_type_t layer_type = lv_obj_get_layer_type(obj);
if(layer_type == LV_LAYER_TYPE_NONE) {
lv_obj_redraw(layer, obj);
}

View File

@ -41,16 +41,6 @@ extern "C" {
* GLOBAL FUNCTIONS
**********************/
/**
* Initialize the screen refresh subsystem
*/
void _lv_refr_init(void);
/**
* Deinitialize the screen refresh subsystem
*/
void _lv_refr_deinit(void);
/**
* Redraw the invalidated areas now.
* Normally the redrawing is periodically executed in `lv_timer_handler` but a long blocking process
@ -67,32 +57,6 @@ void lv_refr_now(lv_display_t * disp);
*/
void lv_obj_redraw(lv_layer_t * layer, lv_obj_t * obj);
/**
* Invalidate an area on display to redraw it
* @param area_p pointer to area which should be invalidated (NULL: delete the invalidated areas)
* @param disp pointer to display where the area should be invalidated (NULL can be used if there is
* only one display)
*/
void _lv_inv_area(lv_display_t * disp, const lv_area_t * area_p);
/**
* Get the display which is being refreshed
* @return the display being refreshed
*/
lv_display_t * _lv_refr_get_disp_refreshing(void);
/**
* Set the display which is being refreshed
* @param disp the display being refreshed
*/
void _lv_refr_set_disp_refreshing(lv_display_t * disp);
/**
* Called periodically to handle the refreshing
* @param timer pointer to the timer itself
*/
void _lv_display_refr_timer(lv_timer_t * timer);
/**********************
* STATIC FUNCTIONS
**********************/

View File

@ -0,0 +1,75 @@
/**
* @file lv_refr_private.h
*
*/
#ifndef LV_REFR_PRIVATE_H
#define LV_REFR_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_refr.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the screen refresh subsystem
*/
void lv_refr_init(void);
/**
* Deinitialize the screen refresh subsystem
*/
void lv_refr_deinit(void);
/**
* Invalidate an area on display to redraw it
* @param area_p pointer to area which should be invalidated (NULL: delete the invalidated areas)
* @param disp pointer to display where the area should be invalidated (NULL can be used if there is
* only one display)
*/
void lv_inv_area(lv_display_t * disp, const lv_area_t * area_p);
/**
* Get the display which is being refreshed
* @return the display being refreshed
*/
lv_display_t * lv_refr_get_disp_refreshing(void);
/**
* Set the display which is being refreshed
* @param disp the display being refreshed
*/
void lv_refr_set_disp_refreshing(lv_display_t * disp);
/**
* Called periodically to handle the refreshing
* @param timer pointer to the timer itself
*/
void lv_display_refr_timer(lv_timer_t * timer);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_REFR_PRIVATE_H*/

View File

@ -6,9 +6,13 @@
/*********************
* INCLUDES
*********************/
#include "../misc/lv_event_private.h"
#include "../misc/lv_anim_private.h"
#include "../draw/lv_draw_private.h"
#include "../core/lv_obj_private.h"
#include "lv_display.h"
#include "../misc/lv_math.h"
#include "../core/lv_refr.h"
#include "../core/lv_refr_private.h"
#include "../display/lv_display_private.h"
#include "../stdlib/lv_string.h"
#include "../themes/lv_theme.h"
@ -57,7 +61,7 @@ static void disp_event_cb(lv_event_t * e);
lv_display_t * lv_display_create(int32_t hor_res, int32_t ver_res)
{
lv_display_t * disp = _lv_ll_ins_head(disp_ll_p);
lv_display_t * disp = lv_ll_ins_head(disp_ll_p);
LV_ASSERT_MALLOC(disp);
if(!disp) return NULL;
@ -87,13 +91,13 @@ lv_display_t * lv_display_create(int32_t hor_res, int32_t ver_res)
disp->inv_en_cnt = 1;
disp->last_activity_time = lv_tick_get();
_lv_ll_init(&disp->sync_areas, sizeof(lv_area_t));
lv_ll_init(&disp->sync_areas, sizeof(lv_area_t));
lv_display_t * disp_def_tmp = disp_def;
disp_def = disp; /*Temporarily change the default screen to create the default screens on the
new display*/
/*Create a refresh timer*/
disp->refr_timer = lv_timer_create(_lv_display_refr_timer, LV_DEF_REFR_PERIOD, disp);
disp->refr_timer = lv_timer_create(lv_display_refr_timer, LV_DEF_REFR_PERIOD, disp);
LV_ASSERT_MALLOC(disp->refr_timer);
if(disp->refr_timer == NULL) {
lv_free(disp);
@ -191,8 +195,8 @@ void lv_display_delete(lv_display_t * disp)
lv_obj_delete(disp->screens[0]);
}
_lv_ll_clear(&disp->sync_areas);
_lv_ll_remove(disp_ll_p, disp);
lv_ll_clear(&disp->sync_areas);
lv_ll_remove(disp_ll_p, disp);
if(disp->refr_timer) lv_timer_delete(disp->refr_timer);
if(disp->layer_deinit) disp->layer_deinit(disp, disp->layer_head);
@ -200,7 +204,7 @@ void lv_display_delete(lv_display_t * disp)
lv_free(disp);
if(was_default) lv_display_set_default(_lv_ll_get_head(disp_ll_p));
if(was_default) lv_display_set_default(lv_ll_get_head(disp_ll_p));
}
void lv_display_set_default(lv_display_t * disp)
@ -216,9 +220,9 @@ lv_display_t * lv_display_get_default(void)
lv_display_t * lv_display_get_next(lv_display_t * disp)
{
if(disp == NULL)
return _lv_ll_get_head(disp_ll_p);
return lv_ll_get_head(disp_ll_p);
else
return _lv_ll_get_next(disp_ll_p, disp);
return lv_ll_get_next(disp_ll_p, disp);
}
/*---------------------
@ -570,7 +574,7 @@ lv_obj_t * lv_display_get_layer_bottom(lv_display_t * disp)
return disp->bottom_layer;
}
void lv_screen_load(struct _lv_obj_t * scr)
void lv_screen_load(struct lv_obj_t * scr)
{
lv_screen_load_anim(scr, LV_SCR_LOAD_ANIM_NONE, 0, 0, false);
}
@ -962,6 +966,36 @@ void lv_display_rotate_area(lv_display_t * disp, lv_area_t * area)
}
}
lv_obj_t * lv_screen_active(void)
{
return lv_display_get_screen_active(lv_display_get_default());
}
lv_obj_t * lv_layer_top(void)
{
return lv_display_get_layer_top(lv_display_get_default());
}
lv_obj_t * lv_layer_sys(void)
{
return lv_display_get_layer_sys(lv_display_get_default());
}
lv_obj_t * lv_layer_bottom(void)
{
return lv_display_get_layer_bottom(lv_display_get_default());
}
int32_t lv_dpx(int32_t n)
{
return LV_DPX(n);
}
int32_t lv_display_dpx(const lv_display_t * disp, int32_t n)
{
return LV_DPX_CALC(lv_display_get_dpi(disp), n);
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@ -374,7 +374,7 @@ lv_obj_t * lv_display_get_layer_bottom(lv_display_t * disp);
* Load a screen on the default display
* @param scr pointer to a screen
*/
void lv_screen_load(struct _lv_obj_t * scr);
void lv_screen_load(struct lv_obj_t * scr);
/**
* Switch screen with animation
@ -391,37 +391,25 @@ void lv_screen_load_anim(lv_obj_t * scr, lv_screen_load_anim_t anim_type, uint32
* Get the active screen of the default display
* @return pointer to the active screen
*/
static inline lv_obj_t * lv_screen_active(void)
{
return lv_display_get_screen_active(lv_display_get_default());
}
lv_obj_t * lv_screen_active(void);
/**
* Get the top layer of the default display
* @return pointer to the top layer
*/
static inline lv_obj_t * lv_layer_top(void)
{
return lv_display_get_layer_top(lv_display_get_default());
}
lv_obj_t * lv_layer_top(void);
/**
* Get the system layer of the default display
* @return pointer to the sys layer
*/
static inline lv_obj_t * lv_layer_sys(void)
{
return lv_display_get_layer_sys(lv_display_get_default());
}
lv_obj_t * lv_layer_sys(void);
/**
* Get the bottom layer of the default display
* @return pointer to the bottom layer
*/
static inline lv_obj_t * lv_layer_bottom(void)
{
return lv_display_get_layer_bottom(lv_display_get_default());
}
lv_obj_t * lv_layer_bottom(void);
/*---------------------
* OTHERS
@ -574,8 +562,8 @@ void lv_display_rotate_area(lv_display_t * disp, lv_area_t * area);
* 1 dip is 2 px on a 320 DPI screen
* https://stackoverflow.com/questions/2025282/what-is-the-difference-between-px-dip-dp-and-sp
*/
#define _LV_DPX_CALC(dpi, n) ((n) == 0 ? 0 :LV_MAX((( (dpi) * (n) + 80) / 160), 1)) /*+80 for rounding*/
#define LV_DPX(n) _LV_DPX_CALC(lv_display_get_dpi(NULL), n)
#define LV_DPX_CALC(dpi, n) ((n) == 0 ? 0 :LV_MAX((( (dpi) * (n) + 80) / 160), 1)) /*+80 for rounding*/
#define LV_DPX(n) LV_DPX_CALC(lv_display_get_dpi(NULL), n)
/**
* Scale the given number of pixels (a distance or size) relative to a 160 DPI display
@ -585,10 +573,7 @@ void lv_display_rotate_area(lv_display_t * disp, lv_area_t * area);
* @param n the number of pixels to scale
* @return `n x current_dpi/160`
*/
static inline int32_t lv_dpx(int32_t n)
{
return LV_DPX(n);
}
int32_t lv_dpx(int32_t n);
/**
* Scale the given number of pixels (a distance or size) relative to a 160 DPI display
@ -599,10 +584,7 @@ static inline int32_t lv_dpx(int32_t n)
* @param n the number of pixels to scale
* @return `n x current_dpi/160`
*/
static inline int32_t lv_display_dpx(const lv_display_t * disp, int32_t n)
{
return _LV_DPX_CALC(lv_display_get_dpi(disp), n);
}
int32_t lv_display_dpx(const lv_display_t * disp, int32_t n);
#ifdef __cplusplus
} /*extern "C"*/

View File

@ -19,7 +19,7 @@ extern "C" {
#include "lv_display.h"
#if LV_USE_SYSMON
#include "../others/sysmon/lv_sysmon.h"
#include "../others/sysmon/lv_sysmon_private.h"
#endif
/*********************
@ -33,7 +33,7 @@ extern "C" {
* TYPEDEFS
**********************/
struct _lv_display_t {
struct lv_display_t {
/*---------------------
* Resolution

View File

@ -6,11 +6,12 @@
/*********************
* INCLUDES
*********************/
#include "lv_draw.h"
#include "../misc/lv_area_private.h"
#include "lv_draw_private.h"
#include "sw/lv_draw_sw.h"
#include "../display/lv_display_private.h"
#include "../core/lv_global.h"
#include "../core/lv_refr.h"
#include "../core/lv_refr_private.h"
#include "../stdlib/lv_string.h"
/*********************
@ -289,8 +290,8 @@ lv_draw_task_t * lv_draw_get_next_available_task(lv_layer_t * layer, lv_draw_tas
LV_PROFILER_BEGIN;
/*If the first task is screen sized, there cannot be independent areas*/
if(layer->draw_task_head) {
int32_t hor_res = lv_display_get_horizontal_resolution(_lv_refr_get_disp_refreshing());
int32_t ver_res = lv_display_get_vertical_resolution(_lv_refr_get_disp_refreshing());
int32_t hor_res = lv_display_get_horizontal_resolution(lv_refr_get_disp_refreshing());
int32_t ver_res = lv_display_get_vertical_resolution(lv_refr_get_disp_refreshing());
lv_draw_task_t * t = layer->draw_task_head;
if(t->state != LV_DRAW_TASK_STATE_QUEUED &&
t->area.x1 <= 0 && t->area.x2 >= hor_res - 1 &&
@ -327,7 +328,7 @@ uint32_t lv_draw_get_dependent_count(lv_draw_task_t * t_check)
lv_draw_task_t * t = t_check->next;
while(t) {
if((t->state == LV_DRAW_TASK_STATE_QUEUED || t->state == LV_DRAW_TASK_STATE_WAITING) &&
_lv_area_is_on(&t_check->area, &t->area)) {
lv_area_is_on(&t_check->area, &t->area)) {
cnt++;
}
@ -339,7 +340,7 @@ uint32_t lv_draw_get_dependent_count(lv_draw_task_t * t_check)
lv_layer_t * lv_draw_layer_create(lv_layer_t * parent_layer, lv_color_format_t color_format, const lv_area_t * area)
{
lv_display_t * disp = _lv_refr_get_disp_refreshing();
lv_display_t * disp = lv_refr_get_disp_refreshing();
lv_layer_t * new_layer = lv_malloc_zeroed(sizeof(lv_layer_t));
LV_ASSERT_MALLOC(new_layer);
if(new_layer == NULL) return NULL;
@ -399,6 +400,21 @@ void * lv_draw_layer_go_to_xy(lv_layer_t * layer, int32_t x, int32_t y)
return lv_draw_buf_goto_xy(layer->draw_buf, x, y);
}
lv_draw_task_type_t lv_draw_task_get_type(const lv_draw_task_t * t)
{
return t->type;
}
void * lv_draw_task_get_draw_dsc(const lv_draw_task_t * t)
{
return t->draw_dsc;
}
void lv_draw_task_get_area(const lv_draw_task_t * t, lv_area_t * area)
{
*area = t->area;
}
/**********************
* STATIC FUNCTIONS
**********************/
@ -418,7 +434,7 @@ static bool is_independent(lv_layer_t * layer, lv_draw_task_t * t_check)
while(t && t != t_check) {
if(t->state != LV_DRAW_TASK_STATE_READY) {
lv_area_t a;
if(_lv_area_intersect(&a, &t->_real_area, &t_check->_real_area)) {
if(lv_area_intersect(&a, &t->_real_area, &t_check->_real_area)) {
LV_PROFILER_END;
return false;
}

View File

@ -41,6 +41,7 @@ extern "C" {
**********************/
typedef enum {
LV_DRAW_TASK_TYPE_NONE = 0,
LV_DRAW_TASK_TYPE_FILL,
LV_DRAW_TASK_TYPE_BORDER,
LV_DRAW_TASK_TYPE_BOX_SHADOW,
@ -62,102 +63,7 @@ typedef enum {
LV_DRAW_TASK_STATE_READY,
} lv_draw_task_state_t;
struct _lv_draw_task_t {
lv_draw_task_t * next;
lv_draw_task_type_t type;
/**
* The area where to draw
*/
lv_area_t area;
/**
* The real draw area. E.g. for shadow, outline, or transformed images it's different from `area`
*/
lv_area_t _real_area;
/** The original area which is updated*/
lv_area_t clip_area_original;
/**
* The clip area of the layer is saved here when the draw task is created.
* As the clip area of the layer can be changed as new draw tasks are added its current value needs to be saved.
* Therefore during drawing the layer's clip area shouldn't be used as it might be already changed for other draw tasks.
*/
lv_area_t clip_area;
#if LV_DRAW_TRANSFORM_USE_MATRIX
/** Transform matrix to be applied when rendering the layer */
lv_matrix_t matrix;
#endif
volatile int state; /*int instead of lv_draw_task_state_t to be sure its atomic*/
void * draw_dsc;
/**
* The ID of the draw_unit which should take this task
*/
uint8_t preferred_draw_unit_id;
/**
* Set to which extent `preferred_draw_unit_id` is good at this task.
* 80: means 20% better (faster) than software rendering
* 100: the default value
* 110: means 10% worse (slower) than software rendering
*/
uint8_t preference_score;
};
typedef struct {
void * user_data;
} lv_draw_mask_t;
struct _lv_draw_unit_t {
lv_draw_unit_t * next;
/**
* The target_layer on which drawing should happen
*/
lv_layer_t * target_layer;
const lv_area_t * clip_area;
/**
* Called to try to assign a draw task to itself.
* `lv_draw_get_next_available_task` can be used to get an independent draw task.
* A draw task should be assign only if the draw unit can draw it too
* @param draw_unit pointer to the draw unit
* @param layer pointer to a layer on which the draw task should be drawn
* @return >=0: The number of taken draw task:
* 0 means the task has not yet been completed.
* 1 means a new task has been accepted.
* -1: The draw unit wanted to work on a task but couldn't do that
* due to some errors (e.g. out of memory).
* It signals that LVGL should call the dispatcher later again
* to let draw unit try to start the rendering again.
*/
int32_t (*dispatch_cb)(lv_draw_unit_t * draw_unit, lv_layer_t * layer);
/**
*
* @param draw_unit
* @param task
* @return
*/
int32_t (*evaluate_cb)(lv_draw_unit_t * draw_unit, lv_draw_task_t * task);
/**
* Called to delete draw unit.
* @param draw_unit
* @return
*/
int32_t (*delete_cb)(lv_draw_unit_t * draw_unit);
};
struct _lv_layer_t {
struct lv_layer_t {
/** Target draw buffer of the layer*/
lv_draw_buf_t * draw_buf;
@ -202,18 +108,6 @@ typedef struct {
void * user_data;
} lv_draw_dsc_base_t;
typedef struct {
lv_draw_unit_t * unit_head;
uint32_t used_memory_for_layers_kb;
#if LV_USE_OS
lv_thread_sync_t sync;
#else
int dispatch_req;
#endif
lv_mutex_t circle_cache_mutex;
bool task_running;
} lv_draw_global_info_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
@ -322,6 +216,27 @@ void * lv_draw_layer_alloc_buf(lv_layer_t * layer);
*/
void * lv_draw_layer_go_to_xy(lv_layer_t * layer, int32_t x, int32_t y);
/**
* Get the type of a draw task
* @param t the draw task to get the type of
* @return the draw task type
*/
lv_draw_task_type_t lv_draw_task_get_type(const lv_draw_task_t * t);
/**
* Get the draw descriptor of a draw task
* @param t the draw task to get the draw descriptor of
* @return a void pointer to the draw descriptor
*/
void * lv_draw_task_get_draw_dsc(const lv_draw_task_t * t);
/**
* Get the draw area of a draw task
* @param t the draw task to get the draw area of
* @param area the destination where the draw area will be stored
*/
void lv_draw_task_get_area(const lv_draw_task_t * t, lv_area_t * area);
/**********************
* GLOBAL VARIABLES
**********************/

View File

@ -6,6 +6,7 @@
/*********************
* INCLUDES
*********************/
#include "lv_draw_private.h"
#include "../core/lv_obj.h"
#include "lv_draw_arc.h"
#include "../core/lv_obj_event.h"

View File

@ -7,10 +7,11 @@
* INCLUDES
*********************/
#include "../misc/lv_types.h"
#include "lv_draw_buf.h"
#include "lv_draw_buf_private.h"
#include "../stdlib/lv_string.h"
#include "../core/lv_global.h"
#include "../misc/lv_math.h"
#include "../misc/lv_area_private.h"
/*********************
* DEFINES
@ -48,7 +49,7 @@ static void draw_buf_get_full_area(const lv_draw_buf_t * draw_buf, lv_area_t * f
* GLOBAL FUNCTIONS
**********************/
void _lv_draw_buf_init_handlers(void)
void lv_draw_buf_init_handlers(void)
{
lv_draw_buf_init_with_default_handlers(&default_handlers);
lv_draw_buf_init_with_default_handlers(&font_draw_buf_handlers);
@ -57,10 +58,10 @@ void _lv_draw_buf_init_handlers(void)
void lv_draw_buf_init_with_default_handlers(lv_draw_buf_handlers_t * handlers)
{
lv_draw_buf_init_handlers(handlers, buf_malloc, buf_free, buf_align, NULL, NULL, width_to_stride);
lv_draw_buf_handlers_init(handlers, buf_malloc, buf_free, buf_align, NULL, NULL, width_to_stride);
}
void lv_draw_buf_init_handlers(lv_draw_buf_handlers_t * handlers,
void lv_draw_buf_handlers_init(lv_draw_buf_handlers_t * handlers,
lv_draw_buf_malloc_cb buf_malloc_cb,
lv_draw_buf_free_cb buf_free_cb,
lv_draw_buf_align_cb align_pointer_cb,
@ -171,7 +172,7 @@ void lv_draw_buf_clear(lv_draw_buf_t * draw_buf, const lv_area_t * a)
a_draw_buf.y2 = draw_buf->header.h - 1;
lv_area_t a_clipped;
if(!_lv_area_intersect(&a_clipped, a, &a_draw_buf)) return;
if(!lv_area_intersect(&a_clipped, a, &a_draw_buf)) return;
if(lv_area_get_width(&a_clipped) <= 0) return;
if(lv_area_get_height(&a_clipped) <= 0) return;
@ -543,6 +544,49 @@ void lv_draw_buf_set_palette(lv_draw_buf_t * draw_buf, uint8_t index, lv_color32
palette[index] = color;
}
bool lv_draw_buf_has_flag(lv_draw_buf_t * draw_buf, lv_image_flags_t flag)
{
return draw_buf->header.flags & flag;
}
void lv_draw_buf_set_flag(lv_draw_buf_t * draw_buf, lv_image_flags_t flag)
{
draw_buf->header.flags |= flag;
}
void lv_draw_buf_clear_flag(lv_draw_buf_t * draw_buf, lv_image_flags_t flag)
{
draw_buf->header.flags &= ~flag;
}
void lv_draw_buf_from_image(lv_draw_buf_t * buf, const lv_image_dsc_t * img)
{
lv_memcpy(buf, img, sizeof(lv_image_dsc_t));
buf->unaligned_data = buf->data;
}
void lv_draw_buf_to_image(const lv_draw_buf_t * buf, lv_image_dsc_t * img)
{
lv_memcpy((void *)img, buf, sizeof(lv_image_dsc_t));
}
void lv_image_buf_set_palette(lv_image_dsc_t * dsc, uint8_t id, lv_color32_t c)
{
LV_LOG_WARN("Deprecated API, use lv_draw_buf_set_palette instead.");
lv_draw_buf_set_palette((lv_draw_buf_t *)dsc, id, c);
}
void lv_image_buf_free(lv_image_dsc_t * dsc)
{
LV_LOG_WARN("Deprecated API, use lv_draw_buf_destroy instead.");
if(dsc != NULL) {
if(dsc->data != NULL)
lv_free((void *)dsc->data);
lv_free((void *)dsc);
}
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@ -43,12 +43,12 @@ typedef struct {
* Refine it to suit your needs.
*/
#define _LV_DRAW_BUF_STRIDE(w, cf) \
#define LV_DRAW_BUF_STRIDE(w, cf) \
LV_ROUND_UP(((w) * LV_COLOR_FORMAT_GET_BPP(cf) + 7) / 8, LV_DRAW_BUF_STRIDE_ALIGN)
/* Allocate a slightly larger buffer, so we can adjust the start address to meet alignment */
#define _LV_DRAW_BUF_SIZE(w, h, cf) \
(_LV_DRAW_BUF_STRIDE(w, cf) * (h) + LV_DRAW_BUF_ALIGN + \
#define LV_DRAW_BUF_SIZE(w, h, cf) \
(LV_DRAW_BUF_STRIDE(w, cf) * (h) + LV_DRAW_BUF_ALIGN + \
LV_COLOR_INDEXED_PALETTE_SIZE(cf) * sizeof(lv_color32_t))
/**
@ -58,7 +58,7 @@ typedef struct {
* For platform that needs special buffer alignment, call LV_DRAW_BUF_INIT_STATIC.
*/
#define LV_DRAW_BUF_DEFINE_STATIC(name, _w, _h, _cf) \
static uint8_t buf_##name[_LV_DRAW_BUF_SIZE(_w, _h, _cf)]; \
static uint8_t buf_##name[LV_DRAW_BUF_SIZE(_w, _h, _cf)]; \
static lv_draw_buf_t name = { \
.header = { \
.magic = LV_IMAGE_HEADER_MAGIC, \
@ -66,7 +66,7 @@ typedef struct {
.flags = LV_IMAGE_FLAGS_MODIFIABLE, \
.w = (_w), \
.h = (_h), \
.stride = _LV_DRAW_BUF_STRIDE(_w, _cf), \
.stride = LV_DRAW_BUF_STRIDE(_w, _cf), \
.reserved_2 = 0, \
}, \
.data_size = sizeof(buf_##name), \
@ -91,24 +91,10 @@ typedef void (*lv_draw_buf_cache_operation_cb)(const lv_draw_buf_t * draw_buf, c
typedef uint32_t (*lv_draw_buf_width_to_stride_cb)(uint32_t w, lv_color_format_t color_format);
typedef struct {
lv_draw_buf_malloc_cb buf_malloc_cb;
lv_draw_buf_free_cb buf_free_cb;
lv_draw_buf_align_cb align_pointer_cb;
lv_draw_buf_cache_operation_cb invalidate_cache_cb;
lv_draw_buf_cache_operation_cb flush_cache_cb;
lv_draw_buf_width_to_stride_cb width_to_stride_cb;
} lv_draw_buf_handlers_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Called internally to initialize the draw_buf_handlers in lv_global
*/
void _lv_draw_buf_init_handlers(void);
/**
* Initialize the draw buffer with the default handlers.
*
@ -126,7 +112,7 @@ void lv_draw_buf_init_with_default_handlers(lv_draw_buf_handlers_t * handlers);
* @param invalidate_cache_cb the callback to invalidate the cache of the buffer
* @param width_to_stride_cb the callback to calculate the stride based on the width and color format
*/
void lv_draw_buf_init_handlers(lv_draw_buf_handlers_t * handlers,
void lv_draw_buf_handlers_init(lv_draw_buf_handlers_t * handlers,
lv_draw_buf_malloc_cb buf_malloc_cb,
lv_draw_buf_free_cb buf_free_cb,
lv_draw_buf_align_cb align_pointer_cb,
@ -341,36 +327,20 @@ lv_result_t lv_draw_buf_adjust_stride(lv_draw_buf_t * src, uint32_t stride);
*/
lv_result_t lv_draw_buf_premultiply(lv_draw_buf_t * draw_buf);
static inline bool lv_draw_buf_has_flag(lv_draw_buf_t * draw_buf, lv_image_flags_t flag)
{
return draw_buf->header.flags & flag;
}
bool lv_draw_buf_has_flag(lv_draw_buf_t * draw_buf, lv_image_flags_t flag);
static inline void lv_draw_buf_set_flag(lv_draw_buf_t * draw_buf, lv_image_flags_t flag)
{
draw_buf->header.flags |= flag;
}
void lv_draw_buf_set_flag(lv_draw_buf_t * draw_buf, lv_image_flags_t flag);
static inline void lv_draw_buf_clear_flag(lv_draw_buf_t * draw_buf, lv_image_flags_t flag)
{
draw_buf->header.flags &= ~flag;
}
void lv_draw_buf_clear_flag(lv_draw_buf_t * draw_buf, lv_image_flags_t flag);
/**
* As of now, draw buf share same definition as `lv_image_dsc_t`.
* And is interchangeable with `lv_image_dsc_t`.
*/
static inline void lv_draw_buf_from_image(lv_draw_buf_t * buf, const lv_image_dsc_t * img)
{
lv_memcpy(buf, img, sizeof(lv_image_dsc_t));
buf->unaligned_data = buf->data;
}
void lv_draw_buf_from_image(lv_draw_buf_t * buf, const lv_image_dsc_t * img);
static inline void lv_draw_buf_to_image(const lv_draw_buf_t * buf, lv_image_dsc_t * img)
{
lv_memcpy((void *)img, buf, sizeof(lv_image_dsc_t));
}
void lv_draw_buf_to_image(const lv_draw_buf_t * buf, lv_image_dsc_t * img);
/**
* Set the palette color of an indexed image. Valid only for `LV_COLOR_FORMAT_I1/2/4/8`
@ -387,26 +357,13 @@ void lv_draw_buf_set_palette(lv_draw_buf_t * draw_buf, uint8_t index, lv_color32
/**
* @deprecated Use lv_draw_buf_set_palette instead.
*/
static inline void lv_image_buf_set_palette(lv_image_dsc_t * dsc, uint8_t id, lv_color32_t c)
{
LV_LOG_WARN("Deprecated API, use lv_draw_buf_set_palette instead.");
lv_draw_buf_set_palette((lv_draw_buf_t *)dsc, id, c);
}
void lv_image_buf_set_palette(lv_image_dsc_t * dsc, uint8_t id, lv_color32_t c);
/**
* @deprecated Use lv_draw_buffer_create/destroy instead.
* Free the data pointer and dsc struct of an image.
*/
static inline void lv_image_buf_free(lv_image_dsc_t * dsc)
{
LV_LOG_WARN("Deprecated API, use lv_draw_buf_destroy instead.");
if(dsc != NULL) {
if(dsc->data != NULL)
lv_free((void *)dsc->data);
lv_free((void *)dsc);
}
}
void lv_image_buf_free(lv_image_dsc_t * dsc);
/**********************
* MACROS

View File

@ -0,0 +1,53 @@
/**
* @file lv_draw_buf_private.h
*
*/
#ifndef LV_DRAW_BUF_PRIVATE_H
#define LV_DRAW_BUF_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_buf.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
struct lv_draw_buf_handlers_t {
lv_draw_buf_malloc_cb buf_malloc_cb;
lv_draw_buf_free_cb buf_free_cb;
lv_draw_buf_align_cb align_pointer_cb;
lv_draw_buf_cache_operation_cb invalidate_cache_cb;
lv_draw_buf_cache_operation_cb flush_cache_cb;
lv_draw_buf_width_to_stride_cb width_to_stride_cb;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Called internally to initialize the draw_buf_handlers in lv_global
*/
void lv_draw_buf_init_handlers(void);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_BUF_PRIVATE_H*/

View File

@ -6,7 +6,10 @@
/*********************
* INCLUDES
*********************/
#include "lv_draw_image.h"
#include "../misc/lv_area_private.h"
#include "lv_image_decoder_private.h"
#include "lv_draw_private.h"
#include "lv_draw_image_private.h"
#include "../display/lv_display.h"
#include "../misc/lv_log.h"
#include "../misc/lv_math.h"
@ -69,8 +72,8 @@ void lv_draw_layer(lv_layer_t * layer, const lv_draw_image_dsc_t * dsc, const lv
t->type = LV_DRAW_TASK_TYPE_LAYER;
t->state = LV_DRAW_TASK_STATE_WAITING;
_lv_image_buf_get_transformed_area(&t->_real_area, lv_area_get_width(coords), lv_area_get_height(coords),
dsc->rotation, dsc->scale_x, dsc->scale_y, &dsc->pivot);
lv_image_buf_get_transformed_area(&t->_real_area, lv_area_get_width(coords), lv_area_get_height(coords),
dsc->rotation, dsc->scale_x, dsc->scale_y, &dsc->pivot);
lv_area_move(&t->_real_area, coords->x1, coords->y1);
lv_layer_t * layer_to_draw = (lv_layer_t *)dsc->src;
@ -102,8 +105,8 @@ void lv_draw_image(lv_layer_t * layer, const lv_draw_image_dsc_t * dsc, const lv
t->draw_dsc = new_image_dsc;
t->type = LV_DRAW_TASK_TYPE_IMAGE;
_lv_image_buf_get_transformed_area(&t->_real_area, lv_area_get_width(coords), lv_area_get_height(coords),
dsc->rotation, dsc->scale_x, dsc->scale_y, &dsc->pivot);
lv_image_buf_get_transformed_area(&t->_real_area, lv_area_get_width(coords), lv_area_get_height(coords),
dsc->rotation, dsc->scale_x, dsc->scale_y, &dsc->pivot);
lv_area_move(&t->_real_area, coords->x1, coords->y1);
lv_draw_finalize_task_creation(layer, t);
@ -127,8 +130,8 @@ lv_image_src_t lv_image_src_get_type(const void * src)
}
}
void _lv_draw_image_normal_helper(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords, lv_draw_image_core_cb draw_core_cb)
void lv_draw_image_normal_helper(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords, lv_draw_image_core_cb draw_core_cb)
{
if(draw_core_cb == NULL) {
LV_LOG_WARN("draw_core_cb is NULL");
@ -141,8 +144,8 @@ void _lv_draw_image_normal_helper(lv_draw_unit_t * draw_unit, const lv_draw_imag
int32_t w = lv_area_get_width(coords);
int32_t h = lv_area_get_height(coords);
_lv_image_buf_get_transformed_area(&draw_area, w, h, draw_dsc->rotation, draw_dsc->scale_x, draw_dsc->scale_y,
&draw_dsc->pivot);
lv_image_buf_get_transformed_area(&draw_area, w, h, draw_dsc->rotation, draw_dsc->scale_x, draw_dsc->scale_y,
&draw_dsc->pivot);
draw_area.x1 += coords->x1;
draw_area.y1 += coords->y1;
@ -151,7 +154,7 @@ void _lv_draw_image_normal_helper(lv_draw_unit_t * draw_unit, const lv_draw_imag
}
lv_area_t clipped_img_area;
if(!_lv_area_intersect(&clipped_img_area, &draw_area, draw_unit->clip_area)) {
if(!lv_area_intersect(&clipped_img_area, &draw_area, draw_unit->clip_area)) {
return;
}
@ -167,8 +170,8 @@ void _lv_draw_image_normal_helper(lv_draw_unit_t * draw_unit, const lv_draw_imag
lv_image_decoder_close(&decoder_dsc);
}
void _lv_draw_image_tiled_helper(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords, lv_draw_image_core_cb draw_core_cb)
void lv_draw_image_tiled_helper(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords, lv_draw_image_core_cb draw_core_cb)
{
if(draw_core_cb == NULL) {
LV_LOG_WARN("draw_core_cb is NULL");
@ -208,7 +211,7 @@ void _lv_draw_image_tiled_helper(lv_draw_unit_t * draw_unit, const lv_draw_image
while(tile_area.x1 <= coords->x2) {
lv_area_t clipped_img_area;
if(_lv_area_intersect(&clipped_img_area, &tile_area, coords)) {
if(lv_area_intersect(&clipped_img_area, &tile_area, coords)) {
img_decode_and_draw(draw_unit, draw_dsc, &decoder_dsc, &relative_decoded_area, &tile_area, &clipped_img_area,
draw_core_cb);
}
@ -226,8 +229,8 @@ void _lv_draw_image_tiled_helper(lv_draw_unit_t * draw_unit, const lv_draw_image
lv_image_decoder_close(&decoder_dsc);
}
void _lv_image_buf_get_transformed_area(lv_area_t * res, int32_t w, int32_t h, int32_t angle,
uint16_t scale_x, uint16_t scale_y, const lv_point_t * pivot)
void lv_image_buf_get_transformed_area(lv_area_t * res, int32_t w, int32_t h, int32_t angle,
uint16_t scale_x, uint16_t scale_y, const lv_point_t * pivot)
{
if(angle == 0 && scale_x == LV_SCALE_NONE && scale_y == LV_SCALE_NONE) {
res->x1 = 0;
@ -291,7 +294,7 @@ static void img_decode_and_draw(lv_draw_unit_t * draw_unit, const lv_draw_image_
if(res == LV_RESULT_OK) {
/*Limit draw area to the current decoded area and draw the image*/
lv_area_t clipped_img_area_sub;
if(_lv_area_intersect(&clipped_img_area_sub, clipped_img_area, &absolute_decoded_area)) {
if(lv_area_intersect(&clipped_img_area_sub, clipped_img_area, &absolute_decoded_area)) {
draw_core_cb(draw_unit, draw_dsc, decoder_dsc, &sup,
&absolute_decoded_area, &clipped_img_area_sub);
}

View File

@ -26,17 +26,7 @@ extern "C" {
* MACROS
**********************/
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_color_t alpha_color;
const lv_color32_t * palette;
uint32_t palette_size : 9;
} lv_draw_image_sup_t;
typedef struct _lv_draw_image_dsc_t {
typedef struct lv_draw_image_dsc_t {
lv_draw_dsc_base_t base;
const void * src;
@ -132,41 +122,6 @@ void lv_draw_layer(lv_layer_t * layer, const lv_draw_image_dsc_t * dsc, const lv
*/
lv_image_src_t lv_image_src_get_type(const void * src);
/**
* Can be used by draw units to handle the decoding and
* prepare everything for the actual image rendering
* @param draw_unit pointer to a draw unit
* @param draw_dsc the draw descriptor of the image
* @param coords the absolute coordinates of the image
* @param draw_core_cb a callback to perform the actual rendering
*/
void _lv_draw_image_normal_helper(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords, lv_draw_image_core_cb draw_core_cb);
/**
* Can be used by draw units for TILED images to handle the decoding and
* prepare everything for the actual image rendering
* @param draw_unit pointer to a draw unit
* @param draw_dsc the draw descriptor of the image
* @param coords the absolute coordinates of the image
* @param draw_core_cb a callback to perform the actual rendering
*/
void _lv_draw_image_tiled_helper(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords, lv_draw_image_core_cb draw_core_cb);
/**
* Get the area of a rectangle if its rotated and scaled
* @param res store the coordinates here
* @param w width of the rectangle to transform
* @param h height of the rectangle to transform
* @param angle angle of rotation
* @param scale_x zoom in x direction, (256 no zoom)
* @param scale_y zoom in y direction, (256 no zoom)
* @param pivot x,y pivot coordinates of rotation
*/
void _lv_image_buf_get_transformed_area(lv_area_t * res, int32_t w, int32_t h, int32_t angle,
uint16_t scale_x, uint16_t scale_y, const lv_point_t * pivot);
#ifdef __cplusplus
} /*extern "C"*/
#endif

View File

@ -0,0 +1,85 @@
/**
* @file lv_draw_image_private.h
*
*/
#ifndef LV_DRAW_IMAGE_PRIVATE_H
#define LV_DRAW_IMAGE_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_image.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* TYPEDEFS
**********************/
struct lv_draw_image_sup_t {
lv_color_t alpha_color;
const lv_color32_t * palette;
uint32_t palette_size : 9;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Can be used by draw units to handle the decoding and
* prepare everything for the actual image rendering
* @param draw_unit pointer to a draw unit
* @param draw_dsc the draw descriptor of the image
* @param coords the absolute coordinates of the image
* @param draw_core_cb a callback to perform the actual rendering
*/
void lv_draw_image_normal_helper(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords, lv_draw_image_core_cb draw_core_cb);
/**
* Can be used by draw units for TILED images to handle the decoding and
* prepare everything for the actual image rendering
* @param draw_unit pointer to a draw unit
* @param draw_dsc the draw descriptor of the image
* @param coords the absolute coordinates of the image
* @param draw_core_cb a callback to perform the actual rendering
*/
void lv_draw_image_tiled_helper(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords, lv_draw_image_core_cb draw_core_cb);
/**
* Get the area of a rectangle if its rotated and scaled
* @param res store the coordinates here
* @param w width of the rectangle to transform
* @param h height of the rectangle to transform
* @param angle angle of rotation
* @param scale_x zoom in x direction, (256 no zoom)
* @param scale_y zoom in y direction, (256 no zoom)
* @param pivot x,y pivot coordinates of rotation
*/
void lv_image_buf_get_transformed_area(lv_area_t * res, int32_t w, int32_t h, int32_t angle,
uint16_t scale_x, uint16_t scale_y, const lv_point_t * pivot);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_IMAGE_PRIVATE_H*/

View File

@ -6,11 +6,15 @@
/*********************
* INCLUDES
*********************/
#include "../misc/lv_area_private.h"
#include "lv_draw_vector_private.h"
#include "lv_draw_rect_private.h"
#include "lv_draw_private.h"
#include "../core/lv_obj.h"
#include "lv_draw_label.h"
#include "lv_draw_label_private.h"
#include "../misc/lv_math.h"
#include "../core/lv_obj_event.h"
#include "../misc/lv_bidi.h"
#include "../misc/lv_bidi_private.h"
#include "../misc/lv_text_private.h"
#include "../misc/lv_assert.h"
#include "../stdlib/lv_mem.h"
@ -150,7 +154,7 @@ void lv_draw_label_iterate_characters(lv_draw_unit_t * draw_unit, const lv_draw_
int32_t w;
lv_area_t clipped_area;
bool clip_ok = _lv_area_intersect(&clipped_area, coords, draw_unit->clip_area);
bool clip_ok = lv_area_intersect(&clipped_area, coords, draw_unit->clip_area);
if(!clip_ok) return;
lv_text_align_t align = dsc->align;
@ -268,7 +272,7 @@ void lv_draw_label_iterate_characters(lv_draw_unit_t * draw_unit, const lv_draw_
#if LV_USE_BIDI
char * bidi_txt = lv_malloc(line_end - line_start + 1);
LV_ASSERT_MALLOC(bidi_txt);
_lv_bidi_process_paragraph(dsc->text + line_start, bidi_txt, line_end - line_start, base_dir, NULL, 0);
lv_bidi_process_paragraph(dsc->text + line_start, bidi_txt, line_end - line_start, base_dir, NULL, 0);
#else
const char * bidi_txt = dsc->text + line_start;
#endif
@ -279,7 +283,7 @@ void lv_draw_label_iterate_characters(lv_draw_unit_t * draw_unit, const lv_draw_
#if LV_USE_BIDI
logical_char_pos = lv_text_encoded_get_char_id(dsc->text, line_start);
uint32_t t = lv_text_encoded_get_char_id(bidi_txt, i);
logical_char_pos += _lv_bidi_get_logical_pos(bidi_txt, NULL, line_end - line_start, base_dir, t, NULL);
logical_char_pos += lv_bidi_get_logical_pos(bidi_txt, NULL, line_end - line_start, base_dir, t, NULL);
#else
logical_char_pos = lv_text_encoded_get_char_id(dsc->text, line_start + i);
#endif
@ -402,8 +406,8 @@ static void draw_letter(lv_draw_unit_t * draw_unit, lv_draw_glyph_dsc_t * dsc,
letter_coords.y2 = letter_coords.y1 + g.box_h - 1;
/*If the letter is completely out of mask don't draw it*/
if(_lv_area_is_out(&letter_coords, draw_unit->clip_area, 0) &&
_lv_area_is_out(dsc->bg_coords, draw_unit->clip_area, 0)) {
if(lv_area_is_out(&letter_coords, draw_unit->clip_area, 0) &&
lv_area_is_out(dsc->bg_coords, draw_unit->clip_area, 0)) {
LV_PROFILER_END;
return;
}

View File

@ -28,23 +28,6 @@ extern "C" {
* TYPEDEFS
**********************/
/** Store some info to speed up drawing of very large texts
* It takes a lot of time to get the first visible character because
* all the previous characters needs to be checked to calculate the positions.
* This structure stores an earlier (e.g. at -1000 px) coordinate and the index of that line.
* Therefore the calculations can start from here.*/
typedef struct _lv_draw_label_hint_t {
/** Index of the line at `y` coordinate*/
int32_t line_start;
/** Give the `y` coordinate of the first letter at `line start` index. Relative to the label's coordinates*/
int32_t y;
/** The 'y1' coordinate of the label when the hint was saved.
* Used to invalidate the hint if the label has moved too much.*/
int32_t coord_y;
} lv_draw_label_hint_t;
typedef struct {
lv_draw_dsc_base_t base;
@ -72,17 +55,6 @@ typedef struct {
lv_draw_label_hint_t * hint;
} lv_draw_label_dsc_t;
typedef struct {
void * glyph_data; /*Depends on `format` field, it could be image source or draw buf of bitmap or vector data.*/
lv_font_glyph_format_t format;
const lv_area_t * letter_coords;
const lv_area_t * bg_coords;
const lv_font_glyph_dsc_t * g;
lv_color_t color;
lv_opa_t opa;
lv_draw_buf_t * _draw_buf; /*a shared draw buf for get_bitmap, do not use it directly, use glyph_data instead*/
} lv_draw_glyph_dsc_t;
/**
* Passed as a parameter to `lv_draw_label_iterate_characters` to
* draw the characters one by one

View File

@ -0,0 +1,68 @@
/**
* @file lv_draw_label_private.h
*
*/
#ifndef LV_DRAW_LABEL_PRIVATE_H
#define LV_DRAW_LABEL_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_label.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/** Store some info to speed up drawing of very large texts
* It takes a lot of time to get the first visible character because
* all the previous characters needs to be checked to calculate the positions.
* This structure stores an earlier (e.g. at -1000 px) coordinate and the index of that line.
* Therefore the calculations can start from here.*/
struct lv_draw_label_hint_t {
/** Index of the line at `y` coordinate*/
int32_t line_start;
/** Give the `y` coordinate of the first letter at `line start` index. Relative to the label's coordinates*/
int32_t y;
/** The 'y1' coordinate of the label when the hint was saved.
* Used to invalidate the hint if the label has moved too much.*/
int32_t coord_y;
};
struct lv_draw_glyph_dsc_t {
void * glyph_data; /*Depends on `format` field, it could be image source or draw buf of bitmap or vector data.*/
lv_font_glyph_format_t format;
const lv_area_t * letter_coords;
const lv_area_t * bg_coords;
const lv_font_glyph_dsc_t * g;
lv_color_t color;
lv_opa_t opa;
lv_draw_buf_t * _draw_buf; /*a shared draw buf for get_bitmap, do not use it directly, use glyph_data instead*/
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_LABEL_PRIVATE_H*/

View File

@ -6,6 +6,7 @@
/*********************
* INCLUDES
*********************/
#include "lv_draw_private.h"
#include "../core/lv_refr.h"
#include "../misc/lv_math.h"
#include "../misc/lv_types.h"

View File

@ -6,7 +6,8 @@
/*********************
* INCLUDES
*********************/
#include "lv_draw_mask.h"
#include "lv_draw_private.h"
#include "lv_draw_mask_private.h"
#include "../core/lv_refr.h"
#include "../misc/lv_math.h"
#include "../misc/lv_types.h"

View File

@ -22,16 +22,6 @@ extern "C" {
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_draw_dsc_base_t base;
lv_area_t area;
int32_t radius;
} lv_draw_mask_rect_dsc_t;
/**********************
* GLOBAL PROTOTYPES
**********************/

View File

@ -0,0 +1,50 @@
/**
* @file lv_draw_mask_private.h
*
*/
#ifndef LV_DRAW_MASK_PRIVATE_H
#define LV_DRAW_MASK_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_mask.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* TYPEDEFS
**********************/
struct lv_draw_mask_rect_dsc_t {
lv_draw_dsc_base_t base;
lv_area_t area;
int32_t radius;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_MASK_PRIVATE_H*/

146
src/draw/lv_draw_private.h Normal file
View File

@ -0,0 +1,146 @@
/**
* @file lv_draw_private.h
*
*/
#ifndef LV_DRAW_PRIVATE_H
#define LV_DRAW_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
struct lv_draw_task_t {
lv_draw_task_t * next;
lv_draw_task_type_t type;
/**
* The area where to draw
*/
lv_area_t area;
/**
* The real draw area. E.g. for shadow, outline, or transformed images it's different from `area`
*/
lv_area_t _real_area;
/** The original area which is updated*/
lv_area_t clip_area_original;
/**
* The clip area of the layer is saved here when the draw task is created.
* As the clip area of the layer can be changed as new draw tasks are added its current value needs to be saved.
* Therefore during drawing the layer's clip area shouldn't be used as it might be already changed for other draw tasks.
*/
lv_area_t clip_area;
#if LV_DRAW_TRANSFORM_USE_MATRIX
/** Transform matrix to be applied when rendering the layer */
lv_matrix_t matrix;
#endif
volatile int state; /*int instead of lv_draw_task_state_t to be sure its atomic*/
void * draw_dsc;
/**
* The ID of the draw_unit which should take this task
*/
uint8_t preferred_draw_unit_id;
/**
* Set to which extent `preferred_draw_unit_id` is good at this task.
* 80: means 20% better (faster) than software rendering
* 100: the default value
* 110: means 10% worse (slower) than software rendering
*/
uint8_t preference_score;
};
struct lv_draw_mask_t {
void * user_data;
};
struct lv_draw_unit_t {
lv_draw_unit_t * next;
/**
* The target_layer on which drawing should happen
*/
lv_layer_t * target_layer;
const lv_area_t * clip_area;
/**
* Called to try to assign a draw task to itself.
* `lv_draw_get_next_available_task` can be used to get an independent draw task.
* A draw task should be assign only if the draw unit can draw it too
* @param draw_unit pointer to the draw unit
* @param layer pointer to a layer on which the draw task should be drawn
* @return >=0: The number of taken draw task:
* 0 means the task has not yet been completed.
* 1 means a new task has been accepted.
* -1: The draw unit wanted to work on a task but couldn't do that
* due to some errors (e.g. out of memory).
* It signals that LVGL should call the dispatcher later again
* to let draw unit try to start the rendering again.
*/
int32_t (*dispatch_cb)(lv_draw_unit_t * draw_unit, lv_layer_t * layer);
/**
*
* @param draw_unit
* @param task
* @return
*/
int32_t (*evaluate_cb)(lv_draw_unit_t * draw_unit, lv_draw_task_t * task);
/**
* Called to delete draw unit.
* @param draw_unit
* @return
*/
int32_t (*delete_cb)(lv_draw_unit_t * draw_unit);
};
typedef struct {
lv_draw_unit_t * unit_head;
uint32_t used_memory_for_layers_kb;
#if LV_USE_OS
lv_thread_sync_t sync;
#else
int dispatch_req;
#endif
lv_mutex_t circle_cache_mutex;
bool task_running;
} lv_draw_global_info_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_PRIVATE_H*/

View File

@ -6,8 +6,9 @@
/*********************
* INCLUDES
*********************/
#include "lv_draw_private.h"
#include "../core/lv_obj.h"
#include "lv_draw_rect.h"
#include "lv_draw_rect_private.h"
#include "../misc/lv_assert.h"
#include "../core/lv_obj_event.h"
#include "../stdlib/lv_string.h"

View File

@ -0,0 +1,39 @@
/**
* @file lv_draw_rect_private.h
*
*/
#ifndef LV_DRAW_RECT_PRIVATE_H
#define LV_DRAW_RECT_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_rect.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_RECT_PRIVATE_H*/

View File

@ -6,8 +6,9 @@
/*********************
* INCLUDES
*********************/
#include "lv_draw_private.h"
#include "../core/lv_obj.h"
#include "lv_draw_triangle.h"
#include "lv_draw_triangle_private.h"
#include "../misc/lv_math.h"
#include "../stdlib/lv_mem.h"
#include "../stdlib/lv_string.h"

View File

@ -0,0 +1,43 @@
/**
* @file lv_draw_triangle_private.h
*
*/
#ifndef LV_DRAW_TRIANGLE_PRIVATE_H
#define LV_DRAW_TRIANGLE_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_triangle.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_TRIANGLE_PRIVATE_H*/

View File

@ -4,9 +4,11 @@
*/
/*********************
* INCLUDES
* INCLUDES
*********************/
#include "lv_draw_vector.h"
#include "../misc/lv_area_private.h"
#include "lv_draw_private.h"
#include "lv_draw_vector_private.h"
#if LV_USE_VECTOR_GRAPHIC
@ -26,7 +28,7 @@
#define MATH_DEGREES(rad) ((rad) * RAD_TO_DEG)
/*********************
* DEFINES
* DEFINES
*********************/
#ifndef M_PI
@ -44,16 +46,16 @@
} while(0)
/**********************
* TYPEDEFS
* TYPEDEFS
**********************/
typedef struct {
lv_vector_path_t * path;
lv_vector_draw_dsc_t dsc;
} _lv_vector_draw_task;
} lv_vector_draw_task;
/**********************
* STATIC PROTOTYPES
* STATIC PROTOTYPES
**********************/
static void _copy_draw_dsc(lv_vector_draw_dsc_t * dst, const lv_vector_draw_dsc_t * src)
@ -81,7 +83,7 @@ static void _copy_draw_dsc(lv_vector_draw_dsc_t * dst, const lv_vector_draw_dsc_
lv_area_copy(&(dst->scissor_area), &(src->scissor_area));
}
/**********************
* GLOBAL FUNCTIONS
* GLOBAL FUNCTIONS
**********************/
void lv_matrix_transform_point(const lv_matrix_t * matrix, lv_fpoint_t * point)
@ -109,7 +111,7 @@ lv_vector_path_t * lv_vector_path_create(lv_vector_path_quality_t quality)
LV_ASSERT_MALLOC(path);
lv_memzero(path, sizeof(lv_vector_path_t));
path->quality = quality;
lv_array_init(&path->ops, 8, sizeof(uint8_t));
lv_array_init(&path->ops, 8, sizeof(lv_vector_path_op_t));
lv_array_init(&path->points, 8, sizeof(lv_fpoint_t));
return path;
}
@ -138,7 +140,7 @@ void lv_vector_path_move_to(lv_vector_path_t * path, const lv_fpoint_t * p)
{
CHECK_AND_RESIZE_PATH_CONTAINER(path, 1);
uint8_t op = LV_VECTOR_PATH_OP_MOVE_TO;
lv_vector_path_op_t op = LV_VECTOR_PATH_OP_MOVE_TO;
lv_array_push_back(&path->ops, &op);
lv_array_push_back(&path->points, p);
}
@ -152,7 +154,7 @@ void lv_vector_path_line_to(lv_vector_path_t * path, const lv_fpoint_t * p)
CHECK_AND_RESIZE_PATH_CONTAINER(path, 1);
uint8_t op = LV_VECTOR_PATH_OP_LINE_TO;
lv_vector_path_op_t op = LV_VECTOR_PATH_OP_LINE_TO;
lv_array_push_back(&path->ops, &op);
lv_array_push_back(&path->points, p);
}
@ -166,7 +168,7 @@ void lv_vector_path_quad_to(lv_vector_path_t * path, const lv_fpoint_t * p1, con
CHECK_AND_RESIZE_PATH_CONTAINER(path, 2);
uint8_t op = LV_VECTOR_PATH_OP_QUAD_TO;
lv_vector_path_op_t op = LV_VECTOR_PATH_OP_QUAD_TO;
lv_array_push_back(&path->ops, &op);
lv_array_push_back(&path->points, p1);
lv_array_push_back(&path->points, p2);
@ -182,7 +184,7 @@ void lv_vector_path_cubic_to(lv_vector_path_t * path, const lv_fpoint_t * p1, co
CHECK_AND_RESIZE_PATH_CONTAINER(path, 3);
uint8_t op = LV_VECTOR_PATH_OP_CUBIC_TO;
lv_vector_path_op_t op = LV_VECTOR_PATH_OP_CUBIC_TO;
lv_array_push_back(&path->ops, &op);
lv_array_push_back(&path->points, p1);
lv_array_push_back(&path->points, p2);
@ -198,7 +200,7 @@ void lv_vector_path_close(lv_vector_path_t * path)
CHECK_AND_RESIZE_PATH_CONTAINER(path, 1);
uint8_t op = LV_VECTOR_PATH_OP_CLOSE;
lv_vector_path_op_t op = LV_VECTOR_PATH_OP_CLOSE;
lv_array_push_back(&path->ops, &op);
}
@ -500,7 +502,7 @@ void lv_vector_dsc_delete(lv_vector_dsc_t * dsc)
{
if(dsc->tasks.task_list) {
lv_ll_t * task_list = dsc->tasks.task_list;
_lv_vector_for_each_destroy_tasks(task_list, NULL, NULL);
lv_vector_for_each_destroy_tasks(task_list, NULL, NULL);
dsc->tasks.task_list = NULL;
}
lv_array_deinit(&(dsc->current_dsc.stroke_dsc.dash_pattern));
@ -688,7 +690,7 @@ void lv_vector_dsc_set_stroke_gradient_color_stops(lv_vector_dsc_t * dsc, const
void lv_vector_dsc_add_path(lv_vector_dsc_t * dsc, const lv_vector_path_t * path)
{
lv_area_t rect;
if(!_lv_area_intersect(&rect, &(dsc->layer->_clip_area), &(dsc->current_dsc.scissor_area))) {
if(!lv_area_intersect(&rect, &(dsc->layer->_clip_area), &(dsc->current_dsc.scissor_area))) {
return;
}
@ -700,11 +702,11 @@ void lv_vector_dsc_add_path(lv_vector_dsc_t * dsc, const lv_vector_path_t * path
if(!dsc->tasks.task_list) {
dsc->tasks.task_list = lv_malloc(sizeof(lv_ll_t));
LV_ASSERT_MALLOC(dsc->tasks.task_list);
_lv_ll_init(dsc->tasks.task_list, sizeof(_lv_vector_draw_task));
lv_ll_init(dsc->tasks.task_list, sizeof(lv_vector_draw_task));
}
_lv_vector_draw_task * new_task = (_lv_vector_draw_task *)_lv_ll_ins_tail(dsc->tasks.task_list);
lv_memset(new_task, 0, sizeof(_lv_vector_draw_task));
lv_vector_draw_task * new_task = (lv_vector_draw_task *)lv_ll_ins_tail(dsc->tasks.task_list);
lv_memset(new_task, 0, sizeof(lv_vector_draw_task));
new_task->path = lv_vector_path_create(0);
@ -716,18 +718,18 @@ void lv_vector_dsc_add_path(lv_vector_dsc_t * dsc, const lv_vector_path_t * path
void lv_vector_clear_area(lv_vector_dsc_t * dsc, const lv_area_t * rect)
{
lv_area_t r;
if(!_lv_area_intersect(&r, &(dsc->layer->_clip_area), &(dsc->current_dsc.scissor_area))) {
if(!lv_area_intersect(&r, &(dsc->layer->_clip_area), &(dsc->current_dsc.scissor_area))) {
return;
}
if(!dsc->tasks.task_list) {
dsc->tasks.task_list = lv_malloc(sizeof(lv_ll_t));
LV_ASSERT_MALLOC(dsc->tasks.task_list);
_lv_ll_init(dsc->tasks.task_list, sizeof(_lv_vector_draw_task));
lv_ll_init(dsc->tasks.task_list, sizeof(lv_vector_draw_task));
}
_lv_vector_draw_task * new_task = (_lv_vector_draw_task *)_lv_ll_ins_tail(dsc->tasks.task_list);
lv_memset(new_task, 0, sizeof(_lv_vector_draw_task));
lv_vector_draw_task * new_task = (lv_vector_draw_task *)lv_ll_ins_tail(dsc->tasks.task_list);
lv_memset(new_task, 0, sizeof(lv_vector_draw_task));
new_task->dsc.fill_dsc.color = dsc->current_dsc.fill_dsc.color;
new_task->dsc.fill_dsc.opa = dsc->current_dsc.fill_dsc.opa;
@ -776,14 +778,14 @@ void lv_vector_dsc_skew(lv_vector_dsc_t * dsc, float skew_x, float skew_y)
lv_matrix_skew(&(dsc->current_dsc.matrix), skew_x, skew_y);
}
void _lv_vector_for_each_destroy_tasks(lv_ll_t * task_list, vector_draw_task_cb cb, void * data)
void lv_vector_for_each_destroy_tasks(lv_ll_t * task_list, vector_draw_task_cb cb, void * data)
{
_lv_vector_draw_task * task = _lv_ll_get_head(task_list);
_lv_vector_draw_task * next_task = NULL;
lv_vector_draw_task * task = lv_ll_get_head(task_list);
lv_vector_draw_task * next_task = NULL;
while(task != NULL) {
next_task = _lv_ll_get_next(task_list, task);
_lv_ll_remove(task_list, task);
next_task = lv_ll_get_next(task_list, task);
lv_ll_remove(task_list, task);
if(cb) {
cb(data, task->path, &(task->dsc));

View File

@ -26,34 +26,30 @@ extern "C" {
/**********************
* TYPEDEFS
**********************/
enum {
typedef enum {
LV_VECTOR_FILL_NONZERO = 0,
LV_VECTOR_FILL_EVENODD,
};
typedef uint8_t lv_vector_fill_t;
} lv_vector_fill_t;
enum {
typedef enum {
LV_VECTOR_STROKE_CAP_BUTT = 0,
LV_VECTOR_STROKE_CAP_SQUARE,
LV_VECTOR_STROKE_CAP_ROUND,
};
typedef uint8_t lv_vector_stroke_cap_t;
} lv_vector_stroke_cap_t;
enum {
typedef enum {
LV_VECTOR_STROKE_JOIN_MITER = 0,
LV_VECTOR_STROKE_JOIN_BEVEL,
LV_VECTOR_STROKE_JOIN_ROUND,
};
typedef uint8_t lv_vector_stroke_join_t;
} lv_vector_stroke_join_t;
enum {
typedef enum {
LV_VECTOR_PATH_QUALITY_MEDIUM = 0, /* default*/
LV_VECTOR_PATH_QUALITY_HIGH,
LV_VECTOR_PATH_QUALITY_LOW,
};
typedef uint8_t lv_vector_path_quality_t;
} lv_vector_path_quality_t;
enum {
typedef enum {
LV_VECTOR_BLEND_SRC_OVER = 0,
LV_VECTOR_BLEND_SRC_IN,
LV_VECTOR_BLEND_DST_OVER,
@ -63,105 +59,37 @@ enum {
LV_VECTOR_BLEND_NONE,
LV_VECTOR_BLEND_ADDITIVE,
LV_VECTOR_BLEND_SUBTRACTIVE,
};
typedef uint8_t lv_vector_blend_t;
} lv_vector_blend_t;
enum {
typedef enum {
LV_VECTOR_PATH_OP_MOVE_TO = 0,
LV_VECTOR_PATH_OP_LINE_TO,
LV_VECTOR_PATH_OP_QUAD_TO,
LV_VECTOR_PATH_OP_CUBIC_TO,
LV_VECTOR_PATH_OP_CLOSE,
};
typedef uint8_t lv_vector_path_op_t;
} lv_vector_path_op_t;
enum {
typedef enum {
LV_VECTOR_DRAW_STYLE_SOLID = 0,
LV_VECTOR_DRAW_STYLE_PATTERN,
LV_VECTOR_DRAW_STYLE_GRADIENT,
};
typedef uint8_t lv_vector_draw_style_t;
} lv_vector_draw_style_t;
enum {
typedef enum {
LV_VECTOR_GRADIENT_SPREAD_PAD = 0,
LV_VECTOR_GRADIENT_SPREAD_REPEAT,
LV_VECTOR_GRADIENT_SPREAD_REFLECT,
};
typedef uint8_t lv_vector_gradient_spread_t;
} lv_vector_gradient_spread_t;
enum {
typedef enum {
LV_VECTOR_GRADIENT_STYLE_LINEAR = 0,
LV_VECTOR_GRADIENT_STYLE_RADIAL,
};
typedef uint8_t lv_vector_gradient_style_t;
} lv_vector_gradient_style_t;
typedef struct {
struct lv_fpoint_t {
float x;
float y;
} lv_fpoint_t;
typedef struct {
lv_vector_path_quality_t quality;
lv_array_t ops;
lv_array_t points;
} lv_vector_path_t;
typedef struct {
lv_vector_gradient_style_t style;
lv_gradient_stop_t stops[LV_GRADIENT_MAX_STOPS]; /**< A gradient stop array */
uint16_t stops_count; /**< The number of used stops in the array */
float x1;
float y1;
float x2;
float y2;
float cx;
float cy;
float cr;
lv_vector_gradient_spread_t spread;
} lv_vector_gradient_t;
typedef struct {
lv_vector_draw_style_t style;
lv_color32_t color;
lv_opa_t opa;
lv_vector_fill_t fill_rule;
lv_draw_image_dsc_t img_dsc;
lv_vector_gradient_t gradient;
lv_matrix_t matrix;
} lv_vector_fill_dsc_t;
typedef struct {
lv_vector_draw_style_t style;
lv_color32_t color;
lv_opa_t opa;
float width;
lv_array_t dash_pattern;
lv_vector_stroke_cap_t cap;
lv_vector_stroke_join_t join;
uint16_t miter_limit;
lv_vector_gradient_t gradient;
lv_matrix_t matrix;
} lv_vector_stroke_dsc_t;
typedef struct {
lv_vector_fill_dsc_t fill_dsc;
lv_vector_stroke_dsc_t stroke_dsc;
lv_matrix_t matrix;
lv_vector_blend_t blend_mode;
lv_area_t scissor_area;
} lv_vector_draw_dsc_t;
typedef struct {
lv_draw_dsc_base_t base;
lv_ll_t * task_list; /*draw task list.*/
} lv_draw_vector_task_dsc_t;
typedef struct {
lv_layer_t * layer;
lv_vector_draw_dsc_t current_dsc;
/* private data */
lv_draw_vector_task_dsc_t tasks;
} lv_vector_dsc_t;
};
/**********************
* GLOBAL PROTOTYPES
@ -552,8 +480,6 @@ void lv_draw_vector(lv_vector_dsc_t * dsc);
/* Traverser for task list */
typedef void (*vector_draw_task_cb)(void * ctx, const lv_vector_path_t * path, const lv_vector_draw_dsc_t * dsc);
void _lv_vector_for_each_destroy_tasks(lv_ll_t * task_list, vector_draw_task_cb cb, void * data);
#endif /* LV_USE_VECTOR_GRAPHIC */
#ifdef __cplusplus

View File

@ -0,0 +1,109 @@
/**
* @file lv_draw_vector_private.h
*
*/
#ifndef LV_DRAW_VECTOR_PRIVATE_H
#define LV_DRAW_VECTOR_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_vector.h"
#if LV_USE_VECTOR_GRAPHIC
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
struct lv_vector_path_t {
lv_vector_path_quality_t quality;
lv_array_t ops;
lv_array_t points;
};
struct lv_vector_gradient_t {
lv_vector_gradient_style_t style;
lv_gradient_stop_t stops[LV_GRADIENT_MAX_STOPS]; /**< A gradient stop array */
uint16_t stops_count; /**< The number of used stops in the array */
float x1;
float y1;
float x2;
float y2;
float cx;
float cy;
float cr;
lv_vector_gradient_spread_t spread;
};
struct lv_vector_fill_dsc_t {
lv_vector_draw_style_t style;
lv_color32_t color;
lv_opa_t opa;
lv_vector_fill_t fill_rule;
lv_draw_image_dsc_t img_dsc;
lv_vector_gradient_t gradient;
lv_matrix_t matrix;
};
struct lv_vector_stroke_dsc_t {
lv_vector_draw_style_t style;
lv_color32_t color;
lv_opa_t opa;
float width;
lv_array_t dash_pattern;
lv_vector_stroke_cap_t cap;
lv_vector_stroke_join_t join;
uint16_t miter_limit;
lv_vector_gradient_t gradient;
lv_matrix_t matrix;
};
struct lv_vector_draw_dsc_t {
lv_vector_fill_dsc_t fill_dsc;
lv_vector_stroke_dsc_t stroke_dsc;
lv_matrix_t matrix;
lv_vector_blend_t blend_mode;
lv_area_t scissor_area;
};
struct lv_draw_vector_task_dsc_t {
lv_draw_dsc_base_t base;
lv_ll_t * task_list; /*draw task list.*/
};
struct lv_vector_dsc_t {
lv_layer_t * layer;
lv_vector_draw_dsc_t current_dsc;
/* private data */
lv_draw_vector_task_dsc_t tasks;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_vector_for_each_destroy_tasks(lv_ll_t * task_list, vector_draw_task_cb cb, void * data);
/**********************
* MACROS
**********************/
#endif /* LV_USE_VECTOR_GRAPHIC */
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_VECTOR_PRIVATE_H*/

View File

@ -6,7 +6,7 @@
/*********************
* INCLUDES
*********************/
#include "lv_image_decoder.h"
#include "lv_image_decoder_private.h"
#include "../misc/lv_assert.h"
#include "../draw/lv_draw_image.h"
#include "../misc/lv_ll.h"
@ -56,9 +56,9 @@ static lv_result_t try_cache(lv_image_decoder_dsc_t * dsc);
/**
* Initialize the image decoder module
*/
void _lv_image_decoder_init(uint32_t image_cache_size, uint32_t image_header_count)
void lv_image_decoder_init(uint32_t image_cache_size, uint32_t image_header_count)
{
_lv_ll_init(img_decoder_ll_p, sizeof(lv_image_decoder_t));
lv_ll_init(img_decoder_ll_p, sizeof(lv_image_decoder_t));
/*Initialize the cache*/
lv_image_cache_init(image_cache_size);
@ -68,12 +68,12 @@ void _lv_image_decoder_init(uint32_t image_cache_size, uint32_t image_header_cou
/**
* Deinitialize the image decoder module
*/
void _lv_image_decoder_deinit(void)
void lv_image_decoder_deinit(void)
{
lv_cache_destroy(img_cache_p, NULL);
lv_cache_destroy(img_header_cache_p, NULL);
_lv_ll_clear(img_decoder_ll_p);
lv_ll_clear(img_decoder_ll_p);
}
lv_result_t lv_image_decoder_get_info(const void * src, lv_image_header_t * header)
@ -171,7 +171,7 @@ void lv_image_decoder_close(lv_image_decoder_dsc_t * dsc)
lv_image_decoder_t * lv_image_decoder_create(void)
{
lv_image_decoder_t * decoder;
decoder = _lv_ll_ins_head(img_decoder_ll_p);
decoder = lv_ll_ins_head(img_decoder_ll_p);
LV_ASSERT_MALLOC(decoder);
if(decoder == NULL) return NULL;
@ -182,16 +182,16 @@ lv_image_decoder_t * lv_image_decoder_create(void)
void lv_image_decoder_delete(lv_image_decoder_t * decoder)
{
_lv_ll_remove(img_decoder_ll_p, decoder);
lv_ll_remove(img_decoder_ll_p, decoder);
lv_free(decoder);
}
lv_image_decoder_t * lv_image_decoder_get_next(lv_image_decoder_t * decoder)
{
if(decoder == NULL)
return _lv_ll_get_head(img_decoder_ll_p);
return lv_ll_get_head(img_decoder_ll_p);
else
return _lv_ll_get_next(img_decoder_ll_p, decoder);
return lv_ll_get_next(img_decoder_ll_p, decoder);
}
void lv_image_decoder_set_info_cb(lv_image_decoder_t * decoder, lv_image_decoder_info_f_t info_cb)
@ -336,7 +336,7 @@ static lv_image_decoder_t * image_decoder_get_info(lv_image_decoder_dsc_t * dsc,
/*Search the decoders*/
lv_image_decoder_t * decoder_prev = NULL;
_LV_LL_READ(img_decoder_ll_p, decoder) {
LV_LL_READ(img_decoder_ll_p, decoder) {
/*Info and Open callbacks are required*/
if(decoder->info_cb && decoder->open_cb) {
lv_fs_seek(&dsc->file, 0, LV_FS_SEEK_SET);

View File

@ -31,39 +31,12 @@ extern "C" {
/**
* Source of image.*/
enum _lv_image_src_t {
typedef enum {
LV_IMAGE_SRC_VARIABLE, /** Binary/C variable*/
LV_IMAGE_SRC_FILE, /** File in filesystem*/
LV_IMAGE_SRC_SYMBOL, /** Symbol (@ref lv_symbol_def.h)*/
LV_IMAGE_SRC_UNKNOWN, /** Unknown source*/
};
#ifdef DOXYGEN
typedef _lv_image_src_t lv_image_src_t;
#else
typedef uint8_t lv_image_src_t;
#endif /*DOXYGEN*/
/*Decoder function definitions*/
struct _lv_image_decoder_dsc_t;
typedef struct _lv_image_decoder_dsc_t lv_image_decoder_dsc_t;
/**
* Image decoder args.
* It determines how to decoder an image, e.g. whether to premultiply the alpha or not.
* It should be passed to lv_img_decoder_open() function. If NULL is provided, default
* args are used.
*
* Default args:
* all field are zero or false.
*/
typedef struct _lv_image_decoder_args_t {
bool stride_align; /*Whether stride should be aligned*/
bool premultiply; /*Whether image should be premultiplied or not after decoding*/
bool no_cache; /*When set, decoded image won't be put to cache, and decoder open will also ignore cache.*/
bool use_indexed; /*Decoded indexed image as is. Convert to ARGB8888 if false.*/
bool flush_cache; /*Whether to flush the data cache after decoding*/
} lv_image_decoder_args_t;
} lv_image_src_t;
/**
* Get info from an image and store in the `header`
@ -103,95 +76,10 @@ typedef lv_result_t (*lv_image_decoder_get_area_cb_t)(lv_image_decoder_t * decod
*/
typedef void (*lv_image_decoder_close_f_t)(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc);
struct _lv_image_decoder_t {
lv_image_decoder_info_f_t info_cb;
lv_image_decoder_open_f_t open_cb;
lv_image_decoder_get_area_cb_t get_area_cb;
lv_image_decoder_close_f_t close_cb;
const char * name;
void * user_data;
};
typedef struct _lv_image_decoder_cache_data_t {
lv_cache_slot_size_t slot;
const void * src;
lv_image_src_t src_type;
const lv_draw_buf_t * decoded;
const lv_image_decoder_t * decoder;
void * user_data;
} lv_image_cache_data_t;
typedef struct _lv_image_decoder_header_cache_data_t {
const void * src;
lv_image_src_t src_type;
lv_image_header_t header;
lv_image_decoder_t * decoder;
} lv_image_header_cache_data_t;
/**Describe an image decoding session. Stores data about the decoding*/
struct _lv_image_decoder_dsc_t {
/**The decoder which was able to open the image source*/
lv_image_decoder_t * decoder;
/**A copy of parameters of how this image is decoded*/
lv_image_decoder_args_t args;
/**The image source. A file path like "S:my_img.png" or pointer to an `lv_image_dsc_t` variable*/
const void * src;
/**Type of the source: file or variable. Can be set in `open` function if required*/
lv_image_src_t src_type;
lv_fs_file_t file;
/**Info about the opened image: color format, size, etc. MUST be set in `open` function*/
lv_image_header_t header;
/** Pointer to a draw buffer where the image's data (pixels) are stored in a decoded, plain format.
* MUST be set in `open` or `get_area_cb`function*/
const lv_draw_buf_t * decoded;
const lv_color32_t * palette;
uint32_t palette_size;
/** How much time did it take to open the image. [ms]
* If not set `lv_image_cache` will measure and set the time to open*/
uint32_t time_to_open;
/**A text to display instead of the image when the image can't be opened.
* Can be set in `open` function or set NULL.*/
const char * error_msg;
lv_cache_t * cache;
/**Point to cache entry information*/
lv_cache_entry_t * cache_entry;
/**Store any custom data here is required*/
void * user_data;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the image decoder module
* @param image_cache_size Image cache size in bytes. 0 to disable cache.
* @param image_header_count Number of header cache entries. 0 to disable header cache.
*/
void _lv_image_decoder_init(uint32_t image_cache_size, uint32_t image_header_count);
/**
* Deinitialize the image decoder module
*/
void _lv_image_decoder_deinit(void);
/**
* Get information about an image.
* Try the created image decoder one by one. Once one is able to get info that info will be used.

View File

@ -0,0 +1,142 @@
/**
* @file lv_image_decoder_private.h
*
*/
#ifndef LV_IMAGE_DECODER_PRIVATE_H
#define LV_IMAGE_DECODER_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_image_decoder.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**
* Image decoder args.
* It determines how to decoder an image, e.g. whether to premultiply the alpha or not.
* It should be passed to lv_img_decoder_open() function. If NULL is provided, default
* args are used.
*
* Default args:
* all field are zero or false.
*/
struct lv_image_decoder_args_t {
bool stride_align; /*Whether stride should be aligned*/
bool premultiply; /*Whether image should be premultiplied or not after decoding*/
bool no_cache; /*When set, decoded image won't be put to cache, and decoder open will also ignore cache.*/
bool use_indexed; /*Decoded indexed image as is. Convert to ARGB8888 if false.*/
bool flush_cache; /*Whether to flush the data cache after decoding*/
};
struct lv_image_decoder_t {
lv_image_decoder_info_f_t info_cb;
lv_image_decoder_open_f_t open_cb;
lv_image_decoder_get_area_cb_t get_area_cb;
lv_image_decoder_close_f_t close_cb;
const char * name;
void * user_data;
};
struct lv_image_cache_data_t {
lv_cache_slot_size_t slot;
const void * src;
lv_image_src_t src_type;
const lv_draw_buf_t * decoded;
const lv_image_decoder_t * decoder;
void * user_data;
};
struct lv_image_header_cache_data_t {
const void * src;
lv_image_src_t src_type;
lv_image_header_t header;
lv_image_decoder_t * decoder;
};
/**Describe an image decoding session. Stores data about the decoding*/
struct lv_image_decoder_dsc_t {
/**The decoder which was able to open the image source*/
lv_image_decoder_t * decoder;
/**A copy of parameters of how this image is decoded*/
lv_image_decoder_args_t args;
/**The image source. A file path like "S:my_img.png" or pointer to an `lv_image_dsc_t` variable*/
const void * src;
/**Type of the source: file or variable. Can be set in `open` function if required*/
lv_image_src_t src_type;
lv_fs_file_t file;
/**Info about the opened image: color format, size, etc. MUST be set in `open` function*/
lv_image_header_t header;
/** Pointer to a draw buffer where the image's data (pixels) are stored in a decoded, plain format.
* MUST be set in `open` or `get_area_cb`function*/
const lv_draw_buf_t * decoded;
const lv_color32_t * palette;
uint32_t palette_size;
/** How much time did it take to open the image. [ms]
* If not set `lv_image_cache` will measure and set the time to open*/
uint32_t time_to_open;
/**A text to display instead of the image when the image can't be opened.
* Can be set in `open` function or set NULL.*/
const char * error_msg;
lv_cache_t * cache;
/**Point to cache entry information*/
lv_cache_entry_t * cache_entry;
/**Store any custom data here is required*/
void * user_data;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the image decoder module
* @param image_cache_size Image cache size in bytes. 0 to disable cache.
* @param image_header_count Number of header cache entries. 0 to disable header cache.
*/
void lv_image_decoder_init(uint32_t image_cache_size, uint32_t image_header_count);
/**
* Deinitialize the image decoder module
*/
void lv_image_decoder_deinit(void);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_IMAGE_DECODER_PRIVATE_H*/

View File

@ -29,7 +29,7 @@ LV_EXPORT_CONST_INT(LV_IMAGE_HEADER_MAGIC);
* TYPEDEFS
**********************/
typedef enum _lv_image_flags_t {
typedef enum lv_image_flags_t {
/**
* For RGB map of the image data, mark if it's pre-multiplied with alpha.
* For indexed image, this bit indicated palette data is pre-multiplied with alpha.

View File

@ -16,6 +16,7 @@
#include "lv_draw_pxp.h"
#if LV_USE_DRAW_PXP
#include "../../lv_draw_buf_private.h"
#include "lv_pxp_cfg.h"
#include "lv_pxp_utils.h"

View File

@ -376,7 +376,7 @@ static void _pxp_execute_drawing(lv_draw_pxp_unit_t * u)
lv_draw_buf_t * draw_buf = layer->draw_buf;
lv_area_t draw_area;
if(!_lv_area_intersect(&draw_area, &t->area, draw_unit->clip_area))
if(!lv_area_intersect(&draw_area, &t->area, draw_unit->clip_area))
return; /*Fully clipped, nothing to do*/
/* Make area relative to the buffer */
@ -403,7 +403,7 @@ static void _pxp_execute_drawing(lv_draw_pxp_unit_t * u)
/*Layers manage it for themselves*/
if(t->type != LV_DRAW_TASK_TYPE_LAYER) {
lv_area_t draw_area;
if(!_lv_area_intersect(&draw_area, &t->area, u->base_unit.clip_area))
if(!lv_area_intersect(&draw_area, &t->area, u->base_unit.clip_area))
return;
int32_t idx = 0;
@ -414,7 +414,7 @@ static void _pxp_execute_drawing(lv_draw_pxp_unit_t * u)
}
lv_draw_rect_dsc_t rect_dsc;
lv_draw_rect_dsc_init(&rect_dsc);
rect_dsc.bg_color = lv_palette_main(idx % _LV_PALETTE_LAST);
rect_dsc.bg_color = lv_palette_main(idx % LV_PALETTE_LAST);
rect_dsc.border_color = rect_dsc.bg_color;
rect_dsc.bg_opa = LV_OPA_10;
rect_dsc.border_opa = LV_OPA_80;

View File

@ -64,7 +64,7 @@ void lv_draw_pxp_fill(lv_draw_unit_t * draw_unit, const lv_draw_fill_dsc_t * dsc
lv_area_move(&rel_clip_area, -layer->buf_area.x1, -layer->buf_area.y1);
lv_area_t blend_area;
if(!_lv_area_intersect(&blend_area, &rel_coords, &rel_clip_area))
if(!lv_area_intersect(&blend_area, &rel_coords, &rel_clip_area))
return; /*Fully clipped, nothing to do*/
_pxp_fill(draw_buf->data, &blend_area, draw_buf->header.stride, draw_buf->header.cf, dsc);

Some files were not shown because too many files have changed in this diff Show More