feat(color): telemetry queues for Lua, enhance default widget options (#5926)
This commit is contained in:
@@ -109,7 +109,7 @@ void InputMixButtonBase::setSource(mixsrc_t idx)
|
||||
else
|
||||
lv_obj_clear_state(source, LV_STATE_USER_1);
|
||||
|
||||
lv_label_set_text(source, s);
|
||||
lv_label_set_text(source, s);
|
||||
}
|
||||
|
||||
void InputMixButtonBase::setOpts(const char* s)
|
||||
|
||||
@@ -49,7 +49,7 @@ class LayoutFactory
|
||||
|
||||
virtual const uint8_t* getBitmap() const = 0;
|
||||
|
||||
virtual const ZoneOption* getOptions() const = 0;
|
||||
virtual const ZoneOption* getLayoutOptions() const = 0;
|
||||
|
||||
virtual WidgetsContainer* create(
|
||||
Window* parent, LayoutPersistentData* persistentData) const = 0;
|
||||
|
||||
@@ -98,8 +98,6 @@ class Layout: public LayoutBase
|
||||
return getOptionValue(LAYOUT_OPTION_MIRRORED)->boolValue;
|
||||
}
|
||||
|
||||
virtual bool isAppMode() const { return false; }
|
||||
|
||||
// Set decoration visibility
|
||||
void setTrimsVisible(bool visible);
|
||||
void setSlidersVisible(bool visible);
|
||||
@@ -182,7 +180,7 @@ class BaseLayoutFactory: public LayoutFactory
|
||||
|
||||
const uint8_t* getBitmap() const override { return bitmap; }
|
||||
|
||||
const ZoneOption * getOptions() const override
|
||||
const ZoneOption * getLayoutOptions() const override
|
||||
{
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ void ScreenSetupPage::buildLayoutOptions()
|
||||
if (!factory) return;
|
||||
|
||||
int index = 0;
|
||||
for (auto* option = factory->getOptions(); option->name; option++, index++) {
|
||||
for (auto* option = factory->getLayoutOptions(); option->name; option++, index++) {
|
||||
auto layoutData = &g_model.screenData[customScreenIndex].layoutData;
|
||||
ZoneOptionValue* value = &layoutData->options[index].value;
|
||||
|
||||
|
||||
@@ -57,13 +57,13 @@ void Widget::openMenu()
|
||||
return;
|
||||
}
|
||||
|
||||
if (getOptions() || fsAllowed) {
|
||||
if (hasOptions() || fsAllowed) {
|
||||
Menu* menu = new Menu();
|
||||
menu->setTitle(getFactory()->getDisplayName());
|
||||
if (fsAllowed) {
|
||||
menu->addLine(STR_WIDGET_FULLSCREEN, [&]() { setFullscreen(true); });
|
||||
}
|
||||
if (getOptions() && getOptions()->name) {
|
||||
if (hasOptions()) {
|
||||
menu->addLine(STR_WIDGET_SETTINGS,
|
||||
[=]() { new WidgetSettings(this); });
|
||||
}
|
||||
@@ -146,9 +146,9 @@ bool Widget::onLongPress()
|
||||
return true;
|
||||
}
|
||||
|
||||
const ZoneOption* Widget::getOptions() const
|
||||
const ZoneOption* Widget::getOptionDefinitions() const
|
||||
{
|
||||
return getFactory()->getOptions();
|
||||
return getFactory()->getDefaultOptions();
|
||||
}
|
||||
|
||||
void Widget::enableFocus(bool enable)
|
||||
@@ -253,6 +253,7 @@ void WidgetFactory::initPersistentData(Widget::PersistentData* persistentData,
|
||||
{
|
||||
if (setDefault) {
|
||||
memset(persistentData, 0, sizeof(Widget::PersistentData));
|
||||
parseOptionDefaults();
|
||||
}
|
||||
if (options) {
|
||||
int i = 0;
|
||||
|
||||
@@ -42,7 +42,8 @@ class Widget : public ButtonBase
|
||||
|
||||
const WidgetFactory* getFactory() const { return factory; }
|
||||
|
||||
const ZoneOption* getOptions() const;
|
||||
const ZoneOption* getOptionDefinitions() const;
|
||||
bool hasOptions() const { return getOptionDefinitions() && getOptionDefinitions()->name; }
|
||||
|
||||
virtual const char* getErrorMessage() const { return nullptr; }
|
||||
|
||||
@@ -117,7 +118,8 @@ class WidgetFactory
|
||||
|
||||
const char* getName() const { return name; }
|
||||
|
||||
const ZoneOption* getOptions() const { return options; }
|
||||
const ZoneOption* getDefaultOptions() const { return options; }
|
||||
virtual const void parseOptionDefaults() const {}
|
||||
|
||||
const char* getDisplayName() const
|
||||
{
|
||||
|
||||
@@ -49,7 +49,8 @@ WidgetSettings::WidgetSettings(Widget* w) :
|
||||
FlexGridLayout grid(line_col_dsc, line_row_dsc, PAD_TINY);
|
||||
|
||||
uint8_t optIdx = 0;
|
||||
auto opt = widget->getOptions();
|
||||
auto opt = widget->getOptionDefinitions();
|
||||
|
||||
while (opt && opt->name != nullptr) {
|
||||
auto line = form->newLine(grid);
|
||||
|
||||
|
||||
@@ -85,5 +85,6 @@ class WidgetsContainer: public Window
|
||||
virtual void runBackground() = 0;
|
||||
|
||||
virtual bool isLayout() { return false; }
|
||||
virtual bool isAppMode() const { return false; }
|
||||
bool isWidgetsContainer() override { return true; }
|
||||
};
|
||||
|
||||
@@ -41,7 +41,7 @@ SetupWidgetsPageSlot::SetupWidgetsPageSlot(Window* parent, const rect_t& rect,
|
||||
menu->addLine(STR_SELECT_WIDGET,
|
||||
[=]() { addNewWidget(container, slotIndex); });
|
||||
auto widget = container->getWidget(slotIndex);
|
||||
if (widget->getOptions() && widget->getOptions()->name)
|
||||
if (widget->hasOptions())
|
||||
menu->addLine(STR_WIDGET_SETTINGS,
|
||||
[=]() { new WidgetSettings(widget); });
|
||||
menu->addLine(STR_REMOVE_WIDGET,
|
||||
@@ -103,7 +103,7 @@ void SetupWidgetsPageSlot::addNewWidget(WidgetsContainer* container,
|
||||
menu->addLine(factory->getDisplayName(), [=]() {
|
||||
container->createWidget(slotIndex, factory);
|
||||
auto widget = container->getWidget(slotIndex);
|
||||
if (widget->getOptions() && widget->getOptions()->name)
|
||||
if (widget->hasOptions())
|
||||
new WidgetSettings(widget);
|
||||
});
|
||||
if (cur && strcmp(cur, factory->getDisplayName()) == 0)
|
||||
|
||||
@@ -133,6 +133,8 @@ StandaloneLuaWindow::StandaloneLuaWindow(bool useLvgl, int initFn, int runFn) :
|
||||
|
||||
etx_solid_bg(lvobj);
|
||||
|
||||
luaScriptManager = this;
|
||||
|
||||
if (useLvglLayout()) {
|
||||
padAll(PAD_ZERO);
|
||||
etx_scrollbar(lvobj);
|
||||
@@ -146,8 +148,6 @@ StandaloneLuaWindow::StandaloneLuaWindow(bool useLvgl, int initFn, int runFn) :
|
||||
lv_obj_set_style_text_align(lbl, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_top(lbl, (LCD_H - EdgeTxStyles::PAGE_LINE_HEIGHT) / 2, LV_PART_MAIN);
|
||||
lv_label_set_text(lbl, STR_LOADING);
|
||||
|
||||
luaLvglManager = this;
|
||||
} else {
|
||||
lcdBuffer = new BitmapBuffer(BMP_RGB565, LCD_W, LCD_H);
|
||||
|
||||
@@ -218,7 +218,7 @@ void StandaloneLuaWindow::deleteLater(bool detach, bool trash)
|
||||
if (lcdBuffer) delete lcdBuffer;
|
||||
lcdBuffer = nullptr;
|
||||
|
||||
luaLvglManager = nullptr;
|
||||
luaScriptManager = nullptr;
|
||||
|
||||
Layer::pop(this);
|
||||
Layer::back()->show();
|
||||
@@ -320,13 +320,13 @@ void StandaloneLuaWindow::checkEvents()
|
||||
luaLcdAllowed = false;
|
||||
}
|
||||
|
||||
void StandaloneLuaWindow::onClicked() { Keyboard::hide(false); LuaEventHandler::onClicked(); }
|
||||
void StandaloneLuaWindow::onClicked() { Keyboard::hide(false); LuaScriptManager::onClickedEvent(); }
|
||||
|
||||
void StandaloneLuaWindow::onCancel() { LuaEventHandler::onCancel(); }
|
||||
void StandaloneLuaWindow::onCancel() { LuaScriptManager::onCancelEvent(); }
|
||||
|
||||
void StandaloneLuaWindow::onEvent(event_t evt)
|
||||
{
|
||||
LuaEventHandler::onLuaEvent(evt);
|
||||
LuaScriptManager::onLuaEvent(evt);
|
||||
}
|
||||
|
||||
void StandaloneLuaWindow::popupPaint(BitmapBuffer* dc, coord_t x, coord_t y, coord_t w, coord_t h,
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
extern void luaExecStandalone(const char * filename);
|
||||
|
||||
class StandaloneLuaWindow : public Window, public LuaEventHandler, public LuaLvglManager
|
||||
class StandaloneLuaWindow : public Window, public LuaScriptManager
|
||||
{
|
||||
static StandaloneLuaWindow* _instance;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user