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
e6dafd61
Commit
e6dafd61
authored
Jan 06, 2017
by
Gabor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lv_btnm: with a lot of buttons in row there was a minor position error
parent
446c86a3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
lv_btnm.c
lv_objx/lv_btnm.c
+10
-5
No files found.
lv_objx/lv_btnm.c
View file @
e6dafd61
...
@@ -216,7 +216,8 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
...
@@ -216,7 +216,8 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
/* Count the units and the buttons in a line
/* Count the units and the buttons in a line
* (A button can be 1,2,3... unit wide)*/
* (A button can be 1,2,3... unit wide)*/
uint16_t
unit_cnt
;
uint16_t
unit_cnt
;
/*Number of units in a row*/
uint16_t
unit_act_cnt
;
/*Number of units currently put in a row*/
uint16_t
btn_cnt
;
/*Number of buttons in a row*/
uint16_t
btn_cnt
;
/*Number of buttons in a row*/
uint16_t
i_tot
=
0
;
/*Act. index in the str map*/
uint16_t
i_tot
=
0
;
/*Act. index in the str map*/
uint16_t
btn_i
=
0
;
/*Act. index of button areas*/
uint16_t
btn_i
=
0
;
/*Act. index of button areas*/
...
@@ -243,17 +244,22 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
...
@@ -243,17 +244,22 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
uint16_t
i
;
uint16_t
i
;
cord_t
act_x
=
btnms
->
rects
.
hpad
;
cord_t
act_x
=
btnms
->
rects
.
hpad
;
cord_t
act_unit_w
;
cord_t
act_unit_w
;
unit_act_cnt
=
0
;
for
(
i
=
0
;
i
<
btn_cnt
;
i
++
)
{
for
(
i
=
0
;
i
<
btn_cnt
;
i
++
)
{
/* one_unit_w = all_unit_w / unit_cnt
/* one_unit_w = all_unit_w / unit_cnt
* act_unit_w = one_unit_w * button_width
* act_unit_w = one_unit_w * button_width
* do this two operation but the multipl
ications
first to divide a greater number */
* do this two operation but the multipl
y
first to divide a greater number */
act_unit_w
=
(
all_unit_w
*
lv_btnm_get_width_unit
(
map_p_tmp
[
i
]))
/
unit_cnt
;
act_unit_w
=
(
all_unit_w
*
lv_btnm_get_width_unit
(
map_p_tmp
[
i
]))
/
unit_cnt
;
/*Always recalculate act_x because of rounding errors */
act_x
=
(
unit_act_cnt
*
all_unit_w
)
/
unit_cnt
+
i
*
btnms
->
rects
.
opad
+
btnms
->
rects
.
hpad
;
area_set
(
&
ext
->
btn_areas
[
btn_i
],
act_x
,
area_set
(
&
ext
->
btn_areas
[
btn_i
],
act_x
,
act_y
,
act_y
,
act_x
+
act_unit_w
,
act_x
+
act_unit_w
,
act_y
+
btn_h
);
act_y
+
btn_h
);
act_x
+=
act_unit_w
+
btnms
->
rects
.
opad
;
unit_act_cnt
+=
lv_btnm_get_width_unit
(
map_p_tmp
[
i
])
;
i_tot
++
;
i_tot
++
;
btn_i
++
;
btn_i
++
;
...
@@ -266,7 +272,6 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
...
@@ -266,7 +272,6 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
}
}
lv_obj_inv
(
btnm
);
lv_obj_inv
(
btnm
);
}
}
/**
/**
...
@@ -388,7 +393,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_
...
@@ -388,7 +393,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_
lv_rects_t
new_rects
;
lv_rects_t
new_rects
;
lv_btn_state_t
state
;
lv_btn_state_t
state
;
state
=
ext
->
btn_pr
==
btn_i
?
LV_BTN_STATE_PR
:
LV_BTN_STATE_REL
;
state
=
ext
->
btn_pr
==
btn_i
?
LV_BTN_STATE_PR
:
LV_BTN_STATE_REL
;
memcpy
(
&
new_rects
,
&
style
->
rect
s
,
sizeof
(
lv_rects_t
));
memcpy
(
&
new_rects
,
&
style
->
btn
s
,
sizeof
(
lv_rects_t
));
new_rects
.
objs
.
color
=
style
->
btns
.
mcolor
[
state
];
new_rects
.
objs
.
color
=
style
->
btns
.
mcolor
[
state
];
new_rects
.
gcolor
=
style
->
btns
.
gcolor
[
state
];
new_rects
.
gcolor
=
style
->
btns
.
gcolor
[
state
];
new_rects
.
bcolor
=
style
->
btns
.
bcolor
[
state
];
new_rects
.
bcolor
=
style
->
btns
.
bcolor
[
state
];
...
...
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