mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#344 radio button appearance changes
This commit is contained in:
parent
b173b72f21
commit
7a87499aa4
@ -22,7 +22,7 @@ local sounder = require("coordinator.sounder")
|
|||||||
|
|
||||||
local apisessions = require("coordinator.session.apisessions")
|
local apisessions = require("coordinator.session.apisessions")
|
||||||
|
|
||||||
local COORDINATOR_VERSION = "v1.0.12"
|
local COORDINATOR_VERSION = "v1.0.13"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
|
@ -241,7 +241,7 @@ local function new_view(root, x, y)
|
|||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
local ctl_opts = { "Monitored Max Burn", "Combined Burn Rate", "Charge Level", "Generation Rate" }
|
local ctl_opts = { "Monitored Max Burn", "Combined Burn Rate", "Charge Level", "Generation Rate" }
|
||||||
local mode = RadioButton{parent=proc,x=34,y=1,options=ctl_opts,callback=function()end,radio_colors=cpair(colors.white,colors.black),radio_bg=colors.purple}
|
local mode = RadioButton{parent=proc,x=34,y=1,options=ctl_opts,callback=function()end,radio_colors=cpair(colors.gray,colors.white),select_color=colors.purple}
|
||||||
|
|
||||||
mode.register(facility.ps, "process_mode", mode.set_value)
|
mode.register(facility.ps, "process_mode", mode.set_value)
|
||||||
|
|
||||||
@ -335,7 +335,7 @@ local function new_view(root, x, y)
|
|||||||
|
|
||||||
status.register(facility.ps, "current_waste_product", status.update)
|
status.register(facility.ps, "current_waste_product", status.update)
|
||||||
|
|
||||||
local waste_prod = RadioButton{parent=rect,x=2,y=3,options=style.waste.options,callback=process.set_process_waste,radio_colors=cpair(colors.white,colors.black),radio_bg=colors.brown}
|
local waste_prod = RadioButton{parent=rect,x=2,y=3,options=style.waste.options,callback=process.set_process_waste,radio_colors=cpair(colors.gray,colors.white),select_color=colors.brown}
|
||||||
local pu_fallback = Checkbox{parent=rect,x=2,y=7,label="Pu Fallback",callback=process.set_pu_fallback,box_fg_bg=cpair(colors.green,colors.black)}
|
local pu_fallback = Checkbox{parent=rect,x=2,y=7,label="Pu Fallback",callback=process.set_pu_fallback,box_fg_bg=cpair(colors.green,colors.black)}
|
||||||
|
|
||||||
waste_prod.register(facility.ps, "process_waste_product", waste_prod.set_value)
|
waste_prod.register(facility.ps, "process_waste_product", waste_prod.set_value)
|
||||||
|
@ -476,7 +476,7 @@ local function init(parent, id)
|
|||||||
|
|
||||||
local ctl_opts = { "Manual", "Primary", "Secondary", "Tertiary", "Backup" }
|
local ctl_opts = { "Manual", "Primary", "Secondary", "Tertiary", "Backup" }
|
||||||
|
|
||||||
local group = RadioButton{parent=auto_div,options=ctl_opts,callback=function()end,radio_colors=cpair(colors.blue,colors.white),radio_bg=colors.gray}
|
local group = RadioButton{parent=auto_div,options=ctl_opts,callback=function()end,radio_colors=cpair(colors.gray,colors.white),select_color=colors.purple}
|
||||||
|
|
||||||
group.register(u_ps, "auto_group_id", function (gid) group.set_value(gid + 1) end)
|
group.register(u_ps, "auto_group_id", function (gid) group.set_value(gid + 1) end)
|
||||||
|
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
-- Radio Button Graphics Element
|
-- Radio Button Graphics Element
|
||||||
|
|
||||||
|
local util = require("scada-common.util")
|
||||||
|
|
||||||
local core = require("graphics.core")
|
local core = require("graphics.core")
|
||||||
local element = require("graphics.element")
|
local element = require("graphics.element")
|
||||||
|
|
||||||
---@class radio_button_args
|
---@class radio_button_args
|
||||||
---@field options table button options
|
---@field options table button options
|
||||||
---@field callback function function to call on touch
|
---@field callback function function to call on touch
|
||||||
---@field radio_colors cpair colors for radio button center dot when active (a) or inactive (b)
|
---@field radio_colors cpair radio button colors (inner & outer)
|
||||||
---@field radio_bg color background color of radio button
|
---@field select_color color color for radio button border when selected
|
||||||
---@field default? integer default state, defaults to options[1]
|
---@field default? integer default state, defaults to options[1]
|
||||||
---@field min_width? integer text length + 2 if omitted
|
---@field min_width? integer text length + 2 if omitted
|
||||||
---@field parent graphics_element
|
---@field parent graphics_element
|
||||||
@ -24,6 +26,8 @@ local function radio_button(args)
|
|||||||
assert(type(args.options) == "table", "graphics.elements.controls.radio_button: options is a required field")
|
assert(type(args.options) == "table", "graphics.elements.controls.radio_button: options is a required field")
|
||||||
assert(#args.options > 0, "graphics.elements.controls.radio_button: at least one option is required")
|
assert(#args.options > 0, "graphics.elements.controls.radio_button: at least one option is required")
|
||||||
assert(type(args.callback) == "function", "graphics.elements.controls.radio_button: callback is a required field")
|
assert(type(args.callback) == "function", "graphics.elements.controls.radio_button: callback is a required field")
|
||||||
|
assert(type(args.radio_colors) == "table", "graphics.elements.controls.radio_button: radio_colors is a required field")
|
||||||
|
assert(type(args.select_color) == "number", "graphics.elements.controls.radio_button: select_color is a required field")
|
||||||
assert(type(args.default) == "nil" or (type(args.default) == "number" and args.default > 0),
|
assert(type(args.default) == "nil" or (type(args.default) == "number" and args.default > 0),
|
||||||
"graphics.elements.controls.radio_button: default must be nil or a number > 0")
|
"graphics.elements.controls.radio_button: default must be nil or a number > 0")
|
||||||
assert(type(args.min_width) == "nil" or (type(args.min_width) == "number" and args.min_width > 0),
|
assert(type(args.min_width) == "nil" or (type(args.min_width) == "number" and args.min_width > 0),
|
||||||
@ -56,21 +60,16 @@ local function radio_button(args)
|
|||||||
for i = 1, #args.options do
|
for i = 1, #args.options do
|
||||||
local opt = args.options[i] ---@type string
|
local opt = args.options[i] ---@type string
|
||||||
|
|
||||||
|
local inner_color = util.trinary(e.value == i, args.radio_colors.color_b, args.radio_colors.color_a)
|
||||||
|
local outer_color = util.trinary(e.value == i, args.select_color, args.radio_colors.color_b)
|
||||||
|
|
||||||
e.w_set_cur(1, i)
|
e.w_set_cur(1, i)
|
||||||
|
|
||||||
if e.value == i then
|
e.w_set_fgd(inner_color)
|
||||||
-- show as selected
|
e.w_set_bkg(outer_color)
|
||||||
e.w_set_fgd(args.radio_colors.color_a)
|
|
||||||
e.w_set_bkg(args.radio_bg)
|
|
||||||
else
|
|
||||||
-- show as unselected
|
|
||||||
e.w_set_fgd(args.radio_colors.color_b)
|
|
||||||
e.w_set_bkg(args.radio_bg)
|
|
||||||
end
|
|
||||||
|
|
||||||
e.w_write("\x88")
|
e.w_write("\x88")
|
||||||
|
|
||||||
e.w_set_fgd(args.radio_bg)
|
e.w_set_fgd(outer_color)
|
||||||
e.w_set_bkg(e.fg_bg.bkg)
|
e.w_set_bkg(e.fg_bg.bkg)
|
||||||
e.w_write("\x95")
|
e.w_write("\x95")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user