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
d6739192
Commit
d6739192
authored
Nov 07, 2017
by
Gabor Kiss-Vamosi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add early return on LV_RES_INV in signal function
parent
410ea1f8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
420 additions
and
455 deletions
+420
-455
lv_btn.c
lv_objx/lv_btn.c
+80
-83
lv_cb.c
lv_objx/lv_cb.c
+14
-17
lv_cont.c
lv_objx/lv_cont.c
+12
-15
lv_ddlist.c
lv_objx/lv_ddlist.c
+72
-75
lv_ddlist.h
lv_objx/lv_ddlist.h
+0
-9
lv_list.c
lv_objx/lv_list.c
+63
-66
lv_mbox.c
lv_objx/lv_mbox.c
+78
-81
lv_page.c
lv_objx/lv_page.c
+0
-0
lv_roller.c
lv_objx/lv_roller.c
+46
-50
lv_ta.c
lv_objx/lv_ta.c
+55
-59
No files found.
lv_objx/lv_btn.c
View file @
d6739192
...
...
@@ -256,104 +256,101 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
/* Include the ancient signal function */
res
=
ancestor_signal
(
btn
,
sign
,
param
);
if
(
res
!=
LV_RES_OK
)
return
res
;
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if
(
res
==
LV_RES_OK
)
{
lv_btn_ext_t
*
ext
=
lv_obj_get_ext_attr
(
btn
);
lv_btn_state_t
state
=
lv_btn_get_state
(
btn
);
bool
tgl
=
lv_btn_get_toggle
(
btn
);
if
(
sign
==
LV_SIGNAL_PRESSED
)
{
/*Refresh the state*/
if
(
ext
->
state
==
LV_BTN_STATE_RELEASED
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_PRESSED
);
}
else
if
(
ext
->
state
==
LV_BTN_STATE_TGL_RELEASED
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_TGL_PRESSED
);
}
lv_btn_ext_t
*
ext
=
lv_obj_get_ext_attr
(
btn
);
lv_btn_state_t
state
=
lv_btn_get_state
(
btn
);
bool
tgl
=
lv_btn_get_toggle
(
btn
);
if
(
sign
==
LV_SIGNAL_PRESSED
)
{
/*Refresh the state*/
if
(
ext
->
state
==
LV_BTN_STATE_RELEASED
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_PRESSED
);
}
else
if
(
ext
->
state
==
LV_BTN_STATE_TGL_RELEASED
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_TGL_PRESSED
);
}
ext
->
long_press_action_executed
=
0
;
/*Call the press action, 'param' is the caller indev_proc*/
if
(
ext
->
actions
[
LV_BTN_ACTION_PRESS
]
&&
state
!=
LV_BTN_STATE_INACTIVE
)
{
res
=
ext
->
actions
[
LV_BTN_ACTION_PRESS
](
btn
);
}
ext
->
long_press_action_executed
=
0
;
/*Call the press action, 'param' is the caller indev_proc*/
if
(
ext
->
actions
[
LV_BTN_ACTION_PRESS
]
&&
state
!=
LV_BTN_STATE_INACTIVE
)
{
res
=
ext
->
actions
[
LV_BTN_ACTION_PRESS
](
btn
);
}
else
if
(
sign
==
LV_SIGNAL_PRESS_LOST
)
{
/*Refresh the state*/
}
else
if
(
sign
==
LV_SIGNAL_PRESS_LOST
)
{
/*Refresh the state*/
if
(
ext
->
state
==
LV_BTN_STATE_PRESSED
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
else
if
(
ext
->
state
==
LV_BTN_STATE_TGL_PRESSED
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_TGL_RELEASED
);
}
else
if
(
sign
==
LV_SIGNAL_PRESSING
)
{
/*When the button begins to drag revert pressed states to released*/
if
(
lv_indev_is_dragging
(
param
)
!=
false
)
{
if
(
ext
->
state
==
LV_BTN_STATE_PRESSED
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
else
if
(
ext
->
state
==
LV_BTN_STATE_TGL_PRESSED
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_TGL_RELEASED
);
}
else
if
(
sign
==
LV_SIGNAL_PRESSING
)
{
/*When the button begins to drag revert pressed states to released*/
if
(
lv_indev_is_dragging
(
param
)
!=
false
)
{
if
(
ext
->
state
==
LV_BTN_STATE_PRESSED
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
else
if
(
ext
->
state
==
LV_BTN_STATE_TGL_PRESSED
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_TGL_RELEASED
);
}
else
if
(
sign
==
LV_SIGNAL_RELEASED
)
{
/*If not dragged and it was not long press action then
*change state and run the action*/
if
(
lv_indev_is_dragging
(
param
)
==
false
&&
ext
->
long_press_action_executed
==
0
)
{
if
(
ext
->
state
==
LV_BTN_STATE_PRESSED
&&
tgl
==
false
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
}
else
if
(
ext
->
state
==
LV_BTN_STATE_TGL_PRESSED
&&
tgl
==
false
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_TGL_RELEASED
);
}
else
if
(
ext
->
state
==
LV_BTN_STATE_PRESSED
&&
tgl
==
true
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_TGL_RELEASED
);
}
else
if
(
ext
->
state
==
LV_BTN_STATE_TGL_PRESSED
&&
tgl
==
true
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
}
}
else
if
(
sign
==
LV_SIGNAL_RELEASED
)
{
/*If not dragged and it was not long press action then
*change state and run the action*/
if
(
lv_indev_is_dragging
(
param
)
==
false
&&
ext
->
long_press_action_executed
==
0
)
{
if
(
ext
->
state
==
LV_BTN_STATE_PRESSED
&&
tgl
==
false
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
}
else
if
(
ext
->
state
==
LV_BTN_STATE_TGL_PRESSED
&&
tgl
==
false
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_TGL_RELEASED
);
}
else
if
(
ext
->
state
==
LV_BTN_STATE_PRESSED
&&
tgl
==
true
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_TGL_RELEASED
);
}
else
if
(
ext
->
state
==
LV_BTN_STATE_TGL_PRESSED
&&
tgl
==
true
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
}
if
(
ext
->
actions
[
LV_BTN_ACTION_RELEASE
]
&&
state
!=
LV_BTN_STATE_INACTIVE
)
{
res
=
ext
->
actions
[
LV_BTN_ACTION_RELEASE
](
btn
);
}
}
else
{
/*If dragged change back the state*/
if
(
ext
->
state
==
LV_BTN_STATE_PRESSED
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
}
else
if
(
ext
->
state
==
LV_BTN_STATE_TGL_PRESSED
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_TGL_RELEASED
);
}
if
(
ext
->
actions
[
LV_BTN_ACTION_RELEASE
]
&&
state
!=
LV_BTN_STATE_INACTIVE
)
{
res
=
ext
->
actions
[
LV_BTN_ACTION_RELEASE
](
btn
);
}
}
else
{
/*If dragged change back the state*/
if
(
ext
->
state
==
LV_BTN_STATE_PRESSED
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
}
else
if
(
ext
->
state
==
LV_BTN_STATE_TGL_PRESSED
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_TGL_RELEASED
);
}
}
else
if
(
sign
==
LV_SIGNAL_LONG_PRESS
)
{
if
(
ext
->
actions
[
LV_BTN_ACTION_LONG_PRESS
]
&&
state
!=
LV_BTN_STATE_INACTIVE
)
{
ext
->
long_press_action_executed
=
1
;
res
=
ext
->
actions
[
LV_BTN_ACTION_LONG_PRESS
](
btn
);
}
}
else
if
(
sign
==
LV_SIGNAL_LONG_PRESS_REP
)
{
if
(
ext
->
actions
[
LV_BTN_ACTION_LONG_PRESS_REPEATE
]
&&
state
!=
LV_BTN_STATE_INACTIVE
)
{
res
=
ext
->
actions
[
LV_BTN_ACTION_LONG_PRESS_REPEATE
](
btn
);
}
else
if
(
sign
==
LV_SIGNAL_LONG_PRESS
)
{
if
(
ext
->
actions
[
LV_BTN_ACTION_LONG_PRESS
]
&&
state
!=
LV_BTN_STATE_INACTIVE
)
{
ext
->
long_press_action_executed
=
1
;
res
=
ext
->
actions
[
LV_BTN_ACTION_LONG_PRESS
](
btn
);
}
}
else
if
(
sign
==
LV_SIGNAL_LONG_PRESS_REP
)
{
if
(
ext
->
actions
[
LV_BTN_ACTION_LONG_PRESS_REPEATE
]
&&
state
!=
LV_BTN_STATE_INACTIVE
)
{
res
=
ext
->
actions
[
LV_BTN_ACTION_LONG_PRESS_REPEATE
](
btn
);
}
else
if
(
sign
==
LV_SIGNAL_CONTROLL
)
{
char
c
=
*
((
char
*
)
param
);
if
(
c
==
LV_GROUP_KEY_RIGHT
||
c
==
LV_GROUP_KEY_UP
)
{
if
(
lv_btn_get_toggle
(
btn
)
!=
false
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_TGL_RELEASED
);
if
(
ext
->
actions
[
LV_BTN_ACTION_RELEASE
]
&&
lv_btn_get_state
(
btn
)
!=
LV_BTN_STATE_INACTIVE
)
{
res
=
ext
->
actions
[
LV_BTN_ACTION_RELEASE
](
btn
);
}
}
else
if
(
c
==
LV_GROUP_KEY_LEFT
||
c
==
LV_GROUP_KEY_DOWN
)
{
if
(
lv_btn_get_toggle
(
btn
)
!=
false
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
if
(
ext
->
actions
[
LV_BTN_ACTION_RELEASE
]
&&
lv_btn_get_state
(
btn
)
!=
LV_BTN_STATE_INACTIVE
)
{
res
=
ext
->
actions
[
LV_BTN_ACTION_RELEASE
](
btn
);
}
}
else
if
(
c
==
LV_GROUP_KEY_ENTER
)
{
if
(
lv_btn_get_toggle
(
btn
)
!=
false
)
{
lv_btn_state_t
state
=
lv_btn_get_state
(
btn
);
if
(
state
==
LV_BTN_STATE_RELEASED
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_TGL_RELEASED
);
else
if
(
state
==
LV_BTN_STATE_PRESSED
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_TGL_PRES
SED
);
else
if
(
state
==
LV_BTN_STATE_TGL_RELEASED
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEA
SED
);
else
if
(
state
==
LV_BTN_STATE_TGL_PRESSED
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_PRES
SED
);
}
if
(
ext
->
actions
[
LV_BTN_ACTION_RELEASE
]
&&
lv_btn_get_state
(
btn
)
!=
LV_BTN_STATE_INACTIVE
)
{
res
=
ext
->
actions
[
LV_BTN_ACTION_RELEASE
](
btn
);
}
}
else
if
(
sign
==
LV_SIGNAL_CONTROLL
)
{
char
c
=
*
((
char
*
)
param
);
if
(
c
==
LV_GROUP_KEY_RIGHT
||
c
==
LV_GROUP_KEY_UP
)
{
if
(
lv_btn_get_toggle
(
btn
)
!=
false
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_TGL_RELEASED
);
if
(
ext
->
actions
[
LV_BTN_ACTION_RELEASE
]
&&
lv_btn_get_state
(
btn
)
!=
LV_BTN_STATE_INACTIVE
)
{
res
=
ext
->
actions
[
LV_BTN_ACTION_RELEASE
](
btn
);
}
}
else
if
(
c
==
LV_GROUP_KEY_LEFT
||
c
==
LV_GROUP_KEY_DOWN
)
{
if
(
lv_btn_get_toggle
(
btn
)
!=
false
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
if
(
ext
->
actions
[
LV_BTN_ACTION_RELEASE
]
&&
lv_btn_get_state
(
btn
)
!=
LV_BTN_STATE_INACTIVE
)
{
res
=
ext
->
actions
[
LV_BTN_ACTION_RELEASE
](
btn
);
}
}
else
if
(
c
==
LV_GROUP_KEY_ENTER
)
{
if
(
lv_btn_get_toggle
(
btn
)
!=
false
)
{
lv_btn_state_t
state
=
lv_btn_get_state
(
btn
);
if
(
state
==
LV_BTN_STATE_RELEASED
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_TGL_RELEA
SED
);
else
if
(
state
==
LV_BTN_STATE_PRESSED
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_TGL_PRES
SED
);
else
if
(
state
==
LV_BTN_STATE_TGL_RELEASED
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEA
SED
);
else
if
(
state
==
LV_BTN_STATE_TGL_PRESSED
)
lv_btn_set_state
(
btn
,
LV_BTN_STATE_PRESSED
);
}
if
(
ext
->
actions
[
LV_BTN_ACTION_RELEASE
]
&&
lv_btn_get_state
(
btn
)
!=
LV_BTN_STATE_INACTIVE
)
{
res
=
ext
->
actions
[
LV_BTN_ACTION_RELEASE
](
btn
);
}
}
}
return
res
;
return
LV_RES_OK
;
}
...
...
lv_objx/lv_cb.c
View file @
d6739192
...
...
@@ -241,31 +241,28 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
/* Include the ancient signal function */
res
=
ancestor_signal
(
cb
,
sign
,
param
);
if
(
res
!=
LV_RES_OK
)
return
res
;
lv_cb_ext_t
*
ext
=
lv_obj_get_ext_attr
(
cb
);
lv_style_t
*
style
=
lv_obj_get_style
(
cb
);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if
(
res
==
LV_RES_OK
)
{
if
(
sign
==
LV_SIGNAL_STYLE_CHG
)
{
lv_obj_set_size
(
ext
->
bullet
,
font_get_height
(
style
->
text
.
font
),
font_get_height
(
style
->
text
.
font
));
if
(
sign
==
LV_SIGNAL_STYLE_CHG
)
{
lv_obj_set_size
(
ext
->
bullet
,
font_get_height
(
style
->
text
.
font
),
font_get_height
(
style
->
text
.
font
));
lv_btn_set_state
(
ext
->
bullet
,
lv_btn_get_state
(
cb
));
}
else
if
(
sign
==
LV_SIGNAL_PRESSED
||
sign
==
LV_SIGNAL_RELEASED
||
sign
==
LV_SIGNAL_PRESS_LOST
)
{
lv_btn_set_state
(
ext
->
bullet
,
lv_btn_get_state
(
cb
));
}
else
if
(
sign
==
LV_SIGNAL_CONTROLL
)
{
char
c
=
*
((
char
*
)
param
);
if
(
c
==
LV_GROUP_KEY_RIGHT
||
c
==
LV_GROUP_KEY_DOWN
||
c
==
LV_GROUP_KEY_LEFT
||
c
==
LV_GROUP_KEY_UP
||
c
==
LV_GROUP_KEY_ENTER
)
{
lv_btn_set_state
(
ext
->
bullet
,
lv_btn_get_state
(
cb
));
}
else
if
(
sign
==
LV_SIGNAL_PRESSED
||
sign
==
LV_SIGNAL_RELEASED
||
sign
==
LV_SIGNAL_PRESS_LOST
)
{
lv_btn_set_state
(
ext
->
bullet
,
lv_btn_get_state
(
cb
));
}
else
if
(
sign
==
LV_SIGNAL_CONTROLL
)
{
char
c
=
*
((
char
*
)
param
);
if
(
c
==
LV_GROUP_KEY_RIGHT
||
c
==
LV_GROUP_KEY_DOWN
||
c
==
LV_GROUP_KEY_LEFT
||
c
==
LV_GROUP_KEY_UP
||
c
==
LV_GROUP_KEY_ENTER
)
{
lv_btn_set_state
(
ext
->
bullet
,
lv_btn_get_state
(
cb
));
}
}
}
return
res
;
return
LV_RES_OK
;
}
#endif
lv_objx/lv_cont.c
View file @
d6739192
...
...
@@ -191,26 +191,23 @@ static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
/* Include the ancient signal function */
res
=
ancestor_signal
(
cont
,
sign
,
param
);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if
(
res
==
LV_RES_OK
)
{
if
(
sign
==
LV_SIGNAL_STYLE_CHG
)
{
/*Recalculate the padding if the style changed*/
lv_cont_refr_layout
(
cont
);
lv_cont_refr_autofit
(
cont
);
}
else
if
(
sign
==
LV_SIGNAL_CHILD_CHG
)
{
if
(
res
!=
LV_RES_OK
)
return
res
;
if
(
sign
==
LV_SIGNAL_STYLE_CHG
)
{
/*Recalculate the padding if the style changed*/
lv_cont_refr_layout
(
cont
);
lv_cont_refr_autofit
(
cont
);
}
else
if
(
sign
==
LV_SIGNAL_CHILD_CHG
)
{
lv_cont_refr_layout
(
cont
);
lv_cont_refr_autofit
(
cont
);
}
else
if
(
sign
==
LV_SIGNAL_CORD_CHG
)
{
if
(
lv_obj_get_width
(
cont
)
!=
area_get_width
(
param
)
||
lv_obj_get_height
(
cont
)
!=
area_get_height
(
param
))
{
lv_cont_refr_layout
(
cont
);
lv_cont_refr_autofit
(
cont
);
}
else
if
(
sign
==
LV_SIGNAL_CORD_CHG
)
{
if
(
lv_obj_get_width
(
cont
)
!=
area_get_width
(
param
)
||
lv_obj_get_height
(
cont
)
!=
area_get_height
(
param
))
{
lv_cont_refr_layout
(
cont
);
lv_cont_refr_autofit
(
cont
);
}
}
}
return
res
;
return
LV_RES_OK
;
}
...
...
lv_objx/lv_ddlist.c
View file @
d6739192
...
...
@@ -29,6 +29,7 @@
* STATIC PROTOTYPES
**********************/
static
bool
lv_ddlist_design
(
lv_obj_t
*
ddlist
,
const
area_t
*
mask
,
lv_design_mode_t
mode
);
lv_res_t
lv_ddlist_signal
(
lv_obj_t
*
ddlist
,
lv_signal_t
sign
,
void
*
param
);
static
lv_res_t
lv_ddlist_scrl_signal
(
lv_obj_t
*
scrl
,
lv_signal_t
sign
,
void
*
param
);
static
lv_res_t
lv_ddlist_rel_action
(
lv_obj_t
*
ddlist
);
static
void
lv_ddlist_refr_size
(
lv_obj_t
*
ddlist
,
uint16_t
anim_time
);
...
...
@@ -118,70 +119,6 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
return
new_ddlist
;
}
/**
* Signal function of the drop down list
* @param ddlist pointer to a drop down list 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_ddlist_signal
(
lv_obj_t
*
ddlist
,
lv_signal_t
sign
,
void
*
param
)
{
bool
valid
;
/* Include the ancient signal function */
valid
=
ancestor_signal
(
ddlist
,
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_STYLE_CHG
)
{
lv_ddlist_refr_size
(
ddlist
,
0
);
lv_obj_t
*
scrl
=
lv_page_get_scrl
(
ddlist
);
lv_obj_refresh_ext_size
(
scrl
);
/*Because of the wider selected rectangle*/
}
else
if
(
sign
==
LV_SIGNAL_FOCUS
)
{
lv_ddlist_ext_t
*
ext
=
lv_obj_get_ext_attr
(
ddlist
);
if
(
ext
->
opened
==
false
)
{
ext
->
opened
=
true
;
lv_ddlist_refr_size
(
ddlist
,
true
);
}
}
else
if
(
sign
==
LV_SIGNAL_DEFOCUS
)
{
lv_ddlist_ext_t
*
ext
=
lv_obj_get_ext_attr
(
ddlist
);
if
(
ext
->
opened
!=
false
)
{
ext
->
opened
=
false
;
lv_ddlist_refr_size
(
ddlist
,
true
);
}
}
else
if
(
sign
==
LV_SIGNAL_CONTROLL
)
{
lv_ddlist_ext_t
*
ext
=
lv_obj_get_ext_attr
(
ddlist
);
char
c
=
*
((
char
*
)
param
);
if
(
c
==
LV_GROUP_KEY_RIGHT
||
c
==
LV_GROUP_KEY_DOWN
)
{
if
(
ext
->
selected_option_id
+
1
<
ext
->
option_cnt
)
{
ext
->
selected_option_id
++
;
lv_obj_invalidate
(
ddlist
);
if
(
ext
->
callback
!=
NULL
)
{
ext
->
callback
(
ddlist
);
}
}
}
else
if
(
c
==
LV_GROUP_KEY_LEFT
||
c
==
LV_GROUP_KEY_UP
)
{
if
(
ext
->
selected_option_id
>
0
)
{
ext
->
selected_option_id
--
;
lv_obj_invalidate
(
ddlist
);
if
(
ext
->
callback
!=
NULL
)
{
ext
->
callback
(
ddlist
);
}
}
}
else
if
(
c
==
LV_GROUP_KEY_ENTER
||
c
==
LV_GROUP_KEY_ESC
)
{
if
(
ext
->
opened
!=
false
)
ext
->
opened
=
false
;
if
(
ext
->
opened
==
false
)
ext
->
opened
=
true
;
lv_ddlist_refr_size
(
ddlist
,
true
);
}
}
}
return
valid
;
}
/*=====================
* Setter functions
*====================*/
...
...
@@ -452,6 +389,69 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const area_t * mask, lv_design_m
}
/**
* Signal function of the drop down list
* @param ddlist pointer to a drop down list object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
lv_res_t
lv_ddlist_signal
(
lv_obj_t
*
ddlist
,
lv_signal_t
sign
,
void
*
param
)
{
lv_res_t
res
;
/* Include the ancient signal function */
res
=
ancestor_signal
(
ddlist
,
sign
,
param
);
if
(
res
!=
LV_RES_OK
)
return
res
;
if
(
sign
==
LV_SIGNAL_STYLE_CHG
)
{
lv_ddlist_refr_size
(
ddlist
,
0
);
lv_obj_t
*
scrl
=
lv_page_get_scrl
(
ddlist
);
lv_obj_refresh_ext_size
(
scrl
);
/*Because of the wider selected rectangle*/
}
else
if
(
sign
==
LV_SIGNAL_FOCUS
)
{
lv_ddlist_ext_t
*
ext
=
lv_obj_get_ext_attr
(
ddlist
);
if
(
ext
->
opened
==
false
)
{
ext
->
opened
=
true
;
lv_ddlist_refr_size
(
ddlist
,
true
);
}
}
else
if
(
sign
==
LV_SIGNAL_DEFOCUS
)
{
lv_ddlist_ext_t
*
ext
=
lv_obj_get_ext_attr
(
ddlist
);
if
(
ext
->
opened
!=
false
)
{
ext
->
opened
=
false
;
lv_ddlist_refr_size
(
ddlist
,
true
);
}
}
else
if
(
sign
==
LV_SIGNAL_CONTROLL
)
{
lv_ddlist_ext_t
*
ext
=
lv_obj_get_ext_attr
(
ddlist
);
char
c
=
*
((
char
*
)
param
);
if
(
c
==
LV_GROUP_KEY_RIGHT
||
c
==
LV_GROUP_KEY_DOWN
)
{
if
(
ext
->
selected_option_id
+
1
<
ext
->
option_cnt
)
{
ext
->
selected_option_id
++
;
lv_obj_invalidate
(
ddlist
);
if
(
ext
->
callback
!=
NULL
)
{
ext
->
callback
(
ddlist
);
}
}
}
else
if
(
c
==
LV_GROUP_KEY_LEFT
||
c
==
LV_GROUP_KEY_UP
)
{
if
(
ext
->
selected_option_id
>
0
)
{
ext
->
selected_option_id
--
;
lv_obj_invalidate
(
ddlist
);
if
(
ext
->
callback
!=
NULL
)
{
ext
->
callback
(
ddlist
);
}
}
}
else
if
(
c
==
LV_GROUP_KEY_ENTER
||
c
==
LV_GROUP_KEY_ESC
)
{
if
(
ext
->
opened
!=
false
)
ext
->
opened
=
false
;
if
(
ext
->
opened
==
false
)
ext
->
opened
=
true
;
lv_ddlist_refr_size
(
ddlist
,
true
);
}
}
return
res
;
}
/**
* Signal function of the drop down list's scrollable part
* @param scrl pointer to a drop down list's scrollable part
* @param sign a signal type from lv_signal_t enum
...
...
@@ -464,17 +464,14 @@ static lv_res_t lv_ddlist_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void *
/* Include the ancient signal function */
res
=
ancestor_scrl_signal
(
scrl
,
sign
,
param
);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if
(
res
!=
false
)
{
if
(
sign
==
LV_SIGNAL_REFR_EXT_SIZE
)
{
/* Because of the wider selected rectangle ext. size
* In this way by dragging the scrollable part the wider rectangle area can be redrawn too*/
lv_obj_t
*
ddlist
=
lv_obj_get_parent
(
scrl
);
lv_style_t
*
style
=
lv_ddlist_get_style_bg
(
ddlist
);
if
(
scrl
->
ext_size
<
style
->
body
.
padding
.
hor
)
scrl
->
ext_size
=
style
->
body
.
padding
.
hor
;
}
if
(
res
!=
LV_RES_OK
)
return
res
;
if
(
sign
==
LV_SIGNAL_REFR_EXT_SIZE
)
{
/* Because of the wider selected rectangle ext. size
* In this way by dragging the scrollable part the wider rectangle area can be redrawn too*/
lv_obj_t
*
ddlist
=
lv_obj_get_parent
(
scrl
);
lv_style_t
*
style
=
lv_ddlist_get_style_bg
(
ddlist
);
if
(
scrl
->
ext_size
<
style
->
body
.
padding
.
hor
)
scrl
->
ext_size
=
style
->
body
.
padding
.
hor
;
}
return
res
;
...
...
lv_objx/lv_ddlist.h
View file @
d6739192
...
...
@@ -65,15 +65,6 @@ typedef struct
lv_obj_t
*
lv_ddlist_create
(
lv_obj_t
*
par
,
lv_obj_t
*
copy
);
/**
* Signal function of the drop down list
* @param ddlist pointer to a drop down list 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_ddlist_signal
(
lv_obj_t
*
ddlist
,
lv_signal_t
sign
,
void
*
param
);
/**
* Set the options in a drop down list from a string
* @param ddlist pointer to drop down list object
* @param options a string with '\n' separated options. E.g. "One\nTwo\nThree"
...
...
lv_objx/lv_list.c
View file @
d6739192
...
...
@@ -406,37 +406,69 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
/* Include the ancient signal function */
res
=
ancestor_signal
(
list
,
sign
,
param
);
if
(
res
!=
LV_RES_OK
)
return
res
;
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if
(
res
==
LV_RES_OK
)
{
if
(
sign
==
LV_SIGNAL_CORD_CHG
)
{
/*Be sure the width of the buttons are correct*/
cord_t
w
=
lv_obj_get_width
(
list
);
if
(
w
!=
area_get_width
(
param
))
{
/*Width changed*/
refr_btn_width
(
list
);
}
if
(
sign
==
LV_SIGNAL_CORD_CHG
)
{
/*Be sure the width of the buttons are correct*/
cord_t
w
=
lv_obj_get_width
(
list
);
if
(
w
!=
area_get_width
(
param
))
{
/*Width changed*/
refr_btn_width
(
list
);
}
}
else
if
(
sign
==
LV_SIGNAL_STYLE_CHG
)
{
/*Because of the possible change of horizontal and vertical padding refresh buttons width */
refr_btn_width
(
list
);
}
else
if
(
sign
==
LV_SIGNAL_FOCUS
)
{
/*Get the first button*/
lv_obj_t
*
btn
=
NULL
;
lv_obj_t
*
btn_prev
=
NULL
;
btn
=
get_next_btn
(
list
,
btn
);
while
(
btn
!=
NULL
)
{
btn_prev
=
btn
;
btn
=
get_next_btn
(
list
,
btn
);
}
if
(
btn_prev
!=
NULL
)
{
lv_btn_set_state
(
btn_prev
,
LV_BTN_STATE_PRESSED
);
}
}
else
if
(
sign
==
LV_SIGNAL_DEFOCUS
)
{
/*Get the 'pressed' button*/
lv_obj_t
*
btn
=
NULL
;
btn
=
get_next_btn
(
list
,
btn
);
while
(
btn
!=
NULL
)
{
if
(
lv_btn_get_state
(
btn
)
==
LV_BTN_STATE_PRESSED
)
break
;
btn
=
get_next_btn
(
list
,
btn
);
}
else
if
(
sign
==
LV_SIGNAL_STYLE_CHG
)
{
/*Because of the possible change of horizontal and vertical padding refresh buttons width */
refr_btn_width
(
list
);
if
(
btn
!=
NULL
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
}
else
if
(
sign
==
LV_SIGNAL_FOCUS
)
{
/*Get the first button*/
}
else
if
(
sign
==
LV_SIGNAL_CONTROLL
)
{
char
c
=
*
((
char
*
)
param
);
if
(
c
==
LV_GROUP_KEY_RIGHT
||
c
==
LV_GROUP_KEY_DOWN
)
{
/*Get the last pressed button*/
lv_obj_t
*
btn
=
NULL
;
lv_obj_t
*
btn_prev
=
NULL
;
lv_list_ext_t
*
ext
=
lv_obj_get_ext_attr
(
list
);
btn
=
get_next_btn
(
list
,
btn
);
while
(
btn
!=
NULL
)
{
if
(
lv_btn_get_state
(
btn
)
==
LV_BTN_STATE_PRESSED
)
break
;
btn_prev
=
btn
;
btn
=
get_next_btn
(
list
,
btn
);
}
if
(
btn_prev
!=
NULL
)
{
if
(
btn_prev
!=
NULL
&&
btn
!=
NULL
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
lv_btn_set_state
(
btn_prev
,
LV_BTN_STATE_PRESSED
);
lv_page_focus
(
list
,
btn_prev
,
ext
->
anim_time
);
}
}
else
if
(
sign
==
LV_SIGNAL_DEFOCUS
)
{
/*Get the
'pressed'
button*/
else
if
(
c
==
LV_GROUP_KEY_LEFT
||
c
==
LV_GROUP_KEY_UP
)
{
/*Get the
last pressed
button*/
lv_obj_t
*
btn
=
NULL
;
lv_list_ext_t
*
ext
=
lv_obj_get_ext_attr
(
list
);
btn
=
get_next_btn
(
list
,
btn
);
while
(
btn
!=
NULL
)
{
if
(
lv_btn_get_state
(
btn
)
==
LV_BTN_STATE_PRESSED
)
break
;
...
...
@@ -444,65 +476,30 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
}
if
(
btn
!=
NULL
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
}
}
else
if
(
sign
==
LV_SIGNAL_CONTROLL
)
{
char
c
=
*
((
char
*
)
param
);
if
(
c
==
LV_GROUP_KEY_RIGHT
||
c
==
LV_GROUP_KEY_DOWN
)
{
/*Get the last pressed button*/
lv_obj_t
*
btn
=
NULL
;
lv_obj_t
*
btn_prev
=
NULL
;
lv_list_ext_t
*
ext
=
lv_obj_get_ext_attr
(
list
);
btn
=
get_next_btn
(
list
,
btn
);
while
(
btn
!=
NULL
)
{
if
(
lv_btn_get_state
(
btn
)
==
LV_BTN_STATE_PRESSED
)
break
;
btn_prev
=
btn
;
btn
=
get_next_btn
(
list
,
btn
);
}
if
(
btn_prev
!=
NULL
&&
btn
!=
NULL
)
{
lv_obj_t
*
btn_prev
=
get_next_btn
(
list
,
btn
);
if
(
btn_prev
!=
NULL
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
lv_btn_set_state
(
btn_prev
,
LV_BTN_STATE_PRESSED
);
lv_page_focus
(
list
,
btn_prev
,
ext
->
anim_time
);
}
}
else
if
(
c
==
LV_GROUP_KEY_LEFT
||
c
==
LV_GROUP_KEY_UP
)
{
/*Get the last pressed button*/
lv_obj_t
*
btn
=
NULL
;
lv_list_ext_t
*
ext
=
lv_obj_get_ext_attr
(
list
);
btn
=
get_next_btn
(
list
,
btn
);
while
(
btn
!=
NULL
)
{
if
(
lv_btn_get_state
(
btn
)
==
LV_BTN_STATE_PRESSED
)
break
;
btn
=
get_next_btn
(
list
,
btn
);
}
if
(
btn
!=
NULL
)
{
lv_obj_t
*
btn_prev
=
get_next_btn
(
list
,
btn
);
if
(
btn_prev
!=
NULL
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
lv_btn_set_state
(
btn_prev
,
LV_BTN_STATE_PRESSED
);
lv_page_focus
(
list
,
btn_prev
,
ext
->
anim_time
);
}
}
}
else
if
(
c
==
LV_GROUP_KEY_ENTER
)
{
/*Get the 'pressed' button*/
lv_obj_t
*
btn
=
NULL
;
}
else
if
(
c
==
LV_GROUP_KEY_ENTER
)
{
/*Get the 'pressed' button*/
lv_obj_t
*
btn
=
NULL
;
btn
=
get_next_btn
(
list
,
btn
);
while
(
btn
!=
NULL
)
{
if
(
lv_btn_get_state
(
btn
)
==
LV_BTN_STATE_PRESSED
)
break
;
btn
=
get_next_btn
(
list
,
btn
);
while
(
btn
!=
NULL
)
{
if
(
lv_btn_get_state
(
btn
)
==
LV_BTN_STATE_PRESSED
)
break
;
btn
=
get_next_btn
(
list
,
btn
);
}
}
if
(
btn
!=
NULL
)
{
lv_action_t
rel_action
;
rel_action
=
lv_btn_get_action
(
btn
,
LV_BTN_ACTION_RELEASE
);
if
(
rel_action
!=
NULL
)
rel_action
(
btn
);
}
if
(
btn
!=
NULL
)
{
lv_action_t
rel_action
;
rel_action
=
lv_btn_get_action
(
btn
,
LV_BTN_ACTION_RELEASE
);
if
(
rel_action
!=
NULL
)
rel_action
(
btn
);
}
}
}
return
res
;
return
LV_RES_OK
;
}
/**
...
...
lv_objx/lv_mbox.c
View file @
d6739192
...
...
@@ -308,50 +308,84 @@ static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
/* Include the ancient signal function */
res
=
ancestor_signal
(
mbox
,
sign
,
param
);
if
(
res
!=
LV_RES_OK
)
return
res
;
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if
(
res
==
LV_RES_OK
)
{
lv_mbox_ext_t
*
ext
=
lv_obj_get_ext_attr
(
mbox
);
if
(
sign
==
LV_SIGNAL_CORD_CHG
)
{
if
(
lv_obj_get_width
(
mbox
)
!=
area_get_width
(
param
))
{
btnh_resize
(
mbox
);
lv_mbox_ext_t
*
ext
=
lv_obj_get_ext_attr
(
mbox
);
if
(
sign
==
LV_SIGNAL_CORD_CHG
)
{
if
(
lv_obj_get_width
(
mbox
)
!=
area_get_width
(
param
))
{
btnh_resize
(
mbox
);
}
}
if
(
sign
==
LV_SIGNAL_LONG_PRESS
)
{
lv_mbox_start_auto_close
(
mbox
,
0
);
lv_indev_wait_release
(
param
);
res
=
LV_RES_INV
;
}
else
if
(
sign
==
LV_SIGNAL_STYLE_CHG
)
{
/*Refresh all the buttons*/
if
(
ext
->
btnh
!=
NULL
)
{
lv_obj_t
*
btn
;
btn
=
lv_obj_get_child
(
ext
->
btnh
,
NULL
);
while
(
btn
!=
NULL
)
{
/*Refresh the next button's style*/
lv_btn_set_style
(
btn
,
ext
->
style_btn_rel
,
ext
->
style_btn_pr
,
NULL
,
NULL
,
NULL
);
btn
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
}
}
if
(
sign
==
LV_SIGNAL_LONG_PRESS
)
{
lv_mbox_start_auto_close
(
mbox
,
0
);
lv_indev_wait_release
(
param
);
res
=
LV_RES_INV
;
}
else
if
(
sign
==
LV_SIGNAL_FOCUS
)
{
/*Get the first button*/
if
(
ext
->
btnh
!=
NULL
)
{
lv_obj_t
*
btn
=
NULL
;
lv_obj_t
*
btn_prev
=
NULL
;
btn
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
while
(
btn
!=
NULL
)
{
btn_prev
=
btn
;
btn
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
}
if
(
btn_prev
!=
NULL
)
{
lv_btn_set_state
(
btn_prev
,
LV_BTN_STATE_PRESSED
);
}
}
else
if
(
sign
==
LV_SIGNAL_STYLE_CHG
)
{
/*Refresh all the buttons*/
if
(
ext
->
btnh
!=
NULL
)
{
lv_obj_t
*
btn
;
btn
=
lv_obj_get_child
(
ext
->
btnh
,
NULL
);
while
(
btn
!=
NULL
)
{
/*Refresh the next button's style*/
lv_btn_set_style
(
btn
,
ext
->
style_btn_rel
,
ext
->
style_btn_pr
,
NULL
,
NULL
,
NULL
);
btn
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
}
}
else
if
(
sign
==
LV_SIGNAL_DEFOCUS
)
{
/*Get the 'pressed' button*/
if
(
ext
->
btnh
!=
NULL
)
{
lv_obj_t
*
btn
=
NULL
;
btn
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
while
(
btn
!=
NULL
)
{
if
(
lv_btn_get_state
(
btn
)
==
LV_BTN_STATE_PRESSED
)
break
;
btn
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
}
if
(
btn
!=
NULL
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
}
}
else
if
(
sign
==
LV_SIGNAL_FOCUS
)
{
/*Get the first button*/
}
else
if
(
sign
==
LV_SIGNAL_CONTROLL
)
{
lv_mbox_ext_t
*
ext
=
lv_obj_get_ext_attr
(
mbox
);
char
c
=
*
((
char
*
)
param
);
if
(
c
==
LV_GROUP_KEY_RIGHT
||
c
==
LV_GROUP_KEY_UP
)
{
/*Get the last pressed button*/
if
(
ext
->
btnh
!=
NULL
)
{
lv_obj_t
*
btn
=
NULL
;
lv_obj_t
*
btn_prev
=
NULL
;
btn
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
while
(
btn
!=
NULL
)
{
if
(
lv_btn_get_state
(
btn
)
==
LV_BTN_STATE_PRESSED
)
break
;
btn_prev
=
btn
;
btn
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
}
if
(
btn_prev
!=
NULL
)
{
if
(
btn_prev
!=
NULL
&&
btn
!=
NULL
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
lv_btn_set_state
(
btn_prev
,
LV_BTN_STATE_PRESSED
);
}
}
}
else
if
(
sign
==
LV_SIGNAL_DEFOCUS
)
{
/*Get the
'pressed'
button*/
else
if
(
c
==
LV_GROUP_KEY_LEFT
||
c
==
LV_GROUP_KEY_DOWN
)
{
/*Get the
last pressed
button*/
if
(
ext
->
btnh
!=
NULL
)
{
lv_obj_t
*
btn
=
NULL
;
btn
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
...
...
@@ -361,72 +395,35 @@ static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
}
if
(
btn
!=
NULL
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
}
}
}
else
if
(
sign
==
LV_SIGNAL_CONTROLL
)
{
lv_mbox_ext_t
*
ext
=
lv_obj_get_ext_attr
(
mbox
);
char
c
=
*
((
char
*
)
param
);
if
(
c
==
LV_GROUP_KEY_RIGHT
||
c
==
LV_GROUP_KEY_UP
)
{
/*Get the last pressed button*/
if
(
ext
->
btnh
!=
NULL
)
{
lv_obj_t
*
btn
=
NULL
;
lv_obj_t
*
btn_prev
=
NULL
;
btn
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
while
(
btn
!=
NULL
)
{
if
(
lv_btn_get_state
(
btn
)
==
LV_BTN_STATE_PRESSED
)
break
;
btn_prev
=
btn
;
btn
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
}
if
(
btn_prev
!=
NULL
&&
btn
!=
NULL
)
{
lv_obj_t
*
btn_prev
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
if
(
btn_prev
!=
NULL
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
lv_btn_set_state
(
btn_prev
,
LV_BTN_STATE_PRESSED
);
}
}
}
else
if
(
c
==
LV_GROUP_KEY_LEFT
||
c
==
LV_GROUP_KEY_DOWN
)
{
/*Get the last pressed button*/
if
(
ext
->
btnh
!=
NULL
)
{
lv_obj_t
*
btn
=
NULL
;
btn
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
while
(
btn
!=
NULL
)
{
if
(
lv_btn_get_state
(
btn
)
==
LV_BTN_STATE_PRESSED
)
break
;
btn
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
}
if
(
btn
!=
NULL
)
{
lv_obj_t
*
btn_prev
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
if
(
btn_prev
!=
NULL
)
{
lv_btn_set_state
(
btn
,
LV_BTN_STATE_RELEASED
);
lv_btn_set_state
(
btn_prev
,
LV_BTN_STATE_PRESSED
);
}
}
}
}
else
if
(
c
==
LV_GROUP_KEY_ENTER
)
{
/*Get the 'pressed' button*/
if
(
ext
->
btnh
!=
NULL
)
{
lv_obj_t
*
btn
=
NULL
;
}
else
if
(
c
==
LV_GROUP_KEY_ENTER
)
{
/*Get the 'pressed' button*/
if
(
ext
->
btnh
!=
NULL
)
{
lv_obj_t
*
btn
=
NULL
;
btn
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
while
(
btn
!=
NULL
)
{
if
(
lv_btn_get_state
(
btn
)
==
LV_BTN_STATE_PRESSED
)
break
;
btn
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
while
(
btn
!=
NULL
)
{
if
(
lv_btn_get_state
(
btn
)
==
LV_BTN_STATE_PRESSED
)
break
;
btn
=
lv_obj_get_child
(
ext
->
btnh
,
btn
);
}
if
(
btn
!=
NULL
)
{
lv_action_t
rel_action
;
rel_action
=
lv_btn_get_action
(
btn
,
LV_BTN_ACTION_RELEASE
);
if
(
rel_action
!=
NULL
)
rel_action
(
btn
);
}
}
}
if
(
btn
!=
NULL
)
{
lv_action_t
rel_action
;
rel_action
=
lv_btn_get_action
(
btn
,
LV_BTN_ACTION_RELEASE
);
if
(
rel_action
!=
NULL
)
rel_action
(
btn
);
}
}
}
}
return
res
;
return
LV_RES_OK
;
}
/**
...
...
lv_objx/lv_page.c
View file @
d6739192
This diff is collapsed.
Click to expand it.
lv_objx/lv_roller.c
View file @
d6739192
...
...
@@ -215,30 +215,28 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
/* Include the ancient signal function */
res
=
ancestor_signal
(
roller
,
sign
,
param
);
if
(
res
!=
LV_RES_OK
)
return
res
;
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if
(
res
==
LV_RES_OK
)
{
lv_roller_ext_t
*
ext
=
lv_obj_get_ext_attr
(
roller
);
if
(
sign
==
LV_SIGNAL_STYLE_CHG
)
{
lv_roller_ext_t
*
ext
=
lv_obj_get_ext_attr
(
roller
);
if
(
sign
==
LV_SIGNAL_STYLE_CHG
)
{
lv_obj_set_height
(
lv_page_get_scrl
(
roller
),
lv_obj_get_height
(
ext
->
ddlist
.
options_label
)
+
lv_obj_get_height
(
roller
));
lv_obj_align
(
ext
->
ddlist
.
options_label
,
NULL
,
LV_ALIGN_CENTER
,
0
,
0
);
lv_ddlist_set_selected
(
roller
,
ext
->
ddlist
.
selected_option_id
);
refr_position
(
roller
,
false
);
}
else
if
(
sign
==
LV_SIGNAL_CORD_CHG
)
{
if
(
lv_obj_get_width
(
roller
)
!=
area_get_width
(
param
)
||
lv_obj_get_height
(
roller
)
!=
area_get_height
(
param
))
{
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
.
options_label
)
+
lv_obj_get_height
(
roller
));
lv_obj_align
(
ext
->
ddlist
.
options_label
,
NULL
,
LV_ALIGN_CENTER
,
0
,
0
);
lv_ddlist_set_selected
(
roller
,
ext
->
ddlist
.
selected_option_id
);
refr_position
(
roller
,
false
);
}
else
if
(
sign
==
LV_SIGNAL_CORD_CHG
)
{
if
(
lv_obj_get_width
(
roller
)
!=
area_get_width
(
param
)
||
lv_obj_get_height
(
roller
)
!=
area_get_height
(
param
))
{
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
.
options_label
)
+
lv_obj_get_height
(
roller
));
lv_obj_align
(
ext
->
ddlist
.
options_label
,
NULL
,
LV_ALIGN_CENTER
,
0
,
0
);
lv_ddlist_set_selected
(
roller
,
ext
->
ddlist
.
selected_option_id
);
refr_position
(
roller
,
false
);
}
}
}
...
...
@@ -258,44 +256,42 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign,
/* Include the ancient signal function */
res
=
ancestor_scrl_signal
(
roller_scrl
,
sign
,
param
);
if
(
res
!=
LV_RES_OK
)
return
res
;
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if
(
res
==
LV_RES_OK
)
{
lv_indev_t
*
indev
=
lv_indev_get_act
();
int32_t
id
=
-
1
;
lv_obj_t
*
roller
=
lv_obj_get_parent
(
roller_scrl
);
lv_roller_ext_t
*
ext
=
lv_obj_get_ext_attr
(
roller
);
lv_style_t
*
style_label
=
lv_obj_get_style
(
ext
->
ddlist
.
options_label
);
const
font_t
*
font
=
style_label
->
text
.
font
;
cord_t
font_h
=
font_get_height
(
font
)
>>
FONT_ANTIALIAS
;
if
(
sign
==
LV_SIGNAL_DRAG_END
)
{
/*If dragged then align the list to there be an element in the middle*/
cord_t
label_y1
=
ext
->
ddlist
.
options_label
->
coords
.
y1
-
roller
->
coords
.
y1
;
cord_t
label_unit
=
font_h
+
style_label
->
text
.
line_space
;
cord_t
mid
=
(
roller
->
coords
.
y2
-
roller
->
coords
.
y1
)
/
2
;
id
=
(
mid
-
label_y1
+
style_label
->
text
.
line_space
/
2
)
/
label_unit
;
lv_indev_t
*
indev
=
lv_indev_get_act
();
int32_t
id
=
-
1
;
lv_obj_t
*
roller
=
lv_obj_get_parent
(
roller_scrl
);
lv_roller_ext_t
*
ext
=
lv_obj_get_ext_attr
(
roller
);
lv_style_t
*
style_label
=
lv_obj_get_style
(
ext
->
ddlist
.
options_label
);
const
font_t
*
font
=
style_label
->
text
.
font
;
cord_t
font_h
=
font_get_height
(
font
)
>>
FONT_ANTIALIAS
;
if
(
sign
==
LV_SIGNAL_DRAG_END
)
{
/*If dragged then align the list to there be an element in the middle*/
cord_t
label_y1
=
ext
->
ddlist
.
options_label
->
coords
.
y1
-
roller
->
coords
.
y1
;
cord_t
label_unit
=
font_h
+
style_label
->
text
.
line_space
;
cord_t
mid
=
(
roller
->
coords
.
y2
-
roller
->
coords
.
y1
)
/
2
;
id
=
(
mid
-
label_y1
+
style_label
->
text
.
line_space
/
2
)
/
label_unit
;
if
(
id
<
0
)
id
=
0
;
if
(
id
>=
ext
->
ddlist
.
option_cnt
)
id
=
ext
->
ddlist
.
option_cnt
-
1
;
ext
->
ddlist
.
selected_option_id
=
id
;
}
else
if
(
sign
==
LV_SIGNAL_RELEASED
)
{
/*If picked an option by clicking then set it*/
if
(
!
lv_indev_is_dragging
(
indev
))
{
point_t
p
;
lv_indev_get_point
(
indev
,
&
p
);
p
.
y
=
p
.
y
-
ext
->
ddlist
.
options_label
->
coords
.
y1
;
id
=
p
.
y
/
(
font_h
+
style_label
->
text
.
line_space
);
if
(
id
<
0
)
id
=
0
;
if
(
id
>=
ext
->
ddlist
.
option_cnt
)
id
=
ext
->
ddlist
.
option_cnt
-
1
;
ext
->
ddlist
.
selected_option_id
=
id
;
}
else
if
(
sign
==
LV_SIGNAL_RELEASED
)
{
/*If picked an option by clicking then set it*/
if
(
!
lv_indev_is_dragging
(
indev
))
{
point_t
p
;
lv_indev_get_point
(
indev
,
&
p
);
p
.
y
=
p
.
y
-
ext
->
ddlist
.
options_label
->
coords
.
y1
;
id
=
p
.
y
/
(
font_h
+
style_label
->
text
.
line_space
);
if
(
id
<
0
)
id
=
0
;
if
(
id
>=
ext
->
ddlist
.
option_cnt
)
id
=
ext
->
ddlist
.
option_cnt
-
1
;
ext
->
ddlist
.
selected_option_id
=
id
;
}
}
}
/*Position the scrollable according to the new selected option*/
if
(
id
!=
-
1
)
{
refr_position
(
roller
,
true
);
}
/*Position the scrollable according to the new selected option*/
if
(
id
!=
-
1
)
{
refr_position
(
roller
,
true
);
}
return
res
;
...
...
lv_objx/lv_ta.c
View file @
d6739192
...
...
@@ -861,61 +861,59 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
/* Include the ancient signal function */
res
=
ancestor_signal
(
ta
,
sign
,
param
);
if
(
res
!=
LV_RES_OK
)
return
res
;
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if
(
res
==
LV_RES_OK
)
{
lv_ta_ext_t
*
ext
=
lv_obj_get_ext_attr
(
ta
);
if
(
sign
==
LV_SIGNAL_CLEANUP
)
{
if
(
ext
->
pwd_tmp
!=
NULL
)
dm_free
(
ext
->
pwd_tmp
);
lv_ta_ext_t
*
ext
=
lv_obj_get_ext_attr
(
ta
);
if
(
sign
==
LV_SIGNAL_CLEANUP
)
{
if
(
ext
->
pwd_tmp
!=
NULL
)
dm_free
(
ext
->
pwd_tmp
);
/* (The created label will be deleted automatically) */
}
else
if
(
sign
==
LV_SIGNAL_STYLE_CHG
)
{
if
(
ext
->
label
)
{
lv_obj_t
*
scrl
=
lv_page_get_scrl
(
ta
);
lv_style_t
*
style_ta
=
lv_obj_get_style
(
ta
);
lv_style_t
*
style_scrl
=
lv_obj_get_style
(
scrl
);
if
(
ext
->
one_line
)
{
/*In one line mode refresh the Text Area height because 'vpad' can modify it*/
lv_style_t
*
style_label
=
lv_obj_get_style
(
ext
->
label
);
cord_t
font_h
=
font_get_height
(
style_label
->
text
.
font
)
>>
FONT_ANTIALIAS
;
lv_obj_set_height
(
ta
,
font_h
+
(
style_ta
->
body
.
padding
.
ver
+
style_scrl
->
body
.
padding
.
ver
)
*
2
);
}
else
{
/*In not one line mode refresh the Label width because 'hpad' can modify it*/
lv_obj_set_width
(
ext
->
label
,
lv_obj_get_width
(
scrl
)
-
2
*
style_scrl
->
body
.
padding
.
hor
);
lv_obj_set_pos
(
ext
->
label
,
style_scrl
->
body
.
padding
.
hor
,
style_scrl
->
body
.
padding
.
ver
);
/*Be sure the Label is in the correct position*/
}
lv_label_set_text
(
ext
->
label
,
NULL
);
/* (The created label will be deleted automatically) */
}
else
if
(
sign
==
LV_SIGNAL_STYLE_CHG
)
{
if
(
ext
->
label
)
{
lv_obj_refresh_ext_size
(
scrl
);
/*Refresh ext. size because of cursor drawing*/
}
}
else
if
(
sign
==
LV_SIGNAL_CORD_CHG
)
{
/*Set the label width according to the text area width*/
if
(
ext
->
label
)
{
if
(
lv_obj_get_width
(
ta
)
!=
area_get_width
(
param
)
||
lv_obj_get_height
(
ta
)
!=
area_get_height
(
param
))
{
lv_obj_t
*
scrl
=
lv_page_get_scrl
(
ta
);
lv_style_t
*
style_ta
=
lv_obj_get_style
(
ta
);
lv_style_t
*
style_scrl
=
lv_obj_get_style
(
scrl
);
if
(
ext
->
one_line
)
{
/*In one line mode refresh the Text Area height because 'vpad' can modify it*/
lv_style_t
*
style_label
=
lv_obj_get_style
(
ext
->
label
);
cord_t
font_h
=
font_get_height
(
style_label
->
text
.
font
)
>>
FONT_ANTIALIAS
;
lv_obj_set_height
(
ta
,
font_h
+
(
style_ta
->
body
.
padding
.
ver
+
style_scrl
->
body
.
padding
.
ver
)
*
2
);
}
else
{
/*In not one line mode refresh the Label width because 'hpad' can modify it*/
lv_obj_set_width
(
ext
->
label
,
lv_obj_get_width
(
scrl
)
-
2
*
style_scrl
->
body
.
padding
.
hor
);
lv_obj_set_pos
(
ext
->
label
,
style_scrl
->
body
.
padding
.
hor
,
style_scrl
->
body
.
padding
.
ver
);
/*Be sure the Label is in the correct position*/
}
lv_label_set_text
(
ext
->
label
,
NULL
);
lv_obj_refresh_ext_size
(
scrl
);
/*Refresh ext. size because of cursor drawing*/
}
}
else
if
(
sign
==
LV_SIGNAL_CORD_CHG
)
{
/*Set the label width according to the text area width*/
if
(
ext
->
label
)
{
if
(
lv_obj_get_width
(
ta
)
!=
area_get_width
(
param
)
||
lv_obj_get_height
(
ta
)
!=
area_get_height
(
param
))
{
lv_obj_t
*
scrl
=
lv_page_get_scrl
(
ta
);
lv_style_t
*
style_scrl
=
lv_obj_get_style
(
scrl
);
lv_obj_set_width
(
ext
->
label
,
lv_obj_get_width
(
scrl
)
-
2
*
style_scrl
->
body
.
padding
.
hor
);
lv_obj_set_pos
(
ext
->
label
,
style_scrl
->
body
.
padding
.
hor
,
style_scrl
->
body
.
padding
.
ver
);
lv_label_set_text
(
ext
->
label
,
NULL
);
/*Refresh the label*/
}
lv_obj_set_width
(
ext
->
label
,
lv_obj_get_width
(
scrl
)
-
2
*
style_scrl
->
body
.
padding
.
hor
);
lv_obj_set_pos
(
ext
->
label
,
style_scrl
->
body
.
padding
.
hor
,
style_scrl
->
body
.
padding
.
ver
);
lv_label_set_text
(
ext
->
label
,
NULL
);
/*Refresh the label*/
}
}
else
if
(
sign
==
LV_SIGNAL_CONTROLL
)
{
char
c
=
*
((
char
*
)
param
);
if
(
c
==
LV_GROUP_KEY_RIGHT
)
{
lv_ta_cursor_right
(
ta
);
}
else
if
(
c
==
LV_GROUP_KEY_LEFT
)
{
lv_ta_cursor_left
(
ta
);
}
else
if
(
c
==
LV_GROUP_KEY_UP
)
{
lv_ta_cursor_up
(
ta
);
}
else
if
(
c
==
LV_GROUP_KEY_DOWN
)
{
lv_ta_cursor_down
(
ta
);
}
}
else
if
(
sign
==
LV_SIGNAL_CONTROLL
)
{
char
c
=
*
((
char
*
)
param
);
if
(
c
==
LV_GROUP_KEY_RIGHT
)
{
lv_ta_cursor_right
(
ta
);
}
else
if
(
c
==
LV_GROUP_KEY_LEFT
)
{
lv_ta_cursor_left
(
ta
);
}
else
if
(
c
==
LV_GROUP_KEY_UP
)
{
lv_ta_cursor_up
(
ta
);
}
else
if
(
c
==
LV_GROUP_KEY_DOWN
)
{
lv_ta_cursor_down
(
ta
);
}
}
return
res
;
return
LV_RES_OK
;
}
/**
...
...
@@ -931,20 +929,18 @@ static lv_res_t lv_ta_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void
/* Include the ancient signal function */
res
=
scrl_signal
(
scrl
,
sign
,
param
);
if
(
res
!=
LV_RES_OK
)
return
res
;
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if
(
res
==
LV_RES_OK
)
{
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_attr
(
ta
);
lv_style_t
*
style_label
=
lv_obj_get_style
(
ext
->
label
);
cord_t
font_h
=
font_get_height
(
style_label
->
text
.
font
)
>>
FONT_ANTIALIAS
;
scrl
->
ext_size
=
MATH_MAX
(
scrl
->
ext_size
,
style_label
->
text
.
line_space
+
font_h
);
}
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_attr
(
ta
);
lv_style_t
*
style_label
=
lv_obj_get_style
(
ext
->
label
);
cord_t
font_h
=
font_get_height
(
style_label
->
text
.
font
)
>>
FONT_ANTIALIAS
;
scrl
->
ext_size
=
MATH_MAX
(
scrl
->
ext_size
,
style_label
->
text
.
line_space
+
font_h
);
}
return
res
;
return
LV_RES_OK
;
}
/**
...
...
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