Inputs: update input group label on name changed
This commit is contained in:
committed by
Raphael Coeffic
parent
54a1c48d38
commit
158e2550b9
@@ -36,12 +36,23 @@ static const lv_coord_t row_dsc[] = {
|
||||
LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST,
|
||||
};
|
||||
|
||||
void InputMixGroup::value_changed(lv_event_t* e)
|
||||
{
|
||||
auto obj = lv_event_get_target(e);
|
||||
auto group = (InputMixGroup*)lv_obj_get_user_data(obj);
|
||||
if (!group) return;
|
||||
|
||||
lv_label_set_text(group->label, getSourceString(group->idx));
|
||||
}
|
||||
|
||||
InputMixGroup::InputMixGroup(Window* parent, mixsrc_t idx) :
|
||||
Window(parent, rect_t{}, 0, 0, input_mix_group_create), idx(idx)
|
||||
{
|
||||
lv_obj_set_layout(lvobj, LV_LAYOUT_GRID);
|
||||
lv_obj_set_grid_dsc_array(lvobj, col_dsc, row_dsc);
|
||||
|
||||
lv_obj_add_event_cb(lvobj, InputMixGroup::value_changed,
|
||||
LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
|
||||
label = lv_label_create(lvobj);
|
||||
lv_label_set_text(label, getSourceString(idx));
|
||||
lv_obj_set_grid_cell(label,
|
||||
|
||||
@@ -43,6 +43,8 @@ class InputMixGroup : public Window
|
||||
lv_obj_t* label;
|
||||
lv_obj_t* line_container;
|
||||
|
||||
static void value_changed(lv_event_t* e);
|
||||
|
||||
public:
|
||||
InputMixGroup(Window* parent, mixsrc_t idx);
|
||||
|
||||
|
||||
@@ -383,13 +383,18 @@ void ModelInputsPage::addLineButton(mixsrc_t src, uint8_t index)
|
||||
|
||||
void ModelInputsPage::editInput(uint8_t input, uint8_t index)
|
||||
{
|
||||
auto group = getGroupBySrc(MIXSRC_FIRST_INPUT + input);
|
||||
if (!group) return;
|
||||
|
||||
auto line = getLineByIndex(index);
|
||||
if (!line) return;
|
||||
|
||||
auto line_obj = line->getLvObj();
|
||||
auto group_obj = group->getLvObj();
|
||||
auto edit = new InputEditWindow(input, index);
|
||||
edit->setCloseHandler([=]() {
|
||||
lv_event_send(line_obj, LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
lv_event_send(group_obj, LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user