mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-10 04:37:55 +08:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
**********************/
|
||||
|
||||
+13
-13
@@ -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++;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "../../src/themes/lv_theme_private.h"
|
||||
#include "../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_IMAGE
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../../lv_examples.h"
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_CANVAS && LV_BUILD_EXAMPLES
|
||||
|
||||
#define CANVAS_WIDTH 50
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../../lv_examples.h"
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_CANVAS && LV_BUILD_EXAMPLES
|
||||
|
||||
#define CANVAS_WIDTH 50
|
||||
|
||||
@@ -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*/
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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*/
|
||||
|
||||
@@ -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
|
||||
*********************/
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 = ""
|
||||
|
||||
+20
-9
@@ -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
|
||||
|
||||
+25
-25
@@ -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;
|
||||
}
|
||||
|
||||
+2
-37
@@ -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
|
||||
|
||||
@@ -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*/
|
||||
+30
-14
@@ -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);
|
||||
}
|
||||
|
||||
+5
-59
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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*/
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
**********************/
|
||||
|
||||
@@ -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*/
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
**********************/
|
||||
|
||||
@@ -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*/
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user