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
d9b063d7
Commit
d9b063d7
authored
Oct 04, 2016
by
Gabor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lv_ta finished + LV_DESIGN_MODE_DRAW_POST added + bugfixes
parent
1a591d49
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
355 additions
and
227 deletions
+355
-227
lv_draw_rbasic.h
lv_draw/lv_draw_rbasic.h
+1
-1
lv_draw_vbasic.h
lv_draw/lv_draw_vbasic.h
+1
-1
area.c
lv_misc/area.c
+21
-1
area.h
lv_misc/area.h
+4
-1
circ.c
lv_misc/circ.c
+1
-1
circ.h
lv_misc/circ.h
+1
-1
text.c
lv_misc/text.c
+4
-0
text.h
lv_misc/text.h
+1
-1
lv_obj.c
lv_obj/lv_obj.c
+12
-16
lv_obj.h
lv_obj/lv_obj.h
+3
-2
lv_refr.c
lv_obj/lv_refr.c
+6
-1
lv_vdb.h
lv_obj/lv_vdb.h
+1
-1
lv_btn.c
lv_objx/lv_btn.c
+10
-10
lv_btnm.c
lv_objx/lv_btnm.c
+1
-0
lv_cb.c
lv_objx/lv_cb.c
+1
-0
lv_chart.c
lv_objx/lv_chart.c
+24
-24
lv_img.c
lv_objx/lv_img.c
+18
-16
lv_label.c
lv_objx/lv_label.c
+46
-32
lv_led.c
lv_objx/lv_led.c
+14
-16
lv_line.c
lv_objx/lv_line.c
+32
-31
lv_list.c
lv_objx/lv_list.c
+110
-38
lv_list.h
lv_objx/lv_list.h
+2
-0
lv_objx_templ.c
lv_objx/lv_objx_templ.c
+1
-0
lv_page.c
lv_objx/lv_page.c
+0
-0
lv_page.h
lv_objx/lv_page.h
+10
-5
lv_pb.c
lv_objx/lv_pb.c
+14
-16
lv_rect.c
lv_objx/lv_rect.c
+11
-12
lv_ta.c
lv_objx/lv_ta.c
+0
-0
lv_ta.h
lv_objx/lv_ta.h
+5
-0
No files found.
lv_draw/lv_draw_rbasic.h
View file @
d9b063d7
...
...
@@ -10,7 +10,7 @@
* INCLUDES
*********************/
#include "misc/others/color.h"
#include "../lv_misc/
2d
.h"
#include "../lv_misc/
area
.h"
#include "../lv_misc/font.h"
/*********************
...
...
lv_draw/lv_draw_vbasic.h
View file @
d9b063d7
...
...
@@ -14,7 +14,7 @@
#if LV_VDB_SIZE != 0
#include "misc/others/color.h"
#include "../lv_misc/
2d
.h"
#include "../lv_misc/
area
.h"
#include "../lv_misc/font.h"
/*********************
...
...
lv_misc/
2d
.c
→
lv_misc/
area
.c
View file @
d9b063d7
...
...
@@ -6,7 +6,7 @@
/*********************
* INCLUDES
*********************/
#include <lvgl/lv_misc/
2d
.h>
#include <lvgl/lv_misc/
area
.h>
#include "misc/math/math_base.h"
/*********************
...
...
@@ -49,6 +49,26 @@ void area_set(area_t * area_p, cord_t x1, cord_t y1, cord_t x2, cord_t y2)
area_p
->
y2
=
y2
;
}
void
area_set_width
(
area_t
*
area_p
,
cord_t
w
)
{
area_p
->
x2
=
area_p
->
x1
+
w
-
1
;
}
void
area_set_height
(
area_t
*
area_p
,
cord_t
h
)
{
area_p
->
y2
=
area_p
->
y1
+
h
-
1
;
}
void
area_set_pos
(
area_t
*
area_p
,
cord_t
x
,
cord_t
y
)
{
cord_t
w
=
area_get_width
(
area_p
);
cord_t
h
=
area_get_height
(
area_p
);
area_p
->
x1
=
x
;
area_p
->
y1
=
y
;
area_set_width
(
area_p
,
w
);
area_set_height
(
area_p
,
h
);
}
/**
* Return with area of an area (x * y)
* @param area_p pointer to an area
...
...
lv_misc/
2d
.h
→
lv_misc/
area
.h
View file @
d9b063d7
/**
* @file
2d
.h
* @file
area
.h
*
*/
...
...
@@ -57,6 +57,9 @@ static inline cord_t area_get_height(const area_t * area_p)
}
void
area_set
(
area_t
*
area_p
,
cord_t
x1
,
cord_t
y1
,
cord_t
x2
,
cord_t
y2
);
void
area_set_width
(
area_t
*
area_p
,
cord_t
w
);
void
area_set_height
(
area_t
*
area_p
,
cord_t
h
);
void
area_set_pos
(
area_t
*
area_p
,
cord_t
x
,
cord_t
y
);
uint32_t
area_get_size
(
const
area_t
*
area_p
);
bool
area_union
(
area_t
*
res_p
,
const
area_t
*
a1_p
,
const
area_t
*
a2_p
);
void
area_join
(
area_t
*
a_res_p
,
const
area_t
*
a1_p
,
const
area_t
*
a2_p
);
...
...
lv_misc/circ.c
View file @
d9b063d7
...
...
@@ -8,7 +8,7 @@
/*********************
* INCLUDES
*********************/
#include <lvgl/lv_misc/
2d
.h>
#include <lvgl/lv_misc/
area
.h>
/*********************
* DEFINES
...
...
lv_misc/circ.h
View file @
d9b063d7
...
...
@@ -10,7 +10,7 @@
* INCLUDES
*********************/
#include <lvgl/lv_misc/
2d
.h>
#include <lvgl/lv_misc/
area
.h>
#include <stddef.h>
/*********************
...
...
lv_misc/text.c
View file @
d9b063d7
...
...
@@ -72,6 +72,10 @@ uint16_t txt_get_next_line(const char * txt, const font_t * font_p,
while
(
txt
[
i
]
==
' '
)
i
++
;
/* Do not let to return without doing nothing.
* Find at least one character */
if
(
i
==
0
)
i
++
;
return
i
;
}
/*If this char still can fit to this line then check if
...
...
lv_misc/text.h
View file @
d9b063d7
...
...
@@ -10,7 +10,7 @@
* INCLUDES
*********************/
#include <lvgl/lv_misc/
2d
.h>
#include <lvgl/lv_misc/
area
.h>
#include <stdbool.h>
#include "font.h"
...
...
lv_obj/lv_obj.c
View file @
d9b063d7
...
...
@@ -394,18 +394,15 @@ void lv_obj_set_parent(lv_obj_t* obj_dp, lv_obj_t* parent_dp)
old_pos
.
y
=
lv_obj_get_y
(
obj_dp
);
ll_chg_list
(
&
obj_dp
->
par_dp
->
child_ll
,
&
parent_dp
->
child_ll
,
obj_dp
);
/*Notify the original parent because one of its children is lost*/
obj_dp
->
par_dp
->
signal_f
(
obj_dp
->
par_dp
,
LV_SIGNAL_CHILD_CHG
,
NULL
);
obj_dp
->
par_dp
=
parent_dp
;
lv_obj_set_pos
(
obj_dp
,
old_pos
.
x
,
old_pos
.
y
);
/*Notify the original parent because one of its children is lost*/
obj_dp
->
par_dp
->
signal_f
(
obj_dp
->
par_dp
,
LV_SIGNAL_CHILD_CHG
,
NULL
);
/*Notify the new parent about the child*/
parent_dp
->
signal_f
(
parent_dp
,
LV_SIGNAL_CHILD_CHG
,
obj_dp
);
lv_obj_inv
(
obj_dp
);
}
...
...
@@ -1342,20 +1339,19 @@ static bool lv_obj_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo
bool
cover
;
cover
=
area_is_in
(
mask_p
,
&
obj_dp
->
cords
);
return
cover
;
}
}
else
if
(
mode
==
LV_DESIGN_DRAW_MAIN
)
{
lv_objs_t
*
objs_p
=
lv_obj_get_style
(
obj_dp
);
lv_objs_t
*
objs_p
=
lv_obj_get_style
(
obj_dp
);
opa_t
opa
=
lv_obj_get_opa
(
obj_dp
);
color_t
color
=
objs_p
->
color
;
opa_t
opa
=
lv_obj_get_opa
(
obj_dp
);
color_t
color
=
objs_p
->
color
;
/*Simply draw a rectangle*/
/*Simply draw a rectangle*/
#if LV_VDB_SIZE == 0
lv_rfill
(
&
obj_dp
->
cords
,
mask_p
,
color
,
opa
);
lv_rfill
(
&
obj_dp
->
cords
,
mask_p
,
color
,
opa
);
#else
lv_vfill
(
&
obj_dp
->
cords
,
mask_p
,
color
,
opa
);
lv_vfill
(
&
obj_dp
->
cords
,
mask_p
,
color
,
opa
);
#endif
}
return
true
;
}
...
...
lv_obj/lv_obj.h
View file @
d9b063d7
...
...
@@ -9,7 +9,7 @@
/*********************
* INCLUDES
*********************/
#include <lvgl/lv_misc/
2d
.h>
#include <lvgl/lv_misc/
area
.h>
#include <stddef.h>
#include <stdbool.h>
#include "misc/mem/dyn_mem.h"
...
...
@@ -54,7 +54,8 @@ struct __LV_OBJ_T;
typedef
enum
{
LV_DESIGN_DRAW
,
LV_DESIGN_DRAW_MAIN
,
LV_DESIGN_DRAW_POST
,
LV_DESIGN_COVER_CHK
,
}
lv_design_mode_t
;
...
...
lv_obj/lv_refr.c
View file @
d9b063d7
...
...
@@ -399,7 +399,7 @@ static void lv_refr_obj(lv_obj_t* obj_dp, const area_t * mask_ori_p)
/* Redraw the object */
if
(
obj_dp
->
opa
!=
OPA_TRANSP
&&
LV_SA
(
obj_dp
,
lv_objs_t
)
->
transp
==
0
)
{
obj_dp
->
design_f
(
obj_dp
,
&
mask_parent
,
LV_DESIGN_DRAW
);
obj_dp
->
design_f
(
obj_dp
,
&
mask_parent
,
LV_DESIGN_DRAW
_MAIN
);
}
area_t
mask_child
;
/*Mask from obj_dp and its child*/
...
...
@@ -416,5 +416,10 @@ static void lv_refr_obj(lv_obj_t* obj_dp, const area_t * mask_ori_p)
lv_refr_obj
(
child_p
,
&
mask_child
);
}
}
/* If all the children are redrawn call make 'post draw' design */
if
(
obj_dp
->
opa
!=
OPA_TRANSP
&&
LV_SA
(
obj_dp
,
lv_objs_t
)
->
transp
==
0
)
{
obj_dp
->
design_f
(
obj_dp
,
&
mask_parent
,
LV_DESIGN_DRAW_POST
);
}
}
}
lv_obj/lv_vdb.h
View file @
d9b063d7
...
...
@@ -14,7 +14,7 @@
#if LV_VDB_SIZE != 0
#include "misc/others/color.h"
#include <lvgl/lv_misc/
2d
.h>
#include <lvgl/lv_misc/
area
.h>
#include "../lv_misc/font.h"
/*********************
...
...
lv_objx/lv_btn.c
View file @
d9b063d7
...
...
@@ -368,6 +368,7 @@ lv_btns_t * lv_btns_get(lv_btns_builtin_t style, lv_btns_t * copy_p)
* @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_btn_design
(
lv_obj_t
*
obj_dp
,
const
area_t
*
mask_p
,
lv_design_mode_t
mode
)
...
...
@@ -392,19 +393,18 @@ static bool lv_btn_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mod
if
(
area_is_in
(
mask_p
,
&
area_tmp
)
==
true
)
return
true
;
return
false
;
}
opa_t
opa
=
lv_obj_get_opa
(
obj_dp
);
area_t
area
;
lv_obj_get_cords
(
obj_dp
,
&
area
);
}
else
if
(
mode
==
LV_DESIGN_DRAW_MAIN
)
{
opa_t
opa
=
lv_obj_get_opa
(
obj_dp
);
area_t
area
;
lv_obj_get_cords
(
obj_dp
,
&
area
);
lv_rects_t
rects_tmp
;
lv_rects_t
rects_tmp
;
lv_btn_style_load
(
obj_dp
,
&
rects_tmp
);
lv_btn_style_load
(
obj_dp
,
&
rects_tmp
);
/*Draw the rectangle*/
lv_draw_rect
(
&
area
,
mask_p
,
&
rects_tmp
,
opa
);
/*Draw the rectangle*/
lv_draw_rect
(
&
area
,
mask_p
,
&
rects_tmp
,
opa
);
}
return
true
;
}
...
...
lv_objx/lv_btnm.c
View file @
d9b063d7
...
...
@@ -319,6 +319,7 @@ lv_btnm_callback_t lv_btnm_get_cb(lv_obj_t * obj_dp)
* @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_btnm_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode)
...
...
lv_objx/lv_cb.c
View file @
d9b063d7
...
...
@@ -263,6 +263,7 @@ lv_cbs_t * lv_cbs_get(lv_cbs_builtin_t style, lv_cbs_t * copy_p)
* @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_cb_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode)
...
...
lv_objx/lv_chart.c
View file @
d9b063d7
...
...
@@ -354,6 +354,7 @@ uint16_t lv_chart_get_pnum(lv_obj_t * obj_dp)
* @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_chart_design
(
lv_obj_t
*
obj_dp
,
const
area_t
*
mask_p
,
lv_design_mode_t
mode
)
...
...
@@ -361,31 +362,30 @@ static bool lv_chart_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_m
if
(
mode
==
LV_DESIGN_COVER_CHK
)
{
/*Return false if the object is not covers the mask_p area*/
return
ancestor_design_fp
(
obj_dp
,
mask_p
,
mode
);
}
else
if
(
mode
==
LV_DESIGN_DRAW_MAIN
)
{
/*Draw the rectangle ancient*/
ancestor_design_fp
(
obj_dp
,
mask_p
,
mode
);
/*Draw the object*/
lv_chart_ext_t
*
ext_dp
=
lv_obj_get_ext
(
obj_dp
);
lv_chart_draw_div
(
obj_dp
,
mask_p
);
switch
(
ext_dp
->
type
)
{
case
LV_CHART_LINE
:
lv_chart_draw_lines
(
obj_dp
,
mask_p
);
break
;
case
LV_CHART_COL
:
lv_chart_draw_cols
(
obj_dp
,
mask_p
);
break
;
case
LV_CHART_POINT
:
lv_chart_draw_points
(
obj_dp
,
mask_p
);
break
;
default:
break
;
}
}
/*Draw the rectangle ancient*/
ancestor_design_fp
(
obj_dp
,
mask_p
,
mode
);
/*Draw the object*/
lv_chart_ext_t
*
ext_dp
=
lv_obj_get_ext
(
obj_dp
);
lv_chart_draw_div
(
obj_dp
,
mask_p
);
switch
(
ext_dp
->
type
)
{
case
LV_CHART_LINE
:
lv_chart_draw_lines
(
obj_dp
,
mask_p
);
break
;
case
LV_CHART_COL
:
lv_chart_draw_cols
(
obj_dp
,
mask_p
);
break
;
case
LV_CHART_POINT
:
lv_chart_draw_points
(
obj_dp
,
mask_p
);
break
;
default:
break
;
}
return
true
;
}
...
...
lv_objx/lv_img.c
View file @
d9b063d7
...
...
@@ -256,6 +256,7 @@ bool lv_img_get_auto_size(lv_obj_t* obj_dp)
* @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_img_design
(
lv_obj_t
*
obj_dp
,
const
area_t
*
mask_p
,
lv_design_mode_t
mode
)
...
...
@@ -270,24 +271,25 @@ static bool lv_img_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mod
return
cover
;
}
else
return
false
;
}
else
if
(
mode
==
LV_DESIGN_DRAW_MAIN
)
{
area_t
cords
;
lv_obj_get_cords
(
obj_dp
,
&
cords
);
opa_t
opa
=
lv_obj_get_opa
(
obj_dp
);
area_t
cords_tmp
;
cords_tmp
.
y1
=
cords
.
y1
;
cords_tmp
.
y2
=
cords
.
y1
+
ext_p
->
h
-
1
;
for
(;
cords_tmp
.
y1
<
cords
.
y2
;
cords_tmp
.
y1
+=
ext_p
->
h
,
cords_tmp
.
y2
+=
ext_p
->
h
)
{
cords_tmp
.
x1
=
cords
.
x1
;
cords_tmp
.
x2
=
cords
.
x1
+
ext_p
->
w
-
1
;
for
(;
cords_tmp
.
x1
<
cords
.
x2
;
cords_tmp
.
x1
+=
ext_p
->
w
,
cords_tmp
.
x2
+=
ext_p
->
w
)
{
lv_draw_img
(
&
cords_tmp
,
mask_p
,
imgs_p
,
opa
,
ext_p
->
fn_dp
);
}
}
}
area_t
cords
;
lv_obj_get_cords
(
obj_dp
,
&
cords
);
opa_t
opa
=
lv_obj_get_opa
(
obj_dp
);
area_t
cords_tmp
;
cords_tmp
.
y1
=
cords
.
y1
;
cords_tmp
.
y2
=
cords
.
y1
+
ext_p
->
h
-
1
;
for
(;
cords_tmp
.
y1
<
cords
.
y2
;
cords_tmp
.
y1
+=
ext_p
->
h
,
cords_tmp
.
y2
+=
ext_p
->
h
)
{
cords_tmp
.
x1
=
cords
.
x1
;
cords_tmp
.
x2
=
cords
.
x1
+
ext_p
->
w
-
1
;
for
(;
cords_tmp
.
x1
<
cords
.
x2
;
cords_tmp
.
x1
+=
ext_p
->
w
,
cords_tmp
.
x2
+=
ext_p
->
w
)
{
lv_draw_img
(
&
cords_tmp
,
mask_p
,
imgs_p
,
opa
,
ext_p
->
fn_dp
);
}
}
return
true
;
}
...
...
lv_objx/lv_label.c
View file @
d9b063d7
...
...
@@ -71,10 +71,10 @@ static lv_labels_t lv_labels_txt = {
* @param copy_dp pointer to a button object, if not NULL then the new object will be copied from it
* @return pointer to the created button
*/
lv_obj_t
*
lv_label_create
(
lv_obj_t
*
par_dp
,
lv_obj_t
*
ori
_dp
)
lv_obj_t
*
lv_label_create
(
lv_obj_t
*
par_dp
,
lv_obj_t
*
copy
_dp
)
{
/*Create a basic object*/
lv_obj_t
*
new_obj
=
lv_obj_create
(
par_dp
,
ori
_dp
);
lv_obj_t
*
new_obj
=
lv_obj_create
(
par_dp
,
copy
_dp
);
dm_assert
(
new_obj
);
/*Extend the basic object to a label object*/
...
...
@@ -87,7 +87,7 @@ lv_obj_t* lv_label_create(lv_obj_t* par_dp, lv_obj_t * ori_dp)
lv_obj_set_signal_f
(
new_obj
,
lv_label_signal
);
/*Init the new label*/
if
(
ori
_dp
==
NULL
)
{
if
(
copy
_dp
==
NULL
)
{
lv_obj_set_opa
(
new_obj
,
OPA_COVER
);
lv_obj_set_click
(
new_obj
,
false
);
lv_obj_set_style
(
new_obj
,
&
lv_labels_def
);
...
...
@@ -96,8 +96,8 @@ lv_obj_t* lv_label_create(lv_obj_t* par_dp, lv_obj_t * ori_dp)
}
/*Copy 'ori_dp' if not NULL*/
else
{
lv_label_set_fixw
(
new_obj
,
lv_label_get_fixw
(
ori
_dp
));
lv_label_set_text
(
new_obj
,
lv_label_get_text
(
ori
_dp
));
lv_label_set_fixw
(
new_obj
,
lv_label_get_fixw
(
copy
_dp
));
lv_label_set_text
(
new_obj
,
lv_label_get_text
(
copy
_dp
));
}
return
new_obj
;
}
...
...
@@ -127,8 +127,9 @@ bool lv_label_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param)
label_p
->
txt_dp
=
NULL
;
break
;
case
LV_SIGNAL_STYLE_CHG
:
lv_label_set_text
(
obj_dp
,
lv_label_get_text
(
obj_dp
)
);
lv_label_set_text
(
obj_dp
,
NULL
);
break
;
default:
break
;
}
...
...
@@ -144,23 +145,30 @@ bool lv_label_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param)
/**
* Set a new text for a label
* @param obj_dp pointer to a label object
* @param text '\0' terminated character string
* @param text '\0' terminated character string
. If NULL then refresh with the current text.
*/
void
lv_label_set_text
(
lv_obj_t
*
obj_dp
,
const
char
*
text
)
{
if
(
text
==
NULL
)
return
;
lv_obj_inv
(
obj_dp
);
lv_label_ext_t
*
ext_p
=
lv_obj_get_ext
(
obj_dp
);
uint32_t
len
=
strlen
(
text
)
+
1
;
lv_label_ext_t
*
label_ext_dp
=
lv_obj_get_ext
(
obj_dp
);
if
(
ext_p
->
txt_dp
!=
NULL
&&
text
!=
ext_p
->
txt_dp
)
{
dm_free
(
ext_p
->
txt_dp
);
if
(
text
==
label_ext_dp
->
txt_dp
)
text
=
NULL
;
if
(
text
!=
NULL
)
{
uint32_t
len
=
strlen
(
text
)
+
1
;
if
(
label_ext_dp
->
txt_dp
!=
NULL
)
{
dm_free
(
label_ext_dp
->
txt_dp
);
}
label_ext_dp
->
txt_dp
=
dm_alloc
(
len
);
strcpy
(
label_ext_dp
->
txt_dp
,
text
);
}
else
{
text
=
label_ext_dp
->
txt_dp
;
}
ext_p
->
txt_dp
=
dm_alloc
(
len
);
strcpy
(
ext_p
->
txt_dp
,
text
)
;
/*If 'text" still NULL then nothing to do: return*/
if
(
text
==
NULL
)
return
;
uint32_t
line_start
=
0
;
uint32_t
new_line_start
=
0
;
...
...
@@ -173,7 +181,7 @@ void lv_label_set_text(lv_obj_t * obj_dp, const char * text)
cord_t
act_line_length
;
/*If the fix width is not enabled the set the max length to very big */
if
(
ext_
p
->
fixw
==
0
)
{
if
(
label_ext_d
p
->
fixw
==
0
)
{
max_length
=
LV_CORD_MAX
;
}
...
...
@@ -185,7 +193,7 @@ void lv_label_set_text(lv_obj_t * obj_dp, const char * text)
new_height
+=
labels_p
->
line_space
;
/*If no fix width then calc. the longest line */
if
(
ext_
p
->
fixw
==
false
)
{
if
(
label_ext_d
p
->
fixw
==
false
)
{
act_line_length
=
txt_get_width
(
&
text
[
line_start
],
new_line_start
-
line_start
,
font_p
,
labels_p
->
letter_space
);
if
(
act_line_length
>
longest_line
)
{
...
...
@@ -199,7 +207,7 @@ void lv_label_set_text(lv_obj_t * obj_dp, const char * text)
/*Correction with the last line space*/
new_height
-=
labels_p
->
line_space
;
if
(
ext_
p
->
fixw
==
0
)
{
if
(
label_ext_d
p
->
fixw
==
0
)
{
/*Refresh the full size */
lv_obj_set_size
(
obj_dp
,
longest_line
,
new_height
);
}
else
{
...
...
@@ -253,7 +261,7 @@ bool lv_label_get_fixw(lv_obj_t * obj_dp)
* Get the relative x and y coordinates of a letter
* @param obj_dp pointer to a label object
* @param index index of the letter (0 ... text length)
* @param pos_p store the result here
* @param pos_p store the result here
(E.g. index = 0 gives 0;0 coordinates)
*/
void
lv_label_get_letter_pos
(
lv_obj_t
*
obj_dp
,
uint16_t
index
,
point_t
*
pos_p
)
{
...
...
@@ -273,9 +281,9 @@ void lv_label_get_letter_pos(lv_obj_t * obj_dp, uint16_t index, point_t * pos_p)
}
/*Search the line of the index letter */
;
while
(
text
[
line_start
]
!=
'\0'
)
{
while
(
text
[
new_
line_start
]
!=
'\0'
)
{
new_line_start
+=
txt_get_next_line
(
&
text
[
line_start
],
font_p
,
labels_p
->
letter_space
,
max_length
);
if
(
index
<
new_line_start
)
break
;
/*Lines of index
letter begins at 'line_start'*/
if
(
index
<
new_line_start
||
text
[
new_line_start
]
==
'\0'
)
break
;
/*The line of 'index'
letter begins at 'line_start'*/
y
+=
letter_height
+
labels_p
->
line_space
;
line_start
=
new_line_start
;
...
...
@@ -300,6 +308,12 @@ void lv_label_get_letter_pos(lv_obj_t * obj_dp, uint16_t index, point_t * pos_p)
}
/**
* Get the index of letter on a relative point of a label
* @param obj_dp pointer to label object
* @param pos_p pointer to point with coordinates on a the label
* @return the index of the letter on the 'pos_p' point (E.g. on 0;0 is the 0. letter)
*/
uint16_t
lv_label_get_letter_on
(
lv_obj_t
*
obj_dp
,
point_t
*
pos_p
)
{
const
char
*
text
=
lv_label_get_text
(
obj_dp
);
...
...
@@ -337,7 +351,7 @@ uint16_t lv_label_get_letter_on(lv_obj_t * obj_dp, point_t * pos_p)
uint32_t
i
;
for
(
i
=
line_start
;
i
<
new_line_start
-
1
;
i
++
)
{
x
+=
font_get_width
(
font_p
,
text
[
i
])
+
labels_p
->
letter_space
;
if
(
pos_p
->
x
<
=
x
)
break
;
if
(
pos_p
->
x
<
x
)
break
;
}
...
...
@@ -392,23 +406,23 @@ lv_labels_t * lv_labels_get(lv_labels_builtin_t style, lv_labels_t * copy_p)
* @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_label_design
(
lv_obj_t
*
obj_dp
,
const
area_t
*
mask_p
,
lv_design_mode_t
mode
)
{
/* A label never covers an area */
if
(
mode
==
LV_DESIGN_COVER_CHK
)
return
false
;
/*TEST: draw a background for the label*/
/*lv_vfill(&obj_dp->cords, mask_p, COLOR_LIME, OPA_COVER); */
area_t
cords
;
lv_obj_get_cords
(
obj_dp
,
&
cords
);
opa_t
opa
=
lv_obj_get_opa
(
obj_dp
);
const
char
*
txt
=
lv_label_get_text
(
obj_dp
);
lv_draw_label
(
&
cords
,
mask_p
,
lv_obj_get_style
(
obj_dp
),
opa
,
txt
);
else
if
(
mode
==
LV_DESIGN_DRAW_MAIN
)
{
/*TEST: draw a background for the label*/
/*lv_vfill(&obj_dp->cords, mask_p, COLOR_LIME, OPA_COVER); */
area_t
cords
;
lv_obj_get_cords
(
obj_dp
,
&
cords
);
opa_t
opa
=
lv_obj_get_opa
(
obj_dp
);
const
char
*
txt
=
lv_label_get_text
(
obj_dp
);
lv_draw_label
(
&
cords
,
mask_p
,
lv_obj_get_style
(
obj_dp
),
opa
,
txt
);
}
return
true
;
}
...
...
lv_objx/lv_led.c
View file @
d9b063d7
...
...
@@ -235,6 +235,7 @@ uint8_t lv_led_get_bright(lv_obj_t * obj_dp)
* @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_led_design
(
lv_obj_t
*
obj_dp
,
const
area_t
*
mask_p
,
lv_design_mode_t
mode
)
...
...
@@ -242,26 +243,23 @@ static bool lv_led_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mod
if
(
mode
==
LV_DESIGN_COVER_CHK
)
{
/*Return false if the object is not covers the mask_p area*/
return
false
;
}
/*Draw the object*/
/*Make darker colors in a temporary style according to the brightness*/
lv_led_ext_t
*
led_ext_p
=
lv_obj_get_ext
(
obj_dp
);
lv_leds_t
*
leds_p
=
lv_obj_get_style
(
obj_dp
);
lv_leds_t
leds_tmp
;
}
else
if
(
mode
==
LV_DESIGN_DRAW_MAIN
)
{
/*Make darker colors in a temporary style according to the brightness*/
lv_led_ext_t
*
led_ext_p
=
lv_obj_get_ext
(
obj_dp
);
lv_leds_t
*
leds_p
=
lv_obj_get_style
(
obj_dp
);
lv_leds_t
leds_tmp
;
memcpy
(
&
leds_tmp
,
leds_p
,
sizeof
(
leds_tmp
));
memcpy
(
&
leds_tmp
,
leds_p
,
sizeof
(
leds_tmp
));
leds_tmp
.
rects
.
objs
.
color
=
color_mix
(
leds_tmp
.
rects
.
objs
.
color
,
COLOR_BLACK
,
led_ext_p
->
bright
);
leds_tmp
.
rects
.
gcolor
=
color_mix
(
leds_tmp
.
rects
.
gcolor
,
COLOR_BLACK
,
led_ext_p
->
bright
);
leds_tmp
.
rects
.
objs
.
color
=
color_mix
(
leds_tmp
.
rects
.
objs
.
color
,
COLOR_BLACK
,
led_ext_p
->
bright
);
leds_tmp
.
rects
.
gcolor
=
color_mix
(
leds_tmp
.
rects
.
gcolor
,
COLOR_BLACK
,
led_ext_p
->
bright
);
opa_t
opa
=
lv_obj_get_opa
(
obj_dp
);
area_t
area
;
lv_obj_get_cords
(
obj_dp
,
&
area
);
lv_draw_rect
(
&
area
,
mask_p
,
&
leds_tmp
.
rects
,
opa
);
opa_t
opa
=
lv_obj_get_opa
(
obj_dp
);
area_t
area
;
lv_obj_get_cords
(
obj_dp
,
&
area
);
lv_draw_rect
(
&
area
,
mask_p
,
&
leds_tmp
.
rects
,
opa
);
}
return
true
;
}
...
...
lv_objx/lv_line.c
View file @
d9b063d7
...
...
@@ -13,7 +13,7 @@
#include "../lv_draw/lv_draw_vbasic.h"
#include "../lv_draw/lv_draw_rbasic.h"
#include "../lv_draw/lv_draw.h"
#include <lvgl/lv_misc/
2d
.h>
#include <lvgl/lv_misc/
area
.h>
#include <misc/math/math_base.h>
#include <misc/mem/dyn_mem.h>
#include <misc/others/color.h>
...
...
@@ -283,49 +283,50 @@ lv_lines_t * lv_lines_get(lv_lines_builtin_t style, lv_lines_t * copy_p)
* @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_line_design
(
lv_obj_t
*
obj_dp
,
const
area_t
*
mask_p
,
lv_design_mode_t
mode
)
{
/*A line never covers an area*/
if
(
mode
==
LV_DESIGN_COVER_CHK
)
return
false
;
lv_line_ext_t
*
ext_p
=
lv_obj_get_ext
(
obj_dp
);
else
if
(
mode
==
LV_DESIGN_DRAW_MAIN
)
{
lv_line_ext_t
*
ext_p
=
lv_obj_get_ext
(
obj_dp
);
if
(
ext_p
->
point_num
==
0
||
ext_p
->
point_p
==
NULL
)
return
false
;
if
(
ext_p
->
point_num
==
0
||
ext_p
->
point_p
==
NULL
)
return
false
;
lv_lines_t
*
lines_p
=
lv_obj_get_style
(
obj_dp
);
lv_lines_t
*
lines_p
=
lv_obj_get_style
(
obj_dp
);
opa_t
opa
=
lv_obj_get_opa
(
obj_dp
);
area_t
area
;
lv_obj_get_cords
(
obj_dp
,
&
area
);
cord_t
x_ofs
=
area
.
x1
;
cord_t
y_ofs
=
area
.
y1
;
point_t
p1
;
point_t
p2
;
cord_t
h
=
lv_obj_get_height
(
obj_dp
);
uint16_t
i
;
uint8_t
us
=
1
;
if
(
ext_p
->
upscale
!=
0
)
{
us
=
LV_DOWNSCALE
;
}
opa_t
opa
=
lv_obj_get_opa
(
obj_dp
);
area_t
area
;
lv_obj_get_cords
(
obj_dp
,
&
area
);
cord_t
x_ofs
=
area
.
x1
;
cord_t
y_ofs
=
area
.
y1
;
point_t
p1
;
point_t
p2
;
cord_t
h
=
lv_obj_get_height
(
obj_dp
);
uint16_t
i
;
uint8_t
us
=
1
;
if
(
ext_p
->
upscale
!=
0
)
{
us
=
LV_DOWNSCALE
;
}
/*Read all pints and draw the lines*/
for
(
i
=
0
;
i
<
ext_p
->
point_num
-
1
;
i
++
)
{
/*Read all pints and draw the lines*/
for
(
i
=
0
;
i
<
ext_p
->
point_num
-
1
;
i
++
)
{
p1
.
x
=
ext_p
->
point_p
[
i
].
x
*
us
+
x_ofs
;
p2
.
x
=
ext_p
->
point_p
[
i
+
1
].
x
*
us
+
x_ofs
;
p1
.
x
=
ext_p
->
point_p
[
i
].
x
*
us
+
x_ofs
;
p2
.
x
=
ext_p
->
point_p
[
i
+
1
].
x
*
us
+
x_ofs
;
if
(
ext_p
->
y_inv
==
0
)
{
p1
.
y
=
ext_p
->
point_p
[
i
].
y
*
us
+
y_ofs
;
p2
.
y
=
ext_p
->
point_p
[
i
+
1
].
y
*
us
+
y_ofs
;
}
else
{
p1
.
y
=
h
-
ext_p
->
point_p
[
i
].
y
*
us
+
y_ofs
;
p2
.
y
=
h
-
ext_p
->
point_p
[
i
+
1
].
y
*
us
+
y_ofs
;
if
(
ext_p
->
y_inv
==
0
)
{
p1
.
y
=
ext_p
->
point_p
[
i
].
y
*
us
+
y_ofs
;
p2
.
y
=
ext_p
->
point_p
[
i
+
1
].
y
*
us
+
y_ofs
;
}
else
{
p1
.
y
=
h
-
ext_p
->
point_p
[
i
].
y
*
us
+
y_ofs
;
p2
.
y
=
h
-
ext_p
->
point_p
[
i
+
1
].
y
*
us
+
y_ofs
;
}
lv_draw_line
(
&
p1
,
&
p2
,
mask_p
,
lines_p
,
opa
);
}
lv_draw_line
(
&
p1
,
&
p2
,
mask_p
,
lines_p
,
opa
);
}
}
return
true
;
}
...
...
lv_objx/lv_list.c
View file @
d9b063d7
...
...
@@ -35,13 +35,72 @@ static bool lv_list_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo
static
lv_lists_t
lv_lists_def
=
{
/*Page style*/
.
pages
.
bg_rects
.
objs
.
color
=
COLOR_MAKE
(
0x20
,
0x50
,
0x80
),
.
pages
.
bg_rects
.
gcolor
=
COLOR_SILVER
,
.
pages
.
bg_rects
.
bcolor
=
COLOR_GRAY
,
.
pages
.
bg_rects
.
bopa
=
50
,
.
pages
.
bg_rects
.
bwidth
=
0
*
LV_STYLE_MULT
,
.
pages
.
bg_rects
.
round
=
2
*
LV_STYLE_MULT
,
.
pages
.
bg_rects
.
empty
=
1
,
.
pages
.
bg_rects
.
objs
.
color
=
COLOR_MAKE
(
0x50
,
0x70
,
0x90
),
.
pages
.
bg_rects
.
gcolor
=
COLOR_MAKE
(
0x70
,
0xA0
,
0xC0
),
.
pages
.
bg_rects
.
bcolor
=
COLOR_WHITE
,
.
pages
.
bg_rects
.
bopa
=
50
,
.
pages
.
bg_rects
.
bwidth
=
2
*
LV_STYLE_MULT
,
.
pages
.
bg_rects
.
round
=
4
*
LV_STYLE_MULT
,
.
pages
.
bg_rects
.
empty
=
0
,
.
pages
.
bg_rects
.
vpad
=
10
*
LV_STYLE_MULT
,
.
pages
.
bg_rects
.
hpad
=
10
*
LV_STYLE_MULT
,
.
pages
.
bg_rects
.
opad
=
5
*
LV_STYLE_MULT
,
.
pages
.
scrable_rects
.
objs
.
color
=
COLOR_WHITE
,
.
pages
.
scrable_rects
.
gcolor
=
COLOR_SILVER
,
.
pages
.
scrable_rects
.
bcolor
=
COLOR_GRAY
,
.
pages
.
scrable_rects
.
bopa
=
100
,
.
pages
.
scrable_rects
.
bwidth
=
2
*
LV_STYLE_MULT
,
.
pages
.
scrable_rects
.
round
=
4
*
LV_STYLE_MULT
,
.
pages
.
scrable_rects
.
empty
=
0
,
.
pages
.
scrable_rects
.
hpad
=
10
*
LV_STYLE_MULT
,
.
pages
.
scrable_rects
.
vpad
=
10
*
LV_STYLE_MULT
,
.
pages
.
scrable_rects
.
opad
=
10
*
LV_STYLE_MULT
,
.
pages
.
sb_rects
.
objs
.
color
=
COLOR_BLACK
,
.
pages
.
sb_rects
.
gcolor
=
COLOR_BLACK
,
.
pages
.
sb_rects
.
bcolor
=
COLOR_WHITE
,
.
pages
.
sb_rects
.
bopa
=
50
,
.
pages
.
sb_rects
.
bwidth
=
1
*
LV_STYLE_MULT
,
.
pages
.
sb_rects
.
round
=
5
*
LV_STYLE_MULT
,
.
pages
.
sb_rects
.
empty
=
0
,
.
pages
.
sb_width
=
8
*
LV_STYLE_MULT
,
.
pages
.
sb_opa
=
50
,
.
pages
.
sb_mode
=
LV_PAGE_SB_MODE_AUTO
,
/*List element style*/
.
liste_btns
.
mcolor
[
LV_BTN_STATE_REL
]
=
COLOR_MAKE
(
0xa0
,
0xa0
,
0xa0
),
.
liste_btns
.
gcolor
[
LV_BTN_STATE_REL
]
=
COLOR_WHITE
,
.
liste_btns
.
bcolor
[
LV_BTN_STATE_REL
]
=
COLOR_WHITE
,
.
liste_btns
.
mcolor
[
LV_BTN_STATE_PR
]
=
COLOR_MAKE
(
0xa0
,
0xa0
,
0xa0
),
.
liste_btns
.
gcolor
[
LV_BTN_STATE_PR
]
=
COLOR_MAKE
(
0xa0
,
0xc0
,
0xe0
),
.
liste_btns
.
bcolor
[
LV_BTN_STATE_PR
]
=
COLOR_WHITE
,
.
liste_btns
.
mcolor
[
LV_BTN_STATE_TGL_REL
]
=
COLOR_MAKE
(
0x60
,
0x80
,
0xa0
),
.
liste_btns
.
gcolor
[
LV_BTN_STATE_TGL_REL
]
=
COLOR_MAKE
(
0xc0
,
0xd0
,
0xf0
),
.
liste_btns
.
bcolor
[
LV_BTN_STATE_TGL_REL
]
=
COLOR_WHITE
,
.
liste_btns
.
mcolor
[
LV_BTN_STATE_TGL_PR
]
=
COLOR_MAKE
(
0x60
,
0x80
,
0xa0
),
.
liste_btns
.
gcolor
[
LV_BTN_STATE_TGL_PR
]
=
COLOR_MAKE
(
0x80
,
0xa0
,
0xc0
),
.
liste_btns
.
bcolor
[
LV_BTN_STATE_TGL_PR
]
=
COLOR_WHITE
,
.
liste_btns
.
mcolor
[
LV_BTN_STATE_INA
]
=
COLOR_SILVER
,
.
liste_btns
.
gcolor
[
LV_BTN_STATE_INA
]
=
COLOR_GRAY
,
.
liste_btns
.
bcolor
[
LV_BTN_STATE_INA
]
=
COLOR_WHITE
,
.
liste_btns
.
rects
.
bwidth
=
2
*
LV_STYLE_MULT
,
.
liste_btns
.
rects
.
bopa
=
50
,
.
liste_btns
.
rects
.
empty
=
0
,
.
liste_btns
.
rects
.
round
=
4
*
LV_STYLE_MULT
,
.
liste_btns
.
rects
.
hpad
=
10
*
LV_STYLE_MULT
,
.
liste_btns
.
rects
.
vpad
=
10
*
LV_STYLE_MULT
,
.
liste_btns
.
rects
.
opad
=
20
*
LV_STYLE_MULT
,
.
liste_labels
.
objs
.
color
=
COLOR_MAKE
(
0x20
,
0x20
,
0x20
),
.
liste_labels
.
font
=
LV_FONT_DEFAULT
,
.
liste_labels
.
letter_space
=
2
*
LV_STYLE_MULT
,
.
liste_labels
.
line_space
=
2
*
LV_STYLE_MULT
,
.
liste_labels
.
mid
=
0
,
.
liste_imgs
.
recolor_opa
=
OPA_COVER
,
.
liste_layout
=
LV_RECT_LAYOUT_ROW_M
};
static
lv_lists_t
lv_lists_tight
=
{
/*Page style*/
.
pages
.
bg_rects
.
objs
.
color
=
COLOR_MAKE
(
0x50
,
0x70
,
0x90
),
.
pages
.
bg_rects
.
gcolor
=
COLOR_MAKE
(
0x70
,
0xA0
,
0xC0
),
.
pages
.
bg_rects
.
bcolor
=
COLOR_WHITE
,
.
pages
.
bg_rects
.
bopa
=
50
,
.
pages
.
bg_rects
.
bwidth
=
0
*
LV_STYLE_MULT
,
.
pages
.
bg_rects
.
round
=
4
*
LV_STYLE_MULT
,
.
pages
.
bg_rects
.
empty
=
1
,
.
pages
.
bg_rects
.
vpad
=
0
*
LV_STYLE_MULT
,
.
pages
.
bg_rects
.
hpad
=
0
*
LV_STYLE_MULT
,
.
pages
.
bg_rects
.
opad
=
0
*
LV_STYLE_MULT
,
.
pages
.
scrable_rects
.
objs
.
color
=
COLOR_WHITE
,
.
pages
.
scrable_rects
.
gcolor
=
COLOR_SILVER
,
.
pages
.
scrable_rects
.
bcolor
=
COLOR_GRAY
,
.
pages
.
scrable_rects
.
bopa
=
100
,
.
pages
.
scrable_rects
.
bwidth
=
0
*
LV_STYLE_MULT
,
.
pages
.
scrable_rects
.
round
=
0
*
LV_STYLE_MULT
,
.
pages
.
scrable_rects
.
empty
=
0
,
.
pages
.
scrable_rects
.
hpad
=
0
*
LV_STYLE_MULT
,
.
pages
.
scrable_rects
.
vpad
=
0
*
LV_STYLE_MULT
,
.
pages
.
scrable_rects
.
opad
=
0
*
LV_STYLE_MULT
,
.
pages
.
sb_rects
.
objs
.
color
=
COLOR_BLACK
,
.
pages
.
sb_rects
.
gcolor
=
COLOR_BLACK
,
.
pages
.
sb_rects
.
bcolor
=
COLOR_WHITE
,
.
pages
.
sb_rects
.
bopa
=
50
,
.
pages
.
sb_rects
.
bwidth
=
1
*
LV_STYLE_MULT
,
.
pages
.
sb_rects
.
round
=
5
*
LV_STYLE_MULT
,
.
pages
.
sb_rects
.
empty
=
0
,
.
pages
.
sb_width
=
8
*
LV_STYLE_MULT
,
.
pages
.
sb_opa
=
50
,
.
pages
.
sb_mode
=
LV_PAGE_SB_MODE_AUTO
,
...
...
@@ -91,13 +150,18 @@ lv_obj_t* lv_list_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
lv_obj_t
*
new_obj_dp
=
lv_page_create
(
par_dp
,
copy_dp
);
dm_assert
(
new_obj_dp
);
lv_list_ext_t
*
ext_p
=
lv_obj_alloc_ext
(
new_obj_dp
,
sizeof
(
lv_list_ext_t
));
lv_obj_set_signal_f
(
new_obj_dp
,
lv_list_signal
);
/*Init the new list object*/
if
(
copy_dp
==
NULL
)
{
ext_p
->
fit
=
LV_LIST_FIT_LONGEST
;
lv_obj_set_si
gnal_f
(
new_obj_dp
,
lv_list_signal
);
lv_obj_set_si
ze_us
(
new_obj_dp
,
100
,
150
);
lv_obj_set_style
(
new_obj_dp
,
&
lv_lists_def
);
lv_rect_set_layout
(
new_obj_dp
,
LV_LIST_LAYOUT_DEF
);
lv_rect_set_layout
(
LV_EA
(
new_obj_dp
,
lv_list_ext_t
)
->
page_ext
.
scrolling_dp
,
LV_LIST_LAYOUT_DEF
);
}
else
{
lv_list_ext_t
*
copy_ext_dp
=
lv_obj_get_ext
(
copy_dp
);
ext_p
->
fit
=
copy_ext_dp
->
fit
;
}
return
new_obj_dp
;
...
...
@@ -147,7 +211,7 @@ lv_obj_t * lv_list_add(lv_obj_t * obj_dp, const char * img_fn, const char * txt,
lv_obj_set_style
(
liste
,
&
lists_p
->
liste_btns
);
lv_btn_set_rel_action
(
liste
,
rel_action
);
lv_page_glue_obj
(
liste
,
true
);
lv_rect_set_layout
(
liste
,
l
v_lists_def
.
liste_layout
);
lv_rect_set_layout
(
liste
,
l
ists_p
->
liste_layout
);
lv_rect_set_fit
(
liste
,
true
,
true
);
/*hor. fit might be disabled later*/
if
(
img_fn
!=
NULL
)
{
...
...
@@ -168,7 +232,7 @@ lv_obj_t * lv_list_add(lv_obj_t * obj_dp, const char * img_fn, const char * txt,
if
(
ext_p
->
fit
==
LV_LIST_FIT_HOLDER
)
{
/*Now the width will be adjusted*/
lv_rect_set_fit
(
liste
,
false
,
true
);
cord_t
w
=
lv_obj_get_width
(
lv_obj_get_parent
(
obj_dp
)
);
cord_t
w
=
lv_obj_get_width
(
obj_dp
);
w
-=
lists_p
->
pages
.
bg_rects
.
hpad
*
2
;
lv_obj_set_width
(
liste
,
w
);
}
else
if
(
ext_p
->
fit
==
LV_LIST_FIT_LONGEST
)
{
...
...
@@ -178,19 +242,20 @@ lv_obj_t * lv_list_add(lv_obj_t * obj_dp, const char * img_fn, const char * txt,
lv_obj_t
*
e
;
cord_t
w
=
0
;
/*Get the longest list element*/
e
=
lv_obj_get_child
(
obj_dp
,
NULL
);
lv_obj_t
*
e_par
=
lv_obj_get_parent
(
liste
);
/*The page changes the parent so get it*/
e
=
lv_obj_get_child
(
e_par
,
NULL
);
while
(
e
!=
NULL
)
{
w
=
max
(
w
,
lv_obj_get_width
(
e
));
e
=
lv_obj_get_child
(
obj_dp
,
e
);
e
=
lv_obj_get_child
(
e_par
,
e
);
}
/*Set all list element to the longest width*/
e
=
lv_obj_get_child
(
obj_dp
,
NULL
);
e
=
lv_obj_get_child
(
e_par
,
NULL
);
while
(
e
!=
NULL
)
{
if
(
lv_obj_get_width
(
e
)
!=
w
)
{
lv_obj_set_width
(
e
,
w
);
}
e
=
lv_obj_get_child
(
obj_dp
,
e
);
e
=
lv_obj_get_child
(
e_par
,
e
);
}
}
...
...
@@ -198,32 +263,6 @@ lv_obj_t * lv_list_add(lv_obj_t * obj_dp, const char * img_fn, const char * txt,
}
/**
* Return with a pointer to a built-in style and/or copy it to a variable
* @param style a style name from lv_lists_builtin_t enum
* @param copy_p copy the style to this variable. (NULL if unused)
* @return pointer to an lv_lists_t style
*/
lv_lists_t
*
lv_lists_get
(
lv_lists_builtin_t
style
,
lv_lists_t
*
copy_p
)
{
lv_lists_t
*
style_p
;
switch
(
style
)
{
case
LV_LISTS_DEF
:
style_p
=
&
lv_lists_def
;
break
;
default:
style_p
=
&
lv_lists_def
;
}
if
(
copy_p
!=
NULL
)
{
if
(
style_p
!=
NULL
)
memcpy
(
copy_p
,
style_p
,
sizeof
(
lv_lists_t
));
else
memcpy
(
copy_p
,
&
lv_lists_def
,
sizeof
(
lv_lists_t
));
}
return
style_p
;
}
/**
* Move the list elements up by one
* @param obj_dp pointer a to list object
*/
...
...
@@ -298,6 +337,38 @@ lv_list_fit_t lv_list_get_fit(lv_obj_t * obj_dp)
return
LV_EA
(
obj_dp
,
lv_list_ext_t
)
->
fit
;
}
/**
* Return with a pointer to a built-in style and/or copy it to a variable
* @param style a style name from lv_lists_builtin_t enum
* @param copy_p copy the style to this variable. (NULL if unused)
* @return pointer to an lv_lists_t style
*/
lv_lists_t
*
lv_lists_get
(
lv_lists_builtin_t
style
,
lv_lists_t
*
copy_p
)
{
lv_lists_t
*
style_p
;
switch
(
style
)
{
case
LV_LISTS_DEF
:
case
LV_LISTS_GAP
:
style_p
=
&
lv_lists_def
;
break
;
case
LV_LISTS_TIGHT
:
style_p
=
&
lv_lists_tight
;
break
;
default:
style_p
=
&
lv_lists_def
;
}
if
(
copy_p
!=
NULL
)
{
if
(
style_p
!=
NULL
)
memcpy
(
copy_p
,
style_p
,
sizeof
(
lv_lists_t
));
else
memcpy
(
copy_p
,
&
lv_lists_def
,
sizeof
(
lv_lists_t
));
}
return
style_p
;
}
/**********************
* STATIC FUNCTIONS
**********************/
...
...
@@ -310,6 +381,7 @@ lv_list_fit_t lv_list_get_fit(lv_obj_t * obj_dp)
* @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_list_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode)
...
...
lv_objx/lv_list.h
View file @
d9b063d7
...
...
@@ -40,6 +40,8 @@ typedef struct
typedef
enum
{
LV_LISTS_DEF
,
LV_LISTS_GAP
,
LV_LISTS_TIGHT
,
}
lv_lists_builtin_t
;
typedef
enum
...
...
lv_objx/lv_objx_templ.c
View file @
d9b063d7
...
...
@@ -156,6 +156,7 @@ lv_templs_t * lv_templs_get(lv_templs_builtin_t style, lv_templs_t * copy_p)
* @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_templ_design
(
lv_obj_t
*
obj_dp
,
const
area_t
*
mask_p
,
lv_design_mode_t
mode
)
...
...
lv_objx/lv_page.c
View file @
d9b063d7
This diff is collapsed.
Click to expand it.
lv_objx/lv_page.h
View file @
d9b063d7
...
...
@@ -31,7 +31,9 @@ typedef enum
typedef
struct
{
lv_rects_t
bg_rects
;
lv_rects_t
bg_rects
;
/*Style of ancestor*/
/*New style element for this type */
lv_rects_t
scrable_rects
;
lv_rects_t
sb_rects
;
cord_t
sb_width
;
lv_page_sb_mode_t
sb_mode
;
...
...
@@ -41,15 +43,18 @@ typedef struct
typedef
struct
{
lv_rect_ext_t
rect_ext
;
lv_obj_t
*
sbh_dp
;
/*Horizontal scrollbar*/
lv_obj_t
*
sbv_dp
;
/*Vertical scrollbar*/
lv_rect_ext_t
rect_ext
;
/*Ext. of ancestor*/
/*New data for this type */
lv_obj_t
*
scrolling_dp
;
/*The scrollable object on the background*/
area_t
sbh
;
/*Horizontal scrollbar*/
area_t
sbv
;
/*Vertical scrollbar*/
uint8_t
sbh_draw
:
1
;
/*1: horizontal scrollbar is visible now*/
uint8_t
sbv_draw
:
1
;
/*1: vertical scrollbar is visible now*/
}
lv_page_ext_t
;
typedef
enum
{
LV_PAGES_DEF
,
LV_PAGES_PAPER
,
LV_PAGES_TRANSP
,
}
lv_pages_builtin_t
;
...
...
lv_objx/lv_pb.c
View file @
d9b063d7
...
...
@@ -252,6 +252,7 @@ lv_pbs_t * lv_pbs_get(lv_pbs_builtin_t style, lv_pbs_t * copy_p)
* @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_pb_design
(
lv_obj_t
*
obj_dp
,
const
area_t
*
mask_p
,
lv_design_mode_t
mode
)
...
...
@@ -261,23 +262,20 @@ static bool lv_pb_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode
if
(
mode
==
LV_DESIGN_COVER_CHK
)
{
/*Return false if the object is not covers the mask_p area*/
return
ancestor_design_fp
(
obj_dp
,
mask_p
,
mode
);
}
else
if
(
mode
==
LV_DESIGN_DRAW_MAIN
)
{
ancestor_design_fp
(
obj_dp
,
mask_p
,
mode
);
lv_pb_ext_t
*
ext_dp
=
lv_obj_get_ext
(
obj_dp
);
area_t
bar_area
;
uint32_t
tmp
;
area_cpy
(
&
bar_area
,
&
obj_dp
->
cords
);
tmp
=
(
uint32_t
)
ext_dp
->
act_value
*
lv_obj_get_width
(
obj_dp
);
tmp
=
(
uint32_t
)
tmp
/
(
ext_dp
->
max_value
-
ext_dp
->
min_value
);
bar_area
.
x2
=
bar_area
.
x1
+
(
cord_t
)
tmp
;
lv_pbs_t
*
style_p
=
lv_obj_get_style
(
obj_dp
);
lv_draw_rect
(
&
bar_area
,
mask_p
,
&
style_p
->
bar
,
OPA_COVER
);
}
/*Draw the object*/
ancestor_design_fp
(
obj_dp
,
mask_p
,
mode
);
lv_pb_ext_t
*
ext_dp
=
lv_obj_get_ext
(
obj_dp
);
area_t
bar_area
;
uint32_t
tmp
;
area_cpy
(
&
bar_area
,
&
obj_dp
->
cords
);
tmp
=
(
uint32_t
)
ext_dp
->
act_value
*
lv_obj_get_width
(
obj_dp
);
tmp
=
(
uint32_t
)
tmp
/
(
ext_dp
->
max_value
-
ext_dp
->
min_value
);
bar_area
.
x2
=
bar_area
.
x1
+
(
cord_t
)
tmp
;
lv_pbs_t
*
style_p
=
lv_obj_get_style
(
obj_dp
);
lv_draw_rect
(
&
bar_area
,
mask_p
,
&
style_p
->
bar
,
OPA_COVER
);
return
true
;
}
...
...
lv_objx/lv_rect.c
View file @
d9b063d7
...
...
@@ -7,7 +7,7 @@
* INCLUDES
*********************/
#include <lvgl/lv_misc/
2d
.h>
#include <lvgl/lv_misc/
area
.h>
#include <misc/mem/dyn_mem.h>
#include <misc/mem/linked_list.h>
#include <misc/others/color.h>
...
...
@@ -173,8 +173,7 @@ void lv_rect_set_fit(lv_obj_t * obj_dp, bool hor_en, bool ver_en)
ext_p
->
vfit_en
=
ver_en
==
false
?
0
:
1
;
/*Send a signal to run the paddig calculations*/
lv_obj_t
*
par_dp
=
lv_obj_get_parent
(
obj_dp
);
par_dp
->
signal_f
(
par_dp
,
LV_SIGNAL_CHILD_CHG
,
obj_dp
);
obj_dp
->
signal_f
(
obj_dp
,
LV_SIGNAL_CORD_CHG
,
obj_dp
);
}
/*=====================
...
...
@@ -248,12 +247,13 @@ lv_rects_t * lv_rects_get(lv_rects_builtin_t style, lv_rects_t * copy_p)
**********************/
/**
* Handle the drawing related tasks of the
label
s
* Handle the drawing related tasks of the
rectangle
s
* @param obj_dp 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_rect_design
(
lv_obj_t
*
obj_dp
,
const
area_t
*
mask_p
,
lv_design_mode_t
mode
)
...
...
@@ -278,15 +278,14 @@ static bool lv_rect_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo
if
(
area_is_in
(
mask_p
,
&
area_tmp
)
==
true
)
return
true
;
return
false
;
}
opa_t
opa
=
lv_obj_get_opa
(
obj_dp
);
area_t
area
;
lv_obj_get_cords
(
obj_dp
,
&
area
);
}
else
if
(
mode
==
LV_DESIGN_DRAW_MAIN
)
{
opa_t
opa
=
lv_obj_get_opa
(
obj_dp
);
area_t
area
;
lv_obj_get_cords
(
obj_dp
,
&
area
);
/*Draw the rectangle*/
lv_draw_rect
(
&
area
,
mask_p
,
lv_obj_get_style
(
obj_dp
),
opa
);
/*Draw the rectangle*/
lv_draw_rect
(
&
area
,
mask_p
,
lv_obj_get_style
(
obj_dp
),
opa
);
}
return
true
;
}
...
...
lv_objx/lv_ta.c
View file @
d9b063d7
This diff is collapsed.
Click to expand it.
lv_objx/lv_ta.h
View file @
d9b063d7
...
...
@@ -30,6 +30,8 @@ typedef struct
lv_pages_t
pages
;
/*Style of ancestor*/
/*New style element for this type */
lv_labels_t
labels
;
color_t
cursor_color
;
cord_t
cursor_width
;
uint8_t
cursor_show
:
1
;
}
lv_tas_t
;
...
...
@@ -45,6 +47,7 @@ typedef struct
lv_page_ext_t
page
;
/*Ext. of ancestor*/
/*New data for this type */
lv_obj_t
*
label_dp
;
cord_t
cursor_valid_x
;
uint16_t
cursor_pos
;
}
lv_ta_ext_t
;
...
...
@@ -59,6 +62,8 @@ void lv_ta_add_char(lv_obj_t * obj_dp, char c);
void
lv_ta_add_text
(
lv_obj_t
*
obj_dp
,
const
char
*
txt
);
void
lv_ta_del
(
lv_obj_t
*
obj_dp
);
void
lv_ta_set_cursor_pos
(
lv_obj_t
*
obj_dp
,
uint16_t
pos
);
void
lv_ta_cursor_right
(
lv_obj_t
*
obj_dp
);
void
lv_ta_cursor_left
(
lv_obj_t
*
obj_dp
);
void
lv_ta_cursor_down
(
lv_obj_t
*
obj_dp
);
void
lv_ta_cursor_up
(
lv_obj_t
*
obj_dp
);
...
...
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