Expand "lv_btnmatrix_set_one_check" to allow radio-button functionality

Right now there is no radio button in lvgl.

It seems like there almost exists this functionality in the btnmatrix widget, when combined with the lv_btnmatrix_set_one_check function.

The only thing missing is that lv_btnmatrix_set_one_check makes it so only one thing can be checked, but it doesn’t make is to that one thing must be checked. With a radio button, one of the options must be selected.

It sounds quite reasonable. I can’t imagine a use case where either 0 or 1 option can to be selected. It should be always 1. So I’d agree to update lv_btnmatrix_set_one_check to ensure there is at least one checked button.

@kisvegabor,
Now that lv_btnmatrix_set_one_check works correctly, there needs to be a way to programmatically set which button is checked. Currently this is not possible, that I can see.

It should be possible using lv_btnmatrix_set_btn_ctrl(btnm, btn_id, LV_BTNMATRIX_CTRL_CHECK_STATE).

This makes it look checked, yes, but doesn’t handle anything else.
That is: it is the only one checked, it is the currently active button, etc.
It should be possible to programmatically check the button and have the same effects that pressing it does.

What about this?

void lv_btnmatrix_set_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl)
{
    LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);

    lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);

    if(btn_id >= ext->btn_cnt) return;

    /*Uncheck all buttons if required*/
    if(ext->one_check && (ctrl & LV_BTNMATRIX_CTRL_CHECKED)) {
        lv_btnmatrix_clear_btn_ctrl_all(btnm, LV_BTNMATRIX_CTRL_CHECKED);
    }

    ext->ctrl_bits[btn_id] |= ctrl;
    invalidate_button_area(btnm, btn_id);
}

That seems sound, but ext->btn_id_act must still be set.

True!
I’ve added it to master.