fix conflicts
This commit is contained in:
1
lvgl.h
1
lvgl.h
@@ -28,6 +28,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include "src/lv_core/lv_refr.h"
|
#include "src/lv_core/lv_refr.h"
|
||||||
#include "src/lv_core/lv_disp.h"
|
#include "src/lv_core/lv_disp.h"
|
||||||
|
#include "src/lv_core/lv_debug.h"
|
||||||
|
|
||||||
#include "src/lv_themes/lv_theme.h"
|
#include "src/lv_themes/lv_theme.h"
|
||||||
|
|
||||||
|
|||||||
177
src/lv_core/lv_debug.c
Normal file
177
src/lv_core/lv_debug.c
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
/**
|
||||||
|
* @file lv_debug.c
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*********************
|
||||||
|
* INCLUDES
|
||||||
|
*********************/
|
||||||
|
#include "lv_obj.h"
|
||||||
|
|
||||||
|
/*********************
|
||||||
|
* DEFINES
|
||||||
|
*********************/
|
||||||
|
#define LV_DEBUG_STR_MAX_LENGTH (1024 * 8)
|
||||||
|
#define LV_DEBUG_STR_MAX_REPEAT 8
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* TYPEDEFS
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* STATIC PROTOTYPES
|
||||||
|
**********************/
|
||||||
|
static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find);
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* STATIC VARIABLES
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* MACROS
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* GLOBAL FUNCTIONS
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
bool lv_debug_check_null(const void * p)
|
||||||
|
{
|
||||||
|
if(p) return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool lv_debug_check_obj_type(const lv_obj_t * obj, const char * obj_type)
|
||||||
|
{
|
||||||
|
if(obj_type[0] == '\0') return true;
|
||||||
|
|
||||||
|
lv_obj_type_t types;
|
||||||
|
lv_obj_get_type((lv_obj_t *)obj, &types);
|
||||||
|
|
||||||
|
uint8_t i;
|
||||||
|
for(i = 0; i < LV_MAX_ANCESTOR_NUM; i++) {
|
||||||
|
if(strcmp(types.type[i], obj_type) == 0) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool lv_debug_check_obj_valid(const lv_obj_t * obj)
|
||||||
|
{
|
||||||
|
lv_disp_t * disp = lv_disp_get_next(NULL);
|
||||||
|
while(disp) {
|
||||||
|
lv_obj_t * scr;
|
||||||
|
LV_LL_READ(disp->scr_ll, scr) {
|
||||||
|
|
||||||
|
if(scr == obj) return true;
|
||||||
|
bool found = obj_valid_child(scr, obj);
|
||||||
|
if(found) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
disp = lv_disp_get_next(disp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool lv_debug_check_style(const void * str)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
|
||||||
|
LV_LOG_WARN("Invalid style (local variable or not initialized?)");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool lv_debug_check_str(const void * str)
|
||||||
|
{
|
||||||
|
const uint8_t * s = (const uint8_t *)str;
|
||||||
|
uint8_t last_byte = 0;
|
||||||
|
uint32_t rep = 0;
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
for(i = 0; s[i] != '\0' && i < LV_DEBUG_STR_MAX_LENGTH; i++) {
|
||||||
|
if(s[i] != last_byte) {
|
||||||
|
last_byte = s[i];
|
||||||
|
rep = 1;
|
||||||
|
} else {
|
||||||
|
rep++;
|
||||||
|
if(rep > LV_DEBUG_STR_MAX_REPEAT) {
|
||||||
|
LV_LOG_WARN("lv_debug_check_str: a char has repeated more than LV_DEBUG_STR_MAX_REPEAT times)");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(s[i] < 10) {
|
||||||
|
LV_LOG_WARN("lv_debug_check_str: invalid char in the string (< 10 value)");
|
||||||
|
return false; /*Shouldn't occur in strings*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(s[i] == '\0') return true;
|
||||||
|
|
||||||
|
LV_LOG_WARN("lv_debug_check_str: string is longer than LV_DEBUG_STR_MAX_LENGTH");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void lv_debug_log_error(const char * msg, unsigned long int value)
|
||||||
|
{
|
||||||
|
static const char hex[] = "0123456789ABCDEF";
|
||||||
|
|
||||||
|
uint32_t msg_len = strlen(msg);
|
||||||
|
uint32_t value_len = sizeof(unsigned long int);
|
||||||
|
|
||||||
|
if(msg_len < 230) {
|
||||||
|
char buf[255];
|
||||||
|
char * bufp = buf;
|
||||||
|
|
||||||
|
/*Add the function name*/
|
||||||
|
memcpy(bufp, msg, msg_len);
|
||||||
|
bufp += msg_len;
|
||||||
|
|
||||||
|
/*Add value in hey*/
|
||||||
|
*bufp = ' ';
|
||||||
|
bufp ++;
|
||||||
|
*bufp = '(';
|
||||||
|
bufp ++;
|
||||||
|
*bufp = '0';
|
||||||
|
bufp ++;
|
||||||
|
*bufp = 'x';
|
||||||
|
bufp ++;
|
||||||
|
|
||||||
|
int8_t i;
|
||||||
|
for(i = value_len * 2 - 1; i >= 0; i--) {
|
||||||
|
uint8_t x = (unsigned long int)((unsigned long int)value >> (i * 4)) & 0xF;
|
||||||
|
|
||||||
|
*bufp = hex[x];
|
||||||
|
bufp++;
|
||||||
|
}
|
||||||
|
|
||||||
|
*bufp = ')';
|
||||||
|
bufp ++;
|
||||||
|
|
||||||
|
*bufp = '\0';
|
||||||
|
LV_LOG_ERROR(buf);
|
||||||
|
} else {
|
||||||
|
LV_LOG_ERROR(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* STATIC FUNCTIONS
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find)
|
||||||
|
{
|
||||||
|
/*Check all children of `parent`*/
|
||||||
|
lv_obj_t * child;
|
||||||
|
LV_LL_READ(parent->child_ll, child) {
|
||||||
|
if(child == obj_to_find) return true;
|
||||||
|
|
||||||
|
/*Check the children*/
|
||||||
|
bool found = obj_valid_child(child, obj_to_find);
|
||||||
|
if(found) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
132
src/lv_core/lv_debug.h
Normal file
132
src/lv_core/lv_debug.h
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
/**
|
||||||
|
* @file lv_debug.h
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LV_DEBUG_H
|
||||||
|
#define LV_DEBUG_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*********************
|
||||||
|
* INCLUDES
|
||||||
|
*********************/
|
||||||
|
#include "lv_obj.h"
|
||||||
|
|
||||||
|
/*********************
|
||||||
|
* DEFINES
|
||||||
|
*********************/
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* TYPEDEFS
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* GLOBAL PROTOTYPES
|
||||||
|
**********************/
|
||||||
|
bool lv_debug_check_null(const void * p);
|
||||||
|
|
||||||
|
bool lv_debug_check_obj_type(const lv_obj_t * obj, const char * obj_type);
|
||||||
|
|
||||||
|
bool lv_debug_check_obj_valid(const lv_obj_t * obj);
|
||||||
|
|
||||||
|
bool lv_debug_check_style(const void * str);
|
||||||
|
|
||||||
|
bool lv_debug_check_str(const void * str);
|
||||||
|
|
||||||
|
void lv_debug_log_error(const char * msg, uint64_t value);
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* MACROS
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
#ifndef LV_DEBUG_ASSERT
|
||||||
|
#define LV_DEBUG_ASSERT(expr, msg, value) \
|
||||||
|
{ \
|
||||||
|
if(!(expr)) { \
|
||||||
|
LV_LOG_ERROR(__func__); \
|
||||||
|
lv_debug_log_error(msg, (unsigned long int)value); \
|
||||||
|
while(1); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*----------------
|
||||||
|
* CHECKS
|
||||||
|
*----------------*/
|
||||||
|
|
||||||
|
#ifndef LV_DEBUG_IS_NULL
|
||||||
|
#define LV_DEBUG_IS_NULL(p) (lv_debug_check_null(p))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LV_DEBUG_IS_STR
|
||||||
|
#define LV_DEBUG_IS_STR(str) (lv_debug_check_str(str))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LV_DEBUG_IS_OBJ
|
||||||
|
#define LV_DEBUG_IS_OBJ(obj_p, obj_type) (lv_debug_check_null(obj_p) && \
|
||||||
|
lv_debug_check_obj_valid(obj_p) && \
|
||||||
|
lv_debug_check_obj_type(obj_p, obj_type))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LV_DEBUG_IS_STYLE
|
||||||
|
#define LV_DEBUG_IS_STYLE(style_p) (lv_debug_check_style(style_p))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*-----------------
|
||||||
|
* ASSERTS
|
||||||
|
*-----------------*/
|
||||||
|
|
||||||
|
/*clang-format off*/
|
||||||
|
|
||||||
|
#if LV_USE_ASSERT_NULL
|
||||||
|
# ifndef LV_ASSERT_NULL
|
||||||
|
# define LV_ASSERT_NULL(p) LV_DEBUG_ASSERT(LV_DEBUG_IS_NULL(p), "NULL pointer", p);
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define LV_ASSERT_NULL(p) true
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LV_USE_ASSERT_MEM
|
||||||
|
# ifndef LV_ASSERT_MEM
|
||||||
|
# define LV_ASSERT_MEM(p) LV_DEBUG_ASSERT(LV_DEBUG_IS_NULL(p), "Out of memory", p);
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define LV_ASSERT_MEM(p) true
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LV_USE_ASSERT_STR
|
||||||
|
# ifndef LV_ASSERT_STR
|
||||||
|
# define LV_ASSERT_STR(str) LV_DEBUG_ASSERT(LV_DEBUG_IS_STR(str), "Strange or invalid string", str);
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define LV_ASSERT_STR(p) true
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if LV_USE_ASSERT_OBJ
|
||||||
|
# ifndef LV_ASSERT_OBJ
|
||||||
|
# define LV_ASSERT_OBJ(obj_p, obj_type) LV_DEBUG_ASSERT(LV_DEBUG_IS_OBJ(obj_p, obj_type), "Invalid object", obj_p);
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define LV_ASSERT_OBJ(obj_p, obj_type) true
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if LV_USE_ASSERT_STYLE
|
||||||
|
# ifndef LV_ASSERT_STYLE
|
||||||
|
# define LV_ASSERT_STYLE(style_p) LV_DEBUG_ASSERT(LV_DEBUG_IS_STYLE(style_p), "Invalid style", style_p);
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define LV_ASSERT_STYLE(style) true
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*clang-format on*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*LV_DEBUG_H*/
|
||||||
@@ -8,8 +8,9 @@
|
|||||||
*********************/
|
*********************/
|
||||||
#include "lv_group.h"
|
#include "lv_group.h"
|
||||||
#if LV_USE_GROUP != 0
|
#if LV_USE_GROUP != 0
|
||||||
#include "../lv_themes/lv_theme.h"
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
|
#include "../lv_themes/lv_theme.h"
|
||||||
#include "../lv_misc/lv_gc.h"
|
#include "../lv_misc/lv_gc.h"
|
||||||
|
|
||||||
#if defined(LV_GC_INCLUDE)
|
#if defined(LV_GC_INCLUDE)
|
||||||
@@ -62,7 +63,7 @@ void lv_group_init(void)
|
|||||||
lv_group_t * lv_group_create(void)
|
lv_group_t * lv_group_create(void)
|
||||||
{
|
{
|
||||||
lv_group_t * group = lv_ll_ins_head(&LV_GC_ROOT(_lv_group_ll));
|
lv_group_t * group = lv_ll_ins_head(&LV_GC_ROOT(_lv_group_ll));
|
||||||
lv_mem_assert(group);
|
LV_ASSERT_MEM(group);
|
||||||
if(group == NULL) return NULL;
|
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 *));
|
||||||
|
|
||||||
@@ -138,7 +139,7 @@ void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
|
|||||||
|
|
||||||
obj->group_p = group;
|
obj->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_mem_assert(next);
|
LV_ASSERT_MEM(next);
|
||||||
if(next == NULL) return;
|
if(next == NULL) return;
|
||||||
*next = obj;
|
*next = obj;
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "lv_refr.h"
|
#include "lv_refr.h"
|
||||||
#include "lv_group.h"
|
#include "lv_group.h"
|
||||||
#include "lv_disp.h"
|
#include "lv_disp.h"
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
#include "../lv_misc/lv_anim.h"
|
#include "../lv_misc/lv_anim.h"
|
||||||
@@ -30,6 +31,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_obj"
|
||||||
#define LV_OBJ_DEF_WIDTH (LV_DPI)
|
#define LV_OBJ_DEF_WIDTH (LV_DPI)
|
||||||
#define LV_OBJ_DEF_HEIGHT (2 * LV_DPI / 3)
|
#define LV_OBJ_DEF_HEIGHT (2 * LV_DPI / 3)
|
||||||
|
|
||||||
@@ -143,7 +145,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
new_obj = lv_ll_ins_head(&disp->scr_ll);
|
new_obj = lv_ll_ins_head(&disp->scr_ll);
|
||||||
lv_mem_assert(new_obj);
|
LV_ASSERT_MEM(new_obj);
|
||||||
if(new_obj == NULL) return NULL;
|
if(new_obj == NULL) return NULL;
|
||||||
|
|
||||||
new_obj->par = NULL; /*Screens has no a parent*/
|
new_obj->par = NULL; /*Screens has no a parent*/
|
||||||
@@ -182,8 +184,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
|||||||
new_obj->style_p = &lv_style_scr;
|
new_obj->style_p = &lv_style_scr;
|
||||||
}
|
}
|
||||||
/*Set the callbacks*/
|
/*Set the callbacks*/
|
||||||
lv_obj_set_signal_cb(new_obj, lv_obj_signal);
|
new_obj->signal_cb = lv_obj_signal;
|
||||||
lv_obj_set_design_cb(new_obj, lv_obj_design);
|
new_obj->design_cb = lv_obj_design;
|
||||||
new_obj->event_cb = NULL;
|
new_obj->event_cb = NULL;
|
||||||
|
|
||||||
/*Init. user date*/
|
/*Init. user date*/
|
||||||
@@ -214,9 +216,10 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
|||||||
/*parent != NULL create normal obj. on a parent*/
|
/*parent != NULL create normal obj. on a parent*/
|
||||||
else {
|
else {
|
||||||
LV_LOG_TRACE("Object create started");
|
LV_LOG_TRACE("Object create started");
|
||||||
|
LV_ASSERT_OBJ(parent, LV_OBJX_NAME);
|
||||||
|
|
||||||
new_obj = lv_ll_ins_head(&parent->child_ll);
|
new_obj = lv_ll_ins_head(&parent->child_ll);
|
||||||
lv_mem_assert(new_obj);
|
LV_ASSERT_MEM(new_obj);
|
||||||
if(new_obj == NULL) return NULL;
|
if(new_obj == NULL) return NULL;
|
||||||
|
|
||||||
new_obj->par = parent; /*Set the parent*/
|
new_obj->par = parent; /*Set the parent*/
|
||||||
@@ -255,8 +258,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*Set the callbacks*/
|
/*Set the callbacks*/
|
||||||
lv_obj_set_signal_cb(new_obj, lv_obj_signal);
|
new_obj->signal_cb = lv_obj_signal;
|
||||||
lv_obj_set_design_cb(new_obj, lv_obj_design);
|
new_obj->design_cb = lv_obj_design;
|
||||||
new_obj->event_cb = NULL;
|
new_obj->event_cb = NULL;
|
||||||
|
|
||||||
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
|
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
|
||||||
@@ -295,6 +298,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Copy the attributes if required*/
|
/*Copy the attributes if required*/
|
||||||
if(copy != NULL) {
|
if(copy != NULL) {
|
||||||
|
LV_ASSERT_OBJ(copy, LV_OBJX_NAME);
|
||||||
lv_area_copy(&new_obj->coords, ©->coords);
|
lv_area_copy(&new_obj->coords, ©->coords);
|
||||||
new_obj->ext_draw_pad = copy->ext_draw_pad;
|
new_obj->ext_draw_pad = copy->ext_draw_pad;
|
||||||
|
|
||||||
@@ -375,6 +379,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
lv_res_t lv_obj_del(lv_obj_t * obj)
|
lv_res_t lv_obj_del(lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
lv_obj_invalidate(obj);
|
lv_obj_invalidate(obj);
|
||||||
|
|
||||||
/*Delete from the group*/
|
/*Delete from the group*/
|
||||||
@@ -408,15 +413,6 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
|
|||||||
|
|
||||||
lv_event_mark_deleted(obj);
|
lv_event_mark_deleted(obj);
|
||||||
|
|
||||||
/*Remove the object from parent's children list*/
|
|
||||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
|
||||||
if(par == NULL) { /*It is a screen*/
|
|
||||||
lv_disp_t * d = lv_obj_get_disp(obj);
|
|
||||||
lv_ll_rem(&d->scr_ll, obj);
|
|
||||||
} else {
|
|
||||||
lv_ll_rem(&(par->child_ll), obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reset all input devices if the object to delete is used*/
|
/* Reset all input devices if the object to delete is used*/
|
||||||
lv_indev_t * indev = lv_indev_get_next(NULL);
|
lv_indev_t * indev = lv_indev_get_next(NULL);
|
||||||
while(indev) {
|
while(indev) {
|
||||||
@@ -439,6 +435,15 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
|
|||||||
* Now clean up the object specific data*/
|
* Now clean up the object specific data*/
|
||||||
obj->signal_cb(obj, LV_SIGNAL_CLEANUP, NULL);
|
obj->signal_cb(obj, LV_SIGNAL_CLEANUP, NULL);
|
||||||
|
|
||||||
|
/*Remove the object from parent's children list*/
|
||||||
|
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||||
|
if(par == NULL) { /*It is a screen*/
|
||||||
|
lv_disp_t * d = lv_obj_get_disp(obj);
|
||||||
|
lv_ll_rem(&d->scr_ll, obj);
|
||||||
|
} else {
|
||||||
|
lv_ll_rem(&(par->child_ll), obj);
|
||||||
|
}
|
||||||
|
|
||||||
/*Delete the base objects*/
|
/*Delete the base objects*/
|
||||||
if(obj->ext_attr != NULL) lv_mem_free(obj->ext_attr);
|
if(obj->ext_attr != NULL) lv_mem_free(obj->ext_attr);
|
||||||
lv_mem_free(obj); /*Free the object itself*/
|
lv_mem_free(obj); /*Free the object itself*/
|
||||||
@@ -459,6 +464,7 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_del_async(lv_obj_t * obj)
|
void lv_obj_del_async(lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
lv_async_call(lv_obj_del_async_cb, obj);
|
lv_async_call(lv_obj_del_async_cb, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,6 +474,7 @@ void lv_obj_del_async(lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_clean(lv_obj_t * obj)
|
void lv_obj_clean(lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
lv_obj_t * child = lv_obj_get_child(obj, NULL);
|
lv_obj_t * child = lv_obj_get_child(obj, NULL);
|
||||||
lv_obj_t * child_next;
|
lv_obj_t * child_next;
|
||||||
while(child) {
|
while(child) {
|
||||||
@@ -485,6 +492,8 @@ void lv_obj_clean(lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_invalidate(const lv_obj_t * obj)
|
void lv_obj_invalidate(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(lv_obj_get_hidden(obj)) return;
|
if(lv_obj_get_hidden(obj)) return;
|
||||||
|
|
||||||
/*Invalidate the object only if it belongs to the 'LV_GC_ROOT(_lv_act_scr)'*/
|
/*Invalidate the object only if it belongs to the 'LV_GC_ROOT(_lv_act_scr)'*/
|
||||||
@@ -532,6 +541,9 @@ void lv_obj_invalidate(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
|
void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_OBJ(parent, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(obj->par == NULL) {
|
if(obj->par == NULL) {
|
||||||
LV_LOG_WARN("Can't set the parent of a screen");
|
LV_LOG_WARN("Can't set the parent of a screen");
|
||||||
return;
|
return;
|
||||||
@@ -569,6 +581,8 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_move_foreground(lv_obj_t * obj)
|
void lv_obj_move_foreground(lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||||
|
|
||||||
/*Do nothing of already in the foreground*/
|
/*Do nothing of already in the foreground*/
|
||||||
@@ -590,6 +604,8 @@ void lv_obj_move_foreground(lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_move_background(lv_obj_t * obj)
|
void lv_obj_move_background(lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||||
|
|
||||||
/*Do nothing of already in the background*/
|
/*Do nothing of already in the background*/
|
||||||
@@ -617,6 +633,8 @@ void lv_obj_move_background(lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
|
void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
/*Convert x and y to absolute coordinates*/
|
/*Convert x and y to absolute coordinates*/
|
||||||
lv_obj_t * par = obj->par;
|
lv_obj_t * par = obj->par;
|
||||||
|
|
||||||
@@ -664,6 +682,8 @@ void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_x(lv_obj_t * obj, lv_coord_t x)
|
void lv_obj_set_x(lv_obj_t * obj, lv_coord_t x)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_obj_set_pos(obj, x, lv_obj_get_y(obj));
|
lv_obj_set_pos(obj, x, lv_obj_get_y(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -674,6 +694,8 @@ void lv_obj_set_x(lv_obj_t * obj, lv_coord_t x)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_y(lv_obj_t * obj, lv_coord_t y)
|
void lv_obj_set_y(lv_obj_t * obj, lv_coord_t y)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_obj_set_pos(obj, lv_obj_get_x(obj), y);
|
lv_obj_set_pos(obj, lv_obj_get_x(obj), y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -685,6 +707,8 @@ void lv_obj_set_y(lv_obj_t * obj, lv_coord_t y)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h)
|
void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
|
|
||||||
/* Do nothing if the size is not changed */
|
/* Do nothing if the size is not changed */
|
||||||
/* It is very important else recursive resizing can
|
/* It is very important else recursive resizing can
|
||||||
@@ -734,6 +758,8 @@ void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_width(lv_obj_t * obj, lv_coord_t w)
|
void lv_obj_set_width(lv_obj_t * obj, lv_coord_t w)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_obj_set_size(obj, w, lv_obj_get_height(obj));
|
lv_obj_set_size(obj, w, lv_obj_get_height(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -744,6 +770,8 @@ void lv_obj_set_width(lv_obj_t * obj, lv_coord_t w)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h)
|
void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_obj_set_size(obj, lv_obj_get_width(obj), h);
|
lv_obj_set_size(obj, lv_obj_get_width(obj), h);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,6 +785,8 @@ void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod)
|
void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_coord_t new_x = lv_obj_get_x(obj);
|
lv_coord_t new_x = lv_obj_get_x(obj);
|
||||||
lv_coord_t new_y = lv_obj_get_y(obj);
|
lv_coord_t new_y = lv_obj_get_y(obj);
|
||||||
|
|
||||||
@@ -764,6 +794,9 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
|
|||||||
base = lv_obj_get_parent(obj);
|
base = lv_obj_get_parent(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LV_ASSERT_OBJ(base, LV_OBJX_NAME);
|
||||||
|
|
||||||
|
|
||||||
switch(align) {
|
switch(align) {
|
||||||
case LV_ALIGN_CENTER:
|
case LV_ALIGN_CENTER:
|
||||||
new_x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
new_x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
||||||
@@ -902,6 +935,8 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
|
|||||||
*/
|
*/
|
||||||
void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod)
|
void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_coord_t new_x = lv_obj_get_x(obj);
|
lv_coord_t new_x = lv_obj_get_x(obj);
|
||||||
lv_coord_t new_y = lv_obj_get_y(obj);
|
lv_coord_t new_y = lv_obj_get_y(obj);
|
||||||
|
|
||||||
@@ -912,6 +947,9 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align,
|
|||||||
base = lv_obj_get_parent(obj);
|
base = lv_obj_get_parent(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LV_ASSERT_OBJ(base, LV_OBJX_NAME);
|
||||||
|
|
||||||
|
|
||||||
switch(align) {
|
switch(align) {
|
||||||
case LV_ALIGN_CENTER:
|
case LV_ALIGN_CENTER:
|
||||||
new_x = lv_obj_get_width(base) / 2 - obj_w_half;
|
new_x = lv_obj_get_width(base) / 2 - obj_w_half;
|
||||||
@@ -1046,6 +1084,8 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align,
|
|||||||
*/
|
*/
|
||||||
void lv_obj_realign(lv_obj_t * obj)
|
void lv_obj_realign(lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_OBJ_REALIGN
|
#if LV_USE_OBJ_REALIGN
|
||||||
if(obj->realign.origo_align)
|
if(obj->realign.origo_align)
|
||||||
lv_obj_align_origo(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, obj->realign.yofs);
|
lv_obj_align_origo(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, obj->realign.yofs);
|
||||||
@@ -1065,6 +1105,8 @@ void lv_obj_realign(lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_auto_realign(lv_obj_t * obj, bool en)
|
void lv_obj_set_auto_realign(lv_obj_t * obj, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_OBJ_REALIGN
|
#if LV_USE_OBJ_REALIGN
|
||||||
obj->realign.auto_realign = en ? 1 : 0;
|
obj->realign.auto_realign = en ? 1 : 0;
|
||||||
#else
|
#else
|
||||||
@@ -1083,6 +1125,8 @@ void lv_obj_set_auto_realign(lv_obj_t * obj, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_ext_click_area(lv_obj_t * obj, uint8_t w, uint8_t h)
|
void lv_obj_set_ext_click_area(lv_obj_t * obj, uint8_t w, uint8_t h)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
obj->ext_click_pad_hor = w;
|
obj->ext_click_pad_hor = w;
|
||||||
obj->ext_click_pad_ver = h;
|
obj->ext_click_pad_ver = h;
|
||||||
}
|
}
|
||||||
@@ -1100,6 +1144,8 @@ void lv_obj_set_ext_click_area(lv_obj_t * obj, uint8_t w, uint8_t h)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_ext_click_area(lv_obj_t * obj, lv_coord_t left, lv_coord_t right, lv_coord_t top, lv_coord_t bottom)
|
void lv_obj_set_ext_click_area(lv_obj_t * obj, lv_coord_t left, lv_coord_t right, lv_coord_t top, lv_coord_t bottom)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
|
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
|
||||||
obj->ext_click_pad.x1 = left;
|
obj->ext_click_pad.x1 = left;
|
||||||
obj->ext_click_pad.x2 = right;
|
obj->ext_click_pad.x2 = right;
|
||||||
@@ -1128,6 +1174,9 @@ void lv_obj_set_ext_click_area(lv_obj_t * obj, lv_coord_t left, lv_coord_t right
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_style(lv_obj_t * obj, const lv_style_t * style)
|
void lv_obj_set_style(lv_obj_t * obj, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_STYLE(style);
|
||||||
|
|
||||||
obj->style_p = style;
|
obj->style_p = style;
|
||||||
|
|
||||||
/*Send a signal about style change to every children with NULL style*/
|
/*Send a signal about style change to every children with NULL style*/
|
||||||
@@ -1143,6 +1192,8 @@ void lv_obj_set_style(lv_obj_t * obj, const lv_style_t * style)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_refresh_style(lv_obj_t * obj)
|
void lv_obj_refresh_style(lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_obj_invalidate(obj);
|
lv_obj_invalidate(obj);
|
||||||
obj->signal_cb(obj, LV_SIGNAL_STYLE_CHG, NULL);
|
obj->signal_cb(obj, LV_SIGNAL_STYLE_CHG, NULL);
|
||||||
lv_obj_invalidate(obj);
|
lv_obj_invalidate(obj);
|
||||||
@@ -1155,6 +1206,8 @@ void lv_obj_refresh_style(lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_report_style_mod(lv_style_t * style)
|
void lv_obj_report_style_mod(lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_STYLE(style);
|
||||||
|
|
||||||
lv_disp_t * d = lv_disp_get_next(NULL);
|
lv_disp_t * d = lv_disp_get_next(NULL);
|
||||||
|
|
||||||
while(d) {
|
while(d) {
|
||||||
@@ -1182,6 +1235,8 @@ void lv_obj_report_style_mod(lv_style_t * style)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_hidden(lv_obj_t * obj, bool en)
|
void lv_obj_set_hidden(lv_obj_t * obj, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(!obj->hidden) lv_obj_invalidate(obj); /*Invalidate when not hidden (hidden objects are ignored) */
|
if(!obj->hidden) lv_obj_invalidate(obj); /*Invalidate when not hidden (hidden objects are ignored) */
|
||||||
|
|
||||||
obj->hidden = en == false ? 0 : 1;
|
obj->hidden = en == false ? 0 : 1;
|
||||||
@@ -1199,6 +1254,8 @@ void lv_obj_set_hidden(lv_obj_t * obj, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_click(lv_obj_t * obj, bool en)
|
void lv_obj_set_click(lv_obj_t * obj, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
obj->click = (en == true ? 1 : 0);
|
obj->click = (en == true ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1210,6 +1267,8 @@ void lv_obj_set_click(lv_obj_t * obj, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_top(lv_obj_t * obj, bool en)
|
void lv_obj_set_top(lv_obj_t * obj, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
obj->top = (en == true ? 1 : 0);
|
obj->top = (en == true ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1220,6 +1279,8 @@ void lv_obj_set_top(lv_obj_t * obj, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_drag(lv_obj_t * obj, bool en)
|
void lv_obj_set_drag(lv_obj_t * obj, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(en == true) lv_obj_set_click(obj, true); /*Drag is useless without enabled clicking*/
|
if(en == true) lv_obj_set_click(obj, true); /*Drag is useless without enabled clicking*/
|
||||||
obj->drag = (en == true ? 1 : 0);
|
obj->drag = (en == true ? 1 : 0);
|
||||||
}
|
}
|
||||||
@@ -1231,6 +1292,8 @@ void lv_obj_set_drag(lv_obj_t * obj, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_drag_dir(lv_obj_t * obj, lv_drag_dir_t drag_dir)
|
void lv_obj_set_drag_dir(lv_obj_t * obj, lv_drag_dir_t drag_dir)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
obj->drag_dir = drag_dir;
|
obj->drag_dir = drag_dir;
|
||||||
|
|
||||||
if(obj->drag_dir != 0) lv_obj_set_drag(obj, true); /*Drag direction requires drag*/
|
if(obj->drag_dir != 0) lv_obj_set_drag(obj, true); /*Drag direction requires drag*/
|
||||||
@@ -1243,6 +1306,8 @@ void lv_obj_set_drag_dir(lv_obj_t * obj, lv_drag_dir_t drag_dir)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_drag_throw(lv_obj_t * obj, bool en)
|
void lv_obj_set_drag_throw(lv_obj_t * obj, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
obj->drag_throw = (en == true ? 1 : 0);
|
obj->drag_throw = (en == true ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1254,6 +1319,8 @@ void lv_obj_set_drag_throw(lv_obj_t * obj, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_drag_parent(lv_obj_t * obj, bool en)
|
void lv_obj_set_drag_parent(lv_obj_t * obj, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
obj->drag_parent = (en == true ? 1 : 0);
|
obj->drag_parent = (en == true ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1264,6 +1331,8 @@ void lv_obj_set_drag_parent(lv_obj_t * obj, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_parent_event(lv_obj_t * obj, bool en)
|
void lv_obj_set_parent_event(lv_obj_t * obj, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
obj->parent_event = (en == true ? 1 : 0);
|
obj->parent_event = (en == true ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1274,6 +1343,8 @@ void lv_obj_set_parent_event(lv_obj_t * obj, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_opa_scale_enable(lv_obj_t * obj, bool en)
|
void lv_obj_set_opa_scale_enable(lv_obj_t * obj, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
obj->opa_scale_en = en ? 1 : 0;
|
obj->opa_scale_en = en ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1287,6 +1358,8 @@ void lv_obj_set_opa_scale_enable(lv_obj_t * obj, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_opa_scale(lv_obj_t * obj, lv_opa_t opa_scale)
|
void lv_obj_set_opa_scale(lv_obj_t * obj, lv_opa_t opa_scale)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
obj->opa_scale = opa_scale;
|
obj->opa_scale = opa_scale;
|
||||||
lv_obj_invalidate(obj);
|
lv_obj_invalidate(obj);
|
||||||
}
|
}
|
||||||
@@ -1298,6 +1371,8 @@ void lv_obj_set_opa_scale(lv_obj_t * obj, lv_opa_t opa_scale)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_protect(lv_obj_t * obj, uint8_t prot)
|
void lv_obj_set_protect(lv_obj_t * obj, uint8_t prot)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
obj->protect |= prot;
|
obj->protect |= prot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1308,6 +1383,8 @@ void lv_obj_set_protect(lv_obj_t * obj, uint8_t prot)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_clear_protect(lv_obj_t * obj, uint8_t prot)
|
void lv_obj_clear_protect(lv_obj_t * obj, uint8_t prot)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
prot = (~prot) & 0xFF;
|
prot = (~prot) & 0xFF;
|
||||||
obj->protect &= prot;
|
obj->protect &= prot;
|
||||||
}
|
}
|
||||||
@@ -1320,6 +1397,8 @@ void lv_obj_clear_protect(lv_obj_t * obj, uint8_t prot)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb)
|
void lv_obj_set_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
obj->event_cb = event_cb;
|
obj->event_cb = event_cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1334,6 +1413,8 @@ lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, const void * data)
|
|||||||
{
|
{
|
||||||
if(obj == NULL) return LV_RES_OK;
|
if(obj == NULL) return LV_RES_OK;
|
||||||
|
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_res_t res;
|
lv_res_t res;
|
||||||
res = lv_event_send_func(obj->event_cb, obj, event, data);
|
res = lv_event_send_func(obj->event_cb, obj, event, data);
|
||||||
return res;
|
return res;
|
||||||
@@ -1351,6 +1432,8 @@ lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, const void * data)
|
|||||||
*/
|
*/
|
||||||
lv_res_t lv_event_send_func(lv_event_cb_t event_xcb, lv_obj_t * obj, lv_event_t event, const void * data)
|
lv_res_t lv_event_send_func(lv_event_cb_t event_xcb, lv_obj_t * obj, lv_event_t event, const void * data)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
/* Build a simple linked list from the objects used in the events
|
/* Build a simple linked list from the objects used in the events
|
||||||
* It's important to know if an this object was deleted by a nested event
|
* It's important to know if an this object was deleted by a nested event
|
||||||
* called from this `even_cb`. */
|
* called from this `even_cb`. */
|
||||||
@@ -1415,6 +1498,8 @@ const void * lv_event_get_data(void)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_signal_cb(lv_obj_t * obj, lv_signal_cb_t signal_cb)
|
void lv_obj_set_signal_cb(lv_obj_t * obj, lv_signal_cb_t signal_cb)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
obj->signal_cb = signal_cb;
|
obj->signal_cb = signal_cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1425,6 +1510,8 @@ void lv_obj_set_signal_cb(lv_obj_t * obj, lv_signal_cb_t signal_cb)
|
|||||||
*/
|
*/
|
||||||
void lv_signal_send(lv_obj_t * obj, lv_signal_t signal, void * param)
|
void lv_signal_send(lv_obj_t * obj, lv_signal_t signal, void * param)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(obj->signal_cb) obj->signal_cb(obj, signal, param);
|
if(obj->signal_cb) obj->signal_cb(obj, signal, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1435,6 +1522,8 @@ void lv_signal_send(lv_obj_t * obj, lv_signal_t signal, void * param)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_design_cb(lv_obj_t * obj, lv_design_cb_t design_cb)
|
void lv_obj_set_design_cb(lv_obj_t * obj, lv_design_cb_t design_cb)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
obj->design_cb = design_cb;
|
obj->design_cb = design_cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1450,6 +1539,8 @@ void lv_obj_set_design_cb(lv_obj_t * obj, lv_design_cb_t design_cb)
|
|||||||
*/
|
*/
|
||||||
void * lv_obj_allocate_ext_attr(lv_obj_t * obj, uint16_t ext_size)
|
void * lv_obj_allocate_ext_attr(lv_obj_t * obj, uint16_t ext_size)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
obj->ext_attr = lv_mem_realloc(obj->ext_attr, ext_size);
|
obj->ext_attr = lv_mem_realloc(obj->ext_attr, ext_size);
|
||||||
|
|
||||||
return (void *)obj->ext_attr;
|
return (void *)obj->ext_attr;
|
||||||
@@ -1461,6 +1552,8 @@ void * lv_obj_allocate_ext_attr(lv_obj_t * obj, uint16_t ext_size)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_refresh_ext_draw_pad(lv_obj_t * obj)
|
void lv_obj_refresh_ext_draw_pad(lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
obj->ext_draw_pad = 0;
|
obj->ext_draw_pad = 0;
|
||||||
obj->signal_cb(obj, LV_SIGNAL_REFR_EXT_DRAW_PAD, NULL);
|
obj->signal_cb(obj, LV_SIGNAL_REFR_EXT_DRAW_PAD, NULL);
|
||||||
|
|
||||||
@@ -1478,6 +1571,8 @@ void lv_obj_refresh_ext_draw_pad(lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj)
|
lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_obj_t * par = obj;
|
const lv_obj_t * par = obj;
|
||||||
const lv_obj_t * act_p;
|
const lv_obj_t * act_p;
|
||||||
|
|
||||||
@@ -1496,6 +1591,8 @@ lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj)
|
lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_obj_t * scr;
|
const lv_obj_t * scr;
|
||||||
|
|
||||||
if(obj->par == NULL)
|
if(obj->par == NULL)
|
||||||
@@ -1528,6 +1625,8 @@ lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_obj_get_parent(const lv_obj_t * obj)
|
lv_obj_t * lv_obj_get_parent(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return obj->par;
|
return obj->par;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1540,6 +1639,8 @@ lv_obj_t * lv_obj_get_parent(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_obj_get_child(const lv_obj_t * obj, const lv_obj_t * child)
|
lv_obj_t * lv_obj_get_child(const lv_obj_t * obj, const lv_obj_t * child)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_obj_t * result = NULL;
|
lv_obj_t * result = NULL;
|
||||||
|
|
||||||
if(child == NULL) {
|
if(child == NULL) {
|
||||||
@@ -1560,6 +1661,8 @@ lv_obj_t * lv_obj_get_child(const lv_obj_t * obj, const lv_obj_t * child)
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_obj_get_child_back(const lv_obj_t * obj, const lv_obj_t * child)
|
lv_obj_t * lv_obj_get_child_back(const lv_obj_t * obj, const lv_obj_t * child)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_obj_t * result = NULL;
|
lv_obj_t * result = NULL;
|
||||||
|
|
||||||
if(child == NULL) {
|
if(child == NULL) {
|
||||||
@@ -1578,6 +1681,8 @@ lv_obj_t * lv_obj_get_child_back(const lv_obj_t * obj, const lv_obj_t * child)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_obj_count_children(const lv_obj_t * obj)
|
uint16_t lv_obj_count_children(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_obj_t * i;
|
lv_obj_t * i;
|
||||||
uint16_t cnt = 0;
|
uint16_t cnt = 0;
|
||||||
|
|
||||||
@@ -1592,6 +1697,8 @@ uint16_t lv_obj_count_children(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_obj_count_children_recursive(const lv_obj_t * obj)
|
uint16_t lv_obj_count_children_recursive(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_obj_t * i;
|
lv_obj_t * i;
|
||||||
uint16_t cnt = 0;
|
uint16_t cnt = 0;
|
||||||
|
|
||||||
@@ -1615,6 +1722,8 @@ uint16_t lv_obj_count_children_recursive(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_get_coords(const lv_obj_t * obj, lv_area_t * cords_p)
|
void lv_obj_get_coords(const lv_obj_t * obj, lv_area_t * cords_p)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_area_copy(cords_p, &obj->coords);
|
lv_area_copy(cords_p, &obj->coords);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1625,6 +1734,8 @@ void lv_obj_get_coords(const lv_obj_t * obj, lv_area_t * cords_p)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_get_inner_coords(const lv_obj_t * obj, lv_area_t * coords_p)
|
void lv_obj_get_inner_coords(const lv_obj_t * obj, lv_area_t * coords_p)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = lv_obj_get_style(obj);
|
const lv_style_t * style = lv_obj_get_style(obj);
|
||||||
if(style->body.border.part & LV_BORDER_PART_LEFT) coords_p->x1 += style->body.border.width;
|
if(style->body.border.part & LV_BORDER_PART_LEFT) coords_p->x1 += style->body.border.width;
|
||||||
|
|
||||||
@@ -1642,6 +1753,8 @@ void lv_obj_get_inner_coords(const lv_obj_t * obj, lv_area_t * coords_p)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_obj_get_x(const lv_obj_t * obj)
|
lv_coord_t lv_obj_get_x(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_coord_t rel_x;
|
lv_coord_t rel_x;
|
||||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||||
rel_x = obj->coords.x1 - parent->coords.x1;
|
rel_x = obj->coords.x1 - parent->coords.x1;
|
||||||
@@ -1656,6 +1769,8 @@ lv_coord_t lv_obj_get_x(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_obj_get_y(const lv_obj_t * obj)
|
lv_coord_t lv_obj_get_y(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_coord_t rel_y;
|
lv_coord_t rel_y;
|
||||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||||
rel_y = obj->coords.y1 - parent->coords.y1;
|
rel_y = obj->coords.y1 - parent->coords.y1;
|
||||||
@@ -1670,6 +1785,8 @@ lv_coord_t lv_obj_get_y(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_obj_get_width(const lv_obj_t * obj)
|
lv_coord_t lv_obj_get_width(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return lv_area_get_width(&obj->coords);
|
return lv_area_get_width(&obj->coords);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1680,6 +1797,8 @@ lv_coord_t lv_obj_get_width(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_obj_get_height(const lv_obj_t * obj)
|
lv_coord_t lv_obj_get_height(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return lv_area_get_height(&obj->coords);
|
return lv_area_get_height(&obj->coords);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1690,6 +1809,8 @@ lv_coord_t lv_obj_get_height(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_obj_get_width_fit(lv_obj_t * obj)
|
lv_coord_t lv_obj_get_width_fit(lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = lv_obj_get_style(obj);
|
const lv_style_t * style = lv_obj_get_style(obj);
|
||||||
|
|
||||||
return lv_obj_get_width(obj) - style->body.padding.left - style->body.padding.right;
|
return lv_obj_get_width(obj) - style->body.padding.left - style->body.padding.right;
|
||||||
@@ -1702,6 +1823,8 @@ lv_coord_t lv_obj_get_width_fit(lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_obj_get_height_fit(lv_obj_t * obj)
|
lv_coord_t lv_obj_get_height_fit(lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = lv_obj_get_style(obj);
|
const lv_style_t * style = lv_obj_get_style(obj);
|
||||||
|
|
||||||
return lv_obj_get_height(obj) - style->body.padding.top - style->body.padding.bottom;
|
return lv_obj_get_height(obj) - style->body.padding.top - style->body.padding.bottom;
|
||||||
@@ -1714,6 +1837,8 @@ lv_coord_t lv_obj_get_height_fit(lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
bool lv_obj_get_auto_realign(lv_obj_t * obj)
|
bool lv_obj_get_auto_realign(lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_OBJ_REALIGN
|
#if LV_USE_OBJ_REALIGN
|
||||||
return obj->realign.auto_realign ? true : false;
|
return obj->realign.auto_realign ? true : false;
|
||||||
#else
|
#else
|
||||||
@@ -1729,6 +1854,8 @@ bool lv_obj_get_auto_realign(lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_obj_get_ext_click_pad_left(const lv_obj_t * obj)
|
lv_coord_t lv_obj_get_ext_click_pad_left(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
|
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
|
||||||
return obj->ext_click_pad_hor;
|
return obj->ext_click_pad_hor;
|
||||||
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
|
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
|
||||||
@@ -1746,6 +1873,8 @@ lv_coord_t lv_obj_get_ext_click_pad_left(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_obj_get_ext_click_pad_right(const lv_obj_t * obj)
|
lv_coord_t lv_obj_get_ext_click_pad_right(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
|
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
|
||||||
return obj->ext_click_pad_hor;
|
return obj->ext_click_pad_hor;
|
||||||
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
|
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
|
||||||
@@ -1763,6 +1892,8 @@ lv_coord_t lv_obj_get_ext_click_pad_right(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_obj_get_ext_click_pad_top(const lv_obj_t * obj)
|
lv_coord_t lv_obj_get_ext_click_pad_top(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
|
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
|
||||||
return obj->ext_click_pad_ver;
|
return obj->ext_click_pad_ver;
|
||||||
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
|
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
|
||||||
@@ -1780,6 +1911,8 @@ lv_coord_t lv_obj_get_ext_click_pad_top(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_obj_get_ext_click_pad_bottom(const lv_obj_t * obj)
|
lv_coord_t lv_obj_get_ext_click_pad_bottom(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
|
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
|
||||||
return obj->ext_click_pad_ver
|
return obj->ext_click_pad_ver
|
||||||
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
|
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
|
||||||
@@ -1797,6 +1930,8 @@ lv_coord_t lv_obj_get_ext_click_pad_bottom(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_obj_get_ext_draw_pad(const lv_obj_t * obj)
|
lv_coord_t lv_obj_get_ext_draw_pad(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return obj->ext_draw_pad;
|
return obj->ext_draw_pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1811,6 +1946,8 @@ lv_coord_t lv_obj_get_ext_draw_pad(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
const lv_style_t * lv_obj_get_style(const lv_obj_t * obj)
|
const lv_style_t * lv_obj_get_style(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style_act = obj->style_p;
|
const lv_style_t * style_act = obj->style_p;
|
||||||
if(style_act == NULL) {
|
if(style_act == NULL) {
|
||||||
lv_obj_t * par = obj->par;
|
lv_obj_t * par = obj->par;
|
||||||
@@ -1859,6 +1996,8 @@ const lv_style_t * lv_obj_get_style(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
bool lv_obj_get_hidden(const lv_obj_t * obj)
|
bool lv_obj_get_hidden(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return obj->hidden == 0 ? false : true;
|
return obj->hidden == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1869,6 +2008,8 @@ bool lv_obj_get_hidden(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
bool lv_obj_get_click(const lv_obj_t * obj)
|
bool lv_obj_get_click(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return obj->click == 0 ? false : true;
|
return obj->click == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1879,6 +2020,8 @@ bool lv_obj_get_click(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
bool lv_obj_get_top(const lv_obj_t * obj)
|
bool lv_obj_get_top(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return obj->top == 0 ? false : true;
|
return obj->top == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1889,6 +2032,8 @@ bool lv_obj_get_top(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
bool lv_obj_get_drag(const lv_obj_t * obj)
|
bool lv_obj_get_drag(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return obj->drag == 0 ? false : true;
|
return obj->drag == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1899,6 +2044,8 @@ bool lv_obj_get_drag(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_drag_dir_t lv_obj_get_drag_dir(const lv_obj_t * obj)
|
lv_drag_dir_t lv_obj_get_drag_dir(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return obj->drag_dir;
|
return obj->drag_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1909,6 +2056,8 @@ lv_drag_dir_t lv_obj_get_drag_dir(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
bool lv_obj_get_drag_throw(const lv_obj_t * obj)
|
bool lv_obj_get_drag_throw(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return obj->drag_throw == 0 ? false : true;
|
return obj->drag_throw == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1929,6 +2078,8 @@ bool lv_obj_get_drag_parent(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
bool lv_obj_get_parent_event(const lv_obj_t * obj)
|
bool lv_obj_get_parent_event(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return obj->parent_event == 0 ? false : true;
|
return obj->parent_event == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1939,6 +2090,8 @@ bool lv_obj_get_parent_event(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_opa_t lv_obj_get_opa_scale_enable(const lv_obj_t * obj)
|
lv_opa_t lv_obj_get_opa_scale_enable(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return obj->opa_scale_en == 0 ? false : true;
|
return obj->opa_scale_en == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1949,6 +2102,8 @@ lv_opa_t lv_obj_get_opa_scale_enable(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_opa_t lv_obj_get_opa_scale(const lv_obj_t * obj)
|
lv_opa_t lv_obj_get_opa_scale(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_obj_t * parent = obj;
|
const lv_obj_t * parent = obj;
|
||||||
|
|
||||||
while(parent) {
|
while(parent) {
|
||||||
@@ -1966,6 +2121,8 @@ lv_opa_t lv_obj_get_opa_scale(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
uint8_t lv_obj_get_protect(const lv_obj_t * obj)
|
uint8_t lv_obj_get_protect(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return obj->protect;
|
return obj->protect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1977,6 +2134,8 @@ uint8_t lv_obj_get_protect(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
bool lv_obj_is_protected(const lv_obj_t * obj, uint8_t prot)
|
bool lv_obj_is_protected(const lv_obj_t * obj, uint8_t prot)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return (obj->protect & prot) == 0 ? false : true;
|
return (obj->protect & prot) == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1987,6 +2146,8 @@ bool lv_obj_is_protected(const lv_obj_t * obj, uint8_t prot)
|
|||||||
*/
|
*/
|
||||||
lv_signal_cb_t lv_obj_get_signal_cb(const lv_obj_t * obj)
|
lv_signal_cb_t lv_obj_get_signal_cb(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return obj->signal_cb;
|
return obj->signal_cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1997,6 +2158,8 @@ lv_signal_cb_t lv_obj_get_signal_cb(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_design_cb_t lv_obj_get_design_cb(const lv_obj_t * obj)
|
lv_design_cb_t lv_obj_get_design_cb(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return obj->design_cb;
|
return obj->design_cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2007,6 +2170,8 @@ lv_design_cb_t lv_obj_get_design_cb(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_event_cb_t lv_obj_get_event_cb(const lv_obj_t * obj)
|
lv_event_cb_t lv_obj_get_event_cb(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return obj->event_cb;
|
return obj->event_cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2022,6 +2187,8 @@ lv_event_cb_t lv_obj_get_event_cb(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
void * lv_obj_get_ext_attr(const lv_obj_t * obj)
|
void * lv_obj_get_ext_attr(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return obj->ext_attr;
|
return obj->ext_attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2033,6 +2200,9 @@ void * lv_obj_get_ext_attr(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_get_type(lv_obj_t * obj, lv_obj_type_t * buf)
|
void lv_obj_get_type(lv_obj_t * obj, lv_obj_type_t * buf)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_NULL(buf);
|
||||||
|
LV_ASSERT_NULL(obj);
|
||||||
|
|
||||||
lv_obj_type_t tmp;
|
lv_obj_type_t tmp;
|
||||||
|
|
||||||
memset(buf, 0, sizeof(lv_obj_type_t));
|
memset(buf, 0, sizeof(lv_obj_type_t));
|
||||||
@@ -2061,6 +2231,8 @@ void lv_obj_get_type(lv_obj_t * obj, lv_obj_type_t * buf)
|
|||||||
*/
|
*/
|
||||||
lv_obj_user_data_t lv_obj_get_user_data(lv_obj_t * obj)
|
lv_obj_user_data_t lv_obj_get_user_data(lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return obj->user_data;
|
return obj->user_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2071,6 +2243,8 @@ lv_obj_user_data_t lv_obj_get_user_data(lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_obj_user_data_t * lv_obj_get_user_data_ptr(lv_obj_t * obj)
|
lv_obj_user_data_t * lv_obj_get_user_data_ptr(lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return &obj->user_data;
|
return &obj->user_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2081,6 +2255,8 @@ lv_obj_user_data_t * lv_obj_get_user_data_ptr(lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
void lv_obj_set_user_data(lv_obj_t * obj, lv_obj_user_data_t data)
|
void lv_obj_set_user_data(lv_obj_t * obj, lv_obj_user_data_t data)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
memcpy(&obj->user_data, &data, sizeof(lv_obj_user_data_t));
|
memcpy(&obj->user_data, &data, sizeof(lv_obj_user_data_t));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -2093,6 +2269,8 @@ void lv_obj_set_user_data(lv_obj_t * obj, lv_obj_user_data_t data)
|
|||||||
*/
|
*/
|
||||||
void * lv_obj_get_group(const lv_obj_t * obj)
|
void * lv_obj_get_group(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
return obj->group_p;
|
return obj->group_p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2103,6 +2281,8 @@ void * lv_obj_get_group(const lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
bool lv_obj_is_focused(const lv_obj_t * obj)
|
bool lv_obj_is_focused(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(obj->group_p) {
|
if(obj->group_p) {
|
||||||
if(lv_group_get_focused(obj->group_p) == obj) return true;
|
if(lv_group_get_focused(obj->group_p) == obj) return true;
|
||||||
}
|
}
|
||||||
@@ -2111,12 +2291,37 @@ bool lv_obj_is_focused(const lv_obj_t * obj)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------
|
||||||
|
* OTHER FUNCTIONS
|
||||||
|
*------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used in the signal callback to handle `LV_SIGNAL_GET_TYPE` signal
|
||||||
|
* @param obj pointer to an object
|
||||||
|
* @param buf pointer to `lv_obj_type_t`. (`param` i nteh signal callback)
|
||||||
|
* @param name name of the object. E.g. "lv_btn". (Only teh pointer is saved)
|
||||||
|
* @return LV_RES_OK
|
||||||
|
*/
|
||||||
|
lv_res_t lv_obj_handle_get_type_signal(lv_obj_type_t * buf, const char * name)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||||
|
if(buf->type[i] == NULL) break;
|
||||||
|
}
|
||||||
|
buf->type[i] = name;
|
||||||
|
|
||||||
|
return LV_RES_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC FUNCTIONS
|
* STATIC FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
static void lv_obj_del_async_cb(void * obj)
|
static void lv_obj_del_async_cb(void * obj)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_obj_del(obj);
|
lv_obj_del(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2179,16 +2384,15 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area
|
|||||||
*/
|
*/
|
||||||
static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||||
{
|
{
|
||||||
(void)param;
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_res_t res = LV_RES_OK;
|
lv_res_t res = LV_RES_OK;
|
||||||
|
|
||||||
const lv_style_t * style = lv_obj_get_style(obj);
|
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_CHILD_CHG) {
|
if(sign == LV_SIGNAL_CHILD_CHG) {
|
||||||
/*Return 'invalid' if the child change signal is not enabled*/
|
/*Return 'invalid' if the child change signal is not enabled*/
|
||||||
if(lv_obj_is_protected(obj, LV_PROTECT_CHILD_CHG) != false) res = LV_RES_INV;
|
if(lv_obj_is_protected(obj, LV_PROTECT_CHILD_CHG) != false) res = LV_RES_INV;
|
||||||
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
||||||
|
const lv_style_t * style = lv_obj_get_style(obj);
|
||||||
lv_coord_t shadow = (style->body.shadow.width >> 1) + 1;
|
lv_coord_t shadow = (style->body.shadow.width >> 1) + 1;
|
||||||
shadow += style->body.shadow.spread;
|
shadow += style->body.shadow.spread;
|
||||||
shadow += LV_MATH_MAX(LV_MATH_ABS(style->body.shadow.offset.x), LV_MATH_ABS(style->body.shadow.offset.y));
|
shadow += LV_MATH_MAX(LV_MATH_ABS(style->body.shadow.offset.x), LV_MATH_ABS(style->body.shadow.offset.y));
|
||||||
@@ -2196,11 +2400,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
|||||||
if(shadow > obj->ext_draw_pad) obj->ext_draw_pad = shadow;
|
if(shadow > obj->ext_draw_pad) obj->ext_draw_pad = shadow;
|
||||||
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||||
lv_obj_refresh_ext_draw_pad(obj);
|
lv_obj_refresh_ext_draw_pad(obj);
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
buf->type[0] = "lv_obj";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2321,13 +2521,13 @@ static void delete_children(lv_obj_t * obj)
|
|||||||
indev = lv_indev_get_next(indev);
|
indev = lv_indev_get_next(indev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Clean up the object specific data*/
|
||||||
|
obj->signal_cb(obj, LV_SIGNAL_CLEANUP, NULL);
|
||||||
|
|
||||||
/*Remove the object from parent's children list*/
|
/*Remove the object from parent's children list*/
|
||||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||||
lv_ll_rem(&(par->child_ll), obj);
|
lv_ll_rem(&(par->child_ll), obj);
|
||||||
|
|
||||||
/* Clean up the object specific data*/
|
|
||||||
obj->signal_cb(obj, LV_SIGNAL_CLEANUP, NULL);
|
|
||||||
|
|
||||||
/*Delete the base objects*/
|
/*Delete the base objects*/
|
||||||
if(obj->ext_attr != NULL) lv_mem_free(obj->ext_attr);
|
if(obj->ext_attr != NULL) lv_mem_free(obj->ext_attr);
|
||||||
lv_mem_free(obj); /*Free the object itself*/
|
lv_mem_free(obj); /*Free the object itself*/
|
||||||
|
|||||||
@@ -965,6 +965,18 @@ bool lv_obj_is_focused(const lv_obj_t * obj);
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*-------------------
|
||||||
|
* OTHER FUNCTIONS
|
||||||
|
*------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used in the signal callback to handle `LV_SIGNAL_GET_TYPE` signal
|
||||||
|
* @param buf pointer to `lv_obj_type_t`. (`param` i nteh signal callback)
|
||||||
|
* @param name name of the object. E.g. "lv_btn". (Only teh pointer is saved)
|
||||||
|
* @return LV_RES_OK
|
||||||
|
*/
|
||||||
|
lv_res_t lv_obj_handle_get_type_signal(lv_obj_type_t * buf, const char * name);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
* INCLUDES
|
* INCLUDES
|
||||||
*********************/
|
*********************/
|
||||||
#include "lv_obj.h"
|
#include "lv_obj.h"
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_misc/lv_mem.h"
|
#include "../lv_misc/lv_mem.h"
|
||||||
#include "../lv_misc/lv_anim.h"
|
#include "../lv_misc/lv_anim.h"
|
||||||
|
|
||||||
@@ -313,7 +314,7 @@ void lv_style_anim_init(lv_anim_t * a)
|
|||||||
|
|
||||||
lv_style_anim_dsc_t * dsc;
|
lv_style_anim_dsc_t * dsc;
|
||||||
dsc = lv_mem_alloc(sizeof(lv_style_anim_dsc_t));
|
dsc = lv_mem_alloc(sizeof(lv_style_anim_dsc_t));
|
||||||
lv_mem_assert(dsc);
|
LV_ASSERT_MEM(dsc);
|
||||||
if(dsc == NULL) return;
|
if(dsc == NULL) return;
|
||||||
dsc->ready_cb = NULL;
|
dsc->ready_cb = NULL;
|
||||||
dsc->style_anim = NULL;
|
dsc->style_anim = NULL;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "lv_draw.h"
|
#include "lv_draw.h"
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_misc/lv_math.h"
|
#include "../lv_misc/lv_math.h"
|
||||||
#include "../lv_misc/lv_log.h"
|
#include "../lv_misc/lv_log.h"
|
||||||
#include "../lv_misc/lv_math.h"
|
#include "../lv_misc/lv_math.h"
|
||||||
@@ -66,7 +67,7 @@ void * lv_draw_buf_get(uint32_t size)
|
|||||||
_lv_draw_buf[i].used = 1;
|
_lv_draw_buf[i].used = 1;
|
||||||
_lv_draw_buf[i].size = size;
|
_lv_draw_buf[i].size = size;
|
||||||
_lv_draw_buf[i].p = lv_mem_realloc(_lv_draw_buf[i].p, size);
|
_lv_draw_buf[i].p = lv_mem_realloc(_lv_draw_buf[i].p, size);
|
||||||
lv_mem_assert(_lv_draw_buf[i].p);
|
LV_ASSERT_MEM(_lv_draw_buf[i].p);
|
||||||
return _lv_draw_buf[i].p;
|
return _lv_draw_buf[i].p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ extern "C" {
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
#define LV_DRAW_BUF_MAX_NUM 6
|
#ifndef LV_DRAW_BUF_MAX_NUM
|
||||||
|
#define LV_DRAW_BUF_MAX_NUM 8
|
||||||
|
#endif
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
|
|||||||
@@ -66,6 +66,13 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
|
|||||||
{
|
{
|
||||||
const lv_font_t * font = style->text.font;
|
const lv_font_t * font = style->text.font;
|
||||||
lv_coord_t w;
|
lv_coord_t w;
|
||||||
|
|
||||||
|
/*No need to waste processor time if string is empty*/
|
||||||
|
if (txt[0] == '\0')
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if((flag & LV_TXT_FLAG_EXPAND) == 0) {
|
if((flag & LV_TXT_FLAG_EXPAND) == 0) {
|
||||||
/*Normally use the label's width as width*/
|
/*Normally use the label's width as width*/
|
||||||
w = lv_area_get_width(coords);
|
w = lv_area_get_width(coords);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* INCLUDES
|
* INCLUDES
|
||||||
*********************/
|
*********************/
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "lv_img_cache.h"
|
#include "lv_img_cache.h"
|
||||||
#include "../lv_hal/lv_hal_tick.h"
|
#include "../lv_hal/lv_hal_tick.h"
|
||||||
#include "../lv_misc/lv_gc.h"
|
#include "../lv_misc/lv_gc.h"
|
||||||
@@ -152,7 +153,7 @@ void lv_img_cache_set_size(uint16_t new_entry_cnt)
|
|||||||
|
|
||||||
/*Reallocate the cache*/
|
/*Reallocate the cache*/
|
||||||
LV_GC_ROOT(_lv_img_cache_array) = lv_mem_alloc(sizeof(lv_img_cache_entry_t) * new_entry_cnt);
|
LV_GC_ROOT(_lv_img_cache_array) = lv_mem_alloc(sizeof(lv_img_cache_entry_t) * new_entry_cnt);
|
||||||
lv_mem_assert(LV_GC_ROOT(_lv_img_cache_array));
|
LV_ASSERT_MEM(LV_GC_ROOT(_lv_img_cache_array));
|
||||||
if(LV_GC_ROOT(_lv_img_cache_array) == NULL) {
|
if(LV_GC_ROOT(_lv_img_cache_array) == NULL) {
|
||||||
entry_cnt = 0;
|
entry_cnt = 0;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
* INCLUDES
|
* INCLUDES
|
||||||
*********************/
|
*********************/
|
||||||
#include "lv_img_decoder.h"
|
#include "lv_img_decoder.h"
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_draw/lv_draw_img.h"
|
#include "../lv_draw/lv_draw_img.h"
|
||||||
#include "../lv_misc/lv_ll.h"
|
#include "../lv_misc/lv_ll.h"
|
||||||
#include "../lv_misc/lv_color.h"
|
#include "../lv_misc/lv_color.h"
|
||||||
@@ -69,7 +70,7 @@ void lv_img_decoder_init(void)
|
|||||||
decoder = lv_img_decoder_create();
|
decoder = lv_img_decoder_create();
|
||||||
if(decoder == NULL) {
|
if(decoder == NULL) {
|
||||||
LV_LOG_WARN("lv_img_decoder_init: out of memory");
|
LV_LOG_WARN("lv_img_decoder_init: out of memory");
|
||||||
lv_mem_assert(decoder);
|
LV_ASSERT_MEM(decoder);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +188,7 @@ lv_img_decoder_t * lv_img_decoder_create(void)
|
|||||||
{
|
{
|
||||||
lv_img_decoder_t * decoder;
|
lv_img_decoder_t * decoder;
|
||||||
decoder = lv_ll_ins_head(&LV_GC_ROOT(_lv_img_defoder_ll));
|
decoder = lv_ll_ins_head(&LV_GC_ROOT(_lv_img_defoder_ll));
|
||||||
lv_mem_assert(decoder);
|
LV_ASSERT_MEM(decoder);
|
||||||
if(decoder == NULL) return NULL;
|
if(decoder == NULL) return NULL;
|
||||||
|
|
||||||
memset(decoder, 0, sizeof(lv_img_decoder_t));
|
memset(decoder, 0, sizeof(lv_img_decoder_t));
|
||||||
@@ -322,7 +323,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
|
|||||||
dsc->user_data = lv_mem_alloc(sizeof(lv_img_decoder_built_in_data_t));
|
dsc->user_data = lv_mem_alloc(sizeof(lv_img_decoder_built_in_data_t));
|
||||||
if(dsc->user_data == NULL) {
|
if(dsc->user_data == NULL) {
|
||||||
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
|
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
|
||||||
lv_mem_assert(dsc->user_data);
|
LV_ASSERT_MEM(dsc->user_data);
|
||||||
}
|
}
|
||||||
memset(dsc->user_data, 0, sizeof(lv_img_decoder_built_in_data_t));
|
memset(dsc->user_data, 0, sizeof(lv_img_decoder_built_in_data_t));
|
||||||
}
|
}
|
||||||
@@ -331,7 +332,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
|
|||||||
user_data->f = lv_mem_alloc(sizeof(f));
|
user_data->f = lv_mem_alloc(sizeof(f));
|
||||||
if(user_data->f == NULL) {
|
if(user_data->f == NULL) {
|
||||||
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
|
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
|
||||||
lv_mem_assert(user_data->f);
|
LV_ASSERT_MEM(user_data->f);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(user_data->f, &f, sizeof(f));
|
memcpy(user_data->f, &f, sizeof(f));
|
||||||
@@ -369,7 +370,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
|
|||||||
dsc->user_data = lv_mem_alloc(sizeof(lv_img_decoder_built_in_data_t));
|
dsc->user_data = lv_mem_alloc(sizeof(lv_img_decoder_built_in_data_t));
|
||||||
if(dsc->user_data == NULL) {
|
if(dsc->user_data == NULL) {
|
||||||
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
|
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
|
||||||
lv_mem_assert(dsc->user_data);
|
LV_ASSERT_MEM(dsc->user_data);
|
||||||
}
|
}
|
||||||
memset(dsc->user_data, 0, sizeof(lv_img_decoder_built_in_data_t));
|
memset(dsc->user_data, 0, sizeof(lv_img_decoder_built_in_data_t));
|
||||||
}
|
}
|
||||||
@@ -380,7 +381,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
|
|||||||
if(user_data->palette == NULL || user_data->opa == NULL) {
|
if(user_data->palette == NULL || user_data->opa == NULL) {
|
||||||
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
|
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
|
||||||
#if LV_USE_FILESYSTEM
|
#if LV_USE_FILESYSTEM
|
||||||
lv_mem_assert(user_data->f);
|
LV_ASSERT_MEM(user_data->f);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*********************/
|
*********************/
|
||||||
#include "lv_font.h"
|
#include "lv_font.h"
|
||||||
#include "lv_font_fmt_txt.h"
|
#include "lv_font_fmt_txt.h"
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
#include "../lv_misc/lv_types.h"
|
#include "../lv_misc/lv_types.h"
|
||||||
#include "../lv_misc/lv_log.h"
|
#include "../lv_misc/lv_log.h"
|
||||||
@@ -100,7 +101,7 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
|
|||||||
|
|
||||||
if(lv_mem_get_size(buf) < buf_size) {
|
if(lv_mem_get_size(buf) < buf_size) {
|
||||||
buf = lv_mem_realloc(buf, buf_size);
|
buf = lv_mem_realloc(buf, buf_size);
|
||||||
lv_mem_assert(buf);
|
LV_ASSERT_MEM(buf);
|
||||||
if(buf == NULL) return NULL;
|
if(buf == NULL) return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -11,57 +11,67 @@ extern "C" {
|
|||||||
#include "../../../lv_conf.h"
|
#include "../../../lv_conf.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* In the font converter use this list as range:
|
||||||
|
61441, 61448, 61451, 61452, 61452, 61457, 61459, 61461, 61465, 61468,
|
||||||
|
61473, 61478, 61479, 61480, 61502, 61508, 61512, 61515, 61516, 61517,
|
||||||
|
61521, 61522, 61523, 61524, 61543, 61544, 61553, 61556, 61559, 61560,
|
||||||
|
61561, 61563, 61587, 61589, 61636, 61637, 61639, 61671, 61674, 61683,
|
||||||
|
61724, 61732, 61787, 61931, 62016, 62017, 62018, 62019, 62020, 62099,
|
||||||
|
62189, 62810
|
||||||
|
*/
|
||||||
|
|
||||||
#define LV_SYMBOL_AUDIO "\xef\x80\x81"
|
#define LV_SYMBOL_AUDIO "\xef\x80\x81" /*61441, 0xF001*/
|
||||||
#define LV_SYMBOL_VIDEO "\xef\x80\x88"
|
#define LV_SYMBOL_VIDEO "\xef\x80\x88" /*61448, 0xF008*/
|
||||||
#define LV_SYMBOL_LIST "\xef\x80\x8b"
|
#define LV_SYMBOL_LIST "\xef\x80\x8b" /*61451, 0xF00B*/
|
||||||
#define LV_SYMBOL_OK "\xef\x80\x8c"
|
#define LV_SYMBOL_OK "\xef\x80\x8c" /*61452, 0xF00C*/
|
||||||
#define LV_SYMBOL_CLOSE "\xef\x80\x8d"
|
#define LV_SYMBOL_CLOSE "\xef\x80\x8d" /*61453, 0xF00D*/
|
||||||
#define LV_SYMBOL_POWER "\xef\x80\x91"
|
#define LV_SYMBOL_POWER "\xef\x80\x91" /*61457, 0xF011*/
|
||||||
#define LV_SYMBOL_SETTINGS "\xef\x80\x93"
|
#define LV_SYMBOL_SETTINGS "\xef\x80\x93" /*61459, 0xF013*/
|
||||||
#define LV_SYMBOL_TRASH "\xef\x80\x94"
|
#define LV_SYMBOL_HOME "\xef\x80\x95" /*61461, 0xF015*/
|
||||||
#define LV_SYMBOL_HOME "\xef\x80\x95"
|
#define LV_SYMBOL_DOWNLOAD "\xef\x80\x99" /*61465, 0xF019*/
|
||||||
#define LV_SYMBOL_DOWNLOAD "\xef\x80\x99"
|
#define LV_SYMBOL_DRIVE "\xef\x80\x9c" /*61468, 0xF01C*/
|
||||||
#define LV_SYMBOL_DRIVE "\xef\x80\x9c"
|
#define LV_SYMBOL_REFRESH "\xef\x80\xa1" /*61473, 0xF021*/
|
||||||
#define LV_SYMBOL_REFRESH "\xef\x80\xa1"
|
#define LV_SYMBOL_MUTE "\xef\x80\xa6" /*61478, 0xF026*/
|
||||||
#define LV_SYMBOL_MUTE "\xef\x80\xa6"
|
#define LV_SYMBOL_VOLUME_MID "\xef\x80\xa7" /*61479, 0xF027*/
|
||||||
#define LV_SYMBOL_VOLUME_MID "\xef\x80\xa7"
|
#define LV_SYMBOL_VOLUME_MAX "\xef\x80\xa8" /*61480, 0xF028*/
|
||||||
#define LV_SYMBOL_VOLUME_MAX "\xef\x80\xa8"
|
#define LV_SYMBOL_IMAGE "\xef\x80\xbe" /*61502, 0xF03E*/
|
||||||
#define LV_SYMBOL_IMAGE "\xef\x80\xbe"
|
#define LV_SYMBOL_EDIT "\xef\x81\x84" /*61508, 0xF044*/
|
||||||
#define LV_SYMBOL_EDIT "\xef\x81\x80"
|
#define LV_SYMBOL_PREV "\xef\x81\x88" /*61512, 0xF048*/
|
||||||
#define LV_SYMBOL_PREV "\xef\x81\x88"
|
#define LV_SYMBOL_PLAY "\xef\x81\x8b" /*61515, 0xF04B*/
|
||||||
#define LV_SYMBOL_PLAY "\xef\x81\x8b"
|
#define LV_SYMBOL_PAUSE "\xef\x81\x8c" /*61516, 0xF04C*/
|
||||||
#define LV_SYMBOL_PAUSE "\xef\x81\x8c"
|
#define LV_SYMBOL_STOP "\xef\x81\x8d" /*61517, 0xF04D*/
|
||||||
#define LV_SYMBOL_STOP "\xef\x81\x8d"
|
#define LV_SYMBOL_NEXT "\xef\x81\x91" /*61521, 0xF051*/
|
||||||
#define LV_SYMBOL_NEXT "\xef\x81\x91"
|
#define LV_SYMBOL_EJECT "\xef\x81\x92" /*61522, 0xF052*/
|
||||||
#define LV_SYMBOL_EJECT "\xef\x81\x92"
|
#define LV_SYMBOL_LEFT "\xef\x81\x93" /*61523, 0xF053*/
|
||||||
#define LV_SYMBOL_LEFT "\xef\x81\x93"
|
#define LV_SYMBOL_RIGHT "\xef\x81\x94" /*61524, 0xF054*/
|
||||||
#define LV_SYMBOL_RIGHT "\xef\x81\x94"
|
#define LV_SYMBOL_PLUS "\xef\x81\xa7" /*61543, 0xF067*/
|
||||||
#define LV_SYMBOL_PLUS "\xef\x81\xa7"
|
#define LV_SYMBOL_MINUS "\xef\x81\xa8" /*61544, 0xF068*/
|
||||||
#define LV_SYMBOL_MINUS "\xef\x81\xa8"
|
#define LV_SYMBOL_WARNING "\xef\x81\xb1" /*61553, 0xF071*/
|
||||||
#define LV_SYMBOL_WARNING "\xef\x81\xb1"
|
#define LV_SYMBOL_SHUFFLE "\xef\x81\xb4" /*61556, 0xF074*/
|
||||||
#define LV_SYMBOL_SHUFFLE "\xef\x81\xb4"
|
#define LV_SYMBOL_UP "\xef\x81\xb7" /*61559, 0xF077*/
|
||||||
#define LV_SYMBOL_UP "\xef\x81\xb7"
|
#define LV_SYMBOL_DOWN "\xef\x81\xb8" /*61560, 0xF078*/
|
||||||
#define LV_SYMBOL_DOWN "\xef\x81\xb8"
|
#define LV_SYMBOL_LOOP "\xef\x81\xb9" /*61561, 0xF079*/
|
||||||
#define LV_SYMBOL_LOOP "\xef\x81\xb9"
|
#define LV_SYMBOL_DIRECTORY "\xef\x81\xbb" /*61563, 0xF07B*/
|
||||||
#define LV_SYMBOL_DIRECTORY "\xef\x81\xbb"
|
#define LV_SYMBOL_UPLOAD "\xef\x82\x93" /*61587, 0xF093*/
|
||||||
#define LV_SYMBOL_UPLOAD "\xef\x82\x93"
|
#define LV_SYMBOL_CALL "\xef\x82\x95" /*61589, 0xF095*/
|
||||||
#define LV_SYMBOL_CALL "\xef\x82\x95"
|
#define LV_SYMBOL_CUT "\xef\x83\x84" /*61636, 0xF0C4*/
|
||||||
#define LV_SYMBOL_CUT "\xef\x83\x84"
|
#define LV_SYMBOL_COPY "\xef\x83\x85" /*61637, 0xF0C5*/
|
||||||
#define LV_SYMBOL_COPY "\xef\x83\x85"
|
#define LV_SYMBOL_SAVE "\xef\x83\x87" /*61639, 0xF0C7*/
|
||||||
#define LV_SYMBOL_SAVE "\xef\x83\x87"
|
#define LV_SYMBOL_CHARGE "\xef\x83\xa7" /*61671, 0xF0E7*/
|
||||||
#define LV_SYMBOL_CHARGE "\xef\x83\xa7"
|
#define LV_SYMBOL_PASTE "\xef\x83\xAA" /*61674, 0xF0EA*/
|
||||||
#define LV_SYMBOL_BELL "\xef\x83\xb3"
|
#define LV_SYMBOL_BELL "\xef\x83\xb3" /*61683, 0xF0F3*/
|
||||||
#define LV_SYMBOL_KEYBOARD "\xef\x84\x9c"
|
#define LV_SYMBOL_KEYBOARD "\xef\x84\x9c" /*61724, 0xF11C*/
|
||||||
#define LV_SYMBOL_GPS "\xef\x84\xa4"
|
#define LV_SYMBOL_GPS "\xef\x84\xa4" /*61732, 0xF124*/
|
||||||
#define LV_SYMBOL_FILE "\xef\x85\x9b"
|
#define LV_SYMBOL_FILE "\xef\x85\x9b" /*61787, 0xF158*/
|
||||||
#define LV_SYMBOL_WIFI "\xef\x87\xab"
|
#define LV_SYMBOL_WIFI "\xef\x87\xab" /*61931, 0xF1EB*/
|
||||||
#define LV_SYMBOL_BATTERY_FULL "\xef\x89\x80"
|
#define LV_SYMBOL_BATTERY_FULL "\xef\x89\x80" /*62016, 0xF240*/
|
||||||
#define LV_SYMBOL_BATTERY_3 "\xef\x89\x81"
|
#define LV_SYMBOL_BATTERY_3 "\xef\x89\x81" /*62017, 0xF241*/
|
||||||
#define LV_SYMBOL_BATTERY_2 "\xef\x89\x82"
|
#define LV_SYMBOL_BATTERY_2 "\xef\x89\x82" /*62018, 0xF242*/
|
||||||
#define LV_SYMBOL_BATTERY_1 "\xef\x89\x83"
|
#define LV_SYMBOL_BATTERY_1 "\xef\x89\x83" /*62019, 0xF243*/
|
||||||
#define LV_SYMBOL_BATTERY_EMPTY "\xef\x89\x84"
|
#define LV_SYMBOL_BATTERY_EMPTY "\xef\x89\x84" /*62020, 0xF244*/
|
||||||
#define LV_SYMBOL_BLUETOOTH "\xef\x8a\x93"
|
#define LV_SYMBOL_BLUETOOTH "\xef\x8a\x93" /*62099, 0xF293*/
|
||||||
|
#define LV_SYMBOL_TRASH "\xef\x8B\xAD" /*62189, 0xF2ED*/
|
||||||
|
#define LV_SYMBOL_BACKSPACE "\xef\x95\x9A" /*62810, 0xF55A*/
|
||||||
|
|
||||||
/** Invalid symbol at (U+F8FF). If written before a string then `lv_img` will show it as a label*/
|
/** Invalid symbol at (U+F8FF). If written before a string then `lv_img` will show it as a label*/
|
||||||
#define LV_SYMBOL_DUMMY "\xEF\xA3\xBF"
|
#define LV_SYMBOL_DUMMY "\xEF\xA3\xBF"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "lv_hal.h"
|
#include "lv_hal.h"
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_misc/lv_mem.h"
|
#include "../lv_misc/lv_mem.h"
|
||||||
#include "../lv_core/lv_obj.h"
|
#include "../lv_core/lv_obj.h"
|
||||||
#include "../lv_core/lv_refr.h"
|
#include "../lv_core/lv_refr.h"
|
||||||
@@ -118,7 +119,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
|
|||||||
{
|
{
|
||||||
lv_disp_t * disp = lv_ll_ins_head(&LV_GC_ROOT(_lv_disp_ll));
|
lv_disp_t * disp = lv_ll_ins_head(&LV_GC_ROOT(_lv_disp_ll));
|
||||||
if(!disp) {
|
if(!disp) {
|
||||||
lv_mem_assert(disp);
|
LV_ASSERT_MEM(disp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +148,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
|
|||||||
|
|
||||||
/*Create a refresh task*/
|
/*Create a refresh task*/
|
||||||
disp->refr_task = lv_task_create(lv_disp_refr_task, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, disp);
|
disp->refr_task = lv_task_create(lv_disp_refr_task, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, disp);
|
||||||
lv_mem_assert(disp->refr_task);
|
LV_ASSERT_MEM(disp->refr_task);
|
||||||
if(disp->refr_task == NULL) return NULL;
|
if(disp->refr_task == NULL) return NULL;
|
||||||
|
|
||||||
lv_task_ready(disp->refr_task); /*Be sure the screen will be refreshed immediately on start up*/
|
lv_task_ready(disp->refr_task); /*Be sure the screen will be refreshed immediately on start up*/
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* INCLUDES
|
* INCLUDES
|
||||||
*********************/
|
*********************/
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_hal/lv_hal_indev.h"
|
#include "../lv_hal/lv_hal_indev.h"
|
||||||
#include "../lv_core/lv_indev.h"
|
#include "../lv_core/lv_indev.h"
|
||||||
#include "../lv_misc/lv_mem.h"
|
#include "../lv_misc/lv_mem.h"
|
||||||
@@ -77,7 +78,7 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver)
|
|||||||
|
|
||||||
lv_indev_t * indev = lv_ll_ins_head(&LV_GC_ROOT(_lv_indev_ll));
|
lv_indev_t * indev = lv_ll_ins_head(&LV_GC_ROOT(_lv_indev_ll));
|
||||||
if(!indev) {
|
if(!indev) {
|
||||||
lv_mem_assert(indev);
|
LV_ASSERT_MEM(indev);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_hal/lv_hal_tick.h"
|
#include "../lv_hal/lv_hal_tick.h"
|
||||||
#include "lv_task.h"
|
#include "lv_task.h"
|
||||||
#include "lv_math.h"
|
#include "lv_math.h"
|
||||||
@@ -89,7 +90,7 @@ void lv_anim_create(lv_anim_t * a)
|
|||||||
|
|
||||||
/*Add the new animation to the animation linked list*/
|
/*Add the new animation to the animation linked list*/
|
||||||
lv_anim_t * new_anim = lv_ll_ins_head(&LV_GC_ROOT(_lv_anim_ll));
|
lv_anim_t * new_anim = lv_ll_ins_head(&LV_GC_ROOT(_lv_anim_ll));
|
||||||
lv_mem_assert(new_anim);
|
LV_ASSERT_MEM(new_anim);
|
||||||
if(new_anim == NULL) return;
|
if(new_anim == NULL) return;
|
||||||
|
|
||||||
/*Initialize the animation descriptor*/
|
/*Initialize the animation descriptor*/
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "lv_fs.h"
|
#include "lv_fs.h"
|
||||||
#if LV_USE_FILESYSTEM
|
#if LV_USE_FILESYSTEM
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "lv_ll.h"
|
#include "lv_ll.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "lv_gc.h"
|
#include "lv_gc.h"
|
||||||
@@ -107,7 +108,7 @@ lv_fs_res_t lv_fs_open(lv_fs_file_t * file_p, const char * path, lv_fs_mode_t mo
|
|||||||
}
|
}
|
||||||
|
|
||||||
file_p->file_d = lv_mem_alloc(file_p->drv->file_size);
|
file_p->file_d = lv_mem_alloc(file_p->drv->file_size);
|
||||||
lv_mem_assert(file_p->file_d);
|
LV_ASSERT_MEM(file_p->file_d);
|
||||||
if(file_p->file_d == NULL) {
|
if(file_p->file_d == NULL) {
|
||||||
file_p->drv = NULL;
|
file_p->drv = NULL;
|
||||||
return LV_FS_RES_OUT_OF_MEM; /* Out of memory */
|
return LV_FS_RES_OUT_OF_MEM; /* Out of memory */
|
||||||
@@ -367,7 +368,7 @@ lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t * rddir_p, const char * path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rddir_p->dir_d = lv_mem_alloc(rddir_p->drv->rddir_size);
|
rddir_p->dir_d = lv_mem_alloc(rddir_p->drv->rddir_size);
|
||||||
lv_mem_assert(rddir_p->dir_d);
|
LV_ASSERT_MEM(rddir_p->dir_d);
|
||||||
if(rddir_p->dir_d == NULL) {
|
if(rddir_p->dir_d == NULL) {
|
||||||
rddir_p->dir_d = NULL;
|
rddir_p->dir_d = NULL;
|
||||||
return LV_FS_RES_OUT_OF_MEM; /* Out of memory */
|
return LV_FS_RES_OUT_OF_MEM; /* Out of memory */
|
||||||
@@ -486,7 +487,7 @@ void lv_fs_drv_register(lv_fs_drv_t * drv_p)
|
|||||||
/*Save the new driver*/
|
/*Save the new driver*/
|
||||||
lv_fs_drv_t * new_drv;
|
lv_fs_drv_t * new_drv;
|
||||||
new_drv = lv_ll_ins_head(&LV_GC_ROOT(_lv_drv_ll));
|
new_drv = lv_ll_ins_head(&LV_GC_ROOT(_lv_drv_ll));
|
||||||
lv_mem_assert(new_drv);
|
LV_ASSERT_MEM(new_drv);
|
||||||
if(new_drv == NULL) return;
|
if(new_drv == NULL) return;
|
||||||
|
|
||||||
memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t));
|
memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t));
|
||||||
|
|||||||
@@ -110,27 +110,6 @@ uint32_t lv_mem_get_size(const void * data);
|
|||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
/**
|
|
||||||
* Halt on NULL pointer
|
|
||||||
* p pointer to a memory
|
|
||||||
*/
|
|
||||||
#if LV_USE_LOG == 0
|
|
||||||
#define lv_mem_assert(p) \
|
|
||||||
{ \
|
|
||||||
if(p == NULL) \
|
|
||||||
while(1) \
|
|
||||||
; \
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define lv_mem_assert(p) \
|
|
||||||
{ \
|
|
||||||
if(p == NULL) { \
|
|
||||||
LV_LOG_ERROR("Out of memory!"); \
|
|
||||||
while(1) \
|
|
||||||
; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*********************/
|
*********************/
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "lv_task.h"
|
#include "lv_task.h"
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_hal/lv_hal_tick.h"
|
#include "../lv_hal/lv_hal_tick.h"
|
||||||
#include "lv_gc.h"
|
#include "lv_gc.h"
|
||||||
|
|
||||||
@@ -173,7 +174,7 @@ lv_task_t * lv_task_create_basic(void)
|
|||||||
/*It's the first task*/
|
/*It's the first task*/
|
||||||
if(NULL == tmp) {
|
if(NULL == tmp) {
|
||||||
new_task = lv_ll_ins_head(&LV_GC_ROOT(_lv_task_ll));
|
new_task = lv_ll_ins_head(&LV_GC_ROOT(_lv_task_ll));
|
||||||
lv_mem_assert(new_task);
|
LV_ASSERT_MEM(new_task);
|
||||||
if(new_task == NULL) return NULL;
|
if(new_task == NULL) return NULL;
|
||||||
}
|
}
|
||||||
/*Insert the new task to proper place according to its priority*/
|
/*Insert the new task to proper place according to its priority*/
|
||||||
@@ -181,7 +182,7 @@ lv_task_t * lv_task_create_basic(void)
|
|||||||
do {
|
do {
|
||||||
if(tmp->prio <= DEF_PRIO) {
|
if(tmp->prio <= DEF_PRIO) {
|
||||||
new_task = lv_ll_ins_prev(&LV_GC_ROOT(_lv_task_ll), tmp);
|
new_task = lv_ll_ins_prev(&LV_GC_ROOT(_lv_task_ll), tmp);
|
||||||
lv_mem_assert(new_task);
|
LV_ASSERT_MEM(new_task);
|
||||||
if(new_task == NULL) return NULL;
|
if(new_task == NULL) return NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -191,7 +192,7 @@ lv_task_t * lv_task_create_basic(void)
|
|||||||
/*Only too high priority tasks were found. Add the task to the end*/
|
/*Only too high priority tasks were found. Add the task to the end*/
|
||||||
if(tmp == NULL) {
|
if(tmp == NULL) {
|
||||||
new_task = lv_ll_ins_tail(&LV_GC_ROOT(_lv_task_ll));
|
new_task = lv_ll_ins_tail(&LV_GC_ROOT(_lv_task_ll));
|
||||||
lv_mem_assert(new_task);
|
LV_ASSERT_MEM(new_task);
|
||||||
if(new_task == NULL) return NULL;
|
if(new_task == NULL) return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,7 +224,7 @@ lv_task_t * lv_task_create_basic(void)
|
|||||||
lv_task_t * lv_task_create(lv_task_cb_t task_cb, uint32_t period, lv_task_prio_t prio, void * user_data)
|
lv_task_t * lv_task_create(lv_task_cb_t task_cb, uint32_t period, lv_task_prio_t prio, void * user_data)
|
||||||
{
|
{
|
||||||
lv_task_t * new_task = lv_task_create_basic();
|
lv_task_t * new_task = lv_task_create_basic();
|
||||||
lv_mem_assert(new_task);
|
LV_ASSERT_MEM(new_task);
|
||||||
if(new_task == NULL) return NULL;
|
if(new_task == NULL) return NULL;
|
||||||
|
|
||||||
lv_task_set_cb(new_task, task_cb);
|
lv_task_set_cb(new_task, task_cb);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "lv_arc.h"
|
#include "lv_arc.h"
|
||||||
#if LV_USE_ARC != 0
|
#if LV_USE_ARC != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_misc/lv_math.h"
|
#include "../lv_misc/lv_math.h"
|
||||||
#include "../lv_draw/lv_draw_arc.h"
|
#include "../lv_draw/lv_draw_arc.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
@@ -16,6 +17,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_arc"
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -54,12 +56,12 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor of arc*/
|
/*Create the ancestor of arc*/
|
||||||
lv_obj_t * new_arc = lv_obj_create(par, copy);
|
lv_obj_t * new_arc = lv_obj_create(par, copy);
|
||||||
lv_mem_assert(new_arc);
|
LV_ASSERT_MEM(new_arc);
|
||||||
if(new_arc == NULL) return NULL;
|
if(new_arc == NULL) return NULL;
|
||||||
|
|
||||||
/*Allocate the arc type specific extended data*/
|
/*Allocate the arc type specific extended data*/
|
||||||
lv_arc_ext_t * ext = lv_obj_allocate_ext_attr(new_arc, sizeof(lv_arc_ext_t));
|
lv_arc_ext_t * ext = lv_obj_allocate_ext_attr(new_arc, sizeof(lv_arc_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_arc);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_arc);
|
||||||
@@ -119,6 +121,8 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_arc_set_angles(lv_obj_t * arc, uint16_t start, uint16_t end)
|
void lv_arc_set_angles(lv_obj_t * arc, uint16_t start, uint16_t end)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
|
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
|
||||||
|
|
||||||
if(start > 360) start = 360;
|
if(start > 360) start = 360;
|
||||||
@@ -138,6 +142,8 @@ void lv_arc_set_angles(lv_obj_t * arc, uint16_t start, uint16_t end)
|
|||||||
* */
|
* */
|
||||||
void lv_arc_set_style(lv_obj_t * arc, lv_arc_style_t type, const lv_style_t * style)
|
void lv_arc_set_style(lv_obj_t * arc, lv_arc_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_ARC_STYLE_MAIN: lv_obj_set_style(arc, style); break;
|
case LV_ARC_STYLE_MAIN: lv_obj_set_style(arc, style); break;
|
||||||
}
|
}
|
||||||
@@ -154,6 +160,8 @@ void lv_arc_set_style(lv_obj_t * arc, lv_arc_style_t type, const lv_style_t * st
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_arc_get_angle_start(lv_obj_t * arc)
|
uint16_t lv_arc_get_angle_start(lv_obj_t * arc)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
|
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
|
||||||
|
|
||||||
return ext->angle_start;
|
return ext->angle_start;
|
||||||
@@ -166,6 +174,8 @@ uint16_t lv_arc_get_angle_start(lv_obj_t * arc)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_arc_get_angle_end(lv_obj_t * arc)
|
uint16_t lv_arc_get_angle_end(lv_obj_t * arc)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
|
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
|
||||||
|
|
||||||
return ext->angle_end;
|
return ext->angle_end;
|
||||||
@@ -179,6 +189,8 @@ uint16_t lv_arc_get_angle_end(lv_obj_t * arc)
|
|||||||
* */
|
* */
|
||||||
const lv_style_t * lv_arc_get_style(const lv_obj_t * arc, lv_arc_style_t type)
|
const lv_style_t * lv_arc_get_style(const lv_obj_t * arc, lv_arc_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -281,15 +293,10 @@ static lv_res_t lv_arc_signal(lv_obj_t * arc, lv_signal_t sign, void * param)
|
|||||||
res = ancestor_signal(arc, sign, param);
|
res = ancestor_signal(arc, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_arc";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "lv_bar.h"
|
#include "lv_bar.h"
|
||||||
#if LV_USE_BAR != 0
|
#if LV_USE_BAR != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
#include "../lv_misc/lv_anim.h"
|
#include "../lv_misc/lv_anim.h"
|
||||||
@@ -20,6 +21,8 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_bar"
|
||||||
|
|
||||||
#define LV_BAR_SIZE_MIN 4 /*hor. pad and ver. pad cannot make the indicator smaller then this [px]*/
|
#define LV_BAR_SIZE_MIN 4 /*hor. pad and ver. pad cannot make the indicator smaller then this [px]*/
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
@@ -66,7 +69,7 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor basic object*/
|
/*Create the ancestor basic object*/
|
||||||
lv_obj_t * new_bar = lv_obj_create(par, copy);
|
lv_obj_t * new_bar = lv_obj_create(par, copy);
|
||||||
lv_mem_assert(new_bar);
|
LV_ASSERT_MEM(new_bar);
|
||||||
if(new_bar == NULL) return NULL;
|
if(new_bar == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_bar);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_bar);
|
||||||
@@ -74,7 +77,7 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Allocate the object type specific extended data*/
|
/*Allocate the object type specific extended data*/
|
||||||
lv_bar_ext_t * ext = lv_obj_allocate_ext_attr(new_bar, sizeof(lv_bar_ext_t));
|
lv_bar_ext_t * ext = lv_obj_allocate_ext_attr(new_bar, sizeof(lv_bar_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
ext->min_value = 0;
|
ext->min_value = 0;
|
||||||
@@ -135,6 +138,8 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_bar_set_value(lv_obj_t * bar, int16_t value, lv_anim_enable_t anim)
|
void lv_bar_set_value(lv_obj_t * bar, int16_t value, lv_anim_enable_t anim)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(bar, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION == 0
|
#if LV_USE_ANIMATION == 0
|
||||||
anim = false;
|
anim = false;
|
||||||
#endif
|
#endif
|
||||||
@@ -190,6 +195,8 @@ void lv_bar_set_value(lv_obj_t * bar, int16_t value, lv_anim_enable_t anim)
|
|||||||
*/
|
*/
|
||||||
void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max)
|
void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(bar, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||||
if(ext->min_value == min && ext->max_value == max) return;
|
if(ext->min_value == min && ext->max_value == max) return;
|
||||||
|
|
||||||
@@ -214,6 +221,8 @@ void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max)
|
|||||||
*/
|
*/
|
||||||
void lv_bar_set_sym(lv_obj_t * bar, bool en)
|
void lv_bar_set_sym(lv_obj_t * bar, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(bar, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||||
ext->sym = en ? 1 : 0;
|
ext->sym = en ? 1 : 0;
|
||||||
}
|
}
|
||||||
@@ -225,6 +234,8 @@ void lv_bar_set_sym(lv_obj_t * bar, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_bar_set_anim_time(lv_obj_t * bar, uint16_t anim_time)
|
void lv_bar_set_anim_time(lv_obj_t * bar, uint16_t anim_time)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(bar, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||||
ext->anim_time = anim_time;
|
ext->anim_time = anim_time;
|
||||||
@@ -242,6 +253,8 @@ void lv_bar_set_anim_time(lv_obj_t * bar, uint16_t anim_time)
|
|||||||
*/
|
*/
|
||||||
void lv_bar_set_style(lv_obj_t * bar, lv_bar_style_t type, const lv_style_t * style)
|
void lv_bar_set_style(lv_obj_t * bar, lv_bar_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(bar, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -264,6 +277,8 @@ void lv_bar_set_style(lv_obj_t * bar, lv_bar_style_t type, const lv_style_t * st
|
|||||||
*/
|
*/
|
||||||
int16_t lv_bar_get_value(const lv_obj_t * bar)
|
int16_t lv_bar_get_value(const lv_obj_t * bar)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(bar, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||||
/*If animated tell that it's already at the end value*/
|
/*If animated tell that it's already at the end value*/
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
@@ -280,6 +295,8 @@ int16_t lv_bar_get_value(const lv_obj_t * bar)
|
|||||||
*/
|
*/
|
||||||
int16_t lv_bar_get_min_value(const lv_obj_t * bar)
|
int16_t lv_bar_get_min_value(const lv_obj_t * bar)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(bar, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||||
return ext->min_value;
|
return ext->min_value;
|
||||||
}
|
}
|
||||||
@@ -291,6 +308,8 @@ int16_t lv_bar_get_min_value(const lv_obj_t * bar)
|
|||||||
*/
|
*/
|
||||||
int16_t lv_bar_get_max_value(const lv_obj_t * bar)
|
int16_t lv_bar_get_max_value(const lv_obj_t * bar)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(bar, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||||
return ext->max_value;
|
return ext->max_value;
|
||||||
}
|
}
|
||||||
@@ -302,6 +321,8 @@ int16_t lv_bar_get_max_value(const lv_obj_t * bar)
|
|||||||
*/
|
*/
|
||||||
bool lv_bar_get_sym(lv_obj_t * bar)
|
bool lv_bar_get_sym(lv_obj_t * bar)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(bar, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||||
return ext->sym ? true : false;
|
return ext->sym ? true : false;
|
||||||
}
|
}
|
||||||
@@ -313,6 +334,8 @@ bool lv_bar_get_sym(lv_obj_t * bar)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_bar_get_anim_time(lv_obj_t * bar)
|
uint16_t lv_bar_get_anim_time(lv_obj_t * bar)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(bar, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||||
return ext->anim_time;
|
return ext->anim_time;
|
||||||
@@ -330,6 +353,8 @@ uint16_t lv_bar_get_anim_time(lv_obj_t * bar)
|
|||||||
*/
|
*/
|
||||||
const lv_style_t * lv_bar_get_style(const lv_obj_t * bar, lv_bar_style_t type)
|
const lv_style_t * lv_bar_get_style(const lv_obj_t * bar, lv_bar_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(bar, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||||
|
|
||||||
@@ -586,6 +611,7 @@ static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param)
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(bar, sign, param);
|
res = ancestor_signal(bar, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
||||||
const lv_style_t * style_indic = lv_bar_get_style(bar, LV_BAR_STYLE_INDIC);
|
const lv_style_t * style_indic = lv_bar_get_style(bar, LV_BAR_STYLE_INDIC);
|
||||||
@@ -601,13 +627,6 @@ static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param)
|
|||||||
bar->ext_draw_pad = LV_MATH_MAX(bar->ext_draw_pad, indic_size);
|
bar->ext_draw_pad = LV_MATH_MAX(bar->ext_draw_pad, indic_size);
|
||||||
|
|
||||||
if(style_indic->body.shadow.width > bar->ext_draw_pad) bar->ext_draw_pad = style_indic->body.shadow.width;
|
if(style_indic->body.shadow.width > bar->ext_draw_pad) bar->ext_draw_pad = style_indic->body.shadow.width;
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_bar";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../lv_core/lv_group.h"
|
#include "../lv_core/lv_group.h"
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
#include "../lv_misc/lv_area.h"
|
#include "../lv_misc/lv_area.h"
|
||||||
@@ -21,6 +22,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_btn"
|
||||||
#define LV_BTN_INK_VALUE_MAX 256
|
#define LV_BTN_INK_VALUE_MAX 256
|
||||||
#define LV_BTN_INK_VALUE_MAX_SHIFT 8
|
#define LV_BTN_INK_VALUE_MAX_SHIFT 8
|
||||||
|
|
||||||
@@ -76,7 +78,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
lv_obj_t * new_btn;
|
lv_obj_t * new_btn;
|
||||||
|
|
||||||
new_btn = lv_cont_create(par, copy);
|
new_btn = lv_cont_create(par, copy);
|
||||||
lv_mem_assert(new_btn);
|
LV_ASSERT_MEM(new_btn);
|
||||||
if(new_btn == NULL) return NULL;
|
if(new_btn == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_btn);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_btn);
|
||||||
@@ -84,7 +86,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Allocate the extended data*/
|
/*Allocate the extended data*/
|
||||||
lv_btn_ext_t * ext = lv_obj_allocate_ext_attr(new_btn, sizeof(lv_btn_ext_t));
|
lv_btn_ext_t * ext = lv_obj_allocate_ext_attr(new_btn, sizeof(lv_btn_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
ext->state = LV_BTN_STATE_REL;
|
ext->state = LV_BTN_STATE_REL;
|
||||||
@@ -158,6 +160,8 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_btn_set_toggle(lv_obj_t * btn, bool tgl)
|
void lv_btn_set_toggle(lv_obj_t * btn, bool tgl)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||||
|
|
||||||
ext->toggle = tgl != false ? 1 : 0;
|
ext->toggle = tgl != false ? 1 : 0;
|
||||||
@@ -170,6 +174,8 @@ void lv_btn_set_toggle(lv_obj_t * btn, bool tgl)
|
|||||||
*/
|
*/
|
||||||
void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state)
|
void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||||
if(ext->state != state) {
|
if(ext->state != state) {
|
||||||
ext->state = state;
|
ext->state = state;
|
||||||
@@ -183,6 +189,8 @@ void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state)
|
|||||||
*/
|
*/
|
||||||
void lv_btn_toggle(lv_obj_t * btn)
|
void lv_btn_toggle(lv_obj_t * btn)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||||
switch(ext->state) {
|
switch(ext->state) {
|
||||||
case LV_BTN_STATE_REL: lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL); break;
|
case LV_BTN_STATE_REL: lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL); break;
|
||||||
@@ -200,6 +208,8 @@ void lv_btn_toggle(lv_obj_t * btn)
|
|||||||
*/
|
*/
|
||||||
void lv_btn_set_ink_in_time(lv_obj_t * btn, uint16_t time)
|
void lv_btn_set_ink_in_time(lv_obj_t * btn, uint16_t time)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
|
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
|
||||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||||
ext->ink_in_time = time;
|
ext->ink_in_time = time;
|
||||||
@@ -218,6 +228,8 @@ void lv_btn_set_ink_in_time(lv_obj_t * btn, uint16_t time)
|
|||||||
*/
|
*/
|
||||||
void lv_btn_set_ink_wait_time(lv_obj_t * btn, uint16_t time)
|
void lv_btn_set_ink_wait_time(lv_obj_t * btn, uint16_t time)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, LV_OBJX_NAME);
|
||||||
|
|
||||||
|
|
||||||
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
|
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
|
||||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||||
@@ -237,6 +249,8 @@ void lv_btn_set_ink_wait_time(lv_obj_t * btn, uint16_t time)
|
|||||||
*/
|
*/
|
||||||
void lv_btn_set_ink_out_time(lv_obj_t * btn, uint16_t time)
|
void lv_btn_set_ink_out_time(lv_obj_t * btn, uint16_t time)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
|
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
|
||||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||||
ext->ink_out_time = time;
|
ext->ink_out_time = time;
|
||||||
@@ -256,6 +270,8 @@ void lv_btn_set_ink_out_time(lv_obj_t * btn, uint16_t time)
|
|||||||
*/
|
*/
|
||||||
void lv_btn_set_style(lv_obj_t * btn, lv_btn_style_t type, const lv_style_t * style)
|
void lv_btn_set_style(lv_obj_t * btn, lv_btn_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -281,6 +297,8 @@ void lv_btn_set_style(lv_obj_t * btn, lv_btn_style_t type, const lv_style_t * st
|
|||||||
*/
|
*/
|
||||||
lv_btn_state_t lv_btn_get_state(const lv_obj_t * btn)
|
lv_btn_state_t lv_btn_get_state(const lv_obj_t * btn)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||||
return ext->state;
|
return ext->state;
|
||||||
}
|
}
|
||||||
@@ -292,6 +310,8 @@ lv_btn_state_t lv_btn_get_state(const lv_obj_t * btn)
|
|||||||
*/
|
*/
|
||||||
bool lv_btn_get_toggle(const lv_obj_t * btn)
|
bool lv_btn_get_toggle(const lv_obj_t * btn)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||||
|
|
||||||
return ext->toggle != 0 ? true : false;
|
return ext->toggle != 0 ? true : false;
|
||||||
@@ -304,6 +324,8 @@ bool lv_btn_get_toggle(const lv_obj_t * btn)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_btn_get_ink_in_time(const lv_obj_t * btn)
|
uint16_t lv_btn_get_ink_in_time(const lv_obj_t * btn)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
|
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
|
||||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||||
return ext->ink_in_time;
|
return ext->ink_in_time;
|
||||||
@@ -320,6 +342,8 @@ uint16_t lv_btn_get_ink_in_time(const lv_obj_t * btn)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_btn_get_ink_wait_time(const lv_obj_t * btn)
|
uint16_t lv_btn_get_ink_wait_time(const lv_obj_t * btn)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
|
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
|
||||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||||
return ext->ink_wait_time;
|
return ext->ink_wait_time;
|
||||||
@@ -335,6 +359,8 @@ uint16_t lv_btn_get_ink_wait_time(const lv_obj_t * btn)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_btn_get_ink_out_time(const lv_obj_t * btn)
|
uint16_t lv_btn_get_ink_out_time(const lv_obj_t * btn)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
|
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
|
||||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||||
return ext->ink_in_time;
|
return ext->ink_in_time;
|
||||||
@@ -352,6 +378,8 @@ uint16_t lv_btn_get_ink_out_time(const lv_obj_t * btn)
|
|||||||
*/
|
*/
|
||||||
const lv_style_t * lv_btn_get_style(const lv_obj_t * btn, lv_btn_style_t type)
|
const lv_style_t * lv_btn_get_style(const lv_obj_t * btn, lv_btn_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||||
lv_btn_state_t state = lv_btn_get_state(btn);
|
lv_btn_state_t state = lv_btn_get_state(btn);
|
||||||
@@ -483,6 +511,7 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(btn, sign, param);
|
res = ancestor_signal(btn, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||||
bool tgl = lv_btn_get_toggle(btn);
|
bool tgl = lv_btn_get_toggle(btn);
|
||||||
@@ -634,13 +663,6 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
|||||||
ink_obj = NULL;
|
ink_obj = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_btn";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "lv_btnm.h"
|
#include "lv_btnm.h"
|
||||||
#if LV_USE_BTNM != 0
|
#if LV_USE_BTNM != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_core/lv_group.h"
|
#include "../lv_core/lv_group.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
#include "../lv_core/lv_refr.h"
|
#include "../lv_core/lv_refr.h"
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_btnm"
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -70,14 +72,14 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor object*/
|
/*Create the ancestor object*/
|
||||||
lv_obj_t * new_btnm = lv_obj_create(par, copy);
|
lv_obj_t * new_btnm = lv_obj_create(par, copy);
|
||||||
lv_mem_assert(new_btnm);
|
LV_ASSERT_MEM(new_btnm);
|
||||||
if(new_btnm == NULL) return NULL;
|
if(new_btnm == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_btnm);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_btnm);
|
||||||
|
|
||||||
/*Allocate the object type specific extended data*/
|
/*Allocate the object type specific extended data*/
|
||||||
lv_btnm_ext_t * ext = lv_obj_allocate_ext_attr(new_btnm, sizeof(lv_btnm_ext_t));
|
lv_btnm_ext_t * ext = lv_obj_allocate_ext_attr(new_btnm, sizeof(lv_btnm_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
ext->btn_cnt = 0;
|
ext->btn_cnt = 0;
|
||||||
@@ -101,8 +103,8 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Init the new button matrix object*/
|
/*Init the new button matrix object*/
|
||||||
if(copy == NULL) {
|
if(copy == NULL) {
|
||||||
lv_obj_set_size(new_btnm, LV_DPI * 3, LV_DPI * 2);
|
|
||||||
lv_btnm_set_map(new_btnm, lv_btnm_def_map);
|
lv_btnm_set_map(new_btnm, lv_btnm_def_map);
|
||||||
|
lv_obj_set_size(new_btnm, LV_DPI * 3, LV_DPI * 2);
|
||||||
|
|
||||||
/*Set the default styles*/
|
/*Set the default styles*/
|
||||||
lv_theme_t * th = lv_theme_get_current();
|
lv_theme_t * th = lv_theme_get_current();
|
||||||
@@ -142,7 +144,8 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[])
|
void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[])
|
||||||
{
|
{
|
||||||
if(map == NULL) return;
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(map);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* lv_btnm_set_map is called on receipt of signals such as
|
* lv_btnm_set_map is called on receipt of signals such as
|
||||||
@@ -265,6 +268,8 @@ void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[])
|
|||||||
*/
|
*/
|
||||||
void lv_btnm_set_ctrl_map(const lv_obj_t * btnm, const lv_btnm_ctrl_t ctrl_map[])
|
void lv_btnm_set_ctrl_map(const lv_obj_t * btnm, const lv_btnm_ctrl_t ctrl_map[])
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
memcpy(ext->ctrl_bits, ctrl_map, sizeof(lv_btnm_ctrl_t) * ext->btn_cnt);
|
memcpy(ext->ctrl_bits, ctrl_map, sizeof(lv_btnm_ctrl_t) * ext->btn_cnt);
|
||||||
|
|
||||||
@@ -279,6 +284,8 @@ void lv_btnm_set_ctrl_map(const lv_obj_t * btnm, const lv_btnm_ctrl_t ctrl_map[]
|
|||||||
*/
|
*/
|
||||||
void lv_btnm_set_pressed(const lv_obj_t * btnm, uint16_t id)
|
void lv_btnm_set_pressed(const lv_obj_t * btnm, uint16_t id)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
|
|
||||||
if(id >= ext->btn_cnt && id != LV_BTNM_BTN_NONE) return;
|
if(id >= ext->btn_cnt && id != LV_BTNM_BTN_NONE) return;
|
||||||
@@ -297,6 +304,8 @@ void lv_btnm_set_pressed(const lv_obj_t * btnm, uint16_t id)
|
|||||||
*/
|
*/
|
||||||
void lv_btnm_set_style(lv_obj_t * btnm, lv_btnm_style_t type, const lv_style_t * style)
|
void lv_btnm_set_style(lv_obj_t * btnm, lv_btnm_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -331,6 +340,8 @@ void lv_btnm_set_style(lv_obj_t * btnm, lv_btnm_style_t type, const lv_style_t *
|
|||||||
*/
|
*/
|
||||||
void lv_btnm_set_recolor(const lv_obj_t * btnm, bool en)
|
void lv_btnm_set_recolor(const lv_obj_t * btnm, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
|
|
||||||
ext->recolor = en;
|
ext->recolor = en;
|
||||||
@@ -344,6 +355,8 @@ void lv_btnm_set_recolor(const lv_obj_t * btnm, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_btnm_set_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl)
|
void lv_btnm_set_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
|
|
||||||
if(btn_id >= ext->btn_cnt) return;
|
if(btn_id >= ext->btn_cnt) return;
|
||||||
@@ -359,6 +372,8 @@ void lv_btnm_set_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t
|
|||||||
*/
|
*/
|
||||||
void lv_btnm_clear_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl)
|
void lv_btnm_clear_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
|
|
||||||
if(btn_id >= ext->btn_cnt) return;
|
if(btn_id >= ext->btn_cnt) return;
|
||||||
@@ -374,6 +389,8 @@ void lv_btnm_clear_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl
|
|||||||
*/
|
*/
|
||||||
void lv_btnm_set_btn_ctrl_all(lv_obj_t * btnm, lv_btnm_ctrl_t ctrl)
|
void lv_btnm_set_btn_ctrl_all(lv_obj_t * btnm, lv_btnm_ctrl_t ctrl)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
for(i = 0; i < ext->btn_cnt; i++) {
|
for(i = 0; i < ext->btn_cnt; i++) {
|
||||||
@@ -389,6 +406,8 @@ void lv_btnm_set_btn_ctrl_all(lv_obj_t * btnm, lv_btnm_ctrl_t ctrl)
|
|||||||
*/
|
*/
|
||||||
void lv_btnm_clear_btn_ctrl_all(lv_obj_t * btnm, lv_btnm_ctrl_t ctrl)
|
void lv_btnm_clear_btn_ctrl_all(lv_obj_t * btnm, lv_btnm_ctrl_t ctrl)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
for(i = 0; i < ext->btn_cnt; i++) {
|
for(i = 0; i < ext->btn_cnt; i++) {
|
||||||
@@ -407,6 +426,8 @@ void lv_btnm_clear_btn_ctrl_all(lv_obj_t * btnm, lv_btnm_ctrl_t ctrl)
|
|||||||
*/
|
*/
|
||||||
void lv_btnm_set_btn_width(const lv_obj_t * btnm, uint16_t btn_id, uint8_t width)
|
void lv_btnm_set_btn_width(const lv_obj_t * btnm, uint16_t btn_id, uint8_t width)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
if(btn_id >= ext->btn_cnt) return;
|
if(btn_id >= ext->btn_cnt) return;
|
||||||
@@ -427,6 +448,8 @@ void lv_btnm_set_btn_width(const lv_obj_t * btnm, uint16_t btn_id, uint8_t width
|
|||||||
*/
|
*/
|
||||||
void lv_btnm_set_one_toggle(lv_obj_t * btnm, bool one_toggle)
|
void lv_btnm_set_one_toggle(lv_obj_t * btnm, bool one_toggle)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
ext->one_toggle = one_toggle;
|
ext->one_toggle = one_toggle;
|
||||||
|
|
||||||
@@ -445,6 +468,8 @@ void lv_btnm_set_one_toggle(lv_obj_t * btnm, bool one_toggle)
|
|||||||
*/
|
*/
|
||||||
const char ** lv_btnm_get_map_array(const lv_obj_t * btnm)
|
const char ** lv_btnm_get_map_array(const lv_obj_t * btnm)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
return ext->map_p;
|
return ext->map_p;
|
||||||
}
|
}
|
||||||
@@ -456,6 +481,8 @@ const char ** lv_btnm_get_map_array(const lv_obj_t * btnm)
|
|||||||
*/
|
*/
|
||||||
bool lv_btnm_get_recolor(const lv_obj_t * btnm)
|
bool lv_btnm_get_recolor(const lv_obj_t * btnm)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
|
|
||||||
return ext->recolor;
|
return ext->recolor;
|
||||||
@@ -469,6 +496,8 @@ bool lv_btnm_get_recolor(const lv_obj_t * btnm)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_btnm_get_active_btn(const lv_obj_t * btnm)
|
uint16_t lv_btnm_get_active_btn(const lv_obj_t * btnm)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
return ext->btn_id_act;
|
return ext->btn_id_act;
|
||||||
}
|
}
|
||||||
@@ -481,6 +510,8 @@ uint16_t lv_btnm_get_active_btn(const lv_obj_t * btnm)
|
|||||||
*/
|
*/
|
||||||
const char * lv_btnm_get_active_btn_text(const lv_obj_t * btnm)
|
const char * lv_btnm_get_active_btn_text(const lv_obj_t * btnm)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
if(ext->btn_id_act != LV_BTNM_BTN_NONE) {
|
if(ext->btn_id_act != LV_BTNM_BTN_NONE) {
|
||||||
return lv_btnm_get_btn_text(btnm, ext->btn_id_act);
|
return lv_btnm_get_btn_text(btnm, ext->btn_id_act);
|
||||||
@@ -497,6 +528,8 @@ const char * lv_btnm_get_active_btn_text(const lv_obj_t * btnm)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_btnm_get_pressed_btn(const lv_obj_t * btnm)
|
uint16_t lv_btnm_get_pressed_btn(const lv_obj_t * btnm)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
return ext->btn_id_pr;
|
return ext->btn_id_pr;
|
||||||
}
|
}
|
||||||
@@ -510,6 +543,8 @@ uint16_t lv_btnm_get_pressed_btn(const lv_obj_t * btnm)
|
|||||||
*/
|
*/
|
||||||
const char * lv_btnm_get_btn_text(const lv_obj_t * btnm, uint16_t btn_id)
|
const char * lv_btnm_get_btn_text(const lv_obj_t * btnm, uint16_t btn_id)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
if(btn_id > ext->btn_cnt) return NULL;
|
if(btn_id > ext->btn_cnt) return NULL;
|
||||||
|
|
||||||
@@ -539,6 +574,8 @@ const char * lv_btnm_get_btn_text(const lv_obj_t * btnm, uint16_t btn_id)
|
|||||||
*/
|
*/
|
||||||
bool lv_btnm_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl)
|
bool lv_btnm_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
if(btn_id >= ext->btn_cnt) return false;
|
if(btn_id >= ext->btn_cnt) return false;
|
||||||
|
|
||||||
@@ -553,6 +590,8 @@ bool lv_btnm_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl)
|
|||||||
*/
|
*/
|
||||||
const lv_style_t * lv_btnm_get_style(const lv_obj_t * btnm, lv_btnm_style_t type)
|
const lv_style_t * lv_btnm_get_style(const lv_obj_t * btnm, lv_btnm_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
|
|
||||||
@@ -576,6 +615,8 @@ const lv_style_t * lv_btnm_get_style(const lv_obj_t * btnm, lv_btnm_style_t type
|
|||||||
*/
|
*/
|
||||||
bool lv_btnm_get_one_toggle(const lv_obj_t * btnm)
|
bool lv_btnm_get_one_toggle(const lv_obj_t * btnm)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
|
|
||||||
return ext->one_toggle;
|
return ext->one_toggle;
|
||||||
@@ -712,6 +753,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(btnm, sign, param);
|
res = ancestor_signal(btnm, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
lv_point_t p;
|
lv_point_t p;
|
||||||
@@ -896,15 +938,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
|||||||
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
||||||
bool * editable = (bool *)param;
|
bool * editable = (bool *)param;
|
||||||
*editable = true;
|
*editable = true;
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_btnm";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -937,9 +971,9 @@ static void allocate_btn_areas_and_controls(const lv_obj_t * btnm, const char **
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext->button_areas = lv_mem_alloc(sizeof(lv_area_t) * btn_cnt);
|
ext->button_areas = lv_mem_alloc(sizeof(lv_area_t) * btn_cnt);
|
||||||
lv_mem_assert(ext->button_areas);
|
LV_ASSERT_MEM(ext->button_areas);
|
||||||
ext->ctrl_bits = lv_mem_alloc(sizeof(lv_btnm_ctrl_t) * btn_cnt);
|
ext->ctrl_bits = lv_mem_alloc(sizeof(lv_btnm_ctrl_t) * btn_cnt);
|
||||||
lv_mem_assert(ext->ctrl_bits);
|
LV_ASSERT_MEM(ext->ctrl_bits);
|
||||||
if(ext->button_areas == NULL || ext->ctrl_bits == NULL) btn_cnt = 0;
|
if(ext->button_areas == NULL || ext->ctrl_bits == NULL) btn_cnt = 0;
|
||||||
|
|
||||||
memset(ext->ctrl_bits, 0, sizeof(lv_btnm_ctrl_t) * btn_cnt);
|
memset(ext->ctrl_bits, 0, sizeof(lv_btnm_ctrl_t) * btn_cnt);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "lv_calendar.h"
|
#include "lv_calendar.h"
|
||||||
#if LV_USE_CALENDAR != 0
|
#if LV_USE_CALENDAR != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
#include "../lv_hal/lv_hal_indev.h"
|
#include "../lv_hal/lv_hal_indev.h"
|
||||||
#include "../lv_misc/lv_utils.h"
|
#include "../lv_misc/lv_utils.h"
|
||||||
@@ -19,6 +20,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_calendar"
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -77,12 +79,12 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor of calendar*/
|
/*Create the ancestor of calendar*/
|
||||||
lv_obj_t * new_calendar = lv_obj_create(par, copy);
|
lv_obj_t * new_calendar = lv_obj_create(par, copy);
|
||||||
lv_mem_assert(new_calendar);
|
LV_ASSERT_MEM(new_calendar);
|
||||||
if(new_calendar == NULL) return NULL;
|
if(new_calendar == NULL) return NULL;
|
||||||
|
|
||||||
/*Allocate the calendar type specific extended data*/
|
/*Allocate the calendar type specific extended data*/
|
||||||
lv_calendar_ext_t * ext = lv_obj_allocate_ext_attr(new_calendar, sizeof(lv_calendar_ext_t));
|
lv_calendar_ext_t * ext = lv_obj_allocate_ext_attr(new_calendar, sizeof(lv_calendar_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_calendar);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_calendar);
|
||||||
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_calendar);
|
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_calendar);
|
||||||
@@ -195,6 +197,9 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_calendar_set_today_date(lv_obj_t * calendar, lv_calendar_date_t * today)
|
void lv_calendar_set_today_date(lv_obj_t * calendar, lv_calendar_date_t * today)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(today);
|
||||||
|
|
||||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||||
ext->today.year = today->year;
|
ext->today.year = today->year;
|
||||||
ext->today.month = today->month;
|
ext->today.month = today->month;
|
||||||
@@ -211,6 +216,9 @@ void lv_calendar_set_today_date(lv_obj_t * calendar, lv_calendar_date_t * today)
|
|||||||
*/
|
*/
|
||||||
void lv_calendar_set_showed_date(lv_obj_t * calendar, lv_calendar_date_t * showed)
|
void lv_calendar_set_showed_date(lv_obj_t * calendar, lv_calendar_date_t * showed)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(showed);
|
||||||
|
|
||||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||||
ext->showed_date.year = showed->year;
|
ext->showed_date.year = showed->year;
|
||||||
ext->showed_date.month = showed->month;
|
ext->showed_date.month = showed->month;
|
||||||
@@ -228,6 +236,9 @@ void lv_calendar_set_showed_date(lv_obj_t * calendar, lv_calendar_date_t * showe
|
|||||||
*/
|
*/
|
||||||
void lv_calendar_set_highlighted_dates(lv_obj_t * calendar, lv_calendar_date_t * highlighted, uint16_t date_num)
|
void lv_calendar_set_highlighted_dates(lv_obj_t * calendar, lv_calendar_date_t * highlighted, uint16_t date_num)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(highlighted);
|
||||||
|
|
||||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||||
ext->highlighted_dates = highlighted;
|
ext->highlighted_dates = highlighted;
|
||||||
ext->highlighted_dates_num = date_num;
|
ext->highlighted_dates_num = date_num;
|
||||||
@@ -244,6 +255,9 @@ void lv_calendar_set_highlighted_dates(lv_obj_t * calendar, lv_calendar_date_t *
|
|||||||
*/
|
*/
|
||||||
void lv_calendar_set_day_names(lv_obj_t * calendar, const char ** day_names)
|
void lv_calendar_set_day_names(lv_obj_t * calendar, const char ** day_names)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(day_names);
|
||||||
|
|
||||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||||
ext->day_names = day_names;
|
ext->day_names = day_names;
|
||||||
lv_obj_invalidate(calendar);
|
lv_obj_invalidate(calendar);
|
||||||
@@ -252,14 +266,17 @@ void lv_calendar_set_day_names(lv_obj_t * calendar, const char ** day_names)
|
|||||||
/**
|
/**
|
||||||
* Set the name of the month
|
* Set the name of the month
|
||||||
* @param calendar pointer to a calendar object
|
* @param calendar pointer to a calendar object
|
||||||
* @param day_names pointer to an array with the names. E.g. `const char * days[12] = {"Jan", "Feb",
|
* @param month_names pointer to an array with the names. E.g. `const char * days[12] = {"Jan", "Feb",
|
||||||
* ...}` Only the pointer will be saved so this variable can't be local which will be destroyed
|
* ...}` Only the pointer will be saved so this variable can't be local which will be destroyed
|
||||||
* later.
|
* later.
|
||||||
*/
|
*/
|
||||||
void lv_calendar_set_month_names(lv_obj_t * calendar, const char ** day_names)
|
void lv_calendar_set_month_names(lv_obj_t * calendar, const char ** month_names)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(month_names);
|
||||||
|
|
||||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||||
ext->month_names = day_names;
|
ext->month_names = month_names;
|
||||||
lv_obj_invalidate(calendar);
|
lv_obj_invalidate(calendar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,6 +288,8 @@ void lv_calendar_set_month_names(lv_obj_t * calendar, const char ** day_names)
|
|||||||
* */
|
* */
|
||||||
void lv_calendar_set_style(lv_obj_t * calendar, lv_calendar_style_t type, const lv_style_t * style)
|
void lv_calendar_set_style(lv_obj_t * calendar, lv_calendar_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -298,6 +317,8 @@ void lv_calendar_set_style(lv_obj_t * calendar, lv_calendar_style_t type, const
|
|||||||
*/
|
*/
|
||||||
lv_calendar_date_t * lv_calendar_get_today_date(const lv_obj_t * calendar)
|
lv_calendar_date_t * lv_calendar_get_today_date(const lv_obj_t * calendar)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||||
return &ext->today;
|
return &ext->today;
|
||||||
}
|
}
|
||||||
@@ -309,6 +330,8 @@ lv_calendar_date_t * lv_calendar_get_today_date(const lv_obj_t * calendar)
|
|||||||
*/
|
*/
|
||||||
lv_calendar_date_t * lv_calendar_get_showed_date(const lv_obj_t * calendar)
|
lv_calendar_date_t * lv_calendar_get_showed_date(const lv_obj_t * calendar)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||||
return &ext->showed_date;
|
return &ext->showed_date;
|
||||||
}
|
}
|
||||||
@@ -321,6 +344,8 @@ lv_calendar_date_t * lv_calendar_get_showed_date(const lv_obj_t * calendar)
|
|||||||
*/
|
*/
|
||||||
lv_calendar_date_t * lv_calendar_get_pressed_date(const lv_obj_t * calendar)
|
lv_calendar_date_t * lv_calendar_get_pressed_date(const lv_obj_t * calendar)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||||
return ext->pressed_date.year != 0 ? &ext->pressed_date : NULL;
|
return ext->pressed_date.year != 0 ? &ext->pressed_date : NULL;
|
||||||
}
|
}
|
||||||
@@ -332,6 +357,8 @@ lv_calendar_date_t * lv_calendar_get_pressed_date(const lv_obj_t * calendar)
|
|||||||
*/
|
*/
|
||||||
lv_calendar_date_t * lv_calendar_get_highlighted_dates(const lv_obj_t * calendar)
|
lv_calendar_date_t * lv_calendar_get_highlighted_dates(const lv_obj_t * calendar)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||||
return ext->highlighted_dates;
|
return ext->highlighted_dates;
|
||||||
}
|
}
|
||||||
@@ -343,6 +370,8 @@ lv_calendar_date_t * lv_calendar_get_highlighted_dates(const lv_obj_t * calendar
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_calendar_get_highlighted_dates_num(const lv_obj_t * calendar)
|
uint16_t lv_calendar_get_highlighted_dates_num(const lv_obj_t * calendar)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||||
return ext->highlighted_dates_num;
|
return ext->highlighted_dates_num;
|
||||||
}
|
}
|
||||||
@@ -354,6 +383,8 @@ uint16_t lv_calendar_get_highlighted_dates_num(const lv_obj_t * calendar)
|
|||||||
*/
|
*/
|
||||||
const char ** lv_calendar_get_day_names(const lv_obj_t * calendar)
|
const char ** lv_calendar_get_day_names(const lv_obj_t * calendar)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||||
return ext->day_names;
|
return ext->day_names;
|
||||||
}
|
}
|
||||||
@@ -365,6 +396,8 @@ const char ** lv_calendar_get_day_names(const lv_obj_t * calendar)
|
|||||||
*/
|
*/
|
||||||
const char ** lv_calendar_get_month_names(const lv_obj_t * calendar)
|
const char ** lv_calendar_get_month_names(const lv_obj_t * calendar)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||||
return ext->month_names;
|
return ext->month_names;
|
||||||
}
|
}
|
||||||
@@ -377,6 +410,8 @@ const char ** lv_calendar_get_month_names(const lv_obj_t * calendar)
|
|||||||
* */
|
* */
|
||||||
const lv_style_t * lv_calendar_get_style(const lv_obj_t * calendar, lv_calendar_style_t type)
|
const lv_style_t * lv_calendar_get_style(const lv_obj_t * calendar, lv_calendar_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||||
|
|
||||||
@@ -454,6 +489,7 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(calendar, sign, param);
|
res = ancestor_signal(calendar, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||||
@@ -542,13 +578,6 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
|
|||||||
}
|
}
|
||||||
lv_obj_invalidate(calendar);
|
lv_obj_invalidate(calendar);
|
||||||
}
|
}
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set date*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_calendar";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -136,11 +136,11 @@ void lv_calendar_set_day_names(lv_obj_t * calendar, const char ** day_names);
|
|||||||
/**
|
/**
|
||||||
* Set the name of the month
|
* Set the name of the month
|
||||||
* @param calendar pointer to a calendar object
|
* @param calendar pointer to a calendar object
|
||||||
* @param day_names pointer to an array with the names. E.g. `const char * days[12] = {"Jan", "Feb",
|
* @param month_names pointer to an array with the names. E.g. `const char * days[12] = {"Jan", "Feb",
|
||||||
* ...}` Only the pointer will be saved so this variable can't be local which will be destroyed
|
* ...}` Only the pointer will be saved so this variable can't be local which will be destroyed
|
||||||
* later.
|
* later.
|
||||||
*/
|
*/
|
||||||
void lv_calendar_set_month_names(lv_obj_t * calendar, const char ** day_names);
|
void lv_calendar_set_month_names(lv_obj_t * calendar, const char ** month_names);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a style of a calendar.
|
* Set a style of a calendar.
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*********************/
|
*********************/
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "lv_canvas.h"
|
#include "lv_canvas.h"
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_misc/lv_math.h"
|
#include "../lv_misc/lv_math.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
#include "../lv_core/lv_refr.h"
|
#include "../lv_core/lv_refr.h"
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_canvas"
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -74,12 +76,12 @@ lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor of canvas*/
|
/*Create the ancestor of canvas*/
|
||||||
lv_obj_t * new_canvas = lv_img_create(par, copy);
|
lv_obj_t * new_canvas = lv_img_create(par, copy);
|
||||||
lv_mem_assert(new_canvas);
|
LV_ASSERT_MEM(new_canvas);
|
||||||
if(new_canvas == NULL) return NULL;
|
if(new_canvas == NULL) return NULL;
|
||||||
|
|
||||||
/*Allocate the canvas type specific extended data*/
|
/*Allocate the canvas type specific extended data*/
|
||||||
lv_canvas_ext_t * ext = lv_obj_allocate_ext_attr(new_canvas, sizeof(lv_canvas_ext_t));
|
lv_canvas_ext_t * ext = lv_obj_allocate_ext_attr(new_canvas, sizeof(lv_canvas_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_canvas);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_canvas);
|
||||||
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_canvas);
|
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_canvas);
|
||||||
@@ -132,6 +134,9 @@ lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
|
void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(buf);
|
||||||
|
|
||||||
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
||||||
|
|
||||||
ext->dsc.header.cf = cf;
|
ext->dsc.header.cf = cf;
|
||||||
@@ -152,6 +157,8 @@ void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_
|
|||||||
*/
|
*/
|
||||||
void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t c)
|
void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t c)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
||||||
|
|
||||||
lv_img_buf_set_px_color(&ext->dsc, x, y, c);
|
lv_img_buf_set_px_color(&ext->dsc, x, y, c);
|
||||||
@@ -170,6 +177,8 @@ void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t
|
|||||||
*/
|
*/
|
||||||
void lv_canvas_set_palette(lv_obj_t * canvas, uint8_t id, lv_color_t c)
|
void lv_canvas_set_palette(lv_obj_t * canvas, uint8_t id, lv_color_t c)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
||||||
|
|
||||||
lv_img_buf_set_palette(&ext->dsc, id, c);
|
lv_img_buf_set_palette(&ext->dsc, id, c);
|
||||||
@@ -184,6 +193,8 @@ void lv_canvas_set_palette(lv_obj_t * canvas, uint8_t id, lv_color_t c)
|
|||||||
*/
|
*/
|
||||||
void lv_canvas_set_style(lv_obj_t * canvas, lv_canvas_style_t type, const lv_style_t * style)
|
void lv_canvas_set_style(lv_obj_t * canvas, lv_canvas_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_CANVAS_STYLE_MAIN: lv_img_set_style(canvas, LV_IMG_STYLE_MAIN, style); break;
|
case LV_CANVAS_STYLE_MAIN: lv_img_set_style(canvas, LV_IMG_STYLE_MAIN, style); break;
|
||||||
}
|
}
|
||||||
@@ -202,6 +213,8 @@ void lv_canvas_set_style(lv_obj_t * canvas, lv_canvas_style_t type, const lv_sty
|
|||||||
*/
|
*/
|
||||||
lv_color_t lv_canvas_get_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y)
|
lv_color_t lv_canvas_get_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
||||||
const lv_style_t * style = lv_canvas_get_style(canvas, LV_CANVAS_STYLE_MAIN);
|
const lv_style_t * style = lv_canvas_get_style(canvas, LV_CANVAS_STYLE_MAIN);
|
||||||
|
|
||||||
@@ -215,6 +228,8 @@ lv_color_t lv_canvas_get_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y)
|
|||||||
*/
|
*/
|
||||||
lv_img_dsc_t * lv_canvas_get_img(lv_obj_t * canvas)
|
lv_img_dsc_t * lv_canvas_get_img(lv_obj_t * canvas)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
||||||
|
|
||||||
return &ext->dsc;
|
return &ext->dsc;
|
||||||
@@ -228,6 +243,8 @@ lv_img_dsc_t * lv_canvas_get_img(lv_obj_t * canvas)
|
|||||||
*/
|
*/
|
||||||
const lv_style_t * lv_canvas_get_style(const lv_obj_t * canvas, lv_canvas_style_t type)
|
const lv_style_t * lv_canvas_get_style(const lv_obj_t * canvas, lv_canvas_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -254,6 +271,9 @@ const lv_style_t * lv_canvas_get_style(const lv_obj_t * canvas, lv_canvas_style_
|
|||||||
*/
|
*/
|
||||||
void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h)
|
void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(to_copy);
|
||||||
|
|
||||||
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
||||||
if(x + w >= ext->dsc.header.w || y + h >= ext->dsc.header.h) {
|
if(x + w >= ext->dsc.header.w || y + h >= ext->dsc.header.h) {
|
||||||
LV_LOG_WARN("lv_canvas_copy_buf: x or y out of the canvas");
|
LV_LOG_WARN("lv_canvas_copy_buf: x or y out of the canvas");
|
||||||
@@ -287,6 +307,9 @@ void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t x, l
|
|||||||
void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, lv_coord_t offset_x, lv_coord_t offset_y,
|
void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, lv_coord_t offset_x, lv_coord_t offset_y,
|
||||||
int32_t pivot_x, int32_t pivot_y)
|
int32_t pivot_x, int32_t pivot_y)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(img);
|
||||||
|
|
||||||
lv_canvas_ext_t * ext_dst = lv_obj_get_ext_attr(canvas);
|
lv_canvas_ext_t * ext_dst = lv_obj_get_ext_attr(canvas);
|
||||||
const lv_style_t * style = lv_canvas_get_style(canvas, LV_CANVAS_STYLE_MAIN);
|
const lv_style_t * style = lv_canvas_get_style(canvas, LV_CANVAS_STYLE_MAIN);
|
||||||
int32_t sinma = lv_trigo_sin(-angle);
|
int32_t sinma = lv_trigo_sin(-angle);
|
||||||
@@ -451,6 +474,8 @@ void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, lv_c
|
|||||||
*/
|
*/
|
||||||
void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color)
|
void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
||||||
|
|
||||||
uint32_t x = dsc->header.w * dsc->header.h;
|
uint32_t x = dsc->header.w * dsc->header.h;
|
||||||
@@ -474,6 +499,9 @@ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color)
|
|||||||
void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h,
|
void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h,
|
||||||
const lv_style_t * style)
|
const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(style);
|
||||||
|
|
||||||
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
||||||
|
|
||||||
/* Create a dummy display to fool the lv_draw function.
|
/* Create a dummy display to fool the lv_draw function.
|
||||||
@@ -538,6 +566,9 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
|
|||||||
void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w, const lv_style_t * style,
|
void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w, const lv_style_t * style,
|
||||||
const char * txt, lv_label_align_t align)
|
const char * txt, lv_label_align_t align)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(style);
|
||||||
|
|
||||||
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
||||||
|
|
||||||
/* Create a dummy display to fool the lv_draw function.
|
/* Create a dummy display to fool the lv_draw function.
|
||||||
@@ -594,6 +625,9 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
|
|||||||
*/
|
*/
|
||||||
void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src, const lv_style_t * style)
|
void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(style);
|
||||||
|
|
||||||
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
||||||
|
|
||||||
/* Create a dummy display to fool the lv_draw function.
|
/* Create a dummy display to fool the lv_draw function.
|
||||||
@@ -649,6 +683,9 @@ void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const voi
|
|||||||
*/
|
*/
|
||||||
void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt, const lv_style_t * style)
|
void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(style);
|
||||||
|
|
||||||
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
||||||
|
|
||||||
/* Create a dummy display to fool the lv_draw function.
|
/* Create a dummy display to fool the lv_draw function.
|
||||||
@@ -705,6 +742,9 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t
|
|||||||
*/
|
*/
|
||||||
void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt, const lv_style_t * style)
|
void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(style);
|
||||||
|
|
||||||
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
||||||
|
|
||||||
/* Create a dummy display to fool the lv_draw function.
|
/* Create a dummy display to fool the lv_draw function.
|
||||||
@@ -762,6 +802,9 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32
|
|||||||
void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle,
|
void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle,
|
||||||
int32_t end_angle, const lv_style_t * style)
|
int32_t end_angle, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(style);
|
||||||
|
|
||||||
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
||||||
|
|
||||||
/* Create a dummy display to fool the lv_draw function.
|
/* Create a dummy display to fool the lv_draw function.
|
||||||
@@ -824,16 +867,10 @@ static lv_res_t lv_canvas_signal(lv_obj_t * canvas, lv_signal_t sign, void * par
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(canvas, sign, param);
|
res = ancestor_signal(canvas, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_canvas";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -9,12 +9,14 @@
|
|||||||
#include "lv_cb.h"
|
#include "lv_cb.h"
|
||||||
#if LV_USE_CB != 0
|
#if LV_USE_CB != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_core/lv_group.h"
|
#include "../lv_core/lv_group.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_cb"
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -55,14 +57,14 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor basic object*/
|
/*Create the ancestor basic object*/
|
||||||
lv_obj_t * new_cb = lv_btn_create(par, copy);
|
lv_obj_t * new_cb = lv_btn_create(par, copy);
|
||||||
lv_mem_assert(new_cb);
|
LV_ASSERT_MEM(new_cb);
|
||||||
if(new_cb == NULL) return NULL;
|
if(new_cb == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_cb);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_cb);
|
||||||
if(ancestor_bg_design == NULL) ancestor_bg_design = lv_obj_get_design_cb(new_cb);
|
if(ancestor_bg_design == NULL) ancestor_bg_design = lv_obj_get_design_cb(new_cb);
|
||||||
|
|
||||||
lv_cb_ext_t * ext = lv_obj_allocate_ext_attr(new_cb, sizeof(lv_cb_ext_t));
|
lv_cb_ext_t * ext = lv_obj_allocate_ext_attr(new_cb, sizeof(lv_cb_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
ext->bullet = NULL;
|
ext->bullet = NULL;
|
||||||
@@ -126,6 +128,8 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_cb_set_text(lv_obj_t * cb, const char * txt)
|
void lv_cb_set_text(lv_obj_t * cb, const char * txt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(cb, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
||||||
lv_label_set_text(ext->label, txt);
|
lv_label_set_text(ext->label, txt);
|
||||||
}
|
}
|
||||||
@@ -138,6 +142,8 @@ void lv_cb_set_text(lv_obj_t * cb, const char * txt)
|
|||||||
*/
|
*/
|
||||||
void lv_cb_set_static_text(lv_obj_t * cb, const char * txt)
|
void lv_cb_set_static_text(lv_obj_t * cb, const char * txt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(cb, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
||||||
lv_label_set_static_text(ext->label, txt);
|
lv_label_set_static_text(ext->label, txt);
|
||||||
}
|
}
|
||||||
@@ -150,6 +156,8 @@ void lv_cb_set_static_text(lv_obj_t * cb, const char * txt)
|
|||||||
* */
|
* */
|
||||||
void lv_cb_set_style(lv_obj_t * cb, lv_cb_style_t type, const lv_style_t * style)
|
void lv_cb_set_style(lv_obj_t * cb, lv_cb_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(cb, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -179,6 +187,8 @@ void lv_cb_set_style(lv_obj_t * cb, lv_cb_style_t type, const lv_style_t * style
|
|||||||
*/
|
*/
|
||||||
const char * lv_cb_get_text(const lv_obj_t * cb)
|
const char * lv_cb_get_text(const lv_obj_t * cb)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(cb, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
||||||
return lv_label_get_text(ext->label);
|
return lv_label_get_text(ext->label);
|
||||||
}
|
}
|
||||||
@@ -191,6 +201,8 @@ const char * lv_cb_get_text(const lv_obj_t * cb)
|
|||||||
* */
|
* */
|
||||||
const lv_style_t * lv_cb_get_style(const lv_obj_t * cb, lv_cb_style_t type)
|
const lv_style_t * lv_cb_get_style(const lv_obj_t * cb, lv_cb_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(cb, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
||||||
|
|
||||||
@@ -300,6 +312,7 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(cb, sign, param);
|
res = ancestor_signal(cb, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
||||||
|
|
||||||
@@ -316,13 +329,6 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
|
|||||||
/*Follow the backgrounds state with the bullet*/
|
/*Follow the backgrounds state with the bullet*/
|
||||||
lv_btn_set_state(ext->bullet, lv_btn_get_state(cb));
|
lv_btn_set_state(ext->bullet, lv_btn_get_state(cb));
|
||||||
}
|
}
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_cb";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "lv_chart.h"
|
#include "lv_chart.h"
|
||||||
#if LV_USE_CHART != 0
|
#if LV_USE_CHART != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_core/lv_refr.h"
|
#include "../lv_core/lv_refr.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
#include "../lv_misc/lv_math.h"
|
#include "../lv_misc/lv_math.h"
|
||||||
@@ -17,6 +18,8 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_chart"
|
||||||
|
|
||||||
#define LV_CHART_YMIN_DEF 0
|
#define LV_CHART_YMIN_DEF 0
|
||||||
#define LV_CHART_YMAX_DEF 100
|
#define LV_CHART_YMAX_DEF 100
|
||||||
#define LV_CHART_HDIV_DEF 3
|
#define LV_CHART_HDIV_DEF 3
|
||||||
@@ -25,11 +28,22 @@
|
|||||||
#define LV_CHART_AXIS_TO_LABEL_DISTANCE 4
|
#define LV_CHART_AXIS_TO_LABEL_DISTANCE 4
|
||||||
#define LV_CHART_AXIS_MAJOR_TICK_LEN_COE 1 / 15
|
#define LV_CHART_AXIS_MAJOR_TICK_LEN_COE 1 / 15
|
||||||
#define LV_CHART_AXIS_MINOR_TICK_LEN_COE 2 / 3
|
#define LV_CHART_AXIS_MINOR_TICK_LEN_COE 2 / 3
|
||||||
|
#define LV_CHART_AXIS_PRIMARY_Y 1
|
||||||
|
#define LV_CHART_AXIS_SECONDARY_Y 0
|
||||||
|
#define LV_CHART_LABEL_ITERATOR_FORWARD 1
|
||||||
|
#define LV_CHART_LABEL_ITERATOR_REVERSE 0
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char * list_start;
|
||||||
|
const char * current_pos;
|
||||||
|
uint8_t items_left;
|
||||||
|
uint8_t is_reverse_iter;
|
||||||
|
} lv_chart_label_iterator_t;
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC PROTOTYPES
|
* STATIC PROTOTYPES
|
||||||
**********************/
|
**********************/
|
||||||
@@ -45,6 +59,9 @@ static void lv_chart_draw_axes(lv_obj_t * chart, const lv_area_t * mask);
|
|||||||
static void lv_chart_inv_lines(lv_obj_t * chart, uint16_t i);
|
static void lv_chart_inv_lines(lv_obj_t * chart, uint16_t i);
|
||||||
static void lv_chart_inv_points(lv_obj_t * chart, uint16_t i);
|
static void lv_chart_inv_points(lv_obj_t * chart, uint16_t i);
|
||||||
static void lv_chart_inv_cols(lv_obj_t * chart, uint16_t i);
|
static void lv_chart_inv_cols(lv_obj_t * chart, uint16_t i);
|
||||||
|
static void lv_chart_get_next_label(lv_chart_label_iterator_t * iterator, char * buf);
|
||||||
|
static inline bool lv_chart_is_tick_with_label(uint8_t tick_num, lv_chart_axis_cfg_t * axis);
|
||||||
|
static lv_chart_label_iterator_t lv_chart_create_label_iter(const char * list, uint8_t iterator_dir);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
@@ -73,12 +90,12 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor basic object*/
|
/*Create the ancestor basic object*/
|
||||||
lv_obj_t * new_chart = lv_obj_create(par, copy);
|
lv_obj_t * new_chart = lv_obj_create(par, copy);
|
||||||
lv_mem_assert(new_chart);
|
LV_ASSERT_MEM(new_chart);
|
||||||
if(new_chart == NULL) return NULL;
|
if(new_chart == NULL) return NULL;
|
||||||
|
|
||||||
/*Allocate the object type specific extended data*/
|
/*Allocate the object type specific extended data*/
|
||||||
lv_chart_ext_t * ext = lv_obj_allocate_ext_attr(new_chart, sizeof(lv_chart_ext_t));
|
lv_chart_ext_t * ext = lv_obj_allocate_ext_attr(new_chart, sizeof(lv_chart_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
lv_ll_init(&ext->series_ll, sizeof(lv_chart_series_t));
|
lv_ll_init(&ext->series_ll, sizeof(lv_chart_series_t));
|
||||||
@@ -97,10 +114,13 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
ext->margin = 0;
|
ext->margin = 0;
|
||||||
memset(&ext->x_axis, 0, sizeof(ext->x_axis));
|
memset(&ext->x_axis, 0, sizeof(ext->x_axis));
|
||||||
memset(&ext->y_axis, 0, sizeof(ext->y_axis));
|
memset(&ext->y_axis, 0, sizeof(ext->y_axis));
|
||||||
|
memset(&ext->secondary_y_axis, 0, sizeof(ext->secondary_y_axis));
|
||||||
ext->x_axis.major_tick_len = LV_CHART_TICK_LENGTH_AUTO;
|
ext->x_axis.major_tick_len = LV_CHART_TICK_LENGTH_AUTO;
|
||||||
ext->x_axis.minor_tick_len = LV_CHART_TICK_LENGTH_AUTO;
|
ext->x_axis.minor_tick_len = LV_CHART_TICK_LENGTH_AUTO;
|
||||||
ext->y_axis.major_tick_len = LV_CHART_TICK_LENGTH_AUTO;
|
ext->y_axis.major_tick_len = LV_CHART_TICK_LENGTH_AUTO;
|
||||||
ext->y_axis.minor_tick_len = LV_CHART_TICK_LENGTH_AUTO;
|
ext->y_axis.minor_tick_len = LV_CHART_TICK_LENGTH_AUTO;
|
||||||
|
ext->secondary_y_axis.major_tick_len = LV_CHART_TICK_LENGTH_AUTO;
|
||||||
|
ext->secondary_y_axis.minor_tick_len = LV_CHART_TICK_LENGTH_AUTO;
|
||||||
|
|
||||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_cb(new_chart);
|
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_cb(new_chart);
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_chart);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_chart);
|
||||||
@@ -133,6 +153,7 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
ext->margin = ext_copy->margin;
|
ext->margin = ext_copy->margin;
|
||||||
memcpy(&ext->x_axis, &ext_copy->x_axis, sizeof(lv_chart_axis_cfg_t));
|
memcpy(&ext->x_axis, &ext_copy->x_axis, sizeof(lv_chart_axis_cfg_t));
|
||||||
memcpy(&ext->y_axis, &ext_copy->y_axis, sizeof(lv_chart_axis_cfg_t));
|
memcpy(&ext->y_axis, &ext_copy->y_axis, sizeof(lv_chart_axis_cfg_t));
|
||||||
|
memcpy(&ext->secondary_y_axis, &ext_copy->secondary_y_axis, sizeof(lv_chart_axis_cfg_t));
|
||||||
|
|
||||||
/*Refresh the style with new signal function*/
|
/*Refresh the style with new signal function*/
|
||||||
lv_obj_refresh_style(new_chart);
|
lv_obj_refresh_style(new_chart);
|
||||||
@@ -155,9 +176,11 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
|
lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
lv_chart_series_t * ser = lv_ll_ins_head(&ext->series_ll);
|
lv_chart_series_t * ser = lv_ll_ins_head(&ext->series_ll);
|
||||||
lv_mem_assert(ser);
|
LV_ASSERT_MEM(ser);
|
||||||
if(ser == NULL) return NULL;
|
if(ser == NULL) return NULL;
|
||||||
|
|
||||||
lv_coord_t def = LV_CHART_POINT_DEF;
|
lv_coord_t def = LV_CHART_POINT_DEF;
|
||||||
@@ -166,7 +189,7 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
|
|||||||
|
|
||||||
ser->color = color;
|
ser->color = color;
|
||||||
ser->points = lv_mem_alloc(sizeof(lv_coord_t) * ext->point_cnt);
|
ser->points = lv_mem_alloc(sizeof(lv_coord_t) * ext->point_cnt);
|
||||||
lv_mem_assert(ser->points);
|
LV_ASSERT_MEM(ser->points);
|
||||||
if(ser->points == NULL) {
|
if(ser->points == NULL) {
|
||||||
lv_ll_rem(&ext->series_ll, ser);
|
lv_ll_rem(&ext->series_ll, ser);
|
||||||
lv_mem_free(ser);
|
lv_mem_free(ser);
|
||||||
@@ -194,6 +217,9 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
|
|||||||
*/
|
*/
|
||||||
void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie)
|
void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(serie);
|
||||||
|
|
||||||
if(chart == NULL || serie == NULL) return;
|
if(chart == NULL || serie == NULL) return;
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
if(ext == NULL) return;
|
if(ext == NULL) return;
|
||||||
@@ -218,6 +244,8 @@ void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie)
|
|||||||
*/
|
*/
|
||||||
void lv_chart_set_div_line_count(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv)
|
void lv_chart_set_div_line_count(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
if(ext->hdiv_cnt == hdiv && ext->vdiv_cnt == vdiv) return;
|
if(ext->hdiv_cnt == hdiv && ext->vdiv_cnt == vdiv) return;
|
||||||
|
|
||||||
@@ -235,6 +263,8 @@ void lv_chart_set_div_line_count(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv)
|
|||||||
*/
|
*/
|
||||||
void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coord_t ymax)
|
void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coord_t ymax)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
if(ext->ymin == ymin && ext->ymax == ymax) return;
|
if(ext->ymin == ymin && ext->ymax == ymax) return;
|
||||||
|
|
||||||
@@ -251,6 +281,8 @@ void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coord_t ymax)
|
|||||||
*/
|
*/
|
||||||
void lv_chart_set_type(lv_obj_t * chart, lv_chart_type_t type)
|
void lv_chart_set_type(lv_obj_t * chart, lv_chart_type_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
if(ext->type == type) return;
|
if(ext->type == type) return;
|
||||||
|
|
||||||
@@ -266,6 +298,8 @@ void lv_chart_set_type(lv_obj_t * chart, lv_chart_type_t type)
|
|||||||
*/
|
*/
|
||||||
void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
|
void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
if(ext->point_cnt == point_cnt) return;
|
if(ext->point_cnt == point_cnt) return;
|
||||||
|
|
||||||
@@ -280,7 +314,7 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
|
|||||||
{
|
{
|
||||||
if(ser->start_point != 0) {
|
if(ser->start_point != 0) {
|
||||||
lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt);
|
lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt);
|
||||||
lv_mem_assert(new_points);
|
LV_ASSERT_MEM(new_points);
|
||||||
if(new_points == NULL) return;
|
if(new_points == NULL) return;
|
||||||
|
|
||||||
if(point_cnt >= point_cnt_old) {
|
if(point_cnt >= point_cnt_old) {
|
||||||
@@ -303,7 +337,7 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
|
|||||||
ser->points = new_points;
|
ser->points = new_points;
|
||||||
} else {
|
} else {
|
||||||
ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt);
|
ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt);
|
||||||
lv_mem_assert(ser->points);
|
LV_ASSERT_MEM(ser->points);
|
||||||
if(ser->points == NULL) return;
|
if(ser->points == NULL) return;
|
||||||
/*Initialize the new points*/
|
/*Initialize the new points*/
|
||||||
if(point_cnt > point_cnt_old) {
|
if(point_cnt > point_cnt_old) {
|
||||||
@@ -328,6 +362,8 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
|
|||||||
*/
|
*/
|
||||||
void lv_chart_set_series_opa(lv_obj_t * chart, lv_opa_t opa)
|
void lv_chart_set_series_opa(lv_obj_t * chart, lv_opa_t opa)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
if(ext->series.opa == opa) return;
|
if(ext->series.opa == opa) return;
|
||||||
|
|
||||||
@@ -342,6 +378,8 @@ void lv_chart_set_series_opa(lv_obj_t * chart, lv_opa_t opa)
|
|||||||
*/
|
*/
|
||||||
void lv_chart_set_series_width(lv_obj_t * chart, lv_coord_t width)
|
void lv_chart_set_series_width(lv_obj_t * chart, lv_coord_t width)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
if(ext->series.width == width) return;
|
if(ext->series.width == width) return;
|
||||||
|
|
||||||
@@ -355,6 +393,8 @@ void lv_chart_set_series_width(lv_obj_t * chart, lv_coord_t width)
|
|||||||
*/
|
*/
|
||||||
void lv_chart_set_series_darking(lv_obj_t * chart, lv_opa_t dark_eff)
|
void lv_chart_set_series_darking(lv_obj_t * chart, lv_opa_t dark_eff)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
if(ext->series.dark == dark_eff) return;
|
if(ext->series.dark == dark_eff) return;
|
||||||
|
|
||||||
@@ -370,6 +410,9 @@ void lv_chart_set_series_darking(lv_obj_t * chart, lv_opa_t dark_eff)
|
|||||||
*/
|
*/
|
||||||
void lv_chart_init_points(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y)
|
void lv_chart_init_points(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(ser);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
for(i = 0; i < ext->point_cnt; i++) {
|
for(i = 0; i < ext->point_cnt; i++) {
|
||||||
@@ -387,6 +430,9 @@ void lv_chart_init_points(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t
|
|||||||
*/
|
*/
|
||||||
void lv_chart_set_points(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y_array[])
|
void lv_chart_set_points(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y_array[])
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(ser);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
memcpy(ser->points, y_array, ext->point_cnt * (sizeof(lv_coord_t)));
|
memcpy(ser->points, y_array, ext->point_cnt * (sizeof(lv_coord_t)));
|
||||||
ser->start_point = 0;
|
ser->start_point = 0;
|
||||||
@@ -401,6 +447,9 @@ void lv_chart_set_points(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y
|
|||||||
*/
|
*/
|
||||||
void lv_chart_set_next(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y)
|
void lv_chart_set_next(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(ser);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
if(ext->update_mode == LV_CHART_UPDATE_MODE_SHIFT) {
|
if(ext->update_mode == LV_CHART_UPDATE_MODE_SHIFT) {
|
||||||
ser->points[ser->start_point] =
|
ser->points[ser->start_point] =
|
||||||
@@ -428,6 +477,8 @@ void lv_chart_set_next(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y)
|
|||||||
*/
|
*/
|
||||||
void lv_chart_set_update_mode(lv_obj_t * chart, lv_chart_update_mode_t update_mode)
|
void lv_chart_set_update_mode(lv_obj_t * chart, lv_chart_update_mode_t update_mode)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
if(ext->update_mode == update_mode) return;
|
if(ext->update_mode == update_mode) return;
|
||||||
|
|
||||||
@@ -445,6 +496,8 @@ void lv_chart_set_update_mode(lv_obj_t * chart, lv_chart_update_mode_t update_mo
|
|||||||
*/
|
*/
|
||||||
void lv_chart_set_x_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_t minor_tick_len)
|
void lv_chart_set_x_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_t minor_tick_len)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
ext->x_axis.major_tick_len = major_tick_len;
|
ext->x_axis.major_tick_len = major_tick_len;
|
||||||
ext->x_axis.minor_tick_len = minor_tick_len;
|
ext->x_axis.minor_tick_len = minor_tick_len;
|
||||||
@@ -460,11 +513,30 @@ void lv_chart_set_x_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_
|
|||||||
*/
|
*/
|
||||||
void lv_chart_set_y_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_t minor_tick_len)
|
void lv_chart_set_y_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_t minor_tick_len)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
ext->y_axis.major_tick_len = major_tick_len;
|
ext->y_axis.major_tick_len = major_tick_len;
|
||||||
ext->y_axis.minor_tick_len = minor_tick_len;
|
ext->y_axis.minor_tick_len = minor_tick_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the length of the tick marks on the secondary y axis
|
||||||
|
* @param chart pointer to the chart
|
||||||
|
* @param major_tick_len the length of the major tick or `LV_CHART_TICK_LENGTH_AUTO` to set automatically
|
||||||
|
* (where labels are added)
|
||||||
|
* @param minor_tick_len the length of the minor tick, `LV_CHART_TICK_LENGTH_AUTO` to set automatically
|
||||||
|
* (where no labels are added)
|
||||||
|
*/
|
||||||
|
void lv_chart_set_secondary_y_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_t minor_tick_len)
|
||||||
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
|
ext->secondary_y_axis.major_tick_len = major_tick_len;
|
||||||
|
ext->secondary_y_axis.minor_tick_len = minor_tick_len;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the x-axis tick count and labels of a chart
|
* Set the x-axis tick count and labels of a chart
|
||||||
* @param chart pointer to a chart object
|
* @param chart pointer to a chart object
|
||||||
@@ -476,6 +548,9 @@ void lv_chart_set_y_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_
|
|||||||
void lv_chart_set_x_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
|
void lv_chart_set_x_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
|
||||||
lv_chart_axis_options_t options)
|
lv_chart_axis_options_t options)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(list_of_values);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
ext->x_axis.num_tick_marks = num_tick_marks;
|
ext->x_axis.num_tick_marks = num_tick_marks;
|
||||||
ext->x_axis.list_of_values = list_of_values;
|
ext->x_axis.list_of_values = list_of_values;
|
||||||
@@ -493,12 +568,35 @@ void lv_chart_set_x_tick_texts(lv_obj_t * chart, const char * list_of_values, ui
|
|||||||
void lv_chart_set_y_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
|
void lv_chart_set_y_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
|
||||||
lv_chart_axis_options_t options)
|
lv_chart_axis_options_t options)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(list_of_values);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
ext->y_axis.num_tick_marks = num_tick_marks;
|
ext->y_axis.num_tick_marks = num_tick_marks;
|
||||||
ext->y_axis.list_of_values = list_of_values;
|
ext->y_axis.list_of_values = list_of_values;
|
||||||
ext->y_axis.options = options;
|
ext->y_axis.options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the secondary y-axis tick count and labels of a chart
|
||||||
|
* @param chart pointer to a chart object
|
||||||
|
* @param list_of_values list of string values, terminated with \n, except the last
|
||||||
|
* @param num_tick_marks if list_of_values is NULL: total number of ticks per axis
|
||||||
|
* else number of ticks between two value labels
|
||||||
|
* @param options extra options
|
||||||
|
*/
|
||||||
|
void lv_chart_set_secondary_y_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
|
||||||
|
lv_chart_axis_options_t options)
|
||||||
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(list_of_values);
|
||||||
|
|
||||||
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
|
ext->secondary_y_axis.num_tick_marks = num_tick_marks;
|
||||||
|
ext->secondary_y_axis.list_of_values = list_of_values;
|
||||||
|
ext->secondary_y_axis.options = options;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the margin around the chart, used for axes value and ticks
|
* Set the margin around the chart, used for axes value and ticks
|
||||||
* @param chart pointer to an chart object
|
* @param chart pointer to an chart object
|
||||||
@@ -506,6 +604,8 @@ void lv_chart_set_y_tick_texts(lv_obj_t * chart, const char * list_of_values, ui
|
|||||||
*/
|
*/
|
||||||
void lv_chart_set_margin(lv_obj_t * chart, uint16_t margin)
|
void lv_chart_set_margin(lv_obj_t * chart, uint16_t margin)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
ext->margin = margin;
|
ext->margin = margin;
|
||||||
lv_obj_refresh_ext_draw_pad(chart);
|
lv_obj_refresh_ext_draw_pad(chart);
|
||||||
@@ -522,6 +622,8 @@ void lv_chart_set_margin(lv_obj_t * chart, uint16_t margin)
|
|||||||
*/
|
*/
|
||||||
lv_chart_type_t lv_chart_get_type(const lv_obj_t * chart)
|
lv_chart_type_t lv_chart_get_type(const lv_obj_t * chart)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
return ext->type;
|
return ext->type;
|
||||||
}
|
}
|
||||||
@@ -533,6 +635,8 @@ lv_chart_type_t lv_chart_get_type(const lv_obj_t * chart)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_chart_get_point_cnt(const lv_obj_t * chart)
|
uint16_t lv_chart_get_point_cnt(const lv_obj_t * chart)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
return ext->point_cnt;
|
return ext->point_cnt;
|
||||||
}
|
}
|
||||||
@@ -544,6 +648,8 @@ uint16_t lv_chart_get_point_cnt(const lv_obj_t * chart)
|
|||||||
*/
|
*/
|
||||||
lv_opa_t lv_chart_get_series_opa(const lv_obj_t * chart)
|
lv_opa_t lv_chart_get_series_opa(const lv_obj_t * chart)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
return ext->series.opa;
|
return ext->series.opa;
|
||||||
}
|
}
|
||||||
@@ -555,6 +661,8 @@ lv_opa_t lv_chart_get_series_opa(const lv_obj_t * chart)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_chart_get_series_width(const lv_obj_t * chart)
|
lv_coord_t lv_chart_get_series_width(const lv_obj_t * chart)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
return ext->series.width;
|
return ext->series.width;
|
||||||
}
|
}
|
||||||
@@ -566,6 +674,8 @@ lv_coord_t lv_chart_get_series_width(const lv_obj_t * chart)
|
|||||||
*/
|
*/
|
||||||
lv_opa_t lv_chart_get_series_darking(const lv_obj_t * chart)
|
lv_opa_t lv_chart_get_series_darking(const lv_obj_t * chart)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
return ext->series.dark;
|
return ext->series.dark;
|
||||||
}
|
}
|
||||||
@@ -580,6 +690,8 @@ lv_opa_t lv_chart_get_series_darking(const lv_obj_t * chart)
|
|||||||
*/
|
*/
|
||||||
void lv_chart_refresh(lv_obj_t * chart)
|
void lv_chart_refresh(lv_obj_t * chart)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_obj_invalidate(chart);
|
lv_obj_invalidate(chart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -590,6 +702,8 @@ void lv_chart_refresh(lv_obj_t * chart)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_chart_get_margin(lv_obj_t * chart)
|
uint16_t lv_chart_get_margin(lv_obj_t * chart)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
return ext->margin;
|
return ext->margin;
|
||||||
}
|
}
|
||||||
@@ -648,12 +762,13 @@ static lv_design_res_t lv_chart_design(lv_obj_t * chart, const lv_area_t * clip_
|
|||||||
*/
|
*/
|
||||||
static lv_res_t lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param)
|
static lv_res_t lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param)
|
||||||
{
|
{
|
||||||
lv_res_t res;
|
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
|
||||||
|
|
||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
|
lv_res_t res;
|
||||||
res = ancestor_signal(chart, sign, param);
|
res = ancestor_signal(chart, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
lv_coord_t ** datal;
|
lv_coord_t ** datal;
|
||||||
@@ -662,13 +777,6 @@ static lv_res_t lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param
|
|||||||
lv_mem_free(*datal);
|
lv_mem_free(*datal);
|
||||||
}
|
}
|
||||||
lv_ll_clear(&ext->series_ll);
|
lv_ll_clear(&ext->series_ll);
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_chart";
|
|
||||||
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
||||||
/*Provide extra px draw area around the chart*/
|
/*Provide extra px draw area around the chart*/
|
||||||
chart->ext_draw_pad = ext->margin;
|
chart->ext_draw_pad = ext->margin;
|
||||||
@@ -1061,65 +1169,187 @@ static void lv_chart_draw_areas(lv_obj_t * chart, const lv_area_t * mask)
|
|||||||
lv_draw_mask_remove_id(mask_fade_id);
|
lv_draw_mask_remove_id(mask_fade_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask)
|
/**
|
||||||
|
* Create iterator for newline-separated list
|
||||||
|
* @param list pointer to newline-separated labels list
|
||||||
|
* @param iterator_dir LV_CHART_ITERATOR_FORWARD or LV_CHART_LABEL_ITERATOR_REVERSE
|
||||||
|
* @return lv_chart_label_iterator_t
|
||||||
|
*/
|
||||||
|
static lv_chart_label_iterator_t lv_chart_create_label_iter(const char * list, uint8_t iterator_dir)
|
||||||
|
{
|
||||||
|
lv_chart_label_iterator_t iterator = {0};
|
||||||
|
uint8_t j;
|
||||||
|
|
||||||
|
iterator.list_start = list;
|
||||||
|
|
||||||
|
/* count number of list items */
|
||||||
|
for(j = 0; list[j] != '\0'; j++) {
|
||||||
|
if(list[j] == '\n')
|
||||||
|
iterator.items_left++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(iterator_dir == LV_CHART_LABEL_ITERATOR_FORWARD) {
|
||||||
|
iterator.is_reverse_iter = 0;
|
||||||
|
iterator.current_pos = list;
|
||||||
|
} else {
|
||||||
|
iterator.is_reverse_iter = 1;
|
||||||
|
// -1 to skip '\0' at the end of the string
|
||||||
|
iterator.current_pos = list + j - 1;
|
||||||
|
}
|
||||||
|
iterator.items_left++;
|
||||||
|
return iterator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get next label from iterator created by lv_chart_create_label_iter()
|
||||||
|
* @param iterator iterator to get label from
|
||||||
|
* @param[out] buf buffer to point next label to
|
||||||
|
*/
|
||||||
|
static void lv_chart_get_next_label(lv_chart_label_iterator_t * iterator, char * buf)
|
||||||
|
{
|
||||||
|
uint8_t label_len = 0;
|
||||||
|
if (iterator->is_reverse_iter) {
|
||||||
|
const char * label_start;
|
||||||
|
/* count the length of the current label*/
|
||||||
|
while ((*iterator->current_pos != '\n') &&
|
||||||
|
(iterator->current_pos != iterator->list_start)) {
|
||||||
|
iterator->current_pos--;
|
||||||
|
label_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
label_start = iterator->current_pos;
|
||||||
|
|
||||||
|
if (*iterator->current_pos == '\n') {
|
||||||
|
/* do not copy \n symbol, +1 to skip it*/
|
||||||
|
label_start++;
|
||||||
|
/* skip newline*/
|
||||||
|
iterator->current_pos--;
|
||||||
|
} else {
|
||||||
|
/* it is last label in list (first one from the beginning )*/
|
||||||
|
label_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* do not allow output buffer overflow */
|
||||||
|
if (label_len > LV_CHART_AXIS_TICK_LABEL_MAX_LEN) {
|
||||||
|
label_len = LV_CHART_AXIS_TICK_LABEL_MAX_LEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
strncpy(buf, label_start, label_len);
|
||||||
|
} else {
|
||||||
|
/* search for tick string */
|
||||||
|
while(iterator->current_pos[label_len] != '\n' &&
|
||||||
|
iterator->current_pos[label_len] != '\0') {
|
||||||
|
/* do not overflow the buffer, but move to the end of the current label */
|
||||||
|
if(label_len < LV_CHART_AXIS_TICK_LABEL_MAX_LEN) {
|
||||||
|
buf[label_len] = iterator->current_pos[label_len];
|
||||||
|
label_len++;
|
||||||
|
} else {
|
||||||
|
label_len++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
iterator->current_pos += label_len;
|
||||||
|
|
||||||
|
/* do not allow output buffer overflow */
|
||||||
|
if (label_len > LV_CHART_AXIS_TICK_LABEL_MAX_LEN) {
|
||||||
|
label_len = LV_CHART_AXIS_TICK_LABEL_MAX_LEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*iterator->current_pos == '\n') iterator->current_pos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* terminate the string */
|
||||||
|
buf[label_len] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether there should be a label next to tick with given
|
||||||
|
* number
|
||||||
|
* @param tick_num number of the tick to check
|
||||||
|
* @param axis pointer to struct containing info on the axis
|
||||||
|
* @return true if label should be located next to current tick
|
||||||
|
*/
|
||||||
|
static inline bool lv_chart_is_tick_with_label(uint8_t tick_num, lv_chart_axis_cfg_t * axis)
|
||||||
|
{
|
||||||
|
return ((tick_num == 0) || ((tick_num % axis->num_tick_marks) == 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask, uint8_t which_axis)
|
||||||
{
|
{
|
||||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||||
|
lv_chart_axis_cfg_t * y_axis = (which_axis == LV_CHART_AXIS_PRIMARY_Y) ?
|
||||||
|
&ext->y_axis : &ext->secondary_y_axis;
|
||||||
|
|
||||||
if(ext->y_axis.list_of_values != NULL || ext->y_axis.num_tick_marks != 0) {
|
if(y_axis->list_of_values != NULL || y_axis->num_tick_marks != 0) {
|
||||||
|
|
||||||
const lv_style_t * style = lv_obj_get_style(chart);
|
const lv_style_t * style = lv_obj_get_style(chart);
|
||||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(chart);
|
lv_opa_t opa_scale = lv_obj_get_opa_scale(chart);
|
||||||
|
|
||||||
uint8_t i, j;
|
uint8_t i, j;
|
||||||
uint8_t list_index;
|
|
||||||
uint8_t num_of_labels;
|
uint8_t num_of_labels;
|
||||||
uint8_t num_scale_ticks;
|
uint8_t num_scale_ticks;
|
||||||
uint8_t major_tick_len, minor_tick_len;
|
int8_t major_tick_len, minor_tick_len;
|
||||||
|
uint8_t iter_dir;
|
||||||
|
|
||||||
lv_point_t p1;
|
lv_point_t p1;
|
||||||
lv_point_t p2;
|
lv_point_t p2;
|
||||||
lv_coord_t x_ofs = chart->coords.x1;
|
lv_coord_t x_ofs;
|
||||||
|
lv_chart_label_iterator_t iter;
|
||||||
lv_coord_t y_ofs = chart->coords.y1;
|
lv_coord_t y_ofs = chart->coords.y1;
|
||||||
lv_coord_t h = lv_obj_get_height(chart);
|
lv_coord_t h = lv_obj_get_height(chart);
|
||||||
lv_coord_t w = lv_obj_get_width(chart);
|
lv_coord_t w = lv_obj_get_width(chart);
|
||||||
char buf[LV_CHART_AXIS_TICK_LABEL_MAX_LEN + 1]; /* up to N symbols per label + null terminator */
|
char buf[LV_CHART_AXIS_TICK_LABEL_MAX_LEN + 1]; /* up to N symbols per label + null terminator */
|
||||||
|
|
||||||
|
/* chose correct side of the chart */
|
||||||
|
if(which_axis == LV_CHART_AXIS_PRIMARY_Y)
|
||||||
|
x_ofs = chart->coords.x1;
|
||||||
|
else
|
||||||
|
x_ofs = chart->coords.x2;
|
||||||
|
|
||||||
/* calculate the size of tick marks */
|
/* calculate the size of tick marks */
|
||||||
if(ext->y_axis.major_tick_len == LV_CHART_TICK_LENGTH_AUTO)
|
if(y_axis->major_tick_len == LV_CHART_TICK_LENGTH_AUTO)
|
||||||
major_tick_len = (int32_t)w * LV_CHART_AXIS_MAJOR_TICK_LEN_COE;
|
major_tick_len = (int32_t)w * LV_CHART_AXIS_MAJOR_TICK_LEN_COE;
|
||||||
else
|
else
|
||||||
major_tick_len = ext->y_axis.major_tick_len;
|
major_tick_len = y_axis->major_tick_len;
|
||||||
|
|
||||||
if(ext->y_axis.minor_tick_len == LV_CHART_TICK_LENGTH_AUTO)
|
if(y_axis->minor_tick_len == LV_CHART_TICK_LENGTH_AUTO)
|
||||||
minor_tick_len = major_tick_len * LV_CHART_AXIS_MINOR_TICK_LEN_COE;
|
minor_tick_len = major_tick_len * LV_CHART_AXIS_MINOR_TICK_LEN_COE;
|
||||||
else
|
else
|
||||||
minor_tick_len = ext->y_axis.minor_tick_len;
|
minor_tick_len = y_axis->minor_tick_len;
|
||||||
|
|
||||||
/* count the '\n'-s to determine the number of options */
|
/* tick lines on secondary y axis are drawn in other direction*/
|
||||||
list_index = 0;
|
if(which_axis == LV_CHART_AXIS_SECONDARY_Y) {
|
||||||
num_of_labels = 0;
|
major_tick_len *= -1;
|
||||||
if(ext->y_axis.list_of_values != NULL) {
|
minor_tick_len *= -1;
|
||||||
for(j = 0; ext->y_axis.list_of_values[j] != '\0'; j++) {
|
|
||||||
if(ext->y_axis.list_of_values[j] == '\n') num_of_labels++;
|
|
||||||
}
|
|
||||||
|
|
||||||
num_of_labels++; /* last option in the at row*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iter_dir = (y_axis->options & LV_CHART_AXIS_INVERSE_LABELS_ORDER) ? LV_CHART_LABEL_ITERATOR_REVERSE : LV_CHART_LABEL_ITERATOR_FORWARD;
|
||||||
|
iter = lv_chart_create_label_iter(y_axis->list_of_values, iter_dir);
|
||||||
|
|
||||||
|
/*determine the number of options */
|
||||||
|
num_of_labels = iter.items_left;
|
||||||
|
|
||||||
/* we can't have string labels without ticks step, set to 1 if not specified */
|
/* we can't have string labels without ticks step, set to 1 if not specified */
|
||||||
if(ext->y_axis.num_tick_marks == 0) ext->y_axis.num_tick_marks = 1;
|
if(y_axis->num_tick_marks == 0) y_axis->num_tick_marks = 1;
|
||||||
|
|
||||||
/* calculate total number of ticks */
|
/* calculate total number of ticks */
|
||||||
if(num_of_labels < 2)
|
if(num_of_labels < 2)
|
||||||
num_scale_ticks = ext->y_axis.num_tick_marks;
|
num_scale_ticks = y_axis->num_tick_marks;
|
||||||
else
|
else
|
||||||
num_scale_ticks = (ext->y_axis.num_tick_marks * (num_of_labels - 1));
|
num_scale_ticks = (y_axis->num_tick_marks * (num_of_labels - 1));
|
||||||
|
|
||||||
for(i = 0; i < (num_scale_ticks + 1); i++) { /* one extra loop - it may not exist in the list, empty label */
|
for(i = 0; i < (num_scale_ticks + 1); i++) { /* one extra loop - it may not exist in the list, empty label */
|
||||||
/* first point of the tick */
|
/* first point of the tick */
|
||||||
p1.x = x_ofs - 1;
|
p1.x = x_ofs;
|
||||||
|
|
||||||
|
/* move extra pixel out of chart boundary */
|
||||||
|
if (which_axis == LV_CHART_AXIS_PRIMARY_Y)
|
||||||
|
p1.x--;
|
||||||
|
else
|
||||||
|
p1.x++;
|
||||||
|
|
||||||
/* second point of the tick */
|
/* second point of the tick */
|
||||||
if((num_of_labels != 0) && (i == 0 || i % ext->y_axis.num_tick_marks == 0))
|
if((num_of_labels != 0) && (i == 0 || i % y_axis->num_tick_marks == 0))
|
||||||
p2.x = p1.x - major_tick_len; /* major tick */
|
p2.x = p1.x - major_tick_len; /* major tick */
|
||||||
else
|
else
|
||||||
p2.x = p1.x - minor_tick_len; /* minor tick */
|
p2.x = p1.x - minor_tick_len; /* minor tick */
|
||||||
@@ -1128,31 +1358,25 @@ static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask)
|
|||||||
p2.y = p1.y =
|
p2.y = p1.y =
|
||||||
y_ofs + (int32_t)((int32_t)(h - style->line.width) * i) / num_scale_ticks;
|
y_ofs + (int32_t)((int32_t)(h - style->line.width) * i) / num_scale_ticks;
|
||||||
|
|
||||||
if(i != num_scale_ticks)
|
if(y_axis->options & LV_CHART_AXIS_INVERSE_LABELS_ORDER) {
|
||||||
lv_draw_line(&p1, &p2, mask, style, opa_scale);
|
/*if label order is inversed last tick have number 0*/
|
||||||
else if((ext->y_axis.options & LV_CHART_AXIS_DRAW_LAST_TICK) != 0)
|
if(i != 0)
|
||||||
lv_draw_line(&p1, &p2, mask, style, opa_scale);
|
lv_draw_line(&p1, &p2, mask, style, opa_scale);
|
||||||
|
else if((y_axis->options & LV_CHART_AXIS_DRAW_LAST_TICK) != 0)
|
||||||
|
lv_draw_line(&p1, &p2, mask, style, opa_scale);
|
||||||
|
} else {
|
||||||
|
if(i != num_scale_ticks)
|
||||||
|
lv_draw_line(&p1, &p2, mask, style, opa_scale);
|
||||||
|
else if((y_axis->options & LV_CHART_AXIS_DRAW_LAST_TICK) != 0)
|
||||||
|
lv_draw_line(&p1, &p2, mask, style, opa_scale);
|
||||||
|
}
|
||||||
|
|
||||||
/* draw values if available */
|
/* draw values if available */
|
||||||
if(num_of_labels != 0) {
|
if(num_of_labels != 0) {
|
||||||
/* add text only to major tick */
|
/* add text only to major tick */
|
||||||
if(i == 0 || i % ext->y_axis.num_tick_marks == 0) {
|
if(lv_chart_is_tick_with_label(i, y_axis)) {
|
||||||
/* search for tick string */
|
|
||||||
j = 0;
|
|
||||||
while(ext->y_axis.list_of_values[list_index] != '\n' &&
|
|
||||||
ext->y_axis.list_of_values[list_index] != '\0') {
|
|
||||||
/* do not overflow the buffer, but move to the end of the current label */
|
|
||||||
if(j < LV_CHART_AXIS_TICK_LABEL_MAX_LEN)
|
|
||||||
buf[j++] = ext->y_axis.list_of_values[list_index++];
|
|
||||||
else
|
|
||||||
list_index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* this was a string, but not end of the list, so jump to the next string */
|
lv_chart_get_next_label(&iter, buf);
|
||||||
if(ext->y_axis.list_of_values[list_index] == '\n') list_index++;
|
|
||||||
|
|
||||||
/* terminate the string */
|
|
||||||
buf[j] = '\0';
|
|
||||||
|
|
||||||
/* reserve appropriate area */
|
/* reserve appropriate area */
|
||||||
lv_point_t size;
|
lv_point_t size;
|
||||||
@@ -1160,8 +1384,16 @@ static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask)
|
|||||||
LV_COORD_MAX, LV_TXT_FLAG_CENTER);
|
LV_COORD_MAX, LV_TXT_FLAG_CENTER);
|
||||||
|
|
||||||
/* set the area at some distance of the major tick len left of the tick */
|
/* set the area at some distance of the major tick len left of the tick */
|
||||||
lv_area_t a = {(p2.x - size.x - LV_CHART_AXIS_TO_LABEL_DISTANCE), (p2.y - size.y / 2),
|
lv_area_t a = {.y1 = p2.y - size.y / 2, .y2 = p2.y + size.y / 2};
|
||||||
(p2.x - LV_CHART_AXIS_TO_LABEL_DISTANCE), (p2.y + size.y / 2)};
|
|
||||||
|
if(which_axis == LV_CHART_AXIS_PRIMARY_Y) {
|
||||||
|
a.x1 = p2.x - size.x - LV_CHART_AXIS_TO_LABEL_DISTANCE;
|
||||||
|
a.x2 = p2.x - LV_CHART_AXIS_TO_LABEL_DISTANCE;
|
||||||
|
} else {
|
||||||
|
a.x1 = p2.x + LV_CHART_AXIS_TO_LABEL_DISTANCE;
|
||||||
|
a.x2 = p2.x + size.x + LV_CHART_AXIS_TO_LABEL_DISTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
lv_draw_label(&a, mask, style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1, -1, NULL);
|
lv_draw_label(&a, mask, style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1, -1, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1184,6 +1416,7 @@ static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask)
|
|||||||
uint8_t num_of_labels;
|
uint8_t num_of_labels;
|
||||||
uint8_t num_scale_ticks;
|
uint8_t num_scale_ticks;
|
||||||
uint8_t major_tick_len, minor_tick_len;
|
uint8_t major_tick_len, minor_tick_len;
|
||||||
|
lv_chart_label_iterator_t iter;
|
||||||
lv_point_t p1;
|
lv_point_t p1;
|
||||||
lv_point_t p2;
|
lv_point_t p2;
|
||||||
lv_coord_t x_ofs = chart->coords.x1;
|
lv_coord_t x_ofs = chart->coords.x1;
|
||||||
@@ -1203,16 +1436,9 @@ static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask)
|
|||||||
else
|
else
|
||||||
minor_tick_len = ext->x_axis.minor_tick_len;
|
minor_tick_len = ext->x_axis.minor_tick_len;
|
||||||
|
|
||||||
/* count the '\n'-s to determine the number of options */
|
/*determine the number of options */
|
||||||
list_index = 0;
|
iter = lv_chart_create_label_iter(ext->x_axis.list_of_values, LV_CHART_LABEL_ITERATOR_FORWARD);
|
||||||
num_of_labels = 0;
|
num_of_labels = iter.items_left;
|
||||||
if(ext->x_axis.list_of_values != NULL) {
|
|
||||||
for(j = 0; ext->x_axis.list_of_values[j] != '\0'; j++) {
|
|
||||||
if(ext->x_axis.list_of_values[j] == '\n') num_of_labels++;
|
|
||||||
}
|
|
||||||
|
|
||||||
num_of_labels++; /* last option in the at row*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we can't have string labels without ticks step, set to 1 if not specified */
|
/* we can't have string labels without ticks step, set to 1 if not specified */
|
||||||
if(ext->x_axis.num_tick_marks == 0) ext->x_axis.num_tick_marks = 1;
|
if(ext->x_axis.num_tick_marks == 0) ext->x_axis.num_tick_marks = 1;
|
||||||
@@ -1244,23 +1470,8 @@ static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask)
|
|||||||
/* draw values if available */
|
/* draw values if available */
|
||||||
if(num_of_labels != 0) {
|
if(num_of_labels != 0) {
|
||||||
/* add text only to major tick */
|
/* add text only to major tick */
|
||||||
if(i == 0 || i % ext->x_axis.num_tick_marks == 0) {
|
if(lv_chart_is_tick_with_label(i, &(ext->x_axis))) {
|
||||||
/* search for tick string */
|
lv_chart_get_next_label(&iter, buf);
|
||||||
j = 0;
|
|
||||||
while(ext->x_axis.list_of_values[list_index] != '\n' &&
|
|
||||||
ext->x_axis.list_of_values[list_index] != '\0') {
|
|
||||||
/* do not overflow the buffer, but move to the end of the current label */
|
|
||||||
if(j < LV_CHART_AXIS_TICK_LABEL_MAX_LEN)
|
|
||||||
buf[j++] = ext->x_axis.list_of_values[list_index++];
|
|
||||||
else
|
|
||||||
list_index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* this was a string, but not end of the list, so jump to the next string */
|
|
||||||
if(ext->x_axis.list_of_values[list_index] == '\n') list_index++;
|
|
||||||
|
|
||||||
/* terminate the string */
|
|
||||||
buf[j] = '\0';
|
|
||||||
|
|
||||||
/* reserve appropriate area */
|
/* reserve appropriate area */
|
||||||
lv_point_t size;
|
lv_point_t size;
|
||||||
@@ -1279,7 +1490,8 @@ static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask)
|
|||||||
|
|
||||||
static void lv_chart_draw_axes(lv_obj_t * chart, const lv_area_t * mask)
|
static void lv_chart_draw_axes(lv_obj_t * chart, const lv_area_t * mask)
|
||||||
{
|
{
|
||||||
lv_chart_draw_y_ticks(chart, mask);
|
lv_chart_draw_y_ticks(chart, mask, LV_CHART_AXIS_PRIMARY_Y);
|
||||||
|
lv_chart_draw_y_ticks(chart, mask, LV_CHART_AXIS_SECONDARY_Y);
|
||||||
lv_chart_draw_x_ticks(chart, mask);
|
lv_chart_draw_x_ticks(chart, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,8 +66,9 @@ typedef struct
|
|||||||
|
|
||||||
/** Data of axis */
|
/** Data of axis */
|
||||||
enum {
|
enum {
|
||||||
LV_CHART_AXIS_SKIP_LAST_TICK = 0x00, /**< don't draw the last tick */
|
LV_CHART_AXIS_SKIP_LAST_TICK = 0x00, /**< don't draw the last tick */
|
||||||
LV_CHART_AXIS_DRAW_LAST_TICK = 0x01 /**< draw the last tick */
|
LV_CHART_AXIS_DRAW_LAST_TICK = 0x01, /**< draw the last tick */
|
||||||
|
LV_CHART_AXIS_INVERSE_LABELS_ORDER = 0x02 /**< draw tick labels in an inversed order*/
|
||||||
};
|
};
|
||||||
typedef uint8_t lv_chart_axis_options_t;
|
typedef uint8_t lv_chart_axis_options_t;
|
||||||
|
|
||||||
@@ -94,6 +95,7 @@ typedef struct
|
|||||||
lv_chart_type_t type; /*Line, column or point chart (from 'lv_chart_type_t')*/
|
lv_chart_type_t type; /*Line, column or point chart (from 'lv_chart_type_t')*/
|
||||||
lv_chart_axis_cfg_t y_axis;
|
lv_chart_axis_cfg_t y_axis;
|
||||||
lv_chart_axis_cfg_t x_axis;
|
lv_chart_axis_cfg_t x_axis;
|
||||||
|
lv_chart_axis_cfg_t secondary_y_axis;
|
||||||
uint16_t margin;
|
uint16_t margin;
|
||||||
uint8_t update_mode : 1;
|
uint8_t update_mode : 1;
|
||||||
struct
|
struct
|
||||||
@@ -260,6 +262,16 @@ void lv_chart_set_x_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_
|
|||||||
*/
|
*/
|
||||||
void lv_chart_set_y_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_t minor_tick_len);
|
void lv_chart_set_y_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_t minor_tick_len);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the length of the tick marks on the secondary y axis
|
||||||
|
* @param chart pointer to the chart
|
||||||
|
* @param major_tick_len the length of the major tick or `LV_CHART_TICK_LENGTH_AUTO` to set automatically
|
||||||
|
* (where labels are added)
|
||||||
|
* @param minor_tick_len the length of the minor tick, `LV_CHART_TICK_LENGTH_AUTO` to set automatically
|
||||||
|
* (where no labels are added)
|
||||||
|
*/
|
||||||
|
void lv_chart_set_secondary_y_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_t minor_tick_len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the x-axis tick count and labels of a chart
|
* Set the x-axis tick count and labels of a chart
|
||||||
* @param chart pointer to a chart object
|
* @param chart pointer to a chart object
|
||||||
@@ -271,6 +283,17 @@ void lv_chart_set_y_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_
|
|||||||
void lv_chart_set_x_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
|
void lv_chart_set_x_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
|
||||||
lv_chart_axis_options_t options);
|
lv_chart_axis_options_t options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the secondary y-axis tick count and labels of a chart
|
||||||
|
* @param chart pointer to a chart object
|
||||||
|
* @param list_of_values list of string values, terminated with \n, except the last
|
||||||
|
* @param num_tick_marks if list_of_values is NULL: total number of ticks per axis
|
||||||
|
* else number of ticks between two value labels
|
||||||
|
* @param options extra options
|
||||||
|
*/
|
||||||
|
void lv_chart_set_secondary_y_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
|
||||||
|
lv_chart_axis_options_t options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the y-axis tick count and labels of a chart
|
* Set the y-axis tick count and labels of a chart
|
||||||
* @param chart pointer to a chart object
|
* @param chart pointer to a chart object
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
#include "../lv_draw/lv_draw_mask.h"
|
#include "../lv_draw/lv_draw_mask.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
@@ -24,6 +25,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_cont"
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -69,7 +71,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create a basic object*/
|
/*Create a basic object*/
|
||||||
lv_obj_t * new_cont = lv_obj_create(par, copy);
|
lv_obj_t * new_cont = lv_obj_create(par, copy);
|
||||||
lv_mem_assert(new_cont);
|
LV_ASSERT_MEM(new_cont);
|
||||||
if(new_cont == NULL) return NULL;
|
if(new_cont == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_cont);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_cont);
|
||||||
@@ -79,7 +81,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(new_cont);
|
lv_cont_ext_t * ext = lv_obj_get_ext_attr(new_cont);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
ext->fit_left = LV_FIT_NONE;
|
ext->fit_left = LV_FIT_NONE;
|
||||||
ext->fit_right = LV_FIT_NONE;
|
ext->fit_right = LV_FIT_NONE;
|
||||||
ext->fit_top = LV_FIT_NONE;
|
ext->fit_top = LV_FIT_NONE;
|
||||||
@@ -130,6 +132,8 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout)
|
void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(cont, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||||
if(ext->layout == layout) return;
|
if(ext->layout == layout) return;
|
||||||
|
|
||||||
@@ -150,6 +154,8 @@ void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout)
|
|||||||
*/
|
*/
|
||||||
void lv_cont_set_fit4(lv_obj_t * cont, lv_fit_t left, lv_fit_t right, lv_fit_t top, lv_fit_t bottom)
|
void lv_cont_set_fit4(lv_obj_t * cont, lv_fit_t left, lv_fit_t right, lv_fit_t top, lv_fit_t bottom)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(cont, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_obj_invalidate(cont);
|
lv_obj_invalidate(cont);
|
||||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||||
if(ext->fit_left == left && ext->fit_right == right && ext->fit_top == top && ext->fit_bottom == bottom) {
|
if(ext->fit_left == left && ext->fit_right == right && ext->fit_top == top && ext->fit_bottom == bottom) {
|
||||||
@@ -176,6 +182,8 @@ void lv_cont_set_fit4(lv_obj_t * cont, lv_fit_t left, lv_fit_t right, lv_fit_t t
|
|||||||
*/
|
*/
|
||||||
lv_layout_t lv_cont_get_layout(const lv_obj_t * cont)
|
lv_layout_t lv_cont_get_layout(const lv_obj_t * cont)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(cont, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||||
return ext->layout;
|
return ext->layout;
|
||||||
}
|
}
|
||||||
@@ -187,6 +195,8 @@ lv_layout_t lv_cont_get_layout(const lv_obj_t * cont)
|
|||||||
*/
|
*/
|
||||||
lv_fit_t lv_cont_get_fit_left(const lv_obj_t * cont)
|
lv_fit_t lv_cont_get_fit_left(const lv_obj_t * cont)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(cont, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||||
return ext->fit_left;
|
return ext->fit_left;
|
||||||
}
|
}
|
||||||
@@ -198,6 +208,8 @@ lv_fit_t lv_cont_get_fit_left(const lv_obj_t * cont)
|
|||||||
*/
|
*/
|
||||||
lv_fit_t lv_cont_get_fit_right(const lv_obj_t * cont)
|
lv_fit_t lv_cont_get_fit_right(const lv_obj_t * cont)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(cont, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||||
return ext->fit_right;
|
return ext->fit_right;
|
||||||
}
|
}
|
||||||
@@ -209,6 +221,8 @@ lv_fit_t lv_cont_get_fit_right(const lv_obj_t * cont)
|
|||||||
*/
|
*/
|
||||||
lv_fit_t lv_cont_get_fit_top(const lv_obj_t * cont)
|
lv_fit_t lv_cont_get_fit_top(const lv_obj_t * cont)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(cont, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||||
return ext->fit_top;
|
return ext->fit_top;
|
||||||
}
|
}
|
||||||
@@ -220,6 +234,8 @@ lv_fit_t lv_cont_get_fit_top(const lv_obj_t * cont)
|
|||||||
*/
|
*/
|
||||||
lv_fit_t lv_cont_get_fit_bottom(const lv_obj_t * cont)
|
lv_fit_t lv_cont_get_fit_bottom(const lv_obj_t * cont)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(cont, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||||
return ext->fit_bottom;
|
return ext->fit_bottom;
|
||||||
}
|
}
|
||||||
@@ -277,6 +293,7 @@ static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(cont, sign, param);
|
res = ancestor_signal(cont, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_STYLE_CHG) { /*Recalculate the padding if the style changed*/
|
if(sign == LV_SIGNAL_STYLE_CHG) { /*Recalculate the padding if the style changed*/
|
||||||
lv_cont_refr_layout(cont);
|
lv_cont_refr_layout(cont);
|
||||||
@@ -293,13 +310,6 @@ static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
|
|||||||
/*FLOOD and FILL fit needs to be refreshed if the parent size has changed*/
|
/*FLOOD and FILL fit needs to be refreshed if the parent size has changed*/
|
||||||
lv_cont_refr_autofit(cont);
|
lv_cont_refr_autofit(cont);
|
||||||
|
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_cont";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "lv_ddlist.h"
|
#include "lv_ddlist.h"
|
||||||
#if LV_USE_DDLIST != 0
|
#if LV_USE_DDLIST != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
#include "../lv_core/lv_group.h"
|
#include "../lv_core/lv_group.h"
|
||||||
#include "../lv_core/lv_indev.h"
|
#include "../lv_core/lv_indev.h"
|
||||||
@@ -21,6 +22,8 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_ddlist"
|
||||||
|
|
||||||
#if LV_USE_ANIMATION == 0
|
#if LV_USE_ANIMATION == 0
|
||||||
#undef LV_DDLIST_DEF_ANIM_TIME
|
#undef LV_DDLIST_DEF_ANIM_TIME
|
||||||
#define LV_DDLIST_DEF_ANIM_TIME 0 /*No animation*/
|
#define LV_DDLIST_DEF_ANIM_TIME 0 /*No animation*/
|
||||||
@@ -74,7 +77,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor drop down list*/
|
/*Create the ancestor drop down list*/
|
||||||
lv_obj_t * new_ddlist = lv_page_create(par, copy);
|
lv_obj_t * new_ddlist = lv_page_create(par, copy);
|
||||||
lv_mem_assert(new_ddlist);
|
LV_ASSERT_MEM(new_ddlist);
|
||||||
if(new_ddlist == NULL) return NULL;
|
if(new_ddlist == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_ddlist);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_ddlist);
|
||||||
@@ -83,7 +86,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Allocate the drop down list type specific extended data*/
|
/*Allocate the drop down list type specific extended data*/
|
||||||
lv_ddlist_ext_t * ext = lv_obj_allocate_ext_attr(new_ddlist, sizeof(lv_ddlist_ext_t));
|
lv_ddlist_ext_t * ext = lv_obj_allocate_ext_attr(new_ddlist, sizeof(lv_ddlist_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
/*Initialize the allocated 'ext' */
|
/*Initialize the allocated 'ext' */
|
||||||
@@ -164,6 +167,9 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_ddlist_set_options(lv_obj_t * ddlist, const char * options)
|
void lv_ddlist_set_options(lv_obj_t * ddlist, const char * options)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_STR(options);
|
||||||
|
|
||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
|
|
||||||
/*Count the '\n'-s to determine the number of options*/
|
/*Count the '\n'-s to determine the number of options*/
|
||||||
@@ -196,6 +202,8 @@ void lv_ddlist_set_options(lv_obj_t * ddlist, const char * options)
|
|||||||
*/
|
*/
|
||||||
void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt)
|
void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
if(ext->sel_opt_id == sel_opt) return;
|
if(ext->sel_opt_id == sel_opt) return;
|
||||||
|
|
||||||
@@ -217,6 +225,8 @@ void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt)
|
|||||||
*/
|
*/
|
||||||
void lv_ddlist_set_fix_height(lv_obj_t * ddlist, lv_coord_t h)
|
void lv_ddlist_set_fix_height(lv_obj_t * ddlist, lv_coord_t h)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
if(ext->fix_height == h) return;
|
if(ext->fix_height == h) return;
|
||||||
|
|
||||||
@@ -232,6 +242,8 @@ void lv_ddlist_set_fix_height(lv_obj_t * ddlist, lv_coord_t h)
|
|||||||
*/
|
*/
|
||||||
void lv_ddlist_set_fix_width(lv_obj_t * ddlist, lv_coord_t w)
|
void lv_ddlist_set_fix_width(lv_obj_t * ddlist, lv_coord_t w)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
if(w == 0) {
|
if(w == 0) {
|
||||||
lv_cont_set_fit2(ddlist, LV_FIT_TIGHT, lv_cont_get_fit_bottom(ddlist));
|
lv_cont_set_fit2(ddlist, LV_FIT_TIGHT, lv_cont_get_fit_bottom(ddlist));
|
||||||
@@ -256,6 +268,8 @@ void lv_ddlist_set_fix_width(lv_obj_t * ddlist, lv_coord_t w)
|
|||||||
*/
|
*/
|
||||||
void lv_ddlist_set_draw_arrow(lv_obj_t * ddlist, bool en)
|
void lv_ddlist_set_draw_arrow(lv_obj_t * ddlist, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
|
|
||||||
/*Set the flag*/
|
/*Set the flag*/
|
||||||
@@ -269,6 +283,8 @@ void lv_ddlist_set_draw_arrow(lv_obj_t * ddlist, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_ddlist_set_stay_open(lv_obj_t * ddlist, bool en)
|
void lv_ddlist_set_stay_open(lv_obj_t * ddlist, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
|
|
||||||
/*Set the flag*/
|
/*Set the flag*/
|
||||||
@@ -283,6 +299,8 @@ void lv_ddlist_set_stay_open(lv_obj_t * ddlist, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_ddlist_set_style(lv_obj_t * ddlist, lv_ddlist_style_t type, const lv_style_t * style)
|
void lv_ddlist_set_style(lv_obj_t * ddlist, lv_ddlist_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -301,6 +319,8 @@ void lv_ddlist_set_style(lv_obj_t * ddlist, lv_ddlist_style_t type, const lv_sty
|
|||||||
|
|
||||||
void lv_ddlist_set_align(lv_obj_t * ddlist, lv_label_align_t align)
|
void lv_ddlist_set_align(lv_obj_t * ddlist, lv_label_align_t align)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
|
|
||||||
lv_label_set_align(ext->label, align);
|
lv_label_set_align(ext->label, align);
|
||||||
@@ -321,6 +341,8 @@ void lv_ddlist_set_align(lv_obj_t * ddlist, lv_label_align_t align)
|
|||||||
*/
|
*/
|
||||||
const char * lv_ddlist_get_options(const lv_obj_t * ddlist)
|
const char * lv_ddlist_get_options(const lv_obj_t * ddlist)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
return lv_label_get_text(ext->label);
|
return lv_label_get_text(ext->label);
|
||||||
}
|
}
|
||||||
@@ -332,6 +354,8 @@ const char * lv_ddlist_get_options(const lv_obj_t * ddlist)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_ddlist_get_selected(const lv_obj_t * ddlist)
|
uint16_t lv_ddlist_get_selected(const lv_obj_t * ddlist)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
|
|
||||||
return ext->sel_opt_id;
|
return ext->sel_opt_id;
|
||||||
@@ -345,6 +369,8 @@ uint16_t lv_ddlist_get_selected(const lv_obj_t * ddlist)
|
|||||||
*/
|
*/
|
||||||
void lv_ddlist_get_selected_str(const lv_obj_t * ddlist, char * buf, uint16_t buf_size)
|
void lv_ddlist_get_selected_str(const lv_obj_t * ddlist, char * buf, uint16_t buf_size)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
|
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
@@ -375,6 +401,8 @@ void lv_ddlist_get_selected_str(const lv_obj_t * ddlist, char * buf, uint16_t bu
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_ddlist_get_fix_height(const lv_obj_t * ddlist)
|
lv_coord_t lv_ddlist_get_fix_height(const lv_obj_t * ddlist)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
return ext->fix_height;
|
return ext->fix_height;
|
||||||
}
|
}
|
||||||
@@ -385,6 +413,8 @@ lv_coord_t lv_ddlist_get_fix_height(const lv_obj_t * ddlist)
|
|||||||
*/
|
*/
|
||||||
bool lv_ddlist_get_draw_arrow(lv_obj_t * ddlist)
|
bool lv_ddlist_get_draw_arrow(lv_obj_t * ddlist)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
|
|
||||||
return ext->draw_arrow ? true : false;
|
return ext->draw_arrow ? true : false;
|
||||||
@@ -396,6 +426,8 @@ bool lv_ddlist_get_draw_arrow(lv_obj_t * ddlist)
|
|||||||
*/
|
*/
|
||||||
bool lv_ddlist_get_stay_open(lv_obj_t * ddlist)
|
bool lv_ddlist_get_stay_open(lv_obj_t * ddlist)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
|
|
||||||
return ext->stay_open ? true : false;
|
return ext->stay_open ? true : false;
|
||||||
@@ -409,6 +441,8 @@ bool lv_ddlist_get_stay_open(lv_obj_t * ddlist)
|
|||||||
*/
|
*/
|
||||||
const lv_style_t * lv_ddlist_get_style(const lv_obj_t * ddlist, lv_ddlist_style_t type)
|
const lv_style_t * lv_ddlist_get_style(const lv_obj_t * ddlist, lv_ddlist_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -622,6 +656,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(ddlist, sign, param);
|
res = ancestor_signal(ddlist, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
|
|
||||||
@@ -700,13 +735,6 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
|||||||
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
||||||
bool * editable = (bool *)param;
|
bool * editable = (bool *)param;
|
||||||
*editable = true;
|
*editable = true;
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_ddlist";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "lv_gauge.h"
|
#include "lv_gauge.h"
|
||||||
#if LV_USE_GAUGE != 0
|
#if LV_USE_GAUGE != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
#include "../lv_misc/lv_txt.h"
|
#include "../lv_misc/lv_txt.h"
|
||||||
@@ -20,6 +21,8 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_gauge"
|
||||||
|
|
||||||
#define LV_GAUGE_DEF_NEEDLE_COLOR LV_COLOR_RED
|
#define LV_GAUGE_DEF_NEEDLE_COLOR LV_COLOR_RED
|
||||||
#define LV_GAUGE_DEF_LABEL_COUNT 6
|
#define LV_GAUGE_DEF_LABEL_COUNT 6
|
||||||
#define LV_GAUGE_DEF_LINE_COUNT 21 /*Should be: ((label_cnt - 1) * internal_lines) + 1*/
|
#define LV_GAUGE_DEF_LINE_COUNT 21 /*Should be: ((label_cnt - 1) * internal_lines) + 1*/
|
||||||
@@ -65,12 +68,12 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor gauge*/
|
/*Create the ancestor gauge*/
|
||||||
lv_obj_t * new_gauge = lv_lmeter_create(par, copy);
|
lv_obj_t * new_gauge = lv_lmeter_create(par, copy);
|
||||||
lv_mem_assert(new_gauge);
|
LV_ASSERT_MEM(new_gauge);
|
||||||
if(new_gauge == NULL) return NULL;
|
if(new_gauge == NULL) return NULL;
|
||||||
|
|
||||||
/*Allocate the gauge type specific extended data*/
|
/*Allocate the gauge type specific extended data*/
|
||||||
lv_gauge_ext_t * ext = lv_obj_allocate_ext_attr(new_gauge, sizeof(lv_gauge_ext_t));
|
lv_gauge_ext_t * ext = lv_obj_allocate_ext_attr(new_gauge, sizeof(lv_gauge_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
/*Initialize the allocated 'ext' */
|
/*Initialize the allocated 'ext' */
|
||||||
@@ -131,6 +134,9 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_color_t colors[])
|
void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_color_t colors[])
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(colors);
|
||||||
|
|
||||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||||
|
|
||||||
if(ext->needle_count != needle_cnt) {
|
if(ext->needle_count != needle_cnt) {
|
||||||
@@ -140,7 +146,7 @@ void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_co
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext->values = lv_mem_realloc(ext->values, needle_cnt * sizeof(int16_t));
|
ext->values = lv_mem_realloc(ext->values, needle_cnt * sizeof(int16_t));
|
||||||
lv_mem_assert(ext->values);
|
LV_ASSERT_MEM(ext->values);
|
||||||
if(ext->values == NULL) return;
|
if(ext->values == NULL) return;
|
||||||
|
|
||||||
int16_t min = lv_gauge_get_min_value(gauge);
|
int16_t min = lv_gauge_get_min_value(gauge);
|
||||||
@@ -164,6 +170,8 @@ void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_co
|
|||||||
*/
|
*/
|
||||||
void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int16_t value)
|
void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int16_t value)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||||
|
|
||||||
if(needle_id >= ext->needle_count) return;
|
if(needle_id >= ext->needle_count) return;
|
||||||
@@ -193,6 +201,8 @@ void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int16_t value)
|
|||||||
*/
|
*/
|
||||||
void lv_gauge_set_scale(lv_obj_t * gauge, uint16_t angle, uint8_t line_cnt, uint8_t label_cnt)
|
void lv_gauge_set_scale(lv_obj_t * gauge, uint16_t angle, uint8_t line_cnt, uint8_t label_cnt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_lmeter_set_scale(gauge, angle, line_cnt);
|
lv_lmeter_set_scale(gauge, angle, line_cnt);
|
||||||
|
|
||||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||||
@@ -212,6 +222,8 @@ void lv_gauge_set_scale(lv_obj_t * gauge, uint16_t angle, uint8_t line_cnt, uint
|
|||||||
*/
|
*/
|
||||||
int16_t lv_gauge_get_value(const lv_obj_t * gauge, uint8_t needle)
|
int16_t lv_gauge_get_value(const lv_obj_t * gauge, uint8_t needle)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||||
int16_t min = lv_gauge_get_min_value(gauge);
|
int16_t min = lv_gauge_get_min_value(gauge);
|
||||||
|
|
||||||
@@ -227,6 +239,8 @@ int16_t lv_gauge_get_value(const lv_obj_t * gauge, uint8_t needle)
|
|||||||
*/
|
*/
|
||||||
uint8_t lv_gauge_get_needle_count(const lv_obj_t * gauge)
|
uint8_t lv_gauge_get_needle_count(const lv_obj_t * gauge)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||||
return ext->needle_count;
|
return ext->needle_count;
|
||||||
}
|
}
|
||||||
@@ -238,6 +252,8 @@ uint8_t lv_gauge_get_needle_count(const lv_obj_t * gauge)
|
|||||||
*/
|
*/
|
||||||
uint8_t lv_gauge_get_label_count(const lv_obj_t * gauge)
|
uint8_t lv_gauge_get_label_count(const lv_obj_t * gauge)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||||
return ext->label_count;
|
return ext->label_count;
|
||||||
}
|
}
|
||||||
@@ -258,7 +274,6 @@ uint8_t lv_gauge_get_label_count(const lv_obj_t * gauge)
|
|||||||
*/
|
*/
|
||||||
static lv_design_res_t lv_gauge_design(lv_obj_t * gauge, const lv_area_t * clip_area, lv_design_mode_t mode)
|
static lv_design_res_t lv_gauge_design(lv_obj_t * gauge, const lv_area_t * clip_area, lv_design_mode_t mode)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*Return false if the object is not covers the mask_p area*/
|
/*Return false if the object is not covers the mask_p area*/
|
||||||
if(mode == LV_DESIGN_COVER_CHK) {
|
if(mode == LV_DESIGN_COVER_CHK) {
|
||||||
return LV_DESIGN_RES_NOT_COVER;
|
return LV_DESIGN_RES_NOT_COVER;
|
||||||
@@ -317,18 +332,12 @@ static lv_res_t lv_gauge_signal(lv_obj_t * gauge, lv_signal_t sign, void * param
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(gauge, sign, param);
|
res = ancestor_signal(gauge, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
lv_mem_free(ext->values);
|
lv_mem_free(ext->values);
|
||||||
ext->values = NULL;
|
ext->values = NULL;
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_gauge";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#error "lv_img: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1) "
|
#error "lv_img: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1) "
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
#include "../lv_draw/lv_img_decoder.h"
|
#include "../lv_draw/lv_img_decoder.h"
|
||||||
#include "../lv_misc/lv_fs.h"
|
#include "../lv_misc/lv_fs.h"
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_img"
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -61,14 +63,14 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create a basic object*/
|
/*Create a basic object*/
|
||||||
new_img = lv_obj_create(par, copy);
|
new_img = lv_obj_create(par, copy);
|
||||||
lv_mem_assert(new_img);
|
LV_ASSERT_MEM(new_img);
|
||||||
if(new_img == NULL) return NULL;
|
if(new_img == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_img);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_img);
|
||||||
|
|
||||||
/*Extend the basic object to image object*/
|
/*Extend the basic object to image object*/
|
||||||
lv_img_ext_t * ext = lv_obj_allocate_ext_attr(new_img, sizeof(lv_img_ext_t));
|
lv_img_ext_t * ext = lv_obj_allocate_ext_attr(new_img, sizeof(lv_img_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
ext->src = NULL;
|
ext->src = NULL;
|
||||||
@@ -121,6 +123,8 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_img_set_src(lv_obj_t * img, const void * src_img)
|
void lv_img_set_src(lv_obj_t * img, const void * src_img)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(img, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_img_src_t src_type = lv_img_src_get_type(src_img);
|
lv_img_src_t src_type = lv_img_src_get_type(src_img);
|
||||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||||
|
|
||||||
@@ -164,7 +168,7 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
|
|||||||
lv_mem_free(ext->src);
|
lv_mem_free(ext->src);
|
||||||
}
|
}
|
||||||
char * new_str = lv_mem_alloc(strlen(src_img) + 1);
|
char * new_str = lv_mem_alloc(strlen(src_img) + 1);
|
||||||
lv_mem_assert(new_str);
|
LV_ASSERT_MEM(new_str);
|
||||||
if(new_str == NULL) return;
|
if(new_str == NULL) return;
|
||||||
strcpy(new_str, src_img);
|
strcpy(new_str, src_img);
|
||||||
ext->src = new_str;
|
ext->src = new_str;
|
||||||
@@ -201,6 +205,8 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
|
|||||||
*/
|
*/
|
||||||
void lv_img_set_auto_size(lv_obj_t * img, bool en)
|
void lv_img_set_auto_size(lv_obj_t * img, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(img, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||||
|
|
||||||
ext->auto_size = (en == false ? 0 : 1);
|
ext->auto_size = (en == false ? 0 : 1);
|
||||||
@@ -214,6 +220,8 @@ void lv_img_set_auto_size(lv_obj_t * img, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_img_set_offset_x(lv_obj_t * img, lv_coord_t x)
|
void lv_img_set_offset_x(lv_obj_t * img, lv_coord_t x)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(img, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||||
|
|
||||||
if(x < ext->w - 1) {
|
if(x < ext->w - 1) {
|
||||||
@@ -230,6 +238,8 @@ void lv_img_set_offset_x(lv_obj_t * img, lv_coord_t x)
|
|||||||
*/
|
*/
|
||||||
void lv_img_set_offset_y(lv_obj_t * img, lv_coord_t y)
|
void lv_img_set_offset_y(lv_obj_t * img, lv_coord_t y)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(img, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||||
|
|
||||||
if(y < ext->h - 1) {
|
if(y < ext->h - 1) {
|
||||||
@@ -249,6 +259,8 @@ void lv_img_set_offset_y(lv_obj_t * img, lv_coord_t y)
|
|||||||
*/
|
*/
|
||||||
const void * lv_img_get_src(lv_obj_t * img)
|
const void * lv_img_get_src(lv_obj_t * img)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(img, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||||
|
|
||||||
return ext->src;
|
return ext->src;
|
||||||
@@ -261,6 +273,8 @@ const void * lv_img_get_src(lv_obj_t * img)
|
|||||||
*/
|
*/
|
||||||
const char * lv_img_get_file_name(const lv_obj_t * img)
|
const char * lv_img_get_file_name(const lv_obj_t * img)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(img, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||||
|
|
||||||
if(ext->src_type == LV_IMG_SRC_FILE)
|
if(ext->src_type == LV_IMG_SRC_FILE)
|
||||||
@@ -276,6 +290,8 @@ const char * lv_img_get_file_name(const lv_obj_t * img)
|
|||||||
*/
|
*/
|
||||||
bool lv_img_get_auto_size(const lv_obj_t * img)
|
bool lv_img_get_auto_size(const lv_obj_t * img)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(img, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||||
|
|
||||||
return ext->auto_size == 0 ? false : true;
|
return ext->auto_size == 0 ? false : true;
|
||||||
@@ -288,6 +304,8 @@ bool lv_img_get_auto_size(const lv_obj_t * img)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_img_get_offset_x(lv_obj_t * img)
|
lv_coord_t lv_img_get_offset_x(lv_obj_t * img)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(img, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||||
|
|
||||||
return ext->offset.x;
|
return ext->offset.x;
|
||||||
@@ -300,6 +318,8 @@ lv_coord_t lv_img_get_offset_x(lv_obj_t * img)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_img_get_offset_y(lv_obj_t * img)
|
lv_coord_t lv_img_get_offset_y(lv_obj_t * img)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(img, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||||
|
|
||||||
return ext->offset.y;
|
return ext->offset.y;
|
||||||
@@ -387,6 +407,8 @@ static lv_res_t lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param)
|
|||||||
res = ancestor_signal(img, sign, param);
|
res = ancestor_signal(img, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
if(ext->src_type == LV_IMG_SRC_FILE || ext->src_type == LV_IMG_SRC_SYMBOL) {
|
if(ext->src_type == LV_IMG_SRC_FILE || ext->src_type == LV_IMG_SRC_SYMBOL) {
|
||||||
@@ -399,13 +421,6 @@ static lv_res_t lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param)
|
|||||||
if(ext->src_type == LV_IMG_SRC_SYMBOL) {
|
if(ext->src_type == LV_IMG_SRC_SYMBOL) {
|
||||||
lv_img_set_src(img, ext->src);
|
lv_img_set_src(img, ext->src);
|
||||||
}
|
}
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_img";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -6,12 +6,16 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* INCLUDES
|
* INCLUDES
|
||||||
*********************/
|
*********************/
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "lv_imgbtn.h"
|
#include "lv_imgbtn.h"
|
||||||
|
|
||||||
#if LV_USE_IMGBTN != 0
|
#if LV_USE_IMGBTN != 0
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_imgbtn"
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -51,12 +55,12 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor of image button*/
|
/*Create the ancestor of image button*/
|
||||||
lv_obj_t * new_imgbtn = lv_btn_create(par, copy);
|
lv_obj_t * new_imgbtn = lv_btn_create(par, copy);
|
||||||
lv_mem_assert(new_imgbtn);
|
LV_ASSERT_MEM(new_imgbtn);
|
||||||
if(new_imgbtn == NULL) return NULL;
|
if(new_imgbtn == NULL) return NULL;
|
||||||
|
|
||||||
/*Allocate the image button type specific extended data*/
|
/*Allocate the image button type specific extended data*/
|
||||||
lv_imgbtn_ext_t * ext = lv_obj_allocate_ext_attr(new_imgbtn, sizeof(lv_imgbtn_ext_t));
|
lv_imgbtn_ext_t * ext = lv_obj_allocate_ext_attr(new_imgbtn, sizeof(lv_imgbtn_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_imgbtn);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_imgbtn);
|
||||||
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_imgbtn);
|
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_imgbtn);
|
||||||
@@ -112,6 +116,8 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src)
|
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(imgbtn, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
|
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
|
||||||
|
|
||||||
ext->img_src[state] = src;
|
ext->img_src[state] = src;
|
||||||
@@ -134,6 +140,8 @@ void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src
|
|||||||
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src_left, const void * src_mid,
|
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src_left, const void * src_mid,
|
||||||
const void * src_right)
|
const void * src_right)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(imgbtn, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
|
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
|
||||||
|
|
||||||
ext->img_src_left[state] = src_left;
|
ext->img_src_left[state] = src_left;
|
||||||
@@ -153,6 +161,8 @@ void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src
|
|||||||
*/
|
*/
|
||||||
void lv_imgbtn_set_style(lv_obj_t * imgbtn, lv_imgbtn_style_t type, const lv_style_t * style)
|
void lv_imgbtn_set_style(lv_obj_t * imgbtn, lv_imgbtn_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(imgbtn, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_btn_set_style(imgbtn, type, style);
|
lv_btn_set_style(imgbtn, type, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,6 +179,8 @@ void lv_imgbtn_set_style(lv_obj_t * imgbtn, lv_imgbtn_style_t type, const lv_sty
|
|||||||
*/
|
*/
|
||||||
const void * lv_imgbtn_get_src(lv_obj_t * imgbtn, lv_btn_state_t state)
|
const void * lv_imgbtn_get_src(lv_obj_t * imgbtn, lv_btn_state_t state)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(imgbtn, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
|
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
|
||||||
|
|
||||||
return ext->img_src[state];
|
return ext->img_src[state];
|
||||||
@@ -183,6 +195,8 @@ const void * lv_imgbtn_get_src(lv_obj_t * imgbtn, lv_btn_state_t state)
|
|||||||
*/
|
*/
|
||||||
const void * lv_imgbtn_get_src_left(lv_obj_t * imgbtn, lv_btn_state_t state)
|
const void * lv_imgbtn_get_src_left(lv_obj_t * imgbtn, lv_btn_state_t state)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(imgbtn, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
|
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
|
||||||
|
|
||||||
return ext->img_src_left[state];
|
return ext->img_src_left[state];
|
||||||
@@ -196,6 +210,8 @@ const void * lv_imgbtn_get_src_left(lv_obj_t * imgbtn, lv_btn_state_t state)
|
|||||||
*/
|
*/
|
||||||
const void * lv_imgbtn_get_src_middle(lv_obj_t * imgbtn, lv_btn_state_t state)
|
const void * lv_imgbtn_get_src_middle(lv_obj_t * imgbtn, lv_btn_state_t state)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(imgbtn, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
|
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
|
||||||
|
|
||||||
return ext->img_src_mid[state];
|
return ext->img_src_mid[state];
|
||||||
@@ -209,6 +225,8 @@ const void * lv_imgbtn_get_src_middle(lv_obj_t * imgbtn, lv_btn_state_t state)
|
|||||||
*/
|
*/
|
||||||
const void * lv_imgbtn_get_src_right(lv_obj_t * imgbtn, lv_btn_state_t state)
|
const void * lv_imgbtn_get_src_right(lv_obj_t * imgbtn, lv_btn_state_t state)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(imgbtn, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
|
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
|
||||||
|
|
||||||
return ext->img_src_right[state];
|
return ext->img_src_right[state];
|
||||||
@@ -224,6 +242,8 @@ const void * lv_imgbtn_get_src_right(lv_obj_t * imgbtn, lv_btn_state_t state)
|
|||||||
*/
|
*/
|
||||||
const lv_style_t * lv_imgbtn_get_style(const lv_obj_t * imgbtn, lv_imgbtn_style_t type)
|
const lv_style_t * lv_imgbtn_get_style(const lv_obj_t * imgbtn, lv_imgbtn_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(imgbtn, LV_OBJX_NAME);
|
||||||
|
|
||||||
return lv_btn_get_style(imgbtn, type);
|
return lv_btn_get_style(imgbtn, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,6 +363,7 @@ static lv_res_t lv_imgbtn_signal(lv_obj_t * imgbtn, lv_signal_t sign, void * par
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(imgbtn, sign, param);
|
res = ancestor_signal(imgbtn, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_STYLE_CHG) {
|
if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||||
/* If the style changed then the button was clicked, released etc. so probably the state was
|
/* If the style changed then the button was clicked, released etc. so probably the state was
|
||||||
@@ -350,13 +371,6 @@ static lv_res_t lv_imgbtn_signal(lv_obj_t * imgbtn, lv_signal_t sign, void * par
|
|||||||
refr_img(imgbtn);
|
refr_img(imgbtn);
|
||||||
} else if(sign == LV_SIGNAL_CLEANUP) {
|
} else if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_imgbtn";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -10,12 +10,15 @@
|
|||||||
#include "lv_kb.h"
|
#include "lv_kb.h"
|
||||||
#if LV_USE_KB != 0
|
#if LV_USE_KB != 0
|
||||||
|
|
||||||
#include "lv_ta.h"
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
|
#include "lv_ta.h"
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_kb"
|
||||||
|
|
||||||
#define LV_KB_CTRL_BTN_FLAGS (LV_BTNM_CTRL_NO_REPEAT | LV_BTNM_CTRL_CLICK_TRIG)
|
#define LV_KB_CTRL_BTN_FLAGS (LV_BTNM_CTRL_NO_REPEAT | LV_BTNM_CTRL_CLICK_TRIG)
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
@@ -32,7 +35,7 @@ static lv_res_t lv_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param);
|
|||||||
**********************/
|
**********************/
|
||||||
static lv_signal_cb_t ancestor_signal;
|
static lv_signal_cb_t ancestor_signal;
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
static const char * kb_map_lc[] = {"1#", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "Bksp", "\n",
|
static const char * kb_map_lc[] = {"1#", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", LV_SYMBOL_BACKSPACE, "\n",
|
||||||
"ABC", "a", "s", "d", "f", "g", "h", "j", "k", "l", "Enter", "\n",
|
"ABC", "a", "s", "d", "f", "g", "h", "j", "k", "l", "Enter", "\n",
|
||||||
"_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n",
|
"_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n",
|
||||||
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
|
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
|
||||||
@@ -43,7 +46,7 @@ static const lv_btnm_ctrl_t kb_ctrl_lc_map[] = {
|
|||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};
|
LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};
|
||||||
|
|
||||||
static const char * kb_map_uc[] = {"1#", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "Bksp", "\n",
|
static const char * kb_map_uc[] = {"1#", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", LV_SYMBOL_BACKSPACE, "\n",
|
||||||
"abc", "A", "S", "D", "F", "G", "H", "J", "K", "L", "Enter", "\n",
|
"abc", "A", "S", "D", "F", "G", "H", "J", "K", "L", "Enter", "\n",
|
||||||
"_", "-", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ":", "\n",
|
"_", "-", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ":", "\n",
|
||||||
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
|
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
|
||||||
@@ -54,7 +57,7 @@ static const lv_btnm_ctrl_t kb_ctrl_uc_map[] = {
|
|||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};
|
LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};
|
||||||
|
|
||||||
static const char * kb_map_spec[] = {"0", "1", "2", "3", "4" ,"5", "6", "7", "8", "9", "Bksp", "\n",
|
static const char * kb_map_spec[] = {"0", "1", "2", "3", "4" ,"5", "6", "7", "8", "9", LV_SYMBOL_BACKSPACE, "\n",
|
||||||
"abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
|
"abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
|
||||||
"\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
|
"\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
|
||||||
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
|
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
|
||||||
@@ -67,7 +70,7 @@ static const lv_btnm_ctrl_t kb_ctrl_spec_map[] = {
|
|||||||
|
|
||||||
static const char * kb_map_num[] = {"1", "2", "3", LV_SYMBOL_CLOSE, "\n",
|
static const char * kb_map_num[] = {"1", "2", "3", LV_SYMBOL_CLOSE, "\n",
|
||||||
"4", "5", "6", LV_SYMBOL_OK, "\n",
|
"4", "5", "6", LV_SYMBOL_OK, "\n",
|
||||||
"7", "8", "9", "Bksp", "\n",
|
"7", "8", "9", LV_SYMBOL_BACKSPACE, "\n",
|
||||||
"+/-", "0", ".", LV_SYMBOL_LEFT, LV_SYMBOL_RIGHT, ""};
|
"+/-", "0", ".", LV_SYMBOL_LEFT, LV_SYMBOL_RIGHT, ""};
|
||||||
|
|
||||||
static const lv_btnm_ctrl_t kb_ctrl_num_map[] = {
|
static const lv_btnm_ctrl_t kb_ctrl_num_map[] = {
|
||||||
@@ -97,14 +100,14 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor of keyboard*/
|
/*Create the ancestor of keyboard*/
|
||||||
lv_obj_t * new_kb = lv_btnm_create(par, copy);
|
lv_obj_t * new_kb = lv_btnm_create(par, copy);
|
||||||
lv_mem_assert(new_kb);
|
LV_ASSERT_MEM(new_kb);
|
||||||
if(new_kb == NULL) return NULL;
|
if(new_kb == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_kb);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_kb);
|
||||||
|
|
||||||
/*Allocate the keyboard type specific extended data*/
|
/*Allocate the keyboard type specific extended data*/
|
||||||
lv_kb_ext_t * ext = lv_obj_allocate_ext_attr(new_kb, sizeof(lv_kb_ext_t));
|
lv_kb_ext_t * ext = lv_obj_allocate_ext_attr(new_kb, sizeof(lv_kb_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
/*Initialize the allocated 'ext' */
|
/*Initialize the allocated 'ext' */
|
||||||
@@ -170,6 +173,9 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_kb_set_ta(lv_obj_t * kb, lv_obj_t * ta)
|
void lv_kb_set_ta(lv_obj_t * kb, lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
|
||||||
|
if(ta) LV_ASSERT_OBJ(ta, "lv_ta");
|
||||||
|
|
||||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||||
lv_cursor_type_t cur_type;
|
lv_cursor_type_t cur_type;
|
||||||
|
|
||||||
@@ -195,6 +201,8 @@ void lv_kb_set_ta(lv_obj_t * kb, lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
void lv_kb_set_mode(lv_obj_t * kb, lv_kb_mode_t mode)
|
void lv_kb_set_mode(lv_obj_t * kb, lv_kb_mode_t mode)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||||
if(ext->mode == mode) return;
|
if(ext->mode == mode) return;
|
||||||
|
|
||||||
@@ -215,6 +223,8 @@ void lv_kb_set_mode(lv_obj_t * kb, lv_kb_mode_t mode)
|
|||||||
*/
|
*/
|
||||||
void lv_kb_set_cursor_manage(lv_obj_t * kb, bool en)
|
void lv_kb_set_cursor_manage(lv_obj_t * kb, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||||
if(ext->cursor_mng == en) return;
|
if(ext->cursor_mng == en) return;
|
||||||
|
|
||||||
@@ -240,6 +250,8 @@ void lv_kb_set_cursor_manage(lv_obj_t * kb, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_kb_set_style(lv_obj_t * kb, lv_kb_style_t type, const lv_style_t * style)
|
void lv_kb_set_style(lv_obj_t * kb, lv_kb_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_KB_STYLE_BG: lv_btnm_set_style(kb, LV_BTNM_STYLE_BG, style); break;
|
case LV_KB_STYLE_BG: lv_btnm_set_style(kb, LV_BTNM_STYLE_BG, style); break;
|
||||||
case LV_KB_STYLE_BTN_REL: lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_REL, style); break;
|
case LV_KB_STYLE_BTN_REL: lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_REL, style); break;
|
||||||
@@ -261,6 +273,8 @@ void lv_kb_set_style(lv_obj_t * kb, lv_kb_style_t type, const lv_style_t * style
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_kb_get_ta(const lv_obj_t * kb)
|
lv_obj_t * lv_kb_get_ta(const lv_obj_t * kb)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||||
return ext->ta;
|
return ext->ta;
|
||||||
}
|
}
|
||||||
@@ -272,6 +286,8 @@ lv_obj_t * lv_kb_get_ta(const lv_obj_t * kb)
|
|||||||
*/
|
*/
|
||||||
lv_kb_mode_t lv_kb_get_mode(const lv_obj_t * kb)
|
lv_kb_mode_t lv_kb_get_mode(const lv_obj_t * kb)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||||
return ext->mode;
|
return ext->mode;
|
||||||
}
|
}
|
||||||
@@ -283,6 +299,8 @@ lv_kb_mode_t lv_kb_get_mode(const lv_obj_t * kb)
|
|||||||
*/
|
*/
|
||||||
bool lv_kb_get_cursor_manage(const lv_obj_t * kb)
|
bool lv_kb_get_cursor_manage(const lv_obj_t * kb)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||||
return ext->cursor_mng == 0 ? false : true;
|
return ext->cursor_mng == 0 ? false : true;
|
||||||
}
|
}
|
||||||
@@ -295,6 +313,8 @@ bool lv_kb_get_cursor_manage(const lv_obj_t * kb)
|
|||||||
*/
|
*/
|
||||||
const lv_style_t * lv_kb_get_style(const lv_obj_t * kb, lv_kb_style_t type)
|
const lv_style_t * lv_kb_get_style(const lv_obj_t * kb, lv_kb_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -323,6 +343,8 @@ const lv_style_t * lv_kb_get_style(const lv_obj_t * kb, lv_kb_style_t type)
|
|||||||
*/
|
*/
|
||||||
void lv_kb_def_event_cb(lv_obj_t * kb, lv_event_t event)
|
void lv_kb_def_event_cb(lv_obj_t * kb, lv_event_t event)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(event != LV_EVENT_VALUE_CHANGED) return;
|
if(event != LV_EVENT_VALUE_CHANGED) return;
|
||||||
|
|
||||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||||
@@ -376,7 +398,7 @@ void lv_kb_def_event_cb(lv_obj_t * kb, lv_event_t event)
|
|||||||
lv_ta_cursor_left(ext->ta);
|
lv_ta_cursor_left(ext->ta);
|
||||||
else if(strcmp(txt, LV_SYMBOL_RIGHT) == 0)
|
else if(strcmp(txt, LV_SYMBOL_RIGHT) == 0)
|
||||||
lv_ta_cursor_right(ext->ta);
|
lv_ta_cursor_right(ext->ta);
|
||||||
else if(strcmp(txt, "Bksp") == 0)
|
else if(strcmp(txt, LV_SYMBOL_BACKSPACE) == 0)
|
||||||
lv_ta_del_char(ext->ta);
|
lv_ta_del_char(ext->ta);
|
||||||
else if(strcmp(txt, "+/-") == 0) {
|
else if(strcmp(txt, "+/-") == 0) {
|
||||||
uint16_t cur = lv_ta_get_cursor_pos(ext->ta);
|
uint16_t cur = lv_ta_get_cursor_pos(ext->ta);
|
||||||
@@ -419,6 +441,7 @@ static lv_res_t lv_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param)
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(kb, sign, param);
|
res = ancestor_signal(kb, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||||
@@ -436,13 +459,6 @@ static lv_res_t lv_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param)
|
|||||||
lv_cursor_type_t cur_type = lv_ta_get_cursor_type(ext->ta);
|
lv_cursor_type_t cur_type = lv_ta_get_cursor_type(ext->ta);
|
||||||
lv_ta_set_cursor_type(ext->ta, cur_type | LV_CURSOR_HIDDEN);
|
lv_ta_set_cursor_type(ext->ta, cur_type | LV_CURSOR_HIDDEN);
|
||||||
}
|
}
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_kb";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#if LV_USE_LABEL != 0
|
#if LV_USE_LABEL != 0
|
||||||
|
|
||||||
#include "../lv_core/lv_obj.h"
|
#include "../lv_core/lv_obj.h"
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_core/lv_group.h"
|
#include "../lv_core/lv_group.h"
|
||||||
#include "../lv_misc/lv_color.h"
|
#include "../lv_misc/lv_color.h"
|
||||||
#include "../lv_misc/lv_math.h"
|
#include "../lv_misc/lv_math.h"
|
||||||
@@ -18,6 +19,8 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_label"
|
||||||
|
|
||||||
/*Test configurations*/
|
/*Test configurations*/
|
||||||
#ifndef LV_LABEL_DEF_SCROLL_SPEED
|
#ifndef LV_LABEL_DEF_SCROLL_SPEED
|
||||||
#define LV_LABEL_DEF_SCROLL_SPEED (25)
|
#define LV_LABEL_DEF_SCROLL_SPEED (25)
|
||||||
@@ -73,7 +76,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create a basic object*/
|
/*Create a basic object*/
|
||||||
lv_obj_t * new_label = lv_obj_create(par, copy);
|
lv_obj_t * new_label = lv_obj_create(par, copy);
|
||||||
lv_mem_assert(new_label);
|
LV_ASSERT_MEM(new_label);
|
||||||
if(new_label == NULL) return NULL;
|
if(new_label == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_label);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_label);
|
||||||
@@ -82,7 +85,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
lv_obj_allocate_ext_attr(new_label, sizeof(lv_label_ext_t));
|
lv_obj_allocate_ext_attr(new_label, sizeof(lv_label_ext_t));
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(new_label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(new_label);
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
ext->text = NULL;
|
ext->text = NULL;
|
||||||
@@ -136,7 +139,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
/*In DOT mode save the text byte-to-byte because a '\0' can be in the middle*/
|
/*In DOT mode save the text byte-to-byte because a '\0' can be in the middle*/
|
||||||
if(copy_ext->long_mode == LV_LABEL_LONG_DOT) {
|
if(copy_ext->long_mode == LV_LABEL_LONG_DOT) {
|
||||||
ext->text = lv_mem_realloc(ext->text, lv_mem_get_size(copy_ext->text));
|
ext->text = lv_mem_realloc(ext->text, lv_mem_get_size(copy_ext->text));
|
||||||
lv_mem_assert(ext->text);
|
LV_ASSERT_MEM(ext->text);
|
||||||
if(ext->text == NULL) return NULL;
|
if(ext->text == NULL) return NULL;
|
||||||
memcpy(ext->text, copy_ext->text, lv_mem_get_size(copy_ext->text));
|
memcpy(ext->text, copy_ext->text, lv_mem_get_size(copy_ext->text));
|
||||||
}
|
}
|
||||||
@@ -170,6 +173,8 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_label_set_text(lv_obj_t * label, const char * text)
|
void lv_label_set_text(lv_obj_t * label, const char * text)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_obj_invalidate(label);
|
lv_obj_invalidate(label);
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
@@ -180,10 +185,12 @@ void lv_label_set_text(lv_obj_t * label, const char * text)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LV_ASSERT_STR(text);
|
||||||
|
|
||||||
if(ext->text == text) {
|
if(ext->text == text) {
|
||||||
/*If set its own text then reallocate it (maybe its size changed)*/
|
/*If set its own text then reallocate it (maybe its size changed)*/
|
||||||
ext->text = lv_mem_realloc(ext->text, strlen(ext->text) + 1);
|
ext->text = lv_mem_realloc(ext->text, strlen(ext->text) + 1);
|
||||||
lv_mem_assert(ext->text);
|
LV_ASSERT_MEM(ext->text);
|
||||||
if(ext->text == NULL) return;
|
if(ext->text == NULL) return;
|
||||||
} else {
|
} else {
|
||||||
/*Allocate space for the new text*/
|
/*Allocate space for the new text*/
|
||||||
@@ -194,7 +201,7 @@ void lv_label_set_text(lv_obj_t * label, const char * text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext->text = lv_mem_alloc(len);
|
ext->text = lv_mem_alloc(len);
|
||||||
lv_mem_assert(ext->text);
|
LV_ASSERT_MEM(ext->text);
|
||||||
if(ext->text == NULL) return;
|
if(ext->text == NULL) return;
|
||||||
|
|
||||||
strcpy(ext->text, text);
|
strcpy(ext->text, text);
|
||||||
@@ -211,6 +218,9 @@ void lv_label_set_text(lv_obj_t * label, const char * text)
|
|||||||
*/
|
*/
|
||||||
void lv_label_set_text_fmt(lv_obj_t * label, const char * fmt, ...)
|
void lv_label_set_text_fmt(lv_obj_t * label, const char * fmt, ...)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_STR(fmt);
|
||||||
|
|
||||||
lv_obj_invalidate(label);
|
lv_obj_invalidate(label);
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
@@ -237,7 +247,7 @@ void lv_label_set_text_fmt(lv_obj_t * label, const char * fmt, ...)
|
|||||||
|
|
||||||
|
|
||||||
ext->text = lv_mem_alloc(len+1);
|
ext->text = lv_mem_alloc(len+1);
|
||||||
lv_mem_assert(ext->text);
|
LV_ASSERT_MEM(ext->text);
|
||||||
if(ext->text == NULL) return;
|
if(ext->text == NULL) return;
|
||||||
ext->text[len-1] = 0; /* Ensure NULL termination */
|
ext->text[len-1] = 0; /* Ensure NULL termination */
|
||||||
|
|
||||||
@@ -258,6 +268,8 @@ void lv_label_set_text_fmt(lv_obj_t * label, const char * fmt, ...)
|
|||||||
*/
|
*/
|
||||||
void lv_label_set_array_text(lv_obj_t * label, const char * array, uint16_t size)
|
void lv_label_set_array_text(lv_obj_t * label, const char * array, uint16_t size)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_obj_invalidate(label);
|
lv_obj_invalidate(label);
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
@@ -274,7 +286,7 @@ void lv_label_set_array_text(lv_obj_t * label, const char * array, uint16_t size
|
|||||||
ext->text = NULL;
|
ext->text = NULL;
|
||||||
}
|
}
|
||||||
ext->text = lv_mem_alloc(size + 1);
|
ext->text = lv_mem_alloc(size + 1);
|
||||||
lv_mem_assert(ext->text);
|
LV_ASSERT_MEM(ext->text);
|
||||||
if(ext->text == NULL) return;
|
if(ext->text == NULL) return;
|
||||||
|
|
||||||
memcpy(ext->text, array, size);
|
memcpy(ext->text, array, size);
|
||||||
@@ -292,6 +304,9 @@ void lv_label_set_array_text(lv_obj_t * label, const char * array, uint16_t size
|
|||||||
*/
|
*/
|
||||||
void lv_label_set_static_text(lv_obj_t * label, const char * text)
|
void lv_label_set_static_text(lv_obj_t * label, const char * text)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_STR(text);
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
if(ext->static_txt == 0 && ext->text != NULL) {
|
if(ext->static_txt == 0 && ext->text != NULL) {
|
||||||
lv_mem_free(ext->text);
|
lv_mem_free(ext->text);
|
||||||
@@ -315,6 +330,8 @@ void lv_label_set_static_text(lv_obj_t * label, const char * text)
|
|||||||
*/
|
*/
|
||||||
void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode)
|
void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
@@ -348,6 +365,8 @@ void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode)
|
|||||||
*/
|
*/
|
||||||
void lv_label_set_align(lv_obj_t * label, lv_label_align_t align)
|
void lv_label_set_align(lv_obj_t * label, lv_label_align_t align)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
if(ext->align == align) return;
|
if(ext->align == align) return;
|
||||||
|
|
||||||
@@ -364,6 +383,8 @@ void lv_label_set_align(lv_obj_t * label, lv_label_align_t align)
|
|||||||
*/
|
*/
|
||||||
void lv_label_set_recolor(lv_obj_t * label, bool en)
|
void lv_label_set_recolor(lv_obj_t * label, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
if(ext->recolor == en) return;
|
if(ext->recolor == en) return;
|
||||||
|
|
||||||
@@ -380,6 +401,8 @@ void lv_label_set_recolor(lv_obj_t * label, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_label_set_body_draw(lv_obj_t * label, bool en)
|
void lv_label_set_body_draw(lv_obj_t * label, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
if(ext->body_draw == en) return;
|
if(ext->body_draw == en) return;
|
||||||
|
|
||||||
@@ -397,6 +420,8 @@ void lv_label_set_body_draw(lv_obj_t * label, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_label_set_anim_speed(lv_obj_t * label, uint16_t anim_speed)
|
void lv_label_set_anim_speed(lv_obj_t * label, uint16_t anim_speed)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
if(ext->anim_speed == anim_speed) return;
|
if(ext->anim_speed == anim_speed) return;
|
||||||
@@ -414,6 +439,8 @@ void lv_label_set_anim_speed(lv_obj_t * label, uint16_t anim_speed)
|
|||||||
|
|
||||||
void lv_label_set_text_sel_start(lv_obj_t * label, uint16_t index)
|
void lv_label_set_text_sel_start(lv_obj_t * label, uint16_t index)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SEL
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
ext->txt_sel_start = index;
|
ext->txt_sel_start = index;
|
||||||
@@ -426,6 +453,8 @@ void lv_label_set_text_sel_start(lv_obj_t * label, uint16_t index)
|
|||||||
|
|
||||||
void lv_label_set_text_sel_end(lv_obj_t * label, uint16_t index)
|
void lv_label_set_text_sel_end(lv_obj_t * label, uint16_t index)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SEL
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
ext->txt_sel_end = index;
|
ext->txt_sel_end = index;
|
||||||
@@ -447,6 +476,8 @@ void lv_label_set_text_sel_end(lv_obj_t * label, uint16_t index)
|
|||||||
*/
|
*/
|
||||||
char * lv_label_get_text(const lv_obj_t * label)
|
char * lv_label_get_text(const lv_obj_t * label)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
|
|
||||||
return ext->text;
|
return ext->text;
|
||||||
@@ -459,6 +490,8 @@ char * lv_label_get_text(const lv_obj_t * label)
|
|||||||
*/
|
*/
|
||||||
lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t * label)
|
lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t * label)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
return ext->long_mode;
|
return ext->long_mode;
|
||||||
}
|
}
|
||||||
@@ -470,6 +503,8 @@ lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t * label)
|
|||||||
*/
|
*/
|
||||||
lv_label_align_t lv_label_get_align(const lv_obj_t * label)
|
lv_label_align_t lv_label_get_align(const lv_obj_t * label)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
return ext->align;
|
return ext->align;
|
||||||
}
|
}
|
||||||
@@ -481,6 +516,8 @@ lv_label_align_t lv_label_get_align(const lv_obj_t * label)
|
|||||||
*/
|
*/
|
||||||
bool lv_label_get_recolor(const lv_obj_t * label)
|
bool lv_label_get_recolor(const lv_obj_t * label)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
return ext->recolor == 0 ? false : true;
|
return ext->recolor == 0 ? false : true;
|
||||||
}
|
}
|
||||||
@@ -492,6 +529,8 @@ bool lv_label_get_recolor(const lv_obj_t * label)
|
|||||||
*/
|
*/
|
||||||
bool lv_label_get_body_draw(const lv_obj_t * label)
|
bool lv_label_get_body_draw(const lv_obj_t * label)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
return ext->body_draw == 0 ? false : true;
|
return ext->body_draw == 0 ? false : true;
|
||||||
}
|
}
|
||||||
@@ -503,6 +542,8 @@ bool lv_label_get_body_draw(const lv_obj_t * label)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_label_get_anim_speed(const lv_obj_t * label)
|
uint16_t lv_label_get_anim_speed(const lv_obj_t * label)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
return ext->anim_speed;
|
return ext->anim_speed;
|
||||||
@@ -521,6 +562,9 @@ uint16_t lv_label_get_anim_speed(const lv_obj_t * label)
|
|||||||
*/
|
*/
|
||||||
void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t * pos)
|
void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t * pos)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(pos);
|
||||||
|
|
||||||
const char * txt = lv_label_get_text(label);
|
const char * txt = lv_label_get_text(label);
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
uint32_t line_start = 0;
|
uint32_t line_start = 0;
|
||||||
@@ -590,6 +634,9 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(pos);
|
||||||
|
|
||||||
const char * txt = lv_label_get_text(label);
|
const char * txt = lv_label_get_text(label);
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
uint32_t line_start = 0;
|
uint32_t line_start = 0;
|
||||||
@@ -672,6 +719,8 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_label_get_text_sel_start(const lv_obj_t * label)
|
uint16_t lv_label_get_text_sel_start(const lv_obj_t * label)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SEL
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
return ext->txt_sel_start;
|
return ext->txt_sel_start;
|
||||||
@@ -689,6 +738,8 @@ uint16_t lv_label_get_text_sel_start(const lv_obj_t * label)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_label_get_text_sel_end(const lv_obj_t * label)
|
uint16_t lv_label_get_text_sel_end(const lv_obj_t * label)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SEL
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
return ext->txt_sel_end;
|
return ext->txt_sel_end;
|
||||||
@@ -706,6 +757,9 @@ uint16_t lv_label_get_text_sel_end(const lv_obj_t * label)
|
|||||||
*/
|
*/
|
||||||
bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos)
|
bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(pos);
|
||||||
|
|
||||||
const char * txt = lv_label_get_text(label);
|
const char * txt = lv_label_get_text(label);
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
uint32_t line_start = 0;
|
uint32_t line_start = 0;
|
||||||
@@ -795,6 +849,9 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos)
|
|||||||
*/
|
*/
|
||||||
void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
|
void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_STR(txt);
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
|
|
||||||
/*Can not append to static text*/
|
/*Can not append to static text*/
|
||||||
@@ -807,7 +864,7 @@ void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
|
|||||||
uint32_t ins_len = strlen(txt);
|
uint32_t ins_len = strlen(txt);
|
||||||
uint32_t new_len = ins_len + old_len;
|
uint32_t new_len = ins_len + old_len;
|
||||||
ext->text = lv_mem_realloc(ext->text, new_len + 1);
|
ext->text = lv_mem_realloc(ext->text, new_len + 1);
|
||||||
lv_mem_assert(ext->text);
|
LV_ASSERT_MEM(ext->text);
|
||||||
if(ext->text == NULL) return;
|
if(ext->text == NULL) return;
|
||||||
|
|
||||||
if(pos == LV_LABEL_POS_LAST) {
|
if(pos == LV_LABEL_POS_LAST) {
|
||||||
@@ -828,6 +885,8 @@ void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
|
|||||||
*/
|
*/
|
||||||
void lv_label_cut_text(lv_obj_t * label, uint32_t pos, uint32_t cnt)
|
void lv_label_cut_text(lv_obj_t * label, uint32_t pos, uint32_t cnt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
|
|
||||||
/*Can not append to static text*/
|
/*Can not append to static text*/
|
||||||
@@ -965,6 +1024,7 @@ static lv_res_t lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(label, sign, param);
|
res = ancestor_signal(label, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
@@ -993,13 +1053,6 @@ static lv_res_t lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param
|
|||||||
label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, style->body.padding.top);
|
label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, style->body.padding.top);
|
||||||
label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, style->body.padding.bottom);
|
label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, style->body.padding.bottom);
|
||||||
}
|
}
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_label";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -9,12 +9,15 @@
|
|||||||
#include "lv_led.h"
|
#include "lv_led.h"
|
||||||
#if LV_USE_LED != 0
|
#if LV_USE_LED != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_led"
|
||||||
|
|
||||||
#define LV_LED_WIDTH_DEF (LV_DPI / 3)
|
#define LV_LED_WIDTH_DEF (LV_DPI / 3)
|
||||||
#define LV_LED_HEIGHT_DEF (LV_DPI / 3)
|
#define LV_LED_HEIGHT_DEF (LV_DPI / 3)
|
||||||
#define LV_LED_BRIGHT_OFF 100
|
#define LV_LED_BRIGHT_OFF 100
|
||||||
@@ -56,7 +59,7 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor basic object*/
|
/*Create the ancestor basic object*/
|
||||||
lv_obj_t * new_led = lv_obj_create(par, copy);
|
lv_obj_t * new_led = lv_obj_create(par, copy);
|
||||||
lv_mem_assert(new_led);
|
LV_ASSERT_MEM(new_led);
|
||||||
if(new_led == NULL) return NULL;
|
if(new_led == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_led);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_led);
|
||||||
@@ -64,7 +67,7 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Allocate the object type specific extended data*/
|
/*Allocate the object type specific extended data*/
|
||||||
lv_led_ext_t * ext = lv_obj_allocate_ext_attr(new_led, sizeof(lv_led_ext_t));
|
lv_led_ext_t * ext = lv_obj_allocate_ext_attr(new_led, sizeof(lv_led_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
ext->bright = LV_LED_BRIGHT_ON;
|
ext->bright = LV_LED_BRIGHT_ON;
|
||||||
@@ -109,6 +112,8 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_led_set_bright(lv_obj_t * led, uint8_t bright)
|
void lv_led_set_bright(lv_obj_t * led, uint8_t bright)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(led, LV_OBJX_NAME);
|
||||||
|
|
||||||
/*Set the brightness*/
|
/*Set the brightness*/
|
||||||
lv_led_ext_t * ext = lv_obj_get_ext_attr(led);
|
lv_led_ext_t * ext = lv_obj_get_ext_attr(led);
|
||||||
if(ext->bright == bright) return;
|
if(ext->bright == bright) return;
|
||||||
@@ -125,6 +130,8 @@ void lv_led_set_bright(lv_obj_t * led, uint8_t bright)
|
|||||||
*/
|
*/
|
||||||
void lv_led_on(lv_obj_t * led)
|
void lv_led_on(lv_obj_t * led)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(led, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_led_set_bright(led, LV_LED_BRIGHT_ON);
|
lv_led_set_bright(led, LV_LED_BRIGHT_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,6 +141,8 @@ void lv_led_on(lv_obj_t * led)
|
|||||||
*/
|
*/
|
||||||
void lv_led_off(lv_obj_t * led)
|
void lv_led_off(lv_obj_t * led)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(led, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_led_set_bright(led, LV_LED_BRIGHT_OFF);
|
lv_led_set_bright(led, LV_LED_BRIGHT_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,6 +152,8 @@ void lv_led_off(lv_obj_t * led)
|
|||||||
*/
|
*/
|
||||||
void lv_led_toggle(lv_obj_t * led)
|
void lv_led_toggle(lv_obj_t * led)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(led, LV_OBJX_NAME);
|
||||||
|
|
||||||
uint8_t bright = lv_led_get_bright(led);
|
uint8_t bright = lv_led_get_bright(led);
|
||||||
if(bright > (LV_LED_BRIGHT_OFF + LV_LED_BRIGHT_ON) >> 1)
|
if(bright > (LV_LED_BRIGHT_OFF + LV_LED_BRIGHT_ON) >> 1)
|
||||||
lv_led_off(led);
|
lv_led_off(led);
|
||||||
@@ -161,6 +172,8 @@ void lv_led_toggle(lv_obj_t * led)
|
|||||||
*/
|
*/
|
||||||
uint8_t lv_led_get_bright(const lv_obj_t * led)
|
uint8_t lv_led_get_bright(const lv_obj_t * led)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(led, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_led_ext_t * ext = lv_obj_get_ext_attr(led);
|
lv_led_ext_t * ext = lv_obj_get_ext_attr(led);
|
||||||
return ext->bright;
|
return ext->bright;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "lv_line.h"
|
#include "lv_line.h"
|
||||||
|
|
||||||
#if LV_USE_LINE != 0
|
#if LV_USE_LINE != 0
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
#include "../lv_misc/lv_math.h"
|
#include "../lv_misc/lv_math.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_line"
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -53,14 +55,14 @@ lv_obj_t * lv_line_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create a basic object*/
|
/*Create a basic object*/
|
||||||
lv_obj_t * new_line = lv_obj_create(par, copy);
|
lv_obj_t * new_line = lv_obj_create(par, copy);
|
||||||
lv_mem_assert(new_line);
|
LV_ASSERT_MEM(new_line);
|
||||||
if(new_line == NULL) return NULL;
|
if(new_line == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_line);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_line);
|
||||||
|
|
||||||
/*Extend the basic object to line object*/
|
/*Extend the basic object to line object*/
|
||||||
lv_line_ext_t * ext = lv_obj_allocate_ext_attr(new_line, sizeof(lv_line_ext_t));
|
lv_line_ext_t * ext = lv_obj_allocate_ext_attr(new_line, sizeof(lv_line_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
ext->point_num = 0;
|
ext->point_num = 0;
|
||||||
@@ -107,6 +109,8 @@ lv_obj_t * lv_line_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_line_set_points(lv_obj_t * line, const lv_point_t point_a[], uint16_t point_num)
|
void lv_line_set_points(lv_obj_t * line, const lv_point_t point_a[], uint16_t point_num)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(line, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||||
ext->point_array = point_a;
|
ext->point_array = point_a;
|
||||||
ext->point_num = point_num;
|
ext->point_num = point_num;
|
||||||
@@ -135,6 +139,8 @@ void lv_line_set_points(lv_obj_t * line, const lv_point_t point_a[], uint16_t po
|
|||||||
*/
|
*/
|
||||||
void lv_line_set_auto_size(lv_obj_t * line, bool en)
|
void lv_line_set_auto_size(lv_obj_t * line, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(line, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||||
if(ext->auto_size == en) return;
|
if(ext->auto_size == en) return;
|
||||||
|
|
||||||
@@ -153,6 +159,8 @@ void lv_line_set_auto_size(lv_obj_t * line, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_line_set_y_invert(lv_obj_t * line, bool en)
|
void lv_line_set_y_invert(lv_obj_t * line, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(line, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||||
if(ext->y_inv == en) return;
|
if(ext->y_inv == en) return;
|
||||||
|
|
||||||
@@ -172,6 +180,8 @@ void lv_line_set_y_invert(lv_obj_t * line, bool en)
|
|||||||
*/
|
*/
|
||||||
bool lv_line_get_auto_size(const lv_obj_t * line)
|
bool lv_line_get_auto_size(const lv_obj_t * line)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(line, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||||
|
|
||||||
return ext->auto_size == 0 ? false : true;
|
return ext->auto_size == 0 ? false : true;
|
||||||
@@ -184,6 +194,8 @@ bool lv_line_get_auto_size(const lv_obj_t * line)
|
|||||||
*/
|
*/
|
||||||
bool lv_line_get_y_invert(const lv_obj_t * line)
|
bool lv_line_get_y_invert(const lv_obj_t * line)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(line, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||||
|
|
||||||
return ext->y_inv == 0 ? false : true;
|
return ext->y_inv == 0 ? false : true;
|
||||||
@@ -284,15 +296,9 @@ static lv_res_t lv_line_signal(lv_obj_t * line, lv_signal_t sign, void * param)
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(line, sign, param);
|
res = ancestor_signal(line, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_GET_TYPE) {
|
if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_line";
|
|
||||||
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
|
||||||
const lv_style_t * style = lv_line_get_style(line, LV_LINE_STYLE_MAIN);
|
const lv_style_t * style = lv_line_get_style(line, LV_LINE_STYLE_MAIN);
|
||||||
if(line->ext_draw_pad < style->line.width) line->ext_draw_pad = style->line.width;
|
if(line->ext_draw_pad < style->line.width) line->ext_draw_pad = style->line.width;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "lv_list.h"
|
#include "lv_list.h"
|
||||||
#if LV_USE_LIST != 0
|
#if LV_USE_LIST != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_core/lv_group.h"
|
#include "../lv_core/lv_group.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
#include "../lv_misc/lv_anim.h"
|
#include "../lv_misc/lv_anim.h"
|
||||||
@@ -17,6 +18,8 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_list"
|
||||||
|
|
||||||
#define LV_LIST_LAYOUT_DEF LV_LAYOUT_COL_M
|
#define LV_LIST_LAYOUT_DEF LV_LAYOUT_COL_M
|
||||||
|
|
||||||
#if LV_USE_ANIMATION == 0
|
#if LV_USE_ANIMATION == 0
|
||||||
@@ -69,13 +72,13 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor basic object*/
|
/*Create the ancestor basic object*/
|
||||||
lv_obj_t * new_list = lv_page_create(par, copy);
|
lv_obj_t * new_list = lv_page_create(par, copy);
|
||||||
lv_mem_assert(new_list);
|
LV_ASSERT_MEM(new_list);
|
||||||
if(new_list == NULL) return NULL;
|
if(new_list == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_page_signal == NULL) ancestor_page_signal = lv_obj_get_signal_cb(new_list);
|
if(ancestor_page_signal == NULL) ancestor_page_signal = lv_obj_get_signal_cb(new_list);
|
||||||
|
|
||||||
lv_list_ext_t * ext = lv_obj_allocate_ext_attr(new_list, sizeof(lv_list_ext_t));
|
lv_list_ext_t * ext = lv_obj_allocate_ext_attr(new_list, sizeof(lv_list_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
ext->style_img = NULL;
|
ext->style_img = NULL;
|
||||||
@@ -149,13 +152,15 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all children of the scrl object, without deleting scrl child.
|
* Delete all children of the scrl object, without deleting scrl child.
|
||||||
* @param obj pointer to an object
|
* @param list pointer to an object
|
||||||
*/
|
*/
|
||||||
void lv_list_clean(lv_obj_t * obj)
|
void lv_list_clean(lv_obj_t * list)
|
||||||
{
|
{
|
||||||
lv_obj_t * scrl = lv_page_get_scrl(obj);
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
|
||||||
|
lv_obj_t * scrl = lv_page_get_scrl(list);
|
||||||
lv_obj_clean(scrl);
|
lv_obj_clean(scrl);
|
||||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(obj);
|
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||||
ext->size = 0;
|
ext->size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,6 +177,8 @@ void lv_list_clean(lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * txt)
|
lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * txt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||||
ext->size++;
|
ext->size++;
|
||||||
/*Create a list element with the image an the text*/
|
/*Create a list element with the image an the text*/
|
||||||
@@ -237,6 +244,8 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t
|
|||||||
*/
|
*/
|
||||||
bool lv_list_remove(const lv_obj_t * list, uint16_t index)
|
bool lv_list_remove(const lv_obj_t * list, uint16_t index)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||||
if(index >= ext->size) return false;
|
if(index >= ext->size) return false;
|
||||||
uint16_t count = 0;
|
uint16_t count = 0;
|
||||||
@@ -264,6 +273,8 @@ bool lv_list_remove(const lv_obj_t * list, uint16_t index)
|
|||||||
*/
|
*/
|
||||||
void lv_list_set_single_mode(lv_obj_t * list, bool mode)
|
void lv_list_set_single_mode(lv_obj_t * list, bool mode)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||||
|
|
||||||
ext->single_mode = mode;
|
ext->single_mode = mode;
|
||||||
@@ -279,6 +290,9 @@ void lv_list_set_single_mode(lv_obj_t * list, bool mode)
|
|||||||
*/
|
*/
|
||||||
void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn)
|
void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
if(btn) LV_ASSERT_OBJ(list, "lv_btn");
|
||||||
|
|
||||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||||
|
|
||||||
if(ext->selected_btn) {
|
if(ext->selected_btn) {
|
||||||
@@ -318,6 +332,8 @@ void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn)
|
|||||||
*/
|
*/
|
||||||
void lv_list_set_style(lv_obj_t * list, lv_list_style_t type, const lv_style_t * style)
|
void lv_list_set_style(lv_obj_t * list, lv_list_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||||
lv_btn_style_t btn_style_refr = LV_BTN_STYLE_REL;
|
lv_btn_style_t btn_style_refr = LV_BTN_STYLE_REL;
|
||||||
lv_obj_t * btn;
|
lv_obj_t * btn;
|
||||||
@@ -370,6 +386,8 @@ void lv_list_set_style(lv_obj_t * list, lv_list_style_t type, const lv_style_t *
|
|||||||
*/
|
*/
|
||||||
void lv_list_set_layout(lv_obj_t * list, lv_layout_t layout)
|
void lv_list_set_layout(lv_obj_t * list, lv_layout_t layout)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
|
||||||
/* Update list layout if necessary */
|
/* Update list layout if necessary */
|
||||||
if (layout == lv_list_get_layout(list)) return;
|
if (layout == lv_list_get_layout(list)) return;
|
||||||
|
|
||||||
@@ -403,6 +421,8 @@ void lv_list_set_style(lv_obj_t * list, lv_list_style_t type, const lv_style_t *
|
|||||||
*/
|
*/
|
||||||
bool lv_list_get_single_mode(lv_obj_t * list)
|
bool lv_list_get_single_mode(lv_obj_t * list)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||||
|
|
||||||
return (ext->single_mode);
|
return (ext->single_mode);
|
||||||
@@ -415,6 +435,8 @@ bool lv_list_get_single_mode(lv_obj_t * list)
|
|||||||
*/
|
*/
|
||||||
const char * lv_list_get_btn_text(const lv_obj_t * btn)
|
const char * lv_list_get_btn_text(const lv_obj_t * btn)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, "lv_btn");
|
||||||
|
|
||||||
lv_obj_t * label = lv_list_get_btn_label(btn);
|
lv_obj_t * label = lv_list_get_btn_label(btn);
|
||||||
if(label == NULL) return "";
|
if(label == NULL) return "";
|
||||||
return lv_label_get_text(label);
|
return lv_label_get_text(label);
|
||||||
@@ -427,6 +449,8 @@ const char * lv_list_get_btn_text(const lv_obj_t * btn)
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_list_get_btn_label(const lv_obj_t * btn)
|
lv_obj_t * lv_list_get_btn_label(const lv_obj_t * btn)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, "lv_btn");
|
||||||
|
|
||||||
lv_obj_t * label = lv_obj_get_child(btn, NULL);
|
lv_obj_t * label = lv_obj_get_child(btn, NULL);
|
||||||
if(label == NULL) return NULL;
|
if(label == NULL) return NULL;
|
||||||
|
|
||||||
@@ -445,6 +469,8 @@ lv_obj_t * lv_list_get_btn_label(const lv_obj_t * btn)
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_list_get_btn_img(const lv_obj_t * btn)
|
lv_obj_t * lv_list_get_btn_img(const lv_obj_t * btn)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, "lv_btn");
|
||||||
|
|
||||||
#if LV_USE_IMG != 0
|
#if LV_USE_IMG != 0
|
||||||
lv_obj_t * img = lv_obj_get_child(btn, NULL);
|
lv_obj_t * img = lv_obj_get_child(btn, NULL);
|
||||||
if(img == NULL) return NULL;
|
if(img == NULL) return NULL;
|
||||||
@@ -468,6 +494,8 @@ lv_obj_t * lv_list_get_btn_img(const lv_obj_t * btn)
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_list_get_prev_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
|
lv_obj_t * lv_list_get_prev_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
|
||||||
/* Not a good practice but user can add/create objects to the lists manually.
|
/* Not a good practice but user can add/create objects to the lists manually.
|
||||||
* When getting the next button try to be sure that it is at least a button */
|
* When getting the next button try to be sure that it is at least a button */
|
||||||
|
|
||||||
@@ -493,6 +521,8 @@ lv_obj_t * lv_list_get_prev_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_list_get_next_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
|
lv_obj_t * lv_list_get_next_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
|
||||||
/* Not a good practice but user can add/create objects to the lists manually.
|
/* Not a good practice but user can add/create objects to the lists manually.
|
||||||
* When getting the next button try to be sure that it is at least a button */
|
* When getting the next button try to be sure that it is at least a button */
|
||||||
|
|
||||||
@@ -518,6 +548,9 @@ lv_obj_t * lv_list_get_next_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
|
|||||||
*/
|
*/
|
||||||
int32_t lv_list_get_btn_index(const lv_obj_t * list, const lv_obj_t * btn)
|
int32_t lv_list_get_btn_index(const lv_obj_t * list, const lv_obj_t * btn)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_OBJ(btn, "lv_btn");
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
if(list == NULL) {
|
if(list == NULL) {
|
||||||
/* no list provided, assuming btn is part of a list */
|
/* no list provided, assuming btn is part of a list */
|
||||||
@@ -541,6 +574,8 @@ int32_t lv_list_get_btn_index(const lv_obj_t * list, const lv_obj_t * btn)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_list_get_size(const lv_obj_t * list)
|
uint16_t lv_list_get_size(const lv_obj_t * list)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||||
return ext->size;
|
return ext->size;
|
||||||
}
|
}
|
||||||
@@ -553,6 +588,8 @@ uint16_t lv_list_get_size(const lv_obj_t * list)
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_list_get_btn_selected(const lv_obj_t * list)
|
lv_obj_t * lv_list_get_btn_selected(const lv_obj_t * list)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||||
return ext->selected_btn;
|
return ext->selected_btn;
|
||||||
}
|
}
|
||||||
@@ -565,6 +602,8 @@ lv_obj_t * lv_list_get_btn_selected(const lv_obj_t * list)
|
|||||||
*/
|
*/
|
||||||
lv_layout_t lv_list_get_layout(lv_obj_t * list)
|
lv_layout_t lv_list_get_layout(lv_obj_t * list)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
|
||||||
return lv_page_get_scrl_layout(list);
|
return lv_page_get_scrl_layout(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,6 +615,8 @@ lv_layout_t lv_list_get_layout(lv_obj_t * list)
|
|||||||
*/
|
*/
|
||||||
const lv_style_t * lv_list_get_style(const lv_obj_t * list, lv_list_style_t type)
|
const lv_style_t * lv_list_get_style(const lv_obj_t * list, lv_list_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||||
|
|
||||||
@@ -605,6 +646,8 @@ const lv_style_t * lv_list_get_style(const lv_obj_t * list, lv_list_style_t type
|
|||||||
*/
|
*/
|
||||||
void lv_list_up(const lv_obj_t * list)
|
void lv_list_up(const lv_obj_t * list)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
|
||||||
/*Search the first list element which 'y' coordinate is below the parent
|
/*Search the first list element which 'y' coordinate is below the parent
|
||||||
* and position the list to show this element on the bottom*/
|
* and position the list to show this element on the bottom*/
|
||||||
lv_obj_t * scrl = lv_page_get_scrl(list);
|
lv_obj_t * scrl = lv_page_get_scrl(list);
|
||||||
@@ -650,6 +693,8 @@ void lv_list_up(const lv_obj_t * list)
|
|||||||
*/
|
*/
|
||||||
void lv_list_down(const lv_obj_t * list)
|
void lv_list_down(const lv_obj_t * list)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
|
||||||
/*Search the first list element which 'y' coordinate is above the parent
|
/*Search the first list element which 'y' coordinate is above the parent
|
||||||
* and position the list to show this element on the top*/
|
* and position the list to show this element on the top*/
|
||||||
lv_obj_t * scrl = lv_page_get_scrl(list);
|
lv_obj_t * scrl = lv_page_get_scrl(list);
|
||||||
@@ -691,6 +736,7 @@ void lv_list_down(const lv_obj_t * list)
|
|||||||
*/
|
*/
|
||||||
void lv_list_focus(const lv_obj_t * btn, lv_anim_enable_t anim)
|
void lv_list_focus(const lv_obj_t * btn, lv_anim_enable_t anim)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, "");
|
||||||
|
|
||||||
#if LV_USE_ANIMATION == 0
|
#if LV_USE_ANIMATION == 0
|
||||||
anim = false;
|
anim = false;
|
||||||
@@ -719,6 +765,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_page_signal(list, sign, param);
|
res = ancestor_page_signal(list, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING ||
|
if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING ||
|
||||||
sign == LV_SIGNAL_LONG_PRESS || sign == LV_SIGNAL_LONG_PRESS_REP) {
|
sign == LV_SIGNAL_LONG_PRESS || sign == LV_SIGNAL_LONG_PRESS_REP) {
|
||||||
@@ -848,13 +895,6 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_list";
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -873,6 +913,7 @@ static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * para
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_btn_signal(btn, sign, param);
|
res = ancestor_btn_signal(btn, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, "");
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_RELEASED) {
|
if(sign == LV_SIGNAL_RELEASED) {
|
||||||
lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn));
|
lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn));
|
||||||
|
|||||||
@@ -95,9 +95,9 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all children of the scrl object, without deleting scrl child.
|
* Delete all children of the scrl object, without deleting scrl child.
|
||||||
* @param obj pointer to an object
|
* @param list pointer to an object
|
||||||
*/
|
*/
|
||||||
void lv_list_clean(lv_obj_t * obj);
|
void lv_list_clean(lv_obj_t * list);
|
||||||
|
|
||||||
/*======================
|
/*======================
|
||||||
* Add/remove functions
|
* Add/remove functions
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "lv_lmeter.h"
|
#include "lv_lmeter.h"
|
||||||
#if LV_USE_LMETER != 0
|
#if LV_USE_LMETER != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
#include "../lv_core/lv_group.h"
|
#include "../lv_core/lv_group.h"
|
||||||
@@ -17,6 +18,8 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_lmeter"
|
||||||
|
|
||||||
#define LV_LMETER_LINE_UPSCALE 5 /*2^x upscale of line to make rounding*/
|
#define LV_LMETER_LINE_UPSCALE 5 /*2^x upscale of line to make rounding*/
|
||||||
#define LV_LMETER_LINE_UPSCALE_MASK ((1 << LV_LMETER_LINE_UPSCALE) - 1)
|
#define LV_LMETER_LINE_UPSCALE_MASK ((1 << LV_LMETER_LINE_UPSCALE) - 1)
|
||||||
|
|
||||||
@@ -57,14 +60,14 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor of line meter*/
|
/*Create the ancestor of line meter*/
|
||||||
lv_obj_t * new_lmeter = lv_obj_create(par, copy);
|
lv_obj_t * new_lmeter = lv_obj_create(par, copy);
|
||||||
lv_mem_assert(new_lmeter);
|
LV_ASSERT_MEM(new_lmeter);
|
||||||
if(new_lmeter == NULL) return NULL;
|
if(new_lmeter == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_lmeter);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_lmeter);
|
||||||
|
|
||||||
/*Allocate the line meter type specific extended data*/
|
/*Allocate the line meter type specific extended data*/
|
||||||
lv_lmeter_ext_t * ext = lv_obj_allocate_ext_attr(new_lmeter, sizeof(lv_lmeter_ext_t));
|
lv_lmeter_ext_t * ext = lv_obj_allocate_ext_attr(new_lmeter, sizeof(lv_lmeter_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
/*Initialize the allocated 'ext' */
|
/*Initialize the allocated 'ext' */
|
||||||
@@ -119,6 +122,8 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_lmeter_set_value(lv_obj_t * lmeter, int16_t value)
|
void lv_lmeter_set_value(lv_obj_t * lmeter, int16_t value)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||||
if(ext->cur_value == value) return;
|
if(ext->cur_value == value) return;
|
||||||
|
|
||||||
@@ -135,6 +140,8 @@ void lv_lmeter_set_value(lv_obj_t * lmeter, int16_t value)
|
|||||||
*/
|
*/
|
||||||
void lv_lmeter_set_range(lv_obj_t * lmeter, int16_t min, int16_t max)
|
void lv_lmeter_set_range(lv_obj_t * lmeter, int16_t min, int16_t max)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||||
if(ext->min_value == min && ext->max_value == max) return;
|
if(ext->min_value == min && ext->max_value == max) return;
|
||||||
|
|
||||||
@@ -159,6 +166,8 @@ void lv_lmeter_set_range(lv_obj_t * lmeter, int16_t min, int16_t max)
|
|||||||
*/
|
*/
|
||||||
void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t line_cnt)
|
void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t line_cnt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||||
if(ext->scale_angle == angle && ext->line_cnt == line_cnt) return;
|
if(ext->scale_angle == angle && ext->line_cnt == line_cnt) return;
|
||||||
|
|
||||||
@@ -179,6 +188,8 @@ void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t line_cnt)
|
|||||||
*/
|
*/
|
||||||
int16_t lv_lmeter_get_value(const lv_obj_t * lmeter)
|
int16_t lv_lmeter_get_value(const lv_obj_t * lmeter)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||||
return ext->cur_value;
|
return ext->cur_value;
|
||||||
}
|
}
|
||||||
@@ -190,6 +201,8 @@ int16_t lv_lmeter_get_value(const lv_obj_t * lmeter)
|
|||||||
*/
|
*/
|
||||||
int16_t lv_lmeter_get_min_value(const lv_obj_t * lmeter)
|
int16_t lv_lmeter_get_min_value(const lv_obj_t * lmeter)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||||
return ext->min_value;
|
return ext->min_value;
|
||||||
}
|
}
|
||||||
@@ -201,6 +214,8 @@ int16_t lv_lmeter_get_min_value(const lv_obj_t * lmeter)
|
|||||||
*/
|
*/
|
||||||
int16_t lv_lmeter_get_max_value(const lv_obj_t * lmeter)
|
int16_t lv_lmeter_get_max_value(const lv_obj_t * lmeter)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||||
return ext->max_value;
|
return ext->max_value;
|
||||||
}
|
}
|
||||||
@@ -212,6 +227,8 @@ int16_t lv_lmeter_get_max_value(const lv_obj_t * lmeter)
|
|||||||
*/
|
*/
|
||||||
uint8_t lv_lmeter_get_line_count(const lv_obj_t * lmeter)
|
uint8_t lv_lmeter_get_line_count(const lv_obj_t * lmeter)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||||
return ext->line_cnt;
|
return ext->line_cnt;
|
||||||
}
|
}
|
||||||
@@ -223,6 +240,8 @@ uint8_t lv_lmeter_get_line_count(const lv_obj_t * lmeter)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_lmeter_get_scale_angle(const lv_obj_t * lmeter)
|
uint16_t lv_lmeter_get_scale_angle(const lv_obj_t * lmeter)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||||
return ext->scale_angle;
|
return ext->scale_angle;
|
||||||
}
|
}
|
||||||
@@ -335,6 +354,7 @@ static lv_res_t lv_lmeter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * par
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(lmeter, sign, param);
|
res = ancestor_signal(lmeter, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||||
@@ -343,13 +363,6 @@ static lv_res_t lv_lmeter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * par
|
|||||||
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
||||||
const lv_style_t * style = lv_lmeter_get_style(lmeter, LV_LMETER_STYLE_MAIN);
|
const lv_style_t * style = lv_lmeter_get_style(lmeter, LV_LMETER_STYLE_MAIN);
|
||||||
lmeter->ext_draw_pad = LV_MATH_MAX(lmeter->ext_draw_pad, style->line.width);
|
lmeter->ext_draw_pad = LV_MATH_MAX(lmeter->ext_draw_pad, style->line.width);
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_lmeter";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "lv_mbox.h"
|
#include "lv_mbox.h"
|
||||||
#if LV_USE_MBOX != 0
|
#if LV_USE_MBOX != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_core/lv_group.h"
|
#include "../lv_core/lv_group.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
#include "../lv_misc/lv_anim.h"
|
#include "../lv_misc/lv_anim.h"
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_mbos"
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
#ifndef LV_MBOX_CLOSE_ANIM_TIME
|
#ifndef LV_MBOX_CLOSE_ANIM_TIME
|
||||||
@@ -68,14 +70,14 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor message box*/
|
/*Create the ancestor message box*/
|
||||||
lv_obj_t * new_mbox = lv_cont_create(par, copy);
|
lv_obj_t * new_mbox = lv_cont_create(par, copy);
|
||||||
lv_mem_assert(new_mbox);
|
LV_ASSERT_MEM(new_mbox);
|
||||||
if(new_mbox == NULL) return NULL;
|
if(new_mbox == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_mbox);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_mbox);
|
||||||
|
|
||||||
/*Allocate the message box type specific extended data*/
|
/*Allocate the message box type specific extended data*/
|
||||||
lv_mbox_ext_t * ext = lv_obj_allocate_ext_attr(new_mbox, sizeof(lv_mbox_ext_t));
|
lv_mbox_ext_t * ext = lv_obj_allocate_ext_attr(new_mbox, sizeof(lv_mbox_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
ext->text = NULL;
|
ext->text = NULL;
|
||||||
@@ -139,6 +141,9 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_mbox_add_btns(lv_obj_t * mbox, const char ** btn_map)
|
void lv_mbox_add_btns(lv_obj_t * mbox, const char ** btn_map)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(btn_map);
|
||||||
|
|
||||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||||
|
|
||||||
/*Create a button matrix if not exists yet*/
|
/*Create a button matrix if not exists yet*/
|
||||||
@@ -174,6 +179,9 @@ void lv_mbox_add_btns(lv_obj_t * mbox, const char ** btn_map)
|
|||||||
*/
|
*/
|
||||||
void lv_mbox_set_text(lv_obj_t * mbox, const char * txt)
|
void lv_mbox_set_text(lv_obj_t * mbox, const char * txt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_STR(txt);
|
||||||
|
|
||||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||||
lv_label_set_text(ext->text, txt);
|
lv_label_set_text(ext->text, txt);
|
||||||
|
|
||||||
@@ -187,6 +195,8 @@ void lv_mbox_set_text(lv_obj_t * mbox, const char * txt)
|
|||||||
*/
|
*/
|
||||||
void lv_mbox_set_anim_time(lv_obj_t * mbox, uint16_t anim_time)
|
void lv_mbox_set_anim_time(lv_obj_t * mbox, uint16_t anim_time)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||||
anim_time = 0;
|
anim_time = 0;
|
||||||
@@ -204,6 +214,8 @@ void lv_mbox_set_anim_time(lv_obj_t * mbox, uint16_t anim_time)
|
|||||||
*/
|
*/
|
||||||
void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay)
|
void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
if(lv_mbox_get_anim_time(mbox) != 0) {
|
if(lv_mbox_get_anim_time(mbox) != 0) {
|
||||||
/*Add shrinking animations*/
|
/*Add shrinking animations*/
|
||||||
@@ -258,6 +270,8 @@ void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay)
|
|||||||
*/
|
*/
|
||||||
void lv_mbox_stop_auto_close(lv_obj_t * mbox)
|
void lv_mbox_stop_auto_close(lv_obj_t * mbox)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_anim_del(mbox, NULL);
|
lv_anim_del(mbox, NULL);
|
||||||
#else
|
#else
|
||||||
@@ -273,6 +287,8 @@ void lv_mbox_stop_auto_close(lv_obj_t * mbox)
|
|||||||
*/
|
*/
|
||||||
void lv_mbox_set_style(lv_obj_t * mbox, lv_mbox_style_t type, const lv_style_t * style)
|
void lv_mbox_set_style(lv_obj_t * mbox, lv_mbox_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -295,6 +311,8 @@ void lv_mbox_set_style(lv_obj_t * mbox, lv_mbox_style_t type, const lv_style_t *
|
|||||||
*/
|
*/
|
||||||
void lv_mbox_set_recolor(lv_obj_t * mbox, bool en)
|
void lv_mbox_set_recolor(lv_obj_t * mbox, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||||
|
|
||||||
if(ext->btnm) lv_btnm_set_recolor(ext->btnm, en);
|
if(ext->btnm) lv_btnm_set_recolor(ext->btnm, en);
|
||||||
@@ -311,6 +329,8 @@ void lv_mbox_set_recolor(lv_obj_t * mbox, bool en)
|
|||||||
*/
|
*/
|
||||||
const char * lv_mbox_get_text(const lv_obj_t * mbox)
|
const char * lv_mbox_get_text(const lv_obj_t * mbox)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||||
|
|
||||||
return lv_label_get_text(ext->text);
|
return lv_label_get_text(ext->text);
|
||||||
@@ -324,6 +344,8 @@ const char * lv_mbox_get_text(const lv_obj_t * mbox)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_mbox_get_active_btn(lv_obj_t * mbox)
|
uint16_t lv_mbox_get_active_btn(lv_obj_t * mbox)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||||
if(ext->btnm)
|
if(ext->btnm)
|
||||||
return lv_btnm_get_active_btn(ext->btnm);
|
return lv_btnm_get_active_btn(ext->btnm);
|
||||||
@@ -339,6 +361,8 @@ uint16_t lv_mbox_get_active_btn(lv_obj_t * mbox)
|
|||||||
*/
|
*/
|
||||||
const char * lv_mbox_get_active_btn_text(lv_obj_t * mbox)
|
const char * lv_mbox_get_active_btn_text(lv_obj_t * mbox)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||||
if(ext->btnm)
|
if(ext->btnm)
|
||||||
return lv_btnm_get_active_btn_text(ext->btnm);
|
return lv_btnm_get_active_btn_text(ext->btnm);
|
||||||
@@ -353,6 +377,8 @@ const char * lv_mbox_get_active_btn_text(lv_obj_t * mbox)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_mbox_get_anim_time(const lv_obj_t * mbox)
|
uint16_t lv_mbox_get_anim_time(const lv_obj_t * mbox)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||||
return ext->anim_time;
|
return ext->anim_time;
|
||||||
@@ -370,6 +396,8 @@ uint16_t lv_mbox_get_anim_time(const lv_obj_t * mbox)
|
|||||||
*/
|
*/
|
||||||
const lv_style_t * lv_mbox_get_style(const lv_obj_t * mbox, lv_mbox_style_t type)
|
const lv_style_t * lv_mbox_get_style(const lv_obj_t * mbox, lv_mbox_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||||
|
|
||||||
@@ -394,6 +422,8 @@ const lv_style_t * lv_mbox_get_style(const lv_obj_t * mbox, lv_mbox_style_t type
|
|||||||
*/
|
*/
|
||||||
bool lv_mbox_get_recolor(const lv_obj_t * mbox)
|
bool lv_mbox_get_recolor(const lv_obj_t * mbox)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||||
|
|
||||||
if(!ext->btnm) return false;
|
if(!ext->btnm) return false;
|
||||||
@@ -409,6 +439,8 @@ bool lv_mbox_get_recolor(const lv_obj_t * mbox)
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_mbox_get_btnm(lv_obj_t * mbox)
|
lv_obj_t * lv_mbox_get_btnm(lv_obj_t * mbox)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||||
return ext->btnm;
|
return ext->btnm;
|
||||||
}
|
}
|
||||||
@@ -441,6 +473,7 @@ static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(mbox, sign, param);
|
res = ancestor_signal(mbox, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||||
if(sign == LV_SIGNAL_CORD_CHG) {
|
if(sign == LV_SIGNAL_CORD_CHG) {
|
||||||
@@ -476,13 +509,6 @@ static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_mbox";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -7,12 +7,14 @@
|
|||||||
* INCLUDES
|
* INCLUDES
|
||||||
*********************/
|
*********************/
|
||||||
#include "lv_objmask.h"
|
#include "lv_objmask.h"
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
|
|
||||||
#if defined(LV_USE_OBJMASK) && LV_USE_OBJMASK != 0
|
#if defined(LV_USE_OBJMASK) && LV_USE_OBJMASK != 0
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_objmask"
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -50,12 +52,12 @@ lv_obj_t * lv_objmask_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor of object mask*/
|
/*Create the ancestor of object mask*/
|
||||||
lv_obj_t * new_objmask = lv_cont_create(par, copy);
|
lv_obj_t * new_objmask = lv_cont_create(par, copy);
|
||||||
lv_mem_assert(new_objmask);
|
LV_ASSERT_MEM(new_objmask);
|
||||||
if(new_objmask == NULL) return NULL;
|
if(new_objmask == NULL) return NULL;
|
||||||
|
|
||||||
/*Allocate the object mask type specific extended data*/
|
/*Allocate the object mask type specific extended data*/
|
||||||
lv_objmask_ext_t * ext = lv_obj_allocate_ext_attr(new_objmask, sizeof(lv_objmask_ext_t));
|
lv_objmask_ext_t * ext = lv_obj_allocate_ext_attr(new_objmask, sizeof(lv_objmask_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_objmask);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_objmask);
|
||||||
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_objmask);
|
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_objmask);
|
||||||
@@ -175,6 +177,7 @@ static lv_res_t lv_objmask_signal(lv_obj_t * objmask, lv_signal_t sign, void * p
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(objmask, sign, param);
|
res = ancestor_signal(objmask, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* INCLUDES
|
* INCLUDES
|
||||||
*********************/
|
*********************/
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
//#include "lv_templ.h" /*TODO uncomment this*/
|
//#include "lv_templ.h" /*TODO uncomment this*/
|
||||||
|
|
||||||
#if defined(LV_USE_TEMPL) && LV_USE_TEMPL != 0
|
#if defined(LV_USE_TEMPL) && LV_USE_TEMPL != 0
|
||||||
@@ -22,6 +23,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJ_X_NAME "lv_templ"
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -118,6 +120,8 @@ lv_obj_t * lv_templ_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_templ_set_style(lv_obj_t * templ, lv_templ_style_t type, const lv_style_t * style)
|
void lv_templ_set_style(lv_obj_t * templ, lv_templ_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(templ, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_templ_ext_t * ext = lv_obj_get_ext_attr(templ);
|
lv_templ_ext_t * ext = lv_obj_get_ext_attr(templ);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -142,6 +146,8 @@ void lv_templ_set_style(lv_obj_t * templ, lv_templ_style_t type, const lv_style_
|
|||||||
*/
|
*/
|
||||||
lv_style_t * lv_templ_get_style(const lv_obj_t * templ, lv_templ_style_t type)
|
lv_style_t * lv_templ_get_style(const lv_obj_t * templ, lv_templ_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(templ, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_templ_ext_t * ext = lv_obj_get_ext_attr(templ);
|
lv_templ_ext_t * ext = lv_obj_get_ext_attr(templ);
|
||||||
lv_style_t * style = NULL;
|
lv_style_t * style = NULL;
|
||||||
|
|
||||||
@@ -207,16 +213,10 @@ static lv_res_t lv_templ_signal(lv_obj_t * templ, lv_signal_t sign, void * param
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(templ, sign, param);
|
res = ancestor_signal(templ, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_templ";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "../lv_objx/lv_page.h"
|
#include "../lv_objx/lv_page.h"
|
||||||
#if LV_USE_PAGE != 0
|
#if LV_USE_PAGE != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_core/lv_group.h"
|
#include "../lv_core/lv_group.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
@@ -19,6 +20,8 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_page"
|
||||||
|
|
||||||
#define LV_PAGE_SB_MIN_SIZE (LV_DPI / 8)
|
#define LV_PAGE_SB_MIN_SIZE (LV_DPI / 8)
|
||||||
|
|
||||||
/*[ms] Scroll anim time on `lv_page_scroll_up/down/left/rigth`*/
|
/*[ms] Scroll anim time on `lv_page_scroll_up/down/left/rigth`*/
|
||||||
@@ -77,7 +80,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor object*/
|
/*Create the ancestor object*/
|
||||||
lv_obj_t * new_page = lv_cont_create(par, copy);
|
lv_obj_t * new_page = lv_cont_create(par, copy);
|
||||||
lv_mem_assert(new_page);
|
LV_ASSERT_MEM(new_page);
|
||||||
if(new_page == NULL) return NULL;
|
if(new_page == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_page);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_page);
|
||||||
@@ -85,7 +88,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Allocate the object type specific extended data*/
|
/*Allocate the object type specific extended data*/
|
||||||
lv_page_ext_t * ext = lv_obj_allocate_ext_attr(new_page, sizeof(lv_page_ext_t));
|
lv_page_ext_t * ext = lv_obj_allocate_ext_attr(new_page, sizeof(lv_page_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
ext->scrl = NULL;
|
ext->scrl = NULL;
|
||||||
@@ -172,11 +175,13 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all children of the scrl object, without deleting scrl child.
|
* Delete all children of the scrl object, without deleting scrl child.
|
||||||
* @param obj pointer to an object
|
* @param page pointer to an object
|
||||||
*/
|
*/
|
||||||
void lv_page_clean(lv_obj_t * obj)
|
void lv_page_clean(lv_obj_t * page)
|
||||||
{
|
{
|
||||||
lv_obj_t * scrl = lv_page_get_scrl(obj);
|
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
||||||
|
|
||||||
|
lv_obj_t * scrl = lv_page_get_scrl(page);
|
||||||
lv_obj_clean(scrl);
|
lv_obj_clean(scrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,6 +196,8 @@ void lv_page_clean(lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
void lv_page_set_sb_mode(lv_obj_t * page, lv_sb_mode_t sb_mode)
|
void lv_page_set_sb_mode(lv_obj_t * page, lv_sb_mode_t sb_mode)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||||
if(ext->sb.mode == sb_mode) return;
|
if(ext->sb.mode == sb_mode) return;
|
||||||
|
|
||||||
@@ -217,6 +224,8 @@ void lv_page_set_sb_mode(lv_obj_t * page, lv_sb_mode_t sb_mode)
|
|||||||
*/
|
*/
|
||||||
void lv_page_set_anim_time(lv_obj_t * page, uint16_t anim_time)
|
void lv_page_set_anim_time(lv_obj_t * page, uint16_t anim_time)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||||
ext->anim_time = anim_time;
|
ext->anim_time = anim_time;
|
||||||
@@ -236,6 +245,8 @@ void lv_page_set_anim_time(lv_obj_t * page, uint16_t anim_time)
|
|||||||
*/
|
*/
|
||||||
void lv_page_set_scroll_propagation(lv_obj_t * page, bool en)
|
void lv_page_set_scroll_propagation(lv_obj_t * page, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||||
if(en) lv_obj_set_drag_dir(ext->scrl, LV_DRAG_DIR_ONE);
|
if(en) lv_obj_set_drag_dir(ext->scrl, LV_DRAG_DIR_ONE);
|
||||||
else lv_obj_set_drag_dir(ext->scrl, LV_DRAG_DIR_BOTH);
|
else lv_obj_set_drag_dir(ext->scrl, LV_DRAG_DIR_BOTH);
|
||||||
@@ -250,6 +261,8 @@ void lv_page_set_scroll_propagation(lv_obj_t * page, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_page_set_edge_flash(lv_obj_t * page, bool en)
|
void lv_page_set_edge_flash(lv_obj_t * page, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||||
ext->edge_flash.enabled = en ? 1 : 0;
|
ext->edge_flash.enabled = en ? 1 : 0;
|
||||||
@@ -267,6 +280,8 @@ void lv_page_set_edge_flash(lv_obj_t * page, bool en)
|
|||||||
* */
|
* */
|
||||||
void lv_page_set_style(lv_obj_t * page, lv_page_style_t type, const lv_style_t * style)
|
void lv_page_set_style(lv_obj_t * page, lv_page_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -297,6 +312,8 @@ void lv_page_set_style(lv_obj_t * page, lv_page_style_t type, const lv_style_t *
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_page_get_scrl(const lv_obj_t * page)
|
lv_obj_t * lv_page_get_scrl(const lv_obj_t * page)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||||
|
|
||||||
return ext->scrl;
|
return ext->scrl;
|
||||||
@@ -309,6 +326,8 @@ lv_obj_t * lv_page_get_scrl(const lv_obj_t * page)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_page_get_anim_time(const lv_obj_t * page)
|
uint16_t lv_page_get_anim_time(const lv_obj_t * page)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||||
return ext->anim_time;
|
return ext->anim_time;
|
||||||
@@ -325,6 +344,8 @@ uint16_t lv_page_get_anim_time(const lv_obj_t * page)
|
|||||||
*/
|
*/
|
||||||
lv_sb_mode_t lv_page_get_sb_mode(const lv_obj_t * page)
|
lv_sb_mode_t lv_page_get_sb_mode(const lv_obj_t * page)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||||
return ext->sb.mode;
|
return ext->sb.mode;
|
||||||
}
|
}
|
||||||
@@ -336,6 +357,8 @@ lv_sb_mode_t lv_page_get_sb_mode(const lv_obj_t * page)
|
|||||||
*/
|
*/
|
||||||
bool lv_page_get_scroll_propagation(lv_obj_t * page)
|
bool lv_page_get_scroll_propagation(lv_obj_t * page)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||||
return ext->scroll_prop ? true : false;
|
return ext->scroll_prop ? true : false;
|
||||||
}
|
}
|
||||||
@@ -347,6 +370,8 @@ bool lv_page_get_scroll_propagation(lv_obj_t * page)
|
|||||||
*/
|
*/
|
||||||
bool lv_page_get_edge_flash(lv_obj_t * page)
|
bool lv_page_get_edge_flash(lv_obj_t * page)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||||
return ext->edge_flash.enabled == 0 ? false : true;
|
return ext->edge_flash.enabled == 0 ? false : true;
|
||||||
@@ -363,6 +388,8 @@ bool lv_page_get_edge_flash(lv_obj_t * page)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_page_get_fit_width(lv_obj_t * page)
|
lv_coord_t lv_page_get_fit_width(lv_obj_t * page)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * bg_style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
const lv_style_t * bg_style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
||||||
const lv_style_t * scrl_style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
|
const lv_style_t * scrl_style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
|
||||||
|
|
||||||
@@ -377,6 +404,8 @@ lv_coord_t lv_page_get_fit_width(lv_obj_t * page)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_page_get_fit_height(lv_obj_t * page)
|
lv_coord_t lv_page_get_fit_height(lv_obj_t * page)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * bg_style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
const lv_style_t * bg_style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
||||||
const lv_style_t * scrl_style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
|
const lv_style_t * scrl_style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
|
||||||
|
|
||||||
@@ -392,6 +421,8 @@ lv_coord_t lv_page_get_fit_height(lv_obj_t * page)
|
|||||||
* */
|
* */
|
||||||
const lv_style_t * lv_page_get_style(const lv_obj_t * page, lv_page_style_t type)
|
const lv_style_t * lv_page_get_style(const lv_obj_t * page, lv_page_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||||
|
|
||||||
@@ -825,6 +856,7 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(page, sign, param);
|
res = ancestor_signal(page, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
@@ -913,13 +945,6 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
|||||||
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
||||||
bool * editable = (bool *)param;
|
bool * editable = (bool *)param;
|
||||||
*editable = true;
|
*editable = true;
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_page";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -939,6 +964,7 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(scrl, sign, param);
|
res = ancestor_signal(scrl, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, "");
|
||||||
|
|
||||||
lv_obj_t * page = lv_obj_get_parent(scrl);
|
lv_obj_t * page = lv_obj_get_parent(scrl);
|
||||||
const lv_style_t * page_style = lv_obj_get_style(page);
|
const lv_style_t * page_style = lv_obj_get_style(page);
|
||||||
|
|||||||
@@ -112,9 +112,9 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all children of the scrl object, without deleting scrl child.
|
* Delete all children of the scrl object, without deleting scrl child.
|
||||||
* @param obj pointer to an object
|
* @param page pointer to an object
|
||||||
*/
|
*/
|
||||||
void lv_page_clean(lv_obj_t * obj);
|
void lv_page_clean(lv_obj_t * page);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the scrollable object of a page
|
* Get the scrollable object of a page
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "lv_preload.h"
|
#include "lv_preload.h"
|
||||||
#if LV_USE_PRELOAD != 0
|
#if LV_USE_PRELOAD != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_misc/lv_math.h"
|
#include "../lv_misc/lv_math.h"
|
||||||
#include "../lv_draw/lv_draw_rect.h"
|
#include "../lv_draw/lv_draw_rect.h"
|
||||||
#include "../lv_draw/lv_draw_arc.h"
|
#include "../lv_draw/lv_draw_arc.h"
|
||||||
@@ -17,6 +18,8 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_preloader"
|
||||||
|
|
||||||
#ifndef LV_PRELOAD_DEF_ARC_LENGTH
|
#ifndef LV_PRELOAD_DEF_ARC_LENGTH
|
||||||
#define LV_PRELOAD_DEF_ARC_LENGTH 60 /*[deg]*/
|
#define LV_PRELOAD_DEF_ARC_LENGTH 60 /*[deg]*/
|
||||||
#endif
|
#endif
|
||||||
@@ -66,12 +69,12 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor of pre loader*/
|
/*Create the ancestor of pre loader*/
|
||||||
lv_obj_t * new_preload = lv_arc_create(par, copy);
|
lv_obj_t * new_preload = lv_arc_create(par, copy);
|
||||||
lv_mem_assert(new_preload);
|
LV_ASSERT_MEM(new_preload);
|
||||||
if(new_preload == NULL) return NULL;
|
if(new_preload == NULL) return NULL;
|
||||||
|
|
||||||
/*Allocate the pre loader type specific extended data*/
|
/*Allocate the pre loader type specific extended data*/
|
||||||
lv_preload_ext_t * ext = lv_obj_allocate_ext_attr(new_preload, sizeof(lv_preload_ext_t));
|
lv_preload_ext_t * ext = lv_obj_allocate_ext_attr(new_preload, sizeof(lv_preload_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_preload);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_preload);
|
||||||
@@ -129,6 +132,8 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_preload_set_arc_length(lv_obj_t * preload, lv_anim_value_t deg)
|
void lv_preload_set_arc_length(lv_obj_t * preload, lv_anim_value_t deg)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(preload, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
|
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
|
||||||
|
|
||||||
ext->arc_length = deg;
|
ext->arc_length = deg;
|
||||||
@@ -141,6 +146,8 @@ void lv_preload_set_arc_length(lv_obj_t * preload, lv_anim_value_t deg)
|
|||||||
*/
|
*/
|
||||||
void lv_preload_set_spin_time(lv_obj_t * preload, uint16_t time)
|
void lv_preload_set_spin_time(lv_obj_t * preload, uint16_t time)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(preload, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
|
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
|
||||||
|
|
||||||
ext->time = time;
|
ext->time = time;
|
||||||
@@ -158,6 +165,8 @@ void lv_preload_set_spin_time(lv_obj_t * preload, uint16_t time)
|
|||||||
* */
|
* */
|
||||||
void lv_preload_set_style(lv_obj_t * preload, lv_preload_style_t type, const lv_style_t * style)
|
void lv_preload_set_style(lv_obj_t * preload, lv_preload_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(preload, LV_OBJX_NAME);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_PRELOAD_STYLE_MAIN: lv_arc_set_style(preload, LV_ARC_STYLE_MAIN, style); break;
|
case LV_PRELOAD_STYLE_MAIN: lv_arc_set_style(preload, LV_ARC_STYLE_MAIN, style); break;
|
||||||
}
|
}
|
||||||
@@ -170,6 +179,8 @@ void lv_preload_set_style(lv_obj_t * preload, lv_preload_style_t type, const lv_
|
|||||||
* */
|
* */
|
||||||
void lv_preload_set_type(lv_obj_t * preload, lv_preload_type_t type)
|
void lv_preload_set_type(lv_obj_t * preload, lv_preload_type_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(preload, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
|
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
|
||||||
|
|
||||||
/*delete previous animation*/
|
/*delete previous animation*/
|
||||||
@@ -252,6 +263,8 @@ void lv_preload_set_type(lv_obj_t * preload, lv_preload_type_t type)
|
|||||||
|
|
||||||
void lv_preload_set_dir(lv_obj_t * preload, lv_preload_dir_t dir)
|
void lv_preload_set_dir(lv_obj_t * preload, lv_preload_dir_t dir)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(preload, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
|
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
|
||||||
|
|
||||||
ext->anim_dir = dir;
|
ext->anim_dir = dir;
|
||||||
@@ -268,6 +281,8 @@ void lv_preload_set_dir(lv_obj_t * preload, lv_preload_dir_t dir)
|
|||||||
*/
|
*/
|
||||||
lv_anim_value_t lv_preload_get_arc_length(const lv_obj_t * preload)
|
lv_anim_value_t lv_preload_get_arc_length(const lv_obj_t * preload)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(preload, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
|
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
|
||||||
return ext->arc_length;
|
return ext->arc_length;
|
||||||
}
|
}
|
||||||
@@ -278,6 +293,8 @@ lv_anim_value_t lv_preload_get_arc_length(const lv_obj_t * preload)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_preload_get_spin_time(const lv_obj_t * preload)
|
uint16_t lv_preload_get_spin_time(const lv_obj_t * preload)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(preload, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
|
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
|
||||||
return ext->time;
|
return ext->time;
|
||||||
}
|
}
|
||||||
@@ -290,6 +307,8 @@ uint16_t lv_preload_get_spin_time(const lv_obj_t * preload)
|
|||||||
* */
|
* */
|
||||||
const lv_style_t * lv_preload_get_style(const lv_obj_t * preload, lv_preload_style_t type)
|
const lv_style_t * lv_preload_get_style(const lv_obj_t * preload, lv_preload_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(preload, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -307,6 +326,8 @@ const lv_style_t * lv_preload_get_style(const lv_obj_t * preload, lv_preload_sty
|
|||||||
* */
|
* */
|
||||||
lv_preload_type_t lv_preload_get_type(lv_obj_t * preload)
|
lv_preload_type_t lv_preload_get_type(lv_obj_t * preload)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(preload, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
|
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
|
||||||
return ext->anim_type;
|
return ext->anim_type;
|
||||||
}
|
}
|
||||||
@@ -411,16 +432,10 @@ static lv_res_t lv_preload_signal(lv_obj_t * preload, lv_signal_t sign, void * p
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(preload, sign, param);
|
res = ancestor_signal(preload, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_preload";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "lv_roller.h"
|
#include "lv_roller.h"
|
||||||
#if LV_USE_ROLLER != 0
|
#if LV_USE_ROLLER != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
#include "../lv_core/lv_group.h"
|
#include "../lv_core/lv_group.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
@@ -16,6 +17,8 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_roller"
|
||||||
|
|
||||||
#if LV_USE_ANIMATION == 0
|
#if LV_USE_ANIMATION == 0
|
||||||
#undef LV_ROLLER_DEF_ANIM_TIME
|
#undef LV_ROLLER_DEF_ANIM_TIME
|
||||||
#define LV_ROLLER_DEF_ANIM_TIME 0 /*No animation*/
|
#define LV_ROLLER_DEF_ANIM_TIME 0 /*No animation*/
|
||||||
@@ -65,7 +68,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor of roller*/
|
/*Create the ancestor of roller*/
|
||||||
lv_obj_t * new_roller = lv_ddlist_create(par, copy);
|
lv_obj_t * new_roller = lv_ddlist_create(par, copy);
|
||||||
lv_mem_assert(new_roller);
|
LV_ASSERT_MEM(new_roller);
|
||||||
if(new_roller == NULL) return NULL;
|
if(new_roller == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(new_roller));
|
if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(new_roller));
|
||||||
@@ -73,7 +76,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Allocate the roller type specific extended data*/
|
/*Allocate the roller type specific extended data*/
|
||||||
lv_roller_ext_t * ext = lv_obj_allocate_ext_attr(new_roller, sizeof(lv_roller_ext_t));
|
lv_roller_ext_t * ext = lv_obj_allocate_ext_attr(new_roller, sizeof(lv_roller_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
ext->ddlist.draw_arrow = 0; /*Do not draw arrow by default*/
|
ext->ddlist.draw_arrow = 0; /*Do not draw arrow by default*/
|
||||||
|
|
||||||
@@ -134,6 +137,9 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_roller_set_options(lv_obj_t * roller, const char * options, lv_roller_mode_t mode)
|
void lv_roller_set_options(lv_obj_t * roller, const char * options, lv_roller_mode_t mode)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(roller, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_STR(options);
|
||||||
|
|
||||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||||
|
|
||||||
if(mode == LV_ROLLER_MODE_NORMAL) {
|
if(mode == LV_ROLLER_MODE_NORMAL) {
|
||||||
@@ -175,6 +181,8 @@ void lv_roller_set_options(lv_obj_t * roller, const char * options, lv_roller_mo
|
|||||||
*/
|
*/
|
||||||
void lv_roller_set_align(lv_obj_t * roller, lv_label_align_t align)
|
void lv_roller_set_align(lv_obj_t * roller, lv_label_align_t align)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(roller, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||||
|
|
||||||
lv_obj_t * label = ext->ddlist.label;
|
lv_obj_t * label = ext->ddlist.label;
|
||||||
@@ -197,6 +205,8 @@ void lv_roller_set_align(lv_obj_t * roller, lv_label_align_t align)
|
|||||||
*/
|
*/
|
||||||
void lv_roller_set_selected(lv_obj_t * roller, uint16_t sel_opt, lv_anim_enable_t anim)
|
void lv_roller_set_selected(lv_obj_t * roller, uint16_t sel_opt, lv_anim_enable_t anim)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(roller, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION == 0
|
#if LV_USE_ANIMATION == 0
|
||||||
anim = LV_ANIM_OFF;
|
anim = LV_ANIM_OFF;
|
||||||
#endif
|
#endif
|
||||||
@@ -214,6 +224,8 @@ void lv_roller_set_selected(lv_obj_t * roller, uint16_t sel_opt, lv_anim_enable_
|
|||||||
*/
|
*/
|
||||||
void lv_roller_set_visible_row_count(lv_obj_t * roller, uint8_t row_cnt)
|
void lv_roller_set_visible_row_count(lv_obj_t * roller, uint8_t row_cnt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(roller, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||||
const lv_style_t * style_label = lv_obj_get_style(ext->ddlist.label);
|
const lv_style_t * style_label = lv_obj_get_style(ext->ddlist.label);
|
||||||
uint8_t n_line_space = (row_cnt > 1) ? row_cnt - 1 : 1;
|
uint8_t n_line_space = (row_cnt > 1) ? row_cnt - 1 : 1;
|
||||||
@@ -229,6 +241,8 @@ void lv_roller_set_visible_row_count(lv_obj_t * roller, uint8_t row_cnt)
|
|||||||
*/
|
*/
|
||||||
void lv_roller_set_style(lv_obj_t * roller, lv_roller_style_t type, const lv_style_t * style)
|
void lv_roller_set_style(lv_obj_t * roller, lv_roller_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(roller, LV_OBJX_NAME);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_ROLLER_STYLE_BG: lv_obj_set_style(roller, style); break;
|
case LV_ROLLER_STYLE_BG: lv_obj_set_style(roller, style); break;
|
||||||
case LV_ROLLER_STYLE_SEL: lv_ddlist_set_style(roller, LV_DDLIST_STYLE_SEL, style); break;
|
case LV_ROLLER_STYLE_SEL: lv_ddlist_set_style(roller, LV_DDLIST_STYLE_SEL, style); break;
|
||||||
@@ -246,6 +260,8 @@ void lv_roller_set_style(lv_obj_t * roller, lv_roller_style_t type, const lv_sty
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_roller_get_selected(const lv_obj_t * roller)
|
uint16_t lv_roller_get_selected(const lv_obj_t * roller)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(roller, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||||
if(ext->mode == LV_ROLLER_MODE_INIFINITE) {
|
if(ext->mode == LV_ROLLER_MODE_INIFINITE) {
|
||||||
uint16_t real_id_cnt = ext->ddlist.option_cnt / LV_ROLLER_INF_PAGES;
|
uint16_t real_id_cnt = ext->ddlist.option_cnt / LV_ROLLER_INF_PAGES;
|
||||||
@@ -262,9 +278,11 @@ uint16_t lv_roller_get_selected(const lv_obj_t * roller)
|
|||||||
*/
|
*/
|
||||||
lv_label_align_t lv_roller_get_align(const lv_obj_t * roller)
|
lv_label_align_t lv_roller_get_align(const lv_obj_t * roller)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(roller, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
lv_mem_assert(ext->ddlist.label);
|
LV_ASSERT_MEM(ext->ddlist.label);
|
||||||
return lv_label_get_align(ext->ddlist.label);
|
return lv_label_get_align(ext->ddlist.label);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,6 +293,8 @@ lv_label_align_t lv_roller_get_align(const lv_obj_t * roller)
|
|||||||
*/
|
*/
|
||||||
bool lv_roller_get_hor_fit(const lv_obj_t * roller)
|
bool lv_roller_get_hor_fit(const lv_obj_t * roller)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(roller, LV_OBJX_NAME);
|
||||||
|
|
||||||
return lv_page_get_scrl_fit_left(roller);
|
return lv_page_get_scrl_fit_left(roller);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,6 +306,8 @@ bool lv_roller_get_hor_fit(const lv_obj_t * roller)
|
|||||||
* */
|
* */
|
||||||
const lv_style_t * lv_roller_get_style(const lv_obj_t * roller, lv_roller_style_t type)
|
const lv_style_t * lv_roller_get_style(const lv_obj_t * roller, lv_roller_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(roller, LV_OBJX_NAME);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_ROLLER_STYLE_BG: return lv_obj_get_style(roller);
|
case LV_ROLLER_STYLE_BG: return lv_obj_get_style(roller);
|
||||||
case LV_ROLLER_STYLE_SEL: return lv_ddlist_get_style(roller, LV_DDLIST_STYLE_SEL);
|
case LV_ROLLER_STYLE_SEL: return lv_ddlist_get_style(roller, LV_DDLIST_STYLE_SEL);
|
||||||
@@ -399,6 +421,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
|||||||
res = ancestor_signal(roller, sign, param);
|
res = ancestor_signal(roller, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
}
|
}
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||||
|
|
||||||
@@ -465,13 +488,6 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
|||||||
ext->ddlist.sel_opt_id_ori = ori_id;
|
ext->ddlist.sel_opt_id_ori = ori_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_roller";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "lv_slider.h"
|
#include "lv_slider.h"
|
||||||
#if LV_USE_SLIDER != 0
|
#if LV_USE_SLIDER != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_core/lv_group.h"
|
#include "../lv_core/lv_group.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_slider"
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -55,7 +57,7 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor slider*/
|
/*Create the ancestor slider*/
|
||||||
lv_obj_t * new_slider = lv_bar_create(par, copy);
|
lv_obj_t * new_slider = lv_bar_create(par, copy);
|
||||||
lv_mem_assert(new_slider);
|
LV_ASSERT_MEM(new_slider);
|
||||||
if(new_slider == NULL) return NULL;
|
if(new_slider == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_cb(new_slider);
|
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_cb(new_slider);
|
||||||
@@ -63,7 +65,7 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Allocate the slider type specific extended data*/
|
/*Allocate the slider type specific extended data*/
|
||||||
lv_slider_ext_t * ext = lv_obj_allocate_ext_attr(new_slider, sizeof(lv_slider_ext_t));
|
lv_slider_ext_t * ext = lv_obj_allocate_ext_attr(new_slider, sizeof(lv_slider_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
/*Initialize the allocated 'ext' */
|
/*Initialize the allocated 'ext' */
|
||||||
@@ -113,6 +115,8 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_slider_set_style(lv_obj_t * slider, lv_slider_style_t type, const lv_style_t * style)
|
void lv_slider_set_style(lv_obj_t * slider, lv_slider_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(slider, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -136,6 +140,7 @@ void lv_slider_set_style(lv_obj_t * slider, lv_slider_style_t type, const lv_sty
|
|||||||
*/
|
*/
|
||||||
int16_t lv_slider_get_value(const lv_obj_t * slider)
|
int16_t lv_slider_get_value(const lv_obj_t * slider)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(slider, LV_OBJX_NAME);
|
||||||
return lv_bar_get_value(slider);
|
return lv_bar_get_value(slider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,6 +151,8 @@ int16_t lv_slider_get_value(const lv_obj_t * slider)
|
|||||||
*/
|
*/
|
||||||
bool lv_slider_is_dragged(const lv_obj_t * slider)
|
bool lv_slider_is_dragged(const lv_obj_t * slider)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(slider, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
||||||
return ext->dragging ? true : false;
|
return ext->dragging ? true : false;
|
||||||
}
|
}
|
||||||
@@ -158,6 +165,8 @@ bool lv_slider_is_dragged(const lv_obj_t * slider)
|
|||||||
*/
|
*/
|
||||||
const lv_style_t * lv_slider_get_style(const lv_obj_t * slider, lv_slider_style_t type)
|
const lv_style_t * lv_slider_get_style(const lv_obj_t * slider, lv_slider_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(slider, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
||||||
|
|
||||||
@@ -273,6 +282,7 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(slider, sign, param);
|
res = ancestor_signal(slider, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
||||||
lv_point_t p;
|
lv_point_t p;
|
||||||
@@ -369,13 +379,6 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
|
|||||||
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
||||||
bool * editable = (bool *)param;
|
bool * editable = (bool *)param;
|
||||||
*editable = true;
|
*editable = true;
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_slider";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "lv_spinbox.h"
|
#include "lv_spinbox.h"
|
||||||
|
|
||||||
#if LV_USE_SPINBOX != 0
|
#if LV_USE_SPINBOX != 0
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
#include "../lv_misc/lv_math.h"
|
#include "../lv_misc/lv_math.h"
|
||||||
#include "../lv_misc/lv_utils.h"
|
#include "../lv_misc/lv_utils.h"
|
||||||
@@ -16,6 +17,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_spinbox"
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -53,12 +55,12 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor of spinbox*/
|
/*Create the ancestor of spinbox*/
|
||||||
lv_obj_t * new_spinbox = lv_ta_create(par, copy);
|
lv_obj_t * new_spinbox = lv_ta_create(par, copy);
|
||||||
lv_mem_assert(new_spinbox);
|
LV_ASSERT_MEM(new_spinbox);
|
||||||
if(new_spinbox == NULL) return NULL;
|
if(new_spinbox == NULL) return NULL;
|
||||||
|
|
||||||
/*Allocate the spinbox type specific extended data*/
|
/*Allocate the spinbox type specific extended data*/
|
||||||
lv_spinbox_ext_t * ext = lv_obj_allocate_ext_attr(new_spinbox, sizeof(lv_spinbox_ext_t));
|
lv_spinbox_ext_t * ext = lv_obj_allocate_ext_attr(new_spinbox, sizeof(lv_spinbox_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_spinbox);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_spinbox);
|
||||||
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_spinbox);
|
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_spinbox);
|
||||||
@@ -121,6 +123,8 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_spinbox_set_value(lv_obj_t * spinbox, int32_t i)
|
void lv_spinbox_set_value(lv_obj_t * spinbox, int32_t i)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(spinbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||||
if(ext == NULL) return;
|
if(ext == NULL) return;
|
||||||
|
|
||||||
@@ -141,6 +145,8 @@ void lv_spinbox_set_value(lv_obj_t * spinbox, int32_t i)
|
|||||||
*/
|
*/
|
||||||
void lv_spinbox_set_digit_format(lv_obj_t * spinbox, uint8_t digit_count, uint8_t separator_position)
|
void lv_spinbox_set_digit_format(lv_obj_t * spinbox, uint8_t digit_count, uint8_t separator_position)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(spinbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||||
if(ext == NULL) return;
|
if(ext == NULL) return;
|
||||||
|
|
||||||
@@ -161,6 +167,8 @@ void lv_spinbox_set_digit_format(lv_obj_t * spinbox, uint8_t digit_count, uint8_
|
|||||||
*/
|
*/
|
||||||
void lv_spinbox_set_step(lv_obj_t * spinbox, uint32_t step)
|
void lv_spinbox_set_step(lv_obj_t * spinbox, uint32_t step)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(spinbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||||
if(ext == NULL) return;
|
if(ext == NULL) return;
|
||||||
|
|
||||||
@@ -175,6 +183,8 @@ void lv_spinbox_set_step(lv_obj_t * spinbox, uint32_t step)
|
|||||||
*/
|
*/
|
||||||
void lv_spinbox_set_range(lv_obj_t * spinbox, int32_t range_min, int32_t range_max)
|
void lv_spinbox_set_range(lv_obj_t * spinbox, int32_t range_min, int32_t range_max)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(spinbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||||
if(ext == NULL) return;
|
if(ext == NULL) return;
|
||||||
|
|
||||||
@@ -198,6 +208,8 @@ void lv_spinbox_set_range(lv_obj_t * spinbox, int32_t range_min, int32_t range_m
|
|||||||
*/
|
*/
|
||||||
void lv_spinbox_set_padding_left(lv_obj_t * spinbox, uint8_t padding)
|
void lv_spinbox_set_padding_left(lv_obj_t * spinbox, uint8_t padding)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(spinbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||||
ext->digit_padding_left = padding;
|
ext->digit_padding_left = padding;
|
||||||
lv_spinbox_updatevalue(spinbox);
|
lv_spinbox_updatevalue(spinbox);
|
||||||
@@ -214,6 +226,8 @@ void lv_spinbox_set_padding_left(lv_obj_t * spinbox, uint8_t padding)
|
|||||||
*/
|
*/
|
||||||
int32_t lv_spinbox_get_value(lv_obj_t * spinbox)
|
int32_t lv_spinbox_get_value(lv_obj_t * spinbox)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(spinbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||||
|
|
||||||
return ext->value;
|
return ext->value;
|
||||||
@@ -229,6 +243,8 @@ int32_t lv_spinbox_get_value(lv_obj_t * spinbox)
|
|||||||
*/
|
*/
|
||||||
void lv_spinbox_step_next(lv_obj_t * spinbox)
|
void lv_spinbox_step_next(lv_obj_t * spinbox)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(spinbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||||
|
|
||||||
int32_t new_step = ext->step / 10;
|
int32_t new_step = ext->step / 10;
|
||||||
@@ -246,6 +262,8 @@ void lv_spinbox_step_next(lv_obj_t * spinbox)
|
|||||||
*/
|
*/
|
||||||
void lv_spinbox_step_prev(lv_obj_t * spinbox)
|
void lv_spinbox_step_prev(lv_obj_t * spinbox)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(spinbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||||
int32_t step_limit;
|
int32_t step_limit;
|
||||||
step_limit = LV_MATH_MAX(ext->range_max, (ext->range_min < 0 ? (-ext->range_min) : ext->range_min));
|
step_limit = LV_MATH_MAX(ext->range_max, (ext->range_min < 0 ? (-ext->range_min) : ext->range_min));
|
||||||
@@ -261,6 +279,8 @@ void lv_spinbox_step_prev(lv_obj_t * spinbox)
|
|||||||
*/
|
*/
|
||||||
void lv_spinbox_increment(lv_obj_t * spinbox)
|
void lv_spinbox_increment(lv_obj_t * spinbox)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(spinbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||||
|
|
||||||
if(ext->value + ext->step <= ext->range_max) {
|
if(ext->value + ext->step <= ext->range_max) {
|
||||||
@@ -281,6 +301,8 @@ void lv_spinbox_increment(lv_obj_t * spinbox)
|
|||||||
*/
|
*/
|
||||||
void lv_spinbox_decrement(lv_obj_t * spinbox)
|
void lv_spinbox_decrement(lv_obj_t * spinbox)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(spinbox, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||||
|
|
||||||
if(ext->value - ext->step >= ext->range_min) {
|
if(ext->value - ext->step >= ext->range_min) {
|
||||||
@@ -317,6 +339,7 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
|
|||||||
res = ancestor_signal(spinbox, sign, param);
|
res = ancestor_signal(spinbox, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
}
|
}
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||||
|
|||||||
@@ -15,12 +15,14 @@
|
|||||||
#error "lv_sw: lv_slider is required. Enable it in lv_conf.h (LV_USE_SLIDER 1) "
|
#error "lv_sw: lv_slider is required. Enable it in lv_conf.h (LV_USE_SLIDER 1) "
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
#include "../lv_misc/lv_math.h"
|
#include "../lv_misc/lv_math.h"
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_sw"
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -58,7 +60,8 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor of switch*/
|
/*Create the ancestor of switch*/
|
||||||
lv_obj_t * new_sw = lv_bar_create(par, copy);
|
lv_obj_t * new_sw = lv_bar_create(par, copy);
|
||||||
lv_mem_assert(new_sw);
|
LV_ASSERT_MEM(new_sw);
|
||||||
|
|
||||||
if(new_sw == NULL) return NULL;
|
if(new_sw == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_sw);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_sw);
|
||||||
@@ -66,7 +69,7 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Allocate the switch type specific extended data*/
|
/*Allocate the switch type specific extended data*/
|
||||||
lv_sw_ext_t * ext = lv_obj_allocate_ext_attr(new_sw, sizeof(lv_sw_ext_t));
|
lv_sw_ext_t * ext = lv_obj_allocate_ext_attr(new_sw, sizeof(lv_sw_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
/*Initialize the allocated 'ext' */
|
/*Initialize the allocated 'ext' */
|
||||||
@@ -128,6 +131,8 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_sw_on(lv_obj_t * sw, lv_anim_enable_t anim)
|
void lv_sw_on(lv_obj_t * sw, lv_anim_enable_t anim)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(sw, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION == 0
|
#if LV_USE_ANIMATION == 0
|
||||||
anim = LV_ANIM_OFF;
|
anim = LV_ANIM_OFF;
|
||||||
#endif
|
#endif
|
||||||
@@ -144,6 +149,8 @@ void lv_sw_on(lv_obj_t * sw, lv_anim_enable_t anim)
|
|||||||
*/
|
*/
|
||||||
void lv_sw_off(lv_obj_t * sw, lv_anim_enable_t anim)
|
void lv_sw_off(lv_obj_t * sw, lv_anim_enable_t anim)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(sw, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION == 0
|
#if LV_USE_ANIMATION == 0
|
||||||
anim = LV_ANIM_OFF;
|
anim = LV_ANIM_OFF;
|
||||||
#endif
|
#endif
|
||||||
@@ -161,6 +168,8 @@ void lv_sw_off(lv_obj_t * sw, lv_anim_enable_t anim)
|
|||||||
*/
|
*/
|
||||||
bool lv_sw_toggle(lv_obj_t * sw, lv_anim_enable_t anim)
|
bool lv_sw_toggle(lv_obj_t * sw, lv_anim_enable_t anim)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(sw, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION == 0
|
#if LV_USE_ANIMATION == 0
|
||||||
anim = LV_ANIM_OFF;
|
anim = LV_ANIM_OFF;
|
||||||
#endif
|
#endif
|
||||||
@@ -182,6 +191,8 @@ bool lv_sw_toggle(lv_obj_t * sw, lv_anim_enable_t anim)
|
|||||||
*/
|
*/
|
||||||
void lv_sw_set_style(lv_obj_t * sw, lv_sw_style_t type, const lv_style_t * style)
|
void lv_sw_set_style(lv_obj_t * sw, lv_sw_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(sw, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
|
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -200,6 +211,8 @@ void lv_sw_set_style(lv_obj_t * sw, lv_sw_style_t type, const lv_style_t * style
|
|||||||
|
|
||||||
void lv_sw_set_anim_time(lv_obj_t * sw, uint16_t anim_time)
|
void lv_sw_set_anim_time(lv_obj_t * sw, uint16_t anim_time)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(sw, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
|
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
|
||||||
ext->anim_time = anim_time;
|
ext->anim_time = anim_time;
|
||||||
@@ -221,6 +234,8 @@ void lv_sw_set_anim_time(lv_obj_t * sw, uint16_t anim_time)
|
|||||||
*/
|
*/
|
||||||
const lv_style_t * lv_sw_get_style(const lv_obj_t * sw, lv_sw_style_t type)
|
const lv_style_t * lv_sw_get_style(const lv_obj_t * sw, lv_sw_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(sw, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
|
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
|
||||||
|
|
||||||
@@ -237,6 +252,7 @@ const lv_style_t * lv_sw_get_style(const lv_obj_t * sw, lv_sw_style_t type)
|
|||||||
|
|
||||||
uint16_t lv_sw_get_anim_time(const lv_obj_t * sw)
|
uint16_t lv_sw_get_anim_time(const lv_obj_t * sw)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(sw, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
|
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
|
||||||
@@ -319,6 +335,7 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(sw, sign, param);
|
res = ancestor_signal(sw, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||||
@@ -453,13 +470,6 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
|
|||||||
else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
||||||
bool * editable = (bool *)param;
|
bool * editable = (bool *)param;
|
||||||
*editable = false; /*The ancestor slider is editable the switch is not*/
|
*editable = false; /*The ancestor slider is editable the switch is not*/
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_sw";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "lv_ta.h"
|
#include "lv_ta.h"
|
||||||
#if LV_USE_TA != 0
|
#if LV_USE_TA != 0
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_core/lv_group.h"
|
#include "../lv_core/lv_group.h"
|
||||||
#include "../lv_core/lv_refr.h"
|
#include "../lv_core/lv_refr.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
@@ -20,8 +21,9 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
/*Test configuration*/
|
#define LV_OBJX_NAME "lv_ta"
|
||||||
|
|
||||||
|
/*Test configuration*/
|
||||||
#ifndef LV_TA_DEF_CURSOR_BLINK_TIME
|
#ifndef LV_TA_DEF_CURSOR_BLINK_TIME
|
||||||
#define LV_TA_DEF_CURSOR_BLINK_TIME 400 /*ms*/
|
#define LV_TA_DEF_CURSOR_BLINK_TIME 400 /*ms*/
|
||||||
#endif
|
#endif
|
||||||
@@ -85,7 +87,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor object*/
|
/*Create the ancestor object*/
|
||||||
lv_obj_t * new_ta = lv_page_create(par, copy);
|
lv_obj_t * new_ta = lv_page_create(par, copy);
|
||||||
lv_mem_assert(new_ta);
|
LV_ASSERT_MEM(new_ta);
|
||||||
if(new_ta == NULL) return NULL;
|
if(new_ta == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_ta);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_ta);
|
||||||
@@ -95,7 +97,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Allocate the object type specific extended data*/
|
/*Allocate the object type specific extended data*/
|
||||||
lv_ta_ext_t * ext = lv_obj_allocate_ext_attr(new_ta, sizeof(lv_ta_ext_t));
|
lv_ta_ext_t * ext = lv_obj_allocate_ext_attr(new_ta, sizeof(lv_ta_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
ext->cursor.state = 1;
|
ext->cursor.state = 1;
|
||||||
@@ -162,6 +164,23 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
ext->cursor.pos = copy_ext->cursor.pos;
|
ext->cursor.pos = copy_ext->cursor.pos;
|
||||||
ext->cursor.valid_x = copy_ext->cursor.valid_x;
|
ext->cursor.valid_x = copy_ext->cursor.valid_x;
|
||||||
ext->cursor.type = copy_ext->cursor.type;
|
ext->cursor.type = copy_ext->cursor.type;
|
||||||
|
|
||||||
|
if(ext->pwd_mode != 0) pwd_char_hider( new_ta);
|
||||||
|
|
||||||
|
if(copy_ext->placeholder != NULL)
|
||||||
|
ext->placeholder = lv_label_create(new_ta, copy_ext->placeholder);
|
||||||
|
else
|
||||||
|
ext->placeholder = NULL;
|
||||||
|
|
||||||
|
if(copy_ext->pwd_tmp) {
|
||||||
|
uint16_t len = lv_mem_get_size(copy_ext->pwd_tmp);
|
||||||
|
ext->pwd_tmp = lv_mem_alloc(len);
|
||||||
|
LV_ASSERT_MEM(ext->pwd_tmp);
|
||||||
|
if(ext->pwd_tmp == NULL) return NULL;
|
||||||
|
|
||||||
|
memcpy(ext->pwd_tmp, copy_ext->pwd_tmp, len);
|
||||||
|
}
|
||||||
|
|
||||||
if(copy_ext->one_line) lv_ta_set_one_line(new_ta, true);
|
if(copy_ext->one_line) lv_ta_set_one_line(new_ta, true);
|
||||||
|
|
||||||
lv_ta_set_style(new_ta, LV_TA_STYLE_CURSOR, lv_ta_get_style(copy, LV_TA_STYLE_CURSOR));
|
lv_ta_set_style(new_ta, LV_TA_STYLE_CURSOR, lv_ta_get_style(copy, LV_TA_STYLE_CURSOR));
|
||||||
@@ -207,6 +226,8 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_add_char(lv_obj_t * ta, uint32_t c)
|
void lv_ta_add_char(lv_obj_t * ta, uint32_t c)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
|
|
||||||
uint32_t letter_buf[2];
|
uint32_t letter_buf[2];
|
||||||
@@ -250,7 +271,7 @@ void lv_ta_add_char(lv_obj_t * ta, uint32_t c)
|
|||||||
if(ext->pwd_mode != 0) {
|
if(ext->pwd_mode != 0) {
|
||||||
|
|
||||||
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 2); /*+2: the new char + \0 */
|
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 2); /*+2: the new char + \0 */
|
||||||
lv_mem_assert(ext->pwd_tmp);
|
LV_ASSERT_MEM(ext->pwd_tmp);
|
||||||
if(ext->pwd_tmp == NULL) return;
|
if(ext->pwd_tmp == NULL) return;
|
||||||
|
|
||||||
lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, (const char *)letter_buf);
|
lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, (const char *)letter_buf);
|
||||||
@@ -295,6 +316,9 @@ void lv_ta_add_char(lv_obj_t * ta, uint32_t c)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_add_text(lv_obj_t * ta, const char * txt)
|
void lv_ta_add_text(lv_obj_t * ta, const char * txt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(txt);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
|
|
||||||
ta_insert_replace = NULL;
|
ta_insert_replace = NULL;
|
||||||
@@ -331,7 +355,7 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt)
|
|||||||
|
|
||||||
if(ext->pwd_mode != 0) {
|
if(ext->pwd_mode != 0) {
|
||||||
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + strlen(txt) + 1);
|
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + strlen(txt) + 1);
|
||||||
lv_mem_assert(ext->pwd_tmp);
|
LV_ASSERT_MEM(ext->pwd_tmp);
|
||||||
if(ext->pwd_tmp == NULL) return;
|
if(ext->pwd_tmp == NULL) return;
|
||||||
|
|
||||||
lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, txt);
|
lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, txt);
|
||||||
@@ -374,6 +398,8 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_del_char(lv_obj_t * ta)
|
void lv_ta_del_char(lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
uint16_t cur_pos = ext->cursor.pos;
|
uint16_t cur_pos = ext->cursor.pos;
|
||||||
|
|
||||||
@@ -410,7 +436,7 @@ void lv_ta_del_char(lv_obj_t * ta)
|
|||||||
lv_txt_cut(ext->pwd_tmp, ext->cursor.pos - 1, lv_txt_encoded_size(&label_txt[byte_pos]));
|
lv_txt_cut(ext->pwd_tmp, ext->cursor.pos - 1, lv_txt_encoded_size(&label_txt[byte_pos]));
|
||||||
|
|
||||||
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 1);
|
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 1);
|
||||||
lv_mem_assert(ext->pwd_tmp);
|
LV_ASSERT_MEM(ext->pwd_tmp);
|
||||||
if(ext->pwd_tmp == NULL) return;
|
if(ext->pwd_tmp == NULL) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,6 +454,8 @@ void lv_ta_del_char(lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_del_char_forward(lv_obj_t * ta)
|
void lv_ta_del_char_forward(lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
uint16_t cp = lv_ta_get_cursor_pos(ta);
|
uint16_t cp = lv_ta_get_cursor_pos(ta);
|
||||||
lv_ta_set_cursor_pos(ta, cp + 1);
|
lv_ta_set_cursor_pos(ta, cp + 1);
|
||||||
if(cp != lv_ta_get_cursor_pos(ta)) lv_ta_del_char(ta);
|
if(cp != lv_ta_get_cursor_pos(ta)) lv_ta_del_char(ta);
|
||||||
@@ -444,6 +472,9 @@ void lv_ta_del_char_forward(lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_set_text(lv_obj_t * ta, const char * txt)
|
void lv_ta_set_text(lv_obj_t * ta, const char * txt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(txt);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
|
|
||||||
/*Clear the existing selection*/
|
/*Clear the existing selection*/
|
||||||
@@ -472,7 +503,7 @@ void lv_ta_set_text(lv_obj_t * ta, const char * txt)
|
|||||||
|
|
||||||
if(ext->pwd_mode != 0) {
|
if(ext->pwd_mode != 0) {
|
||||||
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(txt) + 1);
|
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(txt) + 1);
|
||||||
lv_mem_assert(ext->pwd_tmp);
|
LV_ASSERT_MEM(ext->pwd_tmp);
|
||||||
if(ext->pwd_tmp == NULL) return;
|
if(ext->pwd_tmp == NULL) return;
|
||||||
strcpy(ext->pwd_tmp, txt);
|
strcpy(ext->pwd_tmp, txt);
|
||||||
|
|
||||||
@@ -509,6 +540,9 @@ void lv_ta_set_text(lv_obj_t * ta, const char * txt)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_set_placeholder_text(lv_obj_t * ta, const char * txt)
|
void lv_ta_set_placeholder_text(lv_obj_t * ta, const char * txt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(txt);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
|
|
||||||
/*Create the placeholder label only when it is needed*/
|
/*Create the placeholder label only when it is needed*/
|
||||||
@@ -536,6 +570,8 @@ void lv_ta_set_placeholder_text(lv_obj_t * ta, const char * txt)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
|
void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
if(ext->cursor.pos == pos) return;
|
if(ext->cursor.pos == pos) return;
|
||||||
|
|
||||||
@@ -612,6 +648,8 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_set_cursor_type(lv_obj_t * ta, lv_cursor_type_t cur_type)
|
void lv_ta_set_cursor_type(lv_obj_t * ta, lv_cursor_type_t cur_type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
if(ext->cursor.type == cur_type) return;
|
if(ext->cursor.type == cur_type) return;
|
||||||
|
|
||||||
@@ -627,6 +665,8 @@ void lv_ta_set_cursor_type(lv_obj_t * ta, lv_cursor_type_t cur_type)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_set_cursor_click_pos(lv_obj_t * ta, bool en)
|
void lv_ta_set_cursor_click_pos(lv_obj_t * ta, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
ext->cursor.click_pos = en ? 1 : 0;
|
ext->cursor.click_pos = en ? 1 : 0;
|
||||||
}
|
}
|
||||||
@@ -638,6 +678,8 @@ void lv_ta_set_cursor_click_pos(lv_obj_t * ta, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_set_pwd_mode(lv_obj_t * ta, bool en)
|
void lv_ta_set_pwd_mode(lv_obj_t * ta, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
if(ext->pwd_mode == en) return;
|
if(ext->pwd_mode == en) return;
|
||||||
|
|
||||||
@@ -646,13 +688,14 @@ void lv_ta_set_pwd_mode(lv_obj_t * ta, bool en)
|
|||||||
char * txt = lv_label_get_text(ext->label);
|
char * txt = lv_label_get_text(ext->label);
|
||||||
uint16_t len = strlen(txt);
|
uint16_t len = strlen(txt);
|
||||||
ext->pwd_tmp = lv_mem_alloc(len + 1);
|
ext->pwd_tmp = lv_mem_alloc(len + 1);
|
||||||
lv_mem_assert(ext->pwd_tmp);
|
LV_ASSERT_MEM(ext->pwd_tmp);
|
||||||
if(ext->pwd_tmp == NULL) return;
|
if(ext->pwd_tmp == NULL) return;
|
||||||
|
|
||||||
strcpy(ext->pwd_tmp, txt);
|
strcpy(ext->pwd_tmp, txt);
|
||||||
|
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
for(i = 0; i < len; i++) {
|
uint16_t encoded_len = lv_txt_get_encoded_length(txt);
|
||||||
|
for(i = 0; i < encoded_len; i++) {
|
||||||
txt[i] = '*'; /*All char to '*'*/
|
txt[i] = '*'; /*All char to '*'*/
|
||||||
}
|
}
|
||||||
txt[i] = '\0';
|
txt[i] = '\0';
|
||||||
@@ -681,6 +724,8 @@ void lv_ta_set_pwd_mode(lv_obj_t * ta, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_set_one_line(lv_obj_t * ta, bool en)
|
void lv_ta_set_one_line(lv_obj_t * ta, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
if(ext->one_line == en) return;
|
if(ext->one_line == en) return;
|
||||||
|
|
||||||
@@ -722,6 +767,8 @@ void lv_ta_set_one_line(lv_obj_t * ta, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_set_text_align(lv_obj_t * ta, lv_label_align_t align)
|
void lv_ta_set_text_align(lv_obj_t * ta, lv_label_align_t align)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
lv_obj_t * label = lv_ta_get_label(ta);
|
lv_obj_t * label = lv_ta_get_label(ta);
|
||||||
if(!ext->one_line) {
|
if(!ext->one_line) {
|
||||||
@@ -754,6 +801,8 @@ void lv_ta_set_text_align(lv_obj_t * ta, lv_label_align_t align)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_set_accepted_chars(lv_obj_t * ta, const char * list)
|
void lv_ta_set_accepted_chars(lv_obj_t * ta, const char * list)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
|
|
||||||
ext->accapted_chars = list;
|
ext->accapted_chars = list;
|
||||||
@@ -766,6 +815,8 @@ void lv_ta_set_accepted_chars(lv_obj_t * ta, const char * list)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_set_max_length(lv_obj_t * ta, uint16_t num)
|
void lv_ta_set_max_length(lv_obj_t * ta, uint16_t num)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
|
|
||||||
ext->max_length = num;
|
ext->max_length = num;
|
||||||
@@ -781,6 +832,8 @@ void lv_ta_set_max_length(lv_obj_t * ta, uint16_t num)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_set_insert_replace(lv_obj_t * ta, const char * txt)
|
void lv_ta_set_insert_replace(lv_obj_t * ta, const char * txt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
(void)ta; /*Unused*/
|
(void)ta; /*Unused*/
|
||||||
ta_insert_replace = txt;
|
ta_insert_replace = txt;
|
||||||
}
|
}
|
||||||
@@ -793,6 +846,8 @@ void lv_ta_set_insert_replace(lv_obj_t * ta, const char * txt)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_set_style(lv_obj_t * ta, lv_ta_style_t type, const lv_style_t * style)
|
void lv_ta_set_style(lv_obj_t * ta, lv_ta_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -817,6 +872,8 @@ void lv_ta_set_style(lv_obj_t * ta, lv_ta_style_t type, const lv_style_t * style
|
|||||||
*/
|
*/
|
||||||
void lv_ta_set_text_sel(lv_obj_t * ta, bool en)
|
void lv_ta_set_text_sel(lv_obj_t * ta, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SEL
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
|
|
||||||
@@ -836,6 +893,8 @@ void lv_ta_set_text_sel(lv_obj_t * ta, bool en)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_set_pwd_show_time(lv_obj_t * ta, uint16_t time)
|
void lv_ta_set_pwd_show_time(lv_obj_t * ta, uint16_t time)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION == 0
|
#if LV_USE_ANIMATION == 0
|
||||||
time = 0;
|
time = 0;
|
||||||
#endif
|
#endif
|
||||||
@@ -851,6 +910,8 @@ void lv_ta_set_pwd_show_time(lv_obj_t * ta, uint16_t time)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_set_cursor_blink_time(lv_obj_t * ta, uint16_t time)
|
void lv_ta_set_cursor_blink_time(lv_obj_t * ta, uint16_t time)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION == 0
|
#if LV_USE_ANIMATION == 0
|
||||||
time = 0;
|
time = 0;
|
||||||
#endif
|
#endif
|
||||||
@@ -894,6 +955,8 @@ void lv_ta_set_cursor_blink_time(lv_obj_t * ta, uint16_t time)
|
|||||||
*/
|
*/
|
||||||
const char * lv_ta_get_text(const lv_obj_t * ta)
|
const char * lv_ta_get_text(const lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
|
|
||||||
const char * txt;
|
const char * txt;
|
||||||
@@ -913,11 +976,13 @@ const char * lv_ta_get_text(const lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
const char * lv_ta_get_placeholder_text(lv_obj_t * ta)
|
const char * lv_ta_get_placeholder_text(lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
|
|
||||||
const char * txt = NULL;
|
const char * txt = NULL;
|
||||||
|
|
||||||
if(ext->placeholder) txt = lv_label_get_text(ext->label);
|
if(ext->placeholder) txt = lv_label_get_text(ext->placeholder);
|
||||||
|
|
||||||
return txt;
|
return txt;
|
||||||
}
|
}
|
||||||
@@ -929,6 +994,8 @@ const char * lv_ta_get_placeholder_text(lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_ta_get_label(const lv_obj_t * ta)
|
lv_obj_t * lv_ta_get_label(const lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
return ext->label;
|
return ext->label;
|
||||||
}
|
}
|
||||||
@@ -940,6 +1007,8 @@ lv_obj_t * lv_ta_get_label(const lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_ta_get_cursor_pos(const lv_obj_t * ta)
|
uint16_t lv_ta_get_cursor_pos(const lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
return ext->cursor.pos;
|
return ext->cursor.pos;
|
||||||
}
|
}
|
||||||
@@ -951,6 +1020,8 @@ uint16_t lv_ta_get_cursor_pos(const lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
lv_cursor_type_t lv_ta_get_cursor_type(const lv_obj_t * ta)
|
lv_cursor_type_t lv_ta_get_cursor_type(const lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
return ext->cursor.type;
|
return ext->cursor.type;
|
||||||
}
|
}
|
||||||
@@ -962,6 +1033,8 @@ lv_cursor_type_t lv_ta_get_cursor_type(const lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
bool lv_ta_get_cursor_click_pos(lv_obj_t * ta)
|
bool lv_ta_get_cursor_click_pos(lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
return ext->cursor.click_pos ? true : false;
|
return ext->cursor.click_pos ? true : false;
|
||||||
}
|
}
|
||||||
@@ -973,6 +1046,8 @@ bool lv_ta_get_cursor_click_pos(lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
bool lv_ta_get_pwd_mode(const lv_obj_t * ta)
|
bool lv_ta_get_pwd_mode(const lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
return ext->pwd_mode == 0 ? false : true;
|
return ext->pwd_mode == 0 ? false : true;
|
||||||
}
|
}
|
||||||
@@ -984,6 +1059,8 @@ bool lv_ta_get_pwd_mode(const lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
bool lv_ta_get_one_line(const lv_obj_t * ta)
|
bool lv_ta_get_one_line(const lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
return ext->one_line == 0 ? false : true;
|
return ext->one_line == 0 ? false : true;
|
||||||
}
|
}
|
||||||
@@ -995,6 +1072,8 @@ bool lv_ta_get_one_line(const lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
const char * lv_ta_get_accepted_chars(lv_obj_t * ta)
|
const char * lv_ta_get_accepted_chars(lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
|
|
||||||
return ext->accapted_chars;
|
return ext->accapted_chars;
|
||||||
@@ -1007,6 +1086,8 @@ const char * lv_ta_get_accepted_chars(lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_ta_get_max_length(lv_obj_t * ta)
|
uint16_t lv_ta_get_max_length(lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
return ext->max_length;
|
return ext->max_length;
|
||||||
}
|
}
|
||||||
@@ -1019,6 +1100,8 @@ uint16_t lv_ta_get_max_length(lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
const lv_style_t * lv_ta_get_style(const lv_obj_t * ta, lv_ta_style_t type)
|
const lv_style_t * lv_ta_get_style(const lv_obj_t * ta, lv_ta_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
|
|
||||||
@@ -1043,6 +1126,8 @@ const lv_style_t * lv_ta_get_style(const lv_obj_t * ta, lv_ta_style_t type)
|
|||||||
*/
|
*/
|
||||||
bool lv_ta_text_is_selected(const lv_obj_t * ta)
|
bool lv_ta_text_is_selected(const lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SEL
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
|
|
||||||
@@ -1065,6 +1150,8 @@ bool lv_ta_text_is_selected(const lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
bool lv_ta_get_text_sel_en(lv_obj_t * ta)
|
bool lv_ta_get_text_sel_en(lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SEL
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
return ext->text_sel_en;
|
return ext->text_sel_en;
|
||||||
@@ -1081,6 +1168,8 @@ bool lv_ta_get_text_sel_en(lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_ta_get_pwd_show_time(lv_obj_t * ta)
|
uint16_t lv_ta_get_pwd_show_time(lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
|
|
||||||
return ext->pwd_show_time;
|
return ext->pwd_show_time;
|
||||||
@@ -1093,6 +1182,8 @@ uint16_t lv_ta_get_pwd_show_time(lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_ta_get_cursor_blink_time(lv_obj_t * ta)
|
uint16_t lv_ta_get_cursor_blink_time(lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
return ext->cursor.blink_time;
|
return ext->cursor.blink_time;
|
||||||
}
|
}
|
||||||
@@ -1107,6 +1198,8 @@ uint16_t lv_ta_get_cursor_blink_time(lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_clear_selection(lv_obj_t * ta)
|
void lv_ta_clear_selection(lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SEL
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
|
|
||||||
@@ -1126,6 +1219,8 @@ void lv_ta_clear_selection(lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_cursor_right(lv_obj_t * ta)
|
void lv_ta_cursor_right(lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
uint16_t cp = lv_ta_get_cursor_pos(ta);
|
uint16_t cp = lv_ta_get_cursor_pos(ta);
|
||||||
cp++;
|
cp++;
|
||||||
lv_ta_set_cursor_pos(ta, cp);
|
lv_ta_set_cursor_pos(ta, cp);
|
||||||
@@ -1137,6 +1232,8 @@ void lv_ta_cursor_right(lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_cursor_left(lv_obj_t * ta)
|
void lv_ta_cursor_left(lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
uint16_t cp = lv_ta_get_cursor_pos(ta);
|
uint16_t cp = lv_ta_get_cursor_pos(ta);
|
||||||
if(cp > 0) {
|
if(cp > 0) {
|
||||||
cp--;
|
cp--;
|
||||||
@@ -1150,6 +1247,8 @@ void lv_ta_cursor_left(lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_cursor_down(lv_obj_t * ta)
|
void lv_ta_cursor_down(lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
lv_point_t pos;
|
lv_point_t pos;
|
||||||
|
|
||||||
@@ -1180,6 +1279,8 @@ void lv_ta_cursor_down(lv_obj_t * ta)
|
|||||||
*/
|
*/
|
||||||
void lv_ta_cursor_up(lv_obj_t * ta)
|
void lv_ta_cursor_up(lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
lv_point_t pos;
|
lv_point_t pos;
|
||||||
|
|
||||||
@@ -1313,6 +1414,7 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(ta, sign, param);
|
res = ancestor_signal(ta, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
@@ -1393,13 +1495,6 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
|
|||||||
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
||||||
bool * editable = (bool *)param;
|
bool * editable = (bool *)param;
|
||||||
*editable = true;
|
*editable = true;
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_ta";
|
|
||||||
} else if(sign == LV_SIGNAL_DEFOCUS) {
|
} else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||||
lv_cursor_type_t cur_type;
|
lv_cursor_type_t cur_type;
|
||||||
cur_type = lv_ta_get_cursor_type(ta);
|
cur_type = lv_ta_get_cursor_type(ta);
|
||||||
@@ -1443,6 +1538,7 @@ static lv_res_t lv_ta_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = scrl_signal(scrl, sign, param);
|
res = scrl_signal(scrl, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, "");
|
||||||
|
|
||||||
lv_obj_t * ta = lv_obj_get_parent(scrl);
|
lv_obj_t * ta = lv_obj_get_parent(scrl);
|
||||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "lv_table.h"
|
#include "lv_table.h"
|
||||||
#if LV_USE_TABLE != 0
|
#if LV_USE_TABLE != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_misc/lv_txt.h"
|
#include "../lv_misc/lv_txt.h"
|
||||||
#include "../lv_misc/lv_math.h"
|
#include "../lv_misc/lv_math.h"
|
||||||
#include "../lv_draw/lv_draw_label.h"
|
#include "../lv_draw/lv_draw_label.h"
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_table"
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -56,12 +58,12 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor of table*/
|
/*Create the ancestor of table*/
|
||||||
lv_obj_t * new_table = lv_obj_create(par, copy);
|
lv_obj_t * new_table = lv_obj_create(par, copy);
|
||||||
lv_mem_assert(new_table);
|
LV_ASSERT_MEM(new_table);
|
||||||
if(new_table == NULL) return NULL;
|
if(new_table == NULL) return NULL;
|
||||||
|
|
||||||
/*Allocate the table type specific extended data*/
|
/*Allocate the table type specific extended data*/
|
||||||
lv_table_ext_t * ext = lv_obj_allocate_ext_attr(new_table, sizeof(lv_table_ext_t));
|
lv_table_ext_t * ext = lv_obj_allocate_ext_attr(new_table, sizeof(lv_table_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_table);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_table);
|
||||||
if(ancestor_scrl_design == NULL) ancestor_scrl_design = lv_obj_get_design_cb(new_table);
|
if(ancestor_scrl_design == NULL) ancestor_scrl_design = lv_obj_get_design_cb(new_table);
|
||||||
@@ -132,6 +134,9 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_table_set_cell_value(lv_obj_t * table, uint16_t row, uint16_t col, const char * txt)
|
void lv_table_set_cell_value(lv_obj_t * table, uint16_t row, uint16_t col, const char * txt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(txt);
|
||||||
|
|
||||||
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
||||||
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
||||||
LV_LOG_WARN("lv_table_set_cell_value: invalid row or column");
|
LV_LOG_WARN("lv_table_set_cell_value: invalid row or column");
|
||||||
@@ -165,6 +170,8 @@ void lv_table_set_cell_value(lv_obj_t * table, uint16_t row, uint16_t col, const
|
|||||||
*/
|
*/
|
||||||
void lv_table_set_row_cnt(lv_obj_t * table, uint16_t row_cnt)
|
void lv_table_set_row_cnt(lv_obj_t * table, uint16_t row_cnt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
||||||
uint16_t old_row_cnt = ext->row_cnt;
|
uint16_t old_row_cnt = ext->row_cnt;
|
||||||
ext->row_cnt = row_cnt;
|
ext->row_cnt = row_cnt;
|
||||||
@@ -193,6 +200,7 @@ void lv_table_set_row_cnt(lv_obj_t * table, uint16_t row_cnt)
|
|||||||
*/
|
*/
|
||||||
void lv_table_set_col_cnt(lv_obj_t * table, uint16_t col_cnt)
|
void lv_table_set_col_cnt(lv_obj_t * table, uint16_t col_cnt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(col_cnt >= LV_TABLE_COL_MAX) {
|
if(col_cnt >= LV_TABLE_COL_MAX) {
|
||||||
LV_LOG_WARN("lv_table_set_col_cnt: too many columns. Must be < LV_TABLE_COL_MAX.");
|
LV_LOG_WARN("lv_table_set_col_cnt: too many columns. Must be < LV_TABLE_COL_MAX.");
|
||||||
@@ -227,6 +235,8 @@ void lv_table_set_col_cnt(lv_obj_t * table, uint16_t col_cnt)
|
|||||||
*/
|
*/
|
||||||
void lv_table_set_col_width(lv_obj_t * table, uint16_t col_id, lv_coord_t w)
|
void lv_table_set_col_width(lv_obj_t * table, uint16_t col_id, lv_coord_t w)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(col_id >= LV_TABLE_COL_MAX) {
|
if(col_id >= LV_TABLE_COL_MAX) {
|
||||||
LV_LOG_WARN("lv_table_set_col_width: too big 'col_id'. Must be < LV_TABLE_COL_MAX.");
|
LV_LOG_WARN("lv_table_set_col_width: too big 'col_id'. Must be < LV_TABLE_COL_MAX.");
|
||||||
return;
|
return;
|
||||||
@@ -246,6 +256,8 @@ void lv_table_set_col_width(lv_obj_t * table, uint16_t col_id, lv_coord_t w)
|
|||||||
*/
|
*/
|
||||||
void lv_table_set_cell_align(lv_obj_t * table, uint16_t row, uint16_t col, lv_label_align_t align)
|
void lv_table_set_cell_align(lv_obj_t * table, uint16_t row, uint16_t col, lv_label_align_t align)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
||||||
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
||||||
LV_LOG_WARN("lv_table_set_cell_align: invalid row or column");
|
LV_LOG_WARN("lv_table_set_cell_align: invalid row or column");
|
||||||
@@ -274,6 +286,8 @@ void lv_table_set_cell_align(lv_obj_t * table, uint16_t row, uint16_t col, lv_la
|
|||||||
*/
|
*/
|
||||||
void lv_table_set_cell_type(lv_obj_t * table, uint16_t row, uint16_t col, uint8_t type)
|
void lv_table_set_cell_type(lv_obj_t * table, uint16_t row, uint16_t col, uint8_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
||||||
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
||||||
LV_LOG_WARN("lv_table_set_cell_type: invalid row or column");
|
LV_LOG_WARN("lv_table_set_cell_type: invalid row or column");
|
||||||
@@ -305,6 +319,8 @@ void lv_table_set_cell_type(lv_obj_t * table, uint16_t row, uint16_t col, uint8_
|
|||||||
*/
|
*/
|
||||||
void lv_table_set_cell_crop(lv_obj_t * table, uint16_t row, uint16_t col, bool crop)
|
void lv_table_set_cell_crop(lv_obj_t * table, uint16_t row, uint16_t col, bool crop)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
||||||
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
||||||
LV_LOG_WARN("lv_table_set_cell_crop: invalid row or column");
|
LV_LOG_WARN("lv_table_set_cell_crop: invalid row or column");
|
||||||
@@ -333,6 +349,8 @@ void lv_table_set_cell_crop(lv_obj_t * table, uint16_t row, uint16_t col, bool c
|
|||||||
*/
|
*/
|
||||||
void lv_table_set_cell_merge_right(lv_obj_t * table, uint16_t row, uint16_t col, bool en)
|
void lv_table_set_cell_merge_right(lv_obj_t * table, uint16_t row, uint16_t col, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
||||||
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
||||||
LV_LOG_WARN("lv_table_set_cell_merge_right: invalid row or column");
|
LV_LOG_WARN("lv_table_set_cell_merge_right: invalid row or column");
|
||||||
@@ -362,6 +380,8 @@ void lv_table_set_cell_merge_right(lv_obj_t * table, uint16_t row, uint16_t col,
|
|||||||
*/
|
*/
|
||||||
void lv_table_set_style(lv_obj_t * table, lv_table_style_t type, const lv_style_t * style)
|
void lv_table_set_style(lv_obj_t * table, lv_table_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -401,6 +421,8 @@ void lv_table_set_style(lv_obj_t * table, lv_table_style_t type, const lv_style_
|
|||||||
*/
|
*/
|
||||||
const char * lv_table_get_cell_value(lv_obj_t * table, uint16_t row, uint16_t col)
|
const char * lv_table_get_cell_value(lv_obj_t * table, uint16_t row, uint16_t col)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
||||||
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
||||||
LV_LOG_WARN("lv_table_set_cell_value: invalid row or column");
|
LV_LOG_WARN("lv_table_set_cell_value: invalid row or column");
|
||||||
@@ -420,6 +442,8 @@ const char * lv_table_get_cell_value(lv_obj_t * table, uint16_t row, uint16_t co
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_table_get_row_cnt(lv_obj_t * table)
|
uint16_t lv_table_get_row_cnt(lv_obj_t * table)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
||||||
return ext->row_cnt;
|
return ext->row_cnt;
|
||||||
}
|
}
|
||||||
@@ -431,6 +455,8 @@ uint16_t lv_table_get_row_cnt(lv_obj_t * table)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_table_get_col_cnt(lv_obj_t * table)
|
uint16_t lv_table_get_col_cnt(lv_obj_t * table)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
||||||
return ext->col_cnt;
|
return ext->col_cnt;
|
||||||
}
|
}
|
||||||
@@ -443,6 +469,8 @@ uint16_t lv_table_get_col_cnt(lv_obj_t * table)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_table_get_col_width(lv_obj_t * table, uint16_t col_id)
|
lv_coord_t lv_table_get_col_width(lv_obj_t * table, uint16_t col_id)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(col_id >= LV_TABLE_COL_MAX) {
|
if(col_id >= LV_TABLE_COL_MAX) {
|
||||||
LV_LOG_WARN("lv_table_set_col_width: too big 'col_id'. Must be < LV_TABLE_COL_MAX.");
|
LV_LOG_WARN("lv_table_set_col_width: too big 'col_id'. Must be < LV_TABLE_COL_MAX.");
|
||||||
return 0;
|
return 0;
|
||||||
@@ -462,6 +490,8 @@ lv_coord_t lv_table_get_col_width(lv_obj_t * table, uint16_t col_id)
|
|||||||
*/
|
*/
|
||||||
lv_label_align_t lv_table_get_cell_align(lv_obj_t * table, uint16_t row, uint16_t col)
|
lv_label_align_t lv_table_get_cell_align(lv_obj_t * table, uint16_t row, uint16_t col)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
||||||
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
||||||
LV_LOG_WARN("lv_table_set_cell_align: invalid row or column");
|
LV_LOG_WARN("lv_table_set_cell_align: invalid row or column");
|
||||||
@@ -487,6 +517,8 @@ lv_label_align_t lv_table_get_cell_align(lv_obj_t * table, uint16_t row, uint16_
|
|||||||
*/
|
*/
|
||||||
lv_label_align_t lv_table_get_cell_type(lv_obj_t * table, uint16_t row, uint16_t col)
|
lv_label_align_t lv_table_get_cell_type(lv_obj_t * table, uint16_t row, uint16_t col)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
||||||
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
||||||
LV_LOG_WARN("lv_table_get_cell_type: invalid row or column");
|
LV_LOG_WARN("lv_table_get_cell_type: invalid row or column");
|
||||||
@@ -512,6 +544,8 @@ lv_label_align_t lv_table_get_cell_type(lv_obj_t * table, uint16_t row, uint16_t
|
|||||||
*/
|
*/
|
||||||
lv_label_align_t lv_table_get_cell_crop(lv_obj_t * table, uint16_t row, uint16_t col)
|
lv_label_align_t lv_table_get_cell_crop(lv_obj_t * table, uint16_t row, uint16_t col)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
||||||
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
||||||
LV_LOG_WARN("lv_table_get_cell_crop: invalid row or column");
|
LV_LOG_WARN("lv_table_get_cell_crop: invalid row or column");
|
||||||
@@ -537,6 +571,8 @@ lv_label_align_t lv_table_get_cell_crop(lv_obj_t * table, uint16_t row, uint16_t
|
|||||||
*/
|
*/
|
||||||
bool lv_table_get_cell_merge_right(lv_obj_t * table, uint16_t row, uint16_t col)
|
bool lv_table_get_cell_merge_right(lv_obj_t * table, uint16_t row, uint16_t col)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
||||||
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
||||||
LV_LOG_WARN("lv_table_get_cell_merge_right: invalid row or column");
|
LV_LOG_WARN("lv_table_get_cell_merge_right: invalid row or column");
|
||||||
@@ -562,6 +598,8 @@ bool lv_table_get_cell_merge_right(lv_obj_t * table, uint16_t row, uint16_t col)
|
|||||||
*/
|
*/
|
||||||
const lv_style_t * lv_table_get_style(const lv_obj_t * table, lv_table_style_t type)
|
const lv_style_t * lv_table_get_style(const lv_obj_t * table, lv_table_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
|
|
||||||
@@ -741,6 +779,7 @@ static lv_res_t lv_table_signal(lv_obj_t * table, lv_signal_t sign, void * param
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(table, sign, param);
|
res = ancestor_signal(table, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
/*Free the cell texts*/
|
/*Free the cell texts*/
|
||||||
@@ -754,13 +793,6 @@ static lv_res_t lv_table_signal(lv_obj_t * table, lv_signal_t sign, void * param
|
|||||||
}
|
}
|
||||||
if(ext->cell_data != NULL)
|
if(ext->cell_data != NULL)
|
||||||
lv_mem_free(ext->cell_data);
|
lv_mem_free(ext->cell_data);
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_table";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#if LV_USE_TABVIEW != 0
|
#if LV_USE_TABVIEW != 0
|
||||||
|
|
||||||
#include "lv_btnm.h"
|
#include "lv_btnm.h"
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
#include "../lv_misc/lv_anim.h"
|
#include "../lv_misc/lv_anim.h"
|
||||||
#include "../lv_core/lv_disp.h"
|
#include "../lv_core/lv_disp.h"
|
||||||
@@ -17,6 +18,8 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_tabview"
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
#ifndef LV_TABVIEW_DEF_ANIM_TIME
|
#ifndef LV_TABVIEW_DEF_ANIM_TIME
|
||||||
#define LV_TABVIEW_DEF_ANIM_TIME 300 /*Animation time of focusing to the a list element [ms] (0: no animation) */
|
#define LV_TABVIEW_DEF_ANIM_TIME 300 /*Animation time of focusing to the a list element [ms] (0: no animation) */
|
||||||
@@ -71,13 +74,13 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor of tab*/
|
/*Create the ancestor of tab*/
|
||||||
lv_obj_t * new_tabview = lv_obj_create(par, copy);
|
lv_obj_t * new_tabview = lv_obj_create(par, copy);
|
||||||
lv_mem_assert(new_tabview);
|
LV_ASSERT_MEM(new_tabview);
|
||||||
if(new_tabview == NULL) return NULL;
|
if(new_tabview == NULL) return NULL;
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_tabview);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_tabview);
|
||||||
|
|
||||||
/*Allocate the tab type specific extended data*/
|
/*Allocate the tab type specific extended data*/
|
||||||
lv_tabview_ext_t * ext = lv_obj_allocate_ext_attr(new_tabview, sizeof(lv_tabview_ext_t));
|
lv_tabview_ext_t * ext = lv_obj_allocate_ext_attr(new_tabview, sizeof(lv_tabview_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
/*Initialize the allocated 'ext' */
|
/*Initialize the allocated 'ext' */
|
||||||
@@ -98,7 +101,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
/*Init the new tab tab*/
|
/*Init the new tab tab*/
|
||||||
if(copy == NULL) {
|
if(copy == NULL) {
|
||||||
ext->tab_name_ptr = lv_mem_alloc(sizeof(char *));
|
ext->tab_name_ptr = lv_mem_alloc(sizeof(char *));
|
||||||
lv_mem_assert(ext->tab_name_ptr);
|
LV_ASSERT_MEM(ext->tab_name_ptr);
|
||||||
if(ext->tab_name_ptr == NULL) return NULL;
|
if(ext->tab_name_ptr == NULL) return NULL;
|
||||||
ext->tab_name_ptr[0] = "";
|
ext->tab_name_ptr[0] = "";
|
||||||
ext->tab_cnt = 0;
|
ext->tab_cnt = 0;
|
||||||
@@ -156,7 +159,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ext->tab_name_ptr = lv_mem_alloc(sizeof(char *));
|
ext->tab_name_ptr = lv_mem_alloc(sizeof(char *));
|
||||||
lv_mem_assert(ext->tab_name_ptr);
|
LV_ASSERT_MEM(ext->tab_name_ptr);
|
||||||
if(ext->tab_name_ptr == NULL) return NULL;
|
if(ext->tab_name_ptr == NULL) return NULL;
|
||||||
ext->tab_name_ptr[0] = "";
|
ext->tab_name_ptr[0] = "";
|
||||||
lv_btnm_set_map(ext->btns, ext->tab_name_ptr);
|
lv_btnm_set_map(ext->btns, ext->tab_name_ptr);
|
||||||
@@ -185,11 +188,13 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all children of the scrl object, without deleting scrl child.
|
* Delete all children of the scrl object, without deleting scrl child.
|
||||||
* @param obj pointer to an object
|
* @param tabview pointer to an object
|
||||||
*/
|
*/
|
||||||
void lv_tabview_clean(lv_obj_t * obj)
|
void lv_tabview_clean(lv_obj_t * tabview)
|
||||||
{
|
{
|
||||||
lv_obj_t * scrl = lv_page_get_scrl(obj);
|
LV_ASSERT_OBJ(tabview, LV_OBJX_NAME);
|
||||||
|
|
||||||
|
lv_obj_t * scrl = lv_page_get_scrl(tabview);
|
||||||
lv_obj_clean(scrl);
|
lv_obj_clean(scrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,6 +210,9 @@ void lv_tabview_clean(lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
|
lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(tabview, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_STR(name);
|
||||||
|
|
||||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||||
|
|
||||||
/*Create the container page*/
|
/*Create the container page*/
|
||||||
@@ -220,13 +228,12 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
|
|||||||
/*Extend the button matrix map with the new name*/
|
/*Extend the button matrix map with the new name*/
|
||||||
char * name_dm;
|
char * name_dm;
|
||||||
name_dm = lv_mem_alloc(strlen(name) + 1); /*+1 for the the closing '\0' */
|
name_dm = lv_mem_alloc(strlen(name) + 1); /*+1 for the the closing '\0' */
|
||||||
lv_mem_assert(name_dm);
|
LV_ASSERT_MEM(name_dm);
|
||||||
if(name_dm == NULL) return NULL;
|
if(name_dm == NULL) return NULL;
|
||||||
strcpy(name_dm, name);
|
strcpy(name_dm, name);
|
||||||
|
|
||||||
ext->tab_cnt++;
|
ext->tab_cnt++;
|
||||||
|
|
||||||
|
|
||||||
/* FIXME: It is not possible yet to switch tab button position from/to top/bottom from/to left/right at runtime.
|
/* FIXME: It is not possible yet to switch tab button position from/to top/bottom from/to left/right at runtime.
|
||||||
* Method: clean extra \n when switch from LV_TABVIEW_BTNS_POS_LEFT or LV_TABVIEW_BTNS_POS_RIGHT
|
* Method: clean extra \n when switch from LV_TABVIEW_BTNS_POS_LEFT or LV_TABVIEW_BTNS_POS_RIGHT
|
||||||
* to LV_TABVIEW_BTNS_POS_TOP or LV_TABVIEW_BTNS_POS_BOTTOM.
|
* to LV_TABVIEW_BTNS_POS_TOP or LV_TABVIEW_BTNS_POS_BOTTOM.
|
||||||
@@ -240,7 +247,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
|
|||||||
case LV_TABVIEW_BTNS_POS_BOTTOM:
|
case LV_TABVIEW_BTNS_POS_BOTTOM:
|
||||||
ext->tab_name_ptr = lv_mem_realloc(ext->tab_name_ptr, sizeof(char *) * (ext->tab_cnt + 1));
|
ext->tab_name_ptr = lv_mem_realloc(ext->tab_name_ptr, sizeof(char *) * (ext->tab_cnt + 1));
|
||||||
|
|
||||||
lv_mem_assert(ext->tab_name_ptr);
|
LV_ASSERT_MEM(ext->tab_name_ptr);
|
||||||
if(ext->tab_name_ptr == NULL) return NULL;
|
if(ext->tab_name_ptr == NULL) return NULL;
|
||||||
|
|
||||||
ext->tab_name_ptr[ext->tab_cnt - 1] = name_dm;
|
ext->tab_name_ptr[ext->tab_cnt - 1] = name_dm;
|
||||||
@@ -251,7 +258,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
|
|||||||
case LV_TABVIEW_BTNS_POS_RIGHT:
|
case LV_TABVIEW_BTNS_POS_RIGHT:
|
||||||
ext->tab_name_ptr = lv_mem_realloc(ext->tab_name_ptr, sizeof(char *) * (ext->tab_cnt * 2));
|
ext->tab_name_ptr = lv_mem_realloc(ext->tab_name_ptr, sizeof(char *) * (ext->tab_cnt * 2));
|
||||||
|
|
||||||
lv_mem_assert(ext->tab_name_ptr);
|
LV_ASSERT_MEM(ext->tab_name_ptr);
|
||||||
if(ext->tab_name_ptr == NULL) return NULL;
|
if(ext->tab_name_ptr == NULL) return NULL;
|
||||||
|
|
||||||
if(ext->tab_cnt == 1) {
|
if(ext->tab_cnt == 1) {
|
||||||
@@ -295,6 +302,8 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
|
|||||||
*/
|
*/
|
||||||
void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t anim)
|
void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t anim)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(tabview, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION == 0
|
#if LV_USE_ANIMATION == 0
|
||||||
anim = LV_ANIM_OFF;
|
anim = LV_ANIM_OFF;
|
||||||
#endif
|
#endif
|
||||||
@@ -418,6 +427,8 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an
|
|||||||
*/
|
*/
|
||||||
void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time)
|
void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(tabview, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||||
ext->anim_time = anim_time;
|
ext->anim_time = anim_time;
|
||||||
@@ -435,6 +446,8 @@ void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time)
|
|||||||
*/
|
*/
|
||||||
void lv_tabview_set_style(lv_obj_t * tabview, lv_tabview_style_t type, const lv_style_t * style)
|
void lv_tabview_set_style(lv_obj_t * tabview, lv_tabview_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(tabview, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -472,6 +485,8 @@ void lv_tabview_set_style(lv_obj_t * tabview, lv_tabview_style_t type, const lv_
|
|||||||
*/
|
*/
|
||||||
void lv_tabview_set_btns_pos(lv_obj_t * tabview, lv_tabview_btns_pos_t btns_pos)
|
void lv_tabview_set_btns_pos(lv_obj_t * tabview, lv_tabview_btns_pos_t btns_pos)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(tabview, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||||
|
|
||||||
ext->btns_pos = btns_pos;
|
ext->btns_pos = btns_pos;
|
||||||
@@ -489,6 +504,8 @@ void lv_tabview_set_btns_pos(lv_obj_t * tabview, lv_tabview_btns_pos_t btns_pos)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_tabview_get_tab_act(const lv_obj_t * tabview)
|
uint16_t lv_tabview_get_tab_act(const lv_obj_t * tabview)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(tabview, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||||
return ext->tab_cur;
|
return ext->tab_cur;
|
||||||
}
|
}
|
||||||
@@ -500,6 +517,8 @@ uint16_t lv_tabview_get_tab_act(const lv_obj_t * tabview)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_tabview_get_tab_count(const lv_obj_t * tabview)
|
uint16_t lv_tabview_get_tab_count(const lv_obj_t * tabview)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(tabview, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||||
return ext->tab_cnt;
|
return ext->tab_cnt;
|
||||||
}
|
}
|
||||||
@@ -512,6 +531,8 @@ uint16_t lv_tabview_get_tab_count(const lv_obj_t * tabview)
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_tabview_get_tab(const lv_obj_t * tabview, uint16_t id)
|
lv_obj_t * lv_tabview_get_tab(const lv_obj_t * tabview, uint16_t id)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(tabview, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||||
lv_obj_t * content_scrl = lv_page_get_scrl(ext->content);
|
lv_obj_t * content_scrl = lv_page_get_scrl(ext->content);
|
||||||
uint16_t i = 0;
|
uint16_t i = 0;
|
||||||
@@ -534,6 +555,8 @@ lv_obj_t * lv_tabview_get_tab(const lv_obj_t * tabview, uint16_t id)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_tabview_get_anim_time(const lv_obj_t * tabview)
|
uint16_t lv_tabview_get_anim_time(const lv_obj_t * tabview)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(tabview, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||||
return ext->anim_time;
|
return ext->anim_time;
|
||||||
@@ -551,6 +574,8 @@ uint16_t lv_tabview_get_anim_time(const lv_obj_t * tabview)
|
|||||||
*/
|
*/
|
||||||
const lv_style_t * lv_tabview_get_style(const lv_obj_t * tabview, lv_tabview_style_t type)
|
const lv_style_t * lv_tabview_get_style(const lv_obj_t * tabview, lv_tabview_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(tabview, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||||
|
|
||||||
@@ -573,6 +598,8 @@ const lv_style_t * lv_tabview_get_style(const lv_obj_t * tabview, lv_tabview_sty
|
|||||||
*/
|
*/
|
||||||
lv_tabview_btns_pos_t lv_tabview_get_btns_pos(const lv_obj_t * tabview)
|
lv_tabview_btns_pos_t lv_tabview_get_btns_pos(const lv_obj_t * tabview)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(tabview, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||||
return ext->btns_pos;
|
return ext->btns_pos;
|
||||||
}
|
}
|
||||||
@@ -595,6 +622,7 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(tabview, sign, param);
|
res = ancestor_signal(tabview, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
@@ -649,13 +677,6 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
|
|||||||
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
||||||
bool * editable = (bool *)param;
|
bool * editable = (bool *)param;
|
||||||
*editable = true;
|
*editable = true;
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_tabview";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -676,6 +697,7 @@ static lv_res_t tabview_scrl_signal(lv_obj_t * tab_page, lv_signal_t sign, void
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_scrl_signal(tab_page, sign, param);
|
res = ancestor_scrl_signal(tab_page, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, "");
|
||||||
|
|
||||||
lv_obj_t * cont = lv_obj_get_parent(tab_page);
|
lv_obj_t * cont = lv_obj_get_parent(tab_page);
|
||||||
lv_obj_t * tabview = lv_obj_get_parent(cont);
|
lv_obj_t * tabview = lv_obj_get_parent(cont);
|
||||||
|
|||||||
@@ -95,9 +95,9 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all children of the scrl object, without deleting scrl child.
|
* Delete all children of the scrl object, without deleting scrl child.
|
||||||
* @param obj pointer to an object
|
* @param tabview pointer to an object
|
||||||
*/
|
*/
|
||||||
void lv_tabview_clean(lv_obj_t * obj);
|
void lv_tabview_clean(lv_obj_t * tabview);
|
||||||
|
|
||||||
/*======================
|
/*======================
|
||||||
* Add/remove functions
|
* Add/remove functions
|
||||||
|
|||||||
@@ -11,11 +11,14 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "lv_cont.h"
|
#include "lv_cont.h"
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_tileview"
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
#ifndef LV_TILEVIEW_DEF_ANIM_TIME
|
#ifndef LV_TILEVIEW_DEF_ANIM_TIME
|
||||||
#define LV_TILEVIEW_DEF_ANIM_TIME 300 /*Animation time loading a tile [ms] (0: no animation) */
|
#define LV_TILEVIEW_DEF_ANIM_TIME 300 /*Animation time loading a tile [ms] (0: no animation) */
|
||||||
@@ -64,12 +67,12 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor of tileview*/
|
/*Create the ancestor of tileview*/
|
||||||
lv_obj_t * new_tileview = lv_page_create(par, copy);
|
lv_obj_t * new_tileview = lv_page_create(par, copy);
|
||||||
lv_mem_assert(new_tileview);
|
LV_ASSERT_MEM(new_tileview);
|
||||||
if(new_tileview == NULL) return NULL;
|
if(new_tileview == NULL) return NULL;
|
||||||
|
|
||||||
/*Allocate the tileview type specific extended data*/
|
/*Allocate the tileview type specific extended data*/
|
||||||
lv_tileview_ext_t * ext = lv_obj_allocate_ext_attr(new_tileview, sizeof(lv_tileview_ext_t));
|
lv_tileview_ext_t * ext = lv_obj_allocate_ext_attr(new_tileview, sizeof(lv_tileview_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_tileview);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_tileview);
|
||||||
if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(new_tileview));
|
if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(new_tileview));
|
||||||
@@ -140,6 +143,9 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
*/
|
*/
|
||||||
void lv_tileview_add_element(lv_obj_t * tileview, lv_obj_t * element)
|
void lv_tileview_add_element(lv_obj_t * tileview, lv_obj_t * element)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(tileview, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(tileview);
|
||||||
|
|
||||||
lv_page_glue_obj(element, true);
|
lv_page_glue_obj(element, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,6 +162,9 @@ void lv_tileview_add_element(lv_obj_t * tileview, lv_obj_t * element)
|
|||||||
*/
|
*/
|
||||||
void lv_tileview_set_valid_positions(lv_obj_t * tileview, const lv_point_t * valid_pos, uint16_t valid_pos_cnt)
|
void lv_tileview_set_valid_positions(lv_obj_t * tileview, const lv_point_t * valid_pos, uint16_t valid_pos_cnt)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(tileview, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(valid_pos);
|
||||||
|
|
||||||
lv_tileview_ext_t * ext = lv_obj_get_ext_attr(tileview);
|
lv_tileview_ext_t * ext = lv_obj_get_ext_attr(tileview);
|
||||||
ext->valid_pos = valid_pos;
|
ext->valid_pos = valid_pos;
|
||||||
ext->valid_pos_cnt = valid_pos_cnt;
|
ext->valid_pos_cnt = valid_pos_cnt;
|
||||||
@@ -185,6 +194,8 @@ void lv_tileview_set_valid_positions(lv_obj_t * tileview, const lv_point_t * val
|
|||||||
*/
|
*/
|
||||||
void lv_tileview_set_tile_act(lv_obj_t * tileview, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim)
|
void lv_tileview_set_tile_act(lv_obj_t * tileview, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(tileview, LV_OBJX_NAME);
|
||||||
|
|
||||||
#if LV_USE_ANIMATION == 0
|
#if LV_USE_ANIMATION == 0
|
||||||
anim = LV_ANIM_OFF;
|
anim = LV_ANIM_OFF;
|
||||||
#endif
|
#endif
|
||||||
@@ -256,6 +267,7 @@ void lv_tileview_set_tile_act(lv_obj_t * tileview, lv_coord_t x, lv_coord_t y, l
|
|||||||
*/
|
*/
|
||||||
void lv_tileview_set_style(lv_obj_t * tileview, lv_tileview_style_t type, const lv_style_t * style)
|
void lv_tileview_set_style(lv_obj_t * tileview, lv_tileview_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(tileview, LV_OBJX_NAME);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_TILEVIEW_STYLE_MAIN: lv_obj_set_style(tileview, style); break;
|
case LV_TILEVIEW_STYLE_MAIN: lv_obj_set_style(tileview, style); break;
|
||||||
@@ -278,6 +290,8 @@ void lv_tileview_set_style(lv_obj_t * tileview, lv_tileview_style_t type, const
|
|||||||
*/
|
*/
|
||||||
const lv_style_t * lv_tileview_get_style(const lv_obj_t * tileview, lv_tileview_style_t type)
|
const lv_style_t * lv_tileview_get_style(const lv_obj_t * tileview, lv_tileview_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(tileview, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_TILEVIEW_STYLE_MAIN: style = lv_obj_get_style(tileview); break;
|
case LV_TILEVIEW_STYLE_MAIN: style = lv_obj_get_style(tileview); break;
|
||||||
@@ -313,16 +327,10 @@ static lv_res_t lv_tileview_signal(lv_obj_t * tileview, lv_signal_t sign, void *
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(tileview, sign, param);
|
res = ancestor_signal(tileview, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_CLEANUP) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_tileview";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -9,12 +9,14 @@
|
|||||||
#include "lv_win.h"
|
#include "lv_win.h"
|
||||||
#if LV_USE_WIN != 0
|
#if LV_USE_WIN != 0
|
||||||
|
|
||||||
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
#include "../lv_core/lv_disp.h"
|
#include "../lv_core/lv_disp.h"
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
#define LV_OBJX_NAME "lv_win"
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -51,14 +53,14 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Create the ancestor object*/
|
/*Create the ancestor object*/
|
||||||
lv_obj_t * new_win = lv_obj_create(par, copy);
|
lv_obj_t * new_win = lv_obj_create(par, copy);
|
||||||
lv_mem_assert(new_win);
|
LV_ASSERT_MEM(new_win);
|
||||||
if(new_win == NULL) return NULL;
|
if(new_win == NULL) return NULL;
|
||||||
|
|
||||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_win);
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_win);
|
||||||
|
|
||||||
/*Allocate the object type specific extended data*/
|
/*Allocate the object type specific extended data*/
|
||||||
lv_win_ext_t * ext = lv_obj_allocate_ext_attr(new_win, sizeof(lv_win_ext_t));
|
lv_win_ext_t * ext = lv_obj_allocate_ext_attr(new_win, sizeof(lv_win_ext_t));
|
||||||
lv_mem_assert(ext);
|
LV_ASSERT_MEM(ext);
|
||||||
if(ext == NULL) return NULL;
|
if(ext == NULL) return NULL;
|
||||||
|
|
||||||
ext->page = NULL;
|
ext->page = NULL;
|
||||||
@@ -146,11 +148,13 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all children of the scrl object, without deleting scrl child.
|
* Delete all children of the scrl object, without deleting scrl child.
|
||||||
* @param obj pointer to an object
|
* @param win pointer to an object
|
||||||
*/
|
*/
|
||||||
void lv_win_clean(lv_obj_t * obj)
|
void lv_win_clean(lv_obj_t * win)
|
||||||
{
|
{
|
||||||
lv_obj_t * scrl = lv_page_get_scrl(obj);
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
|
||||||
|
lv_obj_t * scrl = lv_page_get_scrl(win);
|
||||||
lv_obj_clean(scrl);
|
lv_obj_clean(scrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,6 +170,9 @@ void lv_win_clean(lv_obj_t * obj)
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src)
|
lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_NULL(img_src);
|
||||||
|
|
||||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||||
|
|
||||||
lv_obj_t * btn = lv_btn_create(ext->header, NULL);
|
lv_obj_t * btn = lv_btn_create(ext->header, NULL);
|
||||||
@@ -193,6 +200,8 @@ lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src)
|
|||||||
*/
|
*/
|
||||||
void lv_win_close_event_cb(lv_obj_t * btn, lv_event_t event)
|
void lv_win_close_event_cb(lv_obj_t * btn, lv_event_t event)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(btn, "lv_btn");
|
||||||
|
|
||||||
if(event == LV_EVENT_RELEASED) {
|
if(event == LV_EVENT_RELEASED) {
|
||||||
lv_obj_t * win = lv_win_get_from_btn(btn);
|
lv_obj_t * win = lv_win_get_from_btn(btn);
|
||||||
|
|
||||||
@@ -207,6 +216,9 @@ void lv_win_close_event_cb(lv_obj_t * btn, lv_event_t event)
|
|||||||
*/
|
*/
|
||||||
void lv_win_set_title(lv_obj_t * win, const char * title)
|
void lv_win_set_title(lv_obj_t * win, const char * title)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_STR(title);
|
||||||
|
|
||||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||||
|
|
||||||
lv_label_set_text(ext->title, title);
|
lv_label_set_text(ext->title, title);
|
||||||
@@ -220,6 +232,8 @@ void lv_win_set_title(lv_obj_t * win, const char * title)
|
|||||||
*/
|
*/
|
||||||
void lv_win_set_btn_size(lv_obj_t * win, lv_coord_t size)
|
void lv_win_set_btn_size(lv_obj_t * win, lv_coord_t size)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||||
if(ext->btn_size == size) return;
|
if(ext->btn_size == size) return;
|
||||||
|
|
||||||
@@ -228,6 +242,20 @@ void lv_win_set_btn_size(lv_obj_t * win, lv_coord_t size)
|
|||||||
lv_win_realign(win);
|
lv_win_realign(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the size of the content area.
|
||||||
|
* @param win pointer to a window object
|
||||||
|
* @param w width
|
||||||
|
* @param h height (the window will be higher with the height of the header)
|
||||||
|
*/
|
||||||
|
void lv_win_set_content_size(lv_obj_t * win, lv_coord_t w, lv_coord_t h)
|
||||||
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
|
||||||
|
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||||
|
h += lv_obj_get_height(ext->header);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the layout of the window
|
* Set the layout of the window
|
||||||
* @param win pointer to a window object
|
* @param win pointer to a window object
|
||||||
@@ -235,6 +263,8 @@ void lv_win_set_btn_size(lv_obj_t * win, lv_coord_t size)
|
|||||||
*/
|
*/
|
||||||
void lv_win_set_layout(lv_obj_t * win, lv_layout_t layout)
|
void lv_win_set_layout(lv_obj_t * win, lv_layout_t layout)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||||
lv_page_set_scrl_layout(ext->page, layout);
|
lv_page_set_scrl_layout(ext->page, layout);
|
||||||
}
|
}
|
||||||
@@ -246,6 +276,8 @@ void lv_win_set_layout(lv_obj_t * win, lv_layout_t layout)
|
|||||||
*/
|
*/
|
||||||
void lv_win_set_sb_mode(lv_obj_t * win, lv_sb_mode_t sb_mode)
|
void lv_win_set_sb_mode(lv_obj_t * win, lv_sb_mode_t sb_mode)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||||
lv_page_set_sb_mode(ext->page, sb_mode);
|
lv_page_set_sb_mode(ext->page, sb_mode);
|
||||||
}
|
}
|
||||||
@@ -256,6 +288,8 @@ void lv_win_set_sb_mode(lv_obj_t * win, lv_sb_mode_t sb_mode)
|
|||||||
*/
|
*/
|
||||||
void lv_win_set_anim_time(lv_obj_t * win, uint16_t anim_time)
|
void lv_win_set_anim_time(lv_obj_t * win, uint16_t anim_time)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_page_set_anim_time(lv_win_get_content(win), anim_time);
|
lv_page_set_anim_time(lv_win_get_content(win), anim_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,6 +301,8 @@ void lv_win_set_anim_time(lv_obj_t * win, uint16_t anim_time)
|
|||||||
*/
|
*/
|
||||||
void lv_win_set_style(lv_obj_t * win, lv_win_style_t type, const lv_style_t * style)
|
void lv_win_set_style(lv_obj_t * win, lv_win_style_t type, const lv_style_t * style)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@@ -306,6 +342,8 @@ void lv_win_set_style(lv_obj_t * win, lv_win_style_t type, const lv_style_t * st
|
|||||||
*/
|
*/
|
||||||
void lv_win_set_drag(lv_obj_t * win, bool en)
|
void lv_win_set_drag(lv_obj_t * win, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||||
lv_obj_t * win_header = ext->header;
|
lv_obj_t * win_header = ext->header;
|
||||||
lv_obj_set_drag_parent(win_header, en);
|
lv_obj_set_drag_parent(win_header, en);
|
||||||
@@ -323,6 +361,8 @@ void lv_win_set_drag(lv_obj_t * win, bool en)
|
|||||||
*/
|
*/
|
||||||
const char * lv_win_get_title(const lv_obj_t * win)
|
const char * lv_win_get_title(const lv_obj_t * win)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||||
return lv_label_get_text(ext->title);
|
return lv_label_get_text(ext->title);
|
||||||
}
|
}
|
||||||
@@ -334,6 +374,8 @@ const char * lv_win_get_title(const lv_obj_t * win)
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_win_get_content(const lv_obj_t * win)
|
lv_obj_t * lv_win_get_content(const lv_obj_t * win)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||||
return ext->page;
|
return ext->page;
|
||||||
}
|
}
|
||||||
@@ -345,6 +387,8 @@ lv_obj_t * lv_win_get_content(const lv_obj_t * win)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_win_get_btn_size(const lv_obj_t * win)
|
lv_coord_t lv_win_get_btn_size(const lv_obj_t * win)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||||
return ext->btn_size;
|
return ext->btn_size;
|
||||||
}
|
}
|
||||||
@@ -357,6 +401,8 @@ lv_coord_t lv_win_get_btn_size(const lv_obj_t * win)
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_win_get_from_btn(const lv_obj_t * ctrl_btn)
|
lv_obj_t * lv_win_get_from_btn(const lv_obj_t * ctrl_btn)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(ctrl_btn, "lv_btn");
|
||||||
|
|
||||||
lv_obj_t * header = lv_obj_get_parent(ctrl_btn);
|
lv_obj_t * header = lv_obj_get_parent(ctrl_btn);
|
||||||
lv_obj_t * win = lv_obj_get_parent(header);
|
lv_obj_t * win = lv_obj_get_parent(header);
|
||||||
|
|
||||||
@@ -370,6 +416,8 @@ lv_obj_t * lv_win_get_from_btn(const lv_obj_t * ctrl_btn)
|
|||||||
*/
|
*/
|
||||||
lv_layout_t lv_win_get_layout(lv_obj_t * win)
|
lv_layout_t lv_win_get_layout(lv_obj_t * win)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||||
return lv_page_get_scrl_layout(ext->page);
|
return lv_page_get_scrl_layout(ext->page);
|
||||||
}
|
}
|
||||||
@@ -381,6 +429,8 @@ lv_layout_t lv_win_get_layout(lv_obj_t * win)
|
|||||||
*/
|
*/
|
||||||
lv_sb_mode_t lv_win_get_sb_mode(lv_obj_t * win)
|
lv_sb_mode_t lv_win_get_sb_mode(lv_obj_t * win)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||||
return lv_page_get_sb_mode(ext->page);
|
return lv_page_get_sb_mode(ext->page);
|
||||||
}
|
}
|
||||||
@@ -392,6 +442,8 @@ lv_sb_mode_t lv_win_get_sb_mode(lv_obj_t * win)
|
|||||||
*/
|
*/
|
||||||
uint16_t lv_win_get_anim_time(const lv_obj_t * win)
|
uint16_t lv_win_get_anim_time(const lv_obj_t * win)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
|
||||||
return lv_page_get_anim_time(lv_win_get_content(win));
|
return lv_page_get_anim_time(lv_win_get_content(win));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,6 +454,8 @@ uint16_t lv_win_get_anim_time(const lv_obj_t * win)
|
|||||||
*/
|
*/
|
||||||
lv_coord_t lv_win_get_width(lv_obj_t * win)
|
lv_coord_t lv_win_get_width(lv_obj_t * win)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||||
lv_obj_t * scrl = lv_page_get_scrl(ext->page);
|
lv_obj_t * scrl = lv_page_get_scrl(ext->page);
|
||||||
const lv_style_t * style_scrl = lv_obj_get_style(scrl);
|
const lv_style_t * style_scrl = lv_obj_get_style(scrl);
|
||||||
@@ -417,6 +471,8 @@ lv_coord_t lv_win_get_width(lv_obj_t * win)
|
|||||||
*/
|
*/
|
||||||
const lv_style_t * lv_win_get_style(const lv_obj_t * win, lv_win_style_t type)
|
const lv_style_t * lv_win_get_style(const lv_obj_t * win, lv_win_style_t type)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
const lv_style_t * style = NULL;
|
||||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||||
|
|
||||||
@@ -445,6 +501,10 @@ const lv_style_t * lv_win_get_style(const lv_obj_t * win, lv_win_style_t type)
|
|||||||
*/
|
*/
|
||||||
void lv_win_focus(lv_obj_t * win, lv_obj_t * obj, lv_anim_enable_t anim_en)
|
void lv_win_focus(lv_obj_t * win, lv_obj_t * obj, lv_anim_enable_t anim_en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
|
||||||
|
LV_ASSERT_OBJ(obj, "");
|
||||||
|
|
||||||
|
|
||||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||||
lv_page_focus(ext->page, obj, anim_en);
|
lv_page_focus(ext->page, obj, anim_en);
|
||||||
}
|
}
|
||||||
@@ -467,6 +527,7 @@ static lv_res_t lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param)
|
|||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(win, sign, param);
|
res = ancestor_signal(win, sign, param);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||||
if(sign == LV_SIGNAL_CHILD_CHG) { /*Move children to the page*/
|
if(sign == LV_SIGNAL_CHILD_CHG) { /*Move children to the page*/
|
||||||
@@ -498,13 +559,6 @@ static lv_res_t lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param)
|
|||||||
} else if(sign == LV_SIGNAL_CONTROL) {
|
} else if(sign == LV_SIGNAL_CONTROL) {
|
||||||
/*Forward all the control signals to the page*/
|
/*Forward all the control signals to the page*/
|
||||||
ext->page->signal_cb(ext->page, sign, param);
|
ext->page->signal_cb(ext->page, sign, param);
|
||||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
|
||||||
lv_obj_type_t * buf = param;
|
|
||||||
uint8_t i;
|
|
||||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
||||||
if(buf->type[i] == NULL) break;
|
|
||||||
}
|
|
||||||
buf->type[i] = "lv_win";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -91,9 +91,9 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all children of the scrl object, without deleting scrl child.
|
* Delete all children of the scrl object, without deleting scrl child.
|
||||||
* @param obj pointer to an object
|
* @param win pointer to an object
|
||||||
*/
|
*/
|
||||||
void lv_win_clean(lv_obj_t * obj);
|
void lv_win_clean(lv_obj_t * win);
|
||||||
|
|
||||||
/*======================
|
/*======================
|
||||||
* Add/remove functions
|
* Add/remove functions
|
||||||
@@ -132,6 +132,15 @@ void lv_win_set_title(lv_obj_t * win, const char * title);
|
|||||||
*/
|
*/
|
||||||
void lv_win_set_btn_size(lv_obj_t * win, lv_coord_t size);
|
void lv_win_set_btn_size(lv_obj_t * win, lv_coord_t size);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the size of the content area.
|
||||||
|
* @param win pointer to a window object
|
||||||
|
* @param w width
|
||||||
|
* @param h height (the window will be higher with the height of the header)
|
||||||
|
*/
|
||||||
|
void lv_win_set_content_size(lv_obj_t * win, lv_coord_t w, lv_coord_t h);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the layout of the window
|
* Set the layout of the window
|
||||||
* @param win pointer to a window object
|
* @param win pointer to a window object
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ extern "C" {
|
|||||||
*********************/
|
*********************/
|
||||||
/*Current version of LittlevGL*/
|
/*Current version of LittlevGL*/
|
||||||
#define LVGL_VERSION_MAJOR 6
|
#define LVGL_VERSION_MAJOR 6
|
||||||
#define LVGL_VERSION_MINOR 0
|
#define LVGL_VERSION_MINOR 1
|
||||||
#define LVGL_VERSION_PATCH 2
|
#define LVGL_VERSION_PATCH 0
|
||||||
#define LVGL_VERSION_INFO ""
|
#define LVGL_VERSION_INFO "dev"
|
||||||
|
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
|
|||||||
Reference in New Issue
Block a user