simplified checks for colorblind mode

This commit is contained in:
Mikayla
2024-03-12 16:24:32 +00:00
parent 89d56d3101
commit 8dae632b25
10 changed files with 43 additions and 34 deletions

View File

@@ -16,7 +16,6 @@ local unit_view = require("coordinator.ui.layout.unit_view")
local core = require("graphics.core")
local flasher = require("graphics.flasher")
local themes = require("graphics.themes")
local DisplayBox = require("graphics.elements.displaybox")
@@ -73,7 +72,7 @@ end
-- apply renderer configurations
---@param config crd_config
function renderer.configure(config)
style.set_themes(config.MainTheme, config.FrontPanelTheme, config.ColorMode ~= themes.COLOR_MODE.STANDARD)
style.set_themes(config.MainTheme, config.FrontPanelTheme, config.ColorMode)
engine.color_mode = config.ColorMode
engine.disable_flow_view = config.DisableFlowView
@@ -135,7 +134,7 @@ function renderer.try_start_fp()
-- show front panel view on terminal
status, msg = pcall(function ()
engine.ui.front_panel = DisplayBox{window=term.native(),fg_bg=style.fp.root}
panel_view(engine.ui.front_panel, #engine.monitors.unit_displays, engine.color_mode)
panel_view(engine.ui.front_panel, #engine.monitors.unit_displays)
end)
if status then

View File

@@ -13,7 +13,6 @@ local style = require("coordinator.ui.style")
local pkt_entry = require("coordinator.ui.components.pkt_entry")
local core = require("graphics.core")
local themes = require("graphics.themes")
local Div = require("graphics.elements.div")
local ListBox = require("graphics.elements.listbox")
@@ -36,8 +35,7 @@ local led_grn = style.led_grn
-- create new front panel view
---@param panel graphics_element main displaybox
---@param num_units integer number of units (number of unit monitors)
---@param color_mode COLOR_MODE color mode
local function init(panel, num_units, color_mode)
local function init(panel, num_units)
local ps = iocontrol.get_db().fp.ps
TextBox{parent=panel,y=1,text="SCADA COORDINATOR",alignment=ALIGN.CENTER,height=1,fg_bg=style.fp_theme.header}
@@ -61,7 +59,7 @@ local function init(panel, num_units, color_mode)
local modem = LED{parent=system,label="MODEM",colors=led_grn}
if color_mode == themes.COLOR_MODE.STANDARD then
if not style.colorblind then
local network = RGBLED{parent=system,label="NETWORK",colors={colors.green,colors.red,colors.orange,colors.yellow,colors.gray}}
network.update(types.PANEL_LINK_STATE.DISCONNECTED)
network.register(ps, "link_state", network.update)

View File

@@ -84,12 +84,13 @@ local deepslate = {
style.theme = smooth_stone
-- set themes per configurations
---@param main integer main theme ID (1 = smooth_stone, 2 = deepslate)
---@param fp integer fp theme ID (1 = sandstone, 2 = basalt)
---@param colorblind boolean true if in a colorblind mode
function style.set_themes(main, fp, colorblind)
style.ind_bkg = colors.gray
---@param main UI_THEME main UI theme
---@param fp FP_THEME front panel theme
---@param color_mode COLOR_MODE the color mode to use
function style.set_themes(main, fp, color_mode)
local colorblind = color_mode ~= themes.COLOR_MODE.STANDARD
style.ind_bkg = colors.gray
style.ind_hi_box_bg = util.trinary(colorblind, colors.black, colors.gray)
if main == themes.UI_THEME.SMOOTH_STONE then
@@ -100,6 +101,8 @@ function style.set_themes(main, fp, colorblind)
style.ind_hi_box_bg = util.trinary(colorblind, colors.black, colors.lightGray)
end
style.colorblind = colorblind
style.root = cpair(style.theme.text, style.theme.bg)
style.label = cpair(style.theme.label, style.theme.bg)