BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lvgl
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
lvgl
Commits
e468f0d5
Commit
e468f0d5
authored
Oct 05, 2017
by
Gabor Kiss-Vamosi
Browse files
Options
Browse Files
Download
Plain Diff
fumbling with git...
parents
c0715b4c
445b5ad2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
416 additions
and
64 deletions
+416
-64
lv_roller.c
lv_objx/lv_roller.c
+283
-0
lv_roller.h
lv_objx/lv_roller.h
+67
-0
lv_ta.c
lv_objx/lv_ta.c
+66
-64
No files found.
lv_objx/lv_roller.c
0 → 100644
View file @
e468f0d5
/**
* @file lv_roller.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_ROLLER != 0
#include "lv_roller.h"
#include "../lv_draw/lv_draw.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static
bool
lv_roller_design
(
lv_obj_t
*
roller
,
const
area_t
*
mask
,
lv_design_mode_t
mode
);
static
bool
roller_scrl_signal
(
lv_obj_t
*
roller_scrl
,
lv_signal_t
sign
,
void
*
param
);
/**********************
* STATIC VARIABLES
**********************/
static
lv_signal_f_t
ancestor_scr_signal_f
;
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a roller object
* @param par pointer to an object, it will be the parent of the new roller
* @param copy pointer to a roller object, if not NULL then the new object will be copied from it
* @return pointer to the created roller
*/
lv_obj_t
*
lv_roller_create
(
lv_obj_t
*
par
,
lv_obj_t
*
copy
)
{
/*Create the ancestor of roller*/
lv_obj_t
*
new_roller
=
lv_ddlist_create
(
par
,
copy
);
dm_assert
(
new_roller
);
/*Allocate the roller type specific extended data*/
lv_roller_ext_t
*
ext
=
lv_obj_alloc_ext
(
new_roller
,
sizeof
(
lv_roller_ext_t
));
dm_assert
(
ext
);
/*Initialize the allocated 'ext' */
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_f
(
new_roller
,
lv_roller_signal
);
lv_obj_set_design_f
(
new_roller
,
lv_roller_design
);
if
(
ancestor_scr_signal_f
==
NULL
)
ancestor_scr_signal_f
=
lv_obj_get_signal_f
(
lv_page_get_scrl
(
new_roller
));
/*Init the new roller roller*/
if
(
copy
==
NULL
)
{
lv_obj_t
*
scrl
=
lv_page_get_scrl
(
new_roller
);
lv_obj_set_drag
(
scrl
,
true
);
/*In ddlist is might be disabled*/
lv_page_set_rel_action
(
new_roller
,
NULL
);
/*Handle roller specific actions*/
lv_cont_set_fit
(
lv_page_get_scrl
(
new_roller
),
true
,
false
);
/*Height is specified directly*/
lv_obj_set_signal_f
(
scrl
,
roller_scrl_signal
);
lv_ddlist_open
(
new_roller
,
true
,
0
);
lv_style_t
*
style_label
=
lv_obj_get_style
(
ext
->
ddlist
.
opt_label
);
lv_ddlist_set_fix_height
(
new_roller
,
(
font_get_height
(
style_label
->
font
)
>>
FONT_ANTIALIAS
)
*
3
+
style_label
->
line_space
*
4
);
lv_obj_refr_style
(
new_roller
);
/*To set scrollable size automatically*/
}
/*Copy an existing roller*/
else
{
lv_roller_ext_t
*
copy_ext
=
lv_obj_get_ext
(
copy
);
/*Refresh the style with new signal function*/
lv_obj_refr_style
(
new_roller
);
}
return
new_roller
;
}
/**
* Signal function of the roller
* @param roller pointer to a roller object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return true: the object is still valid (not deleted), false: the object become invalid
*/
bool
lv_roller_signal
(
lv_obj_t
*
roller
,
lv_signal_t
sign
,
void
*
param
)
{
bool
valid
;
/* Include the ancient signal function */
valid
=
lv_ddlist_signal
(
roller
,
sign
,
param
);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if
(
valid
!=
false
)
{
lv_roller_ext_t
*
ext
=
lv_obj_get_ext
(
roller
);
if
(
sign
==
LV_SIGNAL_STYLE_CHG
)
{
lv_obj_set_height
(
lv_page_get_scrl
(
roller
),
lv_obj_get_height
(
ext
->
ddlist
.
opt_label
)
+
lv_obj_get_height
(
roller
));
lv_obj_align
(
ext
->
ddlist
.
opt_label
,
NULL
,
LV_ALIGN_CENTER
,
0
,
0
);
lv_ddlist_set_selected
(
roller
,
ext
->
ddlist
.
sel_opt
);
}
else
if
(
sign
==
LV_SIGNAL_CORD_CHG
)
{
lv_ddlist_set_fix_height
(
roller
,
lv_obj_get_height
(
roller
));
lv_obj_set_height
(
lv_page_get_scrl
(
roller
),
lv_obj_get_height
(
ext
->
ddlist
.
opt_label
)
+
lv_obj_get_height
(
roller
));
lv_obj_align
(
ext
->
ddlist
.
opt_label
,
NULL
,
LV_ALIGN_CENTER
,
0
,
0
);
lv_ddlist_set_selected
(
roller
,
ext
->
ddlist
.
sel_opt
);
}
}
return
valid
;
}
/*======================
* Add/remove functions
*=====================*/
/*
* New object specific "add" or "remove" functions come here
*/
/*=====================
* Setter functions
*====================*/
/*
* New object specific "set" functions come here
*/
/*=====================
* Getter functions
*====================*/
/*
* New object specific "get" functions come here
*/
/*=====================
* Other functions
*====================*/
/*
* New object specific "other" functions come here
*/
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Handle the drawing related tasks of the rollers
* @param roller pointer to an object
* @param mask the object will be drawn only in this area
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
* (return 'true' if yes)
* LV_DESIGN_DRAW: draw the object (always return 'true')
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
* @param return true/false, depends on 'mode'
*/
static
bool
lv_roller_design
(
lv_obj_t
*
roller
,
const
area_t
*
mask
,
lv_design_mode_t
mode
)
{
/*Return false if the object is not covers the mask_p area*/
if
(
mode
==
LV_DESIGN_COVER_CHK
)
{
return
false
;
}
/*Draw the object*/
else
if
(
mode
==
LV_DESIGN_DRAW_MAIN
)
{
lv_style_t
*
style
=
lv_obj_get_style
(
roller
);
lv_draw_rect
(
&
roller
->
cords
,
mask
,
style
);
const
font_t
*
font
=
style
->
font
;
lv_roller_ext_t
*
ext
=
lv_obj_get_ext
(
roller
);
cord_t
font_h
=
font_get_height
(
font
)
>>
FONT_ANTIALIAS
;
area_t
rect_area
;
rect_area
.
y1
=
roller
->
cords
.
y1
+
lv_obj_get_height
(
roller
)
/
2
-
font_h
/
2
-
style
->
line_space
-
2
;
rect_area
.
y2
=
rect_area
.
y1
+
font_h
+
style
->
line_space
;
rect_area
.
x1
=
ext
->
ddlist
.
opt_label
->
cords
.
x1
-
style
->
hpad
;
rect_area
.
x2
=
rect_area
.
x1
+
lv_obj_get_width
(
lv_page_get_scrl
(
roller
));
lv_draw_rect
(
&
rect_area
,
mask
,
ext
->
ddlist
.
style_sel
);
}
/*Post draw when the children are drawn*/
else
if
(
mode
==
LV_DESIGN_DRAW_POST
)
{
}
return
true
;
}
/**
* Signal function of the scrollable part of the roller.
* @param roller_scrl ointer to the scrollable part of roller (page)
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return true: the object is still valid (not deleted), false: the object become invalid
*/
static
bool
roller_scrl_signal
(
lv_obj_t
*
roller_scrl
,
lv_signal_t
sign
,
void
*
param
)
{
bool
valid
;
/* Include the ancient signal function */
valid
=
ancestor_scr_signal_f
(
roller_scrl
,
sign
,
param
);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if
(
valid
!=
false
)
{
if
(
sign
==
LV_SIGNAL_RELEASED
)
{
int32_t
id
;
lv_obj_t
*
roller
=
lv_obj_get_parent
(
roller_scrl
);
lv_roller_ext_t
*
ext
=
lv_obj_get_ext
(
roller
);
lv_style_t
*
style_label
=
lv_obj_get_style
(
ext
->
ddlist
.
opt_label
);
const
font_t
*
font
=
style_label
->
font
;
cord_t
font_h
=
font_get_height
(
font
)
>>
FONT_ANTIALIAS
;
/*If dragged then align the list to there be an element in the middle*/
if
(
lv_dispi_is_dragging
(
param
))
{
cord_t
label_y1
=
ext
->
ddlist
.
opt_label
->
cords
.
y1
-
roller
->
cords
.
y1
;
cord_t
label_unit
=
(
font_get_height
(
style_label
->
font
)
>>
FONT_ANTIALIAS
)
+
style_label
->
line_space
/
2
;
cord_t
mid
=
(
roller
->
cords
.
y2
-
roller
->
cords
.
y1
)
/
2
;
id
=
(
mid
-
label_y1
)
/
label_unit
;
}
/*If pick an option by clicking then set it*/
else
{
point_t
p
;
lv_dispi_get_point
(
param
,
&
p
);
p
.
y
=
p
.
y
-
ext
->
ddlist
.
opt_label
->
cords
.
y1
;
id
=
p
.
y
/
(
font_h
+
style_label
->
line_space
);
}
if
(
id
<
0
)
id
=
0
;
if
(
id
>=
ext
->
ddlist
.
num_opt
)
id
=
ext
->
ddlist
.
num_opt
-
1
;
ext
->
ddlist
.
sel_opt
=
id
;
/*Position the scrollable according to the new selected option*/
cord_t
h
=
lv_obj_get_height
(
roller
);
cord_t
line_y1
=
id
*
(
font_h
+
style_label
->
line_space
)
+
ext
->
ddlist
.
opt_label
->
cords
.
y1
-
roller_scrl
->
cords
.
y1
;
cord_t
new_y
=
-
line_y1
+
(
h
-
font_h
)
/
2
;
if
(
ext
->
ddlist
.
anim_time
==
0
)
{
lv_obj_set_y
(
roller_scrl
,
new_y
);
}
else
{
anim_t
a
;
a
.
var
=
roller_scrl
;
a
.
start
=
lv_obj_get_y
(
roller_scrl
);
a
.
end
=
new_y
;
a
.
fp
=
(
anim_fp_t
)
lv_obj_set_y
;
a
.
path
=
anim_get_path
(
ANIM_PATH_LIN
);
a
.
end_cb
=
NULL
;
a
.
act_time
=
0
;
a
.
time
=
ext
->
ddlist
.
anim_time
;
a
.
playback
=
0
;
a
.
playback_pause
=
0
;
a
.
repeat
=
0
;
a
.
repeat_pause
=
0
;
anim_create
(
&
a
);
}
}
}
return
valid
;
}
#endif
lv_objx/lv_roller.h
0 → 100644
View file @
e468f0d5
/**
* @file lv_roller.h
*
*/
#ifndef LV_ROLLER_H
#define LV_ROLLER_H
#ifdef __cplusplus
extern
"C"
{
#endif
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_ROLLER != 0
#include "../lv_obj/lv_obj.h"
#include "lv_ddlist.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/*Data of roller*/
typedef
struct
{
lv_ddlist_ext_t
ddlist
;
/*Ext. of ancestor*/
/*New data for this type */
}
lv_roller_ext_t
;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a roller objects
* @param par pointer to an object, it will be the parent of the new roller
* @param copy pointer to a roller object, if not NULL then the new object will be copied from it
* @return pointer to the created roller
*/
lv_obj_t
*
lv_roller_create
(
lv_obj_t
*
par
,
lv_obj_t
*
copy
);
/**
* Signal function of the roller
* @param roller pointer to a roller object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return true: the object is still valid (not deleted), false: the object become invalid
*/
bool
lv_roller_signal
(
lv_obj_t
*
roller
,
lv_signal_t
sign
,
void
*
param
);
/**********************
* MACROS
**********************/
#endif
/*USE_LV_ROLLER*/
#ifdef __cplusplus
}
/* extern "C" */
#endif
#endif
/*LV_ROLLER_H*/
lv_objx/lv_ta.c
View file @
e468f0d5
...
...
@@ -106,7 +106,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
lv_obj_set_design_f
(
ext
->
page
.
scrl
,
lv_ta_scrling_design
);
lv_label_set_long_mode
(
ext
->
label
,
LV_LABEL_LONG_BREAK
);
lv_label_set_text
(
ext
->
label
,
"Text
area"
);
lv_label_set_text
(
ext
->
label
,
"Text
.
area"
);
lv_page_glue_obj
(
ext
->
label
,
true
);
lv_obj_set_click
(
ext
->
label
,
false
);
lv_obj_set_style
(
new_ta
,
lv_style_get
(
LV_STYLE_PRETTY
,
NULL
));
...
...
@@ -243,36 +243,39 @@ bool lv_ta_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param)
/**
* Insert a character to the current cursor position
* @param ta pointer to a text area object
* @param c a character
* @param c a character
(could but UTF-8 code as well: 'Á' or txt_unicode_to_utf8(0x047C)
*/
void
lv_ta_add_char
(
lv_obj_t
*
ta
,
uint32_t
c
)
{
lv_ta_ext_t
*
ext
=
lv_obj_get_ext
(
ta
);
const
char
*
label_txt
=
lv_label_get_text
(
ext
->
label
);
/*Test the new length: txt length + 1 (closing'\0') + 1 (c character)*/
if
((
strlen
(
label_txt
)
+
2
)
>
LV_TA_MAX_LENGTH
)
return
;
if
(
ext
->
pwd_mode
!=
0
)
pwd_char_hider
(
ta
);
/*Make sure all the current text contains only '*'*/
#if TXT_UTF8 == 0
char
letter_buf
[
2
];
letter_buf
[
0
]
=
c
;
letter_buf
[
1
]
=
'\0'
;
#else
/*Swap because of UTF-8 is "big-endian-like" */
if
(((
c
>>
8
)
&
0
b11100000
)
==
0
b11000000
)
{
c
=
(
c
&
0xFF
)
<<
8
|
((
c
>>
8
)
&
0xFF
);
}
if
(((
c
>>
16
)
&
0
b11110000
)
==
0
b11100000
)
{
c
=
(
c
&
0xFF
)
<<
16
|
((
c
>>
16
)
&
0xFF
);
}
if
(((
c
>>
24
)
&
0
b11111000
)
==
0
b11110000
)
{
c
=
((
c
&
0xFF
)
<<
24
)
|
(((
c
>>
8
)
&
0xFF
)
>>
16
)
|
(((
c
>>
16
)
&
0xFF
)
>>
8
)
|
((
c
>>
24
)
&
0xFF
);
}
char
buf
[
LV_TA_MAX_LENGTH
];
/*Insert the character*/
memcpy
(
buf
,
label_txt
,
ext
->
cursor_pos
);
buf
[
ext
->
cursor_pos
]
=
c
;
memcpy
(
buf
+
ext
->
cursor_pos
+
1
,
label_txt
+
ext
->
cursor_pos
,
strlen
(
label_txt
)
-
ext
->
cursor_pos
+
1
);
char
letter_buf
[
8
]
=
{
0
};
memcpy
(
letter_buf
,
&
c
,
txt_utf8_size
(
c
));
#endif
lv_label_ins_text
(
ext
->
label
,
ext
->
cursor_pos
,
letter_buf
);
/*Insert the character*/
/*Refresh the label*/
lv_label_set_text
(
ext
->
label
,
buf
);
if
(
ext
->
pwd_mode
!=
0
)
{
if
(
ext
->
pwd_mode
!=
0
)
{
ext
->
pwd_tmp
=
dm_realloc
(
ext
->
pwd_tmp
,
strlen
(
ext
->
pwd_tmp
)
+
2
);
/*+2: the new char + \0 */
dm_assert
(
ext
->
pwd_tmp
);
memcpy
(
buf
,
ext
->
pwd_tmp
,
ext
->
cursor_pos
);
buf
[
ext
->
cursor_pos
]
=
c
;
memcpy
(
buf
+
ext
->
cursor_pos
+
1
,
ext
->
pwd_tmp
+
ext
->
cursor_pos
,
strlen
(
ext
->
pwd_tmp
)
-
ext
->
cursor_pos
+
1
);
strcpy
(
ext
->
pwd_tmp
,
buf
);
ext
->
pwd_tmp
=
dm_realloc
(
ext
->
pwd_tmp
,
strlen
(
ext
->
pwd_tmp
)
+
2
);
/*+2: the new char + \0 */
dm_assert
(
ext
->
pwd_tmp
);
txt_ins
(
ext
->
pwd_tmp
,
ext
->
cursor_pos
,
letter_buf
);
anim_t
a
;
a
.
var
=
ta
;
...
...
@@ -310,28 +313,15 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt)
uint16_t
label_len
=
strlen
(
label_txt
);
uint16_t
txt_len
=
strlen
(
txt
);
/*Test the new length (+ 1 for the closing '\0')*/
if
((
label_len
+
txt_len
+
1
)
>
LV_TA_MAX_LENGTH
)
return
;
if
(
ext
->
pwd_mode
!=
0
)
pwd_char_hider
(
ta
);
/*Make sure all the current text contains only '*'*/
/*Insert the text*/
char
buf
[
LV_TA_MAX_LENGTH
];
memcpy
(
buf
,
label_txt
,
ext
->
cursor_pos
);
memcpy
(
buf
+
ext
->
cursor_pos
,
txt
,
txt_len
);
memcpy
(
buf
+
ext
->
cursor_pos
+
txt_len
,
label_txt
+
ext
->
cursor_pos
,
label_len
-
ext
->
cursor_pos
+
1
);
/*Refresh the label*/
lv_label_set_text
(
ext
->
label
,
buf
);
lv_label_ins_text
(
ext
->
label
,
ext
->
cursor_pos
,
txt
);
if
(
ext
->
pwd_mode
!=
0
)
{
ext
->
pwd_tmp
=
dm_realloc
(
ext
->
pwd_tmp
,
strlen
(
ext
->
pwd_tmp
)
+
txt_len
+
1
);
dm_assert
(
ext
->
pwd_tmp
);
memcpy
(
buf
,
ext
->
pwd_tmp
,
ext
->
cursor_pos
);
memcpy
(
buf
+
ext
->
cursor_pos
,
txt
,
txt_len
);
memcpy
(
buf
+
ext
->
cursor_pos
+
txt_len
,
ext
->
pwd_tmp
+
ext
->
cursor_pos
,
label_len
-
ext
->
cursor_pos
+
1
);
strcpy
(
ext
->
pwd_tmp
,
buf
);
txt_ins
(
ext
->
pwd_tmp
,
ext
->
cursor_pos
,
txt
);
anim_t
a
;
a
.
var
=
ta
;
...
...
@@ -408,15 +398,17 @@ void lv_ta_del(lv_obj_t * ta)
if
(
cur_pos
==
0
)
return
;
char
*
label_txt
=
lv_label_get_text
(
ext
->
label
);
/*Delete a character*/
char
buf
[
LV_TA_MAX_LENGTH
];
const
char
*
label_txt
=
lv_label_get_text
(
ext
->
label
);
uint16_t
label_len
=
strlen
(
label_txt
);
memcpy
(
buf
,
label_txt
,
cu
r_pos
-
1
);
memcpy
(
buf
+
cur_pos
-
1
,
label_txt
+
cur_pos
,
label_len
-
cur_pos
+
1
);
#if TXT_UTF8 == 0
txt_cut
(
label_txt
,
ext
->
cursor_pos
-
1
,
1
);
#else
uint32_t
byte_pos
=
txt_utf8_get_id
(
label_txt
,
ext
->
curso
r_pos
-
1
);
txt_cut
(
label_txt
,
ext
->
cursor_pos
-
1
,
txt_utf8_size
(
label_txt
[
byte_pos
])
);
#endif
/*Refresh the label*/
lv_label_set_text
(
ext
->
label
,
buf
);
lv_label_set_text
(
ext
->
label
,
label_txt
);
/*Don't let 'width == 0' because cursor will not be visible*/
if
(
lv_obj_get_width
(
ext
->
label
)
==
0
)
{
lv_style_t
*
style
=
lv_obj_get_style
(
ext
->
label
);
...
...
@@ -424,13 +416,18 @@ void lv_ta_del(lv_obj_t * ta)
}
if
(
ext
->
pwd_mode
!=
0
)
{
ext
->
pwd_tmp
=
dm_realloc
(
ext
->
pwd_tmp
,
strlen
(
buf
));
#if TXT_UTF8 == 0
txt_cut
(
ext
->
pwd_tmp
,
ext
->
cursor_pos
-
1
,
1
);
#else
uint32_t
byte_pos
=
txt_utf8_get_id
(
ext
->
pwd_tmp
,
ext
->
cursor_pos
-
1
);
txt_cut
(
ext
->
pwd_tmp
,
ext
->
cursor_pos
-
1
,
txt_utf8_size
(
label_txt
[
byte_pos
]));
#endif
ext
->
pwd_tmp
=
dm_realloc
(
ext
->
pwd_tmp
,
strlen
(
ext
->
pwd_tmp
)
+
1
);
dm_assert
(
ext
->
pwd_tmp
);
strcpy
(
ext
->
pwd_tmp
,
buf
);
}
/*Move the cursor to the place of the deleted character*/
lv_ta_set_cursor_pos
(
ta
,
lv_ta_get_cursor_pos
(
ta
)
-
1
);
lv_ta_set_cursor_pos
(
ta
,
ext
->
cursor_pos
-
1
);
/*It is a valid x step so save it*/
lv_ta_save_valid_cursor_x
(
ta
);
...
...
@@ -449,11 +446,11 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
lv_ta_ext_t
*
ext
=
lv_obj_get_ext
(
ta
);
lv_obj_t
*
scrl
=
lv_page_get_scrl
(
ta
);
lv_style_t
*
style_scrl
=
lv_obj_get_style
(
scrl
);
uint16_t
txt_len
=
str
len
(
lv_label_get_text
(
ext
->
label
));
uint16_t
len
=
txt_
len
(
lv_label_get_text
(
ext
->
label
));
if
(
pos
<
0
)
pos
=
txt_
len
+
pos
;
if
(
pos
<
0
)
pos
=
len
+
pos
;
if
(
pos
>
txt_len
||
pos
==
LV_TA_CUR_LAST
)
pos
=
txt_
len
;
if
(
pos
>
len
||
pos
==
LV_TA_CUR_LAST
)
pos
=
len
;
ext
->
cursor_pos
=
pos
;
...
...
@@ -490,6 +487,7 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
font_h
+
2
*
style_scrl
->
hpad
));
}
/*Reset cursor blink animation*/
anim_t
a
;
a
.
var
=
ta
;
a
.
fp
=
(
anim_fp_t
)
cursor_blink_anim
;
...
...
@@ -640,14 +638,15 @@ void lv_ta_set_pwd_mode(lv_obj_t * ta, bool en)
/*Pwd mode is now enabled*/
if
(
ext
->
pwd_mode
==
0
&&
en
!=
false
)
{
char
*
txt
=
lv_label_get_text
(
ext
->
label
);
uint16_t
txt_
len
=
strlen
(
txt
);
ext
->
pwd_tmp
=
dm_alloc
(
txt_
len
+
1
);
uint16_t
len
=
strlen
(
txt
);
ext
->
pwd_tmp
=
dm_alloc
(
len
+
1
);
strcpy
(
ext
->
pwd_tmp
,
txt
);
uint16_t
i
;
for
(
i
=
0
;
i
<
txt_
len
;
i
++
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
{
txt
[
i
]
=
'*'
;
/*All char to '*'*/
}
txt
[
i
]
=
'\0'
;
lv_label_set_text
(
ext
->
label
,
NULL
);
}
...
...
@@ -917,9 +916,15 @@ static bool lv_ta_scrling_design(lv_obj_t * scrl, const area_t * mask, lv_design
lv_draw_rect
(
&
cur_area
,
mask
,
&
cur_style
);
/*Get the current letter*/
#if TXT_UTF8 == 0
char
letter_buf
[
2
];
letter_buf
[
0
]
=
txt
[
cur_pos
];
letter_buf
[
1
]
=
'\0'
;
letter_buf
[
0
]
=
txt
[
byte_pos
];
letter_buf
[
1
]
=
'\0'
;
#else
char
letter_buf
[
8
]
=
{
0
};
memcpy
(
letter_buf
,
&
txt
[
byte_pos
],
txt_utf8_size
(
txt
[
byte_pos
]));
#endif
lv_draw_label
(
&
cur_area
,
mask
,
&
cur_style
,
letter_buf
,
TXT_FLAG_NONE
,
0
);
}
else
if
(
ta_ext
->
cursor_type
==
LV_TA_CURSOR_OUTLINE
)
{
...
...
@@ -982,17 +987,14 @@ static void pwd_char_hider(lv_obj_t * ta)
lv_ta_ext_t
*
ext
=
lv_obj_get_ext
(
ta
);
if
(
ext
->
pwd_mode
!=
0
)
{
char
*
txt
=
lv_label_get_text
(
ext
->
label
);
int16_t
txt_len
=
str
len
(
txt
);
int16_t
len
=
txt_
len
(
txt
);
bool
refr
=
false
;
uint16_t
i
;
for
(
i
=
0
;
i
<
txt_len
;
i
++
)
{
if
(
txt
[
i
]
!=
'*'
)
{
txt
[
i
]
=
'*'
;
refr
=
true
;
}
}
for
(
i
=
0
;
i
<
len
;
i
++
)
txt
[
i
]
=
'*'
;
txt
[
i
]
=
'\0'
;
if
(
refr
!=
false
)
lv_label_set_text
(
ext
->
label
,
NULL
);
if
(
refr
!=
false
)
lv_label_set_text
(
ext
->
label
,
txt
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment