Cosmetcis + add colorchoice

This commit is contained in:
3djc
2021-04-05 09:02:36 +02:00
parent 8ccf3c0437
commit 0ac2a814a1
+15 -8
View File
@@ -34,6 +34,7 @@ WidgetSettings::WidgetSettings(Window * parent, Widget * widget, std::function<v
{ {
auto form = &content->form; auto form = &content->form;
FormGridLayout grid(content->form.width()); FormGridLayout grid(content->form.width());
grid.setLabelWidth(width() / 5);
form->clear(); form->clear();
uint8_t optIdx = 0; uint8_t optIdx = 0;
@@ -63,20 +64,20 @@ WidgetSettings::WidgetSettings(Window * parent, Widget * widget, std::function<v
option.min.unsignedValue, // min option.min.unsignedValue, // min
option.max.unsignedValue, // max option.max.unsignedValue, // max
[=]() -> int16_t { // getValue [=]() -> int16_t { // getValue
return (int16_t)widget->getOptionValue(optIdx)->unsignedValue; return (int16_t) widget->getOptionValue(optIdx)->unsignedValue;
}, },
[=](int16_t newValue) { // setValue [=](int16_t newValue) { // setValue
widget->setOptionValue(optIdx, OPTION_VALUE_UNSIGNED((uint32_t)newValue)); widget->setOptionValue(optIdx, OPTION_VALUE_UNSIGNED((uint32_t) newValue));
}); });
break; break;
case ZoneOption::Bool: case ZoneOption::Bool:
new CheckBox(form, grid.getFieldSlot(), new CheckBox(form, grid.getFieldSlot(),
[=]() -> uint8_t { // getValue [=]() -> uint8_t { // getValue
return (uint8_t)widget->getOptionValue(optIdx)->boolValue; return (uint8_t) widget->getOptionValue(optIdx)->boolValue;
}, },
[=](int8_t newValue) { // setValue [=](int8_t newValue) { // setValue
widget->setOptionValue(optIdx, OPTION_VALUE_BOOL((uint32_t)newValue)); widget->setOptionValue(optIdx, OPTION_VALUE_BOOL((uint32_t) newValue));
}); });
break; break;
@@ -94,10 +95,10 @@ WidgetSettings::WidgetSettings(Window * parent, Widget * widget, std::function<v
auto tmChoice = new Choice(form, grid.getFieldSlot(), auto tmChoice = new Choice(form, grid.getFieldSlot(),
0, TIMERS - 1, 0, TIMERS - 1,
[=]() -> int { // getValue [=]() -> int { // getValue
return (int)widget->getOptionValue(optIdx)->unsignedValue; return (int) widget->getOptionValue(optIdx)->unsignedValue;
}, },
[=](int newValue) { // setValue [=](int newValue) { // setValue
widget->setOptionValue(optIdx, OPTION_VALUE_UNSIGNED((uint32_t)newValue)); widget->setOptionValue(optIdx, OPTION_VALUE_UNSIGNED((uint32_t) newValue));
}); });
tmChoice->setTextHandler([](int value) { tmChoice->setTextHandler([](int value) {
@@ -111,14 +112,20 @@ WidgetSettings::WidgetSettings(Window * parent, Widget * widget, std::function<v
option.min.unsignedValue, // min option.min.unsignedValue, // min
option.max.unsignedValue, // max option.max.unsignedValue, // max
[=]() -> int16_t { // getValue [=]() -> int16_t { // getValue
return (uint8_t)widget->getOptionValue(optIdx)->unsignedValue; return (uint8_t) widget->getOptionValue(optIdx)->unsignedValue;
}, },
[=](int16_t newValue) { // setValue [=](int16_t newValue) { // setValue
widget->setOptionValue(optIdx, OPTION_VALUE_UNSIGNED((uint32_t)newValue)); widget->setOptionValue(optIdx, OPTION_VALUE_UNSIGNED((uint32_t) newValue));
}); });
break; break;
case ZoneOption::Color: case ZoneOption::Color:
new ColorEdit(form, grid.getFieldSlot(), [=]() -> int { // getValue
return (int) widget->getOptionValue(optIdx)->unsignedValue;
},
[=](int newValue) { // setValue
widget->setOptionValue(optIdx, OPTION_VALUE_UNSIGNED((uint32_t) newValue));
});
break; break;
} }