fix(color): 'SWITCH' widget option logic, enable for Lua widgets (#4190)

This commit is contained in:
philmoz
2023-10-17 07:22:25 +10:00
committed by GitHub
parent 4128b762dd
commit 1e3f919146
3 changed files with 15 additions and 10 deletions
+9 -4
View File
@@ -149,15 +149,20 @@ ZoneOption *createOptionsArray(int reference, uint8_t maxOptions)
option->type = ZoneOption::Integer;
}
if (option->type == ZoneOption::Integer) {
// set some sensible defaults (only Integer actually uses them)
// set some sensible defaults
option->deflt.signedValue = 0;
option->min.signedValue = -100;
option->max.signedValue = 100;
} else if (option->type == ZoneOption::Switch) {
// set some sensible defaults
option->deflt.signedValue = SWSRC_NONE;
option->min.signedValue = SWSRC_FIRST;
option->max.signedValue = SWSRC_LAST;
}
break;
case 2:
luaL_checktype(lsWidgets, -2, LUA_TNUMBER); // key is number
if (option->type == ZoneOption::Integer) {
if (option->type == ZoneOption::Integer || option->type == ZoneOption::Switch) {
luaL_checktype(lsWidgets, -1, LUA_TNUMBER); // value is number
option->deflt.signedValue = lua_tointeger(lsWidgets, -1);
// TRACE("default signed = %d", option->deflt.signedValue);
@@ -183,14 +188,14 @@ ZoneOption *createOptionsArray(int reference, uint8_t maxOptions)
}
break;
case 3:
if (option->type == ZoneOption::Integer) {
if (option->type == ZoneOption::Integer || option->type == ZoneOption::Switch) {
luaL_checktype(lsWidgets, -2, LUA_TNUMBER); // key is number
luaL_checktype(lsWidgets, -1, LUA_TNUMBER); // value is number
option->min.signedValue = lua_tointeger(lsWidgets, -1);
}
break;
case 4:
if (option->type == ZoneOption::Integer) {
if (option->type == ZoneOption::Integer || option->type == ZoneOption::Switch) {
luaL_checktype(lsWidgets, -2, LUA_TNUMBER); // key is number
luaL_checktype(lsWidgets, -1, LUA_TNUMBER); // value is number
option->max.signedValue = lua_tointeger(lsWidgets, -1);