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
4924e871
Commit
4924e871
authored
Aug 11, 2017
by
Gabor
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'beta' into examples
parents
e6b6c3a1
4ab5d945
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
195 additions
and
20 deletions
+195
-20
animations.c
lv_examples/1_5_animations/animations.c
+28
-0
lv_obj.c
lv_obj/lv_obj.c
+1
-3
lv_style.c
lv_obj/lv_style.c
+91
-0
lv_style.h
lv_obj/lv_style.h
+41
-0
lv_label.c
lv_objx/lv_label.c
+0
-8
lv_slider.c
lv_objx/lv_slider.c
+33
-9
lv_ta.c
lv_objx/lv_ta.c
+1
-0
No files found.
lv_examples/1_5_animations/animations.c
View file @
4924e871
/*
*
static lv_style_t s1;
lv_style_get(LV_STYLE_BTN_REL, &s1);
static lv_style_t s2;
lv_style_get(LV_STYLE_BTN_REL, &s2);
s2.radius = 30;
s2.mcolor = COLOR_RED;
s2.bwidth = 8;
s2.opa = 50;
s2.hpad = 80;
//s2.font = font_get(FONT_DEJAVU_60);
lv_style_anim_t a;
a.act_time = -1000;
a.time = 1000;
a.playback = 1;
a.playback_pause = 300;
a.repeat = 1;
a.repeat_pause = 300;
a.end_cb = NULL;
a.style_anim = lv_style_get(LV_STYLE_BTN_REL, NULL);
a.style_start = &s1;
a.style_end = &s2;
lv_style_anim_create(&a);
*/
lv_obj/lv_obj.c
View file @
4924e871
...
...
@@ -1508,9 +1508,7 @@ static void lv_style_refr_core(void * style_p, lv_obj_t * obj)
lv_obj_t
*
i
;
LL_READ
(
obj
->
child_ll
,
i
)
{
if
(
i
->
style_p
==
style_p
||
style_p
==
NULL
)
{
lv_obj_inv
(
i
);
i
->
signal_f
(
i
,
LV_SIGNAL_STYLE_CHG
,
NULL
);
lv_obj_inv
(
i
);
lv_child_refr_style
(
i
);
}
lv_style_refr_core
(
style_p
,
i
);
...
...
lv_obj/lv_style.c
View file @
4924e871
...
...
@@ -8,18 +8,31 @@
*********************/
#include "lv_conf.h"
#include "lv_style.h"
#include "lv_obj.h"
#include "misc/mem/dyn_mem.h"
/*********************
* DEFINES
*********************/
#define LV_STYLE_ANIM_RES 255
/*Animation max in 1024 steps*/
#define LV_STYLE_ANIM_SHIFT 8
/*log2(LV_STYLE_ANIM_RES)*/
#define VAL_PROP(v1, v2, r) v1 + (((v2-v1) * r) >> LV_STYLE_ANIM_SHIFT)
#define STYLE_ATTR_ANIM(attr, r) if(start->attr != end->attr) act->attr = VAL_PROP(start->attr, end->attr, r)
/**********************
* TYPEDEFS
**********************/
typedef
struct
{
const
lv_style_t
*
style_start
;
const
lv_style_t
*
style_end
;
lv_style_t
*
style_anim
;
}
lv_style_anim_dsc_t
;
/**********************
* STATIC PROTOTYPES
**********************/
static
void
lv_style_aimator
(
lv_style_anim_dsc_t
*
dsc
,
int32_t
val
);
/**********************
* STATIC VARIABLES
...
...
@@ -229,6 +242,84 @@ void lv_style_cpy(lv_style_t * dest, const lv_style_t * src)
memcpy
(
dest
,
src
,
sizeof
(
lv_style_t
));
}
/**
* Create an animation from a pre-configured 'lv_style_anim_t' variable
* @param anim pointer to a pre-configured 'lv_style_anim_t' variable (will be copied)
*/
void
lv_style_anim_create
(
lv_style_anim_t
*
anim
)
{
lv_style_anim_dsc_t
*
dsc
;
dsc
=
dm_alloc
(
sizeof
(
lv_style_anim_dsc_t
));
dsc
->
style_anim
=
anim
->
style_anim
;
dsc
->
style_start
=
anim
->
style_start
;
dsc
->
style_end
=
anim
->
style_end
;
anim_t
a
;
a
.
var
=
(
void
*
)
dsc
;
a
.
start
=
0
;
a
.
end
=
LV_STYLE_ANIM_RES
;
a
.
fp
=
(
anim_fp_t
)
lv_style_aimator
;
a
.
path
=
anim_get_path
(
ANIM_PATH_LIN
);
a
.
end_cb
=
anim
->
end_cb
;
a
.
act_time
=
anim
->
act_time
;
a
.
time
=
anim
->
time
;
a
.
playback
=
anim
->
playback
;
a
.
playback_pause
=
anim
->
playback_pause
;
a
.
repeat
=
anim
->
repeat
;
a
.
repeat_pause
=
anim
->
repeat_pause
;
anim_create
(
&
a
);
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Used by the style animations to set the values of a style according to start and end style.
* @param dsc the 'animated variable' set by lv_style_anim_create()
* @param val the current state of the animation between 0 and LV_STYLE_ANIM_RES
*/
static
void
lv_style_aimator
(
lv_style_anim_dsc_t
*
dsc
,
int32_t
val
)
{
const
lv_style_t
*
start
=
dsc
->
style_start
;
const
lv_style_t
*
end
=
dsc
->
style_end
;
lv_style_t
*
act
=
dsc
->
style_anim
;
STYLE_ATTR_ANIM
(
opa
,
val
);
STYLE_ATTR_ANIM
(
radius
,
val
);
STYLE_ATTR_ANIM
(
bwidth
,
val
);
STYLE_ATTR_ANIM
(
swidth
,
val
);
STYLE_ATTR_ANIM
(
hpad
,
val
);
STYLE_ATTR_ANIM
(
vpad
,
val
);
STYLE_ATTR_ANIM
(
opad
,
val
);
STYLE_ATTR_ANIM
(
line_space
,
val
);
STYLE_ATTR_ANIM
(
letter_space
,
val
);
STYLE_ATTR_ANIM
(
line_width
,
val
);
STYLE_ATTR_ANIM
(
img_recolor
,
val
);
act
->
mcolor
=
color_mix
(
end
->
mcolor
,
start
->
mcolor
,
val
);
act
->
gcolor
=
color_mix
(
end
->
gcolor
,
start
->
gcolor
,
val
);
act
->
bcolor
=
color_mix
(
end
->
bcolor
,
start
->
bcolor
,
val
);
act
->
scolor
=
color_mix
(
end
->
scolor
,
start
->
scolor
,
val
);
act
->
ccolor
=
color_mix
(
end
->
ccolor
,
start
->
ccolor
,
val
);
if
(
val
==
0
)
{
act
->
empty
=
start
->
empty
;
act
->
glass
=
start
->
glass
;
act
->
font
=
start
->
font
;
act
->
stype
=
start
->
stype
;
act
->
txt_align
=
start
->
txt_align
;
}
if
(
val
==
LV_STYLE_ANIM_RES
)
{
act
->
empty
=
end
->
empty
;
act
->
glass
=
end
->
glass
;
act
->
font
=
end
->
font
;
act
->
stype
=
end
->
stype
;
act
->
txt_align
=
end
->
txt_align
;
}
lv_style_refr_objs
(
dsc
->
style_anim
);
}
lv_obj/lv_style.h
View file @
4924e871
...
...
@@ -17,6 +17,7 @@ extern "C" {
#include "misc/gfx/color.h"
#include "misc/gfx/area.h"
#include "misc/gfx/font.h"
#include "misc/gfx/anim.h"
/*********************
* DEFINES
...
...
@@ -83,6 +84,34 @@ typedef enum {
}
lv_style_name_t
;
typedef
struct
{
const
lv_style_t
*
style_start
;
/*Pointer to the starting style*/
const
lv_style_t
*
style_end
;
/*Pointer to the destination style*/
lv_style_t
*
style_anim
;
/*Pointer to a style to animate*/
anim_cb_t
end_cb
;
/*Call it when the animation is ready*/
int16_t
time
;
/*Animation time in ms*/
int16_t
act_time
;
/*Current time in animation. Set to negative to make delay.*/
uint16_t
playback_pause
;
/*Wait before play back*/
uint16_t
repeat_pause
;
/*Wait before repeat*/
uint8_t
playback
:
1
;
/*When the animation is ready play it back*/
uint8_t
repeat
:
1
;
/*Repeat the animation infinitely*/
}
lv_style_anim_t
;
/* Example initialization
lv_style_anim_t a;
a.style_anim = &style_to_anim;
a.style_start = &style_1;
a.style_end = &style_2;
a.act_time = 0;
a.time = 1000;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
a.repeat_pause = 0;
a.end_cb = NULL;
lv_style_anim_create(&a);
*/
/**********************
* GLOBAL PROTOTYPES
**********************/
...
...
@@ -99,8 +128,20 @@ void lv_style_init (void);
*/
lv_style_t
*
lv_style_get
(
lv_style_name_t
style_name
,
lv_style_t
*
copy
);
/**
* Copy a style to an other
* @param dest pointer to the destination style
* @param src pointer to the source style
*/
void
lv_style_cpy
(
lv_style_t
*
dest
,
const
lv_style_t
*
src
);
/**
* Create an animation from a pre-configured 'lv_style_anim_t' variable
* @param anim pointer to a pre-configured 'lv_style_anim_t' variable (will be copied)
*/
void
lv_style_anim_create
(
lv_style_anim_t
*
anim
);
/**********************
* MACROS
...
...
lv_objx/lv_label.c
View file @
4924e871
...
...
@@ -514,15 +514,7 @@ static bool lv_label_design(lv_obj_t * label, const area_t * mask, lv_design_mod
if
(
ext
->
recolor
!=
0
)
flag
|=
TXT_FLAG_RECOLOR
;
if
(
ext
->
expand
!=
0
)
flag
|=
TXT_FLAG_EXPAND
;
if
(
strcmp
(
"Folder1"
,
ext
->
txt
)
==
0
)
{
uint8_t
i
;
i
=
0
;
i
++
;
}
lv_draw_label
(
&
cords
,
mask
,
style
,
ext
->
txt
,
flag
,
&
ext
->
offset
);
}
return
true
;
}
...
...
lv_objx/lv_slider.c
View file @
4924e871
...
...
@@ -17,6 +17,7 @@
/*********************
* DEFINES
*********************/
#define LV_SLIDER_SIZE_MIN (2 * LV_DOWNSCALE)
/*hpad and vpad cannot make the bar or indicator smaller then this [px]*/
/**********************
* TYPEDEFS
...
...
@@ -246,24 +247,47 @@ static bool lv_slider_design(lv_obj_t * slider, const area_t * mask, lv_design_m
lv_style_t
*
style_knob
=
lv_slider_get_style_knob
(
slider
);
lv_style_t
*
style_indic
=
lv_bar_get_style_indic
(
slider
);
/*Draw the bar*/
area_t
area_bar
;
area_cpy
(
&
area_bar
,
&
slider
->
cords
);
area_bar
.
x1
+=
style_knob
->
hpad
;
area_bar
.
x2
-=
style_knob
->
hpad
;
area_bar
.
y1
+=
style_knob
->
vpad
;
area_bar
.
y2
-=
style_knob
->
vpad
;
/*Be sure at least vpad/hpad width bar will remain*/
cord_t
vpad_bar
=
style_indic
->
vpad
;
cord_t
hpad_bar
=
style_indic
->
hpad
;
if
(
vpad_bar
*
2
+
LV_SLIDER_SIZE_MIN
>
area_get_height
(
&
area_bar
))
{
vpad_bar
=
(
area_get_height
(
&
area_bar
)
-
LV_SLIDER_SIZE_MIN
)
>>
1
;
}
if
(
hpad_bar
*
2
+
LV_SLIDER_SIZE_MIN
>
area_get_width
(
&
area_bar
))
{
hpad_bar
=
(
area_get_width
(
&
area_bar
)
-
LV_SLIDER_SIZE_MIN
)
>>
1
;
}
area_bar
.
x1
+=
hpad_bar
;
area_bar
.
x2
-=
hpad_bar
;
area_bar
.
y1
+=
vpad_bar
;
area_bar
.
y2
-=
vpad_bar
;
lv_draw_rect
(
&
area_bar
,
mask
,
style_slider
);
/*Draw the indicator*/
area_t
area_indic
;
area_cpy
(
&
area_indic
,
&
area_bar
);
area_indic
.
x1
+=
style_indic
->
hpad
;
area_indic
.
x2
-=
style_indic
->
hpad
;
area_indic
.
y1
+=
style_indic
->
vpad
;
area_indic
.
y2
-=
style_indic
->
vpad
;
/*Be sure at least vpad/hpad width indicator will remain*/
cord_t
vpad_indic
=
style_indic
->
vpad
;
cord_t
hpad_indic
=
style_indic
->
hpad
;
if
(
vpad_indic
*
2
+
LV_SLIDER_SIZE_MIN
>
area_get_height
(
&
area_bar
))
{
vpad_indic
=
(
area_get_height
(
&
area_bar
)
-
LV_SLIDER_SIZE_MIN
)
>>
1
;
}
if
(
hpad_indic
*
2
+
LV_SLIDER_SIZE_MIN
>
area_get_width
(
&
area_bar
))
{
hpad_indic
=
(
area_get_width
(
&
area_bar
)
-
LV_SLIDER_SIZE_MIN
)
>>
1
;
}
area_indic
.
x1
+=
hpad_indic
;
area_indic
.
x2
-=
hpad_indic
;
area_indic
.
y1
+=
vpad_indic
;
area_indic
.
y2
-=
vpad_indic
;
cord_t
slider_w
=
area_get_width
(
&
slider
->
cords
);
cord_t
slider_h
=
area_get_height
(
&
slider
->
cords
);
cord_t
act_value
=
lv_bar_get_value
(
slider
);
cord_t
min_value
=
lv_bar_get_min_value
(
slider
);
cord_t
max_value
=
lv_bar_get_max_value
(
slider
);
...
...
lv_objx/lv_ta.c
View file @
4924e871
...
...
@@ -115,6 +115,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
lv_ta_ext_t
*
copy_ext
=
lv_obj_get_ext
(
copy
);
ext
->
label
=
lv_label_create
(
new_ta
,
copy_ext
->
label
);
ext
->
cursor_show
=
copy_ext
->
cursor_show
;
ext
->
pwd_mode
=
copy_ext
->
pwd_mode
;
lv_page_glue_obj
(
ext
->
label
,
true
);
/*Refresh the style with new signal function*/
...
...
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