feat(color): show widget name in settings popups (#5372)
And highlight currently selected widget in selection menu.
This commit is contained in:
@@ -63,6 +63,7 @@ void Widget::openMenu()
|
|||||||
// covers the main view menu
|
// covers the main view menu
|
||||||
Window* w = parent->getFullScreenWindow()->getParent();
|
Window* w = parent->getFullScreenWindow()->getParent();
|
||||||
Menu* menu = new Menu(w ? w : this);
|
Menu* menu = new Menu(w ? w : this);
|
||||||
|
menu->setTitle(getFactory()->getDisplayName());
|
||||||
if (fsAllowed) {
|
if (fsAllowed) {
|
||||||
menu->addLine(STR_WIDGET_FULLSCREEN, [&]() { setFullscreen(true); });
|
menu->addLine(STR_WIDGET_FULLSCREEN, [&]() { setFullscreen(true); });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ static const lv_coord_t line_row_dsc[] = {LV_GRID_CONTENT,
|
|||||||
LV_GRID_TEMPLATE_LAST};
|
LV_GRID_TEMPLATE_LAST};
|
||||||
|
|
||||||
WidgetSettings::WidgetSettings(Window* parent, Widget* w) :
|
WidgetSettings::WidgetSettings(Window* parent, Widget* w) :
|
||||||
BaseDialog(ViewMain::instance(), STR_WIDGET_SETTINGS, true), widget(w)
|
BaseDialog(ViewMain::instance(), w->getFactory()->getDisplayName(), true), widget(w)
|
||||||
{
|
{
|
||||||
FlexGridLayout grid(line_col_dsc, line_row_dsc);
|
FlexGridLayout grid(line_col_dsc, line_row_dsc);
|
||||||
form->padAll(PAD_SMALL);
|
form->padAll(PAD_SMALL);
|
||||||
|
|||||||
@@ -91,8 +91,14 @@ void SetupWidgetsPageSlot::setFocusState()
|
|||||||
void SetupWidgetsPageSlot::addNewWidget(WidgetsContainer* container,
|
void SetupWidgetsPageSlot::addNewWidget(WidgetsContainer* container,
|
||||||
uint8_t slotIndex)
|
uint8_t slotIndex)
|
||||||
{
|
{
|
||||||
|
const char* cur = nullptr;
|
||||||
|
auto w = container->getWidget((slotIndex));
|
||||||
|
if (w) cur = w->getFactory()->getDisplayName();
|
||||||
|
|
||||||
Menu* menu = new Menu(parent);
|
Menu* menu = new Menu(parent);
|
||||||
menu->setTitle(STR_SELECT_WIDGET);
|
menu->setTitle(STR_SELECT_WIDGET);
|
||||||
|
int selected = -1;
|
||||||
|
int index = 0;
|
||||||
for (auto factory : WidgetFactory::getRegisteredWidgets()) {
|
for (auto factory : WidgetFactory::getRegisteredWidgets()) {
|
||||||
menu->addLine(factory->getDisplayName(), [=]() {
|
menu->addLine(factory->getDisplayName(), [=]() {
|
||||||
container->createWidget(slotIndex, factory);
|
container->createWidget(slotIndex, factory);
|
||||||
@@ -100,7 +106,13 @@ void SetupWidgetsPageSlot::addNewWidget(WidgetsContainer* container,
|
|||||||
if (widget->getOptions() && widget->getOptions()->name)
|
if (widget->getOptions() && widget->getOptions()->name)
|
||||||
new WidgetSettings(parent, widget);
|
new WidgetSettings(parent, widget);
|
||||||
});
|
});
|
||||||
|
if (cur && strcmp(cur, factory->getDisplayName()) == 0)
|
||||||
|
selected = index;
|
||||||
|
index += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (selected >= 0)
|
||||||
|
menu->select(selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupWidgetsPage::SetupWidgetsPage(uint8_t customScreenIdx) :
|
SetupWidgetsPage::SetupWidgetsPage(uint8_t customScreenIdx) :
|
||||||
|
|||||||
Reference in New Issue
Block a user