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
94b6be4c
Commit
94b6be4c
authored
Aug 16, 2017
by
Gabor
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'beta' into bugfix
parents
0c1e3239
1ff5f1f9
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
201 additions
and
53 deletions
+201
-53
README.md
README.md
+1
-1
lv_app_benchmark.c
lv_appx/lv_app_benchmark.c
+8
-0
lv_conf_templ.h
lv_conf_templ.h
+10
-9
lv_draw_vbasic.c
lv_draw/lv_draw_vbasic.c
+1
-3
lv_refr.c
lv_obj/lv_refr.c
+15
-15
lv_vdb.c
lv_obj/lv_vdb.c
+67
-12
lv_vdb.h
lv_obj/lv_vdb.h
+9
-4
lv_label.c
lv_objx/lv_label.c
+20
-0
lv_label.h
lv_objx/lv_label.h
+6
-4
lv_ta.c
lv_objx/lv_ta.c
+57
-5
lv_ta.h
lv_objx/lv_ta.h
+7
-0
No files found.
README.md
View file @
94b6be4c
...
...
@@ -63,7 +63,7 @@ See the [example HAL](https://github.com/littlevgl/hal) repository!
*
your_systick_init();
*
your_disp_init();
*
your_indev_init();
*
**lv
gl
_init()**
;
*
**lv_init()**
;
10.
To
**test**
create a label:
`lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);`
11.
In the main
*while(1)*
call
`ptask_handler();`
and make a few milliseconds delay (e.g.
`your_delay_ms(5);`
)
12.
Compile the code and load it to your embedded hardware
...
...
lv_appx/lv_app_benchmark.c
View file @
94b6be4c
...
...
@@ -146,6 +146,14 @@ const lv_app_dsc_t * lv_app_benchmark_init(void)
static
void
my_app_run
(
lv_app_inst_t
*
app
,
void
*
conf
)
{
/*Initialize the application*/
my_app_data_t
*
ad
=
app
->
app_data
;
ad
->
opa
=
0
;
ad
->
recolor
=
0
;
ad
->
shdw
=
0
;
ad
->
upscalse
=
0
;
ad
->
wp
=
0
;
}
/**
...
...
lv_conf_templ.h
View file @
94b6be4c
...
...
@@ -17,18 +17,19 @@
#define LV_HOR_RES (320 * LV_DOWNSCALE)
#define LV_VER_RES (240 * LV_DOWNSCALE)
#define LV_DPI (80 * LV_DOWNSCALE)
/* Buffered rendering: >= LV_DOWNSCALE * LV_HOR_RES or 0 to disable buffering*/
#define LV_VDB_SIZE (LV_HOR_RES * 30)
/* Enable antialaiassing
/* Enable anti-aliasing
* If enabled everything will half-sized
* Use LV_DOWNSCALE to compensate
* the down scaling effect of antialiassing*/
* Use LV_DOWNSCALE to compensate he down scaling effect of anti-aliasing*/
#define LV_ANTIALIAS 1
#define LV_DOWNSCALE (1 << LV_ANTIALIAS) /*Set the downscaling value*/
/*Set the downscaling value*/
#define LV_DOWNSCALE (1 << LV_ANTIALIAS)
/* Buffered rendering: >= LV_DOWNSCALE * LV_HOR_RES or 0 to disable buffering*/
#define LV_VDB_SIZE (LV_HOR_RES * LV_VER_RES / 20)
#if LV_VDB_SIZE
/* Double virtual buffering
* One for rendering another to transfer former rendered image to frame buffer in the background*/
#define LV_VDB_DOUBLE 0
#endif
#define LV_REFR_PERIOD 40 /*Screen refresh period in milliseconds*/
#define LV_INV_FIFO_SIZE 32 /*The average number of objects on a screen */
...
...
lv_draw/lv_draw_vbasic.c
View file @
94b6be4c
...
...
@@ -123,8 +123,7 @@ void lv_vfill(const area_t * cords_p, const area_t * mask_p,
cord_t
map_width
=
area_get_width
(
&
vdb_rel_a
);
if
(
color_map
[
0
].
full
!=
color
.
full
||
last_width
!=
map_width
)
{
uint16_t
i
;
for
(
i
=
0
;
i
<
map_width
;
i
++
)
{
for
(
i
=
0
;
i
<
map_width
;
i
++
)
{
color_map
[
i
].
full
=
color
.
full
;
}
...
...
@@ -133,7 +132,6 @@ void lv_vfill(const area_t * cords_p, const area_t * mask_p,
cord_t
row
;
for
(
row
=
vdb_rel_a
.
y1
;
row
<=
vdb_rel_a
.
y2
;
row
++
)
{
disp_color_cpy
(
&
vdb_buf_tmp
[
vdb_rel_a
.
x1
],
color_map
,
map_width
,
opa
);
vdb_buf_tmp
+=
vdb_width
;
}
#endif
...
...
lv_obj/lv_refr.c
View file @
94b6be4c
...
...
@@ -70,7 +70,6 @@ void lv_refr_init(void)
ptask_t
*
task
;
task
=
ptask_create
(
lv_refr_task
,
LV_REFR_PERIOD
,
PTASK_PRIO_MID
,
NULL
);
dm_assert
(
task
);
}
/**
...
...
@@ -130,7 +129,7 @@ void lv_inv_area(const area_t * area_p)
* @param cb pointer to a callback function (void my_refr_cb(uint32_t time_ms, uint32_t px_num))
* time_ms: refresh time in [ms]
* px_num: not the drawn pixels but the number of affected pixels of the screen
* (more pixels are drawn
with opacity area
s)
* (more pixels are drawn
because of overlapping object
s)
*/
void
lv_refr_set_monitor_cb
(
void
(
*
cb
)(
uint32_t
,
uint32_t
))
{
...
...
@@ -257,15 +256,8 @@ static void lv_refr_area_no_vdb(const area_t * area_p)
*/
static
void
lv_refr_area_with_vdb
(
const
area_t
*
area_p
)
{
lv_vdb_t
*
vdb_p
=
lv_vdb_get
();
/*Always use the full row*/
vdb_p
->
area
.
x1
=
area_p
->
x1
;
vdb_p
->
area
.
y1
=
area_p
->
y1
;
vdb_p
->
area
.
x2
=
area_p
->
x2
;
/*Calculate the max row num*/
uint32_t
max_row
=
(
uint32_t
)
LV_VDB_SIZE
/
(
vdb_p
->
area
.
x2
-
vdb_p
->
area
.
x1
+
1
);
uint32_t
max_row
=
(
uint32_t
)
LV_VDB_SIZE
/
(
area_get_width
(
area_p
)
);
if
(
max_row
>
area_get_height
(
area_p
))
max_row
=
area_get_height
(
area_p
);
/*Round the row number with downscale*/
...
...
@@ -273,20 +265,28 @@ static void lv_refr_area_with_vdb(const area_t * area_p)
max_row
&=
(
~
0x1
);
#endif
/*
Refresh all rows
*/
cord_t
row
=
area_p
->
y1
;
/*
Always use the full row
*/
cord_t
row
;
cord_t
row_last
=
0
;
for
(
row
=
area_p
->
y1
;
row
+
max_row
-
1
<=
area_p
->
y2
;
row
+=
max_row
)
{
lv_vdb_t
*
vdb_p
=
lv_vdb_get
();
/*Calc. the next y coordinates of VDB*/
vdb_p
->
area
.
x1
=
area_p
->
x1
;
vdb_p
->
area
.
x2
=
area_p
->
x2
;
vdb_p
->
area
.
y1
=
row
;
vdb_p
->
area
.
y2
=
row
+
max_row
-
1
;
row_last
=
row
+
max_row
-
1
;
lv_refr_area_part_vdb
(
area_p
);
}
/*If the last y coordinates are not handled yet ...*/
if
(
area_p
->
y2
!=
vdb_p
->
area
.
y2
)
{
if
(
area_p
->
y2
!=
row_last
)
{
lv_vdb_t
*
vdb_p
=
lv_vdb_get
();
/*Calc. the next y coordinates of VDB*/
vdb_p
->
area
.
x1
=
area_p
->
x1
;
vdb_p
->
area
.
x2
=
area_p
->
x2
;
vdb_p
->
area
.
y1
=
row
;
vdb_p
->
area
.
y2
=
area_p
->
y2
;
...
...
lv_obj/lv_vdb.c
View file @
94b6be4c
...
...
@@ -20,7 +20,13 @@
/**********************
* TYPEDEFS
**********************/
#if LV_VDB_DOUBLE != 0
typedef
enum
{
LV_VDB_STATE_FREE
=
0
,
LV_VDB_STATE_ACTIVE
,
LV_VDB_STATE_FLUSH
,
}
lv_vdb_state_t
;
#endif
/**********************
* STATIC PROTOTYPES
**********************/
...
...
@@ -28,7 +34,12 @@
/**********************
* STATIC VARIABLES
**********************/
#if LV_VDB_DOUBLE == 0
static
lv_vdb_t
vdb
;
#else
static
lv_vdb_t
vdb
[
2
];
static
volatile
lv_vdb_state_t
vdb_state
[
2
]
=
{
LV_VDB_STATE_FREE
,
LV_VDB_STATE_FREE
};
#endif
/**********************
* MACROS
...
...
@@ -39,21 +50,53 @@ static lv_vdb_t vdb;
**********************/
/**
* Get the
vdb variabl
e
* @return pointer to the
vdb
variable
* Get the
'vdb' variable or allocate one in LV_VDB_DOUBLE mod
e
* @return pointer to the
'vdb'
variable
*/
lv_vdb_t
*
lv_vdb_get
(
void
)
{
#if LV_VDB_DOUBLE == 0
return
&
vdb
;
#else
/*If already there is an active do nothing*/
if
(
vdb_state
[
0
]
==
LV_VDB_STATE_ACTIVE
)
return
&
vdb
[
0
];
if
(
vdb_state
[
1
]
==
LV_VDB_STATE_ACTIVE
)
return
&
vdb
[
1
];
/*Try to allocate a free VDB*/
if
(
vdb_state
[
0
]
==
LV_VDB_STATE_FREE
)
{
vdb_state
[
0
]
=
LV_VDB_STATE_ACTIVE
;
return
&
vdb
[
0
];
}
if
(
vdb_state
[
1
]
==
LV_VDB_STATE_FREE
)
{
vdb_state
[
1
]
=
LV_VDB_STATE_ACTIVE
;
return
&
vdb
[
1
];
}
return
NULL
;
/*There wasn't free VDB (never happen)*/
#endif
}
/**
* Flush the content of the
vdb
* Flush the content of the
VDB
*/
void
lv_vdb_flush
(
void
)
{
lv_vdb_t
*
vdb_act
=
lv_vdb_get
();
if
(
vdb_act
==
NULL
)
return
;
#if LV_VDB_DOUBLE != 0
/* Wait the pending flush before starting this one
* (Don't forget: 'lv_vdb_flush_ready' has to be called when flushing is ready)*/
while
(
vdb_state
[
0
]
==
LV_VDB_STATE_FLUSH
||
vdb_state
[
1
]
==
LV_VDB_STATE_FLUSH
);
/*Turn the active VDB to flushing*/
if
(
vdb_state
[
0
]
==
LV_VDB_STATE_ACTIVE
)
vdb_state
[
0
]
=
LV_VDB_STATE_FLUSH
;
if
(
vdb_state
[
1
]
==
LV_VDB_STATE_ACTIVE
)
vdb_state
[
1
]
=
LV_VDB_STATE_FLUSH
;
#endif
#if LV_ANTIALIAS == 0
disp_map
(
vdb
.
area
.
x1
,
vdb
.
area
.
y1
,
vdb
.
area
.
x2
,
vdb
.
area
.
y2
,
vdb
.
buf
);
disp_map
(
vdb
_act
->
area
.
x1
,
vdb_act
->
area
.
y1
,
vdb_act
->
area
.
x2
,
vdb_act
->
area
.
y2
,
vdb_act
->
buf
);
#else
/* Get the average of 2x2 pixels and put the result back to the VDB
* The reading goes much faster then the write back
...
...
@@ -68,12 +111,12 @@ void lv_vdb_flush(void)
* */
cord_t
x
;
cord_t
y
;
cord_t
w
=
area_get_width
(
&
vdb
.
area
);
color_t
*
in1_buf
=
vdb
.
buf
;
/*Pointer to the first row*/
color_t
*
in2_buf
=
vdb
.
buf
+
w
;
/*Pointer to the second row*/
color_t
*
out_buf
=
vdb
.
buf
;
/*Store the result here*/
for
(
y
=
vdb
.
area
.
y1
;
y
<
vdb
.
area
.
y2
;
y
+=
2
)
{
for
(
x
=
vdb
.
area
.
x1
;
x
<
vdb
.
area
.
x2
;
x
+=
2
)
{
cord_t
w
=
area_get_width
(
&
vdb
_act
->
area
);
color_t
*
in1_buf
=
vdb
_act
->
buf
;
/*Pointer to the first row*/
color_t
*
in2_buf
=
vdb
_act
->
buf
+
w
;
/*Pointer to the second row*/
color_t
*
out_buf
=
vdb
_act
->
buf
;
/*Store the result here*/
for
(
y
=
vdb
_act
->
area
.
y1
;
y
<
vdb_act
->
area
.
y2
;
y
+=
2
)
{
for
(
x
=
vdb
_act
->
area
.
x1
;
x
<
vdb_act
->
area
.
x2
;
x
+=
2
)
{
/*If the pixels are the same do not calculate the average */
if
(
in1_buf
->
full
==
(
in1_buf
+
1
)
->
full
&&
...
...
@@ -103,7 +146,19 @@ void lv_vdb_flush(void)
/* Now the full the VDB is filtered and the result is stored in the first quarter of it
* Write out the filtered map to the display*/
disp_map
(
vdb
.
area
.
x1
>>
1
,
vdb
.
area
.
y1
>>
1
,
vdb
.
area
.
x2
>>
1
,
vdb
.
area
.
y2
>>
1
,
vdb
.
buf
);
disp_map
(
vdb_act
->
area
.
x1
>>
1
,
vdb_act
->
area
.
y1
>>
1
,
vdb_act
->
area
.
x2
>>
1
,
vdb_act
->
area
.
y2
>>
1
,
vdb_act
->
buf
);
#endif
}
/**
* In 'LV_VDB_DOUBLE' mode has to be called when the 'disp_map'
* is ready with copying the map to a frame buffer.
*/
void
lv_vdb_flush_ready
(
void
)
{
#if LV_VDB_DOUBLE != 0
if
(
vdb_state
[
0
]
==
LV_VDB_STATE_FLUSH
)
vdb_state
[
0
]
=
LV_VDB_STATE_FREE
;
if
(
vdb_state
[
1
]
==
LV_VDB_STATE_FLUSH
)
vdb_state
[
1
]
=
LV_VDB_STATE_FREE
;
#endif
}
...
...
lv_obj/lv_vdb.h
View file @
94b6be4c
...
...
@@ -34,15 +34,13 @@ typedef struct
color_t
buf
[
LV_VDB_SIZE
];
}
lv_vdb_t
;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Get the
vdb variabl
e
* @return pointer to the
vdb
variable
* Get the
'vdb' variable or allocate one in LV_VDB_DOUBLE mod
e
* @return pointer to the
'vdb'
variable
*/
lv_vdb_t
*
lv_vdb_get
(
void
);
...
...
@@ -51,6 +49,13 @@ lv_vdb_t * lv_vdb_get(void);
*/
void
lv_vdb_flush
(
void
);
/**
* In 'LV_VDB_DOUBLE' mode has to be called when 'disp_map()'
* is ready with copying the map to a frame buffer.
*/
void
lv_vdb_flush_ready
(
void
);
/**********************
* MACROS
**********************/
...
...
lv_objx/lv_label.c
View file @
94b6be4c
...
...
@@ -84,6 +84,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, lv_obj_t * copy)
ext
->
txt
=
NULL
;
ext
->
static_txt
=
0
;
ext
->
recolor
=
0
;
ext
->
no_break
=
0
;
ext
->
dot_end
=
LV_LABEL_DOT_END_INV
;
ext
->
long_mode
=
LV_LABEL_LONG_EXPAND
;
ext
->
offset
.
x
=
0
;
...
...
@@ -308,6 +309,19 @@ void lv_label_set_recolor(lv_obj_t * label, bool recolor)
lv_label_refr_text
(
label
);
}
/**
* Set the label the ignore (or accept) line breaks on '\n'
* @param label pointer to a label object
* @param en true: ignore line breaks, false: make line breaks on '\n'
*/
void
lv_label_set_no_break
(
lv_obj_t
*
label
,
bool
en
)
{
lv_label_ext_t
*
ext
=
lv_obj_get_ext
(
label
);
ext
->
no_break
=
en
==
false
?
0
:
1
;
lv_label_refr_text
(
label
);
}
/*=====================
* Getter functions
*====================*/
...
...
@@ -367,6 +381,7 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos)
if
(
ext
->
recolor
!=
0
)
flag
|=
TXT_FLAG_RECOLOR
;
if
(
ext
->
expand
!=
0
)
flag
|=
TXT_FLAG_EXPAND
;
if
(
ext
->
no_break
!=
0
)
flag
|=
TXT_FLAG_NO_BREAK
;
/*If the width will be expanded the set the max length to very big */
if
(
ext
->
long_mode
==
LV_LABEL_LONG_EXPAND
||
ext
->
long_mode
==
LV_LABEL_LONG_SCROLL
)
{
...
...
@@ -402,6 +417,8 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos)
}
if
(
x
>
style
->
letter_space
)
x
-=
style
->
letter_space
;
if
(
style
->
txt_align
==
LV_TXT_ALIGN_MID
)
{
cord_t
line_w
;
line_w
=
txt_get_width
(
&
txt
[
line_start
],
new_line_start
-
line_start
,
...
...
@@ -435,6 +452,7 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, point_t * pos)
if
(
ext
->
recolor
!=
0
)
flag
|=
TXT_FLAG_RECOLOR
;
if
(
ext
->
expand
!=
0
)
flag
|=
TXT_FLAG_EXPAND
;
if
(
ext
->
no_break
!=
0
)
flag
|=
TXT_FLAG_NO_BREAK
;
/*If the width will be expanded set the max length to very big */
if
(
ext
->
long_mode
==
LV_LABEL_LONG_EXPAND
||
ext
->
long_mode
==
LV_LABEL_LONG_SCROLL
)
{
...
...
@@ -513,6 +531,7 @@ static bool lv_label_design(lv_obj_t * label, const area_t * mask, lv_design_mod
txt_flag_t
flag
=
TXT_FLAG_NONE
;
if
(
ext
->
recolor
!=
0
)
flag
|=
TXT_FLAG_RECOLOR
;
if
(
ext
->
expand
!=
0
)
flag
|=
TXT_FLAG_EXPAND
;
if
(
ext
->
no_break
!=
0
)
flag
|=
TXT_FLAG_NO_BREAK
;
lv_draw_label
(
&
cords
,
mask
,
style
,
ext
->
txt
,
flag
,
&
ext
->
offset
);
}
...
...
@@ -546,6 +565,7 @@ static void lv_label_refr_text(lv_obj_t * label)
txt_flag_t
flag
=
TXT_FLAG_NONE
;
if
(
ext
->
recolor
!=
0
)
flag
|=
TXT_FLAG_RECOLOR
;
if
(
ext
->
expand
!=
0
)
flag
|=
TXT_FLAG_EXPAND
;
if
(
ext
->
no_break
!=
0
)
flag
|=
TXT_FLAG_NO_BREAK
;
txt_get_size
(
&
size
,
ext
->
txt
,
font
,
style
->
letter_space
,
style
->
line_space
,
max_w
,
flag
);
/*Refresh the full size in expand mode*/
...
...
lv_objx/lv_label.h
View file @
94b6be4c
...
...
@@ -51,7 +51,8 @@ typedef struct
point_t
offset
;
/*Text draw position offset*/
uint8_t
static_txt
:
1
;
/*Flag to indicate the text is static*/
uint8_t
recolor
:
1
;
/*Enable in-line letter re-coloring*/
uint8_t
expand
:
1
;
/*Force expand size when solving line length (used by the library with LV_LABEL_LONG_ROLL)*/
uint8_t
expand
:
1
;
/*Ignore real width (used by the library with LV_LABEL_LONG_ROLL)*/
uint8_t
no_break
:
1
;
/*Ignore new line characters*/
}
lv_label_ext_t
;
/**********************
...
...
@@ -119,12 +120,13 @@ void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode);
*/
void
lv_label_set_recolor
(
lv_obj_t
*
label
,
bool
recolor
);
/**
*
Enable the password mode
*
Set the label the ignore (or accept) line breaks on '\n'
* @param label pointer to a label object
* @param
pwd true: enable password mode, false: disable
* @param
en true: ignore line breaks, false: make line breaks on '\n'
*/
void
lv_label_set_
pwd_mode
(
lv_obj_t
*
label
,
bool
pwd
);
void
lv_label_set_
no_break
(
lv_obj_t
*
label
,
bool
en
);
/**
* Get the text of a label
...
...
lv_objx/lv_ta.c
View file @
94b6be4c
...
...
@@ -173,12 +173,13 @@ bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
}
else
if
(
sign
==
LV_SIGNAL_CORD_CHG
)
{
/*Set the label width according to the text area width*/
if
(
ext
->
label
!=
NULL
)
{
lv_obj_set_width
(
ext
->
label
,
lv_obj_get_width
(
ta
)
-
2
*
(
style
->
hpad
+
style
->
hpad
));
if
(
lv_obj_get_width
(
ta
)
!=
area_get_width
(
param
)
||
lv_obj_get_height
(
ta
)
!=
area_get_height
(
param
))
{
lv_obj_set_width
(
ext
->
label
,
lv_obj_get_width
(
ta
)
-
2
*
style
->
hpad
);
lv_label_set_text
(
ext
->
label
,
NULL
);
}
}
}
else
if
(
sign
==
LV_SIGNAL_CONTROLL
)
{
lv_ta_ext_t
*
ext
=
lv_obj_get_ext
(
ta
);
char
c
=
*
((
char
*
)
param
);
if
(
c
==
LV_GROUP_KEY_RIGHT
)
{
lv_ta_cursor_right
(
ta
);
...
...
@@ -312,6 +313,12 @@ void lv_ta_set_text(lv_obj_t * ta, const char * txt)
lv_label_set_text
(
ext
->
label
,
txt
);
lv_ta_set_cursor_pos
(
ta
,
LV_TA_CUR_LAST
);
/*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
);
lv_obj_set_width
(
ext
->
label
,
style
->
line_width
);
}
/*It is a valid x step so save it*/
lv_ta_save_valid_cursor_x
(
ta
);
...
...
@@ -353,6 +360,11 @@ void lv_ta_del(lv_obj_t * ta)
/*Refresh the label*/
lv_label_set_text
(
ext
->
label
,
buf
);
/*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
);
lv_obj_set_width
(
ext
->
label
,
style
->
line_width
);
}
/*Move the cursor to the place of the deleted character*/
lv_ta_set_cursor_pos
(
ta
,
lv_ta_get_cursor_pos
(
ta
)
-
1
);
...
...
@@ -404,6 +416,16 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
lv_obj_set_y
(
label_par
,
-
(
cur_pos
.
y
-
lv_obj_get_height
(
ta
)
+
font_h
+
2
*
style_scrl
->
vpad
));
}
/*Check the left (use the font_h as general unit)*/
if
(
lv_obj_get_x
(
label_par
)
+
cur_pos
.
x
<
font_h
)
{
lv_obj_set_x
(
label_par
,
-
cur_pos
.
x
+
font_h
);
}
/*Check the right (use the font_h as general unit)*/
if
(
label_cords
.
x1
+
cur_pos
.
x
+
font_h
+
style_scrl
->
hpad
>
ta_cords
.
x2
)
{
lv_obj_set_x
(
label_par
,
-
(
cur_pos
.
x
-
lv_obj_get_width
(
ta
)
+
font_h
+
2
*
style_scrl
->
hpad
));
}
lv_obj_inv
(
ta
);
}
...
...
@@ -533,6 +555,36 @@ void lv_ta_set_pwd_mode(lv_obj_t * ta, bool en)
ext
->
pwd_mode
=
en
==
false
?
0
:
1
;
}
/**
* 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
)
{
if
(
en
!=
false
)
{
lv_ta_ext_t
*
ext
=
lv_obj_get_ext
(
ta
);
lv_style_t
*
style_ta
=
lv_obj_get_style
(
ta
);
lv_style_t
*
style_label
=
lv_obj_get_style
(
ext
->
label
);
lv_cont_set_fit
(
lv_page_get_scrl
(
ta
),
true
,
true
);
lv_obj_set_height
(
ta
,
font_get_height
(
style_label
->
font
)
+
style_ta
->
vpad
*
2
);
lv_label_set_long_mode
(
ext
->
label
,
LV_LABEL_LONG_EXPAND
);
lv_label_set_no_break
(
ext
->
label
,
true
);
lv_obj_set_pos
(
lv_page_get_scrl
(
ta
),
style_ta
->
hpad
,
style_ta
->
vpad
);
}
else
{
lv_ta_ext_t
*
ext
=
lv_obj_get_ext
(
ta
);
lv_style_t
*
style_ta
=
lv_obj_get_style
(
ta
);
lv_cont_set_fit
(
lv_page_get_scrl
(
ta
),
false
,
true
);
lv_label_set_long_mode
(
ext
->
label
,
LV_LABEL_LONG_BREAK
);
lv_label_set_no_break
(
ext
->
label
,
false
);
lv_obj_set_height
(
ta
,
LV_TA_DEF_HEIGHT
);
lv_obj_set_pos
(
lv_page_get_scrl
(
ta
),
style_ta
->
hpad
,
style_ta
->
vpad
);
}
}
/*=====================
* Getter functions
*====================*/
...
...
@@ -664,9 +716,9 @@ static bool lv_ta_scrling_design(lv_obj_t * scrling, const area_t * mask, lv_des
area_t
cur_area
;
lv_style_t
*
labels_p
=
lv_obj_get_style
(
ta_ext
->
label
);
cur_area
.
x1
=
letter_pos
.
x
+
ta_ext
->
label
->
cords
.
x1
;
cur_area
.
x1
=
letter_pos
.
x
+
ta_ext
->
label
->
cords
.
x1
-
scrl_style
->
line_width
/
2
;
cur_area
.
y1
=
letter_pos
.
y
+
ta_ext
->
label
->
cords
.
y1
;
cur_area
.
x2
=
letter_pos
.
x
+
ta_ext
->
label
->
cords
.
x1
+
scrl_style
->
line_width
;
cur_area
.
x2
=
letter_pos
.
x
+
ta_ext
->
label
->
cords
.
x1
+
scrl_style
->
line_width
/
2
+
(
scrl_style
->
line_width
&
0x1
)
;
cur_area
.
y2
=
letter_pos
.
y
+
ta_ext
->
label
->
cords
.
y1
+
(
font_get_height
(
labels_p
->
font
)
>>
FONT_ANTIALIAS
);
lv_style_t
cur_rects
;
...
...
lv_objx/lv_ta.h
View file @
94b6be4c
...
...
@@ -148,6 +148,13 @@ void lv_ta_set_cursor_show(lv_obj_t * ta, bool show);
void
lv_ta_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
);
/**
* Get the text of the i the text area
* @param ta obj pointer to a text area object
* @return pointer to the text
...
...
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