updated type hints for remaining graphics_element generic types

This commit is contained in:
Mikayla 2024-09-26 21:23:50 +00:00
parent ec1fc13ae7
commit 17e53fdba2
38 changed files with 54 additions and 52 deletions

View File

@ -302,7 +302,7 @@ local function load_settings(target, raw)
end end
-- create the config view -- create the config view
---@param display graphics_element ---@param display DisplayBox
local function config_view(display) local function config_view(display)
---@diagnostic disable-next-line: undefined-field ---@diagnostic disable-next-line: undefined-field
local function exit() os.queueEvent("terminate") end local function exit() os.queueEvent("terminate") end

View File

@ -15,7 +15,7 @@ local cpair = core.cpair
local border = core.border local border = core.border
-- new boiler view -- new boiler view
---@param root graphics_element parent ---@param root Container parent
---@param x integer top left x ---@param x integer top left x
---@param y integer top left y ---@param y integer top left y
---@param ps psil ps interface ---@param ps psil ps interface

View File

@ -22,7 +22,7 @@ local border = core.border
local ALIGN = core.ALIGN local ALIGN = core.ALIGN
-- new induction matrix view -- new induction matrix view
---@param root graphics_element parent ---@param root Container parent
---@param x integer top left x ---@param x integer top left x
---@param y integer top left y ---@param y integer top left y
---@param data imatrix_session_db matrix data ---@param data imatrix_session_db matrix data

View File

@ -33,7 +33,7 @@ local bw_fg_bg = style.bw_fg_bg
local period = core.flasher.PERIOD local period = core.flasher.PERIOD
-- new process control view -- new process control view
---@param root graphics_element parent ---@param root Container parent
---@param x integer top left x ---@param x integer top left x
---@param y integer top left y ---@param y integer top left y
local function new_view(root, x, y) local function new_view(root, x, y)

View File

@ -17,7 +17,7 @@ local cpair = core.cpair
local border = core.border local border = core.border
-- create new reactor view -- create new reactor view
---@param root graphics_element parent ---@param root Container parent
---@param x integer top left x ---@param x integer top left x
---@param y integer top left y ---@param y integer top left y
---@param ps psil ps interface ---@param ps psil ps interface

View File

@ -16,7 +16,7 @@ local cpair = core.cpair
local border = core.border local border = core.border
-- new turbine view -- new turbine view
---@param root graphics_element parent ---@param root Container parent
---@param x integer top left x ---@param x integer top left x
---@param y integer top left y ---@param y integer top left y
---@param ps psil ps interface ---@param ps psil ps interface

View File

@ -42,7 +42,7 @@ local gry_wht = style.gray_white
local period = core.flasher.PERIOD local period = core.flasher.PERIOD
-- create a unit view -- create a unit view
---@param parent graphics_element parent ---@param parent DisplayBox parent
---@param id integer ---@param id integer
local function init(parent, id) local function init(parent, id)
local s_hi_box = style.theme.highlight_box local s_hi_box = style.theme.highlight_box

View File

@ -31,7 +31,7 @@ local wh_gray = style.wh_gray
local lg_gray = style.lg_gray local lg_gray = style.lg_gray
-- make a new unit flow window -- make a new unit flow window
---@param parent graphics_element parent ---@param parent DisplayBox parent
---@param x integer top left x ---@param x integer top left x
---@param y integer top left y ---@param y integer top left y
---@param wide boolean whether to render wide version ---@param wide boolean whether to render wide version

View File

@ -19,7 +19,7 @@ local ALIGN = core.ALIGN
local pipe = core.pipe local pipe = core.pipe
-- make a new unit overview window -- make a new unit overview window
---@param parent graphics_element parent ---@param parent Container parent
---@param x integer top left x ---@param x integer top left x
---@param y integer top left y ---@param y integer top left y
---@param unit ioctl_unit unit database entry ---@param unit ioctl_unit unit database entry

View File

@ -34,7 +34,7 @@ local pipe = core.pipe
local wh_gray = style.wh_gray local wh_gray = style.wh_gray
-- create new flow view -- create new flow view
---@param main graphics_element main displaybox ---@param main DisplayBox main displaybox
local function init(main) local function init(main)
local s_hi_bright = style.theme.highlight_box_bright local s_hi_bright = style.theme.highlight_box_bright
local s_field = style.theme.field_box local s_field = style.theme.field_box

View File

@ -34,7 +34,7 @@ local cpair = core.cpair
local led_grn = style.led_grn local led_grn = style.led_grn
-- create new front panel view -- create new front panel view
---@param panel graphics_element main displaybox ---@param panel DisplayBox main displaybox
---@param num_units integer number of units (number of unit monitors) ---@param num_units integer number of units (number of unit monitors)
local function init(panel, num_units) local function init(panel, num_units)
local ps = iocontrol.get_db().fp.ps local ps = iocontrol.get_db().fp.ps

View File

@ -21,7 +21,7 @@ local DataIndicator = require("graphics.elements.indicators.DataIndicator")
local ALIGN = core.ALIGN local ALIGN = core.ALIGN
-- create new main view -- create new main view
---@param main graphics_element main displaybox ---@param main DisplayBox main displaybox
local function init(main) local function init(main)
local s_header = style.theme.header local s_header = style.theme.header

View File

@ -5,7 +5,7 @@
local unit_detail = require("coordinator.ui.components.unit_detail") local unit_detail = require("coordinator.ui.components.unit_detail")
-- create a unit view -- create a unit view
---@param main graphics_element main displaybox ---@param main DisplayBox main displaybox
---@param id integer ---@param id integer
local function init(main, id) local function init(main, id)
unit_detail(main, id) unit_detail(main, id)

View File

@ -17,6 +17,8 @@ core.events = events
---@enum ALIGN ---@enum ALIGN
core.ALIGN = { LEFT = 1, CENTER = 2, RIGHT = 3 } core.ALIGN = { LEFT = 1, CENTER = 2, RIGHT = 3 }
---@alias Container DisplayBox|Div|ListBox|MultiPane|AppMultiPane|Rectangle
---@class graphics_border ---@class graphics_border
---@field width integer ---@field width integer
---@field color color ---@field color color

View File

@ -122,7 +122,7 @@ local function load_settings(target, raw)
end end
-- create the config view -- create the config view
---@param display graphics_element ---@param display DisplayBox
local function config_view(display) local function config_view(display)
---@diagnostic disable-next-line: undefined-field ---@diagnostic disable-next-line: undefined-field
local function exit() os.queueEvent("terminate") end local function exit() os.queueEvent("terminate") end

View File

@ -109,10 +109,10 @@ pocket.APP_ID = APP_ID
---@param smem pkt_shared_memory ---@param smem pkt_shared_memory
function pocket.init_nav(smem) function pocket.init_nav(smem)
local self = { local self = {
pane = nil, ---@type MultiPane|nil pane = nil, ---@type AppMultiPane|MultiPane|nil
sidebar = nil, ---@type Sidebar|nil sidebar = nil, ---@type Sidebar|nil
apps = {}, ---@type pocket_app[] apps = {}, ---@type pocket_app[]
containers = {}, ---@type graphics_element[] containers = {}, ---@type Container[]
help_map = {}, ---@type { [string]: function } help_map = {}, ---@type { [string]: function }
help_return = nil, ---@type POCKET_APP_ID|nil help_return = nil, ---@type POCKET_APP_ID|nil
loader_return = nil, ---@type POCKET_APP_ID|nil loader_return = nil, ---@type POCKET_APP_ID|nil
@ -134,8 +134,8 @@ function pocket.init_nav(smem)
-- register an app -- register an app
---@param app_id POCKET_APP_ID app ID ---@param app_id POCKET_APP_ID app ID
---@param container graphics_element element that contains this app (usually a Div) ---@param container Container element that contains this app (usually a Div)
---@param pane? graphics_element multipane if this is a simple paned app, then nav_to must be a number ---@param pane? AppMultiPane|MultiPane multipane if this is a simple paned app, then nav_to must be a number
---@param require_sv? boolean true to specifiy if this app should be unloaded when the supervisor connection is lost ---@param require_sv? boolean true to specifiy if this app should be unloaded when the supervisor connection is lost
---@param require_api? boolean true to specifiy if this app should be unloaded when the api connection is lost ---@param require_api? boolean true to specifiy if this app should be unloaded when the api connection is lost
function nav.register_app(app_id, container, pane, require_sv, require_api) function nav.register_app(app_id, container, pane, require_sv, require_api)
@ -159,7 +159,7 @@ function pocket.init_nav(smem)
function app.requires_conn() return require_sv or require_api or false end function app.requires_conn() return require_sv or require_api or false end
-- delayed set of the pane if it wasn't ready at the start -- delayed set of the pane if it wasn't ready at the start
---@param root_pane graphics_element multipane ---@param root_pane AppMultiPane|MultiPane multipane
function app.set_root_pane(root_pane) function app.set_root_pane(root_pane)
app.pane = root_pane app.pane = root_pane
end end

View File

@ -42,7 +42,7 @@ local hzd_fg_bg = cpair(colors.white, colors.gray)
local dis_colors = cpair(colors.white, colors.lightGray) local dis_colors = cpair(colors.white, colors.lightGray)
-- new unit control page view -- new unit control page view
---@param root graphics_element parent ---@param root Container parent
local function new_view(root) local function new_view(root)
local db = iocontrol.get_db() local db = iocontrol.get_db()
@ -63,7 +63,7 @@ local function new_view(root)
local btn_fg_bg = cpair(colors.green, colors.black) local btn_fg_bg = cpair(colors.green, colors.black)
local btn_active = cpair(colors.white, colors.black) local btn_active = cpair(colors.white, colors.black)
local page_div = nil ---@type nil|graphics_element local page_div = nil ---@type Div|nil
-- set sidebar to display unit-specific fields based on a specified unit -- set sidebar to display unit-specific fields based on a specified unit
local function set_sidebar() local function set_sidebar()
@ -83,7 +83,7 @@ local function new_view(root)
local function load() local function load()
page_div = Div{parent=main,y=2,width=main.get_width()} page_div = Div{parent=main,y=2,width=main.get_width()}
local panes = {} local panes = {} ---@type Div[]
local active_unit = 1 local active_unit = 1

View File

@ -22,7 +22,7 @@ local cpair = core.cpair
local APP_ID = pocket.APP_ID local APP_ID = pocket.APP_ID
-- create diagnostic app pages -- create diagnostic app pages
---@param root graphics_element parent ---@param root Container parent
local function create_pages(root) local function create_pages(root)
local db = iocontrol.get_db() local db = iocontrol.get_db()

View File

@ -13,7 +13,7 @@ local TextBox = require("graphics.elements.TextBox")
local APP_ID = pocket.APP_ID local APP_ID = pocket.APP_ID
-- create placeholder app page -- create placeholder app page
---@param root graphics_element parent ---@param root Container parent
local function create_pages(root) local function create_pages(root)
local db = iocontrol.get_db() local db = iocontrol.get_db()

View File

@ -36,7 +36,7 @@ local APP_ID = pocket.APP_ID
-- local text_fg = style.text_fg -- local text_fg = style.text_fg
-- new system guide view -- new system guide view
---@param root graphics_element parent ---@param root Container parent
local function new_view(root) local function new_view(root)
local db = iocontrol.get_db() local db = iocontrol.get_db()
@ -58,7 +58,7 @@ local function new_view(root)
app.set_sidebar({{ label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = function () db.nav.open_app(APP_ID.ROOT) end }}) app.set_sidebar({{ label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = function () db.nav.open_app(APP_ID.ROOT) end }})
local page_div = nil ---@type nil|graphics_element local page_div = nil ---@type Div|nil
-- load the app (create the elements) -- load the app (create the elements)
local function load() local function load()
@ -88,7 +88,7 @@ local function new_view(root)
local fps = Div{parent=page_div,x=2,width=p_width} local fps = Div{parent=page_div,x=2,width=p_width}
local gls = Div{parent=page_div,x=2,width=p_width} local gls = Div{parent=page_div,x=2,width=p_width}
local lnk = Div{parent=page_div,x=2,width=p_width} local lnk = Div{parent=page_div,x=2,width=p_width}
local panes = { home, search, use, uis, fps, gls, lnk } local panes = { home, search, use, uis, fps, gls, lnk } ---@type Div[]
local doc_map = {} ---@type { [string]: function } local doc_map = {} ---@type { [string]: function }
local search_db = {} ---@type [ string, string, string, function ][] local search_db = {} ---@type [ string, string, string, function ][]

View File

@ -18,7 +18,7 @@ local APP_ID = pocket.APP_ID
local LINK_STATE = iocontrol.LINK_STATE local LINK_STATE = iocontrol.LINK_STATE
-- create the connecting to SV & API page -- create the connecting to SV & API page
---@param root graphics_element parent ---@param root Container parent
local function create_pages(root) local function create_pages(root)
local db = iocontrol.get_db() local db = iocontrol.get_db()

View File

@ -25,7 +25,7 @@ local cpair = core.cpair
local APP_ID = pocket.APP_ID local APP_ID = pocket.APP_ID
-- create system app pages -- create system app pages
---@param root graphics_element parent ---@param root Container parent
local function create_pages(root) local function create_pages(root)
local db = iocontrol.get_db() local db = iocontrol.get_db()

View File

@ -47,7 +47,7 @@ local emc_ind_s = {
} }
-- new unit page view -- new unit page view
---@param root graphics_element parent ---@param root Container parent
local function new_view(root) local function new_view(root)
local db = iocontrol.get_db() local db = iocontrol.get_db()
@ -69,7 +69,7 @@ local function new_view(root)
local btn_active = cpair(colors.white, colors.black) local btn_active = cpair(colors.white, colors.black)
local nav_links = {} local nav_links = {}
local page_div = nil ---@type nil|graphics_element local page_div = nil ---@type Div|nil
-- set sidebar to display unit-specific fields based on a specified unit -- set sidebar to display unit-specific fields based on a specified unit
local function set_sidebar(id) local function set_sidebar(id)
@ -99,7 +99,7 @@ local function new_view(root)
local function load() local function load()
page_div = Div{parent=main,y=2,width=main.get_width()} page_div = Div{parent=main,y=2,width=main.get_width()}
local panes = {} local panes = {} ---@type Div[]
local active_unit = 1 local active_unit = 1

View File

@ -18,7 +18,7 @@ local ALIGN = core.ALIGN
local cpair = core.cpair local cpair = core.cpair
-- create a waiting view -- create a waiting view
---@param parent graphics_element parent ---@param parent Container parent
---@param y integer y offset ---@param y integer y offset
local function init(parent, y, is_api) local function init(parent, y, is_api)
-- root div -- root div

View File

@ -38,7 +38,7 @@ local cpair = core.cpair
local APP_ID = pocket.APP_ID local APP_ID = pocket.APP_ID
-- create new main view -- create new main view
---@param main graphics_element main displaybox ---@param main DisplayBox main displaybox
local function init(main) local function init(main)
local db = iocontrol.get_db() local db = iocontrol.get_db()

View File

@ -21,7 +21,7 @@ local DOC_TYPE = docs.DOC_ITEM_TYPE
local LIST_TYPE = docs.DOC_LIST_TYPE local LIST_TYPE = docs.DOC_LIST_TYPE
-- new guide documentation section -- new guide documentation section
---@param data { [1]: pocket_app, [2]: graphics_element, [3]: graphics_element[], [4]: { [string]: function }, [5]: [ string, string, string, function ][], [6]: cpair, [7]: cpair } ---@param data { [1]: pocket_app, [2]: Div, [3]: Div[], [4]: { [string]: function }, [5]: [ string, string, string, function ][], [6]: cpair, [7]: cpair }
---@param base_page nav_tree_page ---@param base_page nav_tree_page
---@param title string ---@param title string
---@param items table ---@param items table

View File

@ -19,7 +19,7 @@ local cpair = core.cpair
local APP_ID = pocket.APP_ID local APP_ID = pocket.APP_ID
-- new home page view -- new home page view
---@param root graphics_element parent ---@param root Container parent
local function new_view(root) local function new_view(root)
local db = iocontrol.get_db() local db = iocontrol.get_db()

View File

@ -29,8 +29,8 @@ local yel_ind_s = style.icon_states.yel_ind_s
-- create a boiler view in the unit app -- create a boiler view in the unit app
---@param app pocket_app ---@param app pocket_app
---@param u_page nav_tree_page ---@param u_page nav_tree_page
---@param panes graphics_element[] ---@param panes Div[]
---@param blr_pane graphics_element ---@param blr_pane Div
---@param b_id integer boiler ID ---@param b_id integer boiler ID
---@param ps psil ---@param ps psil
---@param update function ---@param update function

View File

@ -29,8 +29,8 @@ local yel_ind_s = style.icon_states.yel_ind_s
-- create a reactor view in the unit app -- create a reactor view in the unit app
---@param app pocket_app ---@param app pocket_app
---@param u_page nav_tree_page ---@param u_page nav_tree_page
---@param panes graphics_element[] ---@param panes Div[]
---@param page_div graphics_element ---@param page_div Div
---@param u_ps psil ---@param u_ps psil
---@param update function ---@param update function
return function (app, u_page, panes, page_div, u_ps, update) return function (app, u_page, panes, page_div, u_ps, update)

View File

@ -30,8 +30,8 @@ local yel_ind_s = style.icon_states.yel_ind_s
-- create a turbine view in the unit app -- create a turbine view in the unit app
---@param app pocket_app ---@param app pocket_app
---@param u_page nav_tree_page ---@param u_page nav_tree_page
---@param panes graphics_element[] ---@param panes Div[]
---@param tbn_pane graphics_element ---@param tbn_pane Div
---@param u_id integer unit ID ---@param u_id integer unit ID
---@param t_id integer turbine ID ---@param t_id integer turbine ID
---@param ps psil ---@param ps psil

View File

@ -160,7 +160,7 @@ local function self_check()
end end
-- exit self check back home -- exit self check back home
---@param main_pane graphics_element ---@param main_pane MultiPane
local function exit_self_check(main_pane) local function exit_self_check(main_pane)
tcd.abort(handle_timeout) tcd.abort(handle_timeout)
self.net_listen = false self.net_listen = false
@ -172,9 +172,9 @@ end
local check = {} local check = {}
-- create the self-check view -- create the self-check view
---@param main_pane graphics_element ---@param main_pane MultiPane
---@param settings_cfg plc_config ---@param settings_cfg plc_config
---@param check_sys graphics_element ---@param check_sys Div
---@param style { [string]: cpair } ---@param style { [string]: cpair }
function check.create(main_pane, settings_cfg, check_sys, style) function check.create(main_pane, settings_cfg, check_sys, style)
local bw_fg_bg = style.bw_fg_bg local bw_fg_bg = style.bw_fg_bg

View File

@ -61,7 +61,7 @@ local system = {}
-- create the system configuration view -- create the system configuration view
---@param tool_ctl _plc_cfg_tool_ctl ---@param tool_ctl _plc_cfg_tool_ctl
---@param main_pane graphics_element ---@param main_pane MultiPane
---@param cfg_sys [ plc_config, plc_config, plc_config, table, function ] ---@param cfg_sys [ plc_config, plc_config, plc_config, table, function ]
---@param divs Div[] ---@param divs Div[]
---@param style { [string]: cpair } ---@param style { [string]: cpair }

View File

@ -125,7 +125,7 @@ local function load_settings(target, raw)
end end
-- create the config view -- create the config view
---@param display graphics_element ---@param display DisplayBox
local function config_view(display) local function config_view(display)
local bw_fg_bg = style.bw_fg_bg local bw_fg_bg = style.bw_fg_bg
local g_lg_fg_bg = style.g_lg_fg_bg local g_lg_fg_bg = style.g_lg_fg_bg

View File

@ -34,7 +34,7 @@ local ind_grn = style.ind_grn
local ind_red = style.ind_red local ind_red = style.ind_red
-- create new front panel view -- create new front panel view
---@param panel graphics_element main displaybox ---@param panel DisplayBox main displaybox
local function init(panel) local function init(panel)
local s_hi_box = style.theme.highlight_box local s_hi_box = style.theme.highlight_box

View File

@ -259,7 +259,7 @@ local function load_settings(target, raw)
end end
-- create the config view -- create the config view
---@param display graphics_element ---@param display DisplayBox
local function config_view(display) local function config_view(display)
---@diagnostic disable-next-line: undefined-field ---@diagnostic disable-next-line: undefined-field
local function exit() os.queueEvent("terminate") end local function exit() os.queueEvent("terminate") end

View File

@ -30,7 +30,7 @@ local ind_grn = style.ind_grn
local UNIT_TYPE_LABELS = { "UNKNOWN", "REDSTONE", "BOILER", "TURBINE", "DYNAMIC TANK", "IND MATRIX", "SPS", "SNA", "ENV DETECTOR" } local UNIT_TYPE_LABELS = { "UNKNOWN", "REDSTONE", "BOILER", "TURBINE", "DYNAMIC TANK", "IND MATRIX", "SPS", "SNA", "ENV DETECTOR" }
-- create new front panel view -- create new front panel view
---@param panel graphics_element main displaybox ---@param panel DisplayBox main displaybox
---@param units rtu_registry_entry[] unit list ---@param units rtu_registry_entry[] unit list
local function init(panel, units) local function init(panel, units)
local disabled_fg = style.fp.disabled_fg local disabled_fg = style.fp.disabled_fg

View File

@ -153,7 +153,7 @@ local function load_settings(target, raw)
end end
-- create the config view -- create the config view
---@param display graphics_element ---@param display DisplayBox
local function config_view(display) local function config_view(display)
---@diagnostic disable-next-line: undefined-field ---@diagnostic disable-next-line: undefined-field
local function exit() os.queueEvent("terminate") end local function exit() os.queueEvent("terminate") end

View File

@ -33,7 +33,7 @@ local cpair = core.cpair
local ind_grn = style.ind_grn local ind_grn = style.ind_grn
-- create new front panel view -- create new front panel view
---@param panel graphics_element main displaybox ---@param panel DisplayBox main displaybox
local function init(panel) local function init(panel)
local s_hi_box = style.theme.highlight_box local s_hi_box = style.theme.highlight_box
local s_hi_bright = style.theme.highlight_box_bright local s_hi_bright = style.theme.highlight_box_bright