feat(color): Add long press handler for new model curves page (#3091)
This commit is contained in:
@@ -158,6 +158,24 @@ void ModelCurvesPage::presetMenu(FormWindow * window, uint8_t index)
|
|||||||
menu->updateLines();
|
menu->updateLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModelCurvesPage::plusPopup(FormWindow * window)
|
||||||
|
{
|
||||||
|
CurveHeader &curve = g_model.curves[addIndex];
|
||||||
|
int8_t * points = curveAddress(addIndex);
|
||||||
|
|
||||||
|
Menu *menu = new Menu(window);
|
||||||
|
menu->setTitle(STR_NEW);
|
||||||
|
menu->addLine(STR_EDIT, [=]() {
|
||||||
|
focusIndex = addIndex;
|
||||||
|
initPoints(curve, points);
|
||||||
|
editCurve(window, addIndex);
|
||||||
|
});
|
||||||
|
menu->addLine(STR_CURVE_PRESET, [=]() {
|
||||||
|
focusIndex = addIndex;
|
||||||
|
presetMenu(window, addIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void ModelCurvesPage::build(FormWindow * window)
|
void ModelCurvesPage::build(FormWindow * window)
|
||||||
{
|
{
|
||||||
#if LCD_W > LCD_H
|
#if LCD_W > LCD_H
|
||||||
@@ -194,6 +212,7 @@ void ModelCurvesPage::build(FormWindow * window)
|
|||||||
auto button = new CurveButton(line, rect_t{0, 0, CURVE_BTN_W, CURVE_BTH_H}, index);
|
auto button = new CurveButton(line, rect_t{0, 0, CURVE_BTN_W, CURVE_BTH_H}, index);
|
||||||
button->setPressHandler([=]() -> uint8_t {
|
button->setPressHandler([=]() -> uint8_t {
|
||||||
Menu * menu = new Menu(window);
|
Menu * menu = new Menu(window);
|
||||||
|
menu->setTitle(STR_CURVE);
|
||||||
menu->addLine(STR_EDIT, [=]() {
|
menu->addLine(STR_EDIT, [=]() {
|
||||||
editCurve(window, index);
|
editCurve(window, index);
|
||||||
});
|
});
|
||||||
@@ -215,6 +234,14 @@ void ModelCurvesPage::build(FormWindow * window)
|
|||||||
focusIndex = index;
|
focusIndex = index;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
button->setLongPressHandler([=]() -> uint8_t {
|
||||||
|
if (addButton) {
|
||||||
|
lv_group_focus_obj(addButton->getLvObj());
|
||||||
|
plusPopup(window);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
if (!firstCurveButton) {
|
if (!firstCurveButton) {
|
||||||
firstCurveIndex = index;
|
firstCurveIndex = index;
|
||||||
firstCurveButton = button;
|
firstCurveButton = button;
|
||||||
@@ -243,24 +270,13 @@ void ModelCurvesPage::build(FormWindow * window)
|
|||||||
lv_obj_set_grid_align(line->getLvObj(), LV_GRID_ALIGN_SPACE_BETWEEN, LV_GRID_ALIGN_SPACE_BETWEEN);
|
lv_obj_set_grid_align(line->getLvObj(), LV_GRID_ALIGN_SPACE_BETWEEN, LV_GRID_ALIGN_SPACE_BETWEEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
CurveHeader &curve = g_model.curves[n];
|
addIndex = n;
|
||||||
int8_t * points = curveAddress(n);
|
addButton = new TextButton(line, rect_t{0, 0, CURVE_BTN_W, CURVE_BTH_H}, LV_SYMBOL_PLUS, [=]() {
|
||||||
|
plusPopup(window);
|
||||||
auto button = new TextButton(line, rect_t{0, 0, CURVE_BTN_W, CURVE_BTH_H}, LV_SYMBOL_PLUS, [=]() {
|
|
||||||
Menu *menu = new Menu(window);
|
|
||||||
menu->addLine(STR_EDIT, [=]() {
|
|
||||||
focusIndex = n;
|
|
||||||
initPoints(curve, points);
|
|
||||||
editCurve(window, n);
|
|
||||||
});
|
|
||||||
menu->addLine(STR_CURVE_PRESET, [=]() {
|
|
||||||
focusIndex = n;
|
|
||||||
presetMenu(window, n);
|
|
||||||
});
|
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
lv_obj_set_grid_cell(button->getLvObj(), LV_GRID_ALIGN_CENTER, curveIndex % PER_ROW, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
lv_obj_set_grid_cell(addButton->getLvObj(), LV_GRID_ALIGN_CENTER, curveIndex % PER_ROW, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,10 +33,13 @@ class ModelCurvesPage: public PageTab {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint8_t focusIndex = -1;
|
uint8_t focusIndex = -1;
|
||||||
|
Button* addButton = nullptr;
|
||||||
|
uint8_t addIndex = -1;
|
||||||
|
|
||||||
void rebuild(FormWindow * window);
|
void rebuild(FormWindow * window);
|
||||||
void editCurve(FormWindow * window, uint8_t curve);
|
void editCurve(FormWindow * window, uint8_t curve);
|
||||||
void presetMenu(FormWindow * window, uint8_t index);
|
void presetMenu(FormWindow * window, uint8_t index);
|
||||||
|
void plusPopup(FormWindow * window);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _MODEL_CURVES_H_
|
#endif // _MODEL_CURVES_H_
|
||||||
|
|||||||
Reference in New Issue
Block a user