mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-22 07:02:05 +08:00
feat(btnmatrix) allow NULL terminated array too for the button's list
This commit is contained in:
@@ -89,7 +89,7 @@ lv_obj_t * lv_msgbox_create(lv_obj_t * parent, const char * title, const char *
|
||||
lv_btnmatrix_set_btn_ctrl_all(btns, LV_BTNMATRIX_CTRL_CLICK_TRIG | LV_BTNMATRIX_CTRL_NO_REPEAT);
|
||||
|
||||
uint32_t btn_cnt = 0;
|
||||
while(btn_txts[btn_cnt][0] != '\0') {
|
||||
while(btn_txts[btn_cnt] && btn_txts[btn_cnt][0] != '\0') {
|
||||
btn_cnt++;
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ void lv_btnmatrix_set_map(lv_obj_t * obj, const char * map[])
|
||||
/*Count the lines to calculate button height*/
|
||||
uint8_t row_cnt = 1;
|
||||
uint32_t i;
|
||||
for(i = 0; strlen(map[i]) != 0; i++) {
|
||||
for(i = 0; map[i] && map[i][0] != '\0'; i++) {
|
||||
if(strcmp(map[i], "\n") == 0) row_cnt++;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ void lv_btnmatrix_set_map(lv_obj_t * obj, const char * map[])
|
||||
uint16_t unit_cnt = 0; /*Number of units in a row*/
|
||||
uint16_t btn_cnt = 0; /*Number of buttons in a row*/
|
||||
/*Count the buttons and units in this row*/
|
||||
while(strcmp(map_row[btn_cnt], "\n") != 0 && strlen(map_row[btn_cnt]) != '\0') {
|
||||
while(map_row[btn_cnt] && strcmp(map_row[btn_cnt], "\n") != 0 && map_row[btn_cnt][0] != '\0') {
|
||||
unit_cnt += get_button_width(btnm->ctrl_bits[btn_tot_i + btn_cnt]);
|
||||
btn_cnt++;
|
||||
}
|
||||
@@ -796,7 +796,7 @@ static void allocate_btn_areas_and_controls(const lv_obj_t * obj, const char **
|
||||
/*Count the buttons in the map*/
|
||||
uint16_t btn_cnt = 0;
|
||||
uint16_t i = 0;
|
||||
while(strlen(map[i]) != 0) {
|
||||
while(map[i] && map[i][0] != '\0') {
|
||||
if(strcmp(map[i], "\n") != 0) { /*Do not count line breaks*/
|
||||
btn_cnt++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user