Merge from beta
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
*********************/
|
||||
#include <string.h>
|
||||
#include "anim.h"
|
||||
#include "misc/math/math_base.h"
|
||||
#include "misc/os/ptask.h"
|
||||
#include "hal/systick/systick.h"
|
||||
|
||||
@@ -42,6 +43,12 @@ static anim_path_t anim_path_lin[] =
|
||||
128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
|
||||
160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192};
|
||||
|
||||
static anim_path_t anim_path_step[] =
|
||||
{64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 192,};
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
@@ -137,6 +144,9 @@ anim_path_t * anim_get_path(anim_path_name_t name)
|
||||
case ANIM_PATH_LIN:
|
||||
return anim_path_lin;
|
||||
break;
|
||||
case ANIM_PATH_STEP:
|
||||
return anim_path_step;
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
break;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
typedef enum
|
||||
{
|
||||
ANIM_PATH_LIN,
|
||||
ANIM_PATH_STEP,
|
||||
}anim_path_name_t;
|
||||
|
||||
typedef uint8_t anim_path_t;
|
||||
|
||||
@@ -79,7 +79,7 @@ void lv_init(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the object as invalid therefor it will be redrawn by 'lv_refr_task'
|
||||
* Mark the object as invalid therefore its current position will be redrawn by 'lv_refr_task'
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_inv(lv_obj_t * obj)
|
||||
@@ -125,14 +125,14 @@ void lv_obj_refr_style(lv_obj_t * obj)
|
||||
|
||||
/**
|
||||
* Notify all object if a style is modified
|
||||
* @param style_p pinter to a style. Only objects with this style will be notified
|
||||
* @param style pinter to a style. Only objects with this style will be notified
|
||||
* (NULL to notify all objects)
|
||||
*/
|
||||
void lv_style_refr_all(void * style_p)
|
||||
void lv_style_refr_all(void * style)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
LL_READ(scr_ll, i) {
|
||||
lv_style_refr_core(style_p, i);
|
||||
lv_style_refr_core(style, i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -777,13 +777,13 @@ void lv_obj_set_ext_size(lv_obj_t * obj, cord_t ext_size)
|
||||
* @param obj pointer to an object
|
||||
* @param style_p pointer to the new style
|
||||
*/
|
||||
void lv_obj_set_style(lv_obj_t * obj, void * style_p)
|
||||
void lv_obj_set_style(lv_obj_t * obj, void * style)
|
||||
{
|
||||
|
||||
if(obj->style_iso != 0) {
|
||||
dm_free(obj->style_p);
|
||||
}
|
||||
obj->style_p = style_p;
|
||||
obj->style_p = style;
|
||||
|
||||
/*Send a style change signal to the object*/
|
||||
obj->signal_f(obj, LV_SIGNAL_STYLE_CHG, NULL);
|
||||
@@ -849,11 +849,11 @@ void lv_obj_set_opar(lv_obj_t * obj, uint8_t opa)
|
||||
/**
|
||||
* Hide an object. It won't be visible and clickable.
|
||||
* @param obj pointer to an object
|
||||
* @param hidden_en true: hide the object
|
||||
* @param en true: hide the object
|
||||
*/
|
||||
void lv_obj_set_hidden(lv_obj_t * obj, bool hidden_en)
|
||||
void lv_obj_set_hidden(lv_obj_t * obj, bool en)
|
||||
{
|
||||
obj->hidden = hidden_en == false ? 0 : 1;
|
||||
obj->hidden = en == false ? 0 : 1;
|
||||
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
par->signal_f(par, LV_SIGNAL_CHILD_CHG, obj);
|
||||
@@ -864,11 +864,11 @@ void lv_obj_set_hidden(lv_obj_t * obj, bool hidden_en)
|
||||
/**
|
||||
* Enable or disable the clicking of an object
|
||||
* @param obj pointer to an object
|
||||
* @param click_en true: make the object clickable
|
||||
* @param en true: make the object clickable
|
||||
*/
|
||||
void lv_obj_set_click(lv_obj_t * obj, bool click_en)
|
||||
void lv_obj_set_click(lv_obj_t * obj, bool en)
|
||||
{
|
||||
obj->click_en = (click_en == true ? 1 : 0);
|
||||
obj->click_en = (en == true ? 1 : 0);
|
||||
|
||||
}
|
||||
|
||||
@@ -876,42 +876,42 @@ void lv_obj_set_click(lv_obj_t * obj, bool click_en)
|
||||
* Enable to bring this object to the foreground if it
|
||||
* or any of its children is clicked
|
||||
* @param obj pointer to an object
|
||||
* @param top_en true: enable the auto top feature
|
||||
* @param en true: enable the auto top feature
|
||||
*/
|
||||
void lv_obj_set_top(lv_obj_t * obj, bool top_en)
|
||||
void lv_obj_set_top(lv_obj_t * obj, bool en)
|
||||
{
|
||||
obj->top_en= (top_en == true ? 1 : 0);
|
||||
obj->top_en= (en == true ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the dragging of an object
|
||||
* @param obj pointer to an object
|
||||
* @param drag_en true: make the object dragable
|
||||
* @param en true: make the object dragable
|
||||
*/
|
||||
void lv_obj_set_drag(lv_obj_t * obj, bool drag_en)
|
||||
void lv_obj_set_drag(lv_obj_t * obj, bool en)
|
||||
{
|
||||
obj->drag_en = (drag_en == true ? 1 : 0);
|
||||
obj->drag_en = (en == true ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the throwing of an object after is is dragged
|
||||
* @param obj pointer to an object
|
||||
* @param dragthr_en true: enable the drag throw
|
||||
* @param en true: enable the drag throw
|
||||
*/
|
||||
void lv_obj_set_drag_throw(lv_obj_t * obj, bool dragthr_en)
|
||||
void lv_obj_set_drag_throw(lv_obj_t * obj, bool en)
|
||||
{
|
||||
obj->drag_throw_en = (dragthr_en == true ? 1 : 0);
|
||||
obj->drag_throw_en = (en == true ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable to use parent for drag related operations.
|
||||
* If trying to drag the object the parent will be moved instead
|
||||
* @param obj pointer to an object
|
||||
* @param dragpar_en true: enable the 'drag parent' for the object
|
||||
* @param en true: enable the 'drag parent' for the object
|
||||
*/
|
||||
void lv_obj_set_drag_parent(lv_obj_t * obj, bool dragpar_en)
|
||||
void lv_obj_set_drag_parent(lv_obj_t * obj, bool en)
|
||||
{
|
||||
obj->drag_parent = (dragpar_en == true ? 1 : 0);
|
||||
obj->drag_parent = (en == true ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -170,7 +170,7 @@ typedef enum
|
||||
void lv_init(void);
|
||||
void lv_obj_inv(lv_obj_t * obj);
|
||||
void lv_obj_refr_style(lv_obj_t * obj);
|
||||
void lv_style_refr_all(void * style_p);
|
||||
void lv_style_refr_all(void * style);
|
||||
|
||||
/*Create and delete*/
|
||||
lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy);
|
||||
@@ -199,21 +199,21 @@ void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod
|
||||
void lv_obj_align_us(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod);
|
||||
void lv_obj_set_ext_size(lv_obj_t * obj, cord_t ext_size);
|
||||
/*Appearance set*/
|
||||
void lv_obj_set_hidden(lv_obj_t * obj, bool hidden_en);
|
||||
void lv_obj_set_hidden(lv_obj_t * obj, bool en);
|
||||
void lv_obj_set_opa(lv_obj_t * obj, opa_t opa);
|
||||
void lv_obj_set_opar(lv_obj_t * obj, opa_t opa);
|
||||
/*Attribute set*/
|
||||
void lv_obj_set_click(lv_obj_t * obj, bool click_en);
|
||||
void lv_obj_set_top(lv_obj_t * obj, bool click_en);
|
||||
void lv_obj_set_drag(lv_obj_t * obj, bool drag_en);
|
||||
void lv_obj_set_drag_throw(lv_obj_t * obj, bool dragthr_en);
|
||||
void lv_obj_set_drag_parent(lv_obj_t * obj, bool dragpar_en);
|
||||
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_drag(lv_obj_t * obj, bool en);
|
||||
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_signal_f(lv_obj_t * obj, lv_signal_f_t fp);
|
||||
void lv_obj_set_design_f(lv_obj_t * obj, lv_design_f_t fp);
|
||||
/*Other set*/
|
||||
void * lv_obj_alloc_ext(lv_obj_t * obj, uint16_t ext_size);
|
||||
void lv_obj_refr_ext_size(lv_obj_t * obj);
|
||||
void lv_obj_set_style(lv_obj_t * obj, void * style_p);
|
||||
void lv_obj_set_style(lv_obj_t * obj, void * style);
|
||||
void * lv_obj_iso_style(lv_obj_t * obj, uint32_t style_size);
|
||||
void lv_obj_set_free_num(lv_obj_t * obj, uint8_t free_num);
|
||||
void lv_obj_set_free_p(lv_obj_t * obj, void * free_p);
|
||||
|
||||
@@ -6,7 +6,12 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
|
||||
#include <lvgl/lv_misc/area.h>
|
||||
#include <lvgl/lv_obj/lv_obj.h>
|
||||
#include <misc/others/color.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#if USE_LV_BTN != 0
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -126,10 +126,10 @@ bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
/**
|
||||
* Set a new map. Buttons will be created/deleted according to the map.
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @param map pointer a string array. Tha last string hast be: "".
|
||||
* @param map pointer a string array. The last string has to be: "".
|
||||
* Use "\n" to begin a new line.
|
||||
* Use "\003" octal numbers to set relative
|
||||
* the width of a button. (max. 9 -> \011)
|
||||
* Use octal numbers (e.g. "\003") to set the relative
|
||||
* width of a button. (max. 9 -> \011)
|
||||
* (e.g. const char * str[] = {"a", "b", "\n", "\004c", "d", ""}).
|
||||
*/
|
||||
void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
|
||||
@@ -143,10 +143,9 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
|
||||
|
||||
/*Set size and positions of the buttons*/
|
||||
lv_btnms_t * btnms = lv_obj_get_style(btnm);
|
||||
cord_t max_w = lv_obj_get_width(btnm) - 2 * btnms->bg.hpad;
|
||||
cord_t max_h = lv_obj_get_height(btnm) - 2 * btnms->bg.vpad;
|
||||
cord_t act_y = btnms->bg.vpad;
|
||||
uint8_t btn_cnt_tot = 0; /*Used to set free number of the buttons*/
|
||||
cord_t max_w = lv_obj_get_width(btnm) - 2 * btnms->rects.hpad;
|
||||
cord_t max_h = lv_obj_get_height(btnm) - 2 * btnms->rects.vpad;
|
||||
cord_t act_y = btnms->rects.vpad;
|
||||
|
||||
/*Count the lines to calculate button height*/
|
||||
uint8_t line_cnt = 1;
|
||||
@@ -155,13 +154,14 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
|
||||
if(strcmp(map[li], "\n") == 0) line_cnt ++;
|
||||
}
|
||||
|
||||
cord_t btn_h = max_h - ((line_cnt - 1) * btnms->bg.opad);
|
||||
cord_t btn_h = max_h - ((line_cnt - 1) * btnms->rects.opad);
|
||||
btn_h = btn_h / line_cnt;
|
||||
|
||||
/* Count the units and the buttons in a line
|
||||
* (A button can be 1,2,3... unit wide)*/
|
||||
uint16_t unit_cnt;
|
||||
uint16_t btn_cnt;
|
||||
uint16_t btn_cnt; /*Number of buttons in a row*/
|
||||
uint16_t i_tot = 0; /*Act. index in the str map*/
|
||||
const char ** map_p_tmp = map;
|
||||
lv_obj_t * btn;
|
||||
btn = ll_get_head(&btnm->child_ll);
|
||||
@@ -170,6 +170,7 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
|
||||
while(1) {
|
||||
unit_cnt = 0;
|
||||
btn_cnt = 0;
|
||||
/*Count the buttons in a line*/
|
||||
while(strcmp(map_p_tmp[btn_cnt], "\n") != 0 &&
|
||||
strlen(map_p_tmp[btn_cnt]) != 0) { /*Check a line*/
|
||||
unit_cnt += lv_btnm_get_width_unit(map_p_tmp[btn_cnt]);
|
||||
@@ -179,31 +180,32 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
|
||||
/*Only deal with the non empty lines*/
|
||||
if(btn_cnt != 0) {
|
||||
/*Calculate the unit width*/
|
||||
cord_t unit_w = max_w - ((btn_cnt-1) * btnms->bg.opad);
|
||||
cord_t unit_w = max_w - ((btn_cnt-1) * btnms->rects.opad);
|
||||
unit_w = unit_w / unit_cnt;
|
||||
|
||||
/*Set the button size and positions and set the texts*/
|
||||
uint16_t i;
|
||||
lv_obj_t * label;
|
||||
cord_t act_x = btnms->bg.hpad;
|
||||
cord_t act_x = btnms->rects.hpad;
|
||||
for(i = 0; i < btn_cnt; i++) {
|
||||
lv_obj_set_size(btn, unit_w * lv_btnm_get_width_unit(map_p_tmp[i]), btn_h);
|
||||
lv_obj_align(btn, NULL, LV_ALIGN_IN_TOP_LEFT, act_x, act_y);
|
||||
lv_obj_set_free_num(btn, btn_cnt_tot);
|
||||
lv_obj_set_style(btn, &btnms->btn);
|
||||
act_x += lv_obj_get_width(btn) + btnms->bg.opad;
|
||||
lv_obj_set_free_num(btn, i_tot);
|
||||
lv_obj_set_style(btn, &btnms->btns);
|
||||
act_x += lv_obj_get_width(btn) + btnms->rects.opad;
|
||||
|
||||
label = lv_obj_get_child(btn, NULL); /*Get the label on the button (the only child)*/
|
||||
lv_obj_set_style(label, &btnms->btn_label);
|
||||
lv_obj_set_style(label, &btnms->labels);
|
||||
lv_label_set_text(label, map_p_tmp[i]);
|
||||
|
||||
btn = ll_get_next(&btnm->child_ll, btn); /*Go to the next button*/
|
||||
btn_cnt_tot ++;
|
||||
i_tot++;
|
||||
}
|
||||
}
|
||||
act_y += btn_h + btnms->bg.opad;
|
||||
act_y += btn_h + btnms->rects.opad;
|
||||
if(strlen(map_p_tmp[btn_cnt]) == 0) break; /*Break on end of map*/
|
||||
map_p_tmp = &map_p_tmp[btn_cnt + 1]; /*Set the map to the next line*/
|
||||
i_tot ++; /*Skip the '\n'*/
|
||||
}
|
||||
|
||||
}
|
||||
@@ -312,9 +314,9 @@ static bool lv_btnm_design(lv_obj_t * obj, const area_t * mask, lv_design_mode_t
|
||||
static void lv_btnms_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
lv_rects_get(LV_RECTS_DEF, &lv_btnms_def.bg); /*Background rectangle style*/
|
||||
lv_btns_get(LV_BTNS_DEF, &lv_btnms_def.btn); /*Button style*/
|
||||
lv_labels_get(LV_LABELS_BTN, &lv_btnms_def.btn_label); /*BUtton label style*/
|
||||
lv_rects_get(LV_RECTS_DEF, &lv_btnms_def.rects); /*Background rectangle style*/
|
||||
lv_btns_get(LV_BTNS_DEF, &lv_btnms_def.btns); /*Button style*/
|
||||
lv_labels_get(LV_LABELS_BTN, &lv_btnms_def.labels); /*BUtton label style*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,12 +4,6 @@
|
||||
*/
|
||||
|
||||
|
||||
/*Search an replace: button matrix -> object normal name with lower case (e.g. button, label etc.)
|
||||
* btnm -> object short name with lower case(e.g. btn, label etc)
|
||||
* BTNM -> object short name with upper case (e.g. BTN, LABEL etc.)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_BTNM_H
|
||||
#define LV_BTNM_H
|
||||
|
||||
@@ -35,10 +29,10 @@
|
||||
/*Style of button matrix*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rects_t bg; /*Style of ancestor*/
|
||||
lv_rects_t rects; /*Style of ancestor*/
|
||||
/*New style element for this type */
|
||||
lv_btns_t btn;
|
||||
lv_labels_t btn_label;
|
||||
lv_btns_t btns; /*Style of the buttons*/
|
||||
lv_labels_t labels; /*Style of the labels on the buttons*/
|
||||
}lv_btnms_t;
|
||||
|
||||
/*Built-in styles of button matrix*/
|
||||
@@ -48,13 +42,14 @@ typedef enum
|
||||
}lv_btnms_builtin_t;
|
||||
|
||||
/* Type of callback function which is called when a button is released
|
||||
* Parameters: button matrix, released object, button index in the map string*/
|
||||
typedef bool (*lv_btnm_callback_t) (lv_obj_t *, lv_obj_t *, uint16_t);
|
||||
* Parameters: button matrix, released object, button index in the map string
|
||||
* return false: the released button or the button matrix is deleted else true*/
|
||||
typedef bool (*lv_btnm_callback_t) (lv_obj_t *, lv_obj_t *, uint8_t);
|
||||
|
||||
/*Data of button matrix*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t bg; /*Ext. of ancestor*/
|
||||
lv_rect_ext_t rect; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
const char ** map_p; /*Pointer to the current map*/
|
||||
lv_btnm_callback_t cb;
|
||||
|
||||
@@ -80,6 +80,8 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_cb_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
ext->bullet = lv_btn_create(new_cb, copy_ext->bullet);
|
||||
ext->label = lv_label_create(new_cb, copy_ext->label);
|
||||
|
||||
lv_obj_set_style(new_cb, lv_obj_get_style(copy));
|
||||
}
|
||||
|
||||
lv_obj_align_us(new_cb, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
@@ -241,22 +243,27 @@ static void lv_cbs_init(void)
|
||||
lv_cbs_def.bullet.mcolor[LV_BTN_STATE_REL] = COLOR_WHITE;
|
||||
lv_cbs_def.bullet.gcolor[LV_BTN_STATE_REL] = COLOR_SILVER;
|
||||
lv_cbs_def.bullet.bcolor[LV_BTN_STATE_REL] = COLOR_BLACK;
|
||||
lv_cbs_def.bullet.light_en[LV_BTN_STATE_REL] = 0;
|
||||
|
||||
lv_cbs_def.bullet.mcolor[LV_BTN_STATE_PR] = COLOR_SILVER;
|
||||
lv_cbs_def.bullet.gcolor[LV_BTN_STATE_PR] = COLOR_GRAY;
|
||||
lv_cbs_def.bullet.bcolor[LV_BTN_STATE_PR] = COLOR_BLACK;
|
||||
lv_cbs_def.bullet.light_en[LV_BTN_STATE_PR] = 0;
|
||||
|
||||
lv_cbs_def.bullet.mcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x20, 0x30, 0x40);
|
||||
lv_cbs_def.bullet.gcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x10, 0x20, 0x30);
|
||||
lv_cbs_def.bullet.bcolor[LV_BTN_STATE_TGL_REL] = COLOR_WHITE;
|
||||
lv_cbs_def.bullet.light_en[LV_BTN_STATE_TGL_REL] = 0;
|
||||
|
||||
lv_cbs_def.bullet.mcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0x50, 0x70, 0x90);
|
||||
lv_cbs_def.bullet.gcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0x20, 0x30, 0x40);
|
||||
lv_cbs_def.bullet.bcolor[LV_BTN_STATE_TGL_PR] = COLOR_WHITE;
|
||||
lv_cbs_def.bullet.light_en[LV_BTN_STATE_TGL_PR] = 0;
|
||||
|
||||
lv_cbs_def.bullet.mcolor[LV_BTN_STATE_INA] = COLOR_SILVER;
|
||||
lv_cbs_def.bullet.gcolor[LV_BTN_STATE_INA] = COLOR_GRAY;
|
||||
lv_cbs_def.bullet.bcolor[LV_BTN_STATE_INA] = COLOR_WHITE;
|
||||
lv_cbs_def.bullet.light_en[LV_BTN_STATE_INA] = 0;
|
||||
|
||||
lv_cbs_def.bullet.rects.bwidth = 2 * LV_STYLE_MULT;
|
||||
lv_cbs_def.bullet.rects.bopa = 70;
|
||||
|
||||
@@ -396,7 +396,7 @@ static void lv_chart_draw_div(lv_obj_t * chart, const area_t * mask)
|
||||
p1.y = (int32_t)((int32_t)h * div_i) / (ext->hdiv_num + 1);
|
||||
p1.y += y_ofs;
|
||||
p2.y = p1.y;
|
||||
lv_draw_line(&p1, &p2, mask, &style->div_line, div_opa);
|
||||
lv_draw_line(&p1, &p2, mask, &style->div_lines, div_opa);
|
||||
}
|
||||
|
||||
p1.y = 0 + y_ofs;
|
||||
@@ -405,7 +405,7 @@ static void lv_chart_draw_div(lv_obj_t * chart, const area_t * mask)
|
||||
p1.x = (int32_t)((int32_t)w * div_i) / (ext->vdiv_num + 1);
|
||||
p1.x += x_ofs;
|
||||
p2.x = p1.x;
|
||||
lv_draw_line(&p1, &p2, mask, &style->div_line, div_opa);
|
||||
lv_draw_line(&p1, &p2, mask, &style->div_lines, div_opa);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -575,15 +575,15 @@ static void lv_charts_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
/* Background */
|
||||
lv_rects_get(LV_RECTS_DEF, &lv_charts_def.bg);
|
||||
lv_charts_def.bg.objs.color = COLOR_MAKE(0x60, 0x80, 0xA0);
|
||||
lv_charts_def.bg.gcolor = COLOR_WHITE;
|
||||
lv_charts_def.bg.bcolor = COLOR_BLACK;
|
||||
lv_rects_get(LV_RECTS_DEF, &lv_charts_def.bg_rects);
|
||||
lv_charts_def.bg_rects.objs.color = COLOR_MAKE(0x60, 0x80, 0xA0);
|
||||
lv_charts_def.bg_rects.gcolor = COLOR_WHITE;
|
||||
lv_charts_def.bg_rects.bcolor = COLOR_BLACK;
|
||||
|
||||
/* Div. line */
|
||||
lv_lines_get(LV_LINES_DECOR, &lv_charts_def.div_line);
|
||||
lv_charts_def.div_line.width = 1 * LV_STYLE_MULT;
|
||||
lv_charts_def.div_line.objs.color = COLOR_BLACK;
|
||||
lv_lines_get(LV_LINES_DECOR, &lv_charts_def.div_lines);
|
||||
lv_charts_def.div_lines.width = 1 * LV_STYLE_MULT;
|
||||
lv_charts_def.div_lines.objs.color = COLOR_BLACK;
|
||||
lv_charts_def.div_line_opa = OPA_COVER;
|
||||
|
||||
/*Data lines*/
|
||||
|
||||
@@ -35,9 +35,9 @@ typedef enum
|
||||
/*Style of chart background*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rects_t bg; /*Style of ancestor*/
|
||||
lv_rects_t bg_rects; /*Style of ancestor*/
|
||||
/*New style element for this type */
|
||||
lv_lines_t div_line;
|
||||
lv_lines_t div_lines;
|
||||
uint8_t div_line_opa; /*Percentage of obj. opacity*/
|
||||
color_t color[LV_CHART_DL_NUM]; /*Line/Point/Col color */
|
||||
uint16_t width; /*Line width or point radius*/
|
||||
@@ -54,7 +54,7 @@ typedef enum
|
||||
/*Data of chart background*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t bg; /*Ext. of ancestor*/
|
||||
lv_rect_ext_t bg_rects; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
cord_t ymin;
|
||||
cord_t ymax;
|
||||
|
||||
@@ -44,20 +44,20 @@ typedef struct
|
||||
{
|
||||
/*No ext. because inherited from the base object*/ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
char* fn;
|
||||
cord_t w;
|
||||
cord_t h;
|
||||
uint8_t auto_size :1;
|
||||
char* fn; /*Image file name. E.g. "U:/my_image"*/
|
||||
cord_t w; /*Width of the image (if LV_UPSCALE_MAP != 0 then multiplied by LV_DOWNSCALE)*/
|
||||
cord_t h; /*Height of the image (if LV_UPSCALE_MAP != 0 then multiplied by LV_DOWNSCALE)*/
|
||||
uint8_t auto_size :1; /*1: automatically set the object size to the image size*/
|
||||
uint8_t transp :1; /*Transp. bit in the images header (library handles this)*/
|
||||
}lv_img_ext_t;
|
||||
|
||||
/*Image header*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t w;
|
||||
uint16_t h;
|
||||
uint16_t cd; /*Color depth*/
|
||||
uint16_t transp :1; /*Do not draw LV_IMG_TRANSP_COLOR pixels*/
|
||||
uint16_t w; /*Width of the image map*/
|
||||
uint16_t h; /*Height of the image map*/
|
||||
uint16_t cd; /*Color depth (8/16 or 24)*/
|
||||
uint16_t transp :1; /*1: Do not draw LV_IMG_TRANSP_COLOR pixels*/
|
||||
}lv_img_raw_header_t;
|
||||
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, b
|
||||
|
||||
/*Make the size adjustment*/
|
||||
if(ext->fit == LV_LIST_FIT_HOLDER) {
|
||||
/*Now the width will be adjusted*/
|
||||
/*Now the width will be adjusted (so disable hor. auto fit)*/
|
||||
lv_rect_set_fit(liste, false, true);
|
||||
cord_t w = lv_obj_get_width(list);
|
||||
w -= lists->bg_pages.bg_rects.hpad * 2;
|
||||
|
||||
@@ -69,7 +69,7 @@ typedef struct
|
||||
lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
void lv_page_glue_obj(lv_obj_t * page, bool glue);
|
||||
lv_pages_t * lv_pages_get(lv_pages_builtin_t style, lv_pages_t * copy);
|
||||
bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param);
|
||||
bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
@@ -73,8 +73,8 @@ lv_obj_t * lv_pb_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
||||
/*Init the new progress bar object*/
|
||||
if(copy == NULL) {
|
||||
ext->format = dm_alloc(strlen(LV_PB_DEF_FORMAT) + 1);
|
||||
strcpy(ext->format, LV_PB_DEF_FORMAT);
|
||||
ext->format_str = dm_alloc(strlen(LV_PB_DEF_FORMAT) + 1);
|
||||
strcpy(ext->format_str, LV_PB_DEF_FORMAT);
|
||||
ext->min_value = 0;
|
||||
ext->max_value = 100;
|
||||
ext->act_value = 0;
|
||||
@@ -89,8 +89,8 @@ lv_obj_t * lv_pb_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_pb_set_value(new_pb, ext->act_value);
|
||||
} else {
|
||||
lv_pb_ext_t * ext_copy = lv_obj_get_ext(copy);
|
||||
ext->format = dm_alloc(strlen(ext_copy->format) + 1);
|
||||
strcpy(ext->format, ext_copy->format);
|
||||
ext->format_str = dm_alloc(strlen(ext_copy->format_str) + 1);
|
||||
strcpy(ext->format_str, ext_copy->format_str);
|
||||
ext->min_value = ext_copy->min_value;
|
||||
ext->max_value = ext_copy->max_value;
|
||||
ext->act_value = ext_copy->act_value;
|
||||
@@ -122,7 +122,7 @@ bool lv_pb_signal(lv_obj_t * pb, lv_signal_t sign, void * param)
|
||||
lv_pb_set_value(pb, ext->act_value);
|
||||
break;
|
||||
case LV_SIGNAL_CLEANUP:
|
||||
dm_free(ext->format);
|
||||
dm_free(ext->format_str);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -147,7 +147,7 @@ void lv_pb_set_value(lv_obj_t * pb, uint16_t value)
|
||||
ext->act_value = value > ext->max_value ? ext->max_value : value;
|
||||
|
||||
char buf[LV_PB_TXT_MAX_LENGTH];
|
||||
sprintf(buf, ext->format, ext->act_value);
|
||||
sprintf(buf, ext->format_str, ext->act_value);
|
||||
lv_label_set_text(lv_obj_get_child(pb, NULL), buf);
|
||||
|
||||
lv_obj_inv(pb);
|
||||
@@ -172,16 +172,16 @@ void lv_pb_set_min_max_value(lv_obj_t * pb, uint16_t min, uint16_t max)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set format string for the label of the progress bar
|
||||
* Set format string for the label of the progress bar
|
||||
* @param pb pointer to progress bar object
|
||||
* @param format a printf-like format string with one number (e.g. "Loading (%d)")
|
||||
*/
|
||||
void lv_pb_set_format(lv_obj_t * pb, const char * format)
|
||||
void lv_pb_set_format_str(lv_obj_t * pb, const char * format)
|
||||
{
|
||||
lv_pb_ext_t * ext = lv_obj_get_ext(pb);
|
||||
dm_free(ext->format);
|
||||
ext->format = dm_alloc(strlen(format) + 1);
|
||||
strcpy(ext->format, format);
|
||||
dm_free(ext->format_str);
|
||||
ext->format_str = dm_alloc(strlen(format) + 1);
|
||||
strcpy(ext->format_str, format);
|
||||
lv_pb_set_value(pb, ext->act_value);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ typedef struct
|
||||
uint16_t act_value;
|
||||
uint16_t min_value;
|
||||
uint16_t max_value;
|
||||
char * format; /*Format string of the label*/
|
||||
char * format_str; /*Format string of the label*/
|
||||
}lv_pb_ext_t;
|
||||
|
||||
/**********************
|
||||
@@ -56,7 +56,7 @@ lv_obj_t * lv_pb_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
bool lv_pb_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
void lv_pb_set_value(lv_obj_t * obj, uint16_t value);
|
||||
void lv_pb_set_min_max_value(lv_obj_t * obj, uint16_t min, uint16_t max);
|
||||
void lv_pb_set_format(lv_obj_t * obj, const char * format);
|
||||
void lv_pb_set_format_str(lv_obj_t * obj, const char * format);
|
||||
uint16_t lv_pb_get_value(lv_obj_t * obj);
|
||||
lv_pbs_t * lv_pbs_get(lv_pbs_builtin_t style, lv_pbs_t * copy_p);
|
||||
|
||||
|
||||
@@ -31,13 +31,13 @@ typedef enum
|
||||
LV_RECT_LAYOUT_COL_L, /*Column left align*/
|
||||
LV_RECT_LAYOUT_COL_M, /*Column middle align*/
|
||||
LV_RECT_LAYOUT_COL_R, /*Column right align*/
|
||||
LV_RECT_LAYOUT_ROW_T, /*Row row left align*/
|
||||
LV_RECT_LAYOUT_ROW_M, /*Row row middle align*/
|
||||
LV_RECT_LAYOUT_ROW_B, /*Row row right align*/
|
||||
LV_RECT_LAYOUT_GRID,
|
||||
LV_RECT_LAYOUT_ROW_T, /*Row left align*/
|
||||
LV_RECT_LAYOUT_ROW_M, /*Row middle align*/
|
||||
LV_RECT_LAYOUT_ROW_B, /*Row right align*/
|
||||
LV_RECT_LAYOUT_GRID, /*Put as many object as possible in row and begin a new row*/
|
||||
}lv_rect_layout_t;
|
||||
|
||||
/*Style of template*/
|
||||
/*Style of rectangle*/
|
||||
typedef struct
|
||||
{
|
||||
lv_objs_t objs; /*Style of ancestor*/
|
||||
@@ -45,17 +45,17 @@ typedef struct
|
||||
color_t gcolor; /*Gradient color*/
|
||||
color_t bcolor; /*Border color*/
|
||||
color_t lcolor; /*Light color*/
|
||||
uint16_t bwidth;
|
||||
uint16_t round;
|
||||
cord_t hpad;
|
||||
cord_t vpad;
|
||||
cord_t opad;
|
||||
uint16_t bwidth;/*Border width*/
|
||||
uint16_t round; /*Radius on the corners*/
|
||||
cord_t hpad; /*Horizontal padding when horizontal fit is enabled*/
|
||||
cord_t vpad; /*Vertical padding when vertical fit is enabled*/
|
||||
cord_t opad; /*Object padding with fit*/
|
||||
cord_t light; /*Light size*/
|
||||
uint8_t bopa;
|
||||
uint8_t empty :1;
|
||||
uint8_t bopa; /*Border opacity*/
|
||||
uint8_t empty :1; /*1: Do not draw the body of the rectangle*/
|
||||
}lv_rects_t;
|
||||
|
||||
/*Built-in styles of template*/
|
||||
/*Built-in styles of rectangle*/
|
||||
typedef enum
|
||||
{
|
||||
LV_RECTS_DEF,
|
||||
|
||||
@@ -11,12 +11,16 @@
|
||||
#if USE_LV_TA != 0
|
||||
|
||||
#include "lv_ta.h"
|
||||
#include "lvgl/lv_misc/anim.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_TA_MAX_LENGTH 512
|
||||
#define LV_TA_DEF_WIDTH 120
|
||||
#define LV_TA_DEF_HEIGHT 80
|
||||
#define LV_TA_CUR_BLINK_TIME 400 /*ms*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@@ -27,6 +31,7 @@
|
||||
**********************/
|
||||
static bool lv_ta_design(lv_obj_t * ta, const area_t * mask, lv_design_mode_t mode);
|
||||
static bool lv_ta_scrling_design(lv_obj_t * scrling, const area_t * mask, lv_design_mode_t mode);
|
||||
static void lv_ta_hide_cursor(lv_obj_t * ta, uint8_t hide);
|
||||
static void lv_ta_save_valid_cursor_x(lv_obj_t * ta);
|
||||
static void lv_tas_init(void);
|
||||
|
||||
@@ -75,6 +80,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
||||
ext->cursor_valid_x = 0;
|
||||
ext->cursor_pos = 0;
|
||||
ext->cur_hide = 0;
|
||||
|
||||
/*Init the new text area object*/
|
||||
if(copy == NULL) {
|
||||
@@ -82,12 +88,14 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
if(scrling_design_f == NULL) {
|
||||
scrling_design_f = lv_obj_get_design_f(ext->page.scrolling);
|
||||
}
|
||||
|
||||
lv_obj_set_design_f(ext->page.scrolling, lv_ta_scrling_design);
|
||||
lv_label_set_long_mode(ext->label, LV_LABEL_LONG_BREAK);
|
||||
lv_label_set_text(ext->label, "abc aaaa bbbb ccc\n123\nABC\nxyz\nwww\n007\nalma\n:)\naaaaaa");
|
||||
lv_label_set_text(ext->label, "Text area");
|
||||
lv_page_glue_obj(ext->label, true);
|
||||
lv_obj_set_click(ext->label, true);
|
||||
lv_obj_set_style(new_ta, lv_tas_get(LV_TAS_DEF, NULL));
|
||||
lv_obj_set_size_us(new_ta, LV_TA_DEF_WIDTH, LV_TA_DEF_HEIGHT);
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
@@ -100,6 +108,20 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_obj_set_style(new_ta, lv_obj_get_style(copy));
|
||||
}
|
||||
|
||||
/*Create a cursor blinker animation*/
|
||||
anim_t a;
|
||||
a.var = new_ta;
|
||||
a.fp = (anim_fp_t)lv_ta_hide_cursor;
|
||||
a.time = LV_TA_CUR_BLINK_TIME;
|
||||
a.act_time = 0;
|
||||
a.end_cb = NULL;
|
||||
a.repeat = 1;
|
||||
a.repeat_pause = 0;
|
||||
a.playback = 1;
|
||||
a.playback_pause = 0;
|
||||
a.path = anim_get_path(ANIM_PATH_STEP);
|
||||
anim_create(&a);
|
||||
|
||||
return new_ta;
|
||||
}
|
||||
|
||||
@@ -124,10 +146,11 @@ bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
|
||||
lv_tas_t * style = lv_obj_get_style(ta);
|
||||
switch(sign) {
|
||||
case LV_SIGNAL_CLEANUP:
|
||||
lv_obj_del(ext->label);
|
||||
/* Nothing to clean up.
|
||||
* (The created label will be deleted automatically) */
|
||||
break;
|
||||
case LV_SIGNAL_STYLE_CHG:
|
||||
lv_obj_set_style(ext->label, &style->label);
|
||||
lv_obj_set_style(ext->label, &style->labels);
|
||||
lv_obj_set_width(ext->label, lv_obj_get_width(ta) - 2 *
|
||||
(style->pages.bg_rects.hpad + style->pages.scrable_rects.hpad));
|
||||
lv_label_set_text(ext->label, NULL);
|
||||
@@ -206,6 +229,21 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt)
|
||||
lv_ta_save_valid_cursor_x(ta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text os a text area
|
||||
* @param ta pointer to a text area
|
||||
* @param txt pointer to the text
|
||||
*/
|
||||
void lv_ta_set_text(lv_obj_t * ta, const char * txt)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_label_set_text(ext->label, txt);
|
||||
lv_ta_set_cursor_pos(ta, LV_TA_CUR_LAST);
|
||||
|
||||
/*It is a valid x step so save it*/
|
||||
lv_ta_save_valid_cursor_x(ta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a the left character from the current cursor position
|
||||
* @param ta pointer to a text area object
|
||||
@@ -234,17 +272,22 @@ void lv_ta_del(lv_obj_t * ta)
|
||||
lv_ta_save_valid_cursor_x(ta);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the cursor position
|
||||
* @param obj pointer to a text area object
|
||||
* @param pos the new cursor position in character index
|
||||
* < 0 : index from the end of the text
|
||||
* LV_TA_CUR_LAST: go after the last character
|
||||
*/
|
||||
void lv_ta_set_cursor_pos(lv_obj_t * ta, uint16_t pos)
|
||||
void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
uint16_t txt_len = strlen(lv_label_get_text(ext->label));
|
||||
|
||||
if(pos > txt_len) pos = txt_len;
|
||||
if(pos < 0) pos = txt_len + pos;
|
||||
|
||||
if(pos > txt_len || pos == LV_TA_CUR_LAST) pos = txt_len;
|
||||
|
||||
ext->cursor_pos = pos;
|
||||
|
||||
@@ -252,7 +295,7 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, uint16_t pos)
|
||||
lv_obj_t * label_par = lv_obj_get_parent(ext->label);
|
||||
point_t cur_pos;
|
||||
lv_tas_t * style = lv_obj_get_style(ta);
|
||||
const font_t * font_p = font_get(style->label.font);
|
||||
const font_t * font_p = font_get(style->labels.font);
|
||||
lv_label_get_letter_pos(ext->label, pos, &cur_pos);
|
||||
|
||||
/*Check the top*/
|
||||
@@ -462,7 +505,7 @@ static bool lv_ta_scrling_design(lv_obj_t * scrling, const area_t * mask, lv_des
|
||||
lv_ta_ext_t * ta_ext = lv_obj_get_ext(ta);
|
||||
lv_tas_t * ta_style = lv_obj_get_style(ta);
|
||||
|
||||
if(ta_style->cursor_show != 0) {
|
||||
if(ta_style->cursor_show != 0 && ta_ext->cur_hide == 0) {
|
||||
uint16_t cur_pos = lv_ta_get_cursor_pos(ta);
|
||||
point_t letter_pos;
|
||||
lv_label_get_letter_pos(ta_ext->label, cur_pos, &letter_pos);
|
||||
@@ -487,6 +530,21 @@ static bool lv_ta_scrling_design(lv_obj_t * scrling, const area_t * mask, lv_des
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the cursor visibility to make a blinking cursor
|
||||
* @param ta pointer to a text area
|
||||
* @param hide 1: hide the cursor, 0: draw it
|
||||
*/
|
||||
static void lv_ta_hide_cursor(lv_obj_t * ta, uint8_t hide)
|
||||
{
|
||||
lv_ta_ext_t * ta_ext = lv_obj_get_ext(ta);
|
||||
ta_ext->cur_hide = hide == 0 ? 0 : 1;
|
||||
|
||||
lv_obj_inv(ta);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the cursor x position as valid. It is important when jumping up/down to a shorter line
|
||||
* @param ta pointer to a text area object
|
||||
@@ -507,11 +565,11 @@ static void lv_tas_init(void)
|
||||
/*Default style*/
|
||||
lv_pages_get(LV_PAGES_DEF, &lv_tas_def.pages);
|
||||
|
||||
lv_labels_get(LV_LABELS_TXT, &lv_tas_def.label);
|
||||
lv_tas_def.label.objs.color = COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
lv_labels_get(LV_LABELS_TXT, &lv_tas_def.labels);
|
||||
lv_tas_def.labels.objs.color = COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
|
||||
lv_tas_def.cursor_color = COLOR_MAKE(0x10, 0x10, 0x10);
|
||||
lv_tas_def.cursor_width = 2 * LV_STYLE_MULT; /*>1 px for visible cursor*/
|
||||
lv_tas_def.cursor_width = 1 * LV_STYLE_MULT; /*>=1 px for visible cursor*/
|
||||
lv_tas_def.cursor_show = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_TA_CUR_LAST (0x7FFF) /*Put the cursor after the last character*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@@ -29,7 +30,7 @@ typedef struct
|
||||
{
|
||||
lv_pages_t pages; /*Style of ancestor*/
|
||||
/*New style element for this type */
|
||||
lv_labels_t label;
|
||||
lv_labels_t labels;
|
||||
color_t cursor_color;
|
||||
cord_t cursor_width;
|
||||
uint8_t cursor_show :1;
|
||||
@@ -49,6 +50,7 @@ typedef struct
|
||||
lv_obj_t * label;
|
||||
cord_t cursor_valid_x;
|
||||
uint16_t cursor_pos;
|
||||
uint8_t cur_hide :1; /*Indicates that the cursor is visible now or not*/
|
||||
}lv_ta_ext_t;
|
||||
|
||||
/**********************
|
||||
@@ -60,8 +62,9 @@ lv_tas_t * lv_tas_get(lv_tas_builtin_t style, lv_tas_t * copy);
|
||||
|
||||
void lv_ta_add_char(lv_obj_t * ta, char c);
|
||||
void lv_ta_add_text(lv_obj_t * ta, const char * txt);
|
||||
void lv_ta_set_text(lv_obj_t * ta, const char * txt);
|
||||
void lv_ta_del(lv_obj_t * ta);
|
||||
void lv_ta_set_cursor_pos(lv_obj_t * ta, uint16_t pos);
|
||||
void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos);
|
||||
void lv_ta_cursor_right (lv_obj_t * ta);
|
||||
void lv_ta_cursor_left(lv_obj_t * taj);
|
||||
void lv_ta_cursor_down(lv_obj_t * ta);
|
||||
|
||||
@@ -82,7 +82,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
||||
/*Create a holder for the control buttons*/
|
||||
ext->ctrl_holder = lv_rect_create(ext->header, NULL);
|
||||
lv_rect_set_fit(ext->ctrl_holder, true, true);
|
||||
lv_rect_set_fit(ext->ctrl_holder, true, false);
|
||||
lv_rect_set_layout(ext->ctrl_holder, LV_RECT_LAYOUT_ROW_M);
|
||||
|
||||
/*Create a page for the content*/
|
||||
@@ -229,6 +229,32 @@ void lv_win_set_title(lv_obj_t * win, const char * title)
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
/**
|
||||
* Get the title of a window
|
||||
* @param win pointer to a window object
|
||||
* @return title string of the window
|
||||
*/
|
||||
const char * lv_win_get_title(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
|
||||
return ext->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pointer of a widow from one of its control button.
|
||||
* It is useful in the action of the control buttons where only button is known.
|
||||
* @param ctrl_btn pointer to a control button of a window
|
||||
* @return pointer to the window of 'ctrl_btn'
|
||||
*/
|
||||
lv_obj_t * lv_win_get_from_ctrl_btn(lv_obj_t * ctrl_btn)
|
||||
{
|
||||
lv_obj_t * ctrl_holder = lv_obj_get_parent(ctrl_btn);
|
||||
lv_obj_t * header = lv_obj_get_parent(ctrl_holder);
|
||||
lv_obj_t * win = lv_obj_get_parent(header);
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
@@ -369,6 +395,7 @@ static void lv_win_realign(lv_obj_t * win)
|
||||
cbtn = lv_obj_get_child(ext->ctrl_holder, cbtn);
|
||||
}
|
||||
|
||||
lv_obj_set_height(ext->ctrl_holder, style->ctrl_btn_h + 2 * style->ctrl_holder.vpad * 2);
|
||||
lv_obj_set_width(ext->header, lv_obj_get_width(win));
|
||||
lv_obj_set_size(ext->content, lv_obj_get_width(win), lv_obj_get_height(win) - lv_obj_get_height(ext->header));
|
||||
|
||||
|
||||
@@ -71,6 +71,8 @@ lv_wins_t * lv_wins_get(lv_wins_builtin_t style, lv_wins_t * copy);
|
||||
lv_obj_t * lv_win_add_ctrl_btn(lv_obj_t * win, const char * img, bool (*rel_action)(lv_obj_t *, lv_dispi_t *));
|
||||
void lv_win_set_title(lv_obj_t * win, const char * title);
|
||||
|
||||
const char * lv_win_get_title(lv_obj_t * win);
|
||||
lv_obj_t * lv_win_get_from_ctrl_btn(lv_obj_t * ctrl_btn);
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
Reference in New Issue
Block a user