fix(display): fix inconsistency in the API (#5136)

This commit is contained in:
Gabor Kiss-Vamosi
2024-01-11 06:38:24 +01:00
committed by GitHub
parent 0f3c9b4734
commit e10f573150
24 changed files with 56 additions and 63 deletions

View File

@@ -250,7 +250,7 @@ static void inactive_timer_cb(lv_timer_t * t)
}
if(lv_display_get_inactive_time(NULL) > 8000) {
lv_display_trig_activity(NULL);
lv_display_trigger_activity(NULL);
lv_obj_scroll_by(cont, 100, 0, LV_ANIM_ON);
lv_obj_add_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE);
scrolled = true;

View File

@@ -41,7 +41,7 @@ hidden if you register only one display. By default, the last created
:cpp:func:`lv_layer_sys`, :c:macro:`LV_HOR_RES` and :c:macro:`LV_VER_RES` are always applied
on the most recently created (default) display. If you pass ``NULL`` as
``disp`` parameter to display related functions the default display will
usually be used. E.g. :cpp:expr:`lv_display_trig_activity(NULL)` will trigger a
usually be used. E.g. :cpp:expr:`lv_display_trigger_activity(NULL)` will trigger a
user activity on the default display. (See below in :ref:`Inactivity <display_inactivity>`).
Mirror display
@@ -91,7 +91,7 @@ To create a screen, use
To load a screen, use :cpp:expr:`lv_screen_load(scr)`. To get the active screen,
use :cpp:expr:`lv_screen_active()`. These functions work on the default display. If
you want to specify which display to work on, use
:cpp:expr:`lv_display_get_screen_active(disp)` and :cpp:expr:`lv_display_load_scr(disp, scr)`. A
:cpp:expr:`lv_display_get_screen_active(disp)` and :cpp:expr:`lv_display_load_screen(disp, scr)`. A
screen can be loaded with animations too. Read more
:ref:`here <objects_load_screens>`.
@@ -144,7 +144,7 @@ inactivity time among all displays will be returned (**NULL isn't just
the default display**).
You can manually trigger an activity using
:cpp:expr:`lv_display_trig_activity(disp)`. If ``disp`` is ``NULL``, the default
:cpp:expr:`lv_display_trigger_activity(disp)`. If ``disp`` is ``NULL``, the default
screen will be used (**and not all displays**).
Background

View File

@@ -282,7 +282,7 @@ void lv_obj_mark_layout_as_dirty(lv_obj_t * obj)
scr->scr_layout_inv = 1;
/*Make the display refreshing*/
lv_display_t * disp = lv_obj_get_disp(scr);
lv_display_t * disp = lv_obj_get_display(scr);
lv_display_send_event(disp, LV_EVENT_REFR_REQUEST, NULL);
}
@@ -803,14 +803,14 @@ void lv_obj_invalidate_area(const lv_obj_t * obj, const lv_area_t * area)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_display_t * disp = lv_obj_get_disp(obj);
lv_display_t * disp = lv_obj_get_display(obj);
if(!lv_display_is_invalidation_enabled(disp)) return;
lv_area_t area_tmp;
lv_area_copy(&area_tmp, area);
if(!lv_obj_area_is_visible(obj, &area_tmp)) return;
_lv_inv_area(lv_obj_get_disp(obj), &area_tmp);
_lv_inv_area(lv_obj_get_display(obj), &area_tmp);
}
void lv_obj_invalidate(const lv_obj_t * obj)
@@ -835,7 +835,7 @@ bool lv_obj_area_is_visible(const lv_obj_t * obj, lv_area_t * area)
/*Invalidate the object only if it belongs to the current or previous or one of the layers'*/
lv_obj_t * obj_scr = lv_obj_get_screen(obj);
lv_display_t * disp = lv_obj_get_disp(obj_scr);
lv_display_t * disp = lv_obj_get_display(obj_scr);
if(obj_scr != lv_display_get_screen_active(disp) &&
obj_scr != lv_display_get_screen_prev(disp) &&
obj_scr != lv_display_get_layer_bottom(disp) &&

View File

@@ -305,7 +305,7 @@ void lv_obj_scroll_by(lv_obj_t * obj, int32_t dx, int32_t dy, lv_anim_enable_t a
{
if(dx == 0 && dy == 0) return;
if(anim_en == LV_ANIM_ON) {
lv_display_t * d = lv_obj_get_disp(obj);
lv_display_t * d = lv_obj_get_display(obj);
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, obj);

View File

@@ -64,7 +64,7 @@ void lv_obj_delete(lv_obj_t * obj)
lv_display_t * disp = NULL;
bool act_screen_del = false;
if(par == NULL) {
disp = lv_obj_get_disp(obj);
disp = lv_obj_get_display(obj);
if(!disp) return; /*Shouldn't happen*/
if(disp->act_scr == obj) act_screen_del = true;
}
@@ -286,7 +286,7 @@ lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj)
return (lv_obj_t *)act_par;
}
lv_display_t * lv_obj_get_disp(const lv_obj_t * obj)
lv_display_t * lv_obj_get_display(const lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
@@ -529,7 +529,7 @@ static void obj_delete_core(lv_obj_t * obj)
/*Remove the screen for the screen list*/
if(obj->parent == NULL) {
lv_display_t * disp = lv_obj_get_disp(obj);
lv_display_t * disp = lv_obj_get_display(obj);
uint32_t i;
/*Find the screen in the list*/
for(i = 0; i < disp->screen_cnt; i++) {

View File

@@ -114,7 +114,7 @@ lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj);
* @param obj pointer to an object
* @return pointer to the object's display
*/
lv_display_t * lv_obj_get_disp(const lv_obj_t * obj);
lv_display_t * lv_obj_get_display(const lv_obj_t * obj);
/**
* Get the parent of an object

View File

@@ -89,7 +89,7 @@ static int _evdev_calibrate(int v, int in_min, int in_max, int out_min, int out_
static lv_point_t _evdev_process_pointer(lv_indev_t * indev, int x, int y)
{
lv_display_t * disp = lv_indev_get_disp(indev);
lv_display_t * disp = lv_indev_get_display(indev);
lv_evdev_t * dsc = lv_indev_get_driver_data(indev);
LV_ASSERT_NULL(dsc);

View File

@@ -120,7 +120,7 @@ void _lv_sdl_keyboard_handler(SDL_Event * event)
/*Find a suitable indev*/
lv_indev_t * indev = lv_indev_get_next(NULL);
while(indev) {
if(lv_indev_get_disp(indev) == disp && lv_indev_get_type(indev) == LV_INDEV_TYPE_KEYPAD) {
if(lv_indev_get_display(indev) == disp && lv_indev_get_type(indev) == LV_INDEV_TYPE_KEYPAD) {
break;
}
indev = lv_indev_get_next(indev);

View File

@@ -121,7 +121,7 @@ void _lv_sdl_mouse_handler(SDL_Event * event)
/*Find a suitable indev*/
lv_indev_t * indev = lv_indev_get_next(NULL);
while(indev) {
if(lv_indev_get_disp(indev) == disp && lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER) {
if(lv_indev_get_display(indev) == disp && lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER) {
break;
}
indev = lv_indev_get_next(indev);

View File

@@ -104,7 +104,7 @@ void _lv_sdl_mousewheel_handler(SDL_Event * event)
/*Find a suitable indev*/
lv_indev_t * indev = lv_indev_get_next(NULL);
while(indev) {
if(lv_indev_get_disp(indev) == disp && lv_indev_get_type(indev) == LV_INDEV_TYPE_ENCODER) {
if(lv_indev_get_display(indev) == disp && lv_indev_get_type(indev) == LV_INDEV_TYPE_ENCODER) {
break;
}
indev = lv_indev_get_next(indev);

View File

@@ -154,8 +154,8 @@ void lv_display_delete(lv_display_t * disp)
lv_indev_t * indev;
indev = lv_indev_get_next(NULL);
while(indev) {
if(lv_indev_get_disp(indev) == disp) {
lv_indev_set_disp(indev, NULL);
if(lv_indev_get_display(indev) == disp) {
lv_indev_set_display(indev, NULL);
}
indev = lv_indev_get_next(indev);
}
@@ -496,11 +496,6 @@ lv_obj_t * lv_display_get_screen_prev(lv_display_t * disp)
return disp->prev_scr;
}
void lv_display_load_scr(lv_obj_t * scr)
{
lv_screen_load_anim(scr, LV_SCR_LOAD_ANIM_NONE, 0, 0, false);
}
lv_obj_t * lv_display_get_layer_top(lv_display_t * disp)
{
if(!disp) disp = lv_display_get_default();
@@ -534,10 +529,15 @@ 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)
{
lv_screen_load_anim(scr, LV_SCR_LOAD_ANIM_NONE, 0, 0, false);
}
void lv_screen_load_anim(lv_obj_t * new_scr, lv_screen_load_anim_t anim_type, uint32_t time, uint32_t delay,
bool auto_del)
{
lv_display_t * d = lv_obj_get_disp(new_scr);
lv_display_t * d = lv_obj_get_display(new_scr);
lv_obj_t * act_scr = lv_screen_active();
if(act_scr == new_scr || d->scr_to_load == new_scr) {
@@ -807,11 +807,11 @@ uint32_t lv_display_get_inactive_time(const lv_display_t * disp)
return t;
}
void lv_display_trig_activity(lv_display_t * disp)
void lv_display_trigger_activity(lv_display_t * disp)
{
if(!disp) disp = lv_display_get_default();
if(!disp) {
LV_LOG_WARN("lv_display_trig_activity: no display registered");
LV_LOG_WARN("lv_display_trigger_activity: no display registered");
return;
}
@@ -940,7 +940,7 @@ static void scr_load_internal(lv_obj_t * scr)
LV_ASSERT_NULL(scr);
if(scr == NULL) return;
lv_display_t * d = lv_obj_get_disp(scr);
lv_display_t * d = lv_obj_get_display(scr);
if(!d) return; /*Shouldn't happen, just to be sure*/
lv_obj_t * old_scr = d->act_scr;
@@ -959,7 +959,7 @@ static void scr_load_internal(lv_obj_t * scr)
static void scr_load_anim_start(lv_anim_t * a)
{
lv_display_t * d = lv_obj_get_disp(a->var);
lv_display_t * d = lv_obj_get_display(a->var);
d->prev_scr = lv_screen_active();
d->act_scr = a->var;
@@ -984,7 +984,7 @@ static void set_y_anim(void * obj, int32_t v)
static void scr_anim_ready(lv_anim_t * a)
{
lv_display_t * d = lv_obj_get_disp(a->var);
lv_display_t * d = lv_obj_get_display(a->var);
lv_obj_send_event(d->act_scr, LV_EVENT_SCREEN_LOADED, NULL);
lv_obj_send_event(d->prev_scr, LV_EVENT_SCREEN_UNLOADED, NULL);

View File

@@ -333,12 +333,6 @@ lv_obj_t * lv_display_get_screen_active(lv_display_t * disp);
*/
lv_obj_t * lv_display_get_screen_prev(lv_display_t * disp);
/**
* Make a screen active
* @param scr pointer to a screen
*/
void lv_display_load_scr(lv_obj_t * scr);
/**
* Return the top layer. The top layer is the same on all screens and it is above the normal screen layer.
* @param disp pointer to display which top layer should be get. (NULL to use the default screen)
@@ -361,6 +355,12 @@ lv_obj_t * lv_display_get_layer_sys(lv_display_t * disp);
*/
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);
/**
* Switch screen with animation
* @param scr pointer to the new screen to load
@@ -408,15 +408,6 @@ static inline lv_obj_t * lv_layer_bottom(void)
return lv_display_get_layer_bottom(lv_display_get_default());
}
/**
* Load a screen on the default display
* @param scr pointer to a screen
*/
static inline void lv_screen_load(lv_obj_t * scr)
{
lv_display_load_scr(scr);
}
/*---------------------
* OTHERS
*--------------------*/
@@ -496,7 +487,7 @@ uint32_t lv_display_get_inactive_time(const lv_display_t * disp);
* Manually trigger an activity on a display
* @param disp pointer to a display (NULL to use the default display)
*/
void lv_display_trig_activity(lv_display_t * disp);
void lv_display_trigger_activity(lv_display_t * disp);
/**
* Temporarily enable and disable the invalidation of the display.

View File

@@ -335,14 +335,14 @@ lv_group_t * lv_indev_get_group(const lv_indev_t * indev)
return indev->group;
}
lv_display_t * lv_indev_get_disp(const lv_indev_t * indev)
lv_display_t * lv_indev_get_display(const lv_indev_t * indev)
{
if(indev == NULL) return NULL;
return indev->disp;
}
void lv_indev_set_disp(lv_indev_t * indev, lv_display_t * disp)
void lv_indev_set_display(lv_indev_t * indev, lv_display_t * disp)
{
if(indev == NULL) return;

View File

@@ -131,9 +131,9 @@ lv_indev_state_t lv_indev_get_state(const lv_indev_t * indev);
lv_group_t * lv_indev_get_group(const lv_indev_t * indev);
lv_display_t * lv_indev_get_disp(const lv_indev_t * indev);
void lv_indev_set_display(lv_indev_t * indev, struct _lv_display_t * disp);
void lv_indev_set_disp(lv_indev_t * indev, lv_display_t * disp);
lv_display_t * lv_indev_get_display(const lv_indev_t * indev);
void * lv_indev_get_user_data(const lv_indev_t * indev);

View File

@@ -102,6 +102,7 @@ static inline void lv_obj_move_background(lv_obj_t * obj)
#define lv_obj_clear_flag lv_obj_remove_flag
#define lv_obj_clear_state lv_obj_remove_state
#define lv_indev_set_disp lv_indev_set_display
#define lv_indev_get_act lv_indev_active
#define lv_scr_act lv_screen_active
#define lv_disp_create lv_display_create
@@ -132,7 +133,7 @@ static inline void lv_obj_move_background(lv_obj_t * obj)
#define lv_disp_is_double_buffered lv_display_is_double_buffered
#define lv_disp_get_scr_act lv_display_get_screen_active
#define lv_disp_get_scr_prev lv_display_get_screen_prev
#define lv_disp_load_scr lv_display_load_scr
#define lv_disp_load_scr lv_screen_load
#define lv_disp_get_layer_top lv_display_get_layer_top
#define lv_disp_get_layer_sys lv_display_get_layer_sys
#define lv_disp_get_layer_bottom lv_display_get_layer_bottom
@@ -144,7 +145,7 @@ static inline void lv_obj_move_background(lv_obj_t * obj)
#define lv_disp_set_theme lv_display_set_theme
#define lv_disp_get_theme lv_display_get_theme
#define lv_disp_get_inactive_time lv_display_get_inactive_time
#define lv_disp_trig_activity lv_display_trig_activity
#define lv_disp_trig_activity lv_display_trigger_activity
#define lv_disp_enable_invalidation lv_display_enable_invalidation
#define lv_disp_is_invalidation_enabled lv_display_is_invalidation_enabled
#define lv_disp_set_user_data lv_display_set_user_data
@@ -233,6 +234,7 @@ static inline void lv_obj_move_background(lv_obj_t * obj)
#define lv_dropdown_get_option_cnt lv_dropdown_get_option_count
#define lv_obj_get_child_cnt lv_obj_get_child_count
#define lv_obj_get_disp lv_obj_get_display
#define lv_obj_get_style_img_opa lv_obj_get_style_image_opa
#define lv_obj_get_style_img_recolor lv_obj_get_style_image_recolor

View File

@@ -120,7 +120,7 @@ lv_result_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_color_format_t cf, lv_ima
layer._clip_area = snapshot_area;
lv_display_t * disp_old = _lv_refr_get_disp_refreshing();
lv_display_t * disp_new = lv_obj_get_disp(obj);
lv_display_t * disp_new = lv_obj_get_display(obj);
lv_layer_t * layer_old = disp_new->layer_head;
disp_new->layer_head = &layer;

View File

@@ -36,7 +36,7 @@ static void apply_theme_recursion(lv_theme_t * th, lv_obj_t * obj);
lv_theme_t * lv_theme_get_from_obj(lv_obj_t * obj)
{
lv_display_t * disp = obj ? lv_obj_get_disp(obj) : lv_display_get_default();
lv_display_t * disp = obj ? lv_obj_get_display(obj) : lv_display_get_default();
return lv_display_get_theme(disp);
}

View File

@@ -979,7 +979,7 @@ static void invalidate_button_area(const lv_obj_t * obj, uint32_t btn_idx)
int32_t col_gap = lv_obj_get_style_pad_column(obj, LV_PART_MAIN);
/*Be sure to have a minimal extra space if row/col_gap is small*/
int32_t dpi = lv_display_get_dpi(lv_obj_get_disp(obj));
int32_t dpi = lv_display_get_dpi(lv_obj_get_display(obj));
row_gap = LV_MAX(row_gap, dpi / 10);
col_gap = LV_MAX(col_gap, dpi / 10);

View File

@@ -357,7 +357,7 @@ void lv_canvas_finish_layer(lv_obj_t * canvas, lv_layer_t * layer)
{
while(layer->draw_task_head) {
lv_draw_dispatch_wait_for_request();
lv_draw_dispatch_layer(lv_obj_get_disp(canvas), layer);
lv_draw_dispatch_layer(lv_obj_get_display(canvas), layer);
}
}

View File

@@ -284,7 +284,7 @@ void lv_image_set_rotation(lv_obj_t * obj, int32_t angle)
/* Disable invalidations because lv_obj_refresh_ext_draw_size would invalidate
* the whole ext draw area */
lv_display_t * disp = lv_obj_get_disp(obj);
lv_display_t * disp = lv_obj_get_display(obj);
lv_display_enable_invalidation(disp, false);
lv_obj_refresh_ext_draw_size(obj);
lv_display_enable_invalidation(disp, true);
@@ -326,7 +326,7 @@ void lv_image_set_pivot(lv_obj_t * obj, int32_t x, int32_t y)
/* Disable invalidations because lv_obj_refresh_ext_draw_size would invalidate
* the whole ext draw area */
lv_display_t * disp = lv_obj_get_disp(obj);
lv_display_t * disp = lv_obj_get_display(obj);
lv_display_enable_invalidation(disp, false);
lv_obj_refresh_ext_draw_size(obj);
lv_display_enable_invalidation(disp, true);
@@ -784,7 +784,7 @@ static void scale_update(lv_obj_t * obj, int32_t scale_x, int32_t scale_y)
/* Disable invalidations because lv_obj_refresh_ext_draw_size would invalidate
* the whole ext draw area */
lv_display_t * disp = lv_obj_get_disp(obj);
lv_display_t * disp = lv_obj_get_display(obj);
lv_display_enable_invalidation(disp, false);
lv_obj_refresh_ext_draw_size(obj);
lv_display_enable_invalidation(disp, true);

View File

@@ -142,7 +142,7 @@ lv_obj_t * lv_msgbox_add_title(lv_obj_t * obj, const char * title)
if(mbox->header == NULL) return NULL;
lv_obj_class_init_obj(mbox->header);
lv_obj_set_size(mbox->header, lv_pct(100), lv_display_get_dpi(lv_obj_get_disp(obj)) / 3);
lv_obj_set_size(mbox->header, lv_pct(100), lv_display_get_dpi(lv_obj_get_display(obj)) / 3);
lv_obj_set_flex_flow(mbox->header, LV_FLEX_FLOW_ROW);
lv_obj_set_flex_align(mbox->header, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
lv_obj_move_to_index(mbox->header, 0);

View File

@@ -197,7 +197,7 @@ void lv_tabview_set_tab_bar_position(lv_obj_t * obj, lv_dir_t dir)
bool now_ver = dir & LV_DIR_VER;
if(was_ver != now_ver) {
int32_t dpi = lv_display_get_dpi(lv_obj_get_disp(obj));
int32_t dpi = lv_display_get_dpi(lv_obj_get_display(obj));
if(now_ver) {
lv_obj_set_size(tab_bar, lv_pct(100), dpi / 2);
}

View File

@@ -96,7 +96,7 @@ static void lv_win_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN);
lv_obj_t * header = lv_obj_create(obj);
lv_obj_set_size(header, LV_PCT(100), lv_display_get_dpi(lv_obj_get_disp(obj)) / 2);
lv_obj_set_size(header, LV_PCT(100), lv_display_get_dpi(lv_obj_get_display(obj)) / 2);
lv_obj_set_flex_flow(header, LV_FLEX_FLOW_ROW);
lv_obj_set_flex_align(header, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);

View File

@@ -38,7 +38,7 @@ void test_win_should_have_valid_documented_default_values(void)
TEST_ASSERT_EQUAL(content, lv_obj_get_child(win, 1));
// Check that the header is correctly sized and empty
TEST_ASSERT_EQUAL(lv_display_get_dpi(lv_obj_get_disp(win)) / 2, lv_obj_get_height(header));
TEST_ASSERT_EQUAL(lv_display_get_dpi(lv_obj_get_display(win)) / 2, lv_obj_get_height(header));
TEST_ASSERT_EQUAL(0, lv_obj_get_child_count(header));
// Check that the content is empty