(fw) Remove new label from menu, rework layout
This commit is contained in:
@@ -148,7 +148,12 @@ class ButtonHolder : public FormWindow
|
|||||||
|
|
||||||
// New label button
|
// New label button
|
||||||
auto btn = new TextButton(
|
auto btn = new TextButton(
|
||||||
this, rect_t{}, "New",
|
this, rect_t{},
|
||||||
|
#if LCD_W > LCD_H
|
||||||
|
STR_NEW,
|
||||||
|
#else
|
||||||
|
STR_NEW_LABEL,
|
||||||
|
#endif
|
||||||
[=]() {
|
[=]() {
|
||||||
if(_newLabelHandler) _newLabelHandler();
|
if(_newLabelHandler) _newLabelHandler();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -224,7 +229,6 @@ class ButtonHolder : public FormWindow
|
|||||||
});
|
});
|
||||||
|
|
||||||
ButtonInfo bi = {tb, state1Bm, state2Bm, 0};
|
ButtonInfo bi = {tb, state1Bm, state2Bm, 0};
|
||||||
|
|
||||||
_buttons.push_back(bi);
|
_buttons.push_back(bi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -590,6 +594,7 @@ void ModelLabelsWindow::newModel()
|
|||||||
|
|
||||||
void ModelLabelsWindow::newLabel()
|
void ModelLabelsWindow::newLabel()
|
||||||
{
|
{
|
||||||
|
tmpLabel[0] = '\0';
|
||||||
new LabelDialog(parent, tmpLabel, [=](std::string label) {
|
new LabelDialog(parent, tmpLabel, [=](std::string label) {
|
||||||
int newlabindex = modelslabels.addLabel(label);
|
int newlabindex = modelslabels.addLabel(label);
|
||||||
if (newlabindex >= 0) {
|
if (newlabindex >= 0) {
|
||||||
@@ -629,7 +634,7 @@ static const lv_coord_t col_dsc[] = {LABELS_WIDTH, LV_GRID_FR(1), LV_GRID_TEMPLA
|
|||||||
static const lv_coord_t row_dsc[] = {LV_GRID_FR(1), BUTTONS_HEIGHT, LV_GRID_TEMPLATE_LAST};
|
static const lv_coord_t row_dsc[] = {LV_GRID_FR(1), BUTTONS_HEIGHT, LV_GRID_TEMPLATE_LAST};
|
||||||
#else
|
#else
|
||||||
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
||||||
static const lv_coord_t row_dsc[] = {LABELS_HEIGHT, LV_GRID_FR(1), BUTTONS_HEIGHT, LV_GRID_TEMPLATE_LAST};
|
static const lv_coord_t row_dsc[] = {LV_GRID_FR(1), LABELS_HEIGHT, BUTTONS_HEIGHT, LV_GRID_TEMPLATE_LAST};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ModelLabelsWindow::buildBody(FormWindow *window)
|
void ModelLabelsWindow::buildBody(FormWindow *window)
|
||||||
@@ -652,26 +657,30 @@ void ModelLabelsWindow::buildBody(FormWindow *window)
|
|||||||
btnh->setNewLabelHandler(std::bind(&ModelLabelsWindow::newLabel, this));
|
btnh->setNewLabelHandler(std::bind(&ModelLabelsWindow::newLabel, this));
|
||||||
auto buth_obj = btnh->getLvObj();
|
auto buth_obj = btnh->getLvObj();
|
||||||
|
|
||||||
// Labels top left
|
|
||||||
lv_obj_set_grid_cell(lbl_obj, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_STRETCH, 0, 1);
|
|
||||||
|
|
||||||
window->padAll(LAY_MARGIN);
|
window->padAll(LAY_MARGIN);
|
||||||
window->padRow(LAY_MARGIN);
|
window->padRow(LAY_MARGIN);
|
||||||
window->padColumn(LAY_MARGIN);
|
window->padColumn(LAY_MARGIN);
|
||||||
|
|
||||||
#if LCD_W > LCD_H
|
#if LCD_W > LCD_H
|
||||||
|
// Labels top left
|
||||||
|
lv_obj_set_grid_cell(lbl_obj, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_STRETCH, 0, 1);
|
||||||
|
|
||||||
// Buttons bottom left
|
// Buttons bottom left
|
||||||
// Models right
|
|
||||||
lv_obj_set_grid_cell(mdl_obj, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_STRETCH, 0, 2);
|
lv_obj_set_grid_cell(mdl_obj, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_STRETCH, 0, 2);
|
||||||
lv_obj_set_width(mdl_obj, lv_pct(100));
|
lv_obj_set_width(mdl_obj, lv_pct(100));
|
||||||
window->padRight(0);
|
window->padRight(0);
|
||||||
|
|
||||||
|
// Models right
|
||||||
lv_obj_set_grid_cell(buth_obj, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_STRETCH, 1, 1);
|
lv_obj_set_grid_cell(buth_obj, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_STRETCH, 1, 1);
|
||||||
#else
|
#else
|
||||||
// Models middle
|
// Models top
|
||||||
// Buttons bottom
|
lv_obj_set_grid_cell(mdl_obj, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_STRETCH, 0, 1);
|
||||||
lv_obj_set_grid_cell(mdl_obj, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_STRETCH, 1, 1);
|
|
||||||
lv_obj_set_width(mdl_obj, lv_pct(100));
|
lv_obj_set_width(mdl_obj, lv_pct(100));
|
||||||
|
|
||||||
|
// Labels middle
|
||||||
|
lv_obj_set_grid_cell(lbl_obj, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_STRETCH, 1, 1);
|
||||||
|
|
||||||
|
// Buttons bottom
|
||||||
lv_obj_set_grid_cell(buth_obj, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_STRETCH, 2, 1);
|
lv_obj_set_grid_cell(buth_obj, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_STRETCH, 2, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -688,9 +697,6 @@ void ModelLabelsWindow::buildBody(FormWindow *window)
|
|||||||
mdlselector->setSortOrder(sort);
|
mdlselector->setSortOrder(sort);
|
||||||
});
|
});
|
||||||
|
|
||||||
//lv_obj_align(btnh->getLvObj(), LV_ALIGN_BOTTOM_LEFT, 0, 0);
|
|
||||||
|
|
||||||
|
|
||||||
lblselector->setMultiSelect(true);
|
lblselector->setMultiSelect(true);
|
||||||
lblselector->setSelected(modelslabels.filteredLabels());
|
lblselector->setSelected(modelslabels.filteredLabels());
|
||||||
updateFilteredLabels(modelslabels.filteredLabels(), false);
|
updateFilteredLabels(modelslabels.filteredLabels(), false);
|
||||||
@@ -724,20 +730,15 @@ void ModelLabelsWindow::buildBody(FormWindow *window)
|
|||||||
auto labels = getLabels();
|
auto labels = getLabels();
|
||||||
|
|
||||||
if (selected < (int)labels.size()) {
|
if (selected < (int)labels.size()) {
|
||||||
Menu *menu = new Menu(window);
|
|
||||||
std::string selectedLabel = labels.at(selected);
|
std::string selectedLabel = labels.at(selected);
|
||||||
menu->setTitle(selectedLabel);
|
|
||||||
tmpLabel[0] = '\0';
|
|
||||||
menu->addLine(STR_NEW_LABEL, [=]() {
|
|
||||||
newLabel();
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
if (selectedLabel != STR_UNLABELEDMODEL) {
|
if (selectedLabel != STR_UNLABELEDMODEL) {
|
||||||
|
Menu *menu = new Menu(window);
|
||||||
|
menu->setTitle(selectedLabel);
|
||||||
menu->addLine(STR_RENAME_LABEL, [=]() {
|
menu->addLine(STR_RENAME_LABEL, [=]() {
|
||||||
auto oldLabel = labels[selected];
|
auto oldLabel = labels[selected];
|
||||||
strncpy(tmpLabel, oldLabel.c_str(), MAX_LABEL_SIZE);
|
strncpy(tmpLabel, oldLabel.c_str(), MAX_LABEL_SIZE);
|
||||||
tmpLabel[MAX_LABEL_SIZE] = '\0';
|
tmpLabel[MAX_LABEL_SIZE] = '\0';
|
||||||
|
|
||||||
new LabelDialog(this, tmpLabel, [=](std::string newLabel) {
|
new LabelDialog(this, tmpLabel, [=](std::string newLabel) {
|
||||||
auto rndialog =
|
auto rndialog =
|
||||||
new ProgressDialog(this, STR_RENAME_LABEL, [=]() {});
|
new ProgressDialog(this, STR_RENAME_LABEL, [=]() {});
|
||||||
|
|||||||
Reference in New Issue
Block a user