1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

rename ta, cb, sw, ddlist, mbox, kb, btnm, lmeter, preload

This commit is contained in:
Gabor Kiss-Vamosi 2020-02-14 12:36:44 +01:00
parent 738faeda21
commit bd9299c89e
39 changed files with 1451 additions and 1450 deletions

View File

@ -438,7 +438,7 @@ typedef void * lv_obj_user_data_t;
#endif
/*Button matrix (dependencies: -)*/
#define LV_USE_BTNM 1
#define LV_USE_BTNMATRIX 1
/*Calendar (dependencies: -)*/
#define LV_USE_CALENDAR 1
@ -447,7 +447,7 @@ typedef void * lv_obj_user_data_t;
#define LV_USE_CANVAS 1
/*Check box (dependencies: lv_btn, lv_label)*/
#define LV_USE_CB 1
#define LV_USE_CHECKBOX 1
/*Chart (dependencies: -)*/
#define LV_USE_CHART 1
@ -462,13 +462,13 @@ typedef void * lv_obj_user_data_t;
#define LV_USE_CPICKER 1
/*Drop down list (dependencies: lv_page, lv_label, lv_symbol_def.h)*/
#define LV_USE_DDLIST 1
#if LV_USE_DDLIST != 0
#define LV_USE_DROPDOWN 1
#if LV_USE_DROPDOWN != 0
/*Open and close default animation time [ms] (0: no animation)*/
# define LV_DDLIST_DEF_ANIM_TIME 200
# define LV_DROPDOWN_DEF_ANIM_TIME 200
#endif
/*Gauge (dependencies:lv_bar, lv_lmeter)*/
/*Gauge (dependencies:lv_bar, lv_linemeter)*/
#define LV_USE_GAUGE 1
/*Image (dependencies: lv_label*/
@ -482,7 +482,7 @@ typedef void * lv_obj_user_data_t;
#endif
/*Keyboard (dependencies: lv_btnm)*/
#define LV_USE_KB 1
#define LV_USE_KEYBOARD 1
/*Label (dependencies: -*/
#define LV_USE_LABEL 1
@ -520,7 +520,7 @@ typedef void * lv_obj_user_data_t;
#define LV_USE_OBJMASK 0
/*Message box (dependencies: lv_rect, lv_btnm, lv_label)*/
#define LV_USE_MBOX 1
#define LV_USE_MSGBOX 1
/*Page (dependencies: lv_cont)*/
#define LV_USE_PAGE 1
@ -530,11 +530,11 @@ typedef void * lv_obj_user_data_t;
#endif
/*Preload (dependencies: lv_arc, lv_anim)*/
#define LV_USE_PRELOAD 1
#if LV_USE_PRELOAD != 0
# define LV_PRELOAD_DEF_ARC_LENGTH 60 /*[deg]*/
# define LV_PRELOAD_DEF_SPIN_TIME 1000 /*[ms]*/
# define LV_PRELOAD_DEF_ANIM LV_PRELOAD_TYPE_SPINNING_ARC
#define LV_USE_SPINNER 1
#if LV_USE_SPINNER != 0
# define LV_SPINNER_DEF_ARC_LENGTH 60 /*[deg]*/
# define LV_SPINNER_DEF_SPIN_TIME 1000 /*[ms]*/
# define LV_SPINNER_DEF_ANIM LV_SPINNER_TYPE_SPINNING_ARC
#endif
/*Roller (dependencies: lv_ddlist)*/
@ -554,24 +554,24 @@ typedef void * lv_obj_user_data_t;
#define LV_USE_SPINBOX 1
/*Switch (dependencies: lv_slider)*/
#define LV_USE_SW 1
#define LV_USE_SWITCH 1
/*Text area (dependencies: lv_label, lv_page)*/
#define LV_USE_TA 1
#if LV_USE_TA != 0
# define LV_TA_DEF_CURSOR_BLINK_TIME 400 /*ms*/
# define LV_TA_DEF_PWD_SHOW_TIME 1500 /*ms*/
#define LV_USE_TEXTAREA 1
#if LV_USE_TEXTAREA != 0
# define LV_TEXTAREA_DEF_CURSOR_BLINK_TIME 400 /*ms*/
# define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/
#endif
/*Table (dependencies: lv_label)*/
#define LV_USE_TABLE 1
#if LV_USE_TABLE
#define LV_USE_TEXTAREABLE 1
#if LV_USE_TEXTAREABLE
# define LV_TABLE_COL_MAX 12
#endif
/*Tab (dependencies: lv_page, lv_btnm)*/
#define LV_USE_TABVIEW 1
# if LV_USE_TABVIEW != 0
#define LV_USE_TEXTAREABVIEW 1
# if LV_USE_TEXTAREABVIEW != 0
/*Time of slide animation [ms] (0: no animation)*/
# define LV_TABVIEW_DEF_ANIM_TIME 300
#endif

2
lvgl.h
View File

@ -63,7 +63,7 @@ extern "C" {
#include "src/lv_objx/lv_mbox.h"
#include "src/lv_objx/lv_objmask.h"
#include "src/lv_objx/lv_gauge.h"
#include "src/lv_objx/lv_lmeter.h"
#include "src/lv_objx/lv_linemeter.h"
#include "src/lv_objx/lv_sw.h"
#include "src/lv_objx/lv_kb.h"
#include "src/lv_objx/lv_arc.h"

View File

@ -38,17 +38,17 @@ extern "C" {
#endif
#if LV_USE_DDLIST
#if LV_USE_DROPDOWN
static inline void lv_ddlist_set_draw_arrow(lv_obj_t * ddlist, bool en)
static inline void lv_dropdown_set_draw_arrow(lv_obj_t * ddlist, bool en)
{
if(en) lv_ddlist_set_symbol(ddlist, LV_SYMBOL_DOWN);
else lv_ddlist_set_symbol(ddlist, NULL);
if(en) lv_dropdown_set_symbol(ddlist, LV_SYMBOL_DOWN);
else lv_dropdown_set_symbol(ddlist, NULL);
}
static inline bool lv_ddlist_get_draw_arrow(lv_obj_t * ddlist)
static inline bool lv_dropdown_get_draw_arrow(lv_obj_t * ddlist)
{
if(lv_ddlist_get_symbol(ddlist)) return true;
if(lv_dropdown_get_symbol(ddlist)) return true;
else return false;
}

View File

@ -614,8 +614,8 @@
#endif
/*Button matrix (dependencies: -)*/
#ifndef LV_USE_BTNM
#define LV_USE_BTNM 1
#ifndef LV_USE_BTNMATRIX
#define LV_USE_BTNMATRIX 1
#endif
/*Calendar (dependencies: -)*/
@ -629,8 +629,8 @@
#endif
/*Check box (dependencies: lv_btn, lv_label)*/
#ifndef LV_USE_CB
#define LV_USE_CB 1
#ifndef LV_USE_CHECKBOX
#define LV_USE_CHECKBOX 1
#endif
/*Chart (dependencies: -)*/
@ -654,17 +654,17 @@
#endif
/*Drop down list (dependencies: lv_page, lv_label, lv_symbol_def.h)*/
#ifndef LV_USE_DDLIST
#define LV_USE_DDLIST 1
#ifndef LV_USE_DROPDOWN
#define LV_USE_DROPDOWN 1
#endif
#if LV_USE_DDLIST != 0
#if LV_USE_DROPDOWN != 0
/*Open and close default animation time [ms] (0: no animation)*/
#ifndef LV_DDLIST_DEF_ANIM_TIME
# define LV_DDLIST_DEF_ANIM_TIME 200
#ifndef LV_DROPDOWN_DEF_ANIM_TIME
# define LV_DROPDOWN_DEF_ANIM_TIME 200
#endif
#endif
/*Gauge (dependencies:lv_bar, lv_lmeter)*/
/*Gauge (dependencies:lv_bar, lv_linemeter)*/
#ifndef LV_USE_GAUGE
#define LV_USE_GAUGE 1
#endif
@ -686,8 +686,8 @@
#endif
/*Keyboard (dependencies: lv_btnm)*/
#ifndef LV_USE_KB
#define LV_USE_KB 1
#ifndef LV_USE_KEYBOARD
#define LV_USE_KEYBOARD 1
#endif
/*Label (dependencies: -*/
@ -748,8 +748,8 @@
#endif
/*Message box (dependencies: lv_rect, lv_btnm, lv_label)*/
#ifndef LV_USE_MBOX
#define LV_USE_MBOX 1
#ifndef LV_USE_MSGBOX
#define LV_USE_MSGBOX 1
#endif
/*Page (dependencies: lv_cont)*/
@ -764,18 +764,18 @@
#endif
/*Preload (dependencies: lv_arc, lv_anim)*/
#ifndef LV_USE_PRELOAD
#define LV_USE_PRELOAD 1
#ifndef LV_USE_SPINNER
#define LV_USE_SPINNER 1
#endif
#if LV_USE_PRELOAD != 0
#ifndef LV_PRELOAD_DEF_ARC_LENGTH
# define LV_PRELOAD_DEF_ARC_LENGTH 60 /*[deg]*/
#if LV_USE_SPINNER != 0
#ifndef LV_SPINNER_DEF_ARC_LENGTH
# define LV_SPINNER_DEF_ARC_LENGTH 60 /*[deg]*/
#endif
#ifndef LV_PRELOAD_DEF_SPIN_TIME
# define LV_PRELOAD_DEF_SPIN_TIME 1000 /*[ms]*/
#ifndef LV_SPINNER_DEF_SPIN_TIME
# define LV_SPINNER_DEF_SPIN_TIME 1000 /*[ms]*/
#endif
#ifndef LV_PRELOAD_DEF_ANIM
# define LV_PRELOAD_DEF_ANIM LV_PRELOAD_TYPE_SPINNING_ARC
#ifndef LV_SPINNER_DEF_ANIM
# define LV_SPINNER_DEF_ANIM LV_SPINNER_TYPE_SPINNING_ARC
#endif
#endif
@ -806,38 +806,38 @@
#endif
/*Switch (dependencies: lv_slider)*/
#ifndef LV_USE_SW
#define LV_USE_SW 1
#ifndef LV_USE_SWITCH
#define LV_USE_SWITCH 1
#endif
/*Text area (dependencies: lv_label, lv_page)*/
#ifndef LV_USE_TA
#define LV_USE_TA 1
#ifndef LV_USE_TEXTAREA
#define LV_USE_TEXTAREA 1
#endif
#if LV_USE_TA != 0
#ifndef LV_TA_DEF_CURSOR_BLINK_TIME
# define LV_TA_DEF_CURSOR_BLINK_TIME 400 /*ms*/
#if LV_USE_TEXTAREA != 0
#ifndef LV_TEXTAREA_DEF_CURSOR_BLINK_TIME
# define LV_TEXTAREA_DEF_CURSOR_BLINK_TIME 400 /*ms*/
#endif
#ifndef LV_TA_DEF_PWD_SHOW_TIME
# define LV_TA_DEF_PWD_SHOW_TIME 1500 /*ms*/
#ifndef LV_TEXTAREA_DEF_PWD_SHOW_TIME
# define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/
#endif
#endif
/*Table (dependencies: lv_label)*/
#ifndef LV_USE_TABLE
#define LV_USE_TABLE 1
#ifndef LV_USE_TEXTAREABLE
#define LV_USE_TEXTAREABLE 1
#endif
#if LV_USE_TABLE
#if LV_USE_TEXTAREABLE
#ifndef LV_TABLE_COL_MAX
# define LV_TABLE_COL_MAX 12
#endif
#endif
/*Tab (dependencies: lv_page, lv_btnm)*/
#ifndef LV_USE_TABVIEW
#define LV_USE_TABVIEW 1
#ifndef LV_USE_TEXTAREABVIEW
#define LV_USE_TEXTAREABVIEW 1
#endif
# if LV_USE_TABVIEW != 0
# if LV_USE_TEXTAREABVIEW != 0
/*Time of slide animation [ms] (0: no animation)*/
#ifndef LV_TABVIEW_DEF_ANIM_TIME
# define LV_TABVIEW_DEF_ANIM_TIME 300

View File

@ -7,7 +7,7 @@
* INCLUDES
*********************/
#include "lv_btnm.h"
#if LV_USE_BTNM != 0
#if LV_USE_BTNMATRIX != 0
#include "../lv_core/lv_debug.h"
#include "../lv_core/lv_group.h"
@ -19,7 +19,7 @@
/*********************
* DEFINES
*********************/
#define LV_OBJX_NAME "lv_btnm"
#define LV_OBJX_NAME "lv_btnmatrix"
/**********************
* TYPEDEFS
@ -28,17 +28,17 @@
/**********************
* STATIC PROTOTYPES
**********************/
static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param);
static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_style_list_t * lv_btnm_get_style(lv_obj_t * btnm, uint8_t part);
static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * param);
static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_style_list_t * lv_btnmatrix_get_style(lv_obj_t * btnm, uint8_t part);
static uint8_t get_button_width(lv_btnm_ctrl_t ctrl_bits);
static bool button_is_hidden(lv_btnm_ctrl_t ctrl_bits);
static bool button_is_repeat_disabled(lv_btnm_ctrl_t ctrl_bits);
static bool button_is_inactive(lv_btnm_ctrl_t ctrl_bits);
static bool button_is_click_trig(lv_btnm_ctrl_t ctrl_bits);
static bool button_is_tgl_enabled(lv_btnm_ctrl_t ctrl_bits);
static bool button_get_tgl_state(lv_btnm_ctrl_t ctrl_bits);
static uint8_t get_button_width(lv_btnmatrix_ctrl_t ctrl_bits);
static bool button_is_hidden(lv_btnmatrix_ctrl_t ctrl_bits);
static bool button_is_repeat_disabled(lv_btnmatrix_ctrl_t ctrl_bits);
static bool button_is_inactive(lv_btnmatrix_ctrl_t ctrl_bits);
static bool button_is_click_trig(lv_btnmatrix_ctrl_t ctrl_bits);
static bool button_is_tgl_enabled(lv_btnmatrix_ctrl_t ctrl_bits);
static bool button_get_tgl_state(lv_btnmatrix_ctrl_t ctrl_bits);
static uint16_t get_button_from_point(lv_obj_t * btnm, lv_point_t * p);
static void allocate_btn_areas_and_controls(const lv_obj_t * btnm, const char ** map);
static void invalidate_button_area(const lv_obj_t * btnm, uint16_t btn_idx);
@ -48,7 +48,7 @@ static void make_one_button_toggled(lv_obj_t * btnm, uint16_t btn_idx);
/**********************
* STATIC VARIABLES
**********************/
static const char * lv_btnm_def_map[] = {"Btn1", "Btn2", "Btn3", "\n", "Btn4", "Btn5", ""};
static const char * lv_btnmatrix_def_map[] = {"Btn1", "Btn2", "Btn3", "\n", "Btn4", "Btn5", ""};
static lv_design_cb_t ancestor_design_f;
static lv_signal_cb_t ancestor_signal;
@ -68,7 +68,7 @@ static lv_signal_cb_t ancestor_signal;
* from it
* @return pointer to the created button matrix
*/
lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_t * lv_btnmatrix_create(lv_obj_t * par, const lv_obj_t * copy)
{
LV_LOG_TRACE("button matrix create started");
@ -80,7 +80,7 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(btnm);
/*Allocate the object type specific extended data*/
lv_btnm_ext_t * ext = lv_obj_allocate_ext_attr(btnm, sizeof(lv_btnm_ext_t));
lv_btnmatrix_ext_t * ext = lv_obj_allocate_ext_attr(btnm, sizeof(lv_btnmatrix_ext_t));
LV_ASSERT_MEM(ext);
if(ext == NULL) {
lv_obj_del(btnm);
@ -88,9 +88,9 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
}
ext->btn_cnt = 0;
ext->btn_id_pr = LV_BTNM_BTN_NONE;
ext->btn_id_focused = LV_BTNM_BTN_NONE;
ext->btn_id_act = LV_BTNM_BTN_NONE;
ext->btn_id_pr = LV_BTNMATRIX_BTN_NONE;
ext->btn_id_focused = LV_BTNMATRIX_BTN_NONE;
ext->btn_id_act = LV_BTNMATRIX_BTN_NONE;
ext->button_areas = NULL;
ext->ctrl_bits = NULL;
ext->map_p = NULL;
@ -100,20 +100,20 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_cb(btnm);
lv_obj_set_signal_cb(btnm, lv_btnm_signal);
lv_obj_set_design_cb(btnm, lv_btnm_design);
lv_obj_set_signal_cb(btnm, lv_btnmatrix_signal);
lv_obj_set_design_cb(btnm, lv_btnmatrix_design);
/*Init the new button matrix object*/
if(copy == NULL) {
lv_btnm_set_map(btnm, lv_btnm_def_map);
lv_btnmatrix_set_map(btnm, lv_btnmatrix_def_map);
lv_obj_set_size(btnm, LV_DPI * 3, LV_DPI * 2);
lv_theme_apply(btnm, LV_THEME_BTNM);
}
/*Copy an existing object*/
else {
// lv_btnm_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
// lv_btnmatrix_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
// memcpy((void*)ext->styles_btn, copy_ext->styles_btn, sizeof(ext->styles_btn));
// lv_btnm_set_map(new_btnm, lv_btnm_get_map_array(copy));
// lv_btnmatrix_set_map(new_btnm, lv_btnmatrix_get_map_array(copy));
}
LV_LOG_INFO("button matrix created");
@ -132,13 +132,13 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
* @param btnm pointer to a button matrix object
* @param map pointer a string array. The last string has to be: "". Use "\n" to make a line break.
*/
void lv_btnm_set_map(lv_obj_t * btnm, const char * map[])
void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[])
{
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
LV_ASSERT_NULL(map);
/*
* lv_btnm_set_map is called on receipt of signals such as
* lv_btnmatrix_set_map is called on receipt of signals such as
* LV_SIGNAL_CORD_CHG regardless of whether the map has changed (e.g.
* calling lv_obj_align on the map will trigger this).
*
@ -148,7 +148,7 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char * map[])
* TODO: separate all map set/allocation from layout code below and skip
* set/allocation when map hasn't changed.
*/
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
if(!maps_are_identical(ext->map_p, map)) {
/*Analyze the map and create the required number of buttons*/
@ -157,11 +157,11 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char * map[])
ext->map_p = map;
/*Set size and positions of the buttons*/
lv_style_int_t left = lv_obj_get_style_pad_left(btnm, LV_BTNM_PART_BG);
lv_style_int_t right = lv_obj_get_style_pad_right(btnm, LV_BTNM_PART_BG);
lv_style_int_t top = lv_obj_get_style_pad_top(btnm, LV_BTNM_PART_BG);
lv_style_int_t bottom = lv_obj_get_style_pad_bottom(btnm, LV_BTNM_PART_BG);
lv_style_int_t inner = lv_obj_get_style_pad_inner(btnm, LV_BTNM_PART_BG);
lv_style_int_t left = lv_obj_get_style_pad_left(btnm, LV_BTNMATRIX_PART_BG);
lv_style_int_t right = lv_obj_get_style_pad_right(btnm, LV_BTNMATRIX_PART_BG);
lv_style_int_t top = lv_obj_get_style_pad_top(btnm, LV_BTNMATRIX_PART_BG);
lv_style_int_t bottom = lv_obj_get_style_pad_bottom(btnm, LV_BTNMATRIX_PART_BG);
lv_style_int_t inner = lv_obj_get_style_pad_inner(btnm, LV_BTNMATRIX_PART_BG);
lv_coord_t max_w = lv_obj_get_width(btnm) - left - right;
@ -267,31 +267,31 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char * map[])
* the number and order of the individual buttons (i.e. excludes
* newline entries).
* An element of the map should look like e.g.:
* `ctrl_map[0] = width | LV_BTNM_CTRL_NO_REPEAT | LV_BTNM_CTRL_TGL_ENABLE`
* `ctrl_map[0] = width | LV_BTNMATRIX_CTRL_NO_REPEAT | LV_BTNMATRIX_CTRL_TGL_ENABLE`
*/
void lv_btnm_set_ctrl_map(const lv_obj_t * btnm, const lv_btnm_ctrl_t ctrl_map[])
void lv_btnmatrix_set_ctrl_map(const lv_obj_t * btnm, const lv_btnmatrix_ctrl_t ctrl_map[])
{
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
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);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
memcpy(ext->ctrl_bits, ctrl_map, sizeof(lv_btnmatrix_ctrl_t) * ext->btn_cnt);
lv_btnm_set_map(btnm, ext->map_p);
lv_btnmatrix_set_map(btnm, ext->map_p);
}
/**
* Set the pressed button i.e. visually highlight it.
* Mainly used a when the btnm is in a group to show the selected button
* @param btnm pointer to button matrix object
* @param id index of the currently pressed button (`LV_BTNM_BTN_NONE` to unpress)
* @param id index of the currently pressed button (`LV_BTNMATRIX_BTN_NONE` to unpress)
*/
void lv_btnm_set_pressed(const lv_obj_t * btnm, uint16_t id)
void lv_btnmatrix_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_btnmatrix_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_BTNMATRIX_BTN_NONE) return;
if(id == ext->btn_id_pr) return;
@ -305,11 +305,11 @@ void lv_btnm_set_pressed(const lv_obj_t * btnm, uint16_t id)
* @param btnm pointer to button matrix object
* @param en true: enable recoloring; false: disable
*/
void lv_btnm_set_recolor(const lv_obj_t * btnm, bool en)
void lv_btnmatrix_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_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
ext->recolor = en;
lv_obj_invalidate(btnm);
@ -320,11 +320,11 @@ void lv_btnm_set_recolor(const lv_obj_t * btnm, bool en)
* @param btnm pointer to button matrix object
* @param btn_id 0 based index of the button to modify. (Not counting new lines)
*/
void lv_btnm_set_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl)
void lv_btnmatrix_set_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl)
{
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
if(btn_id >= ext->btn_cnt) return;
@ -337,11 +337,11 @@ void lv_btnm_set_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t
* @param btnm pointer to button matrix object
* @param btn_id 0 based index of the button to modify. (Not counting new lines)
*/
void lv_btnm_clear_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl)
void lv_btnmatrix_clear_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl)
{
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
if(btn_id >= ext->btn_cnt) return;
@ -352,33 +352,33 @@ void lv_btnm_clear_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl
/**
* Set the attributes of all buttons of a button matrix
* @param btnm pointer to a button matrix object
* @param ctrl attribute(s) to set from `lv_btnm_ctrl_t`. Values can be ORed.
* @param ctrl attribute(s) to set from `lv_btnmatrix_ctrl_t`. Values can be ORed.
*/
void lv_btnm_set_btn_ctrl_all(lv_obj_t * btnm, lv_btnm_ctrl_t ctrl)
void lv_btnmatrix_set_btn_ctrl_all(lv_obj_t * btnm, lv_btnmatrix_ctrl_t ctrl)
{
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
uint16_t i;
for(i = 0; i < ext->btn_cnt; i++) {
lv_btnm_set_btn_ctrl(btnm, i, ctrl);
lv_btnmatrix_set_btn_ctrl(btnm, i, ctrl);
}
}
/**
* Clear the attributes of all buttons of a button matrix
* @param btnm pointer to a button matrix object
* @param ctrl attribute(s) to set from `lv_btnm_ctrl_t`. Values can be ORed.
* @param ctrl attribute(s) to set from `lv_btnmatrix_ctrl_t`. Values can be ORed.
* @param en true: set the attributes; false: clear the attributes
*/
void lv_btnm_clear_btn_ctrl_all(lv_obj_t * btnm, lv_btnm_ctrl_t ctrl)
void lv_btnmatrix_clear_btn_ctrl_all(lv_obj_t * btnm, lv_btnmatrix_ctrl_t ctrl)
{
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
uint16_t i;
for(i = 0; i < ext->btn_cnt; i++) {
lv_btnm_clear_btn_ctrl(btnm, i, ctrl);
lv_btnmatrix_clear_btn_ctrl(btnm, i, ctrl);
}
}
@ -386,38 +386,38 @@ void lv_btnm_clear_btn_ctrl_all(lv_obj_t * btnm, lv_btnm_ctrl_t ctrl)
* Set a single buttons relative width.
* This method will cause the matrix be regenerated and is a relatively
* expensive operation. It is recommended that initial width be specified using
* `lv_btnm_set_ctrl_map` and this method only be used for dynamic changes.
* `lv_btnmatrix_set_ctrl_map` and this method only be used for dynamic changes.
* @param btnm pointer to button matrix object
* @param btn_id 0 based index of the button to modify.
* @param width Relative width compared to the buttons in the same row. [1..7]
*/
void lv_btnm_set_btn_width(const lv_obj_t * btnm, uint16_t btn_id, uint8_t width)
void lv_btnmatrix_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_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
if(btn_id >= ext->btn_cnt) return;
ext->ctrl_bits[btn_id] &= (~LV_BTNM_WIDTH_MASK);
ext->ctrl_bits[btn_id] |= (LV_BTNM_WIDTH_MASK & width);
ext->ctrl_bits[btn_id] &= (~LV_BTNMATRIX_WIDTH_MASK);
ext->ctrl_bits[btn_id] |= (LV_BTNMATRIX_WIDTH_MASK & width);
lv_btnm_set_map(btnm, ext->map_p);
lv_btnmatrix_set_map(btnm, ext->map_p);
}
/**
* Make the button matrix like a selector widget (only one button may be toggled at a time).
*
* Toggling must be enabled on the buttons you want to be selected with `lv_btnm_set_ctrl` or
* `lv_btnm_set_btn_ctrl_all`.
* Toggling must be enabled on the buttons you want to be selected with `lv_btnmatrix_set_ctrl` or
* `lv_btnmatrix_set_btn_ctrl_all`.
*
* @param btnm Button matrix object
* @param one_toggle Whether "one toggle" mode is enabled
*/
void lv_btnm_set_one_toggle(lv_obj_t * btnm, bool one_toggle)
void lv_btnmatrix_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_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
ext->one_toggle = one_toggle;
/*If more than one button is toggled only the first one should be*/
@ -433,11 +433,11 @@ void lv_btnm_set_one_toggle(lv_obj_t * btnm, bool one_toggle)
* @param btnm pointer to a button matrix object
* @return the current map
*/
const char ** lv_btnm_get_map_array(const lv_obj_t * btnm)
const char ** lv_btnmatrix_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_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
return ext->map_p;
}
@ -446,11 +446,11 @@ const char ** lv_btnm_get_map_array(const lv_obj_t * btnm)
* @param btnm pointer to button matrix object
* @return true: text recolor enable; false: disabled
*/
bool lv_btnm_get_recolor(const lv_obj_t * btnm)
bool lv_btnmatrix_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_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
return ext->recolor;
}
@ -459,13 +459,13 @@ bool lv_btnm_get_recolor(const lv_obj_t * btnm)
* Get the index of the lastly "activated" button by the user (pressed, released etc)
* Useful in the the `event_cb` to get the text of the button, check if hidden etc.
* @param btnm pointer to button matrix object
* @return index of the last released button (LV_BTNM_BTN_NONE: if unset)
* @return index of the last released button (LV_BTNMATRIX_BTN_NONE: if unset)
*/
uint16_t lv_btnm_get_active_btn(const lv_obj_t * btnm)
uint16_t lv_btnmatrix_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_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
return ext->btn_id_act;
}
@ -475,13 +475,13 @@ uint16_t lv_btnm_get_active_btn(const lv_obj_t * btnm)
* @param btnm pointer to button matrix object
* @return text of the last released button (NULL: if unset)
*/
const char * lv_btnm_get_active_btn_text(const lv_obj_t * btnm)
const char * lv_btnmatrix_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);
if(ext->btn_id_act != LV_BTNM_BTN_NONE) {
return lv_btnm_get_btn_text(btnm, ext->btn_id_act);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
if(ext->btn_id_act != LV_BTNMATRIX_BTN_NONE) {
return lv_btnmatrix_get_btn_text(btnm, ext->btn_id_act);
} else {
return NULL;
}
@ -489,15 +489,15 @@ const char * lv_btnm_get_active_btn_text(const lv_obj_t * btnm)
/**
* Get the pressed button's index.
* The button be really pressed by the user or manually set to pressed with `lv_btnm_set_pressed`
* The button be really pressed by the user or manually set to pressed with `lv_btnmatrix_set_pressed`
* @param btnm pointer to button matrix object
* @return index of the pressed button (LV_BTNM_BTN_NONE: if unset)
* @return index of the pressed button (LV_BTNMATRIX_BTN_NONE: if unset)
*/
uint16_t lv_btnm_get_pressed_btn(const lv_obj_t * btnm)
uint16_t lv_btnmatrix_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_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
return ext->btn_id_pr;
}
@ -505,14 +505,14 @@ uint16_t lv_btnm_get_pressed_btn(const lv_obj_t * btnm)
* Get the button's text
* @param btnm pointer to button matrix object
* @param btn_id the index a button not counting new line characters. (The return value of
* lv_btnm_get_pressed/released)
* lv_btnmatrix_get_pressed/released)
* @return text of btn_index` button
*/
const char * lv_btnm_get_btn_text(const lv_obj_t * btnm, uint16_t btn_id)
const char * lv_btnmatrix_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_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
if(btn_id > ext->btn_cnt) return NULL;
uint16_t txt_i = 0;
@ -535,15 +535,15 @@ const char * lv_btnm_get_btn_text(const lv_obj_t * btnm, uint16_t btn_id)
* Get the whether a control value is enabled or disabled for button of a button matrix
* @param btnm pointer to a button matrix object
* @param btn_id the index a button not counting new line characters. (E.g. the return value of
* lv_btnm_get_pressed/released)
* lv_btnmatrix_get_pressed/released)
* @param ctrl control values to check (ORed value can be used)
* @return true: long press repeat is disabled; false: long press repeat enabled
*/
bool lv_btnm_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl)
bool lv_btnmatrix_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl)
{
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
if(btn_id >= ext->btn_cnt) return false;
return ext->ctrl_bits[btn_id] & ctrl ? true : false;
@ -555,11 +555,11 @@ bool lv_btnm_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl)
* @param btnm Button matrix object
* @return whether "one toggle" mode is enabled
*/
bool lv_btnm_get_one_toggle(const lv_obj_t * btnm)
bool lv_btnmatrix_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_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
return ext->one_toggle;
}
@ -578,7 +578,7 @@ bool lv_btnm_get_one_toggle(const lv_obj_t * btnm)
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
* @param return an element of `lv_design_res_t`
*/
static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_area, lv_design_mode_t mode)
static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * clip_area, lv_design_mode_t mode)
{
if(mode == LV_DESIGN_COVER_CHK) {
return ancestor_design_f(btnm, clip_area, mode);
@ -587,7 +587,7 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
else if(mode == LV_DESIGN_DRAW_MAIN) {
ancestor_design_f(btnm, clip_area, mode);
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
if(ext->btn_cnt == 0) return LV_DESIGN_RES_OK;
lv_area_t area_btnm;
lv_obj_get_coords(btnm, &area_btnm);
@ -620,16 +620,16 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
btnm->state_dsc.prev = btnm->state_dsc.act;
lv_draw_rect_dsc_init(&draw_rect_rel_dsc);
lv_draw_label_dsc_init(&draw_label_rel_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNM_PART_BTN, &draw_rect_rel_dsc);
lv_obj_init_draw_label_dsc(btnm, LV_BTNM_PART_BTN, &draw_label_rel_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_rel_dsc);
lv_obj_init_draw_label_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_label_rel_dsc);
draw_label_rel_dsc.flag = txt_flag;
btnm->state_dsc = state_ori;
bool chk_inited = false;
bool disabled_inited = false;
lv_style_int_t padding_top = lv_obj_get_style_pad_top(btnm, LV_BTNM_PART_BG);
lv_style_int_t padding_bottom = lv_obj_get_style_pad_bottom(btnm, LV_BTNM_PART_BG);
lv_style_int_t padding_top = lv_obj_get_style_pad_top(btnm, LV_BTNMATRIX_PART_BG);
lv_style_int_t padding_bottom = lv_obj_get_style_pad_bottom(btnm, LV_BTNMATRIX_PART_BG);
for(btn_i = 0; btn_i < ext->btn_cnt; btn_i++, txt_i++) {
/*Search the next valid text in the map*/
@ -660,8 +660,8 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
btnm->state_dsc.prev = btnm->state_dsc.act;
lv_draw_rect_dsc_init(&draw_rect_chk_dsc);
lv_draw_label_dsc_init(&draw_label_chk_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNM_PART_BTN, &draw_rect_chk_dsc);
lv_obj_init_draw_label_dsc(btnm, LV_BTNM_PART_BTN, &draw_label_chk_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_chk_dsc);
lv_obj_init_draw_label_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_label_chk_dsc);
draw_label_chk_dsc.flag = txt_flag;
btnm->state_dsc = state_ori;
chk_inited = true;
@ -674,8 +674,8 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
btnm->state_dsc.prev = btnm->state_dsc.act;
lv_draw_rect_dsc_init(&draw_rect_ina_dsc);
lv_draw_label_dsc_init(&draw_label_ina_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNM_PART_BTN, &draw_rect_ina_dsc);
lv_obj_init_draw_label_dsc(btnm, LV_BTNM_PART_BTN, &draw_label_ina_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_ina_dsc);
lv_obj_init_draw_label_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_label_ina_dsc);
draw_label_ina_dsc.flag = txt_flag;
btnm->state_dsc = state_ori;
disabled_inited = true;
@ -698,8 +698,8 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
lv_draw_rect_dsc_init(&draw_rect_tmp_dsc);
lv_draw_label_dsc_init(&draw_label_tmp_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNM_PART_BTN, &draw_rect_tmp_dsc);
lv_obj_init_draw_label_dsc(btnm, LV_BTNM_PART_BTN, &draw_label_tmp_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_tmp_dsc);
lv_obj_init_draw_label_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_label_tmp_dsc);
draw_label_tmp_dsc.flag = txt_flag;
draw_rect_dsc_act = &draw_rect_tmp_dsc;
draw_label_dsc_act = &draw_label_tmp_dsc;
@ -764,12 +764,12 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
{
lv_res_t res;
if(sign == LV_SIGNAL_GET_STYLE) {
lv_get_style_info_t * info = param;
info->result = lv_btnm_get_style(btnm, info->part);
info->result = lv_btnmatrix_get_style(btnm, info->part);
if(info->result != NULL) return LV_RES_OK;
else return ancestor_signal(btnm, sign, param);
}
@ -779,16 +779,16 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
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_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_point_t p;
if(sign == LV_SIGNAL_CLEANUP) {
lv_mem_free(ext->button_areas);
lv_mem_free(ext->ctrl_bits);
} else if(sign == LV_SIGNAL_STYLE_CHG) {
lv_btnm_set_map(btnm, ext->map_p);
lv_btnmatrix_set_map(btnm, ext->map_p);
} else if(sign == LV_SIGNAL_COORD_CHG) {
if(lv_obj_get_width(btnm) != lv_area_get_width(param) || lv_obj_get_height(btnm) != lv_area_get_height(param)) {
lv_btnm_set_map(btnm, ext->map_p);
lv_btnmatrix_set_map(btnm, ext->map_p);
}
} else if(sign == LV_SIGNAL_PRESSED) {
invalidate_button_area(btnm, ext->btn_id_pr);
@ -811,7 +811,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
invalidate_button_area(btnm, ext->btn_id_focused);
}
if(ext->btn_id_act != LV_BTNM_BTN_NONE) {
if(ext->btn_id_act != LV_BTNMATRIX_BTN_NONE) {
if(button_is_click_trig(ext->ctrl_bits[ext->btn_id_act]) == false &&
button_is_inactive(ext->ctrl_bits[ext->btn_id_act]) == false &&
button_is_hidden(ext->ctrl_bits[ext->btn_id_act]) == false) {
@ -829,10 +829,10 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
button_is_inactive(ext->ctrl_bits[btn_pr]) == false &&
button_is_hidden(ext->ctrl_bits[btn_pr]) == false) {
lv_indev_reset_long_press(param); /*Start the log press time again on the new button*/
if(ext->btn_id_pr != LV_BTNM_BTN_NONE) {
if(ext->btn_id_pr != LV_BTNMATRIX_BTN_NONE) {
invalidate_button_area(btnm, ext->btn_id_pr);
}
if(btn_pr != LV_BTNM_BTN_NONE) {
if(btn_pr != LV_BTNMATRIX_BTN_NONE) {
uint32_t b = ext->btn_id_act;
res = lv_event_send(btnm, LV_EVENT_VALUE_CHANGED, &b);
if(res == LV_RES_OK) {
@ -844,14 +844,14 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
ext->btn_id_pr = btn_pr;
ext->btn_id_act = btn_pr;
} else if(sign == LV_SIGNAL_RELEASED) {
if(ext->btn_id_pr != LV_BTNM_BTN_NONE) {
if(ext->btn_id_pr != LV_BTNMATRIX_BTN_NONE) {
/*Toggle the button if enabled*/
if(button_is_tgl_enabled(ext->ctrl_bits[ext->btn_id_pr]) &&
!button_is_inactive(ext->ctrl_bits[ext->btn_id_pr])) {
if(button_get_tgl_state(ext->ctrl_bits[ext->btn_id_pr])) {
ext->ctrl_bits[ext->btn_id_pr] &= (~LV_BTNM_CTRL_CHECHK_STATE);
ext->ctrl_bits[ext->btn_id_pr] &= (~LV_BTNMATRIX_CTRL_CHECHK_STATE);
} else {
ext->ctrl_bits[ext->btn_id_pr] |= LV_BTNM_CTRL_CHECHK_STATE;
ext->ctrl_bits[ext->btn_id_pr] |= LV_BTNMATRIX_CTRL_CHECHK_STATE;
}
if(ext->one_toggle) make_one_button_toggled(btnm, ext->btn_id_pr);
}
@ -866,7 +866,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
ext->btn_id_focused = ext->btn_id_pr;
}
ext->btn_id_pr = LV_BTNM_BTN_NONE;
ext->btn_id_pr = LV_BTNMATRIX_BTN_NONE;
if(button_is_click_trig(ext->ctrl_bits[ext->btn_id_act]) == true &&
button_is_inactive(ext->ctrl_bits[ext->btn_id_act]) == false &&
@ -876,7 +876,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
}
}
} else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
if(ext->btn_id_act != LV_BTNM_BTN_NONE) {
if(ext->btn_id_act != LV_BTNMATRIX_BTN_NONE) {
if(button_is_repeat_disabled(ext->ctrl_bits[ext->btn_id_act]) == false &&
button_is_inactive(ext->ctrl_bits[ext->btn_id_act]) == false &&
button_is_hidden(ext->ctrl_bits[ext->btn_id_act]) == false) {
@ -885,8 +885,8 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
}
}
} else if(sign == LV_SIGNAL_PRESS_LOST) {
ext->btn_id_pr = LV_BTNM_BTN_NONE;
ext->btn_id_act = LV_BTNM_BTN_NONE;
ext->btn_id_pr = LV_BTNMATRIX_BTN_NONE;
ext->btn_id_act = LV_BTNMATRIX_BTN_NONE;
lv_obj_invalidate(btnm);
} else if(sign == LV_SIGNAL_FOCUS) {
#if LV_USE_GROUP
@ -904,7 +904,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
if(lv_group_get_editing(lv_obj_get_group(btnm))) {
ext->btn_id_focused = 0;
} else {
ext->btn_id_focused = LV_BTNM_BTN_NONE;
ext->btn_id_focused = LV_BTNMATRIX_BTN_NONE;
}
} else if (indev_type == LV_INDEV_TYPE_KEYPAD) {
ext->btn_id_focused = 0;
@ -914,15 +914,15 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
#endif
}
else if(sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_LEAVE) {
if(ext->btn_id_focused != LV_BTNM_BTN_NONE) invalidate_button_area(btnm, ext->btn_id_focused);
if(ext->btn_id_pr != LV_BTNM_BTN_NONE) invalidate_button_area(btnm, ext->btn_id_pr);
ext->btn_id_focused = LV_BTNM_BTN_NONE;
ext->btn_id_pr = LV_BTNM_BTN_NONE;
ext->btn_id_act = LV_BTNM_BTN_NONE;
if(ext->btn_id_focused != LV_BTNMATRIX_BTN_NONE) invalidate_button_area(btnm, ext->btn_id_focused);
if(ext->btn_id_pr != LV_BTNMATRIX_BTN_NONE) invalidate_button_area(btnm, ext->btn_id_pr);
ext->btn_id_focused = LV_BTNMATRIX_BTN_NONE;
ext->btn_id_pr = LV_BTNMATRIX_BTN_NONE;
ext->btn_id_act = LV_BTNMATRIX_BTN_NONE;
} else if(sign == LV_SIGNAL_CONTROL) {
char c = *((char *)param);
if(c == LV_KEY_RIGHT) {
if(ext->btn_id_focused == LV_BTNM_BTN_NONE)
if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE)
ext->btn_id_focused = 0;
else
ext->btn_id_focused++;
@ -930,14 +930,14 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
ext->btn_id_act = ext->btn_id_focused;
lv_obj_invalidate(btnm);
} else if(c == LV_KEY_LEFT) {
if(ext->btn_id_focused == LV_BTNM_BTN_NONE) ext->btn_id_focused = 0;
if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE) ext->btn_id_focused = 0;
if(ext->btn_id_focused > 0) ext->btn_id_focused--;
ext->btn_id_act = ext->btn_id_focused;
lv_obj_invalidate(btnm);
} else if(c == LV_KEY_DOWN) {
lv_style_int_t pad_inner = lv_obj_get_style_pad_inner(btnm, LV_BTNM_PART_BG);
lv_style_int_t pad_inner = lv_obj_get_style_pad_inner(btnm, LV_BTNMATRIX_PART_BG);
/*Find the area below the the current*/
if(ext->btn_id_focused == LV_BTNM_BTN_NONE) {
if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE) {
ext->btn_id_focused = 0;
} else {
uint16_t area_below;
@ -959,9 +959,9 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
ext->btn_id_act = ext->btn_id_focused;
lv_obj_invalidate(btnm);
} else if(c == LV_KEY_UP) {
lv_style_int_t pad_inner = lv_obj_get_style_pad_inner(btnm, LV_BTNM_PART_BG);
lv_style_int_t pad_inner = lv_obj_get_style_pad_inner(btnm, LV_BTNMATRIX_PART_BG);
/*Find the area below the the current*/
if(ext->btn_id_focused == LV_BTNM_BTN_NONE) {
if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE) {
ext->btn_id_focused = 0;
} else {
int16_t area_above;
@ -992,22 +992,22 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
/**
* Get the style descriptor of a part of the object
* @param btnm pointer the object
* @param part the part of the object. (LV_BTNM_PART_...)
* @param part the part of the object. (LV_BTNMATRIX_PART_...)
* @return pointer to the style descriptor of the specified part
*/
static lv_style_list_t * lv_btnm_get_style(lv_obj_t * btnm, uint8_t part)
static lv_style_list_t * lv_btnmatrix_get_style(lv_obj_t * btnm, uint8_t part)
{
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_style_list_t * style_dsc_p;
switch(part) {
case LV_BTNM_PART_BG:
case LV_BTNMATRIX_PART_BG:
style_dsc_p = &btnm->style_list;
break;
case LV_BTNM_PART_BTN:
case LV_BTNMATRIX_PART_BTN:
style_dsc_p = &ext->style_btn;
break;
default:
@ -1034,7 +1034,7 @@ static void allocate_btn_areas_and_controls(const lv_obj_t * btnm, const char **
i++;
}
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
if(ext->button_areas != NULL) {
lv_mem_free(ext->button_areas);
@ -1047,11 +1047,11 @@ 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);
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_btnmatrix_ctrl_t) * btn_cnt);
LV_ASSERT_MEM(ext->ctrl_bits);
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_btnmatrix_ctrl_t) * btn_cnt);
ext->btn_cnt = btn_cnt;
}
@ -1061,53 +1061,53 @@ static void allocate_btn_areas_and_controls(const lv_obj_t * btnm, const char **
* @param ctrl_bits least significant 3 bits used (1..7 valid values)
* @return the width of the button in units
*/
static uint8_t get_button_width(lv_btnm_ctrl_t ctrl_bits)
static uint8_t get_button_width(lv_btnmatrix_ctrl_t ctrl_bits)
{
uint8_t w = ctrl_bits & LV_BTNM_WIDTH_MASK;
uint8_t w = ctrl_bits & LV_BTNMATRIX_WIDTH_MASK;
return w != 0 ? w : 1;
}
static bool button_is_hidden(lv_btnm_ctrl_t ctrl_bits)
static bool button_is_hidden(lv_btnmatrix_ctrl_t ctrl_bits)
{
return ctrl_bits & LV_BTNM_CTRL_HIDDEN ? true : false;
return ctrl_bits & LV_BTNMATRIX_CTRL_HIDDEN ? true : false;
}
static bool button_is_repeat_disabled(lv_btnm_ctrl_t ctrl_bits)
static bool button_is_repeat_disabled(lv_btnmatrix_ctrl_t ctrl_bits)
{
return ctrl_bits & LV_BTNM_CTRL_NO_REPEAT ? true : false;
return ctrl_bits & LV_BTNMATRIX_CTRL_NO_REPEAT ? true : false;
}
static bool button_is_inactive(lv_btnm_ctrl_t ctrl_bits)
static bool button_is_inactive(lv_btnmatrix_ctrl_t ctrl_bits)
{
return ctrl_bits & LV_BTNM_CTRL_INACTIVE ? true : false;
return ctrl_bits & LV_BTNMATRIX_CTRL_INACTIVE ? true : false;
}
static bool button_is_click_trig(lv_btnm_ctrl_t ctrl_bits)
static bool button_is_click_trig(lv_btnmatrix_ctrl_t ctrl_bits)
{
return ctrl_bits & LV_BTNM_CTRL_CLICK_TRIG ? true : false;
return ctrl_bits & LV_BTNMATRIX_CTRL_CLICK_TRIG ? true : false;
}
static bool button_is_tgl_enabled(lv_btnm_ctrl_t ctrl_bits)
static bool button_is_tgl_enabled(lv_btnmatrix_ctrl_t ctrl_bits)
{
return ctrl_bits & LV_BTNM_CTRL_CHECKABLE ? true : false;
return ctrl_bits & LV_BTNMATRIX_CTRL_CHECKABLE ? true : false;
}
static bool button_get_tgl_state(lv_btnm_ctrl_t ctrl_bits)
static bool button_get_tgl_state(lv_btnmatrix_ctrl_t ctrl_bits)
{
return ctrl_bits & LV_BTNM_CTRL_CHECHK_STATE ? true : false;
return ctrl_bits & LV_BTNMATRIX_CTRL_CHECHK_STATE ? true : false;
}
/**
* Gives the button id of a button under a given point
* @param btnm pointer to a button matrix object
* @param p a point with absolute coordinates
* @return the id of the button or LV_BTNM_BTN_NONE.
* @return the id of the button or LV_BTNMATRIX_BTN_NONE.
*/
static uint16_t get_button_from_point(lv_obj_t * btnm, lv_point_t * p)
{
lv_area_t btnm_cords;
lv_area_t btn_area;
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
uint16_t i;
lv_obj_get_coords(btnm, &btnm_cords);
@ -1122,19 +1122,19 @@ static uint16_t get_button_from_point(lv_obj_t * btnm, lv_point_t * p)
}
}
if(i == ext->btn_cnt) i = LV_BTNM_BTN_NONE;
if(i == ext->btn_cnt) i = LV_BTNMATRIX_BTN_NONE;
return i;
}
static void invalidate_button_area(const lv_obj_t * btnm, uint16_t btn_idx)
{
if(btn_idx == LV_BTNM_BTN_NONE) return;
if(btn_idx == LV_BTNMATRIX_BTN_NONE) return;
lv_area_t btn_area;
lv_area_t btnm_area;
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_area_copy(&btn_area, &ext->button_areas[btn_idx]);
lv_obj_get_coords(btnm, &btnm_area);
@ -1175,11 +1175,11 @@ static bool maps_are_identical(const char ** map1, const char ** map2)
static void make_one_button_toggled(lv_obj_t * btnm, uint16_t btn_idx)
{
/*Save whether the button was toggled*/
bool was_toggled = lv_btnm_get_btn_ctrl(btnm, btn_idx, LV_BTNM_CTRL_CHECHK_STATE);
bool was_toggled = lv_btnmatrix_get_btn_ctrl(btnm, btn_idx, LV_BTNMATRIX_CTRL_CHECHK_STATE);
lv_btnm_clear_btn_ctrl_all(btnm, LV_BTNM_CTRL_CHECHK_STATE);
lv_btnmatrix_clear_btn_ctrl_all(btnm, LV_BTNMATRIX_CTRL_CHECHK_STATE);
if(was_toggled) lv_btnm_set_btn_ctrl(btnm, btn_idx, LV_BTNM_CTRL_CHECHK_STATE);
if(was_toggled) lv_btnmatrix_set_btn_ctrl(btnm, btn_idx, LV_BTNMATRIX_CTRL_CHECHK_STATE);
}
#endif

View File

@ -3,8 +3,8 @@
*
*/
#ifndef LV_BTNM_H
#define LV_BTNM_H
#ifndef LV_BTNMATRIX_H
#define LV_BTNMATRIX_H
#ifdef __cplusplus
extern "C" {
@ -15,7 +15,7 @@ extern "C" {
*********************/
#include "../lv_conf_internal.h"
#if LV_USE_BTNM != 0
#if LV_USE_BTNMATRIX != 0
#include "../lv_core/lv_obj.h"
#include "lv_label.h"
@ -24,10 +24,10 @@ extern "C" {
/*********************
* DEFINES
*********************/
#define LV_BTNM_WIDTH_MASK 0x0007
#define LV_BTNM_BTN_NONE 0xFFFF
#define LV_BTNMATRIX_WIDTH_MASK 0x0007
#define LV_BTNMATRIX_BTN_NONE 0xFFFF
LV_EXPORT_CONST_INT(LV_BTNM_BTN_NONE);
LV_EXPORT_CONST_INT(LV_BTNMATRIX_BTN_NONE);
/**********************
* TYPEDEFS
@ -36,14 +36,14 @@ LV_EXPORT_CONST_INT(LV_BTNM_BTN_NONE);
/** Type to store button control bits (disabled, hidden etc.)
* The first 3 bits are used to store the width */
enum {
LV_BTNM_CTRL_HIDDEN = 0x0008, /**< Button hidden */
LV_BTNM_CTRL_NO_REPEAT = 0x0010, /**< Do not repeat press this button. */
LV_BTNM_CTRL_INACTIVE = 0x0020, /**< Disable this button. */
LV_BTNM_CTRL_CHECKABLE = 0x0040, /**< Button *can* be toggled. */
LV_BTNM_CTRL_CHECHK_STATE = 0x0080, /**< Button is currently toggled (e.g. checked). */
LV_BTNM_CTRL_CLICK_TRIG = 0x0100, /**< 1: Send LV_EVENT_SELECTED on CLICK, 0: Send LV_EVENT_SELECTED on PRESS*/
LV_BTNMATRIX_CTRL_HIDDEN = 0x0008, /**< Button hidden */
LV_BTNMATRIX_CTRL_NO_REPEAT = 0x0010, /**< Do not repeat press this button. */
LV_BTNMATRIX_CTRL_INACTIVE = 0x0020, /**< Disable this button. */
LV_BTNMATRIX_CTRL_CHECKABLE = 0x0040, /**< Button *can* be toggled. */
LV_BTNMATRIX_CTRL_CHECHK_STATE = 0x0080, /**< Button is currently toggled (e.g. checked). */
LV_BTNMATRIX_CTRL_CLICK_TRIG = 0x0100, /**< 1: Send LV_EVENT_SELECTED on CLICK, 0: Send LV_EVENT_SELECTED on PRESS*/
};
typedef uint16_t lv_btnm_ctrl_t;
typedef uint16_t lv_btnmatrix_ctrl_t;
/*Data of button matrix*/
typedef struct
@ -52,21 +52,21 @@ typedef struct
/*New data for this type */
const char ** map_p; /*Pointer to the current map*/
lv_area_t * button_areas; /*Array of areas of buttons*/
lv_btnm_ctrl_t * ctrl_bits; /*Array of control bytes*/
lv_btnmatrix_ctrl_t * ctrl_bits; /*Array of control bytes*/
lv_style_list_t style_btn; /*Styles of buttons in each state*/
uint16_t btn_cnt; /*Number of button in 'map_p'(Handled by the library)*/
uint16_t btn_id_pr; /*Index of the currently pressed button or LV_BTNM_BTN_NONE*/
uint16_t btn_id_focused; /*Index of the currently focused button or LV_BTNM_BTN_NONE*/
uint16_t btn_id_act; /*Index of the active button (being pressed/released etc) or LV_BTNM_BTN_NONE */
uint16_t btn_id_pr; /*Index of the currently pressed button or LV_BTNMATRIX_BTN_NONE*/
uint16_t btn_id_focused; /*Index of the currently focused button or LV_BTNMATRIX_BTN_NONE*/
uint16_t btn_id_act; /*Index of the active button (being pressed/released etc) or LV_BTNMATRIX_BTN_NONE */
uint8_t recolor : 1; /*Enable button recoloring*/
uint8_t one_toggle : 1; /*Single button toggled at once*/
} lv_btnm_ext_t;
} lv_btnmatrix_ext_t;
enum {
LV_BTNM_PART_BG,
LV_BTNM_PART_BTN,
LV_BTNMATRIX_PART_BG,
LV_BTNMATRIX_PART_BTN,
};
typedef uint8_t lv_btnm_part_t;
typedef uint8_t lv_btnmatrix_part_t;
/**********************
* GLOBAL PROTOTYPES
@ -79,7 +79,7 @@ typedef uint8_t lv_btnm_part_t;
* from it
* @return pointer to the created button matrix
*/
lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy);
lv_obj_t * lv_btnmatrix_create(lv_obj_t * par, const lv_obj_t * copy);
/*=====================
* Setter functions
@ -92,7 +92,7 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy);
* @param btnm pointer to a button matrix object
* @param map pointer a string array. The last string has to be: "". Use "\n" to make a line break.
*/
void lv_btnm_set_map(lv_obj_t * btnm, const char * map[]);
void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[]);
/**
* Set the button control map (hidden, disabled etc.) for a button matrix. The
@ -104,17 +104,17 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char * map[]);
* the number and order of the individual buttons (i.e. excludes
* newline entries).
* An element of the map should look like e.g.:
* `ctrl_map[0] = width | LV_BTNM_CTRL_NO_REPEAT | LV_BTNM_CTRL_TGL_ENABLE`
* `ctrl_map[0] = width | LV_BTNMATRIX_CTRL_NO_REPEAT | LV_BTNMATRIX_CTRL_TGL_ENABLE`
*/
void lv_btnm_set_ctrl_map(const lv_obj_t * btnm, const lv_btnm_ctrl_t ctrl_map[]);
void lv_btnmatrix_set_ctrl_map(const lv_obj_t * btnm, const lv_btnmatrix_ctrl_t ctrl_map[]);
/**
* Set the pressed button i.e. visually highlight it.
* Mainly used a when the btnm is in a group to show the selected button
* @param btnm pointer to button matrix object
* @param id index of the currently pressed button (`LV_BTNM_BTN_NONE` to unpress)
* @param id index of the currently pressed button (`LV_BTNMATRIX_BTN_NONE` to unpress)
*/
void lv_btnm_set_pressed(const lv_obj_t * btnm, uint16_t id);
void lv_btnmatrix_set_pressed(const lv_obj_t * btnm, uint16_t id);
/**
* Set a style of a button matrix
@ -122,65 +122,65 @@ void lv_btnm_set_pressed(const lv_obj_t * btnm, uint16_t id);
* @param type which style should be set
* @param style pointer to a style
*/
void lv_btnm_set_style(lv_obj_t * btnm, lv_btnm_part_t type, const lv_style_t * style);
void lv_btnmatrix_set_style(lv_obj_t * btnm, lv_btnmatrix_part_t type, const lv_style_t * style);
/**
* Enable recoloring of button's texts
* @param btnm pointer to button matrix object
* @param en true: enable recoloring; false: disable
*/
void lv_btnm_set_recolor(const lv_obj_t * btnm, bool en);
void lv_btnmatrix_set_recolor(const lv_obj_t * btnm, bool en);
/**
* Set the attributes of a button of the button matrix
* @param btnm pointer to button matrix object
* @param btn_id 0 based index of the button to modify. (Not counting new lines)
*/
void lv_btnm_set_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl);
void lv_btnmatrix_set_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl);
/**
* Clear the attributes of a button of the button matrix
* @param btnm pointer to button matrix object
* @param btn_id 0 based index of the button to modify. (Not counting new lines)
*/
void lv_btnm_clear_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl);
void lv_btnmatrix_clear_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl);
/**
* Set the attributes of all buttons of a button matrix
* @param btnm pointer to a button matrix object
* @param ctrl attribute(s) to set from `lv_btnm_ctrl_t`. Values can be ORed.
* @param ctrl attribute(s) to set from `lv_btnmatrix_ctrl_t`. Values can be ORed.
*/
void lv_btnm_set_btn_ctrl_all(lv_obj_t * btnm, lv_btnm_ctrl_t ctrl);
void lv_btnmatrix_set_btn_ctrl_all(lv_obj_t * btnm, lv_btnmatrix_ctrl_t ctrl);
/**
* Clear the attributes of all buttons of a button matrix
* @param btnm pointer to a button matrix object
* @param ctrl attribute(s) to set from `lv_btnm_ctrl_t`. Values can be ORed.
* @param ctrl attribute(s) to set from `lv_btnmatrix_ctrl_t`. Values can be ORed.
* @param en true: set the attributes; false: clear the attributes
*/
void lv_btnm_clear_btn_ctrl_all(lv_obj_t * btnm, lv_btnm_ctrl_t ctrl);
void lv_btnmatrix_clear_btn_ctrl_all(lv_obj_t * btnm, lv_btnmatrix_ctrl_t ctrl);
/**
* Set a single buttons relative width.
* This method will cause the matrix be regenerated and is a relatively
* expensive operation. It is recommended that initial width be specified using
* `lv_btnm_set_ctrl_map` and this method only be used for dynamic changes.
* `lv_btnmatrix_set_ctrl_map` and this method only be used for dynamic changes.
* @param btnm pointer to button matrix object
* @param btn_id 0 based index of the button to modify.
* @param width Relative width compared to the buttons in the same row. [1..7]
*/
void lv_btnm_set_btn_width(const lv_obj_t * btnm, uint16_t btn_id, uint8_t width);
void lv_btnmatrix_set_btn_width(const lv_obj_t * btnm, uint16_t btn_id, uint8_t width);
/**
* Make the button matrix like a selector widget (only one button may be toggled at a time).
*
* Toggling must be enabled on the buttons you want to be selected with `lv_btnm_set_ctrl` or
* `lv_btnm_set_btn_ctrl_all`.
* Toggling must be enabled on the buttons you want to be selected with `lv_btnmatrix_set_ctrl` or
* `lv_btnmatrix_set_btn_ctrl_all`.
*
* @param btnm Button matrix object
* @param one_toggle Whether "one toggle" mode is enabled
*/
void lv_btnm_set_one_toggle(lv_obj_t * btnm, bool one_toggle);
void lv_btnmatrix_set_one_toggle(lv_obj_t * btnm, bool one_toggle);
/*=====================
* Getter functions
@ -191,22 +191,22 @@ void lv_btnm_set_one_toggle(lv_obj_t * btnm, bool one_toggle);
* @param btnm pointer to a button matrix object
* @return the current map
*/
const char ** lv_btnm_get_map_array(const lv_obj_t * btnm);
const char ** lv_btnmatrix_get_map_array(const lv_obj_t * btnm);
/**
* Check whether the button's text can use recolor or not
* @param btnm pointer to button matrix object
* @return true: text recolor enable; false: disabled
*/
bool lv_btnm_get_recolor(const lv_obj_t * btnm);
bool lv_btnmatrix_get_recolor(const lv_obj_t * btnm);
/**
* Get the index of the lastly "activated" button by the user (pressed, released etc)
* Useful in the the `event_cb` to get the text of the button, check if hidden etc.
* @param btnm pointer to button matrix object
* @return index of the last released button (LV_BTNM_BTN_NONE: if unset)
* @return index of the last released button (LV_BTNMATRIX_BTN_NONE: if unset)
*/
uint16_t lv_btnm_get_active_btn(const lv_obj_t * btnm);
uint16_t lv_btnmatrix_get_active_btn(const lv_obj_t * btnm);
/**
* Get the text of the lastly "activated" button by the user (pressed, released etc)
@ -214,49 +214,49 @@ uint16_t lv_btnm_get_active_btn(const lv_obj_t * btnm);
* @param btnm pointer to button matrix object
* @return text of the last released button (NULL: if unset)
*/
const char * lv_btnm_get_active_btn_text(const lv_obj_t * btnm);
const char * lv_btnmatrix_get_active_btn_text(const lv_obj_t * btnm);
/**
* Get the pressed button's index.
* The button be really pressed by the user or manually set to pressed with `lv_btnm_set_pressed`
* The button be really pressed by the user or manually set to pressed with `lv_btnmatrix_set_pressed`
* @param btnm pointer to button matrix object
* @return index of the pressed button (LV_BTNM_BTN_NONE: if unset)
* @return index of the pressed button (LV_BTNMATRIX_BTN_NONE: if unset)
*/
uint16_t lv_btnm_get_pressed_btn(const lv_obj_t * btnm);
uint16_t lv_btnmatrix_get_pressed_btn(const lv_obj_t * btnm);
/**
* Get the button's text
* @param btnm pointer to button matrix object
* @param btn_id the index a button not counting new line characters. (The return value of
* lv_btnm_get_pressed/released)
* lv_btnmatrix_get_pressed/released)
* @return text of btn_index` button
*/
const char * lv_btnm_get_btn_text(const lv_obj_t * btnm, uint16_t btn_id);
const char * lv_btnmatrix_get_btn_text(const lv_obj_t * btnm, uint16_t btn_id);
/**
* Get the whether a control value is enabled or disabled for button of a button matrix
* @param btnm pointer to a button matrix object
* @param btn_id the index a button not counting new line characters. (E.g. the return value of
* lv_btnm_get_pressed/released)
* lv_btnmatrix_get_pressed/released)
* @param ctrl control values to check (ORed value can be used)
* @return true: long press repeat is disabled; false: long press repeat enabled
*/
bool lv_btnm_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl);
bool lv_btnmatrix_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl);
/**
* Find whether "one toggle" mode is enabled.
* @param btnm Button matrix object
* @return whether "one toggle" mode is enabled
*/
bool lv_btnm_get_one_toggle(const lv_obj_t * btnm);
bool lv_btnmatrix_get_one_toggle(const lv_obj_t * btnm);
/**********************
* MACROS
**********************/
#endif /*LV_USE_BTNM*/
#endif /*LV_USE_BTNMATRIX*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_BTNM_H*/
#endif /*LV_BTNMATRIX_H*/

View File

@ -7,7 +7,7 @@
* INCLUDES
*********************/
#include "lv_cb.h"
#if LV_USE_CB != 0
#if LV_USE_CHECKBOX != 0
#include "../lv_core/lv_debug.h"
#include "../lv_core/lv_group.h"
@ -16,7 +16,7 @@
/*********************
* DEFINES
*********************/
#define LV_OBJX_NAME "lv_cb"
#define LV_OBJX_NAME "lv_checkbox"
/**********************
* TYPEDEFS
@ -25,8 +25,8 @@
/**********************
* STATIC PROTOTYPES
**********************/
static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param);
static lv_style_list_t * lv_cb_get_style(lv_obj_t * cb, uint8_t type);
static lv_res_t lv_checkbox_signal(lv_obj_t * cb, lv_signal_t sign, void * param);
static lv_style_list_t * lv_checkbox_get_style(lv_obj_t * cb, uint8_t type);
/**********************
* STATIC VARIABLES
@ -47,7 +47,7 @@ static lv_signal_cb_t ancestor_signal;
* @param copy pointer to a check box object, if not NULL then the new object will be copied from it
* @return pointer to the created check box
*/
lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_t * lv_checkbox_create(lv_obj_t * par, const lv_obj_t * copy)
{
LV_LOG_TRACE("check box create started");
@ -58,7 +58,7 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(cb);
lv_cb_ext_t * ext = lv_obj_allocate_ext_attr(cb, sizeof(lv_cb_ext_t));
lv_checkbox_ext_t * ext = lv_obj_allocate_ext_attr(cb, sizeof(lv_checkbox_ext_t));
LV_ASSERT_MEM(ext);
if(ext == NULL) {
lv_obj_del(cb);
@ -68,7 +68,7 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
ext->bullet = NULL;
ext->label = NULL;
lv_obj_set_signal_cb(cb, lv_cb_signal);
lv_obj_set_signal_cb(cb, lv_checkbox_signal);
/*Init the new checkbox object*/
if(copy == NULL) {
@ -77,7 +77,7 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
ext->label = lv_label_create(cb, NULL);
lv_cb_set_text(cb, "Check box");
lv_checkbox_set_text(cb, "Check box");
lv_btn_set_layout(cb, LV_LAYOUT_ROW_M);
lv_btn_set_fit(cb, LV_FIT_TIGHT);
lv_btn_set_checkable(cb, true);
@ -86,7 +86,7 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
lv_theme_apply(cb, LV_THEME_CB);
} else {
lv_cb_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
lv_checkbox_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->bullet = lv_obj_create(cb, copy_ext->bullet);
ext->label = lv_label_create(cb, copy_ext->label);
@ -109,11 +109,11 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
* @param cb pointer to a check box
* @param txt the text of the check box. NULL to refresh with the current text.
*/
void lv_cb_set_text(lv_obj_t * cb, const char * txt)
void lv_checkbox_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_checkbox_ext_t * ext = lv_obj_get_ext_attr(cb);
lv_label_set_text(ext->label, txt);
}
@ -123,11 +123,11 @@ void lv_cb_set_text(lv_obj_t * cb, const char * txt)
* @param cb pointer to a check box
* @param txt the text of the check box. NULL to refresh with the current text.
*/
void lv_cb_set_static_text(lv_obj_t * cb, const char * txt)
void lv_checkbox_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_checkbox_ext_t * ext = lv_obj_get_ext_attr(cb);
lv_label_set_static_text(ext->label, txt);
}
@ -140,11 +140,11 @@ void lv_cb_set_static_text(lv_obj_t * cb, const char * txt)
* @param cb pointer to check box object
* @return pointer to the text of the check box
*/
const char * lv_cb_get_text(const lv_obj_t * cb)
const char * lv_checkbox_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_checkbox_ext_t * ext = lv_obj_get_ext_attr(cb);
return lv_label_get_text(ext->label);
}
@ -159,12 +159,12 @@ const char * lv_cb_get_text(const lv_obj_t * cb)
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
static lv_res_t lv_checkbox_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
{
lv_res_t res;
if(sign == LV_SIGNAL_GET_STYLE) {
lv_get_style_info_t * info = param;
info->result = lv_cb_get_style(cb, info->part);
info->result = lv_checkbox_get_style(cb, info->part);
if(info->result != NULL) return LV_RES_OK;
else return ancestor_signal(cb, sign, param);
return LV_RES_OK;
@ -175,21 +175,21 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
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_checkbox_ext_t * ext = lv_obj_get_ext_attr(cb);
if(sign == LV_SIGNAL_STYLE_CHG) {
const lv_font_t * font = lv_obj_get_style_font(ext->label, LV_LABEL_PART_MAIN);
lv_coord_t line_height = lv_font_get_line_height(font);
lv_obj_set_size(ext->bullet, line_height, line_height);
lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CB_PART_BG));
lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG));
} else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST ||
sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS) {
lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CB_PART_BG));
lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG));
} else if(sign == LV_SIGNAL_CONTROL) {
char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN || c == LV_KEY_LEFT || c == LV_KEY_UP) {
/*Follow the backgrounds state with the bullet*/
lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CB_PART_BG));
lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG));
}
}
@ -197,16 +197,16 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
}
static lv_style_list_t * lv_cb_get_style(lv_obj_t * cb, uint8_t type)
static lv_style_list_t * lv_checkbox_get_style(lv_obj_t * cb, uint8_t type)
{
lv_style_list_t * style_dsc_p;
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
lv_checkbox_ext_t * ext = lv_obj_get_ext_attr(cb);
switch(type) {
case LV_CB_PART_BG:
case LV_CHECKBOX_PART_BG:
style_dsc_p = &cb->style_list;
break;
case LV_CB_PART_BULLET:
case LV_CHECKBOX_PART_BULLET:
style_dsc_p = lv_obj_get_style_list(ext->bullet, LV_BTN_PART_MAIN);
break;
default:

View File

@ -3,8 +3,8 @@
*
*/
#ifndef LV_CB_H
#define LV_CB_H
#ifndef LV_CHECKBOX_H
#define LV_CHECKBOX_H
#ifdef __cplusplus
extern "C" {
@ -15,7 +15,7 @@ extern "C" {
*********************/
#include "../lv_conf_internal.h"
#if LV_USE_CB != 0
#if LV_USE_CHECKBOX != 0
/*Testing of dependencies*/
#if LV_USE_BTN == 0
@ -45,14 +45,14 @@ typedef struct
/*New data for this type */
lv_obj_t * bullet; /*Pointer to button*/
lv_obj_t * label; /*Pointer to label*/
} lv_cb_ext_t;
} lv_checkbox_ext_t;
/** Checkbox styles. */
enum {
LV_CB_PART_BG = LV_BTN_PART_MAIN, /**< Style of object background. */
LV_CB_PART_BULLET = _LV_BTN_PART_REAL_LAST, /**< Style of box (released). */
LV_CHECKBOX_PART_BG = LV_BTN_PART_MAIN, /**< Style of object background. */
LV_CHECKBOX_PART_BULLET = _LV_BTN_PART_REAL_LAST, /**< Style of box (released). */
};
typedef uint8_t lv_cb_style_t;
typedef uint8_t lv_checkbox_style_t;
/**********************
* GLOBAL PROTOTYPES
@ -64,7 +64,7 @@ typedef uint8_t lv_cb_style_t;
* @param copy pointer to a check box object, if not NULL then the new object will be copied from it
* @return pointer to the created check box
*/
lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy);
lv_obj_t * lv_checkbox_create(lv_obj_t * par, const lv_obj_t * copy);
/*=====================
* Setter functions
@ -76,7 +76,7 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy);
* @param cb pointer to a check box
* @param txt the text of the check box. NULL to refresh with the current text.
*/
void lv_cb_set_text(lv_obj_t * cb, const char * txt);
void lv_checkbox_set_text(lv_obj_t * cb, const char * txt);
/**
* Set the text of a check box. `txt` must not be deallocated during the life
@ -84,14 +84,14 @@ void lv_cb_set_text(lv_obj_t * cb, const char * txt);
* @param cb pointer to a check box
* @param txt the text of the check box. NULL to refresh with the current text.
*/
void lv_cb_set_static_text(lv_obj_t * cb, const char * txt);
void lv_checkbox_set_static_text(lv_obj_t * cb, const char * txt);
/**
* Set the state of the check box
* @param cb pointer to a check box object
* @param checked true: make the check box checked; false: make it unchecked
*/
static inline void lv_cb_set_checked(lv_obj_t * cb, bool checked)
static inline void lv_checkbox_set_checked(lv_obj_t * cb, bool checked)
{
lv_btn_set_state(cb, checked ? LV_BTN_STATE_CHECKED_RELEASED: LV_BTN_STATE_RELEASED);
}
@ -100,7 +100,7 @@ static inline void lv_cb_set_checked(lv_obj_t * cb, bool checked)
* Make the check box inactive (disabled)
* @param cb pointer to a check box object
*/
static inline void lv_cb_set_inactive(lv_obj_t * cb)
static inline void lv_checkbox_set_inactive(lv_obj_t * cb)
{
lv_btn_set_state(cb, LV_BTN_STATE_DISABLED);
}
@ -111,7 +111,7 @@ static inline void lv_cb_set_inactive(lv_obj_t * cb)
* @param type which style should be set
* @param style pointer to a style
* */
void lv_cb_set_style(lv_obj_t * cb, lv_cb_style_t type, const lv_style_t * style);
void lv_checkbox_set_style(lv_obj_t * cb, lv_checkbox_style_t type, const lv_style_t * style);
/*=====================
* Getter functions
@ -122,14 +122,14 @@ void lv_cb_set_style(lv_obj_t * cb, lv_cb_style_t type, const lv_style_t * style
* @param cb pointer to check box object
* @return pointer to the text of the check box
*/
const char * lv_cb_get_text(const lv_obj_t * cb);
const char * lv_checkbox_get_text(const lv_obj_t * cb);
/**
* Get the current state of the check box
* @param cb pointer to a check box object
* @return true: checked; false: not checked
*/
static inline bool lv_cb_is_checked(const lv_obj_t * cb)
static inline bool lv_checkbox_is_checked(const lv_obj_t * cb)
{
return lv_btn_get_state(cb) == LV_BTN_STATE_RELEASED ? false : true;
}
@ -139,7 +139,7 @@ static inline bool lv_cb_is_checked(const lv_obj_t * cb)
* @param cb pointer to a check box object
* @return true: inactive; false: not inactive
*/
static inline bool lv_cb_is_inactive(const lv_obj_t * cb)
static inline bool lv_checkbox_is_inactive(const lv_obj_t * cb)
{
return lv_btn_get_state(cb) == LV_BTN_STATE_DISABLED ? true :false;
}
@ -149,10 +149,10 @@ static inline bool lv_cb_is_inactive(const lv_obj_t * cb)
* MACROS
**********************/
#endif /*LV_USE_CB*/
#endif /*LV_USE_CHECKBOX*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_CB_H*/
#endif /*LV_CHECKBOX_H*/

View File

@ -7,7 +7,7 @@
* INCLUDES
*********************/
#include "lv_ddlist.h"
#if LV_USE_DDLIST != 0
#if LV_USE_DROPDOWN != 0
#include "../lv_core/lv_debug.h"
#include "../lv_draw/lv_draw.h"
@ -22,14 +22,14 @@
/*********************
* DEFINES
*********************/
#define LV_OBJX_NAME "lv_ddlist"
#define LV_OBJX_NAME "lv_dropdown"
#if LV_USE_ANIMATION == 0
#undef LV_DDLIST_DEF_ANIM_TIME
#define LV_DDLIST_DEF_ANIM_TIME 0 /*No animation*/
#undef LV_DROPDOWN_DEF_ANIM_TIME
#define LV_DROPDOWN_DEF_ANIM_TIME 0 /*No animation*/
#endif
#define LV_DDLIST_PR_NONE 0xFFFF
#define LV_DROPDOWN_PR_NONE 0xFFFF
/**********************
* TYPEDEFS
@ -38,17 +38,17 @@ typedef struct
{
lv_page_ext_t page;
lv_obj_t * ddlist; /*Pointer to the ddlist where the page belongs*/
}lv_ddlist_page_ext_t;
}lv_dropdown_page_ext_t;
/**********************
* STATIC PROTOTYPES
**********************/
static lv_design_res_t lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_design_res_t lv_ddlist_page_design(lv_obj_t * ddlist, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param);
static lv_res_t lv_ddlist_page_signal(lv_obj_t * page, lv_signal_t sign, void * param);
static lv_res_t lv_ddlist_page_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param);
static lv_style_list_t * lv_ddlist_get_style(lv_obj_t * ddlist, uint8_t part);
static lv_design_res_t lv_dropdown_design(lv_obj_t * ddlist, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_design_res_t lv_dropdown_page_design(lv_obj_t * ddlist, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_res_t lv_dropdown_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param);
static lv_res_t lv_dropdown_page_signal(lv_obj_t * page, lv_signal_t sign, void * param);
static lv_res_t lv_dropdown_page_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param);
static lv_style_list_t * lv_dropdown_get_style(lv_obj_t * ddlist, uint8_t part);
static void draw_box(lv_obj_t * ddlist, const lv_area_t * clip_area, uint16_t id, lv_state_t state);
static void draw_box_label(lv_obj_t * ddlist, const lv_area_t * clip_area, uint16_t id, lv_state_t state);
static lv_res_t page_release_handler(lv_obj_t * page);
@ -83,7 +83,7 @@ static lv_design_cb_t ancestor_page_design;
* from it
* @return pointer to the created drop down list
*/
lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_t * lv_dropdown_create(lv_obj_t * par, const lv_obj_t * copy)
{
LV_LOG_TRACE("drop down list create started");
@ -96,7 +96,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(ddlist);
/*Allocate the drop down list type specific extended data*/
lv_ddlist_ext_t * ext = lv_obj_allocate_ext_attr(ddlist, sizeof(lv_ddlist_ext_t));
lv_dropdown_ext_t * ext = lv_obj_allocate_ext_attr(ddlist, sizeof(lv_dropdown_ext_t));
LV_ASSERT_MEM(ext);
if(ext == NULL) {
lv_obj_del(ddlist);
@ -111,28 +111,28 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
ext->show_selected = 1;
ext->sel_opt_id = 0;
ext->sel_opt_id_orig = 0;
ext->pr_opt_id = LV_DDLIST_PR_NONE;
ext->pr_opt_id = LV_DROPDOWN_PR_NONE;
ext->option_cnt = 0;
ext->dir = LV_DDLIST_DIR_DOWN;
ext->dir = LV_DROPDOWN_DIR_DOWN;
ext->max_height = LV_DPI * 2;
ext->anim_time = LV_DDLIST_DEF_ANIM_TIME;
ext->anim_time = LV_DROPDOWN_DEF_ANIM_TIME;
lv_style_list_init(&ext->style_page);
lv_style_list_init(&ext->style_scrlbar);
lv_style_list_init(&ext->style_selected);
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_cb(ddlist, lv_ddlist_signal);
lv_obj_set_design_cb(ddlist, lv_ddlist_design);
lv_obj_set_signal_cb(ddlist, lv_dropdown_signal);
lv_obj_set_design_cb(ddlist, lv_dropdown_design);
/*Init the new drop down list drop down list*/
if(copy == NULL) {
lv_ddlist_set_options(ddlist, "Option 1\nOption 2\nOption 3");
lv_dropdown_set_options(ddlist, "Option 1\nOption 2\nOption 3");
lv_theme_apply(ddlist, LV_THEME_DDLIST);
}
/*Copy an existing drop down list*/
else {
lv_ddlist_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
lv_dropdown_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->options = copy_ext->options;
ext->option_cnt = copy_ext->option_cnt;
ext->sel_opt_id = copy_ext->sel_opt_id;
@ -162,10 +162,10 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
* @param ddlist pointer to a drop down list object
* @param txt the text as a string (Only it's pointer is saved)
*/
void lv_ddlist_set_text(lv_obj_t * ddlist, const char * txt)
void lv_dropdown_set_text(lv_obj_t * ddlist, const char * txt)
{
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
if(ext->text == txt) return;
ext->text = txt;
@ -178,12 +178,12 @@ void lv_ddlist_set_text(lv_obj_t * ddlist, const char * txt)
* @param ddlist pointer to drop down list object
* @param options a string with '\n' separated options. E.g. "One\nTwo\nThree"
*/
void lv_ddlist_set_options(lv_obj_t * ddlist, const char * options)
void lv_dropdown_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_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
/*Count the '\n'-s to determine the number of options*/
ext->option_cnt = 0;
@ -202,11 +202,11 @@ void lv_ddlist_set_options(lv_obj_t * ddlist, const char * options)
* @param ddlist pointer to drop down list object
* @param sel_opt id of the selected option (0 ... number of option - 1);
*/
void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt)
void lv_dropdown_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_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
if(ext->sel_opt_id == sel_opt) return;
ext->sel_opt_id = sel_opt < ext->option_cnt ? sel_opt : ext->option_cnt - 1;
@ -223,11 +223,11 @@ void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt)
* @param ddlist pointer to a drop down list
* @param h the height when the list is opened (0: auto size)
*/
void lv_ddlist_set_max_height(lv_obj_t * ddlist, lv_coord_t h)
void lv_dropdown_set_max_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_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
if(ext->max_height == h) return;
ext->max_height = h;
@ -247,11 +247,11 @@ void lv_ddlist_set_max_height(lv_obj_t * ddlist, lv_coord_t h)
* @param ddlist pointer to drop down list object
* @param symbol a text like `LV_SYMBOL_DOWN` or NULL to not draw icon
*/
void lv_ddlist_set_symbol(lv_obj_t * ddlist, const char * symbol)
void lv_dropdown_set_symbol(lv_obj_t * ddlist, const char * symbol)
{
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
ext->symbol = symbol;
lv_obj_invalidate(ddlist);
}
@ -259,13 +259,13 @@ void lv_ddlist_set_symbol(lv_obj_t * ddlist, const char * symbol)
/**
* Set the direction of the a drop down list
* @param ddlist pointer to a drop down list object
* @param dir LV_DDLIST_DIR_LEF/RIGHT/TOP/BOTTOM
* @param dir LV_DROPDOWN_DIR_LEF/RIGHT/TOP/BOTTOM
*/
void lv_ddlist_set_dir(lv_obj_t * ddlist, lv_ddlist_dir_t dir)
void lv_dropdown_set_dir(lv_obj_t * ddlist, lv_dropdown_dir_t dir)
{
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
if(ext->dir == dir) return;
ext->dir = dir;
@ -278,11 +278,11 @@ void lv_ddlist_set_dir(lv_obj_t * ddlist, lv_ddlist_dir_t dir)
* @param ddlist pointer to a drop down list object
* @param show true/false
*/
void lv_ddlist_set_show_selected(lv_obj_t * ddlist, bool show)
void lv_dropdown_set_show_selected(lv_obj_t * ddlist, bool show)
{
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
if(ext->show_selected == show) return;
ext->show_selected = show;
@ -298,10 +298,10 @@ void lv_ddlist_set_show_selected(lv_obj_t * ddlist, bool show)
* @param ddlist pointer to a drop down list object
* @return the text string
*/
const char * lv_ddlist_get_text(lv_obj_t * ddlist)
const char * lv_dropdown_get_text(lv_obj_t * ddlist)
{
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return ext->text;
}
@ -311,11 +311,11 @@ const char * lv_ddlist_get_text(lv_obj_t * ddlist)
* @param ddlist pointer to drop down list object
* @return the options separated by '\n'-s (E.g. "Option1\nOption2\nOption3")
*/
const char * lv_ddlist_get_options(const lv_obj_t * ddlist)
const char * lv_dropdown_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_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return ext->options;
}
@ -324,11 +324,11 @@ const char * lv_ddlist_get_options(const lv_obj_t * ddlist)
* @param ddlist pointer to drop down list object
* @return id of the selected option (0 ... number of option - 1);
*/
uint16_t lv_ddlist_get_selected(const lv_obj_t * ddlist)
uint16_t lv_dropdown_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_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return ext->sel_opt_id;
}
@ -338,11 +338,11 @@ uint16_t lv_ddlist_get_selected(const lv_obj_t * ddlist)
* @param ddlist pointer to drop down list object
* @return the total number of options in the list
*/
uint16_t lv_ddlist_get_option_cnt(const lv_obj_t * ddlist)
uint16_t lv_dropdown_get_option_cnt(const lv_obj_t * ddlist)
{
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return ext->option_cnt;
}
@ -353,11 +353,11 @@ uint16_t lv_ddlist_get_option_cnt(const lv_obj_t * ddlist)
* @param buf pointer to an array to store the string
* @param buf_size size of `buf` in bytes. 0: to ignore it.
*/
void lv_ddlist_get_selected_str(const lv_obj_t * ddlist, char * buf, uint16_t buf_size)
void lv_dropdown_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_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
uint16_t i;
uint16_t line = 0;
@ -370,7 +370,7 @@ void lv_ddlist_get_selected_str(const lv_obj_t * ddlist, char * buf, uint16_t bu
uint16_t c;
for(c = 0; ext->options[i] != '\n' && i < txt_len; c++, i++) {
if(buf_size && c >= buf_size - 1) {
LV_LOG_WARN("lv_ddlist_get_selected_str: the buffer was too small")
LV_LOG_WARN("lv_dropdown_get_selected_str: the buffer was too small")
break;
}
buf[c] = ext->options[i];
@ -384,11 +384,11 @@ void lv_ddlist_get_selected_str(const lv_obj_t * ddlist, char * buf, uint16_t bu
* @param ddlist pointer to a drop down list object
* @return the height if the ddlist is opened (0: auto size)
*/
lv_coord_t lv_ddlist_get_max_height(const lv_obj_t * ddlist)
lv_coord_t lv_dropdown_get_max_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_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return ext->max_height;
}
@ -397,11 +397,11 @@ lv_coord_t lv_ddlist_get_max_height(const lv_obj_t * ddlist)
* @param ddlist pointer to drop down list object
* @return the symbol or NULL if not enabled
*/
const char * lv_ddlist_get_symbol(lv_obj_t * ddlist)
const char * lv_dropdown_get_symbol(lv_obj_t * ddlist)
{
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return ext->symbol;
}
@ -409,11 +409,11 @@ const char * lv_ddlist_get_symbol(lv_obj_t * ddlist)
/**
* Get the direction of the drop down list
* @param ddlist pointer to a drop down list object
* @return LV_DDLIST_DIR_LEF/RIGHT/TOP/BOTTOM
* @return LV_DROPDOWN_DIR_LEF/RIGHT/TOP/BOTTOM
*/
lv_ddlist_dir_t lv_ddlist_get_dir(const lv_obj_t * ddlist)
lv_dropdown_dir_t lv_dropdown_get_dir(const lv_obj_t * ddlist)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return ext->dir;
}
@ -423,9 +423,9 @@ lv_ddlist_dir_t lv_ddlist_get_dir(const lv_obj_t * ddlist)
* @param ddlist pointer to a drop down list object
* @return true/false
*/
bool lv_ddlist_get_show_selected(lv_obj_t * ddlist)
bool lv_dropdown_get_show_selected(lv_obj_t * ddlist)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return ext->show_selected ? true : false;
@ -440,12 +440,12 @@ bool lv_ddlist_get_show_selected(lv_obj_t * ddlist)
* @param ddlist pointer to drop down list object
* @param anim_en LV_ANIM_EN: use animation; LV_ANIM_OFF: not use animations
*/
void lv_ddlist_open(lv_obj_t * ddlist, lv_anim_enable_t anim)
void lv_dropdown_open(lv_obj_t * ddlist, lv_anim_enable_t anim)
{
#if LV_USE_ANIMATION == 0
anim = false;
#endif
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
if(ext->page) return;
ext->page = lv_page_create(lv_obj_get_screen(ddlist), NULL);
@ -456,12 +456,12 @@ void lv_ddlist_open(lv_obj_t * ddlist, lv_anim_enable_t anim)
if(ancestor_page_scrl_signal == NULL) ancestor_page_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(ext->page));
if(ancestor_page_design == NULL) ancestor_page_design = lv_obj_get_design_cb(ext->page);
lv_ddlist_page_ext_t * page_ext = lv_obj_allocate_ext_attr(ext->page, sizeof(lv_ddlist_page_ext_t));
lv_dropdown_page_ext_t * page_ext = lv_obj_allocate_ext_attr(ext->page, sizeof(lv_dropdown_page_ext_t));
page_ext->ddlist = ddlist;
lv_obj_set_design_cb(ext->page, lv_ddlist_page_design);
lv_obj_set_signal_cb(ext->page, lv_ddlist_page_signal);
lv_obj_set_signal_cb(lv_page_get_scrl(ext->page), lv_ddlist_page_scrl_signal);
lv_obj_set_design_cb(ext->page, lv_dropdown_page_design);
lv_obj_set_signal_cb(ext->page, lv_dropdown_page_signal);
lv_obj_set_signal_cb(lv_page_get_scrl(ext->page), lv_dropdown_page_scrl_signal);
lv_style_list_copy(lv_obj_get_style_list(ext->page, LV_PAGE_PART_BG), &ext->style_page);
lv_style_list_copy(lv_obj_get_style_list(ext->page, LV_PAGE_PART_SCRLBAR), &ext->style_scrlbar);
@ -475,8 +475,8 @@ void lv_ddlist_open(lv_obj_t * ddlist, lv_anim_enable_t anim)
lv_cont_set_fit2(ext->page, LV_FIT_TIGHT, LV_FIT_NONE);
lv_coord_t label_h = lv_obj_get_height(label);
lv_style_int_t top = lv_obj_get_style_pad_top(ddlist, LV_DDLIST_PART_LIST);
lv_style_int_t bottom = lv_obj_get_style_pad_bottom(ddlist, LV_DDLIST_PART_LIST);
lv_style_int_t top = lv_obj_get_style_pad_top(ddlist, LV_DROPDOWN_PART_LIST);
lv_style_int_t bottom = lv_obj_get_style_pad_bottom(ddlist, LV_DROPDOWN_PART_LIST);
lv_coord_t list_h = label_h + top + bottom;
@ -490,13 +490,13 @@ void lv_ddlist_open(lv_obj_t * ddlist, lv_anim_enable_t anim)
lv_coord_t vres = lv_disp_get_ver_res(disp);
lv_coord_t hres = lv_disp_get_hor_res(disp);
if(ext->dir == LV_DDLIST_DIR_DOWN) lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
else if(ext->dir == LV_DDLIST_DIR_UP) lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_TOP_LEFT, 0, 0);
else if(ext->dir == LV_DDLIST_DIR_LEFT) lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_LEFT_TOP, 0, 0);
else if(ext->dir == LV_DDLIST_DIR_RIGHT)lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_RIGHT_TOP, 0, 0);
if(ext->dir == LV_DROPDOWN_DIR_DOWN) lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
else if(ext->dir == LV_DROPDOWN_DIR_UP) lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_TOP_LEFT, 0, 0);
else if(ext->dir == LV_DROPDOWN_DIR_LEFT) lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_LEFT_TOP, 0, 0);
else if(ext->dir == LV_DROPDOWN_DIR_RIGHT)lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_RIGHT_TOP, 0, 0);
lv_obj_t * scr = lv_scr_act();
if(ext->dir != LV_DDLIST_DIR_UP) {
if(ext->dir != LV_DROPDOWN_DIR_UP) {
if(ext->page->coords.y2 > scr->coords.y2) {
lv_obj_set_y(ext->page, lv_obj_get_y(ext->page) - (ext->page->coords.y2 - scr->coords.y2));
}
@ -507,7 +507,7 @@ void lv_ddlist_open(lv_obj_t * ddlist, lv_anim_enable_t anim)
}
}
if(ext->dir != LV_DDLIST_DIR_UP) {
if(ext->dir != LV_DROPDOWN_DIR_UP) {
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_exec_cb(&a, ddlist, list_anim);
@ -522,21 +522,21 @@ void lv_ddlist_open(lv_obj_t * ddlist, lv_anim_enable_t anim)
* @param ddlist pointer to drop down list object
* @param anim_en LV_ANIM_ON: use animation; LV_ANIM_OFF: not use animations
*/
void lv_ddlist_close(lv_obj_t * ddlist, lv_anim_enable_t anim)
void lv_dropdown_close(lv_obj_t * ddlist, lv_anim_enable_t anim)
{
#if LV_USE_ANIMATION == 0
anim = false;
#endif
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
if(ext->page == NULL) return;
ext->pr_opt_id = LV_DDLIST_PR_NONE;
ext->pr_opt_id = LV_DROPDOWN_PR_NONE;
if(ext->anim_time == 0 || anim == LV_ANIM_OFF) {
lv_obj_del(ext->page);
ext->page = NULL;
} else {
// if(dir != LV_DDLIST_DIR_UP) {
// if(dir != LV_DROPDOWN_DIR_UP) {
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_exec_cb(&a, ddlist, list_anim);
@ -564,7 +564,7 @@ void lv_ddlist_close(lv_obj_t * ddlist, lv_anim_enable_t anim)
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
* @param return an element of `lv_design_res_t`
*/
static lv_design_res_t lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * clip_area, lv_design_mode_t mode)
static lv_design_res_t lv_dropdown_design(lv_obj_t * ddlist, const lv_area_t * clip_area, lv_design_mode_t mode)
{
/*Return false if the object is not covers the mask_p area*/
if(mode == LV_DESIGN_COVER_CHK) {
@ -574,15 +574,15 @@ static lv_design_res_t lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * cli
else if(mode == LV_DESIGN_DRAW_MAIN) {
ancestor_design(ddlist, clip_area, mode);
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_style_int_t left = lv_obj_get_style_pad_left(ddlist, LV_DDLIST_PART_BTN);
lv_style_int_t right = lv_obj_get_style_pad_right(ddlist, LV_DDLIST_PART_BTN);
lv_style_int_t top = lv_obj_get_style_pad_top(ddlist, LV_DDLIST_PART_BTN);
lv_style_int_t left = lv_obj_get_style_pad_left(ddlist, LV_DROPDOWN_PART_BTN);
lv_style_int_t right = lv_obj_get_style_pad_right(ddlist, LV_DROPDOWN_PART_BTN);
lv_style_int_t top = lv_obj_get_style_pad_top(ddlist, LV_DROPDOWN_PART_BTN);
lv_draw_label_dsc_t label_dsc;
lv_draw_label_dsc_init(&label_dsc);
lv_obj_init_draw_label_dsc(ddlist, LV_DDLIST_PART_BTN, &label_dsc);
lv_obj_init_draw_label_dsc(ddlist, LV_DROPDOWN_PART_BTN, &label_dsc);
lv_area_t txt_area;
lv_point_t txt_size;
@ -590,13 +590,13 @@ static lv_design_res_t lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * cli
const char * opt_txt = ext->text;
if(ext->show_selected) {
char * buf = lv_mem_buf_get(128);
lv_ddlist_get_selected_str(ddlist, buf, 128);
lv_dropdown_get_selected_str(ddlist, buf, 128);
opt_txt = buf;
}
const char * txt;
txt = ext->dir != LV_DDLIST_DIR_LEFT ? opt_txt : ext->symbol;
txt = ext->dir != LV_DROPDOWN_DIR_LEFT ? opt_txt : ext->symbol;
if(txt) {
lv_txt_get_size(&txt_size, txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, label_dsc.flag);
@ -614,7 +614,7 @@ static lv_design_res_t lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * cli
lv_draw_label(&txt_area, clip_area, &label_dsc, txt, NULL);
}
txt = ext->dir != LV_DDLIST_DIR_LEFT ? ext->symbol : opt_txt;
txt = ext->dir != LV_DROPDOWN_DIR_LEFT ? ext->symbol : opt_txt;
if(txt) {
lv_txt_get_size(&txt_size, txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, label_dsc.flag);
txt_area.y1 = ddlist->coords.y1 + top;
@ -653,7 +653,7 @@ static lv_design_res_t lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * cli
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
* @param return an element of `lv_design_res_t`
*/
static lv_design_res_t lv_ddlist_page_design(lv_obj_t * page, const lv_area_t * clip_area, lv_design_mode_t mode)
static lv_design_res_t lv_dropdown_page_design(lv_obj_t * page, const lv_area_t * clip_area, lv_design_mode_t mode)
{
/*Return false if the object is not covers the mask_p area*/
if(mode == LV_DESIGN_COVER_CHK) {
@ -663,13 +663,13 @@ static lv_design_res_t lv_ddlist_page_design(lv_obj_t * page, const lv_area_t *
else if(mode == LV_DESIGN_DRAW_MAIN) {
ancestor_page_design(page, clip_area, mode);
lv_ddlist_page_ext_t * page_ext = lv_obj_get_ext_attr(page);
lv_dropdown_page_ext_t * page_ext = lv_obj_get_ext_attr(page);
lv_obj_t * ddlist = page_ext->ddlist;
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
/*Draw the boxes if the page is not being deleted*/
if(ext->page) {
if(ext->pr_opt_id != LV_DDLIST_PR_NONE) {
if(ext->pr_opt_id != LV_DROPDOWN_PR_NONE) {
draw_box(ddlist, clip_area, ext->pr_opt_id, LV_STATE_PRESSED);
}
@ -684,13 +684,13 @@ static lv_design_res_t lv_ddlist_page_design(lv_obj_t * page, const lv_area_t *
ancestor_page_design(page, clip_area, mode);
/*Redraw the text on the selected area with a different color*/
lv_ddlist_page_ext_t * page_ext = lv_obj_get_ext_attr(page);
lv_dropdown_page_ext_t * page_ext = lv_obj_get_ext_attr(page);
lv_obj_t * ddlist = page_ext->ddlist;
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
/*Draw the box labels if the page is not being deleted*/
if(ext->page) {
if(ext->pr_opt_id != LV_DDLIST_PR_NONE) {
if(ext->pr_opt_id != LV_DROPDOWN_PR_NONE) {
draw_box_label(ddlist, clip_area, ext->pr_opt_id, LV_STATE_PRESSED);
}
@ -710,7 +710,7 @@ static lv_design_res_t lv_ddlist_page_design(lv_obj_t * page, const lv_area_t *
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param)
static lv_res_t lv_dropdown_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param)
{
lv_res_t res;
@ -719,25 +719,25 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
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_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
if(sign == LV_SIGNAL_GET_STYLE) {
lv_get_style_info_t * info = param;
info->result = lv_ddlist_get_style(ddlist, info->part);
info->result = lv_dropdown_get_style(ddlist, info->part);
if(info->result != NULL) return LV_RES_OK;
return LV_RES_OK;
}
else if(sign == LV_SIGNAL_GET_STATE_DSC) {
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_get_state_info_t * info = param;
if(info->part == LV_DDLIST_PART_LIST ||
info->part == LV_DDLIST_PART_SCRLBAR ||
info->part == LV_DDLIST_PART_SELECTED) {
if(info->part == LV_DROPDOWN_PART_LIST ||
info->part == LV_DROPDOWN_PART_SCRLBAR ||
info->part == LV_DROPDOWN_PART_SELECTED) {
info->result = lv_obj_get_state_dsc(ext->page, LV_PAGE_PART_BG);
}
}
else if(sign == LV_SIGNAL_CLEANUP) {
lv_ddlist_close(ddlist, LV_ANIM_OFF);
lv_dropdown_close(ddlist, LV_ANIM_OFF);
}
else if(sign == LV_SIGNAL_FOCUS) {
#if LV_USE_GROUP
@ -748,25 +748,25 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
/*Encoders need special handling*/
if(indev_type == LV_INDEV_TYPE_ENCODER) {
/*Open the list if editing*/
if(editing) lv_ddlist_open(ddlist, LV_ANIM_ON);
if(editing) lv_dropdown_open(ddlist, LV_ANIM_ON);
/*Close the list if navigating*/
else
lv_ddlist_close(ddlist, LV_ANIM_ON);
lv_dropdown_close(ddlist, LV_ANIM_ON);
}
#endif
} else if(sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_LEAVE) {
lv_ddlist_close(ddlist, LV_ANIM_ON);
lv_dropdown_close(ddlist, LV_ANIM_ON);
}
else if(sign == LV_SIGNAL_RELEASED) {
if(lv_indev_is_dragging(lv_indev_get_act()) == false) {
if(ext->page) {
lv_ddlist_close(ddlist, LV_ANIM_ON);
lv_dropdown_close(ddlist, LV_ANIM_ON);
if(ext->sel_opt_id_orig != ext->sel_opt_id) {
ext->sel_opt_id_orig = ext->sel_opt_id;
lv_obj_invalidate(ddlist);
}
} else {
lv_ddlist_open(ddlist, LV_ANIM_ON);
lv_dropdown_open(ddlist, LV_ANIM_ON);
}
}
else {
@ -775,12 +775,12 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
}
}
else if(sign == LV_SIGNAL_COORD_CHG) {
if(ext->page) lv_ddlist_close(ddlist, LV_ANIM_OFF);
if(ext->page) lv_dropdown_close(ddlist, LV_ANIM_OFF);
}
else if(sign == LV_SIGNAL_STYLE_CHG) {
lv_style_int_t top = lv_obj_get_style_pad_top(ddlist, LV_DDLIST_PART_BTN);
lv_style_int_t bottom = lv_obj_get_style_pad_bottom(ddlist, LV_DDLIST_PART_BTN);
const lv_font_t * font = lv_obj_get_style_font(ddlist, LV_DDLIST_PART_BTN);
lv_style_int_t top = lv_obj_get_style_pad_top(ddlist, LV_DROPDOWN_PART_BTN);
lv_style_int_t bottom = lv_obj_get_style_pad_bottom(ddlist, LV_DROPDOWN_PART_BTN);
const lv_font_t * font = lv_obj_get_style_font(ddlist, LV_DROPDOWN_PART_BTN);
lv_obj_set_height(ddlist, top + bottom + lv_font_get_line_height(font));
if(ext->page) lv_obj_refresh_style(ext->page);
@ -789,7 +789,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) {
if(ext->page == NULL) {
lv_ddlist_open(ddlist, LV_ANIM_ON);
lv_dropdown_open(ddlist, LV_ANIM_ON);
} else if(ext->sel_opt_id + 1 < ext->option_cnt) {
ext->sel_opt_id++;
pos_selected(ddlist);
@ -797,14 +797,14 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
} else if(c == LV_KEY_LEFT || c == LV_KEY_UP) {
if(ext->page == NULL) {
lv_ddlist_open(ddlist, LV_ANIM_ON);
lv_dropdown_open(ddlist, LV_ANIM_ON);
} else if(ext->sel_opt_id > 0) {
ext->sel_opt_id--;
pos_selected(ddlist);
}
} else if(c == LV_KEY_ESC) {
ext->sel_opt_id = ext->sel_opt_id_orig;
lv_ddlist_close(ddlist, LV_ANIM_ON);
lv_dropdown_close(ddlist, LV_ANIM_ON);
}
}
else if(sign == LV_SIGNAL_GET_EDITABLE) {
@ -822,7 +822,7 @@ else if(sign == LV_SIGNAL_GET_EDITABLE) {
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static lv_res_t lv_ddlist_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
static lv_res_t lv_dropdown_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
{
lv_res_t res;
@ -831,15 +831,15 @@ static lv_res_t lv_ddlist_page_signal(lv_obj_t * page, lv_signal_t sign, void *
if(res != LV_RES_OK) return res;
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, "");
lv_ddlist_page_ext_t * page_ext = lv_obj_get_ext_attr(page);
lv_dropdown_page_ext_t * page_ext = lv_obj_get_ext_attr(page);
lv_obj_t * ddlist = page_ext->ddlist;
if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
/* Make possible to draw on the full width of the background to redraw the selected rectangle
* when the ddlist is scrolled in fix height mode.
* (The scrollabel is scrolled the "select rectangle" is drawn on the bg too)*/
lv_style_int_t left = lv_obj_get_style_pad_left(ddlist, LV_DDLIST_PART_LIST);
lv_style_int_t right = lv_obj_get_style_pad_right(ddlist, LV_DDLIST_PART_LIST);
lv_style_int_t left = lv_obj_get_style_pad_left(ddlist, LV_DROPDOWN_PART_LIST);
lv_style_int_t right = lv_obj_get_style_pad_right(ddlist, LV_DROPDOWN_PART_LIST);
lv_obj_t * scrl = lv_page_get_scrl(page);
scrl->ext_draw_pad = LV_MATH_MAX(scrl->ext_draw_pad, LV_MATH_MAX(left, right));
} else if(sign == LV_SIGNAL_RELEASED) {
@ -849,7 +849,7 @@ static lv_res_t lv_ddlist_page_signal(lv_obj_t * page, lv_signal_t sign, void *
} else if(sign == LV_SIGNAL_PRESSED) {
page_press_handler(page);
} else if(sign == LV_SIGNAL_CLEANUP) {
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
ext->page = NULL; /*The page is just being deleted*/
}
@ -863,7 +863,7 @@ static lv_res_t lv_ddlist_page_signal(lv_obj_t * page, lv_signal_t sign, void *
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static lv_res_t lv_ddlist_page_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param)
static lv_res_t lv_dropdown_page_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param)
{
lv_res_t res;
@ -873,9 +873,9 @@ static lv_res_t lv_ddlist_page_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, vo
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, "");
lv_obj_t * page = lv_obj_get_parent(scrl);
lv_ddlist_page_ext_t * page_ext = lv_obj_get_ext_attr(page);
lv_dropdown_page_ext_t * page_ext = lv_obj_get_ext_attr(page);
lv_obj_t * ddlist = page_ext->ddlist;
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
if(sign == LV_SIGNAL_RELEASED) {
if(lv_indev_is_dragging(lv_indev_get_act()) == false) {
@ -884,15 +884,15 @@ static lv_res_t lv_ddlist_page_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, vo
} else if(sign == LV_SIGNAL_PRESSED) {
page_press_handler(page);
} else if(sign == LV_SIGNAL_DRAG_BEGIN) {
ext->pr_opt_id = LV_DDLIST_PR_NONE;
ext->pr_opt_id = LV_DROPDOWN_PR_NONE;
lv_obj_invalidate(page);
}
else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
/* Make possible to draw on the full width of the background to redraw the selected rectangle
* when the ddlist is scrolled in fix height mode.
* (The scrollabel is scrolled the "select rectangle" is drawn on the bg too)*/
lv_style_int_t left = lv_obj_get_style_pad_left(ddlist, LV_DDLIST_PART_LIST);
lv_style_int_t right = lv_obj_get_style_pad_right(ddlist, LV_DDLIST_PART_LIST);
lv_style_int_t left = lv_obj_get_style_pad_left(ddlist, LV_DROPDOWN_PART_LIST);
lv_style_int_t right = lv_obj_get_style_pad_right(ddlist, LV_DROPDOWN_PART_LIST);
scrl->ext_draw_pad = LV_MATH_MAX(scrl->ext_draw_pad, LV_MATH_MAX(left, right));
}
@ -903,27 +903,27 @@ static lv_res_t lv_ddlist_page_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, vo
/**
* Get the style descriptor of a part of the object
* @param page pointer the object
* @param part the part from `lv_ddlist_part_t`. (LV_DDLIST_PART_...)
* @param part the part from `lv_dropdown_part_t`. (LV_DROPDOWN_PART_...)
* @return pointer to the style descriptor of the specified part
*/
static lv_style_list_t * lv_ddlist_get_style(lv_obj_t * ddlist, uint8_t part)
static lv_style_list_t * lv_dropdown_get_style(lv_obj_t * ddlist, uint8_t part)
{
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_style_list_t * style_dsc_p;
switch(part) {
case LV_DDLIST_PART_BTN:
case LV_DROPDOWN_PART_BTN:
style_dsc_p = &ddlist->style_list;
break;
case LV_DDLIST_PART_LIST:
case LV_DROPDOWN_PART_LIST:
style_dsc_p = &ext->style_page;
break;
case LV_DDLIST_PART_SCRLBAR:
case LV_DROPDOWN_PART_SCRLBAR:
style_dsc_p = &ext->style_scrlbar;
break;
case LV_DDLIST_PART_SELECTED:
case LV_DROPDOWN_PART_SELECTED:
style_dsc_p = &ext->style_selected;
break;
default:
@ -935,7 +935,7 @@ static lv_style_list_t * lv_ddlist_get_style(lv_obj_t * ddlist, uint8_t part)
static void draw_box(lv_obj_t * ddlist, const lv_area_t * clip_area, uint16_t id, lv_state_t state)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_obj_t * page = ext->page;
lv_obj_state_dsc_t state_orig = page->state_dsc;
@ -944,8 +944,8 @@ static void draw_box(lv_obj_t * ddlist, const lv_area_t * clip_area, uint16_t id
page->state_dsc.prev = page->state_dsc.act;
/*Draw a rectangle under the selected item*/
const lv_font_t * font = lv_obj_get_style_font(ddlist, LV_DDLIST_PART_LIST);
lv_style_int_t line_space = lv_obj_get_style_text_line_space(ddlist, LV_DDLIST_PART_LIST);
const lv_font_t * font = lv_obj_get_style_font(ddlist, LV_DROPDOWN_PART_LIST);
lv_style_int_t line_space = lv_obj_get_style_text_line_space(ddlist, LV_DROPDOWN_PART_LIST);
lv_coord_t font_h = lv_font_get_line_height(font);
/*Draw the selected*/
@ -961,7 +961,7 @@ static void draw_box(lv_obj_t * ddlist, const lv_area_t * clip_area, uint16_t id
lv_draw_rect_dsc_t sel_rect;
lv_draw_rect_dsc_init(&sel_rect);
lv_obj_init_draw_rect_dsc(ddlist, LV_DDLIST_PART_SELECTED, &sel_rect);
lv_obj_init_draw_rect_dsc(ddlist, LV_DROPDOWN_PART_SELECTED, &sel_rect);
lv_draw_rect(&rect_area, clip_area, &sel_rect);
page->state_dsc = state_orig;
@ -971,7 +971,7 @@ static void draw_box(lv_obj_t * ddlist, const lv_area_t * clip_area, uint16_t id
static void draw_box_label(lv_obj_t * ddlist, const lv_area_t * clip_area, uint16_t id, lv_state_t state)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_obj_t * page = ext->page;
lv_obj_state_dsc_t state_orig = page->state_dsc;
@ -981,8 +981,8 @@ static void draw_box_label(lv_obj_t * ddlist, const lv_area_t * clip_area, uint1
lv_draw_label_dsc_t label_dsc;
lv_draw_label_dsc_init(&label_dsc);
lv_obj_init_draw_label_dsc(ddlist, LV_DDLIST_PART_SELECTED, &label_dsc);
label_dsc.line_space = lv_obj_get_style_text_line_space(ddlist, LV_DDLIST_PART_LIST); /*Line space should come from the page*/
lv_obj_init_draw_label_dsc(ddlist, LV_DROPDOWN_PART_SELECTED, &label_dsc);
label_dsc.line_space = lv_obj_get_style_text_line_space(ddlist, LV_DROPDOWN_PART_LIST); /*Line space should come from the page*/
lv_coord_t font_h = lv_font_get_line_height(label_dsc.font);
lv_obj_t * label = get_label(ddlist);
@ -1010,10 +1010,10 @@ static void draw_box_label(lv_obj_t * ddlist, const lv_area_t * clip_area, uint1
*/
static lv_res_t page_release_handler(lv_obj_t * page)
{
lv_ddlist_page_ext_t * page_ext = lv_obj_get_ext_attr(page);
lv_dropdown_page_ext_t * page_ext = lv_obj_get_ext_attr(page);
lv_obj_t * ddlist = page_ext->ddlist;
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_indev_t * indev = lv_indev_get_act();
#if LV_USE_GROUP
@ -1035,7 +1035,7 @@ static lv_res_t page_release_handler(lv_obj_t * page)
ext->sel_opt_id_orig = ext->sel_opt_id;
}
lv_ddlist_close(ddlist, LV_ANIM_ON);
lv_dropdown_close(ddlist, LV_ANIM_ON);
/*Invalidate to refresh the text*/
if(ext->show_selected) lv_obj_invalidate(ddlist);
@ -1050,10 +1050,10 @@ static lv_res_t page_release_handler(lv_obj_t * page)
static void page_press_handler(lv_obj_t * page)
{
lv_ddlist_page_ext_t * page_ext = lv_obj_get_ext_attr(page);
lv_dropdown_page_ext_t * page_ext = lv_obj_get_ext_attr(page);
lv_obj_t * ddlist = page_ext->ddlist;
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_indev_t * indev = lv_indev_get_act();
if(indev && (lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER || lv_indev_get_type(indev) == LV_INDEV_TYPE_BUTTON)) {
@ -1097,15 +1097,15 @@ static uint16_t get_id_on_point(lv_obj_t * ddlist, lv_coord_t x, lv_coord_t y)
*/
static void pos_selected(lv_obj_t * ddlist)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
const lv_font_t * font = lv_obj_get_style_font(ddlist, LV_DDLIST_PART_LIST);
const lv_font_t * font = lv_obj_get_style_font(ddlist, LV_DROPDOWN_PART_LIST);
lv_coord_t font_h = lv_font_get_line_height(font);
lv_obj_t * scrl = lv_page_get_scrl(ext->page);
lv_obj_t * label = get_label(ddlist);
lv_coord_t h = lv_obj_get_height(ext->page);
lv_style_int_t line_space = lv_obj_get_style_text_line_space(ddlist, LV_DDLIST_PART_LIST);
lv_style_int_t line_space = lv_obj_get_style_text_line_space(ddlist, LV_DROPDOWN_PART_LIST);
lv_coord_t line_y1 = ext->sel_opt_id * (font_h + line_space) + label->coords.y1 - scrl->coords.y1;
@ -1117,7 +1117,7 @@ static void pos_selected(lv_obj_t * ddlist)
static lv_obj_t * get_label(const lv_obj_t * ddlist)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
if(ext->page == NULL) return NULL;
return lv_obj_get_child(lv_page_get_scrl(ext->page), NULL);
@ -1126,14 +1126,14 @@ static lv_obj_t * get_label(const lv_obj_t * ddlist)
static void list_anim(void * p, lv_anim_value_t v)
{
lv_obj_t * ddlist = p;
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_obj_set_height(ext->page, v);
}
static void close_anim_ready(lv_anim_t * a)
{
lv_obj_t * ddlist = a->var;
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_obj_del(ext->page);
ext->page = NULL;
}

View File

@ -3,8 +3,8 @@
*
*/
#ifndef LV_DDLIST_H
#define LV_DDLIST_H
#ifndef LV_DROPDOWN_H
#define LV_DROPDOWN_H
#ifdef __cplusplus
extern "C" {
@ -15,7 +15,7 @@ extern "C" {
*********************/
#include "../lv_conf_internal.h"
#if LV_USE_DDLIST != 0
#if LV_USE_DROPDOWN != 0
/*Testing of dependencies*/
#if LV_USE_PAGE == 0
@ -39,13 +39,13 @@ extern "C" {
**********************/
enum {
LV_DDLIST_DIR_DOWN,
LV_DDLIST_DIR_UP,
LV_DDLIST_DIR_LEFT,
LV_DDLIST_DIR_RIGHT,
LV_DROPDOWN_DIR_DOWN,
LV_DROPDOWN_DIR_UP,
LV_DROPDOWN_DIR_LEFT,
LV_DROPDOWN_DIR_RIGHT,
};
typedef uint8_t lv_ddlist_dir_t;
typedef uint8_t lv_dropdown_dir_t;
/*Data of drop down list*/
typedef struct
@ -65,17 +65,17 @@ typedef struct
uint16_t sel_opt_id_orig; /*Store the original index on focus*/
uint16_t pr_opt_id; /*Index of the currently pressed option*/
uint16_t anim_time;
lv_ddlist_dir_t dir :2;
lv_dropdown_dir_t dir :2;
uint8_t show_selected :1;
} lv_ddlist_ext_t;
} lv_dropdown_ext_t;
enum {
LV_DDLIST_PART_BTN = LV_BTN_PART_MAIN,
LV_DDLIST_PART_LIST = _LV_BTN_PART_REAL_LAST,
LV_DDLIST_PART_SCRLBAR,
LV_DDLIST_PART_SELECTED,
LV_DROPDOWN_PART_BTN = LV_BTN_PART_MAIN,
LV_DROPDOWN_PART_LIST = _LV_BTN_PART_REAL_LAST,
LV_DROPDOWN_PART_SCRLBAR,
LV_DROPDOWN_PART_SELECTED,
};
typedef uint8_t lv_ddlist_part_t;
typedef uint8_t lv_dropdown_part_t;
/**********************
* GLOBAL PROTOTYPES
@ -87,7 +87,7 @@ typedef uint8_t lv_ddlist_part_t;
* from it
* @return pointer to the created drop down list
*/
lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy);
lv_obj_t * lv_dropdown_create(lv_obj_t * par, const lv_obj_t * copy);
/*=====================
* Setter functions
@ -98,21 +98,21 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy);
* @param ddlist pointer to a drop down list object
* @param txt the text as a string (Only it's pointer is saved)
*/
void lv_ddlist_set_text(lv_obj_t * ddlist, const char * txt);
void lv_dropdown_set_text(lv_obj_t * ddlist, const char * txt);
/**
* Set the options in a drop down list from a string
* @param ddlist pointer to drop down list object
* @param options a string with '\n' separated options. E.g. "One\nTwo\nThree"
*/
void lv_ddlist_set_options(lv_obj_t * ddlist, const char * options);
void lv_dropdown_set_options(lv_obj_t * ddlist, const char * options);
/**
* Set the selected option
* @param ddlist pointer to drop down list object
* @param sel_opt id of the selected option (0 ... number of option - 1);
*/
void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt);
void lv_dropdown_set_selected(lv_obj_t * ddlist, uint16_t sel_opt);
/**
* Set a maximum height for the drop down list
@ -120,21 +120,21 @@ void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt);
* @param ddlist pointer to a drop down list
* @param h the height when the list is opened (0: auto size)
*/
void lv_ddlist_set_max_height(lv_obj_t * ddlist, lv_coord_t h);
void lv_dropdown_set_max_height(lv_obj_t * ddlist, lv_coord_t h);
/**
* Set an arrow or other symbol to display when the drop-down list is closed.
* @param ddlist pointer to drop down list object
* @param symbol a text like `LV_SYMBOL_DOWN` or NULL to not draw icon
*/
void lv_ddlist_set_symbol(lv_obj_t * ddlist, const char * symbol);
void lv_dropdown_set_symbol(lv_obj_t * ddlist, const char * symbol);
/**
* Set the scroll bar mode of a drop down list
* @param ddlist pointer to a drop down list object
* @param sb_mode the new mode from 'lv_page_sb_mode_t' enum
*/
static inline void lv_ddlist_set_sb_mode(lv_obj_t * ddlist, lv_sb_mode_t mode)
static inline void lv_dropdown_set_sb_mode(lv_obj_t * ddlist, lv_sb_mode_t mode)
{
lv_page_set_sb_mode(ddlist, mode);
}
@ -143,7 +143,7 @@ static inline void lv_ddlist_set_sb_mode(lv_obj_t * ddlist, lv_sb_mode_t mode)
* @param ddlist pointer to a drop down list
* @param anim_time: open/close animation time [ms]
*/
static inline void lv_ddlist_set_anim_time(lv_obj_t * ddlist, uint16_t anim_time)
static inline void lv_dropdown_set_anim_time(lv_obj_t * ddlist, uint16_t anim_time)
{
lv_page_set_anim_time(ddlist, anim_time);
}
@ -151,16 +151,16 @@ static inline void lv_ddlist_set_anim_time(lv_obj_t * ddlist, uint16_t anim_time
/**
* Set the direction of the a drop down list
* @param ddlist pointer to a drop down list object
* @param dir LV_DDLIST_DIR_LEF/RIGHT/TOP/BOTTOM
* @param dir LV_DROPDOWN_DIR_LEF/RIGHT/TOP/BOTTOM
*/
void lv_ddlist_set_dir(lv_obj_t * ddlist, lv_ddlist_dir_t dir);
void lv_dropdown_set_dir(lv_obj_t * ddlist, lv_dropdown_dir_t dir);
/**
* Set whether the ddlist highlight the last selected option and display its text or not
* @param ddlist pointer to a drop down list object
* @param show true/false
*/
void lv_ddlist_set_show_selected(lv_obj_t * ddlist, bool show);
void lv_dropdown_set_show_selected(lv_obj_t * ddlist, bool show);
/*=====================
* Getter functions
@ -171,28 +171,28 @@ void lv_ddlist_set_show_selected(lv_obj_t * ddlist, bool show);
* @param ddlist pointer to a drop down list object
* @return the text string
*/
const char * lv_ddlist_get_text(lv_obj_t * ddlist);
const char * lv_dropdown_get_text(lv_obj_t * ddlist);
/**
* Get the options of a drop down list
* @param ddlist pointer to drop down list object
* @return the options separated by '\n'-s (E.g. "Option1\nOption2\nOption3")
*/
const char * lv_ddlist_get_options(const lv_obj_t * ddlist);
const char * lv_dropdown_get_options(const lv_obj_t * ddlist);
/**
* Get the selected option
* @param ddlist pointer to drop down list object
* @return id of the selected option (0 ... number of option - 1);
*/
uint16_t lv_ddlist_get_selected(const lv_obj_t * ddlist);
uint16_t lv_dropdown_get_selected(const lv_obj_t * ddlist);
/**
* Get the total number of options
* @param ddlist pointer to drop down list object
* @return the total number of options in the list
*/
uint16_t lv_ddlist_get_option_cnt(const lv_obj_t * ddlist);
uint16_t lv_dropdown_get_option_cnt(const lv_obj_t * ddlist);
/**
* Get the current selected option as a string
@ -200,42 +200,42 @@ uint16_t lv_ddlist_get_option_cnt(const lv_obj_t * ddlist);
* @param buf pointer to an array to store the string
* @param buf_size size of `buf` in bytes. 0: to ignore it.
*/
void lv_ddlist_get_selected_str(const lv_obj_t * ddlist, char * buf, uint16_t buf_size);
void lv_dropdown_get_selected_str(const lv_obj_t * ddlist, char * buf, uint16_t buf_size);
/**
* Get the fix height value.
* @param ddlist pointer to a drop down list object
* @return the height if the ddlist is opened (0: auto size)
*/
lv_coord_t lv_ddlist_get_max_height(const lv_obj_t * ddlist);
lv_coord_t lv_dropdown_get_max_height(const lv_obj_t * ddlist);
/**
* Get the symbol to draw when the drop-down list is closed
* @param ddlist pointer to drop down list object
* @return the symbol or NULL if not enabled
*/
const char * lv_ddlist_get_symbol(lv_obj_t * ddlist);
const char * lv_dropdown_get_symbol(lv_obj_t * ddlist);
/**
* Get the symbol to draw when the drop-down list is closed
* @param ddlist pointer to drop down list object
* @return the symbol or NULL if not enabled
*/
lv_ddlist_dir_t lv_ddlist_get_dir(const lv_obj_t * ddlist);
lv_dropdown_dir_t lv_dropdown_get_dir(const lv_obj_t * ddlist);
/**
* Get whether the ddlist highlight the last selected option and display its text or not
* @param ddlist pointer to a drop down list object
* @return true/false
*/
bool lv_ddlist_get_show_selected(lv_obj_t * ddlist);
bool lv_dropdown_get_show_selected(lv_obj_t * ddlist);
/**
* Get the scroll bar mode of a drop down list
* @param ddlist pointer to a drop down list object
* @return scrollbar mode from 'lv_page_sb_mode_t' enum
*/
static inline lv_sb_mode_t lv_ddlist_get_sb_mode(const lv_obj_t * ddlist)
static inline lv_sb_mode_t lv_dropdown_get_sb_mode(const lv_obj_t * ddlist)
{
return lv_page_get_sb_mode(ddlist);
}
@ -245,7 +245,7 @@ static inline lv_sb_mode_t lv_ddlist_get_sb_mode(const lv_obj_t * ddlist)
* @param ddlist pointer to a drop down list
* @return open/close animation time [ms]
*/
static inline uint16_t lv_ddlist_get_anim_time(const lv_obj_t * ddlist)
static inline uint16_t lv_dropdown_get_anim_time(const lv_obj_t * ddlist)
{
return lv_page_get_anim_time(ddlist);
}
@ -255,7 +255,7 @@ static inline uint16_t lv_ddlist_get_anim_time(const lv_obj_t * ddlist)
* @param ddlist pointer to a drop down list object
* @return alignment of labels
*/
lv_label_align_t lv_ddlist_get_align(const lv_obj_t * ddlist);
lv_label_align_t lv_dropdown_get_align(const lv_obj_t * ddlist);
/*=====================
* Other functions
@ -266,23 +266,23 @@ lv_label_align_t lv_ddlist_get_align(const lv_obj_t * ddlist);
* @param ddlist pointer to drop down list object
* @param anim_en LV_ANIM_ON: use animation; LV_ANOM_OFF: not use animations
*/
void lv_ddlist_open(lv_obj_t * ddlist, lv_anim_enable_t anim);
void lv_dropdown_open(lv_obj_t * ddlist, lv_anim_enable_t anim);
/**
* Close (Collapse) the drop down list
* @param ddlist pointer to drop down list object
* @param anim_en LV_ANIM_ON: use animation; LV_ANOM_OFF: not use animations
*/
void lv_ddlist_close(lv_obj_t * ddlist, lv_anim_enable_t anim);
void lv_dropdown_close(lv_obj_t * ddlist, lv_anim_enable_t anim);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DDLIST*/
#endif /*LV_USE_DROPDOWN*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_DDLIST_H*/
#endif /*LV_DROPDOWN_H*/

View File

@ -67,7 +67,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy)
LV_LOG_TRACE("gauge create started");
/*Create the ancestor gauge*/
lv_obj_t * new_gauge = lv_lmeter_create(par, copy);
lv_obj_t * new_gauge = lv_linemeter_create(par, copy);
LV_ASSERT_MEM(new_gauge);
if(new_gauge == NULL) return NULL;
@ -207,7 +207,7 @@ void lv_gauge_set_scale(lv_obj_t * gauge, uint16_t angle, uint8_t line_cnt, uint
{
LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
lv_lmeter_set_scale(gauge, angle, line_cnt);
lv_linemeter_set_scale(gauge, angle, line_cnt);
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
ext->label_count = label_cnt;
@ -358,7 +358,7 @@ static lv_design_res_t lv_gauge_design(lv_obj_t * gauge, const lv_area_t * clip_
/*Add the strong lines*/
uint16_t line_cnt_tmp = ext->lmeter.line_cnt;
ext->lmeter.line_cnt = ext->label_count; /*Only to labels*/
lv_lmeter_draw_scale(gauge, clip_area, LV_GAUGE_PART_STRONG);
lv_linemeter_draw_scale(gauge, clip_area, LV_GAUGE_PART_STRONG);
ext->lmeter.line_cnt = line_cnt_tmp; /*Restore the parameters*/
lv_gauge_draw_needle(gauge, clip_area);
@ -448,7 +448,7 @@ static void lv_gauge_draw_labels(lv_obj_t * gauge, const lv_area_t * mask)
lv_coord_t r = (lv_obj_get_width(gauge) - left - right) / 2 - scale_width - txt_pad;
lv_coord_t x_ofs = gauge->coords.x1 + r + left + scale_width + txt_pad;
lv_coord_t y_ofs = gauge->coords.y1 + r + top + scale_width + txt_pad;
int16_t scale_angle = lv_lmeter_get_scale_angle(gauge);
int16_t scale_angle = lv_linemeter_get_scale_angle(gauge);
uint16_t label_num = ext->label_count;
int16_t angle_ofs = 90 + (360 - scale_angle) / 2;
int16_t min = lv_gauge_get_min_value(gauge);
@ -504,7 +504,7 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * clip_area)
lv_coord_t r = (lv_obj_get_width(gauge) - left - right) / 2 - pad;
lv_coord_t x_ofs = gauge->coords.x1 + r + left + pad;
lv_coord_t y_ofs = gauge->coords.y1 + r + top + pad;
uint16_t angle = lv_lmeter_get_scale_angle(gauge);
uint16_t angle = lv_linemeter_get_scale_angle(gauge);
int16_t angle_ofs = 90 + (360 - angle) / 2;
int16_t min = lv_gauge_get_min_value(gauge);
int16_t max = lv_gauge_get_max_value(gauge);

View File

@ -19,11 +19,11 @@ extern "C" {
/*Testing of dependencies*/
#if LV_USE_LMETER == 0
#error "lv_gauge: lv_lmeter is required. Enable it in lv_conf.h (LV_USE_LMETER 1) "
#error "lv_gauge: lv_linemeter is required. Enable it in lv_conf.h (LV_USE_LMETER 1) "
#endif
#include "../lv_core/lv_obj.h"
#include "lv_lmeter.h"
#include "lv_linemeter.h"
#include "lv_label.h"
#include "lv_line.h"
@ -38,7 +38,7 @@ extern "C" {
/*Data of gauge*/
typedef struct
{
lv_lmeter_ext_t lmeter; /*Ext. of ancestor*/
lv_linemeter_ext_t lmeter; /*Ext. of ancestor*/
/*New data for this type */
int16_t * values; /*Array of the set values (for needles) */
const lv_color_t * needle_colors; /*Color of the needles (lv_color_t my_colors[needle_num])*/
@ -52,11 +52,11 @@ typedef struct
/*Styles*/
enum {
LV_GAUGE_PART_MAIN = LV_LMETER_PART_MAIN,
LV_GAUGE_PART_STRONG = _LV_LMETER_PART_VIRTUAL_LAST,
LV_GAUGE_PART_MAIN = LV_LINEMETER_PART_MAIN,
LV_GAUGE_PART_STRONG = _LV_LINEMETER_PART_VIRTUAL_LAST,
LV_GAUGE_PART_NEEDLE,
_LV_GAUGE_PART_VIRTUAL_LAST = _LV_LMETER_PART_VIRTUAL_LAST,
_LV_GAUGE_PART_REAL_LAST = _LV_LMETER_PART_REAL_LAST,
_LV_GAUGE_PART_VIRTUAL_LAST = _LV_LINEMETER_PART_VIRTUAL_LAST,
_LV_GAUGE_PART_REAL_LAST = _LV_LINEMETER_PART_REAL_LAST,
};
typedef uint8_t lv_gauge_style_t;
@ -100,7 +100,7 @@ void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int16_t value);
*/
static inline void lv_gauge_set_range(lv_obj_t * gauge, int16_t min, int16_t max)
{
lv_lmeter_set_range(gauge, min, max);
lv_linemeter_set_range(gauge, min, max);
}
/**
@ -110,7 +110,7 @@ static inline void lv_gauge_set_range(lv_obj_t * gauge, int16_t min, int16_t max
*/
static inline void lv_gauge_set_critical_value(lv_obj_t * gauge, int16_t value)
{
lv_lmeter_set_value(gauge, value);
lv_linemeter_set_value(gauge, value);
}
/**
@ -173,7 +173,7 @@ uint8_t lv_gauge_get_needle_count(const lv_obj_t * gauge);
*/
static inline int16_t lv_gauge_get_min_value(const lv_obj_t * lmeter)
{
return lv_lmeter_get_min_value(lmeter);
return lv_linemeter_get_min_value(lmeter);
}
/**
@ -183,7 +183,7 @@ static inline int16_t lv_gauge_get_min_value(const lv_obj_t * lmeter)
*/
static inline int16_t lv_gauge_get_max_value(const lv_obj_t * lmeter)
{
return lv_lmeter_get_max_value(lmeter);
return lv_linemeter_get_max_value(lmeter);
}
/**
@ -193,7 +193,7 @@ static inline int16_t lv_gauge_get_max_value(const lv_obj_t * lmeter)
*/
static inline int16_t lv_gauge_get_critical_value(const lv_obj_t * gauge)
{
return lv_lmeter_get_value(gauge);
return lv_linemeter_get_value(gauge);
}
/**
@ -210,7 +210,7 @@ uint8_t lv_gauge_get_label_count(const lv_obj_t * gauge);
*/
static inline uint16_t lv_gauge_get_line_count(const lv_obj_t * gauge)
{
return lv_lmeter_get_line_count(gauge);
return lv_linemeter_get_line_count(gauge);
}
/**
@ -220,7 +220,7 @@ static inline uint16_t lv_gauge_get_line_count(const lv_obj_t * gauge)
*/
static inline uint16_t lv_gauge_get_scale_angle(const lv_obj_t * gauge)
{
return lv_lmeter_get_scale_angle(gauge);
return lv_linemeter_get_scale_angle(gauge);
}
/**

View File

@ -8,7 +8,7 @@
* INCLUDES
*********************/
#include "lv_kb.h"
#if LV_USE_KB != 0
#if LV_USE_KEYBOARD != 0
#include "../lv_core/lv_debug.h"
#include "../lv_themes/lv_theme.h"
@ -17,9 +17,9 @@
/*********************
* DEFINES
*********************/
#define LV_OBJX_NAME "lv_kb"
#define LV_OBJX_NAME "lv_keyboard"
#define LV_KB_CTRL_BTN_FLAGS (LV_BTNM_CTRL_NO_REPEAT | LV_BTNM_CTRL_CLICK_TRIG)
#define LV_KEYBOARD_CTRL_BTN_FLAGS (LV_BTNMATRIX_CTRL_NO_REPEAT | LV_BTNMATRIX_CTRL_CLICK_TRIG)
/**********************
* TYPEDEFS
@ -28,8 +28,8 @@
/**********************
* STATIC PROTOTYPES
**********************/
static lv_res_t lv_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param);
static void lv_kb_update_map(lv_obj_t * kb);
static lv_res_t lv_keyboard_signal(lv_obj_t * kb, lv_signal_t sign, void * param);
static void lv_keyboard_update_map(lv_obj_t * kb);
/**********************
* STATIC VARIABLES
@ -41,42 +41,42 @@ static const char * const default_kb_map_lc[] = {"1#", "q", "w", "e", "r", "t",
"_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n",
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
static const lv_btnm_ctrl_t default_kb_ctrl_lc_map[] = {
LV_KB_CTRL_BTN_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7,
LV_KB_CTRL_BTN_FLAGS | 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7,
static const lv_btnmatrix_ctrl_t default_kb_ctrl_lc_map[] = {
LV_KEYBOARD_CTRL_BTN_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7,
LV_KEYBOARD_CTRL_BTN_FLAGS | 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7,
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_KEYBOARD_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KEYBOARD_CTRL_BTN_FLAGS | 2};
static const char * const default_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", LV_SYMBOL_NEW_LINE, "\n",
"_", "-", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ":", "\n",
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
static const lv_btnm_ctrl_t default_kb_ctrl_uc_map[] = {
LV_KB_CTRL_BTN_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7,
LV_KB_CTRL_BTN_FLAGS | 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7,
static const lv_btnmatrix_ctrl_t default_kb_ctrl_uc_map[] = {
LV_KEYBOARD_CTRL_BTN_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7,
LV_KEYBOARD_CTRL_BTN_FLAGS | 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7,
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_KEYBOARD_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KEYBOARD_CTRL_BTN_FLAGS | 2};
static const char * const default_kb_map_spec[] = {"0", "1", "2", "3", "4" ,"5", "6", "7", "8", "9", LV_SYMBOL_BACKSPACE, "\n",
"abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
"\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
static const lv_btnm_ctrl_t default_kb_ctrl_spec_map[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2,
LV_KB_CTRL_BTN_FLAGS | 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
static const lv_btnmatrix_ctrl_t default_kb_ctrl_spec_map[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, LV_KEYBOARD_CTRL_BTN_FLAGS | 2,
LV_KEYBOARD_CTRL_BTN_FLAGS | 2, 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_KEYBOARD_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KEYBOARD_CTRL_BTN_FLAGS | 2};
static const char * const default_kb_map_num[] = {"1", "2", "3", LV_SYMBOL_CLOSE, "\n",
"4", "5", "6", LV_SYMBOL_OK, "\n",
"7", "8", "9", LV_SYMBOL_BACKSPACE, "\n",
"+/-", "0", ".", LV_SYMBOL_LEFT, LV_SYMBOL_RIGHT, ""};
static const lv_btnm_ctrl_t default_kb_ctrl_num_map[] = {
1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2,
1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2,
static const lv_btnmatrix_ctrl_t default_kb_ctrl_num_map[] = {
1, 1, 1, LV_KEYBOARD_CTRL_BTN_FLAGS | 2,
1, 1, 1, LV_KEYBOARD_CTRL_BTN_FLAGS | 2,
1, 1, 1, 2,
1, 1, 1, 1, 1};
/* clang-format on */
@ -87,7 +87,7 @@ static const char * * kb_map[4] = {
(const char * *)default_kb_map_spec,
(const char * *)default_kb_map_num
};
static const lv_btnm_ctrl_t * kb_ctrl[4] = {
static const lv_btnmatrix_ctrl_t * kb_ctrl[4] = {
default_kb_ctrl_lc_map,
default_kb_ctrl_uc_map,
default_kb_ctrl_spec_map,
@ -108,19 +108,19 @@ static const lv_btnm_ctrl_t * kb_ctrl[4] = {
* @param copy pointer to a keyboard object, if not NULL then the new object will be copied from it
* @return pointer to the created keyboard
*/
lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_t * lv_keyboard_create(lv_obj_t * par, const lv_obj_t * copy)
{
LV_LOG_TRACE("keyboard create started");
/*Create the ancestor of keyboard*/
lv_obj_t * kb = lv_btnm_create(par, copy);
lv_obj_t * kb = lv_btnmatrix_create(par, copy);
LV_ASSERT_MEM(kb);
if(kb == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(kb);
/*Allocate the keyboard type specific extended data*/
lv_kb_ext_t * ext = lv_obj_allocate_ext_attr(kb, sizeof(lv_kb_ext_t));
lv_keyboard_ext_t * ext = lv_obj_allocate_ext_attr(kb, sizeof(lv_keyboard_ext_t));
LV_ASSERT_MEM(ext);
if(ext == NULL) {
lv_obj_del(kb);
@ -130,11 +130,11 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
/*Initialize the allocated 'ext' */
ext->ta = NULL;
ext->mode = LV_KB_MODE_TEXT_LOWER;
ext->mode = LV_KEYBOARD_MODE_TEXT_LOWER;
ext->cursor_mng = 0;
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_cb(kb, lv_kb_signal);
lv_obj_set_signal_cb(kb, lv_keyboard_signal);
/*Init the new keyboard keyboard*/
if(copy == NULL) {
@ -144,25 +144,25 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_set_size(kb, lv_obj_get_width_fit(lv_obj_get_parent(kb)),
lv_obj_get_height_fit(lv_obj_get_parent(kb)) / 2);
lv_obj_align(kb, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
lv_obj_set_event_cb(kb, lv_kb_def_event_cb);
lv_obj_set_event_cb(kb, lv_keyboard_def_event_cb);
lv_obj_set_base_dir(kb, LV_BIDI_DIR_LTR);
lv_btnm_set_map(kb, kb_map[ext->mode]);
lv_btnm_set_ctrl_map(kb, kb_ctrl[ext->mode]);
lv_btnmatrix_set_map(kb, kb_map[ext->mode]);
lv_btnmatrix_set_ctrl_map(kb, kb_ctrl[ext->mode]);
lv_theme_apply(kb, LV_THEME_KB);
}
/*Copy an existing keyboard*/
else {
lv_kb_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
lv_keyboard_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->ta = NULL;
ext->ta = copy_ext->ta;
ext->mode = copy_ext->mode;
ext->cursor_mng = copy_ext->cursor_mng;
lv_btnm_set_map(kb, kb_map[ext->mode]);
lv_btnm_set_ctrl_map(kb, kb_ctrl[ext->mode]);
lv_btnmatrix_set_map(kb, kb_map[ext->mode]);
lv_btnmatrix_set_ctrl_map(kb, kb_ctrl[ext->mode]);
/*Refresh the style with new signal function*/
// lv_obj_refresh_style(new_kb);
@ -182,41 +182,41 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
* @param kb pointer to a Keyboard object
* @param ta pointer to a Text Area object to write there
*/
void lv_kb_set_ta(lv_obj_t * kb, lv_obj_t * ta)
void lv_keyboard_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_keyboard_ext_t * ext = lv_obj_get_ext_attr(kb);
/*Hide the cursor of the old Text area if cursor management is enabled*/
if(ext->ta && ext->cursor_mng) {
lv_ta_set_cursor_hidden(ext->ta, true);
lv_textarea_set_cursor_hidden(ext->ta, true);
}
ext->ta = ta;
/*Show the cursor of the new Text area if cursor management is enabled*/
if(ext->ta && ext->cursor_mng) {
lv_ta_set_cursor_hidden(ext->ta, false);
lv_textarea_set_cursor_hidden(ext->ta, false);
}
}
/**
* Set a new a mode (text or number map)
* @param kb pointer to a Keyboard object
* @param mode the mode from 'lv_kb_mode_t'
* @param mode the mode from 'lv_keyboard_mode_t'
*/
void lv_kb_set_mode(lv_obj_t * kb, lv_kb_mode_t mode)
void lv_keyboard_set_mode(lv_obj_t * kb, lv_keyboard_mode_t mode)
{
LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
lv_keyboard_ext_t * ext = lv_obj_get_ext_attr(kb);
if(ext->mode == mode) return;
ext->mode = mode;
lv_btnm_set_map(kb, kb_map[mode]);
lv_btnm_set_ctrl_map(kb, kb_ctrl[mode]);
lv_btnmatrix_set_map(kb, kb_map[mode]);
lv_btnmatrix_set_ctrl_map(kb, kb_ctrl[mode]);
}
/**
@ -224,11 +224,11 @@ void lv_kb_set_mode(lv_obj_t * kb, lv_kb_mode_t mode)
* @param kb pointer to a Keyboard object
* @param en true: show cursor on the current text area, false: hide cursor
*/
void lv_kb_set_cursor_manage(lv_obj_t * kb, bool en)
void lv_keyboard_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_keyboard_ext_t * ext = lv_obj_get_ext_attr(kb);
if(ext->cursor_mng == en) return;
ext->cursor_mng = en == false ? 0 : 1;
@ -236,9 +236,9 @@ void lv_kb_set_cursor_manage(lv_obj_t * kb, bool en)
if(ext->ta) {
if(ext->cursor_mng) {
lv_ta_set_cursor_hidden(ext->ta, false);
lv_textarea_set_cursor_hidden(ext->ta, false);
} else {
lv_ta_set_cursor_hidden(ext->ta, true);
lv_textarea_set_cursor_hidden(ext->ta, true);
}
}
}
@ -246,14 +246,14 @@ void lv_kb_set_cursor_manage(lv_obj_t * kb, bool en)
/**
* Set a new map for the keyboard
* @param kb pointer to a Keyboard object
* @param mode keyboard map to alter 'lv_kb_mode_t'
* @param mode keyboard map to alter 'lv_keyboard_mode_t'
* @param map pointer to a string array to describe the map.
* See 'lv_btnm_set_map()' for more info.
* See 'lv_btnmatrix_set_map()' for more info.
*/
void lv_kb_set_map(lv_obj_t * kb, lv_kb_mode_t mode, const char * map[])
void lv_keyboard_set_map(lv_obj_t * kb, lv_keyboard_mode_t mode, const char * map[])
{
kb_map[mode] = map;
lv_kb_update_map(kb);
lv_keyboard_update_map(kb);
}
/**
@ -261,14 +261,14 @@ void lv_kb_set_map(lv_obj_t * kb, lv_kb_mode_t mode, const char * map[])
* control map array will be copied and so may be deallocated after this
* function returns.
* @param kb pointer to a keyboard object
* @param mode keyboard ctrl map to alter 'lv_kb_mode_t'
* @param mode keyboard ctrl map to alter 'lv_keyboard_mode_t'
* @param ctrl_map pointer to an array of `lv_btn_ctrl_t` control bytes.
* See: `lv_btnm_set_ctrl_map` for more details.
* See: `lv_btnmatrix_set_ctrl_map` for more details.
*/
void lv_kb_set_ctrl_map(lv_obj_t * kb, lv_kb_mode_t mode, const lv_btnm_ctrl_t ctrl_map[])
void lv_keyboard_set_ctrl_map(lv_obj_t * kb, lv_keyboard_mode_t mode, const lv_btnmatrix_ctrl_t ctrl_map[])
{
kb_ctrl[mode] = ctrl_map;
lv_kb_update_map(kb);
lv_keyboard_update_map(kb);
}
/*=====================
@ -280,24 +280,24 @@ void lv_kb_set_ctrl_map(lv_obj_t * kb, lv_kb_mode_t mode, const lv_btnm_ctrl_t c
* @param kb pointer to a Keyboard object
* @return pointer to the assigned Text Area object
*/
lv_obj_t * lv_kb_get_ta(const lv_obj_t * kb)
lv_obj_t * lv_keyboard_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_keyboard_ext_t * ext = lv_obj_get_ext_attr(kb);
return ext->ta;
}
/**
* Set a new a mode (text or number map)
* @param kb pointer to a Keyboard object
* @return the current mode from 'lv_kb_mode_t'
* @return the current mode from 'lv_keyboard_mode_t'
*/
lv_kb_mode_t lv_kb_get_mode(const lv_obj_t * kb)
lv_keyboard_mode_t lv_keyboard_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_keyboard_ext_t * ext = lv_obj_get_ext_attr(kb);
return ext->mode;
}
@ -306,11 +306,11 @@ lv_kb_mode_t lv_kb_get_mode(const lv_obj_t * kb)
* @param kb pointer to a Keyboard object
* @return true: show cursor on the current text area, false: hide cursor
*/
bool lv_kb_get_cursor_manage(const lv_obj_t * kb)
bool lv_keyboard_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_keyboard_ext_t * ext = lv_obj_get_ext_attr(kb);
return ext->cursor_mng == 0 ? false : true;
}
@ -325,53 +325,53 @@ bool lv_kb_get_cursor_manage(const lv_obj_t * kb)
* @param kb pointer to a keyboard
* @param event the triggering event
*/
void lv_kb_def_event_cb(lv_obj_t * kb, lv_event_t event)
void lv_keyboard_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;
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
uint16_t btn_id = lv_btnm_get_active_btn(kb);
if(btn_id == LV_BTNM_BTN_NONE) return;
if(lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_HIDDEN | LV_BTNM_CTRL_INACTIVE)) return;
if(lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_NO_REPEAT) && event == LV_EVENT_LONG_PRESSED_REPEAT) return;
lv_keyboard_ext_t * ext = lv_obj_get_ext_attr(kb);
uint16_t btn_id = lv_btnmatrix_get_active_btn(kb);
if(btn_id == LV_BTNMATRIX_BTN_NONE) return;
if(lv_btnmatrix_get_btn_ctrl(kb, btn_id, LV_BTNMATRIX_CTRL_HIDDEN | LV_BTNMATRIX_CTRL_INACTIVE)) return;
if(lv_btnmatrix_get_btn_ctrl(kb, btn_id, LV_BTNMATRIX_CTRL_NO_REPEAT) && event == LV_EVENT_LONG_PRESSED_REPEAT) return;
const char * txt = lv_btnm_get_active_btn_text(kb);
const char * txt = lv_btnmatrix_get_active_btn_text(kb);
if(txt == NULL) return;
/*Do the corresponding action according to the text of the button*/
if(strcmp(txt, "abc") == 0) {
ext->mode = LV_KB_MODE_TEXT_LOWER;
lv_btnm_set_map(kb, kb_map[LV_KB_MODE_TEXT_LOWER]);
lv_btnm_set_ctrl_map(kb, kb_ctrl[LV_KB_MODE_TEXT_LOWER]);
ext->mode = LV_KEYBOARD_MODE_TEXT_LOWER;
lv_btnmatrix_set_map(kb, kb_map[LV_KEYBOARD_MODE_TEXT_LOWER]);
lv_btnmatrix_set_ctrl_map(kb, kb_ctrl[LV_KEYBOARD_MODE_TEXT_LOWER]);
return;
} else if(strcmp(txt, "ABC") == 0) {
ext->mode = LV_KB_MODE_TEXT_UPPER;
lv_btnm_set_map(kb, kb_map[LV_KB_MODE_TEXT_UPPER]);
lv_btnm_set_ctrl_map(kb, kb_ctrl[LV_KB_MODE_TEXT_UPPER]);
ext->mode = LV_KEYBOARD_MODE_TEXT_UPPER;
lv_btnmatrix_set_map(kb, kb_map[LV_KEYBOARD_MODE_TEXT_UPPER]);
lv_btnmatrix_set_ctrl_map(kb, kb_ctrl[LV_KEYBOARD_MODE_TEXT_UPPER]);
return;
} else if(strcmp(txt, "1#") == 0) {
ext->mode = LV_KB_MODE_SPECIAL;
lv_btnm_set_map(kb, kb_map[LV_KB_MODE_SPECIAL]);
lv_btnm_set_ctrl_map(kb, kb_ctrl[LV_KB_MODE_SPECIAL]);
ext->mode = LV_KEYBOARD_MODE_SPECIAL;
lv_btnmatrix_set_map(kb, kb_map[LV_KEYBOARD_MODE_SPECIAL]);
lv_btnmatrix_set_ctrl_map(kb, kb_ctrl[LV_KEYBOARD_MODE_SPECIAL]);
return;
} else if(strcmp(txt, LV_SYMBOL_CLOSE) == 0) {
if(kb->event_cb != lv_kb_def_event_cb) {
if(kb->event_cb != lv_keyboard_def_event_cb) {
lv_res_t res = lv_event_send(kb, LV_EVENT_CANCEL, NULL);
if(res != LV_RES_OK) return;
} else {
lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
lv_keyboard_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
lv_obj_del(kb);
return;
}
return;
} else if(strcmp(txt, LV_SYMBOL_OK) == 0) {
if(kb->event_cb != lv_kb_def_event_cb) {
if(kb->event_cb != lv_keyboard_def_event_cb) {
lv_res_t res = lv_event_send(kb, LV_EVENT_APPLY, NULL);
if(res != LV_RES_OK) return;
} else {
lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
lv_keyboard_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
}
return;
}
@ -380,33 +380,33 @@ void lv_kb_def_event_cb(lv_obj_t * kb, lv_event_t event)
if(ext->ta == NULL) return;
if(strcmp(txt, "Enter") == 0 || strcmp(txt, LV_SYMBOL_NEW_LINE) == 0)
lv_ta_add_char(ext->ta, '\n');
lv_textarea_add_char(ext->ta, '\n');
else if(strcmp(txt, LV_SYMBOL_LEFT) == 0)
lv_ta_cursor_left(ext->ta);
lv_textarea_cursor_left(ext->ta);
else if(strcmp(txt, LV_SYMBOL_RIGHT) == 0)
lv_ta_cursor_right(ext->ta);
lv_textarea_cursor_right(ext->ta);
else if(strcmp(txt, LV_SYMBOL_BACKSPACE) == 0)
lv_ta_del_char(ext->ta);
lv_textarea_del_char(ext->ta);
else if(strcmp(txt, "+/-") == 0) {
uint16_t cur = lv_ta_get_cursor_pos(ext->ta);
const char * ta_txt = lv_ta_get_text(ext->ta);
uint16_t cur = lv_textarea_get_cursor_pos(ext->ta);
const char * ta_txt = lv_textarea_get_text(ext->ta);
if(ta_txt[0] == '-') {
lv_ta_set_cursor_pos(ext->ta, 1);
lv_ta_del_char(ext->ta);
lv_ta_add_char(ext->ta, '+');
lv_ta_set_cursor_pos(ext->ta, cur);
lv_textarea_set_cursor_pos(ext->ta, 1);
lv_textarea_del_char(ext->ta);
lv_textarea_add_char(ext->ta, '+');
lv_textarea_set_cursor_pos(ext->ta, cur);
} else if(ta_txt[0] == '+') {
lv_ta_set_cursor_pos(ext->ta, 1);
lv_ta_del_char(ext->ta);
lv_ta_add_char(ext->ta, '-');
lv_ta_set_cursor_pos(ext->ta, cur);
lv_textarea_set_cursor_pos(ext->ta, 1);
lv_textarea_del_char(ext->ta);
lv_textarea_add_char(ext->ta, '-');
lv_textarea_set_cursor_pos(ext->ta, cur);
} else {
lv_ta_set_cursor_pos(ext->ta, 0);
lv_ta_add_char(ext->ta, '-');
lv_ta_set_cursor_pos(ext->ta, cur + 1);
lv_textarea_set_cursor_pos(ext->ta, 0);
lv_textarea_add_char(ext->ta, '-');
lv_textarea_set_cursor_pos(ext->ta, cur + 1);
}
} else {
lv_ta_add_text(ext->ta, txt);
lv_textarea_add_text(ext->ta, txt);
}
}
@ -421,7 +421,7 @@ void lv_kb_def_event_cb(lv_obj_t * kb, lv_event_t event)
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static lv_res_t lv_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param)
static lv_res_t lv_keyboard_signal(lv_obj_t * kb, lv_signal_t sign, void * param)
{
lv_res_t res;
@ -433,16 +433,16 @@ static lv_res_t lv_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param)
if(sign == LV_SIGNAL_CLEANUP) {
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
} else if(sign == LV_SIGNAL_FOCUS) {
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
lv_keyboard_ext_t * ext = lv_obj_get_ext_attr(kb);
/*Show the cursor of the Text area if cursor management is enabled*/
if(ext->ta && ext->cursor_mng) {
lv_ta_set_cursor_hidden(ext->ta, false);
lv_textarea_set_cursor_hidden(ext->ta, false);
}
} else if(sign == LV_SIGNAL_DEFOCUS) {
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
lv_keyboard_ext_t * ext = lv_obj_get_ext_attr(kb);
/*Show the cursor of the Text area if cursor management is enabled*/
if(ext->ta && ext->cursor_mng) {
lv_ta_set_cursor_hidden(ext->ta, true);
lv_textarea_set_cursor_hidden(ext->ta, true);
}
}
@ -453,11 +453,11 @@ static lv_res_t lv_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param)
* Update the key map for the current mode
* @param kb pointer to a keyboard object
*/
static void lv_kb_update_map(lv_obj_t * kb)
static void lv_keyboard_update_map(lv_obj_t * kb)
{
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
lv_btnm_set_map(kb, kb_map[ext->mode]);
lv_btnm_set_ctrl_map(kb, kb_ctrl[ext->mode]);
lv_keyboard_ext_t * ext = lv_obj_get_ext_attr(kb);
lv_btnmatrix_set_map(kb, kb_map[ext->mode]);
lv_btnmatrix_set_ctrl_map(kb, kb_ctrl[ext->mode]);
}
#endif

View File

@ -3,8 +3,8 @@
*
*/
#ifndef LV_KB_H
#define LV_KB_H
#ifndef LV_KEYBOARD_H
#define LV_KEYBOARD_H
#ifdef __cplusplus
extern "C" {
@ -15,15 +15,15 @@ extern "C" {
*********************/
#include "../lv_conf_internal.h"
#if LV_USE_KB != 0
#if LV_USE_KEYBOARD != 0
/*Testing of dependencies*/
#if LV_USE_BTNM == 0
#error "lv_kb: lv_btnm is required. Enable it in lv_conf.h (LV_USE_BTNM 1) "
#if LV_USE_BTNMATRIX == 0
#error "lv_kb: lv_btnm is required. Enable it in lv_conf.h (LV_USE_BTNMATRIX 1) "
#endif
#if LV_USE_TA == 0
#error "lv_kb: lv_ta is required. Enable it in lv_conf.h (LV_USE_TA 1) "
#if LV_USE_TEXTAREA == 0
#error "lv_kb: lv_ta is required. Enable it in lv_conf.h (LV_USE_TEXTAREA 1) "
#endif
#include "../lv_core/lv_obj.h"
@ -39,28 +39,28 @@ extern "C" {
/** Current keyboard mode. */
enum {
LV_KB_MODE_TEXT_LOWER,
LV_KB_MODE_TEXT_UPPER,
LV_KB_MODE_SPECIAL,
LV_KB_MODE_NUM,
LV_KEYBOARD_MODE_TEXT_LOWER,
LV_KEYBOARD_MODE_TEXT_UPPER,
LV_KEYBOARD_MODE_SPECIAL,
LV_KEYBOARD_MODE_NUM,
};
typedef uint8_t lv_kb_mode_t;
typedef uint8_t lv_keyboard_mode_t;
/*Data of keyboard*/
typedef struct
{
lv_btnm_ext_t btnm; /*Ext. of ancestor*/
lv_btnmatrix_ext_t btnm; /*Ext. of ancestor*/
/*New data for this type */
lv_obj_t * ta; /*Pointer to the assigned text area*/
lv_kb_mode_t mode; /*Key map type*/
lv_keyboard_mode_t mode; /*Key map type*/
uint8_t cursor_mng : 1; /*1: automatically show/hide cursor when a text area is assigned or left*/
} lv_kb_ext_t;
} lv_keyboard_ext_t;
enum {
LV_KB_PART_BG,
LV_KB_PART_BTN,
LV_KEYBOARD_PART_BG,
LV_KEYBOARD_PART_BTN,
};
typedef uint8_t lv_kb_style_t;
typedef uint8_t lv_keyboard_style_t;
/**********************
* GLOBAL PROTOTYPES
@ -72,7 +72,7 @@ typedef uint8_t lv_kb_style_t;
* @param copy pointer to a keyboard object, if not NULL then the new object will be copied from it
* @return pointer to the created keyboard
*/
lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy);
lv_obj_t * lv_keyboard_create(lv_obj_t * par, const lv_obj_t * copy);
/*=====================
* Setter functions
@ -83,41 +83,41 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy);
* @param kb pointer to a Keyboard object
* @param ta pointer to a Text Area object to write there
*/
void lv_kb_set_ta(lv_obj_t * kb, lv_obj_t * ta);
void lv_keyboard_set_ta(lv_obj_t * kb, lv_obj_t * ta);
/**
* Set a new a mode (text or number map)
* @param kb pointer to a Keyboard object
* @param mode the mode from 'lv_kb_mode_t'
* @param mode the mode from 'lv_keyboard_mode_t'
*/
void lv_kb_set_mode(lv_obj_t * kb, lv_kb_mode_t mode);
void lv_keyboard_set_mode(lv_obj_t * kb, lv_keyboard_mode_t mode);
/**
* Automatically hide or show the cursor of the current Text Area
* @param kb pointer to a Keyboard object
* @param en true: show cursor on the current text area, false: hide cursor
*/
void lv_kb_set_cursor_manage(lv_obj_t * kb, bool en);
void lv_keyboard_set_cursor_manage(lv_obj_t * kb, bool en);
/**
* Set a new map for the keyboard
* @param kb pointer to a Keyboard object
* @param mode keyboard map to alter 'lv_kb_mode_t'
* @param mode keyboard map to alter 'lv_keyboard_mode_t'
* @param map pointer to a string array to describe the map.
* See 'lv_btnm_set_map()' for more info.
* See 'lv_btnmatrix_set_map()' for more info.
*/
void lv_kb_set_map(lv_obj_t * kb, lv_kb_mode_t mode, const char * map[]);
void lv_keyboard_set_map(lv_obj_t * kb, lv_keyboard_mode_t mode, const char * map[]);
/**
* Set the button control map (hidden, disabled etc.) for the keyboard. The
* control map array will be copied and so may be deallocated after this
* function returns.
* @param kb pointer to a keyboard object
* @param mode keyboard ctrl map to alter 'lv_kb_mode_t'
* @param mode keyboard ctrl map to alter 'lv_keyboard_mode_t'
* @param ctrl_map pointer to an array of `lv_btn_ctrl_t` control bytes.
* See: `lv_btnm_set_ctrl_map` for more details.
* See: `lv_btnmatrix_set_ctrl_map` for more details.
*/
void lv_kb_set_ctrl_map(lv_obj_t * kb, lv_kb_mode_t mode, const lv_btnm_ctrl_t ctrl_map[]);
void lv_keyboard_set_ctrl_map(lv_obj_t * kb, lv_keyboard_mode_t mode, const lv_btnmatrix_ctrl_t ctrl_map[]);
/*=====================
* Getter functions
@ -128,30 +128,30 @@ void lv_kb_set_ctrl_map(lv_obj_t * kb, lv_kb_mode_t mode, const lv_btnm_ctrl_t c
* @param kb pointer to a Keyboard object
* @return pointer to the assigned Text Area object
*/
lv_obj_t * lv_kb_get_ta(const lv_obj_t * kb);
lv_obj_t * lv_keyboard_get_ta(const lv_obj_t * kb);
/**
* Set a new a mode (text or number map)
* @param kb pointer to a Keyboard object
* @return the current mode from 'lv_kb_mode_t'
* @return the current mode from 'lv_keyboard_mode_t'
*/
lv_kb_mode_t lv_kb_get_mode(const lv_obj_t * kb);
lv_keyboard_mode_t lv_keyboard_get_mode(const lv_obj_t * kb);
/**
* Get the current cursor manage mode.
* @param kb pointer to a Keyboard object
* @return true: show cursor on the current text area, false: hide cursor
*/
bool lv_kb_get_cursor_manage(const lv_obj_t * kb);
bool lv_keyboard_get_cursor_manage(const lv_obj_t * kb);
/**
* Get the current map of a keyboard
* @param kb pointer to a keyboard object
* @return the current map
*/
static inline const char ** lv_kb_get_map_array(const lv_obj_t * kb)
static inline const char ** lv_keyboard_get_map_array(const lv_obj_t * kb)
{
return lv_btnm_get_map_array(kb);
return lv_btnmatrix_get_map_array(kb);
}
/*=====================
@ -165,16 +165,16 @@ static inline const char ** lv_kb_get_map_array(const lv_obj_t * kb)
* @param kb pointer to a keyboard
* @param event the triggering event
*/
void lv_kb_def_event_cb(lv_obj_t * kb, lv_event_t event);
void lv_keyboard_def_event_cb(lv_obj_t * kb, lv_event_t event);
/**********************
* MACROS
**********************/
#endif /*LV_USE_KB*/
#endif /*LV_USE_KEYBOARD*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_KB_H*/
#endif /*LV_KEYBOARD_H*/

View File

@ -1,12 +1,12 @@
/**
* @file lv_lmeter.c
* @file lv_linemeter.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_lmeter.h"
#include "lv_linemeter.h"
#if LV_USE_LMETER != 0
#include "../lv_core/lv_debug.h"
@ -18,7 +18,7 @@
/*********************
* DEFINES
*********************/
#define LV_OBJX_NAME "lv_lmeter"
#define LV_OBJX_NAME "lv_linemeter"
/**********************
* TYPEDEFS
@ -27,8 +27,8 @@
/**********************
* STATIC PROTOTYPES
**********************/
static lv_design_res_t lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_res_t lv_lmeter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * param);
static lv_design_res_t lv_linemeter_design(lv_obj_t * lmeter, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_res_t lv_linemeter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * param);
/**********************
* STATIC VARIABLES
@ -50,7 +50,7 @@ static lv_signal_cb_t ancestor_signal;
* it
* @return pointer to the created line meter
*/
lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_t * lv_linemeter_create(lv_obj_t * par, const lv_obj_t * copy)
{
LV_LOG_TRACE("line meter create started");
@ -62,7 +62,7 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy)
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_lmeter);
/*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_linemeter_ext_t * ext = lv_obj_allocate_ext_attr(new_lmeter, sizeof(lv_linemeter_ext_t));
LV_ASSERT_MEM(ext);
if(ext == NULL) {
lv_obj_del(new_lmeter);
@ -78,8 +78,8 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy)
ext->angle_ofs = 0;
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_cb(new_lmeter, lv_lmeter_signal);
lv_obj_set_design_cb(new_lmeter, lv_lmeter_design);
lv_obj_set_signal_cb(new_lmeter, lv_linemeter_signal);
lv_obj_set_design_cb(new_lmeter, lv_linemeter_design);
/*Init the new line meter line meter*/
if(copy == NULL) {
@ -88,7 +88,7 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy)
}
/*Copy an existing line meter*/
else {
lv_lmeter_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
lv_linemeter_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->scale_angle = copy_ext->scale_angle;
ext->line_cnt = copy_ext->line_cnt;
ext->min_value = copy_ext->min_value;
@ -113,11 +113,11 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy)
* @param lmeter pointer to a line meter object
* @param value new value
*/
void lv_lmeter_set_value(lv_obj_t * lmeter, int16_t value)
void lv_linemeter_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_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
if(ext->cur_value == value) return;
ext->cur_value = value > ext->max_value ? ext->max_value : value;
@ -131,22 +131,22 @@ void lv_lmeter_set_value(lv_obj_t * lmeter, int16_t value)
* @param min minimum value
* @param max maximum value
*/
void lv_lmeter_set_range(lv_obj_t * lmeter, int16_t min, int16_t max)
void lv_linemeter_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_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
if(ext->min_value == min && ext->max_value == max) return;
ext->max_value = max;
ext->min_value = min;
if(ext->cur_value > max) {
ext->cur_value = max;
lv_lmeter_set_value(lmeter, ext->cur_value);
lv_linemeter_set_value(lmeter, ext->cur_value);
}
if(ext->cur_value < min) {
ext->cur_value = min;
lv_lmeter_set_value(lmeter, ext->cur_value);
lv_linemeter_set_value(lmeter, ext->cur_value);
}
lv_obj_invalidate(lmeter);
}
@ -157,11 +157,11 @@ void lv_lmeter_set_range(lv_obj_t * lmeter, int16_t min, int16_t max)
* @param angle angle of the scale (0..360)
* @param line_cnt number of lines
*/
void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint16_t line_cnt)
void lv_linemeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint16_t line_cnt)
{
LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME);
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
lv_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
if(ext->scale_angle == angle && ext->line_cnt == line_cnt) return;
ext->scale_angle = angle;
@ -175,9 +175,9 @@ void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint16_t line_cnt)
* @param lmeter pointer to a line meter object
* @param angle angle where the meter will be facing (with its center)
*/
void lv_lmeter_set_angle_offset(lv_obj_t * lmeter, uint16_t angle)
void lv_linemeter_set_angle_offset(lv_obj_t * lmeter, uint16_t angle)
{
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
lv_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
if(ext->angle_ofs == angle) return;
ext->angle_ofs = angle;
@ -194,11 +194,11 @@ void lv_lmeter_set_angle_offset(lv_obj_t * lmeter, uint16_t angle)
* @param lmeter pointer to a line meter object
* @return the value of the line meter
*/
int16_t lv_lmeter_get_value(const lv_obj_t * lmeter)
int16_t lv_linemeter_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_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
return ext->cur_value;
}
@ -207,11 +207,11 @@ int16_t lv_lmeter_get_value(const lv_obj_t * lmeter)
* @param lmeter pointer to a line meter object
* @return the minimum value of the line meter
*/
int16_t lv_lmeter_get_min_value(const lv_obj_t * lmeter)
int16_t lv_linemeter_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_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
return ext->min_value;
}
@ -220,11 +220,11 @@ int16_t lv_lmeter_get_min_value(const lv_obj_t * lmeter)
* @param lmeter pointer to a line meter object
* @return the maximum value of the line meter
*/
int16_t lv_lmeter_get_max_value(const lv_obj_t * lmeter)
int16_t lv_linemeter_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_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
return ext->max_value;
}
@ -233,11 +233,11 @@ int16_t lv_lmeter_get_max_value(const lv_obj_t * lmeter)
* @param lmeter pointer to a line meter object
* @return number of the scale units
*/
uint16_t lv_lmeter_get_line_count(const lv_obj_t * lmeter)
uint16_t lv_linemeter_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_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
return ext->line_cnt;
}
@ -246,11 +246,11 @@ uint16_t lv_lmeter_get_line_count(const lv_obj_t * lmeter)
* @param lmeter pointer to a line meter object
* @return angle_ofs of the scale
*/
uint16_t lv_lmeter_get_scale_angle(const lv_obj_t * lmeter)
uint16_t lv_linemeter_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_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
return ext->scale_angle;
}
@ -259,20 +259,20 @@ uint16_t lv_lmeter_get_scale_angle(const lv_obj_t * lmeter)
* @param lmeter pointer to a line meter object
* @return angle offset (0..360)
*/
uint16_t lv_lmeter_get_angle_offset(lv_obj_t * lmeter)
uint16_t lv_linemeter_get_angle_offset(lv_obj_t * lmeter)
{
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
lv_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
return ext->angle_ofs;
}
void lv_lmeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uint8_t part)
void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uint8_t part)
{
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
lv_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
lv_style_int_t left = lv_obj_get_style_pad_left(lmeter, LV_LMETER_PART_MAIN);
lv_style_int_t right = lv_obj_get_style_pad_right(lmeter, LV_LMETER_PART_MAIN);
lv_style_int_t top = lv_obj_get_style_pad_top(lmeter, LV_LMETER_PART_MAIN);
lv_style_int_t left = lv_obj_get_style_pad_left(lmeter, LV_LINEMETER_PART_MAIN);
lv_style_int_t right = lv_obj_get_style_pad_right(lmeter, LV_LINEMETER_PART_MAIN);
lv_style_int_t top = lv_obj_get_style_pad_top(lmeter, LV_LINEMETER_PART_MAIN);
lv_coord_t r_out = (lv_obj_get_width(lmeter) - left - right) / 2 ;
lv_coord_t r_in = r_out - lv_obj_get_style_scale_width(lmeter, part);
@ -336,7 +336,7 @@ void lv_lmeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uint8_
lv_draw_line(&p1, &p2, clip_area, &line_dsc);
}
if(part == LV_LMETER_PART_MAIN) {
if(part == LV_LINEMETER_PART_MAIN) {
lv_style_int_t border_width = lv_obj_get_style_scale_border_width(lmeter, part);
lv_style_int_t end_border_width = lv_obj_get_style_scale_end_border_width(lmeter, part);
@ -381,7 +381,7 @@ void lv_lmeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uint8_
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
* @param return an element of `lv_design_res_t`
*/
static lv_design_res_t lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * clip_area, lv_design_mode_t mode)
static lv_design_res_t lv_linemeter_design(lv_obj_t * lmeter, const lv_area_t * clip_area, lv_design_mode_t mode)
{
/*Return false if the object is not covers the mask_p area*/
if(mode == LV_DESIGN_COVER_CHK) {
@ -391,9 +391,9 @@ static lv_design_res_t lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * cli
else if(mode == LV_DESIGN_DRAW_MAIN) {
lv_draw_rect_dsc_t bg_dsc;
lv_draw_rect_dsc_init(&bg_dsc);
lv_obj_init_draw_rect_dsc(lmeter, LV_LMETER_PART_MAIN, &bg_dsc);
lv_obj_init_draw_rect_dsc(lmeter, LV_LINEMETER_PART_MAIN, &bg_dsc);
lv_draw_rect(&lmeter->coords, clip_area, &bg_dsc);
lv_lmeter_draw_scale(lmeter, clip_area, LV_LMETER_PART_MAIN);
lv_linemeter_draw_scale(lmeter, clip_area, LV_LINEMETER_PART_MAIN);
}
/*Post draw when the children are drawn*/
else if(mode == LV_DESIGN_DRAW_POST) {
@ -409,7 +409,7 @@ static lv_design_res_t lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * cli
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static lv_res_t lv_lmeter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * param)
static lv_res_t lv_linemeter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * param)
{
lv_res_t res;

View File

@ -1,10 +1,10 @@
/**
* @file lv_lmeter.h
* @file lv_linemeter.h
*
*/
#ifndef LV_LMETER_H
#define LV_LMETER_H
#ifndef LV_LINEMETER_H
#define LV_LINEMETER_H
#ifdef __cplusplus
extern "C" {
@ -37,15 +37,15 @@ typedef struct
int16_t cur_value;
int16_t min_value;
int16_t max_value;
} lv_lmeter_ext_t;
} lv_linemeter_ext_t;
/*Styles*/
enum {
LV_LMETER_PART_MAIN,
_LV_LMETER_PART_VIRTUAL_LAST,
_LV_LMETER_PART_REAL_LAST = _LV_OBJ_PART_REAL_LAST,
LV_LINEMETER_PART_MAIN,
_LV_LINEMETER_PART_VIRTUAL_LAST,
_LV_LINEMETER_PART_REAL_LAST = _LV_OBJ_PART_REAL_LAST,
};
typedef uint8_t lv_lmeter_part_t;
typedef uint8_t lv_linemeter_part_t;
/**********************
* GLOBAL PROTOTYPES
@ -58,7 +58,7 @@ typedef uint8_t lv_lmeter_part_t;
* it
* @return pointer to the created line meter
*/
lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy);
lv_obj_t * lv_linemeter_create(lv_obj_t * par, const lv_obj_t * copy);
/*=====================
* Setter functions
@ -69,7 +69,7 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy);
* @param lmeter pointer to a line meter object
* @param value new value
*/
void lv_lmeter_set_value(lv_obj_t * lmeter, int16_t value);
void lv_linemeter_set_value(lv_obj_t * lmeter, int16_t value);
/**
* Set minimum and the maximum values of a line meter
@ -77,7 +77,7 @@ void lv_lmeter_set_value(lv_obj_t * lmeter, int16_t value);
* @param min minimum value
* @param max maximum value
*/
void lv_lmeter_set_range(lv_obj_t * lmeter, int16_t min, int16_t max);
void lv_linemeter_set_range(lv_obj_t * lmeter, int16_t min, int16_t max);
/**
* Set the scale settings of a line meter
@ -85,14 +85,14 @@ void lv_lmeter_set_range(lv_obj_t * lmeter, int16_t min, int16_t max);
* @param angle angle of the scale (0..360)
* @param line_cnt number of lines
*/
void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint16_t line_cnt);
void lv_linemeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint16_t line_cnt);
/**
* Set the set an offset for the line meter's angles to rotate it.
* @param lmeter pointer to a line meter object
* @param angle angle offset (0..360), rotates clockwise
*/
void lv_lmeter_set_angle_offset(lv_obj_t * lmeter, uint16_t angle);
void lv_linemeter_set_angle_offset(lv_obj_t * lmeter, uint16_t angle);
/*=====================
* Getter functions
@ -103,45 +103,45 @@ void lv_lmeter_set_angle_offset(lv_obj_t * lmeter, uint16_t angle);
* @param lmeter pointer to a line meter object
* @return the value of the line meter
*/
int16_t lv_lmeter_get_value(const lv_obj_t * lmeter);
int16_t lv_linemeter_get_value(const lv_obj_t * lmeter);
/**
* Get the minimum value of a line meter
* @param lmeter pointer to a line meter object
* @return the minimum value of the line meter
*/
int16_t lv_lmeter_get_min_value(const lv_obj_t * lmeter);
int16_t lv_linemeter_get_min_value(const lv_obj_t * lmeter);
/**
* Get the maximum value of a line meter
* @param lmeter pointer to a line meter object
* @return the maximum value of the line meter
*/
int16_t lv_lmeter_get_max_value(const lv_obj_t * lmeter);
int16_t lv_linemeter_get_max_value(const lv_obj_t * lmeter);
/**
* Get the scale number of a line meter
* @param lmeter pointer to a line meter object
* @return number of the scale units
*/
uint16_t lv_lmeter_get_line_count(const lv_obj_t * lmeter);
uint16_t lv_linemeter_get_line_count(const lv_obj_t * lmeter);
/**
* Get the scale angle of a line meter
* @param lmeter pointer to a line meter object
* @return angle of the scale
*/
uint16_t lv_lmeter_get_scale_angle(const lv_obj_t * lmeter);
uint16_t lv_linemeter_get_scale_angle(const lv_obj_t * lmeter);
/**
* get the set an offset for the line meter.
* @param lmeter pointer to a line meter object
* @return angle offset (0..360)
*/
uint16_t lv_lmeter_get_angle_offset(lv_obj_t * lmeter);
uint16_t lv_linemeter_get_angle_offset(lv_obj_t * lmeter);
void lv_lmeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uint8_t part);
void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uint8_t part);
/**********************
* MACROS
@ -153,4 +153,4 @@ void lv_lmeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uint8_
} /* extern "C" */
#endif
#endif /*LV_LMETER_H*/
#endif /*LV_LINEMETER_H*/

View File

@ -7,7 +7,7 @@
* INCLUDES
*********************/
#include "lv_mbox.h"
#if LV_USE_MBOX != 0
#if LV_USE_MSGBOX != 0
#include "../lv_core/lv_debug.h"
#include "../lv_core/lv_group.h"
@ -18,15 +18,15 @@
/*********************
* DEFINES
*********************/
#define LV_OBJX_NAME "lv_mbos"
#define LV_OBJX_NAME "lv_msgbox"
#if LV_USE_ANIMATION
#ifndef LV_MBOX_CLOSE_ANIM_TIME
#define LV_MBOX_CLOSE_ANIM_TIME 200 /*List close animation time) */
#ifndef LV_MSGBOX_CLOSE_ANIM_TIME
#define LV_MSGBOX_CLOSE_ANIM_TIME 200 /*List close animation time) */
#endif
#else
#undef LV_MBOX_CLOSE_ANIM_TIME
#define LV_MBOX_CLOSE_ANIM_TIME 0 /*No animations*/
#undef LV_MSGBOX_CLOSE_ANIM_TIME
#define LV_MSGBOX_CLOSE_ANIM_TIME 0 /*No animations*/
#endif
/**********************
@ -36,14 +36,14 @@
/**********************
* STATIC PROTOTYPES
**********************/
static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param);
static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param);
static void mbox_realign(lv_obj_t * mbox);
static lv_style_list_t * lv_mbox_get_style(lv_obj_t * mbox, uint8_t part);
static lv_style_list_t * lv_msgbox_get_style(lv_obj_t * mbox, uint8_t part);
#if LV_USE_ANIMATION
static void lv_mbox_close_ready_cb(lv_anim_t * a);
static void lv_msgbox_close_ready_cb(lv_anim_t * a);
#endif
static void lv_mbox_default_event_cb(lv_obj_t * mbox, lv_event_t event);
static void lv_mbox_btnm_event_cb(lv_obj_t * btnm, lv_event_t event);
static void lv_msgbox_default_event_cb(lv_obj_t * mbox, lv_event_t event);
static void lv_msgbox_btnm_event_cb(lv_obj_t * btnm, lv_event_t event);
/**********************
* STATIC VARIABLES
@ -65,7 +65,7 @@ static lv_signal_cb_t ancestor_signal;
* it
* @return pointer to the created message box
*/
lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_t * lv_msgbox_create(lv_obj_t * par, const lv_obj_t * copy)
{
LV_LOG_TRACE("message box create started");
@ -77,7 +77,7 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(mbox);
/*Allocate the message box type specific extended data*/
lv_mbox_ext_t * ext = lv_obj_allocate_ext_attr(mbox, sizeof(lv_mbox_ext_t));
lv_msgbox_ext_t * ext = lv_obj_allocate_ext_attr(mbox, sizeof(lv_msgbox_ext_t));
LV_ASSERT_MEM(ext);
if(ext == NULL) {
lv_obj_del(mbox);
@ -87,11 +87,11 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
ext->text = NULL;
ext->btnm = NULL;
#if LV_USE_ANIMATION
ext->anim_time = LV_MBOX_CLOSE_ANIM_TIME;
ext->anim_time = LV_MSGBOX_CLOSE_ANIM_TIME;
#endif
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_cb(mbox, lv_mbox_signal);
lv_obj_set_signal_cb(mbox, lv_msgbox_signal);
/*Init the new message box message box*/
if(copy == NULL) {
@ -104,7 +104,7 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
lv_cont_set_fit2(mbox, LV_FIT_NONE, LV_FIT_TIGHT);
lv_obj_set_width(mbox, LV_DPI * 2);
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_event_cb(mbox, lv_mbox_default_event_cb);
lv_obj_set_event_cb(mbox, lv_msgbox_default_event_cb);
/*Set the default styles*/
lv_theme_apply(mbox, LV_THEME_MBOX);
@ -112,12 +112,12 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
}
/*Copy an existing message box*/
else {
lv_mbox_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
lv_msgbox_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->text = lv_label_create(mbox, copy_ext->text);
/*Copy the buttons and the label on them*/
if(copy_ext->btnm) ext->btnm = lv_btnm_create(mbox, copy_ext->btnm);
if(copy_ext->btnm) ext->btnm = lv_btnmatrix_create(mbox, copy_ext->btnm);
/*Refresh the style with new signal function*/
lv_obj_refresh_style(mbox);
@ -138,23 +138,23 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
* @param btn_map button descriptor (button matrix map).
* E.g. a const char *txt[] = {"ok", "close", ""} (Can not be local variable)
*/
void lv_mbox_add_btns(lv_obj_t * mbox, const char * btn_map[])
void lv_msgbox_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_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
/*Create a button matrix if not exists yet*/
if(ext->btnm == NULL) {
ext->btnm = lv_btnm_create(mbox, NULL);
ext->btnm = lv_btnmatrix_create(mbox, NULL);
lv_theme_alien_apply(mbox, LV_THEME_MBOX_BTNS);
}
lv_btnm_set_map(ext->btnm, btn_map);
lv_btnm_set_btn_ctrl_all(ext->btnm, LV_BTNM_CTRL_CLICK_TRIG | LV_BTNM_CTRL_NO_REPEAT);
lv_obj_set_event_cb(ext->btnm, lv_mbox_btnm_event_cb);
lv_btnmatrix_set_map(ext->btnm, btn_map);
lv_btnmatrix_set_btn_ctrl_all(ext->btnm, LV_BTNMATRIX_CTRL_CLICK_TRIG | LV_BTNMATRIX_CTRL_NO_REPEAT);
lv_obj_set_event_cb(ext->btnm, lv_msgbox_btnm_event_cb);
mbox_realign(mbox);
}
@ -168,12 +168,12 @@ void lv_mbox_add_btns(lv_obj_t * mbox, const char * btn_map[])
* @param mbox pointer to a message box
* @param txt a '\0' terminated character string which will be the message box text
*/
void lv_mbox_set_text(lv_obj_t * mbox, const char * txt)
void lv_msgbox_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_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
lv_label_set_text(ext->text, txt);
mbox_realign(mbox);
@ -184,12 +184,12 @@ void lv_mbox_set_text(lv_obj_t * mbox, const char * txt)
* @param mbox pointer to a message box object
* @param anim_time animation length in milliseconds (0: no animation)
*/
void lv_mbox_set_anim_time(lv_obj_t * mbox, uint16_t anim_time)
void lv_msgbox_set_anim_time(lv_obj_t * mbox, uint16_t anim_time)
{
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
#if LV_USE_ANIMATION
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
lv_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
anim_time = 0;
ext->anim_time = anim_time;
#else
@ -203,12 +203,12 @@ void lv_mbox_set_anim_time(lv_obj_t * mbox, uint16_t anim_time)
* @param mbox pointer to a message box object
* @param delay a time (in milliseconds) to wait before delete the message box
*/
void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay)
void lv_msgbox_start_auto_close(lv_obj_t * mbox, uint16_t delay)
{
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
#if LV_USE_ANIMATION
if(lv_mbox_get_anim_time(mbox) != 0) {
if(lv_msgbox_get_anim_time(mbox) != 0) {
/*Add shrinking animations*/
lv_anim_t a;
a.var = mbox;
@ -218,7 +218,7 @@ void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay)
a.path_cb = lv_anim_path_linear;
a.ready_cb = NULL;
a.act_time = -delay;
a.time = lv_mbox_get_anim_time(mbox);
a.time = lv_msgbox_get_anim_time(mbox);
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
@ -227,7 +227,7 @@ void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay)
a.start = lv_obj_get_width(mbox);
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_width;
a.ready_cb = lv_mbox_close_ready_cb;
a.ready_cb = lv_msgbox_close_ready_cb;
lv_anim_create(&a);
/*Disable fit to let shrinking work*/
@ -240,7 +240,7 @@ void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay)
a.end = 1;
a.exec_cb = (lv_anim_exec_xcb_t)NULL;
a.path_cb = lv_anim_path_linear;
a.ready_cb = lv_mbox_close_ready_cb;
a.ready_cb = lv_msgbox_close_ready_cb;
a.act_time = -delay;
a.time = 0;
a.playback = 0;
@ -259,7 +259,7 @@ void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay)
* Stop the auto. closing of message box
* @param mbox pointer to a message box object
*/
void lv_mbox_stop_auto_close(lv_obj_t * mbox)
void lv_msgbox_stop_auto_close(lv_obj_t * mbox)
{
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
@ -275,13 +275,13 @@ void lv_mbox_stop_auto_close(lv_obj_t * mbox)
* @param btnm pointer to button matrix object
* @param en whether recoloring is enabled
*/
void lv_mbox_set_recolor(lv_obj_t * mbox, bool en)
void lv_msgbox_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_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
if(ext->btnm) lv_btnm_set_recolor(ext->btnm, en);
if(ext->btnm) lv_btnmatrix_set_recolor(ext->btnm, en);
}
/*=====================
@ -293,11 +293,11 @@ void lv_mbox_set_recolor(lv_obj_t * mbox, bool en)
* @param mbox pointer to a message box object
* @return pointer to the text of the message box
*/
const char * lv_mbox_get_text(const lv_obj_t * mbox)
const char * lv_msgbox_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_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
return lv_label_get_text(ext->text);
}
@ -306,17 +306,17 @@ const char * lv_mbox_get_text(const lv_obj_t * mbox)
* Get the index of the lastly "activated" button by the user (pressed, released etc)
* Useful in the the `event_cb`.
* @param btnm pointer to button matrix object
* @return index of the last released button (LV_BTNM_BTN_NONE: if unset)
* @return index of the last released button (LV_BTNMATRIX_BTN_NONE: if unset)
*/
uint16_t lv_mbox_get_active_btn(lv_obj_t * mbox)
uint16_t lv_msgbox_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_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
if(ext->btnm)
return lv_btnm_get_active_btn(ext->btnm);
return lv_btnmatrix_get_active_btn(ext->btnm);
else
return LV_BTNM_BTN_NONE;
return LV_BTNMATRIX_BTN_NONE;
}
/**
@ -325,13 +325,13 @@ uint16_t lv_mbox_get_active_btn(lv_obj_t * mbox)
* @param btnm pointer to button matrix object
* @return text of the last released button (NULL: if unset)
*/
const char * lv_mbox_get_active_btn_text(lv_obj_t * mbox)
const char * lv_msgbox_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_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
if(ext->btnm)
return lv_btnm_get_active_btn_text(ext->btnm);
return lv_btnmatrix_get_active_btn_text(ext->btnm);
else
return NULL;
}
@ -341,12 +341,12 @@ const char * lv_mbox_get_active_btn_text(lv_obj_t * mbox)
* @param mbox pointer to a message box object
* @return animation length in milliseconds (0: no animation)
*/
uint16_t lv_mbox_get_anim_time(const lv_obj_t * mbox)
uint16_t lv_msgbox_get_anim_time(const lv_obj_t * mbox)
{
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
#if LV_USE_ANIMATION
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
lv_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
return ext->anim_time;
#else
(void)mbox;
@ -359,28 +359,28 @@ uint16_t lv_mbox_get_anim_time(const lv_obj_t * mbox)
* @param mbox pointer to a message box object
* @return whether recoloring is enabled
*/
bool lv_mbox_get_recolor(const lv_obj_t * mbox)
bool lv_msgbox_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_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
if(!ext->btnm) return false;
return lv_btnm_get_recolor(ext->btnm);
return lv_btnmatrix_get_recolor(ext->btnm);
}
/**
* Get message box button matrix
* @param mbox pointer to a message box object
* @return pointer to button matrix object
* @remarks return value will be NULL unless `lv_mbox_add_btns` has been already called
* @remarks return value will be NULL unless `lv_msgbox_add_btns` has been already called
*/
lv_obj_t * lv_mbox_get_btnm(lv_obj_t * mbox)
lv_obj_t * lv_msgbox_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_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
return ext->btnm;
}
@ -395,7 +395,7 @@ lv_obj_t * lv_mbox_get_btnm(lv_obj_t * mbox)
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
{
lv_res_t res;
@ -411,14 +411,14 @@ static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
if(sign == LV_SIGNAL_GET_STYLE) {
lv_get_style_info_t * info = param;
info->result = lv_mbox_get_style(mbox, info->part);
info->result = lv_msgbox_get_style(mbox, info->part);
if(info->result != NULL) return LV_RES_OK;
else return ancestor_signal(mbox, sign, param);
} else if(sign == LV_SIGNAL_GET_STATE_DSC) {
lv_get_state_info_t * info = param;
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
if(ext->btnm && info->part == LV_MBOX_PART_BTN_BG) info->result = lv_obj_get_state_dsc(ext->btnm, LV_BTNM_PART_BG);
else if(ext->btnm && info->part == LV_MBOX_PART_BTN) info->result = lv_obj_get_state_dsc(ext->btnm, LV_BTNM_PART_BTN);
lv_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
if(ext->btnm && info->part == LV_MSGBOX_PART_BTN_BG) info->result = lv_obj_get_state_dsc(ext->btnm, LV_BTNMATRIX_PART_BG);
else if(ext->btnm && info->part == LV_MSGBOX_PART_BTN) info->result = lv_obj_get_state_dsc(ext->btnm, LV_BTNMATRIX_PART_BTN);
return LV_RES_OK;
}
@ -427,7 +427,7 @@ static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
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_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
if(sign == LV_SIGNAL_COORD_CHG) {
if(lv_obj_get_width(mbox) != lv_area_get_width(param)) {
mbox_realign(mbox);
@ -436,8 +436,8 @@ static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
mbox_realign(mbox);
} else if(sign == LV_SIGNAL_RELEASED) {
if(ext->btnm) {
uint32_t btn_id = lv_btnm_get_active_btn(ext->btnm);
if(btn_id != LV_BTNM_BTN_NONE) lv_event_send(mbox, LV_EVENT_VALUE_CHANGED, &btn_id);
uint32_t btn_id = lv_btnmatrix_get_active_btn(ext->btnm);
if(btn_id != LV_BTNMATRIX_BTN_NONE) lv_event_send(mbox, LV_EVENT_VALUE_CHANGED, &btn_id);
}
} else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROL ||
sign == LV_SIGNAL_GET_EDITABLE) {
@ -453,11 +453,11 @@ static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
lv_indev_type_t indev_type = lv_indev_get_type(indev);
if(indev_type == LV_INDEV_TYPE_ENCODER) {
/*In navigation mode don't select any button but in edit mode select the fist*/
lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btnm);
lv_btnmatrix_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btnm);
if(lv_group_get_editing(lv_obj_get_group(mbox)))
btnm_ext->btn_id_pr = 0;
else
btnm_ext->btn_id_pr = LV_BTNM_BTN_NONE;
btnm_ext->btn_id_pr = LV_BTNMATRIX_BTN_NONE;
}
#endif
}
@ -469,25 +469,25 @@ static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
/**
* Get the style descriptor of a part of the object
* @param mbox pointer the object
* @param part the part from `lv_mbox_part_t`. (LV_MBOX_PART_...)
* @param part the part from `lv_msgbox_part_t`. (LV_MSGBOX_PART_...)
* @return pointer to the style descriptor of the specified part
*/
static lv_style_list_t * lv_mbox_get_style(lv_obj_t * mbox, uint8_t part)
static lv_style_list_t * lv_msgbox_get_style(lv_obj_t * mbox, uint8_t part)
{
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
lv_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
lv_style_list_t * style_dsc_p;
switch(part) {
case LV_MBOX_PART_BG:
case LV_MSGBOX_PART_BG:
style_dsc_p = &mbox->style_list;
break;
case LV_MBOX_PART_BTN_BG:
style_dsc_p = ext->btnm ? lv_obj_get_style_list(ext->btnm, LV_BTNM_PART_BG) : NULL;
case LV_MSGBOX_PART_BTN_BG:
style_dsc_p = ext->btnm ? lv_obj_get_style_list(ext->btnm, LV_BTNMATRIX_PART_BG) : NULL;
break;
case LV_MBOX_PART_BTN:
style_dsc_p = ext->btnm ? lv_obj_get_style_list(ext->btnm, LV_BTNM_PART_BTN) : NULL;
case LV_MSGBOX_PART_BTN:
style_dsc_p = ext->btnm ? lv_obj_get_style_list(ext->btnm, LV_BTNMATRIX_PART_BTN) : NULL;
break;
default:
style_dsc_p = NULL;
@ -502,7 +502,7 @@ static lv_style_list_t * lv_mbox_get_style(lv_obj_t * mbox, uint8_t part)
*/
static void mbox_realign(lv_obj_t * mbox)
{
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
lv_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
lv_coord_t w = lv_obj_get_width_fit(mbox);
@ -511,11 +511,11 @@ static void mbox_realign(lv_obj_t * mbox)
}
if(ext->btnm) {
lv_style_int_t bg_top = lv_obj_get_style_pad_top(mbox, LV_MBOX_PART_BTN_BG);
lv_style_int_t bg_bottom = lv_obj_get_style_pad_bottom(mbox, LV_MBOX_PART_BTN_BG);
lv_style_int_t btn_top = lv_obj_get_style_pad_top(mbox, LV_MBOX_PART_BTN);
lv_style_int_t btn_bottom = lv_obj_get_style_pad_bottom(mbox, LV_MBOX_PART_BTN);
const lv_font_t * font = lv_obj_get_style_font(mbox, LV_MBOX_PART_BTN);
lv_style_int_t bg_top = lv_obj_get_style_pad_top(mbox, LV_MSGBOX_PART_BTN_BG);
lv_style_int_t bg_bottom = lv_obj_get_style_pad_bottom(mbox, LV_MSGBOX_PART_BTN_BG);
lv_style_int_t btn_top = lv_obj_get_style_pad_top(mbox, LV_MSGBOX_PART_BTN);
lv_style_int_t btn_bottom = lv_obj_get_style_pad_bottom(mbox, LV_MSGBOX_PART_BTN);
const lv_font_t * font = lv_obj_get_style_font(mbox, LV_MSGBOX_PART_BTN);
lv_coord_t font_h = lv_font_get_line_height(font);
lv_obj_set_size(ext->btnm, w, font_h + btn_top + btn_bottom + bg_top + bg_bottom);
@ -523,23 +523,23 @@ static void mbox_realign(lv_obj_t * mbox)
}
#if LV_USE_ANIMATION
static void lv_mbox_close_ready_cb(lv_anim_t * a)
static void lv_msgbox_close_ready_cb(lv_anim_t * a)
{
lv_obj_del(a->var);
}
#endif
static void lv_mbox_default_event_cb(lv_obj_t * mbox, lv_event_t event)
static void lv_msgbox_default_event_cb(lv_obj_t * mbox, lv_event_t event)
{
if(event != LV_EVENT_VALUE_CHANGED) return;
uint32_t btn_id = lv_mbox_get_active_btn(mbox);
if(btn_id == LV_BTNM_BTN_NONE) return;
uint32_t btn_id = lv_msgbox_get_active_btn(mbox);
if(btn_id == LV_BTNMATRIX_BTN_NONE) return;
lv_mbox_start_auto_close(mbox, 0);
lv_msgbox_start_auto_close(mbox, 0);
}
static void lv_mbox_btnm_event_cb(lv_obj_t * btnm, lv_event_t event)
static void lv_msgbox_btnm_event_cb(lv_obj_t * btnm, lv_event_t event)
{
lv_obj_t * mbox = lv_obj_get_parent(btnm);

View File

@ -3,8 +3,8 @@
*
*/
#ifndef LV_MBOX_H
#define LV_MBOX_H
#ifndef LV_MSGBOX_H
#define LV_MSGBOX_H
#ifdef __cplusplus
extern "C" {
@ -15,15 +15,15 @@ extern "C" {
*********************/
#include "../lv_conf_internal.h"
#if LV_USE_MBOX != 0
#if LV_USE_MSGBOX != 0
/*Testing of dependencies*/
#if LV_USE_CONT == 0
#error "lv_mbox: lv_cont is required. Enable it in lv_conf.h (LV_USE_CONT 1) "
#endif
#if LV_USE_BTNM == 0
#error "lv_mbox: lv_btnm is required. Enable it in lv_conf.h (LV_USE_BTNM 1) "
#if LV_USE_BTNMATRIX == 0
#error "lv_mbox: lv_btnm is required. Enable it in lv_conf.h (LV_USE_BTNMATRIX 1) "
#endif
#if LV_USE_LABEL == 0
@ -53,16 +53,16 @@ typedef struct
#if LV_USE_ANIMATION
uint16_t anim_time; /*Duration of close animation [ms] (0: no animation)*/
#endif
} lv_mbox_ext_t;
} lv_msgbox_ext_t;
/** Message box styles. */
enum {
LV_MBOX_PART_BG = LV_CONT_PART_MAIN,
LV_MSGBOX_PART_BG = LV_CONT_PART_MAIN,
LV_MBOX_PART_BTN_BG = _LV_CONT_PART_REAL_LAST,
LV_MBOX_PART_BTN,
LV_MSGBOX_PART_BTN_BG = _LV_CONT_PART_REAL_LAST,
LV_MSGBOX_PART_BTN,
};
typedef uint8_t lv_mbox_style_t;
typedef uint8_t lv_msgbox_style_t;
/**********************
* GLOBAL PROTOTYPES
@ -75,7 +75,7 @@ typedef uint8_t lv_mbox_style_t;
* it
* @return pointer to the created message box
*/
lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy);
lv_obj_t * lv_msgbox_create(lv_obj_t * par, const lv_obj_t * copy);
/*======================
* Add/remove functions
@ -87,7 +87,7 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy);
* @param btn_map button descriptor (button matrix map).
* E.g. a const char *txt[] = {"ok", "close", ""} (Can not be local variable)
*/
void lv_mbox_add_btns(lv_obj_t * mbox, const char * btn_mapaction[]);
void lv_msgbox_add_btns(lv_obj_t * mbox, const char * btn_mapaction[]);
/*=====================
* Setter functions
@ -98,27 +98,27 @@ void lv_mbox_add_btns(lv_obj_t * mbox, const char * btn_mapaction[]);
* @param mbox pointer to a message box
* @param txt a '\0' terminated character string which will be the message box text
*/
void lv_mbox_set_text(lv_obj_t * mbox, const char * txt);
void lv_msgbox_set_text(lv_obj_t * mbox, const char * txt);
/**
* Set animation duration
* @param mbox pointer to a message box object
* @param anim_time animation length in milliseconds (0: no animation)
*/
void lv_mbox_set_anim_time(lv_obj_t * mbox, uint16_t anim_time);
void lv_msgbox_set_anim_time(lv_obj_t * mbox, uint16_t anim_time);
/**
* Automatically delete the message box after a given time
* @param mbox pointer to a message box object
* @param delay a time (in milliseconds) to wait before delete the message box
*/
void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay);
void lv_msgbox_start_auto_close(lv_obj_t * mbox, uint16_t delay);
/**
* Stop the auto. closing of message box
* @param mbox pointer to a message box object
*/
void lv_mbox_stop_auto_close(lv_obj_t * mbox);
void lv_msgbox_stop_auto_close(lv_obj_t * mbox);
/**
* Set a style of a message box
@ -126,14 +126,14 @@ void lv_mbox_stop_auto_close(lv_obj_t * mbox);
* @param type which style should be set
* @param style pointer to a style
*/
void lv_mbox_set_style(lv_obj_t * mbox, lv_mbox_style_t type, const lv_style_t * style);
void lv_msgbox_set_style(lv_obj_t * mbox, lv_msgbox_style_t type, const lv_style_t * style);
/**
* Set whether recoloring is enabled. Must be called after `lv_mbox_add_btns`.
* Set whether recoloring is enabled. Must be called after `lv_msgbox_add_btns`.
* @param btnm pointer to button matrix object
* @param en whether recoloring is enabled
*/
void lv_mbox_set_recolor(lv_obj_t * mbox, bool en);
void lv_msgbox_set_recolor(lv_obj_t * mbox, bool en);
/*=====================
* Getter functions
@ -144,15 +144,15 @@ void lv_mbox_set_recolor(lv_obj_t * mbox, bool en);
* @param mbox pointer to a message box object
* @return pointer to the text of the message box
*/
const char * lv_mbox_get_text(const lv_obj_t * mbox);
const char * lv_msgbox_get_text(const lv_obj_t * mbox);
/**
* Get the index of the lastly "activated" button by the user (pressed, released etc)
* Useful in the the `event_cb`.
* @param btnm pointer to button matrix object
* @return index of the last released button (LV_BTNM_BTN_NONE: if unset)
* @return index of the last released button (LV_BTNMATRIX_BTN_NONE: if unset)
*/
uint16_t lv_mbox_get_active_btn(lv_obj_t * mbox);
uint16_t lv_msgbox_get_active_btn(lv_obj_t * mbox);
/**
* Get the text of the lastly "activated" button by the user (pressed, released etc)
@ -160,38 +160,38 @@ uint16_t lv_mbox_get_active_btn(lv_obj_t * mbox);
* @param btnm pointer to button matrix object
* @return text of the last released button (NULL: if unset)
*/
const char * lv_mbox_get_active_btn_text(lv_obj_t * mbox);
const char * lv_msgbox_get_active_btn_text(lv_obj_t * mbox);
/**
* Get the animation duration (close animation time)
* @param mbox pointer to a message box object
* @return animation length in milliseconds (0: no animation)
*/
uint16_t lv_mbox_get_anim_time(const lv_obj_t * mbox);
uint16_t lv_msgbox_get_anim_time(const lv_obj_t * mbox);
/**
* Get whether recoloring is enabled
* @param mbox pointer to a message box object
* @return whether recoloring is enabled
*/
bool lv_mbox_get_recolor(const lv_obj_t * mbox);
bool lv_msgbox_get_recolor(const lv_obj_t * mbox);
/**
* Get message box button matrix
* @param mbox pointer to a message box object
* @return pointer to button matrix object
* @remarks return value will be NULL unless `lv_mbox_add_btns` has been already called
* @remarks return value will be NULL unless `lv_msgbox_add_btns` has been already called
*/
lv_obj_t * lv_mbox_get_btnm(lv_obj_t * mbox);
lv_obj_t * lv_msgbox_get_btnm(lv_obj_t * mbox);
/**********************
* MACROS
**********************/
#endif /*LV_USE_MBOX*/
#endif /*LV_USE_MSGBOX*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_MBOX_H*/
#endif /*LV_MSGBOX_H*/

View File

@ -7,7 +7,7 @@
* INCLUDES
*********************/
#include "lv_preload.h"
#if LV_USE_PRELOAD != 0
#if LV_USE_SPINNER != 0
#include "../lv_core/lv_debug.h"
#include "../lv_misc/lv_math.h"
@ -18,18 +18,18 @@
/*********************
* DEFINES
*********************/
#define LV_OBJX_NAME "lv_preloader"
#define LV_OBJX_NAME "lv_spinner"
#ifndef LV_PRELOAD_DEF_ARC_LENGTH
#define LV_PRELOAD_DEF_ARC_LENGTH 60 /*[deg]*/
#ifndef LV_SPINNER_DEF_ARC_LENGTH
#define LV_SPINNER_DEF_ARC_LENGTH 60 /*[deg]*/
#endif
#ifndef LV_PRELOAD_DEF_SPIN_TIME
#define LV_PRELOAD_DEF_SPIN_TIME 1000 /*[ms]*/
#ifndef LV_SPINNER_DEF_SPIN_TIME
#define LV_SPINNER_DEF_SPIN_TIME 1000 /*[ms]*/
#endif
#ifndef LV_PRELOAD_DEF_ANIM
#define LV_PRELOAD_DEF_ANIM LV_PRELOAD_TYPE_SPINNING_ARC /*animation type*/
#ifndef LV_SPINNER_DEF_ANIM
#define LV_SPINNER_DEF_ANIM LV_SPINNER_TYPE_SPINNING_ARC /*animation type*/
#endif
/**********************
@ -39,8 +39,8 @@
/**********************
* STATIC PROTOTYPES
**********************/
static lv_design_res_t lv_preload_design(lv_obj_t * preload, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_res_t lv_preload_signal(lv_obj_t * preload, lv_signal_t sign, void * param);
static lv_design_res_t lv_spinner_design(lv_obj_t * preload, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_res_t lv_spinner_signal(lv_obj_t * preload, lv_signal_t sign, void * param);
/**********************
* STATIC VARIABLES
@ -63,7 +63,7 @@ static lv_design_cb_t ancestor_design;
* it
* @return pointer to the created pre loader
*/
lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_t * lv_spinner_create(lv_obj_t * par, const lv_obj_t * copy)
{
LV_LOG_TRACE("preload create started");
@ -73,7 +73,7 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
if(preload == NULL) return NULL;
/*Allocate the pre loader type specific extended data*/
lv_preload_ext_t * ext = lv_obj_allocate_ext_attr(preload, sizeof(lv_preload_ext_t));
lv_spinner_ext_t * ext = lv_obj_allocate_ext_attr(preload, sizeof(lv_spinner_ext_t));
LV_ASSERT_MEM(ext);
if(ext == NULL) {
lv_obj_del(preload);
@ -84,16 +84,16 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(preload);
/*Initialize the allocated 'ext' */
ext->arc_length = LV_PRELOAD_DEF_ARC_LENGTH;
ext->anim_type = LV_PRELOAD_DEF_ANIM;
ext->anim_dir = LV_PRELOAD_DIR_FORWARD;
ext->time = LV_PRELOAD_DEF_SPIN_TIME;
ext->arc_length = LV_SPINNER_DEF_ARC_LENGTH;
ext->anim_type = LV_SPINNER_DEF_ANIM;
ext->anim_dir = LV_SPINNER_DIR_FORWARD;
ext->time = LV_SPINNER_DEF_SPIN_TIME;
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_cb(preload, lv_preload_signal);
// lv_obj_set_design_cb(preload, lv_preload_design);
lv_obj_set_signal_cb(preload, lv_spinner_signal);
// lv_obj_set_design_cb(preload, lv_spinner_design);
/*Init the new preloader preloader*/
/*Init the new spinner spinner*/
if(copy == NULL) {
ext->arc.bg_angle_start = 0;
ext->arc.bg_angle_end = 360;
@ -101,9 +101,9 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
lv_theme_apply(preload, LV_THEME_PRELOAD);
}
/*Copy an existing preloader*/
/*Copy an existing spinner*/
else {
lv_preload_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
lv_spinner_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->arc_length = copy_ext->arc_length;
ext->time = copy_ext->time;
ext->anim_dir = copy_ext->anim_dir;
@ -111,7 +111,7 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_refresh_style(preload);
}
lv_preload_set_type(preload, ext->anim_type);
lv_spinner_set_type(preload, ext->anim_type);
LV_LOG_INFO("preload created");
@ -127,11 +127,11 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
* @param preload pointer to a preload object
* @param deg length of the arc
*/
void lv_preload_set_arc_length(lv_obj_t * preload, lv_anim_value_t deg)
void lv_spinner_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_spinner_ext_t * ext = lv_obj_get_ext_attr(preload);
ext->arc_length = deg;
}
@ -141,14 +141,14 @@ void lv_preload_set_arc_length(lv_obj_t * preload, lv_anim_value_t deg)
* @param preload pointer to a preload object
* @param time time of one round in milliseconds
*/
void lv_preload_set_spin_time(lv_obj_t * preload, uint16_t time)
void lv_spinner_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_spinner_ext_t * ext = lv_obj_get_ext_attr(preload);
ext->time = time;
lv_preload_set_type(preload, ext->anim_type);
lv_spinner_set_type(preload, ext->anim_type);
}
/*=====================
* Setter functions
@ -159,20 +159,20 @@ void lv_preload_set_spin_time(lv_obj_t * preload, uint16_t time)
* @param preload pointer to pre loader object
* @param type animation type of the preload
* */
void lv_preload_set_type(lv_obj_t * preload, lv_preload_type_t type)
void lv_spinner_set_type(lv_obj_t * preload, lv_spinner_type_t type)
{
LV_ASSERT_OBJ(preload, LV_OBJX_NAME);
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
lv_spinner_ext_t * ext = lv_obj_get_ext_attr(preload);
/*delete previous animation*/
lv_anim_del(preload, NULL);
switch(type) {
case LV_PRELOAD_TYPE_FILLSPIN_ARC: {
ext->anim_type = LV_PRELOAD_TYPE_FILLSPIN_ARC;
case LV_SPINNER_TYPE_FILLSPIN_ARC: {
ext->anim_type = LV_SPINNER_TYPE_FILLSPIN_ARC;
lv_anim_t a;
a.var = preload;
if(ext->anim_dir == LV_PRELOAD_DIR_FORWARD) {
if(ext->anim_dir == LV_SPINNER_DIR_FORWARD) {
/* Clockwise */
a.start = 0;
a.end = 360;
@ -180,7 +180,7 @@ void lv_preload_set_type(lv_obj_t * preload, lv_preload_type_t type)
a.start = 360;
a.end = 0;
}
a.exec_cb = (lv_anim_exec_xcb_t)lv_preload_spinner_anim;
a.exec_cb = (lv_anim_exec_xcb_t)lv_spinner_spinner_anim;
a.path_cb = lv_anim_path_ease_in_out;
a.ready_cb = NULL;
a.act_time = 0;
@ -193,7 +193,7 @@ void lv_preload_set_type(lv_obj_t * preload, lv_preload_type_t type)
lv_anim_t b;
b.var = preload;
if(ext->anim_dir == LV_PRELOAD_DIR_FORWARD) {
if(ext->anim_dir == LV_SPINNER_DIR_FORWARD) {
/* Clockwise */
b.start = ext->arc_length;
b.end = 360 - ext->arc_length;
@ -201,7 +201,7 @@ void lv_preload_set_type(lv_obj_t * preload, lv_preload_type_t type)
b.start = 360 - ext->arc_length;
b.end = ext->arc_length;
}
b.exec_cb = (lv_anim_exec_xcb_t)lv_preload_set_arc_length;
b.exec_cb = (lv_anim_exec_xcb_t)lv_spinner_set_arc_length;
b.path_cb = lv_anim_path_ease_in_out;
b.ready_cb = NULL;
b.act_time = 0;
@ -213,13 +213,13 @@ void lv_preload_set_type(lv_obj_t * preload, lv_preload_type_t type)
lv_anim_create(&b);
break;
}
case LV_PRELOAD_TYPE_CONSTANT_ARC:
case LV_PRELOAD_TYPE_SPINNING_ARC:
case LV_SPINNER_TYPE_CONSTANT_ARC:
case LV_SPINNER_TYPE_SPINNING_ARC:
default: {
ext->anim_type = type;
lv_anim_t a;
a.var = preload;
if(ext->anim_dir == LV_PRELOAD_DIR_FORWARD) {
if(ext->anim_dir == LV_SPINNER_DIR_FORWARD) {
/* Clockwise */
a.start = 0;
a.end = 360;
@ -227,8 +227,8 @@ void lv_preload_set_type(lv_obj_t * preload, lv_preload_type_t type)
a.start = 360;
a.end = 0;
}
a.exec_cb = (lv_anim_exec_xcb_t)lv_preload_spinner_anim;
a.path_cb = (LV_PRELOAD_TYPE_CONSTANT_ARC == type ?
a.exec_cb = (lv_anim_exec_xcb_t)lv_spinner_spinner_anim;
a.path_cb = (LV_SPINNER_TYPE_CONSTANT_ARC == type ?
lv_anim_path_linear : lv_anim_path_ease_in_out);
a.ready_cb = NULL;
a.act_time = 0;
@ -243,14 +243,14 @@ 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_spinner_set_dir(lv_obj_t * preload, lv_spinner_dir_t dir)
{
LV_ASSERT_OBJ(preload, LV_OBJX_NAME);
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
lv_spinner_ext_t * ext = lv_obj_get_ext_attr(preload);
ext->anim_dir = dir;
lv_preload_set_type(preload, ext->anim_type);
lv_spinner_set_type(preload, ext->anim_type);
}
/*=====================
@ -261,11 +261,11 @@ void lv_preload_set_dir(lv_obj_t * preload, lv_preload_dir_t dir)
* Get the arc length [degree] of the a pre loader
* @param preload pointer to a pre loader object
*/
lv_anim_value_t lv_preload_get_arc_length(const lv_obj_t * preload)
lv_anim_value_t lv_spinner_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_spinner_ext_t * ext = lv_obj_get_ext_attr(preload);
return ext->arc_length;
}
@ -273,11 +273,11 @@ lv_anim_value_t lv_preload_get_arc_length(const lv_obj_t * preload)
* Get the spin time of the arc
* @param preload pointer to a pre loader object [milliseconds]
*/
uint16_t lv_preload_get_spin_time(const lv_obj_t * preload)
uint16_t lv_spinner_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_spinner_ext_t * ext = lv_obj_get_ext_attr(preload);
return ext->time;
}
@ -286,17 +286,17 @@ uint16_t lv_preload_get_spin_time(const lv_obj_t * preload)
* @param preload pointer to pre loader object
* @return animation type
* */
lv_preload_type_t lv_preload_get_type(lv_obj_t * preload)
lv_spinner_type_t lv_spinner_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_spinner_ext_t * ext = lv_obj_get_ext_attr(preload);
return ext->anim_type;
}
lv_preload_dir_t lv_preload_get_dir(lv_obj_t * preload)
lv_spinner_dir_t lv_spinner_get_dir(lv_obj_t * preload)
{
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
lv_spinner_ext_t * ext = lv_obj_get_ext_attr(preload);
return ext->anim_dir;
}
@ -306,13 +306,13 @@ lv_preload_dir_t lv_preload_get_dir(lv_obj_t * preload)
/**
* Animator function (exec_cb) to rotate the arc of spinner.
* @param ptr pointer to preloader
* @param ptr pointer to spinner
* @param val the current desired value [0..360]
*/
void lv_preload_spinner_anim(void * ptr, lv_anim_value_t val)
void lv_spinner_spinner_anim(void * ptr, lv_anim_value_t val)
{
lv_obj_t * preload = ptr;
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
lv_spinner_ext_t * ext = lv_obj_get_ext_attr(preload);
int16_t angle_start = val - ext->arc_length / 2 - 90;
if(angle_start < 0) angle_start += 360;
@ -338,7 +338,7 @@ void lv_preload_spinner_anim(void * ptr, lv_anim_value_t val)
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
* @param return an element of `lv_design_res_t`
*/
static lv_design_res_t lv_preload_design(lv_obj_t * preload, const lv_area_t * clip_area, lv_design_mode_t mode)
static lv_design_res_t lv_spinner_design(lv_obj_t * preload, const lv_area_t * clip_area, lv_design_mode_t mode)
{
// /*Return false if the object is not covers the mask_p area*/
// if(mode == LV_DESIGN_COVER_CHK) {
@ -389,7 +389,7 @@ static lv_design_res_t lv_preload_design(lv_obj_t * preload, const lv_area_t * c
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static lv_res_t lv_preload_signal(lv_obj_t * preload, lv_signal_t sign, void * param)
static lv_res_t lv_spinner_signal(lv_obj_t * preload, lv_signal_t sign, void * param)
{
lv_res_t res;

View File

@ -3,8 +3,8 @@
*
*/
#ifndef LV_PRELOAD_H
#define LV_PRELOAD_H
#ifndef LV_SPINNER_H
#define LV_SPINNER_H
#ifdef __cplusplus
extern "C" {
@ -15,7 +15,7 @@ extern "C" {
*********************/
#include "../lv_conf_internal.h"
#if LV_USE_PRELOAD != 0
#if LV_USE_SPINNER != 0
/*Testing of dependencies*/
#if LV_USE_ARC == 0
@ -39,23 +39,23 @@ extern "C" {
**********************/
/**
* Type of preloader.
* Type of spinner.
*/
enum {
LV_PRELOAD_TYPE_SPINNING_ARC,
LV_PRELOAD_TYPE_FILLSPIN_ARC,
LV_PRELOAD_TYPE_CONSTANT_ARC,
LV_SPINNER_TYPE_SPINNING_ARC,
LV_SPINNER_TYPE_FILLSPIN_ARC,
LV_SPINNER_TYPE_CONSTANT_ARC,
};
typedef uint8_t lv_preload_type_t;
typedef uint8_t lv_spinner_type_t;
/**
* Direction the preloader should spin.
* Direction the spinner should spin.
*/
enum {
LV_PRELOAD_DIR_FORWARD,
LV_PRELOAD_DIR_BACKWARD,
LV_SPINNER_DIR_FORWARD,
LV_SPINNER_DIR_BACKWARD,
};
typedef uint8_t lv_preload_dir_t;
typedef uint8_t lv_spinner_dir_t;
/*Data of pre loader*/
typedef struct
@ -64,19 +64,19 @@ typedef struct
/*New data for this type */
lv_anim_value_t arc_length; /*Length of the spinning indicator in degree*/
uint16_t time; /*Time of one round*/
lv_preload_type_t anim_type : 2; /*Type of the arc animation*/
lv_preload_dir_t anim_dir : 1; /*Animation Direction*/
} lv_preload_ext_t;
lv_spinner_type_t anim_type : 2; /*Type of the arc animation*/
lv_spinner_dir_t anim_dir : 1; /*Animation Direction*/
} lv_spinner_ext_t;
/*Parts of the preloader*/
/*Parts of the spinner*/
enum {
LV_PRELOAD_PART_BG = LV_ARC_PART_BG,
LV_PRELOAD_PART_ARC = LV_ARC_PART_ARC,
_LV_PRELOAD_PART_VIRTUAL_LAST,
LV_SPINNER_PART_BG = LV_ARC_PART_BG,
LV_SPINNER_PART_ARC = LV_ARC_PART_ARC,
_LV_SPINNER_PART_VIRTUAL_LAST,
_LV_PRELOAD_PART_REAL_LAST = _LV_ARC_PART_REAL_LAST,
_LV_SPINNER_PART_REAL_LAST = _LV_ARC_PART_REAL_LAST,
};
typedef uint8_t lv_preload_style_t;
typedef uint8_t lv_spinner_style_t;
/**********************
* GLOBAL PROTOTYPES
@ -89,7 +89,7 @@ typedef uint8_t lv_preload_style_t;
* it
* @return pointer to the created pre loader
*/
lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy);
lv_obj_t * lv_spinner_create(lv_obj_t * par, const lv_obj_t * copy);
/*======================
* Add/remove functions
@ -100,14 +100,14 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy);
* @param preload pointer to a preload object
* @param deg length of the arc
*/
void lv_preload_set_arc_length(lv_obj_t * preload, lv_anim_value_t deg);
void lv_spinner_set_arc_length(lv_obj_t * preload, lv_anim_value_t deg);
/**
* Set the spin time of the arc
* @param preload pointer to a preload object
* @param time time of one round in milliseconds
*/
void lv_preload_set_spin_time(lv_obj_t * preload, uint16_t time);
void lv_spinner_set_spin_time(lv_obj_t * preload, uint16_t time);
/*=====================
* Setter functions
@ -119,21 +119,21 @@ void lv_preload_set_spin_time(lv_obj_t * preload, uint16_t time);
* @param type which style should be set
* @param style pointer to a style
* */
void lv_preload_set_style(lv_obj_t * preload, lv_preload_style_t type, const lv_style_t * style);
void lv_spinner_set_style(lv_obj_t * preload, lv_spinner_style_t type, const lv_style_t * style);
/**
* Set the animation type of a preloader.
* Set the animation type of a spinner.
* @param preload pointer to pre loader object
* @param type animation type of the preload
* */
void lv_preload_set_type(lv_obj_t * preload, lv_preload_type_t type);
void lv_spinner_set_type(lv_obj_t * preload, lv_spinner_type_t type);
/**
* Set the animation direction of a preloader
* Set the animation direction of a spinner
* @param preload pointer to pre loader object
* @param direction animation direction of the preload
*/
void lv_preload_set_dir(lv_obj_t * preload, lv_preload_dir_t dir);
void lv_spinner_set_dir(lv_obj_t * preload, lv_spinner_dir_t dir);
/*=====================
* Getter functions
@ -143,13 +143,13 @@ void lv_preload_set_dir(lv_obj_t * preload, lv_preload_dir_t dir);
* Get the arc length [degree] of the a pre loader
* @param preload pointer to a pre loader object
*/
lv_anim_value_t lv_preload_get_arc_length(const lv_obj_t * preload);
lv_anim_value_t lv_spinner_get_arc_length(const lv_obj_t * preload);
/**
* Get the spin time of the arc
* @param preload pointer to a pre loader object [milliseconds]
*/
uint16_t lv_preload_get_spin_time(const lv_obj_t * preload);
uint16_t lv_spinner_get_spin_time(const lv_obj_t * preload);
/**
* Get style of a pre loader.
@ -157,21 +157,21 @@ uint16_t lv_preload_get_spin_time(const lv_obj_t * preload);
* @param type which style should be get
* @return style pointer to the style
* */
const lv_style_t * lv_preload_get_style(const lv_obj_t * preload, lv_preload_style_t type);
const lv_style_t * lv_spinner_get_style(const lv_obj_t * preload, lv_spinner_style_t type);
/**
* Get the animation type of a preloader.
* Get the animation type of a spinner.
* @param preload pointer to pre loader object
* @return animation type
* */
lv_preload_type_t lv_preload_get_type(lv_obj_t * preload);
lv_spinner_type_t lv_spinner_get_type(lv_obj_t * preload);
/**
* Get the animation direction of a preloader
* Get the animation direction of a spinner
* @param preload pointer to pre loader object
* @return animation direction
*/
lv_preload_dir_t lv_preload_get_dir(lv_obj_t * preload);
lv_spinner_dir_t lv_spinner_get_dir(lv_obj_t * preload);
/*=====================
* Other functions
@ -179,19 +179,19 @@ lv_preload_dir_t lv_preload_get_dir(lv_obj_t * preload);
/**
* Animator function (exec_cb) to rotate the arc of spinner.
* @param ptr pointer to preloader
* @param ptr pointer to spinner
* @param val the current desired value [0..360]
*/
void lv_preload_spinner_anim(void * ptr, lv_anim_value_t val);
void lv_spinner_spinner_anim(void * ptr, lv_anim_value_t val);
/**********************
* MACROS
**********************/
#endif /*LV_USE_PRELOAD*/
#endif /*LV_USE_SPINNER*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_PRELOAD_H*/
#endif /*LV_SPINNER_H*/

View File

@ -295,7 +295,7 @@ void lv_roller_get_selected_str(const lv_obj_t * roller, char * buf, uint16_t bu
uint16_t c;
for(c = 0; opt_txt[i] != '\n' && i < txt_len; c++, i++) {
if(buf_size && c >= buf_size - 1) {
LV_LOG_WARN("lv_ddlist_get_selected_str: the buffer was too small")
LV_LOG_WARN("lv_dropdown_get_selected_str: the buffer was too small")
break;
}
buf[c] = opt_txt[i];

View File

@ -55,7 +55,7 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
LV_LOG_TRACE("spinbox create started");
/*Create the ancestor of spinbox*/
lv_obj_t * new_spinbox = lv_ta_create(par, copy);
lv_obj_t * new_spinbox = lv_textarea_create(par, copy);
LV_ASSERT_MEM(new_spinbox);
if(new_spinbox == NULL) return NULL;
@ -79,8 +79,8 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
ext->range_max = 99999;
ext->range_min = -99999;
lv_ta_set_one_line(new_spinbox, true);
lv_ta_set_cursor_click_pos(new_spinbox, true);
lv_textarea_set_one_line(new_spinbox, true);
lv_textarea_set_cursor_click_pos(new_spinbox, true);
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_cb(new_spinbox, lv_spinbox_signal);
@ -395,7 +395,7 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
} else if(c == LV_KEY_DOWN) {
lv_spinbox_decrement(spinbox);
} else {
lv_ta_add_char(spinbox, c);
lv_textarea_add_char(spinbox, c);
}
}
@ -492,7 +492,7 @@ static void lv_spinbox_updatevalue(lv_obj_t * spinbox)
}
/*Refresh the text*/
lv_ta_set_text(spinbox, (char *)buf);
lv_textarea_set_text(spinbox, (char *)buf);
/*Set the cursor position*/
int32_t step = ext->step;
@ -506,7 +506,7 @@ static void lv_spinbox_updatevalue(lv_obj_t * spinbox)
cur_pos += (ext->digit_padding_left - cur_shift_left);
lv_ta_set_cursor_pos(spinbox, cur_pos);
lv_textarea_set_cursor_pos(spinbox, cur_pos);
}
#endif

View File

@ -18,8 +18,8 @@ extern "C" {
#if LV_USE_SPINBOX != 0
/*Testing of dependencies*/
#if LV_USE_TA == 0
#error "lv_spinbox: lv_ta is required. Enable it in lv_conf.h (LV_USE_TA 1) "
#if LV_USE_TEXTAREA == 0
#error "lv_spinbox: lv_ta is required. Enable it in lv_conf.h (LV_USE_TEXTAREA 1) "
#endif
#include "../lv_core/lv_obj.h"
@ -37,7 +37,7 @@ extern "C" {
/*Data of spinbox*/
typedef struct
{
lv_ta_ext_t ta; /*Ext. of ancestor*/
lv_textarea_ext_t ta; /*Ext. of ancestor*/
/*New data for this type */
int32_t value;
int32_t range_max;
@ -50,11 +50,11 @@ typedef struct
/*Styles*/
enum {
LV_SPINBOX_PART_BG = LV_TA_PART_BG,
LV_SPINBOX_PART_SCRLBAR = LV_TA_PART_SCRLBAR,
LV_SPINBOX_PART_CURSOR = LV_TA_PART_CURSOR,
_LV_SPINBOX_PART_VIRTUAL_LAST = _LV_TA_PART_VIRTUAL_LAST,
_LV_SPINBOX_PART_REAL_LAST = _LV_TA_PART_REAL_LAST,
LV_SPINBOX_PART_BG = LV_TEXTAREA_PART_BG,
LV_SPINBOX_PART_SCRLBAR = LV_TEXTAREA_PART_SCRLBAR,
LV_SPINBOX_PART_CURSOR = LV_TEXTAREA_PART_CURSOR,
_LV_SPINBOX_PART_VIRTUAL_LAST = _LV_TEXTAREA_PART_VIRTUAL_LAST,
_LV_SPINBOX_PART_REAL_LAST = _LV_TEXTAREA_PART_REAL_LAST,
};
typedef uint8_t lv_spinbox_part_t;

View File

@ -8,7 +8,7 @@
*********************/
#include "lv_sw.h"
#if LV_USE_SW != 0
#if LV_USE_SWITCH != 0
/*Testing of dependencies*/
#if LV_USE_SLIDER == 0
@ -24,7 +24,7 @@
/*********************
* DEFINES
*********************/
#define LV_OBJX_NAME "lv_sw"
#define LV_OBJX_NAME "lv_switch"
/**********************
* TYPEDEFS
@ -33,10 +33,10 @@
/**********************
* STATIC PROTOTYPES
**********************/
static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param);
static lv_design_res_t lv_sw_design(lv_obj_t * sw, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_style_list_t * lv_sw_get_style(lv_obj_t * sw, uint8_t part);
static lv_style_list_t * lv_sw_get_style(lv_obj_t * sw, uint8_t part);
static lv_res_t lv_switch_signal(lv_obj_t * sw, lv_signal_t sign, void * param);
static lv_design_res_t lv_switch_design(lv_obj_t * sw, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_style_list_t * lv_switch_get_style(lv_obj_t * sw, uint8_t part);
static lv_style_list_t * lv_switch_get_style(lv_obj_t * sw, uint8_t part);
/**********************
* STATIC VARIABLES
@ -58,7 +58,7 @@ static lv_design_cb_t ancestor_design;
* @param copy pointer to a switch object, if not NULL then the new object will be copied from it
* @return pointer to the created switch
*/
lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_t * lv_switch_create(lv_obj_t * par, const lv_obj_t * copy)
{
LV_LOG_TRACE("switch create started");
@ -72,7 +72,7 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy)
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(sw);
/*Allocate the switch type specific extended data*/
lv_sw_ext_t * ext = lv_obj_allocate_ext_attr(sw, sizeof(lv_sw_ext_t));
lv_switch_ext_t * ext = lv_obj_allocate_ext_attr(sw, sizeof(lv_switch_ext_t));
LV_ASSERT_MEM(ext);
if(ext == NULL) {
lv_obj_del(sw);
@ -82,8 +82,8 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy)
lv_style_list_init(&ext->style_knob);
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_cb(sw, lv_sw_signal);
lv_obj_set_design_cb(sw, lv_sw_design);
lv_obj_set_signal_cb(sw, lv_switch_signal);
lv_obj_set_design_cb(sw, lv_switch_design);
/*Init the new switch switch*/
if(copy == NULL) {
@ -96,7 +96,7 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy)
}
/*Copy an existing switch*/
else {
lv_sw_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
lv_switch_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
lv_style_list_copy(&ext->style_knob, &copy_ext->style_knob);
lv_obj_refresh_style(sw);
@ -118,14 +118,14 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy)
* @param sw pointer to a switch objec
* @param anim LV_ANOM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately
*/
void lv_sw_on(lv_obj_t * sw, lv_anim_enable_t anim)
void lv_switch_on(lv_obj_t * sw, lv_anim_enable_t anim)
{
LV_ASSERT_OBJ(sw, LV_OBJX_NAME);
#if LV_USE_ANIMATION == 0
anim = LV_ANIM_OFF;
#endif
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
lv_switch_ext_t * ext = lv_obj_get_ext_attr(sw);
ext->state = 1;
lv_bar_set_value(sw, 1, anim);
lv_obj_add_state(sw, LV_STATE_CHECKED);
@ -136,14 +136,14 @@ void lv_sw_on(lv_obj_t * sw, lv_anim_enable_t anim)
* @param sw pointer to a switch object
* @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately
*/
void lv_sw_off(lv_obj_t * sw, lv_anim_enable_t anim)
void lv_switch_off(lv_obj_t * sw, lv_anim_enable_t anim)
{
LV_ASSERT_OBJ(sw, LV_OBJX_NAME);
#if LV_USE_ANIMATION == 0
anim = LV_ANIM_OFF;
#endif
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
lv_switch_ext_t * ext = lv_obj_get_ext_attr(sw);
ext->state = 0;
lv_bar_set_value(sw, 0, anim);
lv_obj_clear_state(sw, LV_STATE_CHECKED);
@ -155,7 +155,7 @@ void lv_sw_off(lv_obj_t * sw, lv_anim_enable_t anim)
* @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately
* @return resulting state of the switch.
*/
bool lv_sw_toggle(lv_obj_t * sw, lv_anim_enable_t anim)
bool lv_switch_toggle(lv_obj_t * sw, lv_anim_enable_t anim)
{
LV_ASSERT_OBJ(sw, LV_OBJX_NAME);
@ -163,11 +163,11 @@ bool lv_sw_toggle(lv_obj_t * sw, lv_anim_enable_t anim)
anim = LV_ANIM_OFF;
#endif
bool state = lv_sw_get_state(sw);
bool state = lv_switch_get_state(sw);
if(state)
lv_sw_off(sw, anim);
lv_switch_off(sw, anim);
else
lv_sw_on(sw, anim);
lv_switch_on(sw, anim);
return !state;
}
@ -190,7 +190,7 @@ bool lv_sw_toggle(lv_obj_t * sw, lv_anim_enable_t anim)
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
* @param return an element of `lv_design_res_t`
*/
static lv_design_res_t lv_sw_design(lv_obj_t * sw, const lv_area_t * clip_area, lv_design_mode_t mode)
static lv_design_res_t lv_switch_design(lv_obj_t * sw, const lv_area_t * clip_area, lv_design_mode_t mode)
{
/*Return false if the object is not covers the mask_p area*/
if(mode == LV_DESIGN_COVER_CHK) {
@ -203,15 +203,15 @@ static lv_design_res_t lv_sw_design(lv_obj_t * sw, const lv_area_t * clip_area,
* It also sets ext->bar.indic_area*/
ancestor_design(sw, clip_area, mode);
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
lv_switch_ext_t * ext = lv_obj_get_ext_attr(sw);
lv_coord_t objw = lv_obj_get_width(sw);
lv_coord_t objh = lv_obj_get_height(sw);
lv_coord_t knob_size = objh;
lv_area_t knob_area;
lv_style_int_t bg_left = lv_obj_get_style_pad_left(sw, LV_SW_PART_BG);
lv_style_int_t bg_right = lv_obj_get_style_pad_right(sw, LV_SW_PART_BG);
lv_style_int_t bg_left = lv_obj_get_style_pad_left(sw, LV_SWITCH_PART_BG);
lv_style_int_t bg_right = lv_obj_get_style_pad_right(sw, LV_SWITCH_PART_BG);
lv_coord_t max_indic_w = objw - bg_left - bg_right;
lv_coord_t act_indic_w = lv_area_get_width(&ext->bar.indic_area);
@ -222,10 +222,10 @@ static lv_design_res_t lv_sw_design(lv_obj_t * sw, const lv_area_t * clip_area,
knob_area.y1 = sw->coords.y1;
knob_area.y2 = sw->coords.y2;
lv_style_int_t knob_left = lv_obj_get_style_pad_left(sw, LV_SW_PART_KNOB);
lv_style_int_t knob_right = lv_obj_get_style_pad_right(sw, LV_SW_PART_KNOB);
lv_style_int_t knob_top = lv_obj_get_style_pad_top(sw, LV_SW_PART_KNOB);
lv_style_int_t knob_bottom = lv_obj_get_style_pad_bottom(sw, LV_SW_PART_KNOB);
lv_style_int_t knob_left = lv_obj_get_style_pad_left(sw, LV_SWITCH_PART_KNOB);
lv_style_int_t knob_right = lv_obj_get_style_pad_right(sw, LV_SWITCH_PART_KNOB);
lv_style_int_t knob_top = lv_obj_get_style_pad_top(sw, LV_SWITCH_PART_KNOB);
lv_style_int_t knob_bottom = lv_obj_get_style_pad_bottom(sw, LV_SWITCH_PART_KNOB);
/*Apply the paddings on the knob area*/
knob_area.x1 -= knob_left;
@ -235,7 +235,7 @@ static lv_design_res_t lv_sw_design(lv_obj_t * sw, const lv_area_t * clip_area,
lv_draw_rect_dsc_t knob_rect_dsc;
lv_draw_rect_dsc_init(&knob_rect_dsc);
lv_obj_init_draw_rect_dsc(sw, LV_SW_PART_KNOB, &knob_rect_dsc);
lv_obj_init_draw_rect_dsc(sw, LV_SWITCH_PART_KNOB, &knob_rect_dsc);
lv_draw_rect(&knob_area, clip_area, &knob_rect_dsc);
@ -256,13 +256,13 @@ static lv_design_res_t lv_sw_design(lv_obj_t * sw, const lv_area_t * clip_area,
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
static lv_res_t lv_switch_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
{
lv_res_t res;
if(sign == LV_SIGNAL_GET_STYLE) {
lv_get_style_info_t * info = param;
info->result = lv_sw_get_style(sw, info->part);
info->result = lv_switch_get_style(sw, info->part);
if(info->result != NULL) return LV_RES_OK;
else return ancestor_signal(sw, sign, param);
}
@ -280,16 +280,16 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
if(sign == LV_SIGNAL_CLEANUP) {
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
} else if(sign == LV_SIGNAL_RELEASED) {
if(lv_sw_get_state(sw)) lv_sw_off(sw, LV_ANIM_ON);
else lv_sw_on(sw, LV_ANIM_ON);
if(lv_switch_get_state(sw)) lv_switch_off(sw, LV_ANIM_ON);
else lv_switch_on(sw, LV_ANIM_ON);
res = lv_event_send(sw, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res;
} else if(sign == LV_SIGNAL_CONTROL) {
char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) lv_sw_on(sw, LV_ANIM_ON);
else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) lv_sw_off(sw, LV_ANIM_ON);
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) lv_switch_on(sw, LV_ANIM_ON);
else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) lv_switch_off(sw, LV_ANIM_ON);
res = lv_event_send(sw, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res;
@ -317,21 +317,21 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
return res;
}
static lv_style_list_t * lv_sw_get_style(lv_obj_t * sw, uint8_t part)
static lv_style_list_t * lv_switch_get_style(lv_obj_t * sw, uint8_t part)
{
LV_ASSERT_OBJ(sw, LV_OBJX_NAME);
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
lv_switch_ext_t * ext = lv_obj_get_ext_attr(sw);
lv_style_list_t * style_dsc_p;
switch(part) {
case LV_SW_PART_BG:
case LV_SWITCH_PART_BG:
style_dsc_p = &sw->style_list;
break;
case LV_SW_PART_INDIC:
case LV_SWITCH_PART_INDIC:
style_dsc_p = &ext->bar.style_indic;
break;
case LV_SW_PART_KNOB:
case LV_SWITCH_PART_KNOB:
style_dsc_p = &ext->style_knob;
break;
default:

View File

@ -3,8 +3,8 @@
*
*/
#ifndef LV_SW_H
#define LV_SW_H
#ifndef LV_SWITCH_H
#define LV_SWITCH_H
#ifdef __cplusplus
extern "C" {
@ -15,7 +15,7 @@ extern "C" {
*********************/
#include "../lv_conf_internal.h"
#if LV_USE_SW != 0
#if LV_USE_SWITCH != 0
/*Testing of dependencies*/
#if LV_USE_SLIDER == 0
@ -39,19 +39,19 @@ typedef struct
/*New data for this type */
lv_style_list_t style_knob; /*Style of the knob*/
uint8_t state :1; /*The current state*/
} lv_sw_ext_t;
} lv_switch_ext_t;
/**
* Switch parts.
*/
enum {
LV_SW_PART_BG = LV_BAR_PART_BG, /**< Switch background. */
LV_SW_PART_INDIC = LV_BAR_PART_INDIC, /**< Switch fill area. */
LV_SW_PART_KNOB = _LV_BAR_PART_VIRTUAL_LAST, /**< Switch knob. */
_LV_SW_PART_VIRTUAL_LAST
LV_SWITCH_PART_BG = LV_BAR_PART_BG, /**< Switch background. */
LV_SWITCH_PART_INDIC = LV_BAR_PART_INDIC, /**< Switch fill area. */
LV_SWITCH_PART_KNOB = _LV_BAR_PART_VIRTUAL_LAST, /**< Switch knob. */
_LV_SWITCH_PART_VIRTUAL_LAST
};
typedef uint8_t lv_sw_part_t;
typedef uint8_t lv_switch_part_t;
/**********************
* GLOBAL PROTOTYPES
@ -63,7 +63,7 @@ typedef uint8_t lv_sw_part_t;
* @param copy pointer to a switch object, if not NULL then the new object will be copied from it
* @return pointer to the created switch
*/
lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy);
lv_obj_t * lv_switch_create(lv_obj_t * par, const lv_obj_t * copy);
/*=====================
* Setter functions
@ -74,14 +74,14 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy);
* @param sw pointer to a switch object
* @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately
*/
void lv_sw_on(lv_obj_t * sw, lv_anim_enable_t anim);
void lv_switch_on(lv_obj_t * sw, lv_anim_enable_t anim);
/**
* Turn OFF the switch
* @param sw pointer to a switch object
* @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately
*/
void lv_sw_off(lv_obj_t * sw, lv_anim_enable_t anim);
void lv_switch_off(lv_obj_t * sw, lv_anim_enable_t anim);
/**
* Toggle the position of the switch
@ -89,7 +89,7 @@ void lv_sw_off(lv_obj_t * sw, lv_anim_enable_t anim);
* @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately
* @return resulting state of the switch.
*/
bool lv_sw_toggle(lv_obj_t * sw, lv_anim_enable_t anim);
bool lv_switch_toggle(lv_obj_t * sw, lv_anim_enable_t anim);
/**
* Set an image to display on the knob of the switch.
@ -97,7 +97,7 @@ bool lv_sw_toggle(lv_obj_t * sw, lv_anim_enable_t anim);
* @param img_src pointer to an `lv_img_dsc_t` variable or a path to an image
* (not an `lv_img` object)
*/
void lv_sw_set_knob_img(lv_obj_t * sw, const void * img_src);
void lv_switch_set_knob_img(lv_obj_t * sw, const void * img_src);
/**
* Set an image to display on the knob of the switch when it's in ON state
@ -105,7 +105,7 @@ void lv_sw_set_knob_img(lv_obj_t * sw, const void * img_src);
* @param img_src pointer to an `lv_img_dsc_t` variable or a path to an image
* (not an `lv_img` object)
*/
void lv_sw_set_knob_on_img(lv_obj_t * sw, const void * img_src);
void lv_switch_set_knob_on_img(lv_obj_t * sw, const void * img_src);
/**
* Set the animation time of the switch
@ -113,7 +113,7 @@ void lv_sw_set_knob_on_img(lv_obj_t * sw, const void * img_src);
* @param anim_time animation time
* @return style pointer to a style
*/
static inline void lv_sw_set_anim_time(lv_obj_t * sw, uint16_t anim_time)
static inline void lv_switch_set_anim_time(lv_obj_t * sw, uint16_t anim_time)
{
lv_bar_set_anim_time(sw, anim_time);
}
@ -127,9 +127,9 @@ static inline void lv_sw_set_anim_time(lv_obj_t * sw, uint16_t anim_time)
* @param sw pointer to a switch object
* @return false: OFF; true: ON
*/
static inline bool lv_sw_get_state(const lv_obj_t * sw)
static inline bool lv_switch_get_state(const lv_obj_t * sw)
{
lv_sw_ext_t * ext = (lv_sw_ext_t *)lv_obj_get_ext_attr(sw);
lv_switch_ext_t * ext = (lv_switch_ext_t *)lv_obj_get_ext_attr(sw);
return ext->state ? true : false;
}
/**
@ -152,7 +152,7 @@ const void * lv_slider_get_knob_on_img(lv_obj_t * sw, const void * img_src);
* @param sw pointer to a switch object
* @return style pointer to a style
*/
static inline uint16_t lv_sw_get_anim_time(const lv_obj_t * sw)
static inline uint16_t lv_switch_get_anim_time(const lv_obj_t * sw)
{
return lv_bar_get_anim_time(sw);
}
@ -161,10 +161,10 @@ static inline uint16_t lv_sw_get_anim_time(const lv_obj_t * sw)
* MACROS
**********************/
#endif /*LV_USE_SW*/
#endif /*LV_USE_SWITCH*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_SW_H*/
#endif /*LV_SWITCH_H*/

File diff suppressed because it is too large Load Diff

View File

@ -3,8 +3,8 @@
*
*/
#ifndef LV_TA_H
#define LV_TA_H
#ifndef LV_TEXTAREA_H
#define LV_TEXTAREA_H
#ifdef __cplusplus
extern "C" {
@ -15,7 +15,7 @@ extern "C" {
*********************/
#include "../lv_conf_internal.h"
#if LV_USE_TA != 0
#if LV_USE_TEXTAREA != 0
/*Testing of dependencies*/
#if LV_USE_PAGE == 0
@ -33,9 +33,9 @@ extern "C" {
/*********************
* DEFINES
*********************/
#define LV_TA_CURSOR_LAST (0x7FFF) /*Put the cursor after the last character*/
#define LV_TEXTAREA_CURSOR_LAST (0x7FFF) /*Put the cursor after the last character*/
LV_EXPORT_CONST_INT(LV_TA_CURSOR_LAST);
LV_EXPORT_CONST_INT(LV_TEXTAREA_CURSOR_LAST);
/**********************
* TYPEDEFS
@ -74,20 +74,20 @@ typedef struct
#endif
uint8_t pwd_mode : 1; /*Replace characters with '*' */
uint8_t one_line : 1; /*One line mode (ignore line breaks)*/
} lv_ta_ext_t;
} lv_textarea_ext_t;
/** Possible text areas tyles. */
enum {
LV_TA_PART_BG = LV_PAGE_PART_BG, /**< Text area background style */
LV_TA_PART_SCRLBAR = LV_PAGE_PART_SCRLBAR, /**< Scrollbar style */
LV_TA_PART_EDGE_FLASH = LV_PAGE_PART_EDGE_FLASH, /**< Edge flash style */
LV_TA_PART_CURSOR = _LV_PAGE_PART_VIRTUAL_LAST, /**< Cursor style */
_LV_TA_PART_VIRTUAL_LAST,
LV_TEXTAREA_PART_BG = LV_PAGE_PART_BG, /**< Text area background style */
LV_TEXTAREA_PART_SCRLBAR = LV_PAGE_PART_SCRLBAR, /**< Scrollbar style */
LV_TEXTAREA_PART_EDGE_FLASH = LV_PAGE_PART_EDGE_FLASH, /**< Edge flash style */
LV_TEXTAREA_PART_CURSOR = _LV_PAGE_PART_VIRTUAL_LAST, /**< Cursor style */
_LV_TEXTAREA_PART_VIRTUAL_LAST,
LV_TA_PART_PLACEHOLDER = _LV_PAGE_PART_REAL_LAST, /**< Placeholder style */
_LV_TA_PART_REAL_LAST,
LV_TEXTAREA_PART_PLACEHOLDER = _LV_PAGE_PART_REAL_LAST, /**< Placeholder style */
_LV_TEXTAREA_PART_REAL_LAST,
};
typedef uint8_t lv_ta_style_t;
typedef uint8_t lv_textarea_style_t;
/**********************
* GLOBAL PROTOTYPES
@ -99,7 +99,7 @@ typedef uint8_t lv_ta_style_t;
* @param copy pointer to a text area object, if not NULL then the new object will be copied from it
* @return pointer to the created text area
*/
lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy);
lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy);
/*======================
* Add/remove functions
@ -111,26 +111,26 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy);
* @param ta pointer to a text area object
* @param c a character (e.g. 'a')
*/
void lv_ta_add_char(lv_obj_t * ta, uint32_t c);
void lv_textarea_add_char(lv_obj_t * ta, uint32_t c);
/**
* Insert a text to the current cursor position
* @param ta pointer to a text area object
* @param txt a '\0' terminated string to insert
*/
void lv_ta_add_text(lv_obj_t * ta, const char * txt);
void lv_textarea_add_text(lv_obj_t * ta, const char * txt);
/**
* Delete a the left character from the current cursor position
* @param ta pointer to a text area object
*/
void lv_ta_del_char(lv_obj_t * ta);
void lv_textarea_del_char(lv_obj_t * ta);
/**
* Delete the right character from the current cursor position
* @param ta pointer to a text area object
*/
void lv_ta_del_char_forward(lv_obj_t * ta);
void lv_textarea_del_char_forward(lv_obj_t * ta);
/*=====================
* Setter functions
@ -141,51 +141,51 @@ void lv_ta_del_char_forward(lv_obj_t * ta);
* @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);
void lv_textarea_set_text(lv_obj_t * ta, const char * txt);
/**
* Set the placeholder text of a text area
* @param ta pointer to a text area
* @param txt pointer to the text
*/
void lv_ta_set_placeholder_text(lv_obj_t * ta, const char * txt);
void lv_textarea_set_placeholder_text(lv_obj_t * ta, const char * txt);
/**
* 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_CURSOR_LAST: go after the last character
* LV_TEXTAREA_CURSOR_LAST: go after the last character
*/
void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos);
void lv_textarea_set_cursor_pos(lv_obj_t * ta, int16_t pos);
/**
* Hide/Unhide the cursor.
* @param ta pointer to a text area object
* @param hide: true: hide the cursor
*/
void lv_ta_set_cursor_hidden(lv_obj_t * ta, bool hide);
void lv_textarea_set_cursor_hidden(lv_obj_t * ta, bool hide);
/**
* Enable/Disable the positioning of the the cursor by clicking the text on the text area.
* @param ta pointer to a text area object
* @param en true: enable click positions; false: disable
*/
void lv_ta_set_cursor_click_pos(lv_obj_t * ta, bool en);
void lv_textarea_set_cursor_click_pos(lv_obj_t * ta, bool en);
/**
* Enable/Disable password mode
* @param ta pointer to a text area object
* @param en true: enable, false: disable
*/
void lv_ta_set_pwd_mode(lv_obj_t * ta, bool en);
void lv_textarea_set_pwd_mode(lv_obj_t * ta, bool en);
/**
* Configure the text area to one line or back to normal
* @param ta pointer to a Text area object
* @param en true: one line, false: normal
*/
void lv_ta_set_one_line(lv_obj_t * ta, bool en);
void lv_textarea_set_one_line(lv_obj_t * ta, bool en);
/**
* Set the alignment of the text area.
@ -194,21 +194,21 @@ void lv_ta_set_one_line(lv_obj_t * ta, bool en);
* @param ta pointer to a text are object
* @param align the desired alignment from `lv_label_align_t`. (LV_LABEL_ALIGN_LEFT/CENTER/RIGHT)
*/
void lv_ta_set_text_align(lv_obj_t * ta, lv_label_align_t align);
void lv_textarea_set_text_align(lv_obj_t * ta, lv_label_align_t align);
/**
* Set a list of characters. Only these characters will be accepted by the text area
* @param ta pointer to Text Area
* @param list list of characters. Only the pointer is saved. E.g. "+-.,0123456789"
*/
void lv_ta_set_accepted_chars(lv_obj_t * ta, const char * list);
void lv_textarea_set_accepted_chars(lv_obj_t * ta, const char * list);
/**
* Set max length of a Text Area.
* @param ta pointer to Text Area
* @param num the maximal number of characters can be added (`lv_ta_set_text` ignores it)
* @param num the maximal number of characters can be added (`lv_textarea_set_text` ignores it)
*/
void lv_ta_set_max_length(lv_obj_t * ta, uint16_t num);
void lv_textarea_set_max_length(lv_obj_t * ta, uint16_t num);
/**
* In `LV_EVENT_INSERT` the text which planned to be inserted can be replaced by an other text.
@ -218,14 +218,14 @@ void lv_ta_set_max_length(lv_obj_t * ta, uint16_t num);
* The variable must be live after the `event_cb` exists. (Should be `global` or
* `static`)
*/
void lv_ta_set_insert_replace(lv_obj_t * ta, const char * txt);
void lv_textarea_set_insert_replace(lv_obj_t * ta, const char * txt);
/**
* Set the scroll bar mode of a text area
* @param ta pointer to a text area object
* @param sb_mode the new mode from 'lv_page_sb_mode_t' enum
*/
static inline void lv_ta_set_sb_mode(lv_obj_t * ta, lv_sb_mode_t mode)
static inline void lv_textarea_set_sb_mode(lv_obj_t * ta, lv_sb_mode_t mode)
{
lv_page_set_sb_mode(ta, mode);
}
@ -236,7 +236,7 @@ static inline void lv_ta_set_sb_mode(lv_obj_t * ta, lv_sb_mode_t mode)
* @param ta pointer to a Text area
* @param en true or false to enable/disable scroll propagation
*/
static inline void lv_ta_set_scroll_propagation(lv_obj_t * ta, bool en)
static inline void lv_textarea_set_scroll_propagation(lv_obj_t * ta, bool en)
{
lv_page_set_scroll_propagation(ta, en);
}
@ -246,7 +246,7 @@ static inline void lv_ta_set_scroll_propagation(lv_obj_t * ta, bool en)
* @param page pointer to a Text Area
* @param en true or false to enable/disable end flash
*/
static inline void lv_ta_set_edge_flash(lv_obj_t * ta, bool en)
static inline void lv_textarea_set_edge_flash(lv_obj_t * ta, bool en)
{
lv_page_set_edge_flash(ta, en);
}
@ -256,21 +256,21 @@ static inline void lv_ta_set_edge_flash(lv_obj_t * ta, bool en)
* @param ta pointer to a text area object
* @param en true or false to enable/disable selection mode
*/
void lv_ta_set_text_sel(lv_obj_t * ta, bool en);
void lv_textarea_set_text_sel(lv_obj_t * ta, bool en);
/**
* Set how long show the password before changing it to '*'
* @param ta pointer to Text area
* @param time show time in milliseconds. 0: hide immediately.
*/
void lv_ta_set_pwd_show_time(lv_obj_t * ta, uint16_t time);
void lv_textarea_set_pwd_show_time(lv_obj_t * ta, uint16_t time);
/**
* Set cursor blink animation time
* @param ta pointer to Text area
* @param time blink period. 0: disable blinking
*/
void lv_ta_set_cursor_blink_time(lv_obj_t * ta, uint16_t time);
void lv_textarea_set_cursor_blink_time(lv_obj_t * ta, uint16_t time);
/*=====================
* Getter functions
@ -281,77 +281,77 @@ void lv_ta_set_cursor_blink_time(lv_obj_t * ta, uint16_t time);
* @param ta pointer to a text area object
* @return pointer to the text
*/
const char * lv_ta_get_text(const lv_obj_t * ta);
const char * lv_textarea_get_text(const lv_obj_t * ta);
/**
* Get the placeholder text of a text area
* @param ta pointer to a text area object
* @return pointer to the text
*/
const char * lv_ta_get_placeholder_text(lv_obj_t * ta);
const char * lv_textarea_get_placeholder_text(lv_obj_t * ta);
/**
* Get the label of a text area
* @param ta pointer to a text area object
* @return pointer to the label object
*/
lv_obj_t * lv_ta_get_label(const lv_obj_t * ta);
lv_obj_t * lv_textarea_get_label(const lv_obj_t * ta);
/**
* Get the current cursor position in character index
* @param ta pointer to a text area object
* @return the cursor position
*/
uint16_t lv_ta_get_cursor_pos(const lv_obj_t * ta);
uint16_t lv_textarea_get_cursor_pos(const lv_obj_t * ta);
/**
* Get whether the cursor is hidden or not
* @param ta pointer to a text area object
* @return true: the cursor is hidden
*/
bool lv_ta_get_cursor_hidden(const lv_obj_t * ta);
bool lv_textarea_get_cursor_hidden(const lv_obj_t * ta);
/**
* Get whether the cursor click positioning is enabled or not.
* @param ta pointer to a text area object
* @return true: enable click positions; false: disable
*/
bool lv_ta_get_cursor_click_pos(lv_obj_t * ta);
bool lv_textarea_get_cursor_click_pos(lv_obj_t * ta);
/**
* Get the password mode attribute
* @param ta pointer to a text area object
* @return true: password mode is enabled, false: disabled
*/
bool lv_ta_get_pwd_mode(const lv_obj_t * ta);
bool lv_textarea_get_pwd_mode(const lv_obj_t * ta);
/**
* Get the one line configuration attribute
* @param ta pointer to a text area object
* @return true: one line configuration is enabled, false: disabled
*/
bool lv_ta_get_one_line(const lv_obj_t * ta);
bool lv_textarea_get_one_line(const lv_obj_t * ta);
/**
* Get a list of accepted characters.
* @param ta pointer to Text Area
* @return list of accented characters.
*/
const char * lv_ta_get_accepted_chars(lv_obj_t * ta);
const char * lv_textarea_get_accepted_chars(lv_obj_t * ta);
/**
* Set max length of a Text Area.
* @param ta pointer to Text Area
* @return the maximal number of characters to be add
*/
uint16_t lv_ta_get_max_length(lv_obj_t * ta);
uint16_t lv_textarea_get_max_length(lv_obj_t * ta);
/**
* Get the scroll bar mode of a text area
* @param ta pointer to a text area object
* @return scrollbar mode from 'lv_page_sb_mode_t' enum
*/
static inline lv_sb_mode_t lv_ta_get_sb_mode(const lv_obj_t * ta)
static inline lv_sb_mode_t lv_textarea_get_sb_mode(const lv_obj_t * ta)
{
return lv_page_get_sb_mode(ta);
}
@ -361,7 +361,7 @@ static inline lv_sb_mode_t lv_ta_get_sb_mode(const lv_obj_t * ta)
* @param ta pointer to a Text area
* @return true or false
*/
static inline bool lv_ta_get_scroll_propagation(lv_obj_t * ta)
static inline bool lv_textarea_get_scroll_propagation(lv_obj_t * ta)
{
return lv_page_get_scroll_propagation(ta);
}
@ -371,7 +371,7 @@ static inline bool lv_ta_get_scroll_propagation(lv_obj_t * ta)
* @param ta pointer to a Text area
* @return true or false
*/
static inline bool lv_ta_get_edge_flash(lv_obj_t * ta)
static inline bool lv_textarea_get_edge_flash(lv_obj_t * ta)
{
return lv_page_get_edge_flash(ta);
}
@ -381,28 +381,28 @@ static inline bool lv_ta_get_edge_flash(lv_obj_t * ta)
* @param ta Text area object
* @return whether text is selected or not
*/
bool lv_ta_text_is_selected(const lv_obj_t * ta);
bool lv_textarea_text_is_selected(const lv_obj_t * ta);
/**
* Find whether selection mode is enabled.
* @param ta pointer to a text area object
* @return true: selection mode is enabled, false: disabled
*/
bool lv_ta_get_text_sel_en(lv_obj_t * ta);
bool lv_textarea_get_text_sel_en(lv_obj_t * ta);
/**
* Set how long show the password before changing it to '*'
* @param ta pointer to Text area
* @return show time in milliseconds. 0: hide immediately.
*/
uint16_t lv_ta_get_pwd_show_time(lv_obj_t * ta);
uint16_t lv_textarea_get_pwd_show_time(lv_obj_t * ta);
/**
* Set cursor blink animation time
* @param ta pointer to Text area
* @return time blink period. 0: disable blinking
*/
uint16_t lv_ta_get_cursor_blink_time(lv_obj_t * ta);
uint16_t lv_textarea_get_cursor_blink_time(lv_obj_t * ta);
/*=====================
* Other functions
@ -412,40 +412,40 @@ uint16_t lv_ta_get_cursor_blink_time(lv_obj_t * ta);
* Clear the selection on the text area.
* @param ta Text area object
*/
void lv_ta_clear_selection(lv_obj_t * ta);
void lv_textarea_clear_selection(lv_obj_t * ta);
/**
* Move the cursor one character right
* @param ta pointer to a text area object
*/
void lv_ta_cursor_right(lv_obj_t * ta);
void lv_textarea_cursor_right(lv_obj_t * ta);
/**
* Move the cursor one character left
* @param ta pointer to a text area object
*/
void lv_ta_cursor_left(lv_obj_t * ta);
void lv_textarea_cursor_left(lv_obj_t * ta);
/**
* Move the cursor one line down
* @param ta pointer to a text area object
*/
void lv_ta_cursor_down(lv_obj_t * ta);
void lv_textarea_cursor_down(lv_obj_t * ta);
/**
* Move the cursor one line up
* @param ta pointer to a text area object
*/
void lv_ta_cursor_up(lv_obj_t * ta);
void lv_textarea_cursor_up(lv_obj_t * ta);
/**********************
* MACROS
**********************/
#endif /*LV_USE_TA_H*/
#endif /*LV_USE_TEXTAREA_H*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_TA_H*/
#endif /*LV_TEXTAREA_H*/

View File

@ -7,7 +7,7 @@
* INCLUDES
*********************/
#include "lv_table.h"
#if LV_USE_TABLE != 0
#if LV_USE_TEXTAREABLE != 0
#include "../lv_core/lv_debug.h"
#include "../lv_misc/lv_txt.h"

View File

@ -15,7 +15,7 @@ extern "C" {
*********************/
#include "../lv_conf_internal.h"
#if LV_USE_TABLE != 0
#if LV_USE_TEXTAREABLE != 0
/*Testing of dependencies*/
#if LV_USE_LABEL == 0
@ -238,7 +238,7 @@ bool lv_table_get_cell_merge_right(lv_obj_t * table, uint16_t row, uint16_t col)
* MACROS
**********************/
#endif /*LV_USE_TABLE*/
#endif /*LV_USE_TEXTAREABLE*/
#ifdef __cplusplus
} /* extern "C" */

View File

@ -7,7 +7,7 @@
* INCLUDES
*********************/
#include "lv_tabview.h"
#if LV_USE_TABVIEW != 0
#if LV_USE_TEXTAREABVIEW != 0
#include "lv_btnm.h"
#include "../lv_core/lv_debug.h"
@ -125,13 +125,13 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_set_size(tabview, w, h);
ext->content = lv_page_create(tabview, NULL);
ext->btns = lv_btnm_create(tabview, NULL);
ext->btns = lv_btnmatrix_create(tabview, NULL);
ext->indic = lv_obj_create(ext->btns, NULL);
if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(ext->content));
lv_obj_set_signal_cb(lv_page_get_scrl(ext->content), tabview_scrl_signal);
lv_btnm_set_map(ext->btns, tab_def);
lv_btnmatrix_set_map(ext->btns, tab_def);
lv_obj_set_event_cb(ext->btns, tab_btnm_event_cb);
lv_obj_set_click(ext->indic, false);
@ -151,7 +151,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
lv_tabview_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->point_last.x = 0;
ext->point_last.y = 0;
ext->btns = lv_btnm_create(tabview, copy_ext->btns);
ext->btns = lv_btnmatrix_create(tabview, copy_ext->btns);
ext->indic = lv_obj_create(ext->btns, copy_ext->indic);
ext->content = lv_page_create(tabview, copy_ext->content);
#if LV_USE_ANIMATION
@ -162,7 +162,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
LV_ASSERT_MEM(ext->tab_name_ptr);
if(ext->tab_name_ptr == NULL) return NULL;
ext->tab_name_ptr[0] = "";
lv_btnm_set_map(ext->btns, ext->tab_name_ptr);
lv_btnmatrix_set_map(ext->btns, ext->tab_name_ptr);
lv_style_list_copy(lv_obj_get_style_list(tabview, LV_TABVIEW_PART_BG_SCRL), lv_obj_get_style_list(copy, LV_TABVIEW_PART_BG_SCRL));
lv_style_list_copy(lv_obj_get_style_list(tabview, LV_TABVIEW_PART_TAB_BG), lv_obj_get_style_list(copy, LV_TABVIEW_PART_TAB_BG));
@ -289,11 +289,11 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
/* The button matrix's map still points to the old `tab_name_ptr` which might be freed by
* `lv_mem_realloc`. So make its current map invalid*/
lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns);
lv_btnmatrix_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns);
btnm_ext->map_p = NULL;
lv_btnm_set_map(ext->btns, ext->tab_name_ptr);
lv_btnm_set_btn_ctrl(ext->btns, ext->tab_cur, LV_BTNM_CTRL_NO_REPEAT);
lv_btnmatrix_set_map(ext->btns, ext->tab_name_ptr);
lv_btnmatrix_set_btn_ctrl(ext->btns, ext->tab_cur, LV_BTNMATRIX_CTRL_NO_REPEAT);
/*Set the first btn as active*/
if(ext->tab_cnt == 1) ext->tab_cur = 0;
@ -326,7 +326,7 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an
if(id >= ext->tab_cnt) id = ext->tab_cnt - 1;
lv_btnm_clear_btn_ctrl(ext->btns, ext->tab_cur, LV_BTNM_CTRL_CHECHK_STATE);
lv_btnmatrix_clear_btn_ctrl(ext->btns, ext->tab_cur, LV_BTNMATRIX_CTRL_CHECHK_STATE);
ext->tab_cur = id;
@ -445,7 +445,7 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an
}
#endif
lv_btnm_set_btn_ctrl(ext->btns, ext->tab_cur, LV_BTNM_CTRL_CHECHK_STATE);
lv_btnmatrix_set_btn_ctrl(ext->btns, ext->tab_cur, LV_BTNMATRIX_CTRL_CHECHK_STATE);
}
/**
@ -596,8 +596,8 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
} else if(sign == LV_SIGNAL_GET_STATE_DSC) {
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
lv_get_state_info_t * info = param;
if(info->part == LV_TABVIEW_PART_TAB_BG) info->result = lv_obj_get_state_dsc(ext->btns, LV_BTNM_PART_BG);
else if(info->part == LV_TABVIEW_PART_TAB) info->result = lv_obj_get_state_dsc(ext->btns, LV_BTNM_PART_BTN);
if(info->part == LV_TABVIEW_PART_TAB_BG) info->result = lv_obj_get_state_dsc(ext->btns, LV_BTNMATRIX_PART_BG);
else if(info->part == LV_TABVIEW_PART_TAB) info->result = lv_obj_get_state_dsc(ext->btns, LV_BTNMATRIX_PART_BTN);
else if(info->part == LV_TABVIEW_PART_INDIC) info->result = lv_obj_get_state_dsc(ext->indic, LV_OBJ_PART_MAIN);
else if(info->part == LV_TABVIEW_PART_BG_SCRL) info->result = lv_obj_get_state_dsc(ext->content, LV_PAGE_PART_SCRL);
return LV_RES_OK;
@ -741,10 +741,10 @@ static lv_style_list_t * lv_tabview_get_style(lv_obj_t * tabview, uint8_t part)
style_dsc_p = lv_obj_get_style_list(ext->content, LV_PAGE_PART_SCRL);
break;
case LV_TABVIEW_PART_TAB_BG:
style_dsc_p = lv_obj_get_style_list(ext->btns, LV_BTNM_PART_BG);
style_dsc_p = lv_obj_get_style_list(ext->btns, LV_BTNMATRIX_PART_BG);
break;
case LV_TABVIEW_PART_TAB:
style_dsc_p = lv_obj_get_style_list(ext->btns, LV_BTNM_PART_BTN);
style_dsc_p = lv_obj_get_style_list(ext->btns, LV_BTNMATRIX_PART_BTN);
break;
case LV_TABVIEW_PART_INDIC:
style_dsc_p = lv_obj_get_style_list(ext->indic, LV_OBJ_PART_MAIN);
@ -766,11 +766,11 @@ static void tab_btnm_event_cb(lv_obj_t * tab_btnm, lv_event_t event)
{
if(event != LV_EVENT_CLICKED) return;
uint16_t btn_id = lv_btnm_get_active_btn(tab_btnm);
if(btn_id == LV_BTNM_BTN_NONE) return;
uint16_t btn_id = lv_btnmatrix_get_active_btn(tab_btnm);
if(btn_id == LV_BTNMATRIX_BTN_NONE) return;
lv_btnm_clear_btn_ctrl_all(tab_btnm, LV_BTNM_CTRL_CHECHK_STATE);
lv_btnm_set_btn_ctrl(tab_btnm, btn_id, LV_BTNM_CTRL_CHECHK_STATE);
lv_btnmatrix_clear_btn_ctrl_all(tab_btnm, LV_BTNMATRIX_CTRL_CHECHK_STATE);
lv_btnmatrix_set_btn_ctrl(tab_btnm, btn_id, LV_BTNMATRIX_CTRL_CHECHK_STATE);
lv_obj_t * tabview = lv_obj_get_parent(tab_btnm);
@ -806,7 +806,7 @@ static void tabview_realign(lv_obj_t * tabview)
static void refr_indic_size(lv_obj_t * tabview)
{
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns);
lv_btnmatrix_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns);
lv_coord_t indic_size = lv_obj_get_style_size(tabview, LV_TABVIEW_PART_INDIC);

View File

@ -15,11 +15,11 @@ extern "C" {
*********************/
#include "../lv_conf_internal.h"
#if LV_USE_TABVIEW != 0
#if LV_USE_TEXTAREABVIEW != 0
/*Testing of dependencies*/
#if LV_USE_BTNM == 0
#error "lv_tabview: lv_btnm is required. Enable it in lv_conf.h (LV_USE_BTNM 1) "
#if LV_USE_BTNMATRIX == 0
#error "lv_tabview: lv_btnm is required. Enable it in lv_conf.h (LV_USE_BTNMATRIX 1) "
#endif
#if LV_USE_PAGE == 0
@ -176,7 +176,7 @@ lv_tabview_btns_pos_t lv_tabview_get_btns_pos(const lv_obj_t * tabview);
* MACROS
**********************/
#endif /*LV_USE_TABVIEW*/
#endif /*LV_USE_TEXTAREABVIEW*/
#ifdef __cplusplus
} /* extern "C" */

View File

@ -50,11 +50,11 @@ static lv_style_t btn;
static lv_style_t sb;
#if LV_USE_BTNM
#if LV_USE_BTNMATRIX
static lv_style_t btnm_bg, btnm_btn;
#endif
#if LV_USE_BTNM
#if LV_USE_BTNMATRIX
static lv_style_t kb_bg, kb_btn;
#endif
@ -67,11 +67,11 @@ static lv_style_t bar_indic;
static lv_style_t slider_knob;
#endif
#if LV_USE_SW
#if LV_USE_SWITCH
static lv_style_t sw_knob;
#endif
#if LV_USE_CB
#if LV_USE_CHECKBOX
static lv_style_t cb_bg, cb_bullet;
#endif
@ -88,11 +88,11 @@ static lv_style_t gauge_main, gauge_strong, gauge_needle;
static lv_style_t list_bg, list_btn;
#endif
#if LV_USE_DDLIST
#if LV_USE_DROPDOWN
static lv_style_t ddlist_btn, ddlist_page, ddlist_sel;
#endif
#if LV_USE_TA
#if LV_USE_TEXTAREA
static lv_style_t ta_cursor, ta_oneline, ta_placeholder;
#endif
@ -114,15 +114,15 @@ static lv_style_t cpicker_bg, cpicker_indic;
#endif
#if LV_USE_MBOX
#if LV_USE_MSGBOX
static lv_style_t mbox_btn, mbox_btn_bg;
#endif
#if LV_USE_TABVIEW
#if LV_USE_TEXTAREABVIEW
static lv_style_t tabview_btns, tabview_btns_bg, tabview_indic, tabview_page_scrl;
#endif
#if LV_USE_TABLE
#if LV_USE_TEXTAREABLE
static lv_style_t table_cell;
#endif
@ -407,7 +407,7 @@ static void slider_init(void)
static void sw_init(void)
{
#if LV_USE_SW != 0
#if LV_USE_SWITCH != 0
lv_style_init(&sw_knob);
lv_style_set_bg_opa(&sw_knob, LV_STATE_NORMAL, LV_OPA_COVER);
lv_style_set_bg_color(&sw_knob, LV_STATE_NORMAL, LV_COLOR_WHITE);
@ -497,7 +497,7 @@ static void arc_init(void)
static void preload_init(void)
{
#if LV_USE_PRELOAD != 0
#if LV_USE_SPINNER != 0
// theme.style.preload = theme.style.arc;
#endif
@ -591,7 +591,7 @@ static void cpicker_init(void)
static void cb_init(void)
{
#if LV_USE_CB != 0
#if LV_USE_CHECKBOX != 0
lv_style_init(&cb_bg);
lv_style_set_pad_inner(&cb_bg, LV_STATE_NORMAL , LV_DPI / 10);
@ -615,7 +615,7 @@ static void cb_init(void)
static void btnm_init(void)
{
#if LV_USE_BTNM
#if LV_USE_BTNMATRIX
lv_style_init(&btnm_bg);
lv_style_set_bg_opa(&btnm_bg, LV_STATE_NORMAL, LV_OPA_COVER);
lv_style_set_border_width(&btnm_bg, LV_STATE_NORMAL, LV_DPI / 50);
@ -646,7 +646,7 @@ static void btnm_init(void)
static void kb_init(void)
{
#if LV_USE_KB
#if LV_USE_KEYBOARD
lv_style_init(&kb_bg);
lv_style_copy(&kb_bg, &panel);
lv_style_set_pad_inner(&kb_bg, LV_STATE_NORMAL, LV_DPI/20);
@ -660,7 +660,7 @@ static void kb_init(void)
static void mbox_init(void)
{
#if LV_USE_MBOX
#if LV_USE_MSGBOX
lv_style_init(&mbox_btn_bg);
lv_style_set_pad_right(&mbox_btn_bg, LV_STATE_NORMAL, LV_DPI / 10);
lv_style_set_pad_bottom(&mbox_btn_bg, LV_STATE_NORMAL, LV_DPI / 10);
@ -684,7 +684,7 @@ static void page_init(void)
static void ta_init(void)
{
#if LV_USE_TA
#if LV_USE_TEXTAREA
lv_style_init(&ta_cursor);
lv_style_set_border_color(&ta_cursor, LV_STATE_NORMAL, lv_color_hex(0x6c737b));
lv_style_set_border_width(&ta_cursor, LV_STATE_NORMAL, 2);
@ -752,7 +752,7 @@ static void list_init(void)
static void ddlist_init(void)
{
#if LV_USE_DDLIST != 0
#if LV_USE_DROPDOWN != 0
lv_style_init(&ddlist_btn);
lv_style_copy(&ddlist_btn, &panel);
@ -791,7 +791,7 @@ static void roller_init(void)
static void tabview_init(void)
{
#if LV_USE_TABVIEW != 0
#if LV_USE_TEXTAREABVIEW != 0
lv_style_init(&tabview_btns_bg);
lv_style_set_bg_opa(&tabview_btns_bg, LV_STATE_NORMAL, LV_OPA_COVER);
lv_style_set_bg_color(&tabview_btns_bg, LV_STATE_NORMAL, COLOR_CONTAINER);
@ -835,7 +835,7 @@ static void tileview_init(void)
static void table_init(void)
{
#if LV_USE_TABLE != 0
#if LV_USE_TEXTAREABLE != 0
lv_style_init(&table_cell);
lv_style_set_border_color(&table_cell, LV_STATE_NORMAL, lv_color_hex(0x303338));
lv_style_set_border_width(&table_cell, LV_STATE_NORMAL, 1);
@ -952,25 +952,25 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
break;
#endif
#if LV_USE_BTNM
#if LV_USE_BTNMATRIX
case LV_THEME_BTNM:
list = lv_obj_get_style_list(obj, LV_BTNM_PART_BG);
list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG);
lv_style_list_reset(list);
lv_style_list_add_style(list, &btnm_bg);
list = lv_obj_get_style_list(obj, LV_BTNM_PART_BTN);
list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN);
lv_style_list_reset(list);
lv_style_list_add_style(list, &btnm_btn);
break;
#endif
#if LV_USE_KB
#if LV_USE_KEYBOARD
case LV_THEME_KB:
list = lv_obj_get_style_list(obj, LV_KB_PART_BG);
list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG);
lv_style_list_reset(list);
lv_style_list_add_style(list, &kb_bg);
list = lv_obj_get_style_list(obj, LV_KB_PART_BTN);
list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN);
lv_style_list_reset(list);
lv_style_list_add_style(list, &btnm_btn);
break;
@ -988,17 +988,17 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
break;
#endif
#if LV_USE_SW
#if LV_USE_SWITCH
case LV_THEME_SW:
list = lv_obj_get_style_list(obj, LV_SW_PART_BG);
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_BG);
lv_style_list_reset(list);
lv_style_list_add_style(list, &bar_bg);
list = lv_obj_get_style_list(obj, LV_SW_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC);
lv_style_list_reset(list);
lv_style_list_add_style(list, &bar_indic);
list = lv_obj_get_style_list(obj, LV_SW_PART_KNOB);
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB);
lv_style_list_reset(list);
lv_style_list_add_style(list, &sw_knob);
break;
@ -1051,13 +1051,13 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
break;
#endif
#if LV_USE_PRELOAD
#if LV_USE_SPINNER
case LV_THEME_PRELOAD:
list = lv_obj_get_style_list(obj, LV_PRELOAD_PART_BG);
list = lv_obj_get_style_list(obj, LV_SPINNER_PART_BG);
lv_style_list_reset(list);
lv_style_list_add_style(list, &arc_bg);
list = lv_obj_get_style_list(obj, LV_PRELOAD_PART_ARC);
list = lv_obj_get_style_list(obj, LV_SPINNER_PART_ARC);
lv_style_list_reset(list);
lv_style_list_add_style(list, &arc);
break;
@ -1079,31 +1079,31 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
break;
#endif
#if LV_USE_CB
#if LV_USE_CHECKBOX
case LV_THEME_CB:
list = lv_obj_get_style_list(obj, LV_CB_PART_BG);
list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG);
lv_style_list_reset(list);
lv_style_list_add_style(list, &cb_bg);
list = lv_obj_get_style_list(obj, LV_CB_PART_BULLET);
list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET);
lv_style_list_reset(list);
lv_style_list_add_style(list, &cb_bullet);
break;
#endif
#if LV_USE_MBOX
#if LV_USE_MSGBOX
case LV_THEME_MBOX:
list = lv_obj_get_style_list(obj, LV_MBOX_PART_BG);
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG);
lv_style_list_reset(list);
lv_style_list_add_style(list, &panel);
break;
case LV_THEME_MBOX_BTNS:
list = lv_obj_get_style_list(obj, LV_MBOX_PART_BTN_BG);
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG);
lv_style_list_reset(list);
lv_style_list_add_style(list, &mbox_btn_bg);
list = lv_obj_get_style_list(obj, LV_MBOX_PART_BTN);
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN);
lv_style_list_reset(list);
lv_style_list_add_style(list, &btnm_btn);
break;
@ -1130,7 +1130,7 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
lv_style_list_add_style(list, &sb);
break;
#endif
#if LV_USE_TABVIEW
#if LV_USE_TEXTAREABVIEW
case LV_THEME_TABVIEW:
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG);
lv_style_list_reset(list);
@ -1222,21 +1222,21 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
break;
#endif
#if LV_USE_DDLIST
#if LV_USE_DROPDOWN
case LV_THEME_DDLIST:
list = lv_obj_get_style_list(obj, LV_DDLIST_PART_BTN);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_BTN);
lv_style_list_reset(list);
lv_style_list_add_style(list, &ddlist_btn);
list = lv_obj_get_style_list(obj, LV_DDLIST_PART_LIST);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST);
lv_style_list_reset(list);
lv_style_list_add_style(list, &ddlist_page);
list = lv_obj_get_style_list(obj, LV_DDLIST_PART_SCRLBAR);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCRLBAR);
lv_style_list_reset(list);
lv_style_list_add_style(list, &sb);
list = lv_obj_get_style_list(obj, LV_DDLIST_PART_SELECTED);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED);
lv_style_list_reset(list);
lv_style_list_add_style(list, &ddlist_sel);
break;
@ -1257,7 +1257,7 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
lv_style_list_add_style(list, &chart_series);
break;
#endif
#if LV_USE_TABLE
#if LV_USE_TEXTAREABLE
case LV_THEME_TABLE:
list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
lv_style_list_reset(list);
@ -1305,39 +1305,39 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
break;
#endif
#if LV_USE_TA
#if LV_USE_TEXTAREA
case LV_THEME_TA:
list = lv_obj_get_style_list(obj, LV_TA_PART_BG);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG);
lv_style_list_reset(list);
lv_style_list_add_style(list, &panel);
list = lv_obj_get_style_list(obj, LV_TA_PART_PLACEHOLDER);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER);
lv_style_list_reset(list);
lv_style_list_add_style(list, &ta_placeholder);
list = lv_obj_get_style_list(obj, LV_TA_PART_CURSOR);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR);
lv_style_list_reset(list);
lv_style_list_add_style(list, &ta_cursor);
list = lv_obj_get_style_list(obj, LV_TA_PART_SCRLBAR);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCRLBAR);
lv_style_list_reset(list);
lv_style_list_add_style(list, &sb);
break;
case LV_THEME_TA_ONELINE:
list = lv_obj_get_style_list(obj, LV_TA_PART_BG);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG);
lv_style_list_reset(list);
lv_style_list_add_style(list, &ta_oneline);
list = lv_obj_get_style_list(obj, LV_TA_PART_PLACEHOLDER);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER);
lv_style_list_reset(list);
lv_style_list_add_style(list, &ta_placeholder);
list = lv_obj_get_style_list(obj, LV_TA_PART_CURSOR);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR);
lv_style_list_reset(list);
lv_style_list_add_style(list, &ta_cursor);
list = lv_obj_get_style_list(obj, LV_TA_PART_SCRLBAR);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCRLBAR);
lv_style_list_reset(list);
lv_style_list_add_style(list, &sb);
break;
@ -1376,7 +1376,7 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_LMETER
case LV_THEME_LMETER:
list = lv_obj_get_style_list(obj, LV_LMETER_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN);
lv_style_list_reset(list);
lv_style_list_add_style(list, &lmeter);
break;

View File

@ -161,7 +161,7 @@ static void slider_init(void)
static void sw_init(void)
{
#if LV_USE_SW != 0
#if LV_USE_SWITCH != 0
static lv_style_t sw_bg;
lv_style_copy(&sw_bg, &lv_style_pretty);
sw_bg.body.padding.left = 3;
@ -215,7 +215,7 @@ static void chart_init(void)
static void cb_init(void)
{
#if LV_USE_CB != 0
#if LV_USE_CHECKBOX != 0
theme.style.cb.bg = &lv_style_transp;
theme.style.cb.box.rel = &lv_style_pretty;
@ -228,7 +228,7 @@ static void cb_init(void)
static void btnm_init(void)
{
#if LV_USE_BTNM
#if LV_USE_BTNMATRIX
theme.style.btnm.bg = &lv_style_pretty;
theme.style.btnm.btn.rel = &lv_style_btn_rel;
@ -241,7 +241,7 @@ static void btnm_init(void)
static void kb_init(void)
{
#if LV_USE_KB
#if LV_USE_KEYBOARD
theme.style.kb.bg = &lv_style_pretty;
theme.style.kb.btn.rel = &lv_style_btn_rel;
@ -254,7 +254,7 @@ static void kb_init(void)
static void mbox_init(void)
{
#if LV_USE_MBOX
#if LV_USE_MSGBOX
theme.style.mbox.bg = &lv_style_pretty;
theme.style.mbox.btn.bg = &lv_style_transp;
@ -275,7 +275,7 @@ static void page_init(void)
static void ta_init(void)
{
#if LV_USE_TA
#if LV_USE_TEXTAREA
theme.style.ta.area = &lv_style_pretty;
theme.style.ta.oneline = &lv_style_pretty;
@ -301,7 +301,7 @@ static void list_init(void)
static void ddlist_init(void)
{
#if LV_USE_DDLIST != 0
#if LV_USE_DROPDOWN != 0
theme.style.ddlist.bg = &lv_style_pretty;
theme.style.ddlist.sel = &lv_style_plain_color;
@ -320,7 +320,7 @@ static void roller_init(void)
static void tabview_init(void)
{
#if LV_USE_TABVIEW != 0
#if LV_USE_TEXTAREABVIEW != 0
theme.style.tabview.bg = &plain_bordered;
theme.style.tabview.indic = &lv_style_plain_color;
@ -334,7 +334,7 @@ static void tabview_init(void)
static void table_init(void)
{
#if LV_USE_TABLE != 0
#if LV_USE_TEXTAREABLE != 0
theme.style.table.bg = &lv_style_transp_tight;
theme.style.table.cell = &lv_style_plain;
#endif

View File

@ -267,7 +267,7 @@ static void slider_init(void)
static void sw_init(void)
{
#if LV_USE_SW != 0
#if LV_USE_SWITCH != 0
static lv_style_t sw_bg, sw_indic, sw_knob_off, sw_knob_on;
lv_style_copy(&sw_bg, theme.style.slider.bg);
sw_bg.body.radius = LV_RADIUS_CIRCLE;
@ -353,7 +353,7 @@ static void arc_init(void)
static void preload_init(void)
{
#if LV_USE_PRELOAD != 0
#if LV_USE_SPINNER != 0
theme.style.preload = theme.style.arc;
#endif
@ -409,7 +409,7 @@ static void calendar_init(void)
static void cb_init(void)
{
#if LV_USE_CB != 0
#if LV_USE_CHECKBOX != 0
static lv_style_t rel, pr, tgl_rel, tgl_pr, ina;
lv_style_copy(&rel, theme.style.panel);
rel.body.shadow.width = 3;
@ -442,7 +442,7 @@ static void cb_init(void)
static void btnm_init(void)
{
#if LV_USE_BTNM
#if LV_USE_BTNMATRIX
static lv_style_t bg, rel, pr, tgl_rel, tgl_pr, ina;
lv_style_copy(&bg, theme.style.panel);
@ -492,7 +492,7 @@ static void btnm_init(void)
static void kb_init(void)
{
#if LV_USE_KB
#if LV_USE_KEYBOARD
static lv_style_t rel;
lv_style_copy(&rel, &lv_style_transp);
@ -509,7 +509,7 @@ static void kb_init(void)
static void mbox_init(void)
{
#if LV_USE_MBOX
#if LV_USE_MSGBOX
static lv_style_t pr, rel;
lv_style_copy(&rel, &lv_style_transp);
@ -539,7 +539,7 @@ static void page_init(void)
static void ta_init(void)
{
#if LV_USE_TA
#if LV_USE_TEXTAREA
static lv_style_t oneline;
lv_style_copy(&oneline, &def);
@ -626,7 +626,7 @@ static void list_init(void)
static void ddlist_init(void)
{
#if LV_USE_DDLIST != 0
#if LV_USE_DROPDOWN != 0
static lv_style_t bg, sel;
lv_style_copy(&bg, theme.style.panel);
bg.body.padding.left = LV_DPI / 6;
@ -672,7 +672,7 @@ static void roller_init(void)
static void tabview_init(void)
{
#if LV_USE_TABVIEW != 0
#if LV_USE_TEXTAREABVIEW != 0
static lv_style_t indic, btn_bg, rel, pr, tgl_rel, tgl_pr;
lv_style_copy(&indic, &def);
@ -752,7 +752,7 @@ static void tileview_init(void)
static void table_init(void)
{
#if LV_USE_TABLE != 0
#if LV_USE_TEXTAREABLE != 0
static lv_style_t cell;
lv_style_copy(&cell, theme.style.panel);
cell.body.radius = 0;

View File

@ -206,7 +206,7 @@ static void slider_init(void)
static void sw_init(void)
{
#if LV_USE_SW != 0
#if LV_USE_SWITCH != 0
theme.style.sw.bg = theme.style.slider.bg;
theme.style.sw.indic = theme.style.slider.indic;
@ -267,7 +267,7 @@ static void calendar_init(void)
static void cb_init(void)
{
#if LV_USE_CB != 0
#if LV_USE_CHECKBOX != 0
theme.style.cb.bg = &lv_style_transp;
theme.style.cb.box.rel = &light_frame;
@ -280,7 +280,7 @@ static void cb_init(void)
static void btnm_init(void)
{
#if LV_USE_BTNM
#if LV_USE_BTNMATRIX
theme.style.btnm.bg = &light_frame;
theme.style.btnm.btn.rel = &light_frame;
@ -293,7 +293,7 @@ static void btnm_init(void)
static void kb_init(void)
{
#if LV_USE_KB
#if LV_USE_KEYBOARD
theme.style.kb.bg = &lv_style_transp_fit;
theme.style.kb.btn.rel = &light_frame;
theme.style.kb.btn.pr = &light_frame;
@ -305,7 +305,7 @@ static void kb_init(void)
static void mbox_init(void)
{
#if LV_USE_MBOX
#if LV_USE_MSGBOX
theme.style.mbox.bg = &dark_frame;
theme.style.mbox.btn.bg = &lv_style_transp_fit;
@ -326,7 +326,7 @@ static void page_init(void)
static void ta_init(void)
{
#if LV_USE_TA
#if LV_USE_TEXTAREA
theme.style.ta.area = &light_frame;
theme.style.ta.oneline = &light_frame;
@ -352,7 +352,7 @@ static void list_init(void)
static void ddlist_init(void)
{
#if LV_USE_DDLIST != 0
#if LV_USE_DROPDOWN != 0
static lv_style_t bg;
lv_style_copy(&bg, &light_frame);
bg.text.line_space = LV_DPI / 12;
@ -377,7 +377,7 @@ static void roller_init(void)
static void tabview_init(void)
{
#if LV_USE_TABVIEW != 0
#if LV_USE_TEXTAREABVIEW != 0
theme.style.tabview.bg = &light_frame;
theme.style.tabview.indic = &light_plain;

View File

@ -51,11 +51,11 @@ static lv_style_t slider_knob;
static lv_style_t lmeter_bg;
#endif
#if LV_USE_DDLIST
#if LV_USE_DROPDOWN
static lv_style_t ddlist_bg, ddlist_sel;
#endif
#if LV_USE_BTNM
#if LV_USE_BTNMATRIX
static lv_style_t btnm_bg, btnm_rel, btnm_pr, btnm_trel, btnm_ina;
#endif
@ -326,7 +326,7 @@ static void slider_init(void)
static void sw_init(void)
{
#if LV_USE_SW != 0
#if LV_USE_SWITCH != 0
static lv_style_t sw_bg, sw_indic, sw_knob;
lv_style_copy(&sw_bg, &bar_bg);
sw_bg.body.opa = LV_OPA_COVER;
@ -403,7 +403,7 @@ static void arc_init(void)
arc.line.color = lv_color_hsv_to_rgb(_hue, 70, 90);
arc.line.rounded = 1;
/*For preloader*/
/*For spinner*/
arc.body.border.width = 0;
theme.style.arc = &arc;
@ -412,7 +412,7 @@ static void arc_init(void)
static void preload_init(void)
{
#if LV_USE_PRELOAD != 0
#if LV_USE_SPINNER != 0
theme.style.preload = theme.style.arc;
#endif
@ -463,7 +463,7 @@ static void calendar_init(void)
static void cb_init(void)
{
#if LV_USE_CB != 0
#if LV_USE_CHECKBOX != 0
static lv_style_t cb_bg, cb_rel, cb_pr, cb_trel, cb_tpr, cb_ina;
lv_style_copy(&cb_rel, &bg);
cb_rel.body.radius = LV_DPI / 20;
@ -516,7 +516,7 @@ static void cb_init(void)
static void btnm_init(void)
{
#if LV_USE_BTNM
#if LV_USE_BTNMATRIX
lv_style_copy(&btnm_bg, &lv_style_transp_tight);
btnm_bg.body.border.width = 1;
btnm_bg.body.border.color = lv_color_hsv_to_rgb(_hue, 60, 80);
@ -554,7 +554,7 @@ static void btnm_init(void)
static void kb_init(void)
{
#if LV_USE_KB
#if LV_USE_KEYBOARD
theme.style.kb.bg = &btnm_bg;
theme.style.kb.btn.rel = &btnm_rel;
theme.style.kb.btn.pr = &btnm_pr;
@ -566,7 +566,7 @@ static void kb_init(void)
static void mbox_init(void)
{
#if LV_USE_MBOX
#if LV_USE_MSGBOX
static lv_style_t mbox_bg;
lv_style_copy(&mbox_bg, &panel);
mbox_bg.body.shadow.width = LV_DPI / 12;
@ -589,7 +589,7 @@ static void page_init(void)
static void ta_init(void)
{
#if LV_USE_TA
#if LV_USE_TEXTAREA
theme.style.ta.area = &panel;
theme.style.ta.oneline = &panel;
theme.style.ta.cursor = NULL;
@ -647,7 +647,7 @@ static void list_init(void)
static void ddlist_init(void)
{
#if LV_USE_DDLIST != 0
#if LV_USE_DROPDOWN != 0
lv_style_copy(&ddlist_bg, &panel);
ddlist_bg.text.line_space = LV_DPI / 8;
ddlist_bg.body.padding.left = LV_DPI / 6;
@ -694,7 +694,7 @@ static void roller_init(void)
static void tabview_init(void)
{
#if LV_USE_TABVIEW != 0
#if LV_USE_TEXTAREABVIEW != 0
static lv_style_t tab_rel, tab_pr, tab_trel, tab_tpr, tab_indic;
lv_style_copy(&tab_rel, &def);
tab_rel.body.main_color = lv_color_hex3(0x500);
@ -768,7 +768,7 @@ static void tileview_init(void)
static void table_init(void)
{
#if LV_USE_TABLE != 0
#if LV_USE_TEXTAREABLE != 0
static lv_style_t cell;
lv_style_copy(&cell, &panel);
cell.body.radius = 0;

View File

@ -255,7 +255,7 @@ static void slider_init(void)
static void sw_init(void)
{
#if LV_USE_SW != 0
#if LV_USE_SWITCH != 0
theme.style.sw.bg = theme.style.bar.bg;
theme.style.sw.indic = theme.style.bar.indic;
@ -307,7 +307,7 @@ static void arc_init(void)
arc.line.color = lv_color_hsv_to_rgb(_hue, 80, 70);
arc.line.rounded = 1;
/*For preloader*/
/*For spinner*/
arc.body.border.width = 7;
arc.body.border.color = lv_color_hsv_to_rgb(_hue, 11, 48);
arc.body.padding.left = 1;
@ -321,7 +321,7 @@ static void arc_init(void)
static void preload_init(void)
{
#if LV_USE_PRELOAD != 0
#if LV_USE_SPINNER != 0
theme.style.preload = theme.style.arc;
#endif
@ -402,7 +402,7 @@ static void calendar_init(void)
static void cb_init(void)
{
#if LV_USE_CB != 0
#if LV_USE_CHECKBOX != 0
static lv_style_t rel, pr, tgl_rel, tgl_pr, ina;
@ -449,7 +449,7 @@ static void cb_init(void)
static void btnm_init(void)
{
#if LV_USE_BTNM
#if LV_USE_BTNMATRIX
static lv_style_t btnm_bg, rel, pr, tgl_rel, tgl_pr, ina;
lv_style_copy(&btnm_bg, theme.style.btn.rel);
@ -496,7 +496,7 @@ static void btnm_init(void)
static void kb_init(void)
{
#if LV_USE_KB
#if LV_USE_KEYBOARD
theme.style.kb.bg = &bg;
theme.style.kb.btn.rel = theme.style.btn.rel;
theme.style.kb.btn.pr = theme.style.btn.pr;
@ -508,7 +508,7 @@ static void kb_init(void)
static void mbox_init(void)
{
#if LV_USE_MBOX
#if LV_USE_MSGBOX
static lv_style_t mbox_bg;
lv_style_copy(&mbox_bg, &bg);
mbox_bg.body.main_color = lv_color_hsv_to_rgb(_hue, 30, 30);
@ -545,7 +545,7 @@ static void page_init(void)
static void ta_init(void)
{
#if LV_USE_TA
#if LV_USE_TEXTAREA
theme.style.ta.area = &panel;
theme.style.ta.oneline = &panel;
theme.style.ta.cursor = NULL;
@ -623,7 +623,7 @@ static void list_init(void)
static void ddlist_init(void)
{
#if LV_USE_DDLIST != 0
#if LV_USE_DROPDOWN != 0
static lv_style_t ddlist_bg, ddlist_sel;
lv_style_copy(&ddlist_bg, theme.style.btn.rel);
ddlist_bg.text.line_space = LV_DPI / 8;
@ -662,7 +662,7 @@ static void roller_init(void)
static void tabview_init(void)
{
#if LV_USE_TABVIEW != 0
#if LV_USE_TEXTAREABVIEW != 0
theme.style.tabview.bg = &bg;
theme.style.tabview.indic = &lv_style_transp;
theme.style.tabview.btn.bg = &lv_style_transp;
@ -684,7 +684,7 @@ static void tileview_init(void)
static void table_init(void)
{
#if LV_USE_TABLE != 0
#if LV_USE_TEXTAREABLE != 0
static lv_style_t cell;
lv_style_copy(&cell, &panel);
cell.body.radius = 0;

View File

@ -138,7 +138,7 @@ static void slider_init(void)
static void sw_init(void)
{
#if LV_USE_SW != 0
#if LV_USE_SWITCH != 0
theme.style.sw.bg = &def;
theme.style.sw.indic = &def;
@ -173,7 +173,7 @@ static void arc_init(void)
static void preload_init(void)
{
#if LV_USE_PRELOAD != 0
#if LV_USE_SPINNER != 0
theme.style.preload = &def;
#endif
@ -204,7 +204,7 @@ static void calendar_init(void)
static void cb_init(void)
{
#if LV_USE_CB != 0
#if LV_USE_CHECKBOX != 0
theme.style.cb.bg = &def;
theme.style.cb.box.rel = &def;
@ -217,7 +217,7 @@ static void cb_init(void)
static void btnm_init(void)
{
#if LV_USE_BTNM
#if LV_USE_BTNMATRIX
theme.style.btnm.bg = &def;
theme.style.btnm.btn.rel = &def;
@ -230,7 +230,7 @@ static void btnm_init(void)
static void kb_init(void)
{
#if LV_USE_KB
#if LV_USE_KEYBOARD
theme.style.kb.bg = &def;
theme.style.kb.btn.rel = &def;
@ -243,7 +243,7 @@ static void kb_init(void)
static void mbox_init(void)
{
#if LV_USE_MBOX
#if LV_USE_MSGBOX
theme.style.mbox.bg = &def;
theme.style.mbox.btn.bg = &def;
@ -264,7 +264,7 @@ static void page_init(void)
static void ta_init(void)
{
#if LV_USE_TA
#if LV_USE_TEXTAREA
theme.style.ta.area = &def;
theme.style.ta.oneline = &def;
@ -290,7 +290,7 @@ static void list_init(void)
static void ddlist_init(void)
{
#if LV_USE_DDLIST != 0
#if LV_USE_DROPDOWN != 0
theme.style.ddlist.bg = &def;
theme.style.ddlist.sel = &def;
@ -309,7 +309,7 @@ static void roller_init(void)
static void tabview_init(void)
{
#if LV_USE_TABVIEW != 0
#if LV_USE_TEXTAREABVIEW != 0
theme.style.tabview.bg = &def;
theme.style.tabview.indic = &def;
@ -323,7 +323,7 @@ static void tabview_init(void)
static void table_init(void)
{
#if LV_USE_TABLE != 0
#if LV_USE_TEXTAREABLE != 0
theme.style.table.bg = &def;
theme.style.table.cell = &def;
#endif

View File

@ -251,7 +251,7 @@ static void slider_init(void)
static void sw_init(void)
{
#if LV_USE_SW != 0
#if LV_USE_SWITCH != 0
static lv_style_t indic;
lv_style_copy(&indic, theme.style.slider.indic);
@ -318,7 +318,7 @@ static void arc_init(void)
arc.line.color = lv_color_hsv_to_rgb(_hue, 40, 90);
arc.line.rounded = 1;
/*For preloader*/
/*For spinner*/
arc.body.border.width = 0;
theme.style.arc = &arc;
@ -327,7 +327,7 @@ static void arc_init(void)
static void preload_init(void)
{
#if LV_USE_PRELOAD != 0
#if LV_USE_SPINNER != 0
theme.style.preload = theme.style.arc;
#endif
@ -370,7 +370,7 @@ static void calendar_init(void)
static void cb_init(void)
{
#if LV_USE_CB != 0
#if LV_USE_CHECKBOX != 0
static lv_style_t rel, pr, tgl_rel, tgl_pr, ina;
lv_style_copy(&rel, &def);
rel.body.radius = LV_DPI / 20;
@ -408,7 +408,7 @@ static void cb_init(void)
static void btnm_init(void)
{
#if LV_USE_BTNM
#if LV_USE_BTNMATRIX
static lv_style_t bg, rel, pr, tgl_rel, tgl_pr, ina;
lv_style_copy(&bg, &lv_style_transp);
@ -460,7 +460,7 @@ static void btnm_init(void)
static void kb_init(void)
{
#if LV_USE_KB
#if LV_USE_KEYBOARD
static lv_style_t bg, rel, pr, tgl_rel, tgl_pr, ina;
lv_style_copy(&bg, &def);
bg.body.main_color = lv_color_hex3(0x666);
@ -516,7 +516,7 @@ static void kb_init(void)
static void mbox_init(void)
{
#if LV_USE_MBOX
#if LV_USE_MSGBOX
static lv_style_t bg, rel, pr;
lv_style_copy(&bg, theme.style.panel);
bg.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 95);
@ -560,7 +560,7 @@ static void page_init(void)
static void ta_init(void)
{
#if LV_USE_TA
#if LV_USE_TEXTAREA
static lv_style_t oneline;
lv_style_copy(&oneline, theme.style.panel);
oneline.body.radius = LV_RADIUS_CIRCLE;
@ -633,7 +633,7 @@ static void list_init(void)
static void ddlist_init(void)
{
#if LV_USE_DDLIST != 0
#if LV_USE_DROPDOWN != 0
static lv_style_t bg, sel;
lv_style_copy(&bg, theme.style.panel);
bg.text.line_space = LV_DPI / 8;
@ -675,7 +675,7 @@ static void roller_init(void)
static void tabview_init(void)
{
#if LV_USE_TABVIEW != 0
#if LV_USE_TEXTAREABVIEW != 0
static lv_style_t btn_bg, indic, rel, pr, tgl_rel, tgl_pr;
lv_style_copy(&btn_bg, &def);
@ -726,7 +726,7 @@ static void tileview_init(void)
static void table_init(void)
{
#if LV_USE_TABLE != 0
#if LV_USE_TEXTAREABLE != 0
static lv_style_t cell;
lv_style_copy(&cell, theme.style.panel);
cell.body.radius = 0;