2016-06-08 07:25:08 +02:00
|
|
|
/**
|
|
|
|
* @file lv_base_obj.c
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
2016-12-18 22:07:03 +01:00
|
|
|
|
|
|
|
#include <lv_conf.h>
|
|
|
|
#include <lvgl/lv_draw/lv_draw_rbasic.h>
|
|
|
|
#include <lvgl/lv_draw/lv_draw_vbasic.h>
|
|
|
|
#include <lvgl/lv_misc/anim.h>
|
|
|
|
#include <lvgl/lv_obj/lv_dispi.h>
|
|
|
|
#include <lvgl/lv_obj/lv_obj.h>
|
|
|
|
#include <lvgl/lv_obj/lv_refr.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-12-17 12:02:30 +01:00
|
|
|
#ifdef LV_IMG_DEF_WALLPAPER
|
|
|
|
#include "../lv_objx/lv_img.h"
|
|
|
|
#endif
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* STATIC PROTOTYPES
|
|
|
|
**********************/
|
2016-10-07 11:15:46 +02:00
|
|
|
static void lv_obj_pos_child_refr(lv_obj_t * obj, cord_t x_diff, cord_t y_diff);
|
|
|
|
static void lv_style_refr_core(void * style_p, lv_obj_t * obj);
|
2016-12-21 14:49:23 +01:00
|
|
|
static void lv_obj_del_child(lv_obj_t * obj);
|
2016-10-07 11:15:46 +02:00
|
|
|
static bool lv_obj_design(lv_obj_t * obj, const area_t * mask_p, lv_design_mode_t mode);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/**********************
|
|
|
|
* STATIC VARIABLES
|
|
|
|
**********************/
|
2016-12-17 12:02:30 +01:00
|
|
|
static lv_obj_t * def_scr = NULL;
|
|
|
|
static lv_obj_t * act_scr = NULL;
|
|
|
|
static ll_dsc_t scr_ll;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-12-17 12:02:30 +01:00
|
|
|
static lv_objs_t lv_objs_def = {.color = COLOR_MAKE(0xa0, 0xc0, 0xe0), .transp = 0};
|
|
|
|
static lv_objs_t lv_objs_scr = {.color = LV_OBJ_DEF_SCR_COLOR, .transp = 0};
|
|
|
|
static lv_objs_t lv_objs_transp = {.transp = 1};
|
|
|
|
|
|
|
|
#ifdef LV_IMG_DEF_WALLPAPER
|
|
|
|
LV_IMG_DECLARE(LV_IMG_DEF_WALLPAPER);
|
|
|
|
#endif
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* GLOBAL FUNCTIONS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Init. the 'lv' library.
|
|
|
|
*/
|
|
|
|
void lv_init(void)
|
|
|
|
{
|
|
|
|
/*Clear the screen*/
|
|
|
|
area_t scr_area;
|
|
|
|
area_set(&scr_area, 0, 0, LV_HOR_RES, LV_VER_RES);
|
|
|
|
lv_rfill(&scr_area, NULL, COLOR_BLACK, OPA_COVER);
|
|
|
|
|
|
|
|
/*Init. the screen refresh system*/
|
|
|
|
lv_refr_init();
|
|
|
|
|
2016-07-12 15:05:17 +02:00
|
|
|
/*Init. the animations*/
|
|
|
|
anim_init();
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/*Create the default screen*/
|
|
|
|
ll_init(&scr_ll, sizeof(lv_obj_t));
|
2016-12-17 12:02:30 +01:00
|
|
|
#ifdef LV_IMG_DEF_WALLPAPER
|
|
|
|
lv_img_create_file("def_wp", LV_IMG_DEF_WALLPAPER);
|
|
|
|
def_scr = lv_img_create(NULL, NULL);
|
|
|
|
lv_img_set_auto_size(def_scr, false);
|
|
|
|
lv_img_set_file(def_scr, "U:/def_wp");
|
|
|
|
#else
|
2016-10-07 11:15:46 +02:00
|
|
|
def_scr = lv_obj_create(NULL, NULL);
|
2016-12-17 12:02:30 +01:00
|
|
|
#endif
|
2016-10-07 11:15:46 +02:00
|
|
|
act_scr = def_scr;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Refresh the screen*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_inv(act_scr);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
#if LV_DISPI_READ_PERIOD != 0
|
|
|
|
/*Init the display input handling*/
|
|
|
|
lv_dispi_init();
|
|
|
|
#endif
|
2016-12-21 14:49:23 +01:00
|
|
|
|
|
|
|
/*Initialize the application level*/
|
|
|
|
#if LV_APP_ENABLE != 0
|
|
|
|
lv_app_init();
|
|
|
|
#endif
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-15 10:31:30 +01:00
|
|
|
* Mark the object as invalid therefore its current position will be redrawn by 'lv_refr_task'
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_inv(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
|
|
|
/*Invalidate the object only if it belongs to the 'act_scr'*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * act_scr_p = lv_scr_act();
|
|
|
|
if(lv_obj_get_scr(obj) == act_scr_p) {
|
2016-12-16 07:41:34 +01:00
|
|
|
/*Truncate recursively to the parents*/
|
2016-06-08 07:25:08 +02:00
|
|
|
area_t area_trunc;
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * par = lv_obj_get_parent(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
bool union_ok = true;
|
|
|
|
/*Start with the original coordinates*/
|
2016-10-17 15:02:18 +02:00
|
|
|
cord_t ext_size = obj->ext_size;
|
2016-10-07 11:15:46 +02:00
|
|
|
area_cpy(&area_trunc, &obj->cords);
|
2016-10-17 15:02:18 +02:00
|
|
|
area_trunc.x1 -= ext_size;
|
|
|
|
area_trunc.y1 -= ext_size;
|
|
|
|
area_trunc.x2 += ext_size;
|
|
|
|
area_trunc.y2 += ext_size;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Check through all parents*/
|
2016-10-07 11:15:46 +02:00
|
|
|
while(par != NULL) {
|
|
|
|
union_ok = area_union(&area_trunc, &area_trunc, &par->cords);
|
2016-06-08 07:25:08 +02:00
|
|
|
if(union_ok == false) break; /*If no common parts with parent break;*/
|
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
par = lv_obj_get_parent(par);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(union_ok != false) lv_inv_area(&area_trunc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify an object if its style is modified
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_refr_style(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_inv(obj);
|
|
|
|
obj->signal_f(obj, LV_SIGNAL_STYLE_CHG, NULL);
|
|
|
|
lv_obj_inv(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify all object if a style is modified
|
2016-12-15 10:31:30 +01:00
|
|
|
* @param style pinter to a style. Only objects with this style will be notified
|
2016-06-08 07:25:08 +02:00
|
|
|
* (NULL to notify all objects)
|
|
|
|
*/
|
2016-12-15 10:31:30 +01:00
|
|
|
void lv_style_refr_all(void * style)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * i;
|
2016-06-08 07:25:08 +02:00
|
|
|
LL_READ(scr_ll, i) {
|
2016-12-15 10:31:30 +01:00
|
|
|
lv_style_refr_core(style, i);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------
|
|
|
|
* Create and delete
|
|
|
|
*-------------------*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a basic object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param parent pointer to a parent object.
|
2016-06-08 07:25:08 +02:00
|
|
|
* If NULL then a screen will be created
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param copy pointer to a base object, if not NULL then the new object will be copied from it
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return pointer to the new object
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * new_obj = NULL;
|
2016-06-08 07:25:08 +02:00
|
|
|
/*Create a screen if the parent is NULL*/
|
2016-10-07 11:15:46 +02:00
|
|
|
if(parent == NULL) {
|
|
|
|
new_obj = ll_ins_head(&scr_ll);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
new_obj->par = NULL; /*Screens has no a parent*/
|
|
|
|
ll_init(&(new_obj->child_ll), sizeof(lv_obj_t));
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Set coordinates to full screen size*/
|
2016-10-07 11:15:46 +02:00
|
|
|
new_obj->cords.x1 = 0;
|
|
|
|
new_obj->cords.y1 = 0;
|
|
|
|
new_obj->cords.x2 = LV_HOR_RES - 1;
|
|
|
|
new_obj->cords.y2 = LV_VER_RES - 1;
|
2016-10-17 15:02:18 +02:00
|
|
|
new_obj->ext_size = 0;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Set appearance*/
|
2016-10-07 11:15:46 +02:00
|
|
|
new_obj->style_p = lv_objs_get(LV_OBJS_SCR, NULL);
|
|
|
|
new_obj->opa = OPA_COVER;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Set virtual functions*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_set_signal_f(new_obj, lv_obj_signal);
|
|
|
|
lv_obj_set_design_f(new_obj, lv_obj_design);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Set attributes*/
|
2016-10-07 11:15:46 +02:00
|
|
|
new_obj->click_en = 0;
|
|
|
|
new_obj->drag_en = 0;
|
|
|
|
new_obj->drag_throw_en = 0;
|
|
|
|
new_obj->drag_parent = 0;
|
|
|
|
new_obj->style_iso = 0;
|
|
|
|
new_obj->hidden = 0;
|
|
|
|
new_obj->top_en = 0;
|
|
|
|
new_obj->ext = NULL;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
2016-10-17 15:02:18 +02:00
|
|
|
/*parent != NULL create normal obj. on a parent*/
|
2016-06-08 07:25:08 +02:00
|
|
|
else
|
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
new_obj = ll_ins_head(&(parent)->child_ll);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
new_obj->par = parent; /*Set the parent*/
|
|
|
|
ll_init(&(new_obj->child_ll), sizeof(lv_obj_t));
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Set coordinates left top corner of parent*/
|
2016-10-07 11:15:46 +02:00
|
|
|
new_obj->cords.x1 = parent->cords.x1;
|
|
|
|
new_obj->cords.y1 = parent->cords.y1;
|
|
|
|
new_obj->cords.x2 = parent->cords.x1 +
|
2016-06-15 09:38:20 +02:00
|
|
|
LV_OBJ_DEF_WIDTH;
|
2016-10-07 11:15:46 +02:00
|
|
|
new_obj->cords.y2 = parent->cords.y1 +
|
2016-06-15 09:38:20 +02:00
|
|
|
LV_OBJ_DEF_HEIGHT;
|
2016-10-17 15:02:18 +02:00
|
|
|
new_obj->ext_size = 0;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Set appearance*/
|
2016-10-07 11:15:46 +02:00
|
|
|
new_obj->style_p = lv_objs_get(LV_OBJS_DEF, NULL);
|
|
|
|
new_obj->opa = OPA_COVER;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Set virtual functions*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_set_signal_f(new_obj, lv_obj_signal);
|
|
|
|
lv_obj_set_design_f(new_obj, lv_obj_design);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Set attributes*/
|
2016-10-07 11:15:46 +02:00
|
|
|
new_obj->click_en = 1;
|
|
|
|
new_obj->drag_en = 0;
|
|
|
|
new_obj->drag_throw_en = 0;
|
|
|
|
new_obj->drag_parent = 0;
|
|
|
|
new_obj->style_iso = 0;
|
|
|
|
new_obj->hidden = 0;
|
|
|
|
new_obj->top_en = 0;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
new_obj->ext = NULL;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
if(copy != NULL) {
|
|
|
|
area_cpy(&new_obj->cords, ©->cords);
|
2016-10-17 15:02:18 +02:00
|
|
|
new_obj->ext_size = copy->ext_size;
|
2016-06-08 07:25:08 +02:00
|
|
|
/*Set attributes*/
|
2016-10-07 11:15:46 +02:00
|
|
|
new_obj->click_en = copy->click_en;
|
|
|
|
new_obj->drag_en = copy->drag_en;
|
|
|
|
new_obj->drag_throw_en = copy->drag_throw_en;
|
|
|
|
new_obj->drag_parent = copy->drag_parent;
|
|
|
|
new_obj->hidden = copy->hidden;
|
|
|
|
new_obj->top_en = copy->top_en;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
new_obj->style_p = copy->style_p;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
if(copy->style_iso != 0) {
|
|
|
|
lv_obj_iso_style(new_obj, dm_get_size(copy->style_p));
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_set_pos(new_obj, lv_obj_get_x(copy), lv_obj_get_y(copy));
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
new_obj->opa = copy->opa;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*Send a signal to the parent to notify it about the new child*/
|
2016-10-07 11:15:46 +02:00
|
|
|
if(parent != NULL) {
|
|
|
|
parent->signal_f(parent, LV_SIGNAL_CHILD_CHG, new_obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Invalidate the area if not screen created*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_inv(new_obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
return new_obj;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-10-07 11:15:46 +02:00
|
|
|
* Delete 'obj' and all of its children
|
|
|
|
* @param obj
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_del(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_inv(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Recursively delete the children*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * i;
|
|
|
|
lv_obj_t * i_next;
|
|
|
|
i = ll_get_head(&(obj->child_ll));
|
2016-06-08 07:25:08 +02:00
|
|
|
while(i != NULL) {
|
|
|
|
/*Get the next object before delete this*/
|
2016-10-07 11:15:46 +02:00
|
|
|
i_next = ll_get_next(&(obj->child_ll), i);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Call the recursive del to the child too*/
|
2016-12-21 14:49:23 +01:00
|
|
|
lv_obj_del_child(i);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Set i to the next node*/
|
|
|
|
i = i_next;
|
|
|
|
}
|
|
|
|
|
2016-10-20 16:35:03 +02:00
|
|
|
/*Remove the animations from this object*/
|
|
|
|
anim_del(obj, NULL);
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/*Remove the object from parent's children list*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * par = lv_obj_get_parent(obj);
|
|
|
|
if(par == NULL) { /*It is a screen*/
|
|
|
|
ll_rem(&scr_ll, obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
} else {
|
2016-10-07 11:15:46 +02:00
|
|
|
ll_rem(&(par->child_ll), obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* All children deleted.
|
|
|
|
* Now clean up the object specific data*/
|
2016-10-07 11:15:46 +02:00
|
|
|
obj->signal_f(obj, LV_SIGNAL_CLEANUP, NULL);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Delete the base objects*/
|
2016-10-07 11:15:46 +02:00
|
|
|
if(obj->ext != NULL) dm_free(obj->ext);
|
|
|
|
if(obj->style_iso != 0) dm_free(obj->style_p);
|
|
|
|
dm_free(obj); /*Free the object itself*/
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/* Reset all display input (dispi) because
|
|
|
|
* the deleted object can be being pressed*/
|
|
|
|
lv_dispi_reset();
|
|
|
|
|
|
|
|
/*Send a signal to the parent to notify it about the child delete*/
|
2016-10-07 11:15:46 +02:00
|
|
|
if(par != NULL) {
|
|
|
|
par->signal_f(par, LV_SIGNAL_CHILD_CHG, NULL);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signal function of the basic object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param sign signal type
|
|
|
|
* @param param parameter for the signal (depends on signal type)
|
|
|
|
* @return false: the object become invalid (e.g. deleted)
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
bool lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
|
|
|
bool valid = true;
|
|
|
|
|
|
|
|
switch(sign) {
|
2016-06-20 18:18:36 +02:00
|
|
|
case LV_SIGNAL_CHILD_CHG:
|
2016-06-22 21:52:39 +02:00
|
|
|
/*Return 'invalid' if the child change signal is not enabled*/
|
2016-10-07 11:15:46 +02:00
|
|
|
if(obj->child_chg_off != 0) valid = false;
|
2016-06-20 18:18:36 +02:00
|
|
|
break;
|
2016-06-08 07:25:08 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return with a pointer to built-in style and/or copy it to a variable
|
|
|
|
* @param style a style name from lv_objs_builtin_t enum
|
|
|
|
* @param copy_p copy the style to this variable. (NULL if unused)
|
|
|
|
* @return pointer to an lv_objs_t style
|
|
|
|
*/
|
|
|
|
lv_objs_t * lv_objs_get(lv_objs_builtin_t style, lv_objs_t * copy_p)
|
|
|
|
{
|
|
|
|
lv_objs_t *style_p;
|
|
|
|
|
|
|
|
switch(style) {
|
|
|
|
case LV_OBJS_DEF:
|
|
|
|
style_p = &lv_objs_def;
|
|
|
|
break;
|
|
|
|
case LV_OBJS_SCR:
|
|
|
|
style_p = &lv_objs_scr;
|
|
|
|
break;
|
2016-07-12 01:16:27 +02:00
|
|
|
case LV_OBJS_TRANSP:
|
|
|
|
style_p = &lv_objs_transp;
|
2016-06-08 07:25:08 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
style_p = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(copy_p != NULL) {
|
|
|
|
if(style_p != NULL) memcpy(copy_p, style_p, sizeof(lv_objs_t));
|
|
|
|
else memcpy(copy_p, &lv_objs_def, sizeof(lv_objs_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
return style_p;
|
|
|
|
}
|
|
|
|
/*=====================
|
|
|
|
* Setter functions
|
|
|
|
*====================*/
|
|
|
|
|
|
|
|
/*--------------
|
|
|
|
* Screen set
|
|
|
|
*--------------*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load a new screen
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param scr pointer to a screen
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_scr_load(lv_obj_t * scr)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
act_scr = scr;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_inv(act_scr);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------
|
|
|
|
* Parent/children set
|
|
|
|
*--------------------*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a new parent for an object. Its relative position will be the same.
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
|
|
|
* @param parent pointer to the new parent object
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_inv(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
point_t old_pos;
|
2016-10-07 11:15:46 +02:00
|
|
|
old_pos.x = lv_obj_get_x(obj);
|
|
|
|
old_pos.y = lv_obj_get_y(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
ll_chg_list(&obj->par->child_ll, &parent->child_ll, obj);
|
|
|
|
obj->par = parent;
|
|
|
|
lv_obj_set_pos(obj, old_pos.x, old_pos.y);
|
2016-10-04 09:45:39 +02:00
|
|
|
|
|
|
|
/*Notify the original parent because one of its children is lost*/
|
2016-10-07 11:15:46 +02:00
|
|
|
obj->par->signal_f(obj->par, LV_SIGNAL_CHILD_CHG, NULL);
|
2016-10-04 09:45:39 +02:00
|
|
|
|
2016-06-22 15:16:08 +02:00
|
|
|
/*Notify the new parent about the child*/
|
2016-10-07 11:15:46 +02:00
|
|
|
parent->signal_f(parent, LV_SIGNAL_CHILD_CHG, obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_inv(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------
|
|
|
|
* Coordinate set (cord_chk_f will be called)
|
|
|
|
* -----------------------------------------*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set relative the position of an object (relative to the parent)
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param x new distance from the left side of the parent
|
|
|
|
* @param y new distance from the top of the parent
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_pos(lv_obj_t * obj, cord_t x, cord_t y)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
|
|
|
/*Convert x and y to absolute coordinates*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * par = obj->par;
|
|
|
|
x = x + par->cords.x1;
|
|
|
|
y = y + par->cords.y1;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Calculate and set the movement*/
|
|
|
|
point_t diff;
|
2016-10-07 11:15:46 +02:00
|
|
|
diff.x = x - obj->cords.x1;
|
|
|
|
diff.y = y - obj->cords.y1;
|
2016-06-20 18:18:36 +02:00
|
|
|
|
2016-06-22 15:16:08 +02:00
|
|
|
/* Do nothing if the position is not changed */
|
|
|
|
/* It is very important else recursive positioning can
|
|
|
|
* occur without position change*/
|
2016-06-20 18:18:36 +02:00
|
|
|
if(diff.x == 0 && diff.y == 0) return;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-06-22 15:16:08 +02:00
|
|
|
/*Invalidate the original area*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_inv(obj);
|
2016-06-22 15:16:08 +02:00
|
|
|
|
|
|
|
/*Save the original coordinates*/
|
|
|
|
area_t ori;
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_get_cords(obj, &ori);
|
2016-06-22 15:16:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
obj->cords.x1 += diff.x;
|
|
|
|
obj->cords.y1 += diff.y;
|
|
|
|
obj->cords.x2 += diff.x;
|
|
|
|
obj->cords.y2 += diff.y;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_pos_child_refr(obj, diff.x, diff.y);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-06-22 15:16:08 +02:00
|
|
|
/*Inform the object about its new coordinates*/
|
2016-10-07 11:15:46 +02:00
|
|
|
obj->signal_f(obj, LV_SIGNAL_CORD_CHG, &ori);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Send a signal to the parent too*/
|
2016-10-07 11:15:46 +02:00
|
|
|
par->signal_f(par, LV_SIGNAL_CHILD_CHG, obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Invalidate the new area*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_inv(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set relative the position of an object (relative to the parent).
|
|
|
|
* The coordinates will be upscaled to compensate LV_DOWNSCALE.
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param x new distance from the left side of the parent. (will be multiplied with LV_DOWNSCALE)
|
|
|
|
* @param y new distance from the top of the parent. (will be multiplied with LV_DOWNSCALE)
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_pos_us(lv_obj_t * obj, cord_t x, cord_t y)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_set_pos(obj, x * LV_DOWNSCALE, y * LV_DOWNSCALE);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the x coordinate of a object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param x new distance from the left side from the parent
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_x(lv_obj_t * obj, cord_t x)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_set_pos(obj, x, lv_obj_get_y(obj));
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the x coordinate of a object.
|
|
|
|
* The coordinate will be upscaled to compensate LV_DOWNSCALE.
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param x new distance from the left side from the parent. (will be multiplied with LV_DOWNSCALE)
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_x_us(lv_obj_t * obj, cord_t x)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_set_pos(obj, x * LV_DOWNSCALE, lv_obj_get_y(obj));
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the y coordinate of a object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param y new distance from the top of the parent
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_y(lv_obj_t * obj, cord_t y)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_set_pos(obj, lv_obj_get_x(obj), y);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the y coordinate of a object.
|
|
|
|
* The coordinate will be upscaled to compensate LV_DOWNSCALE.
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param y new distance from the top of the parent. (will be multiplied with LV_DOWNSCALE)
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_y_us(lv_obj_t * obj, cord_t y)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_set_pos(obj, lv_obj_get_x(obj), y * LV_DOWNSCALE);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the size of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param w new width
|
|
|
|
* @param h new height
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_size(lv_obj_t * obj, cord_t w, cord_t h)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-06-22 15:16:08 +02:00
|
|
|
|
|
|
|
/* Do nothing if the size is not changed */
|
|
|
|
/* It is very important else recursive resizing can
|
|
|
|
* occur without size change*/
|
2016-10-07 11:15:46 +02:00
|
|
|
if(lv_obj_get_width(obj) == w && lv_obj_get_height(obj) == h) {
|
2016-06-22 15:16:08 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/*Invalidate the original area*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_inv(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Save the original coordinates*/
|
|
|
|
area_t ori;
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_get_cords(obj, &ori);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
//Set the length and height
|
2016-10-07 11:15:46 +02:00
|
|
|
obj->cords.x2 = obj->cords.x1 + w - 1;
|
|
|
|
obj->cords.y2 = obj->cords.y1 + h - 1;
|
2016-06-22 15:16:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*Send a signal to the object with its new coordinates*/
|
2016-10-07 11:15:46 +02:00
|
|
|
obj->signal_f(obj, LV_SIGNAL_CORD_CHG, &ori);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Send a signal to the parent too*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * par = lv_obj_get_parent(obj);
|
|
|
|
if(par != NULL) par->signal_f(par, LV_SIGNAL_CHILD_CHG, obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Invalidate the new area*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_inv(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the size of an object. The coordinates will be upscaled to compensate LV_DOWNSCALE.
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param w new width (will be multiplied with LV_DOWNSCALE)
|
|
|
|
* @param h new height (will be multiplied with LV_DOWNSCALE)
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_size_us(lv_obj_t * obj, cord_t w, cord_t h)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_set_size(obj, w * LV_DOWNSCALE, h * LV_DOWNSCALE);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the width of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param w new width
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_width(lv_obj_t * obj, cord_t w)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_set_size(obj, w, lv_obj_get_height(obj));
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the width of an object. The width will be upscaled to compensate LV_DOWNSCALE
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param w new width (will be multiplied with LV_DOWNSCALE)
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_width_us(lv_obj_t * obj, cord_t w)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_set_size(obj, w * LV_DOWNSCALE, lv_obj_get_height(obj));
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the height of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param h new height
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_height(lv_obj_t * obj, cord_t h)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_set_size(obj, lv_obj_get_width(obj), h);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the height of an object. The height will be upscaled to compensate LV_DOWNSCALE
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param h new height (will be multiplied with LV_DOWNSCALE)
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_height_us(lv_obj_t * obj, cord_t h)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_set_size(obj, lv_obj_get_width(obj), h * LV_DOWNSCALE);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Align an object to an other object.
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object to align
|
|
|
|
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param align type of alignment (see 'lv_align_t' enum)
|
|
|
|
* @param x_mod x coordinate shift after alignment
|
|
|
|
* @param y_mod y coordinate shift after alignment
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
cord_t new_x = lv_obj_get_x(obj);
|
|
|
|
cord_t new_y = lv_obj_get_y(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
if(base == NULL) {
|
|
|
|
base = lv_obj_get_parent(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch(align)
|
|
|
|
{
|
|
|
|
case LV_ALIGN_CENTER:
|
2016-10-07 11:15:46 +02:00
|
|
|
new_x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
|
|
|
new_y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
2016-06-08 07:25:08 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_IN_TOP_LEFT:
|
|
|
|
new_x = 0;
|
|
|
|
new_y = 0;
|
|
|
|
break;
|
|
|
|
case LV_ALIGN_IN_TOP_MID:
|
2016-10-07 11:15:46 +02:00
|
|
|
new_x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
2016-06-08 07:25:08 +02:00
|
|
|
new_y = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_IN_TOP_RIGHT:
|
2016-10-07 11:15:46 +02:00
|
|
|
new_x = lv_obj_get_width(base) - lv_obj_get_width(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
new_y = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_IN_BOTTOM_LEFT:
|
|
|
|
new_x = 0;
|
2016-10-07 11:15:46 +02:00
|
|
|
new_y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
break;
|
|
|
|
case LV_ALIGN_IN_BOTTOM_MID:
|
2016-10-07 11:15:46 +02:00
|
|
|
new_x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
|
|
|
new_y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_IN_BOTTOM_RIGHT:
|
2016-10-07 11:15:46 +02:00
|
|
|
new_x = lv_obj_get_width(base) - lv_obj_get_width(obj);
|
|
|
|
new_y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_IN_LEFT_MID:
|
|
|
|
new_x = 0;
|
2016-10-07 11:15:46 +02:00
|
|
|
new_y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
2016-06-08 07:25:08 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_IN_RIGHT_MID:
|
2016-10-07 11:15:46 +02:00
|
|
|
new_x = lv_obj_get_width(base) - lv_obj_get_width(obj);
|
|
|
|
new_y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
2016-06-08 07:25:08 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_OUT_TOP_LEFT:
|
|
|
|
new_x = 0;
|
2016-10-07 11:15:46 +02:00
|
|
|
new_y = -lv_obj_get_height(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_OUT_TOP_MID:
|
2016-10-07 11:15:46 +02:00
|
|
|
new_x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
|
|
|
new_y = - lv_obj_get_height(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_OUT_TOP_RIGHT:
|
2016-10-07 11:15:46 +02:00
|
|
|
new_x = lv_obj_get_width(base) - lv_obj_get_width(obj);
|
|
|
|
new_y = - lv_obj_get_height(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_OUT_BOTTOM_LEFT:
|
|
|
|
new_x = 0;
|
2016-10-07 11:15:46 +02:00
|
|
|
new_y = lv_obj_get_height(base);
|
2016-06-08 07:25:08 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_OUT_BOTTOM_MID:
|
2016-10-07 11:15:46 +02:00
|
|
|
new_x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
|
|
|
new_y = lv_obj_get_height(base);
|
2016-06-08 07:25:08 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_OUT_BOTTOM_RIGHT:
|
2016-10-07 11:15:46 +02:00
|
|
|
new_x = lv_obj_get_width(base) - lv_obj_get_width(obj);
|
|
|
|
new_y = lv_obj_get_height(base);
|
2016-06-08 07:25:08 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_OUT_LEFT_TOP:
|
2016-10-07 11:15:46 +02:00
|
|
|
new_x = - lv_obj_get_width(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
new_y = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_OUT_LEFT_MID:
|
2016-10-07 11:15:46 +02:00
|
|
|
new_x = - lv_obj_get_width(obj);
|
|
|
|
new_y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
2016-06-08 07:25:08 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_OUT_LEFT_BOTTOM:
|
2016-10-07 11:15:46 +02:00
|
|
|
new_x = - lv_obj_get_width(obj);
|
|
|
|
new_y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_OUT_RIGHT_TOP:
|
2016-10-07 11:15:46 +02:00
|
|
|
new_x = lv_obj_get_width(base);
|
2016-06-08 07:25:08 +02:00
|
|
|
new_y = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_OUT_RIGHT_MID:
|
2016-10-07 11:15:46 +02:00
|
|
|
new_x = lv_obj_get_width(base);
|
|
|
|
new_y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
2016-06-08 07:25:08 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LV_ALIGN_OUT_RIGHT_BOTTOM:
|
2016-10-07 11:15:46 +02:00
|
|
|
new_x = lv_obj_get_width(base);
|
|
|
|
new_y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
/*Bring together the coordination system of base and obj*/
|
|
|
|
lv_obj_t * par = lv_obj_get_parent(obj);
|
|
|
|
cord_t base_abs_x = base->cords.x1;
|
|
|
|
cord_t base_abs_y = base->cords.y1;
|
|
|
|
cord_t par_abs_x = par->cords.x1;
|
|
|
|
cord_t par_abs_y = par->cords.y1;
|
2016-06-20 18:18:36 +02:00
|
|
|
new_x += x_mod + base_abs_x;
|
|
|
|
new_y += y_mod + base_abs_y;
|
2016-06-22 15:16:08 +02:00
|
|
|
new_x -= par_abs_x;
|
|
|
|
new_y -= par_abs_y;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_set_pos(obj, new_x, new_y);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Align an object to an other object. The coordinates will be upscaled to compensate LV_DOWNSCALE.
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object to align
|
|
|
|
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param align type of alignment (see 'lv_align_t' enum)
|
|
|
|
* @param x_mod x coordinate shift after alignment (will be multiplied with LV_DOWNSCALE)
|
|
|
|
* @param y_mod y coordinate shift after alignment (will be multiplied with LV_DOWNSCALE)
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_align_us(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_align(obj, base, align, x_mod * LV_DOWNSCALE, y_mod * LV_DOWNSCALE);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
2016-10-17 15:02:18 +02:00
|
|
|
/**
|
|
|
|
* Set the extended size of an object
|
|
|
|
* @param obj pointer to an object
|
|
|
|
* @param ext_size the extended size
|
|
|
|
*/
|
|
|
|
void lv_obj_set_ext_size(lv_obj_t * obj, cord_t ext_size)
|
|
|
|
{
|
|
|
|
obj->ext_size = ext_size;
|
|
|
|
|
|
|
|
lv_obj_inv(obj);
|
|
|
|
}
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/*---------------------
|
|
|
|
* Appearance set
|
|
|
|
*--------------------*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a new style for an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param style_p pointer to the new style
|
|
|
|
*/
|
2016-12-15 10:31:30 +01:00
|
|
|
void lv_obj_set_style(lv_obj_t * obj, void * style)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-12-22 15:20:12 +01:00
|
|
|
lv_obj_inv(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
if(obj->style_iso != 0) {
|
|
|
|
dm_free(obj->style_p);
|
2016-12-22 15:20:12 +01:00
|
|
|
obj->style_iso = 0;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
2016-12-15 10:31:30 +01:00
|
|
|
obj->style_p = style;
|
2016-06-22 15:16:08 +02:00
|
|
|
|
|
|
|
/*Send a style change signal to the object*/
|
2016-10-07 11:15:46 +02:00
|
|
|
obj->signal_f(obj, LV_SIGNAL_STYLE_CHG, NULL);
|
|
|
|
lv_obj_inv(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Isolate the style of an object. In other words a unique style will be created
|
|
|
|
* for this object which can be freely modified independently from the style of the
|
|
|
|
* other objects.
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void * lv_obj_iso_style(lv_obj_t * obj, uint32_t style_size)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
if(obj->style_iso != 0) return obj->style_p;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
void * ori_style_p = lv_obj_get_style(obj);
|
|
|
|
void * iso_style = dm_alloc(style_size);
|
|
|
|
dm_assert(iso_style);
|
|
|
|
memcpy(iso_style, ori_style_p, style_size);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
obj->style_iso = 1;
|
|
|
|
obj->style_p = iso_style;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_refr_style(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
return obj->style_p;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the opacity of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param opa 0 (transparent) .. 255(fully cover)
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_opa(lv_obj_t * obj, uint8_t opa)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
obj->opa = opa;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_inv(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the opacity of an object and all of its children
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param opa 0 (transparent) .. 255(fully cover)
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_opar(lv_obj_t * obj, uint8_t opa)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * i;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
LL_READ(obj->child_ll, i) {
|
2016-06-08 07:25:08 +02:00
|
|
|
lv_obj_set_opar(i, opa);
|
|
|
|
}
|
|
|
|
|
2016-12-17 21:22:16 +01:00
|
|
|
if(obj->opa_protect == 0) obj->opa = opa;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_inv(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------
|
|
|
|
* Attribute set
|
|
|
|
*----------------*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hide an object. It won't be visible and clickable.
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-12-15 10:31:30 +01:00
|
|
|
* @param en true: hide the object
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-12-15 10:31:30 +01:00
|
|
|
void lv_obj_set_hidden(lv_obj_t * obj, bool en)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-12-15 10:31:30 +01:00
|
|
|
obj->hidden = en == false ? 0 : 1;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * par = lv_obj_get_parent(obj);
|
|
|
|
par->signal_f(par, LV_SIGNAL_CHILD_CHG, obj);
|
2016-07-12 01:16:27 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_inv(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable or disable the clicking of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-12-15 10:31:30 +01:00
|
|
|
* @param en true: make the object clickable
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-12-15 10:31:30 +01:00
|
|
|
void lv_obj_set_click(lv_obj_t * obj, bool en)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-12-15 10:31:30 +01:00
|
|
|
obj->click_en = (en == true ? 1 : 0);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable to bring this object to the foreground if it
|
|
|
|
* or any of its children is clicked
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-12-15 10:31:30 +01:00
|
|
|
* @param en true: enable the auto top feature
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-12-15 10:31:30 +01:00
|
|
|
void lv_obj_set_top(lv_obj_t * obj, bool en)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-12-15 10:31:30 +01:00
|
|
|
obj->top_en= (en == true ? 1 : 0);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable the dragging of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-12-15 10:31:30 +01:00
|
|
|
* @param en true: make the object dragable
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-12-15 10:31:30 +01:00
|
|
|
void lv_obj_set_drag(lv_obj_t * obj, bool en)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-12-15 10:31:30 +01:00
|
|
|
obj->drag_en = (en == true ? 1 : 0);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable the throwing of an object after is is dragged
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-12-15 10:31:30 +01:00
|
|
|
* @param en true: enable the drag throw
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-12-15 10:31:30 +01:00
|
|
|
void lv_obj_set_drag_throw(lv_obj_t * obj, bool en)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-12-15 10:31:30 +01:00
|
|
|
obj->drag_throw_en = (en == true ? 1 : 0);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable to use parent for drag related operations.
|
|
|
|
* If trying to drag the object the parent will be moved instead
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-12-15 10:31:30 +01:00
|
|
|
* @param en true: enable the 'drag parent' for the object
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-12-15 10:31:30 +01:00
|
|
|
void lv_obj_set_drag_parent(lv_obj_t * obj, bool en)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-12-15 10:31:30 +01:00
|
|
|
obj->drag_parent = (en == true ? 1 : 0);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
2016-12-17 21:22:16 +01:00
|
|
|
/**
|
|
|
|
* Do not let 'lv_obj_set_opar' to set the opacity
|
|
|
|
* @param obj pointer to an object
|
|
|
|
* @param en true: enable the 'opa_protect' for the object
|
|
|
|
*/
|
|
|
|
void lv_obj_set_opa_protect(lv_obj_t * obj, bool en)
|
|
|
|
{
|
|
|
|
obj->opa_protect = (en == true ? 1 : 0);
|
|
|
|
}
|
2016-06-08 07:25:08 +02:00
|
|
|
/**
|
|
|
|
* Set the signal function of an object.
|
|
|
|
* Always call the previous signal function in the new.
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param fp the new signal function
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_signal_f(lv_obj_t * obj, lv_signal_f_t fp)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
obj->signal_f = fp;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a new design function for an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param fp the new design function
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_design_f(lv_obj_t * obj, lv_design_f_t fp)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
obj->design_f = fp;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------
|
|
|
|
* Other set
|
|
|
|
*--------------*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a new ext. data for an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param ext_size the size of the new ext. data
|
|
|
|
* @return Normal pointer to the allocated ext
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void * lv_obj_alloc_ext(lv_obj_t * obj, uint16_t ext_size)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
obj->ext = dm_realloc(obj->ext, ext_size);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
return (void*)obj->ext;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
2016-10-17 15:02:18 +02:00
|
|
|
/**
|
|
|
|
* Send a 'LV_SIGNAL_REFR_EXT_SIZE' signal to the object
|
|
|
|
* @param obj pointer to an object
|
|
|
|
*/
|
2016-10-27 14:20:22 +02:00
|
|
|
void lv_obj_refr_ext_size(lv_obj_t * obj)
|
2016-10-17 15:02:18 +02:00
|
|
|
{
|
|
|
|
obj->ext_size = 0;
|
|
|
|
obj->signal_f(obj, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
|
|
|
|
|
|
|
lv_obj_inv(obj);
|
|
|
|
}
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/**
|
|
|
|
* Set an application specific number for an object.
|
|
|
|
* It can help to identify objects in the application.
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param free_num the new free number
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_free_num(lv_obj_t * obj, uint8_t free_num)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
obj->free_num = free_num;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#if LV_OBJ_FREE_P != 0
|
|
|
|
/**
|
|
|
|
* Set an application specific pointer for an object.
|
|
|
|
* It can help to identify objects in the application.
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param free_p the new free pinter
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_set_free_p(lv_obj_t * obj, void * free_p)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
obj->free_p = free_p;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
#endif
|
2016-07-12 15:05:17 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Animate an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object to animate
|
2016-07-12 15:05:17 +02:00
|
|
|
* @param type type of animation from 'lv_anim_builtin_t'. 'OR' it with ANIM_IN or ANIM_OUT
|
|
|
|
* @param time time of animation in milliseconds
|
|
|
|
* @param delay delay before the animation in milliseconds
|
|
|
|
* @param cb a function to call when the animation is ready
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_anim(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint16_t delay, void (*cb) (lv_obj_t *))
|
2016-07-12 15:05:17 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * par = lv_obj_get_parent(obj);
|
2016-07-12 15:05:17 +02:00
|
|
|
|
|
|
|
/*Get the direction*/
|
|
|
|
bool out = (type & ANIM_DIR_MASK) == ANIM_IN ? false : true;
|
|
|
|
type = type & (~ANIM_DIR_MASK);
|
|
|
|
|
|
|
|
anim_t a;
|
2016-10-16 21:43:28 +02:00
|
|
|
a.var = obj;
|
2016-07-12 15:05:17 +02:00
|
|
|
a.time = time;
|
|
|
|
a.act_time = (int32_t)-delay;
|
|
|
|
a.end_cb = (void(*)(void*))cb;
|
2016-10-20 16:35:03 +02:00
|
|
|
a.path = anim_get_path(ANIM_PATH_LIN);
|
|
|
|
a.playback_pause = 0;
|
|
|
|
a.repeat_pause = 0;
|
|
|
|
a.playback = 0;
|
|
|
|
a.repeat = 0;
|
2016-07-12 15:05:17 +02:00
|
|
|
|
|
|
|
/*Init to ANIM_IN*/
|
|
|
|
switch(type) {
|
2016-07-12 15:07:57 +02:00
|
|
|
case LV_ANIM_FLOAT_LEFT:
|
2016-07-12 15:05:17 +02:00
|
|
|
a.fp = (void(*)(void *, int32_t))lv_obj_set_x;
|
2016-10-07 11:15:46 +02:00
|
|
|
a.start = -lv_obj_get_width(obj);
|
|
|
|
a.end = lv_obj_get_x(obj);
|
2016-07-12 15:05:17 +02:00
|
|
|
break;
|
2016-07-12 15:07:57 +02:00
|
|
|
case LV_ANIM_FLOAT_RIGHT:
|
2016-07-12 15:05:17 +02:00
|
|
|
a.fp = (void(*)(void *, int32_t))lv_obj_set_x;
|
2016-10-07 11:15:46 +02:00
|
|
|
a.start = lv_obj_get_width(par);
|
|
|
|
a.end = lv_obj_get_x(obj);
|
2016-07-12 15:05:17 +02:00
|
|
|
break;
|
2016-07-12 15:07:57 +02:00
|
|
|
case LV_ANIM_FLOAT_TOP:
|
2016-07-12 15:05:17 +02:00
|
|
|
a.fp = (void(*)(void * , int32_t))lv_obj_set_y;
|
2016-10-07 11:15:46 +02:00
|
|
|
a.start = -lv_obj_get_height(obj);
|
|
|
|
a.end = lv_obj_get_y(obj);
|
2016-07-12 15:05:17 +02:00
|
|
|
break;
|
2016-07-12 15:07:57 +02:00
|
|
|
case LV_ANIM_FLOAT_BOTTOM:
|
2016-07-12 15:05:17 +02:00
|
|
|
a.fp = (void(*)(void * , int32_t))lv_obj_set_y;
|
2016-10-07 11:15:46 +02:00
|
|
|
a.start = lv_obj_get_height(par);
|
|
|
|
a.end = lv_obj_get_y(obj);
|
2016-07-12 15:05:17 +02:00
|
|
|
break;
|
2016-07-12 15:07:57 +02:00
|
|
|
case LV_ANIM_FADE:
|
2016-07-12 15:05:17 +02:00
|
|
|
a.fp = (void(*)(void * , int32_t))lv_obj_set_opar;
|
|
|
|
a.start = OPA_TRANSP;
|
|
|
|
a.end = OPA_COVER;
|
|
|
|
break;
|
2016-07-12 15:07:57 +02:00
|
|
|
case LV_ANIM_GROW_H:
|
2016-07-12 15:05:17 +02:00
|
|
|
a.fp = (void(*)(void * , int32_t))lv_obj_set_width;
|
|
|
|
a.start = 0;
|
2016-10-07 11:15:46 +02:00
|
|
|
a.end = lv_obj_get_width(obj);
|
2016-07-12 15:05:17 +02:00
|
|
|
break;
|
2016-07-12 15:07:57 +02:00
|
|
|
case LV_ANIM_GROW_V:
|
2016-07-12 15:05:17 +02:00
|
|
|
a.fp = (void(*)(void * , int32_t))lv_obj_set_height;
|
|
|
|
a.start = 0;
|
2016-10-07 11:15:46 +02:00
|
|
|
a.end = lv_obj_get_height(obj);
|
2016-07-12 15:05:17 +02:00
|
|
|
break;
|
2016-12-29 23:48:01 +01:00
|
|
|
case LV_ANIM_NONE:
|
|
|
|
a.fp = NULL;
|
|
|
|
a.start = 0;
|
|
|
|
a.end = 0;
|
|
|
|
break;
|
2016-07-12 15:05:17 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Swap start and end in case of ANIM OUT*/
|
|
|
|
if(out != false) {
|
|
|
|
int32_t tmp = a.start;
|
|
|
|
a.start = a.end;
|
|
|
|
a.end = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
anim_create(&a);
|
|
|
|
}
|
2016-06-08 07:25:08 +02:00
|
|
|
/*=======================
|
|
|
|
* Getter functions
|
|
|
|
*======================*/
|
|
|
|
|
|
|
|
/*------------------
|
|
|
|
* Screen get
|
|
|
|
*-----------------*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return with the actual screen
|
|
|
|
* @return pointer to to the actual screen object
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * lv_scr_act(void)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
return act_scr;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return with the screen of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return pointer to a screen
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * lv_obj_get_scr(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * par = obj;
|
|
|
|
lv_obj_t * act_p;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
do {
|
2016-10-07 11:15:46 +02:00
|
|
|
act_p = par;
|
|
|
|
par = lv_obj_get_parent(act_p);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
2016-10-07 11:15:46 +02:00
|
|
|
while(par != NULL);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
return act_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------
|
|
|
|
* Parent/children get
|
|
|
|
*--------------------*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns with the parent of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
|
|
|
* @return pointer to the parent of 'obj'
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * lv_obj_get_parent(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
return obj->par;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Iterate through the children of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
|
|
|
* @param child NULL at first call to get the next children
|
2016-06-08 07:25:08 +02:00
|
|
|
* and the previous return value later
|
2016-10-07 11:15:46 +02:00
|
|
|
* @return the child after 'act_child' or NULL if no more child
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * lv_obj_get_child(lv_obj_t * obj, lv_obj_t * child)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
if(child == NULL) {
|
|
|
|
return ll_get_head(&obj->child_ll);
|
2016-06-08 07:25:08 +02:00
|
|
|
} else {
|
2016-10-07 11:15:46 +02:00
|
|
|
return ll_get_next(&obj->child_ll, child);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-12-16 07:41:34 +01:00
|
|
|
/**
|
|
|
|
* Count the children of an object (only children directly on 'obj')
|
|
|
|
* @param obj pointer to an object
|
|
|
|
* @return children number of 'obj'
|
|
|
|
*/
|
|
|
|
uint16_t lv_obj_get_child_num(lv_obj_t * obj)
|
|
|
|
{
|
|
|
|
lv_obj_t * i;
|
|
|
|
uint16_t cnt = 0;
|
|
|
|
|
|
|
|
LL_READ(obj->child_ll, i) cnt++;
|
|
|
|
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/*---------------------
|
|
|
|
* Coordinate get
|
|
|
|
*--------------------*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copy the coordinates of an object to an area
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param cords_p pointer to an area to store the coordinates
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_obj_get_cords(lv_obj_t * obj, area_t * cords_p)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
area_cpy(cords_p, &obj->cords);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the x coordinate of object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
|
|
|
* @return distance of 'obj' from the left side of its parent
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
cord_t lv_obj_get_x(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
|
|
|
cord_t rel_x;
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * parent = lv_obj_get_parent(obj);
|
|
|
|
rel_x = obj->cords.x1 - parent->cords.x1;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
return rel_x;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the y coordinate of object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
|
|
|
* @return distance of 'obj' from the top of its parent
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
cord_t lv_obj_get_y(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
|
|
|
cord_t rel_y;
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * parent = lv_obj_get_parent(obj);
|
|
|
|
rel_y = obj->cords.y1 - parent->cords.y1;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
return rel_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the width of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return the width
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
cord_t lv_obj_get_width(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
return area_get_width(&obj->cords);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the height of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return the height
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
cord_t lv_obj_get_height(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
return area_get_height(&obj->cords);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
2016-10-17 15:02:18 +02:00
|
|
|
/**
|
|
|
|
* Get the extended size attribute of an object
|
|
|
|
* @param obj pointer to an object
|
|
|
|
* @return the extended size attribute
|
|
|
|
*/
|
|
|
|
cord_t lv_obj_getext_size(lv_obj_t * obj)
|
|
|
|
{
|
|
|
|
return obj->ext_size;
|
|
|
|
}
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/*-----------------
|
|
|
|
* Appearance get
|
|
|
|
*---------------*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the style pointer of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return pointer to a style
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void * lv_obj_get_style(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
return obj->style_p;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the opacity of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return 0 (transparent) .. 255 (fully cover)
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
opa_t lv_obj_get_opa(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
return obj->opa;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------
|
|
|
|
* Attribute get
|
|
|
|
*----------------*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the hidden attribute of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return true: the object is hidden
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
bool lv_obj_get_hidden(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
return obj->hidden == 0 ? false : true;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the click enable attribute of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return true: the object is clickable
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
bool lv_obj_get_click(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
return obj->click_en == 0 ? false : true;;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the top enable attribute of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return true: the auto top feture is enabled
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
bool lv_obj_get_top(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
return obj->top_en == 0 ? false : true;;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the drag enable attribute of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return true: the object is dragable
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
bool lv_obj_get_drag(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
return obj->drag_en == 0 ? false : true;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the drag thow enable attribute of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return true: drag throw is enabled
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
bool lv_obj_get_drag_throw(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
return obj->drag_throw_en == 0 ? false : true;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the drag parent attribute of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return true: drag parent is enabled
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
bool lv_obj_get_drag_parent(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
return obj->drag_parent == 0 ? false : true;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
2016-12-17 21:22:16 +01:00
|
|
|
/**
|
|
|
|
* Get the opa_protect attribute of an object
|
|
|
|
* @param obj pointer to an object
|
|
|
|
* @return true: opa_protect is enabled
|
|
|
|
*/
|
|
|
|
bool lv_obj_get_opa_protect(lv_obj_t * obj)
|
|
|
|
{
|
|
|
|
return obj->opa_protect == 0 ? false : true;
|
|
|
|
}
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/**
|
|
|
|
* Get the signal function of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return the signal function
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_signal_f_t lv_obj_get_signal_f(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
return obj->signal_f;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the design function of an object
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return the design function
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_design_f_t lv_obj_get_design_f(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
return obj->design_f;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*------------------
|
|
|
|
* Other get
|
|
|
|
*-----------------*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the ext pointer
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return the ext pointer but not the dynamic version
|
|
|
|
* Use it as ext->data1, and NOT da(ext)->data1
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void * lv_obj_get_ext(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
return obj->ext;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the free number
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return the free number
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
uint8_t lv_obj_get_free_num(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
return obj->free_num;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#if LV_OBJ_FREE_P != 0
|
|
|
|
/**
|
|
|
|
* Get the free pointer
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return the free pointer
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void * lv_obj_get_free_p(lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
return obj->free_p;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* STATIC FUNCTIONS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the drawing related tasks of the base objects.
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param mask the object will be drawn only in this area
|
|
|
|
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
|
|
|
* (return 'true' if yes)
|
|
|
|
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
|
|
|
* @param return true/false, depends on 'mode'
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
static bool lv_obj_design(lv_obj_t * obj, const area_t * mask_p, lv_design_mode_t mode)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
|
|
|
if(mode == LV_DESIGN_COVER_CHK) {
|
|
|
|
bool cover;
|
2016-10-07 11:15:46 +02:00
|
|
|
cover = area_is_in(mask_p, &obj->cords);
|
2016-06-08 07:25:08 +02:00
|
|
|
return cover;
|
2016-10-04 09:45:39 +02:00
|
|
|
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_objs_t * objs_p = lv_obj_get_style(obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
opa_t opa = lv_obj_get_opa(obj);
|
2016-10-04 09:45:39 +02:00
|
|
|
color_t color = objs_p->color;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-04 09:45:39 +02:00
|
|
|
/*Simply draw a rectangle*/
|
2016-06-08 07:25:08 +02:00
|
|
|
#if LV_VDB_SIZE == 0
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_rfill(&obj->cords, mask_p, color, opa);
|
2016-06-08 07:25:08 +02:00
|
|
|
#else
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_vfill(&obj->cords, mask_p, color, opa);
|
2016-06-08 07:25:08 +02:00
|
|
|
#endif
|
2016-10-04 09:45:39 +02:00
|
|
|
}
|
2016-06-08 07:25:08 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reposition the children of an object. (Called recursively)
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object which children will be repositioned
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param x_diff x coordinate shift
|
|
|
|
* @param y_diff y coordinate shift
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
static void lv_obj_pos_child_refr(lv_obj_t * obj, cord_t x_diff, cord_t y_diff)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * i;
|
|
|
|
LL_READ(obj->child_ll, i) {
|
2016-06-08 07:25:08 +02:00
|
|
|
i->cords.x1 += x_diff;
|
|
|
|
i->cords.y1 += y_diff;
|
|
|
|
i->cords.x2 += x_diff;
|
|
|
|
i->cords.y2 += y_diff;
|
|
|
|
|
|
|
|
lv_obj_pos_child_refr(i, x_diff, y_diff);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Refresh the style of all children of an object. (Called recursively)
|
|
|
|
* @param style_p refresh objects only with this style. (ignore is if NULL)
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to an object
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
static void lv_style_refr_core(void * style_p, lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * i;
|
|
|
|
LL_READ(obj->child_ll, i) {
|
2016-06-08 07:25:08 +02:00
|
|
|
if(i->style_p == style_p || style_p == NULL) {
|
|
|
|
i->signal_f(i, LV_SIGNAL_STYLE_CHG, NULL);
|
|
|
|
lv_obj_inv(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
lv_style_refr_core(style_p, i);
|
|
|
|
}
|
|
|
|
}
|
2016-06-20 18:18:36 +02:00
|
|
|
|
2016-12-21 14:49:23 +01:00
|
|
|
/**
|
|
|
|
* Called by 'lv_obj_del' to delete the children objects
|
|
|
|
* @param obj pointer to an object (all of its children will be deleted)
|
|
|
|
*/
|
|
|
|
static void lv_obj_del_child(lv_obj_t * obj)
|
|
|
|
{
|
|
|
|
lv_obj_t * i;
|
|
|
|
lv_obj_t * i_next;
|
|
|
|
i = ll_get_head(&(obj->child_ll));
|
|
|
|
while(i != NULL) {
|
|
|
|
/*Get the next object before delete this*/
|
|
|
|
i_next = ll_get_next(&(obj->child_ll), i);
|
|
|
|
|
|
|
|
/*Call the recursive del to the child too*/
|
|
|
|
lv_obj_del_child(i);
|
|
|
|
|
|
|
|
/*Set i to the next node*/
|
|
|
|
i = i_next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Remove the animations from this object*/
|
|
|
|
anim_del(obj, NULL);
|
|
|
|
|
|
|
|
/*Remove the object from parent's children list*/
|
|
|
|
lv_obj_t * par = lv_obj_get_parent(obj);
|
|
|
|
|
|
|
|
ll_rem(&(par->child_ll), obj);
|
|
|
|
|
|
|
|
/* All children deleted.
|
|
|
|
* Now clean up the object specific data*/
|
|
|
|
obj->signal_f(obj, LV_SIGNAL_CLEANUP, NULL);
|
|
|
|
|
|
|
|
/*Delete the base objects*/
|
|
|
|
if(obj->ext != NULL) dm_free(obj->ext);
|
|
|
|
if(obj->style_iso != 0) dm_free(obj->style_p);
|
|
|
|
dm_free(obj); /*Free the object itself*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-06-20 18:18:36 +02:00
|
|
|
|