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
3a35da8f
Commit
3a35da8f
authored
Mar 07, 2018
by
Gabor Kiss-Vamosi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lv_btnm (and lv_kb): add up/down navigation with LV_GROUP_KEY_UP/DOWN
parent
1b1efbd0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
10 deletions
+51
-10
lv_btnm.c
lv_objx/lv_btnm.c
+44
-3
lv_btnm.h
lv_objx/lv_btnm.h
+7
-7
No files found.
lv_objx/lv_btnm.c
View file @
3a35da8f
...
...
@@ -576,16 +576,57 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
}
else
if
(
sign
==
LV_SIGNAL_CONTROLL
)
{
char
c
=
*
((
char
*
)
param
);
if
(
c
==
LV_GROUP_KEY_RIGHT
||
c
==
LV_GROUP_KEY_UP
)
{
if
(
c
==
LV_GROUP_KEY_RIGHT
)
{
if
(
ext
->
btn_id_pr
==
LV_BTNM_PR_NONE
)
ext
->
btn_id_pr
=
0
;
else
ext
->
btn_id_pr
++
;
if
(
ext
->
btn_id_pr
>=
ext
->
btn_cnt
-
1
)
ext
->
btn_id_pr
=
ext
->
btn_cnt
-
1
;
lv_obj_invalidate
(
btnm
);
}
else
if
(
c
==
LV_GROUP_KEY_LEFT
||
c
==
LV_GROUP_KEY_DOWN
)
{
}
else
if
(
c
==
LV_GROUP_KEY_LEFT
)
{
if
(
ext
->
btn_id_pr
==
LV_BTNM_PR_NONE
)
ext
->
btn_id_pr
=
0
;
if
(
ext
->
btn_id_pr
>
0
)
ext
->
btn_id_pr
--
;
lv_obj_invalidate
(
btnm
);
}
else
if
(
c
==
LV_GROUP_KEY_ENTER
||
c
==
LV_GROUP_KEY_ENTER_LONG
)
{
}
else
if
(
c
==
LV_GROUP_KEY_DOWN
)
{
lv_style_t
*
style
=
lv_btnm_get_style
(
btnm
,
LV_BTNM_STYLE_BG
);
/*Find the area below the the current*/
if
(
ext
->
btn_id_pr
==
LV_BTNM_PR_NONE
)
{
ext
->
btn_id_pr
=
0
;
}
else
{
uint16_t
area_below
;
lv_coord_t
pr_center
=
ext
->
button_areas
[
ext
->
btn_id_pr
].
x1
+
(
lv_area_get_width
(
&
ext
->
button_areas
[
ext
->
btn_id_pr
])
>>
1
);
for
(
area_below
=
ext
->
btn_id_pr
;
area_below
<
ext
->
btn_cnt
;
area_below
++
)
{
if
(
ext
->
button_areas
[
area_below
].
y1
>
ext
->
button_areas
[
ext
->
btn_id_pr
].
y1
&&
pr_center
>=
ext
->
button_areas
[
area_below
].
x1
&&
pr_center
<=
ext
->
button_areas
[
area_below
].
x2
+
style
->
body
.
padding
.
hor
)
{
break
;
}
}
ext
->
btn_id_pr
=
area_below
;
}
lv_obj_invalidate
(
btnm
);
}
else
if
(
c
==
LV_GROUP_KEY_UP
)
{
lv_style_t
*
style
=
lv_btnm_get_style
(
btnm
,
LV_BTNM_STYLE_BG
);
/*Find the area below the the current*/
if
(
ext
->
btn_id_pr
==
LV_BTNM_PR_NONE
)
{
ext
->
btn_id_pr
=
0
;
}
else
{
uint16_t
area_above
;
lv_coord_t
pr_center
=
ext
->
button_areas
[
ext
->
btn_id_pr
].
x1
+
(
lv_area_get_width
(
&
ext
->
button_areas
[
ext
->
btn_id_pr
])
>>
1
);
for
(
area_above
=
ext
->
btn_id_pr
;
area_above
>
0
;
area_above
--
)
{
if
(
ext
->
button_areas
[
area_above
].
y1
<
ext
->
button_areas
[
ext
->
btn_id_pr
].
y1
&&
pr_center
>=
ext
->
button_areas
[
area_above
].
x1
-
style
->
body
.
padding
.
hor
&&
pr_center
<=
ext
->
button_areas
[
area_above
].
x2
)
{
break
;
}
}
ext
->
btn_id_pr
=
area_above
;
}
lv_obj_invalidate
(
btnm
);
}
else
if
(
c
==
LV_GROUP_KEY_ENTER
||
c
==
LV_GROUP_KEY_ENTER_LONG
)
{
if
(
ext
->
action
!=
NULL
)
{
uint16_t
txt_i
=
get_button_text
(
btnm
,
ext
->
btn_id_pr
);
if
(
txt_i
!=
LV_BTNM_PR_NONE
)
{
...
...
lv_objx/lv_btnm.h
View file @
3a35da8f
...
...
@@ -47,14 +47,14 @@ typedef struct
{
/*No inherited ext.*/
/*Ext. of ancestor*/
/*New data for this type */
const
char
**
map_p
;
/*Pointer to the current map*/
lv_area_t
*
button_areas
;
/*Array of areas of buttons*/
lv_btnm_action_t
action
;
/*A function to call when a button is releases*/
const
char
**
map_p
;
/*Pointer to the current map*/
lv_area_t
*
button_areas
;
/*Array of areas of buttons*/
lv_btnm_action_t
action
;
/*A function to call when a button is releases*/
lv_style_t
*
styles_btn
[
LV_BTN_STATE_NUM
];
/*Styles of buttons in each state*/
uint16_t
btn_cnt
;
/*Number of button in 'map_p'(Handled by the library)*/
uint16_t
btn_id_pr
;
/*Index of the currently pressed button
or LV_BTNM_PR_NONE*/
uint16_t
btn_id_tgl
;
/*Index of the currently toggled button
or LV_BTNM_PR_NONE */
uint8_t
toggle
:
1
;
/*Enable toggling*/
uint16_t
btn_cnt
;
/*Number of button in 'map_p'(Handled by the library)*/
uint16_t
btn_id_pr
;
/*Index of the currently pressed button (in `button_areas`)
or LV_BTNM_PR_NONE*/
uint16_t
btn_id_tgl
;
/*Index of the currently toggled button (in `button_areas`)
or LV_BTNM_PR_NONE */
uint8_t
toggle
:
1
;
/*Enable toggling*/
}
lv_btnm_ext_t
;
typedef
enum
{
...
...
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