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
c72bb450
Commit
c72bb450
authored
Sep 25, 2017
by
Gabor Kiss-Vamosi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lv_ta: cursor style bugfix on '\n'
parent
ebfe8fbf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
17 deletions
+96
-17
lv_page.c
lv_objx/lv_page.c
+3
-4
lv_page.h
lv_objx/lv_page.h
+8
-0
lv_ta.c
lv_objx/lv_ta.c
+76
-13
lv_ta.h
lv_objx/lv_ta.h
+9
-0
No files found.
lv_objx/lv_page.c
View file @
c72bb450
...
...
@@ -31,7 +31,6 @@
static
void
lv_page_sb_refresh
(
lv_obj_t
*
main
);
static
bool
lv_page_design
(
lv_obj_t
*
scrl
,
const
area_t
*
mask
,
lv_design_mode_t
mode
);
static
bool
lv_scrl_design
(
lv_obj_t
*
scrl
,
const
area_t
*
mask
,
lv_design_mode_t
mode
);
static
bool
lv_scrl_signal
(
lv_obj_t
*
scrl
,
lv_signal_t
sign
,
void
*
param
);
/**********************
* STATIC VARIABLES
...
...
@@ -82,7 +81,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
lv_style_t
*
style
=
lv_style_get
(
LV_STYLE_PRETTY_COLOR
,
NULL
);
ext
->
scrl
=
lv_cont_create
(
new_page
,
NULL
);
if
(
ancestor_scrl_design_f
==
NULL
)
ancestor_scrl_design_f
=
lv_obj_get_design_f
(
ext
->
scrl
);
lv_obj_set_signal_f
(
ext
->
scrl
,
lv_scrl_signal
);
lv_obj_set_signal_f
(
ext
->
scrl
,
lv_
page_
scrl_signal
);
lv_obj_set_drag
(
ext
->
scrl
,
true
);
lv_obj_set_drag_throw
(
ext
->
scrl
,
true
);
lv_obj_set_protect
(
ext
->
scrl
,
LV_PROTECT_PARENT
);
...
...
@@ -102,7 +101,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
}
else
{
lv_page_ext_t
*
copy_ext
=
lv_obj_get_ext
(
copy
);
ext
->
scrl
=
lv_cont_create
(
new_page
,
copy_ext
->
scrl
);
lv_obj_set_signal_f
(
ext
->
scrl
,
lv_scrl_signal
);
lv_obj_set_signal_f
(
ext
->
scrl
,
lv_
page_
scrl_signal
);
lv_page_set_pr_action
(
new_page
,
copy_ext
->
pr_action
);
lv_page_set_rel_action
(
new_page
,
copy_ext
->
rel_action
);
...
...
@@ -209,7 +208,7 @@ bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
*/
static
bool
lv_scrl_signal
(
lv_obj_t
*
scrl
,
lv_signal_t
sign
,
void
*
param
)
bool
lv_page_scrl_signal
(
lv_obj_t
*
scrl
,
lv_signal_t
sign
,
void
*
param
)
{
bool
obj_valid
=
true
;
...
...
lv_objx/lv_page.h
View file @
c72bb450
...
...
@@ -80,6 +80,14 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy);
bool
lv_page_signal
(
lv_obj_t
*
page
,
lv_signal_t
sign
,
void
*
param
);
/**
* Signal function of the scrollable part of a page
* @param scrl pointer to the scrollable object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
*/
bool
lv_page_scrl_signal
(
lv_obj_t
*
scrl
,
lv_signal_t
sign
,
void
*
param
);
/**
* Set a release action for the page
* @param page pointer to a page object
* @param rel_action a function to call when the page is released
...
...
lv_objx/lv_ta.c
View file @
c72bb450
...
...
@@ -14,7 +14,11 @@
#include "../lv_obj/lv_group.h"
#include "../lv_draw/lv_draw.h"
#include "misc/gfx/anim.h"
<<<<<<<
ebfe8fbfd4d93bd0e09a8b16e96e623c5c6be0f2
#include "misc/gfx/text.h"
=======
#include "misc/math/math_base.h"
>>>>>>>
lv_ta
:
cursor
style
bugfix
on
'\n'
/*********************
* DEFINES
...
...
@@ -43,7 +47,7 @@
* STATIC PROTOTYPES
**********************/
static
bool
lv_ta_design
(
lv_obj_t
*
ta
,
const
area_t
*
mask
,
lv_design_mode_t
mode
);
static
bool
lv_ta_scrling_design
(
lv_obj_t
*
scrl
ing
,
const
area_t
*
mask
,
lv_design_mode_t
mode
);
static
bool
lv_ta_scrling_design
(
lv_obj_t
*
scrl
,
const
area_t
*
mask
,
lv_design_mode_t
mode
);
static
void
cursor_blink_anim
(
lv_obj_t
*
ta
,
uint8_t
show
);
static
void
pwd_char_hider_anim
(
lv_obj_t
*
ta
,
int32_t
x
);
static
void
pwd_char_hider
(
lv_obj_t
*
ta
);
...
...
@@ -96,6 +100,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
if
(
scrl_design_f
==
NULL
)
scrl_design_f
=
lv_obj_get_design_f
(
ext
->
page
.
scrl
);
lv_obj_set_signal_f
(
new_ta
,
lv_ta_signal
);
lv_obj_set_signal_f
(
lv_page_get_scrl
(
new_ta
),
lv_ta_scrl_signal
);
lv_obj_set_design_f
(
new_ta
,
lv_ta_design
);
/*Init the new text area object*/
...
...
@@ -173,6 +178,8 @@ bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
lv_obj_set_width
(
ext
->
label
,
lv_obj_get_width
(
scrl
)
-
2
*
style_scrl
->
hpad
);
lv_obj_set_pos
(
ext
->
label
,
style_scrl
->
hpad
,
style_scrl
->
vpad
);
lv_label_set_text
(
ext
->
label
,
NULL
);
lv_obj_refr_ext_size
(
lv_page_get_scrl
(
ta
));
}
}
else
if
(
sign
==
LV_SIGNAL_CORD_CHG
)
{
/*Set the label width according to the text area width*/
...
...
@@ -186,7 +193,8 @@ bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
lv_label_set_text
(
ext
->
label
,
NULL
);
/*Refresh the label*/
}
}
}
else
if
(
sign
==
LV_SIGNAL_CONTROLL
)
{
}
else
if
(
sign
==
LV_SIGNAL_CONTROLL
)
{
char
c
=
*
((
char
*
)
param
);
if
(
c
==
LV_GROUP_KEY_RIGHT
)
{
lv_ta_cursor_right
(
ta
);
...
...
@@ -202,6 +210,34 @@ bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
return
valid
;
}
/**
* Signal function of the scrollable part of the text area
* @param scrl pointer to scrollable part of a text area 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_ta_scrl_signal
(
lv_obj_t
*
scrl
,
lv_signal_t
sign
,
void
*
param
)
{
bool
valid
;
/* Include the ancient signal function */
valid
=
lv_page_scrl_signal
(
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_REFR_EXT_SIZE
)
{
/*Set ext. size because the cursor might be out of this object*/
lv_obj_t
*
ta
=
lv_obj_get_parent
(
scrl
);
lv_ta_ext_t
*
ext
=
lv_obj_get_ext
(
ta
);
lv_style_t
*
style_label
=
lv_obj_get_style
(
ext
->
label
);
scrl
->
ext_size
=
MATH_MAX
(
scrl
->
ext_size
,
style_label
->
line_space
+
font_get_height
(
style_label
->
font
));
}
}
return
valid
;
}
/*=====================
* Setter functions
*====================*/
...
...
@@ -779,8 +815,8 @@ static bool lv_ta_design(lv_obj_t * ta, const area_t * masp, lv_design_mode_t mo
}
/**
* An extended scroll
ing design of the page. Calls the normal design function and it
draws a cursor.
* @param
label pointer to a text area object
* An extended scroll
able design of the page. Calls the normal design function and
draws a cursor.
* @param
scrl pointer to the scrollabla part of the Text area
* @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)
...
...
@@ -788,19 +824,19 @@ static bool lv_ta_design(lv_obj_t * ta, const area_t * masp, lv_design_mode_t mo
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
* @return return true/false, depends on 'mode'
*/
static
bool
lv_ta_scrling_design
(
lv_obj_t
*
scrl
ing
,
const
area_t
*
mask
,
lv_design_mode_t
mode
)
static
bool
lv_ta_scrling_design
(
lv_obj_t
*
scrl
,
const
area_t
*
mask
,
lv_design_mode_t
mode
)
{
if
(
mode
==
LV_DESIGN_COVER_CHK
)
{
/*Return false if the object is not covers the mask_p area*/
return
scrl_design_f
(
scrl
ing
,
mask
,
mode
);
return
scrl_design_f
(
scrl
,
mask
,
mode
);
}
else
if
(
mode
==
LV_DESIGN_DRAW_MAIN
)
{
/*Draw the object*/
scrl_design_f
(
scrl
ing
,
mask
,
mode
);
scrl_design_f
(
scrl
,
mask
,
mode
);
}
else
if
(
mode
==
LV_DESIGN_DRAW_POST
)
{
scrl_design_f
(
scrl
ing
,
mask
,
mode
);
scrl_design_f
(
scrl
,
mask
,
mode
);
/*Draw the cursor too*/
lv_obj_t
*
ta
=
lv_obj_get_parent
(
scrl
ing
);
lv_obj_t
*
ta
=
lv_obj_get_parent
(
scrl
);
lv_ta_ext_t
*
ta_ext
=
lv_obj_get_ext
(
ta
);
if
(
ta_ext
->
cursor_show
==
0
||
ta_ext
->
cursor_state
==
0
)
return
true
;
/*The cursor is not visible now*/
...
...
@@ -808,10 +844,11 @@ static bool lv_ta_scrling_design(lv_obj_t * scrling, const area_t * mask, lv_des
lv_style_t
cur_style
;
if
(
ta_ext
->
cursor_style
!=
NULL
)
{
lv_style_cpy
(
&
cur_style
,
ta_ext
->
cursor_style
);
lv_style_cpy
(
&
cur_style
,
ta_ext
->
cursor_style
);
}
else
{
lv_style_cpy
(
&
cur_style
,
label_style
);
/*Use the label style is no better option and modify it */
/*If cursor style is not specified then use the modified label style */
lv_style_cpy
(
&
cur_style
,
label_style
);
color_t
ccolor_tmp
=
cur_style
.
ccolor
;
/*Make letter color to cursor color*/
cur_style
.
ccolor
=
cur_style
.
mcolor
;
/*In block mode the letter color will be current background color*/
cur_style
.
mcolor
=
ccolor_tmp
;
...
...
@@ -840,9 +877,33 @@ static bool lv_ta_scrling_design(lv_obj_t * scrling, const area_t * mask, lv_des
printf
(
"letter %d
\n
"
,
letter
);
cord_t
letter_w
=
font_get_width
(
label_style
->
font
,
letter
!=
'\0'
?
letter
:
' '
);
cord_t
letter_h
=
font_get_height
(
label_style
->
font
)
>>
FONT_ANTIALIAS
;
/*Set letter_w (set not 0 on non printable but valid chars)*/
cord_t
letter_w
;
if
(
txt
[
byte_pos
]
==
'\0'
||
txt
[
byte_pos
]
==
'\n'
||
txt
[
byte_pos
]
==
'\r'
)
{
letter_w
=
font_get_width
(
label_style
->
font
,
' '
);
}
else
{
letter_w
=
font_get_width
(
label_style
->
font
,
txt
[
byte_pos
]);
}
point_t
letter_pos
;
lv_label_get_letter_pos
(
ta_ext
->
label
,
cur_pos
,
&
letter_pos
);
lv_label_get_letter_pos
(
ta_ext
->
label
,
byte_pos
,
&
letter_pos
);
/*If the cursor is out of the text (most right) draw it to the next line*/
if
(
letter_pos
.
x
+
ta_ext
->
label
->
cords
.
x1
+
letter_w
>
ta_ext
->
label
->
cords
.
x2
)
{
letter_pos
.
x
=
0
;
letter_pos
.
y
+=
letter_h
+
label_style
->
line_space
;
if
(
txt
[
byte_pos
]
!=
'\0'
)
txt_utf8_next
(
txt
,
&
byte_pos
);
if
(
txt
[
byte_pos
]
==
'\0'
||
txt
[
byte_pos
]
==
'\n'
||
txt
[
byte_pos
]
==
'\r'
)
{
letter_w
=
font_get_width
(
label_style
->
font
,
' '
);
}
else
{
letter_w
=
font_get_width
(
label_style
->
font
,
txt
[
cur_pos
]);
}
}
/*Draw he cursor according to the type*/
area_t
cur_area
;
if
(
ta_ext
->
cursor_type
==
LV_TA_CURSOR_LINE
)
{
cur_area
.
x1
=
letter_pos
.
x
+
ta_ext
->
label
->
cords
.
x1
;
...
...
@@ -855,6 +916,7 @@ static bool lv_ta_scrling_design(lv_obj_t * scrling, const area_t * mask, lv_des
cur_area
.
y1
=
letter_pos
.
y
+
ta_ext
->
label
->
cords
.
y1
;
cur_area
.
x2
=
letter_pos
.
x
+
ta_ext
->
label
->
cords
.
x1
+
letter_w
;
cur_area
.
y2
=
letter_pos
.
y
+
ta_ext
->
label
->
cords
.
y1
+
letter_h
;
lv_draw_rect
(
&
cur_area
,
mask
,
&
cur_style
);
/*Get the current letter*/
...
...
@@ -873,6 +935,7 @@ static bool lv_ta_scrling_design(lv_obj_t * scrling, const area_t * mask, lv_des
cur_area
.
y1
=
letter_pos
.
y
+
ta_ext
->
label
->
cords
.
y1
;
cur_area
.
x2
=
letter_pos
.
x
+
ta_ext
->
label
->
cords
.
x1
+
letter_w
;
cur_area
.
y2
=
letter_pos
.
y
+
ta_ext
->
label
->
cords
.
y1
+
letter_h
;
cur_style
.
empty
=
1
;
if
(
cur_style
.
bwidth
==
0
)
cur_style
.
bwidth
=
1
*
LV_DOWNSCALE
;
/*Be sure the border will be drawn*/
lv_draw_rect
(
&
cur_area
,
mask
,
&
cur_style
);
...
...
@@ -881,10 +944,10 @@ static bool lv_ta_scrling_design(lv_obj_t * scrling, const area_t * mask, lv_des
cur_area
.
y1
=
letter_pos
.
y
+
ta_ext
->
label
->
cords
.
y1
+
letter_h
-
cur_style
.
line_width
;
cur_area
.
x2
=
letter_pos
.
x
+
ta_ext
->
label
->
cords
.
x1
+
letter_w
;
cur_area
.
y2
=
letter_pos
.
y
+
ta_ext
->
label
->
cords
.
y1
+
letter_h
;
lv_draw_rect
(
&
cur_area
,
mask
,
&
cur_style
);
}
}
return
true
;
...
...
lv_objx/lv_ta.h
View file @
c72bb450
...
...
@@ -83,6 +83,15 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy);
bool
lv_ta_signal
(
lv_obj_t
*
ta
,
lv_signal_t
sign
,
void
*
param
);
/**
* Signal function of the scrollable part of the text area
* @param scrl pointer to scrollable part of a text area 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_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
...
...
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