graphics element hidden on creation option, changed hide/show logic to only hide/show current element

This commit is contained in:
Mikayla Fischler 2023-05-25 17:40:16 -04:00
parent e313b77abc
commit f9aa75a105
36 changed files with 69 additions and 33 deletions

View File

@ -20,7 +20,7 @@ local sounder = require("coordinator.sounder")
local apisessions = require("coordinator.session.apisessions")
local COORDINATOR_VERSION = "v0.15.2"
local COORDINATOR_VERSION = "v0.15.3"
local println = util.println
local println_ts = util.println_ts

View File

@ -18,6 +18,7 @@ local element = {}
---@field height? integer parent height if omitted
---@field gframe? graphics_frame frame instead of x/y/width/height
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
---@alias graphics_args graphics_args_generic
---|waiting_args
@ -153,7 +154,7 @@ function element.new(args)
assert(f.h >= 1, name_brief .. "frame height not >= 1")
-- create window
protected.window = window.create(self.p_window, f.x, f.y, f.w, f.h, true)
protected.window = window.create(self.p_window, f.x, f.y, f.w, f.h, args.hidden ~= true)
-- init colors
if args.fg_bg ~= nil then
@ -385,25 +386,6 @@ function element.new(args)
return nil
end
-- DYNAMIC CHILD ELEMENTS --
-- insert an element as a contained child<br>
-- this is intended to be used dynamically, and depends on the target element type.<br>
-- not all elements support dynamic children.
---@param id string|integer element identifier
---@param elem graphics_element element
function public.insert_element(id, elem)
protected.insert(id, elem)
end
-- remove an element from contained children<br>
-- this is intended to be used dynamically, and depends on the target element type.<br>
-- not all elements support dynamic children.
---@param id string|integer element identifier
function public.remove_element(id)
protected.remove(id)
end
-- AUTO-PLACEMENT --
-- skip a line for automatically placed elements
@ -545,22 +527,46 @@ function element.new(args)
ps.subscribe(key, func)
end
-- VISIBILITY --
-- VISIBILITY & ANIMATIONS --
-- show the element
function public.show()
-- show the element and enables animations by default
---@param animate? boolean true (default) to automatically resume animations
function public.show(animate)
protected.window.setVisible(true)
protected.start_anim()
for _, child in pairs(self.children) do child.show() end
if animate ~= false then public.animate_all() end
end
-- hide the element
-- hide the element and disables animations
function public.hide()
protected.stop_anim()
for _, child in pairs(self.children) do child.hide() end
public.freeze_all() -- stop animations for efficiency/performance
protected.window.setVisible(false)
end
-- start/resume animation(s)
function public.animate()
protected.start_anim()
end
-- start/resume animation(s) for this element and all its children<br>
-- only animates if a window is visible
function public.animate_all()
if protected.window.isVisible() then
public.animate()
for _, child in pairs(self.children) do child.animate_all() end
end
end
-- freeze animation(s)
function public.freeze()
protected.stop_anim()
end
-- freeze animation(s) for this element and all its children
function public.freeze_all()
public.freeze()
for _, child in pairs(self.children) do child.freeze_all() end
end
-- re-draw the element
function public.redraw()
protected.window.redraw()

View File

@ -10,6 +10,7 @@ local element = require("graphics.element")
---@field x? integer 1 if omitted
---@field y? integer 1 if omitted
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new waiting animation element
---@param args waiting_args

View File

@ -9,6 +9,7 @@ local element = require("graphics.element")
---@field id? string element id
---@field x? integer 1 if omitted
---@field y? integer 1 if omitted
---@field hidden? boolean true to hide on initial draw
-- new color map
---@param args colormap_args

View File

@ -16,6 +16,7 @@ local element = require("graphics.element")
---@field x? integer 1 if omitted
---@field y? integer 1 if omitted
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new hazard button
---@param args hazard_button_args

View File

@ -23,6 +23,7 @@ local element = require("graphics.element")
---@field y? integer 1 if omitted
---@field height? integer parent height if omitted
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new multi button (latch selection, exclusively one button at a time)
---@param args multi_button_args

View File

@ -19,6 +19,7 @@ local CLICK_TYPE = core.events.CLICK_TYPE
---@field y? integer 1 if omitted
---@field height? integer parent height if omitted
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new push button
---@param args push_button_args

View File

@ -15,6 +15,7 @@ local element = require("graphics.element")
---@field x? integer 1 if omitted
---@field y? integer 1 if omitted
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new radio button list (latch selection, exclusively one button at a time)
---@param args radio_button_args

View File

@ -20,6 +20,7 @@ local CLICK_TYPE = core.events.CLICK_TYPE
---@field y? integer 1 if omitted
---@field height? integer parent height if omitted
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new sidebar tab selector
---@param args sidebar_args

View File

@ -18,6 +18,7 @@ local element = require("graphics.element")
---@field x? integer 1 if omitted
---@field y? integer 1 if omitted
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new spinbox control (minimum value is 0)
---@param args spinbox_args

View File

@ -15,6 +15,7 @@ local element = require("graphics.element")
---@field y? integer 1 if omitted
---@field height? integer parent height if omitted
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new switch button (latch high/low)
---@param args switch_button_args

View File

@ -21,6 +21,7 @@ local element = require("graphics.element")
---@field y? integer 1 if omitted
---@field width? integer parent width if omitted
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new tab selector
---@param args tabbar_args

View File

@ -10,6 +10,7 @@ local element = require("graphics.element")
---@field height? integer parent height if omitted
---@field gframe? graphics_frame frame instead of x/y/width/height
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new root display box
---@nodiscard

View File

@ -11,6 +11,7 @@ local element = require("graphics.element")
---@field height? integer parent height if omitted
---@field gframe? graphics_frame frame instead of x/y/width/height
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new div element
---@nodiscard

View File

@ -18,6 +18,7 @@ local flasher = require("graphics.flasher")
---@field x? integer 1 if omitted
---@field y? integer 1 if omitted
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new alarm indicator light
---@nodiscard

View File

@ -17,6 +17,7 @@ local element = require("graphics.element")
---@field y? integer 1 if omitted
---@field width integer length
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new data indicator
---@nodiscard

View File

@ -15,6 +15,7 @@ local element = require("graphics.element")
---@field height? integer parent height if omitted
---@field gframe? graphics_frame frame instead of x/y/width/height
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new horizontal bar
---@nodiscard

View File

@ -18,6 +18,7 @@ local element = require("graphics.element")
---@field x? integer 1 if omitted
---@field y? integer 1 if omitted
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new icon indicator
---@nodiscard

View File

@ -16,6 +16,7 @@ local flasher = require("graphics.flasher")
---@field x? integer 1 if omitted
---@field y? integer 1 if omitted
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new indicator LED
---@nodiscard

View File

@ -18,6 +18,7 @@ local flasher = require("graphics.flasher")
---@field x? integer 1 if omitted
---@field y? integer 1 if omitted
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new dual LED indicator light
---@nodiscard

View File

@ -11,6 +11,7 @@ local element = require("graphics.element")
---@field x? integer 1 if omitted
---@field y? integer 1 if omitted
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new RGB LED indicator light
---@nodiscard

View File

@ -16,6 +16,7 @@ local flasher = require("graphics.flasher")
---@field x? integer 1 if omitted
---@field y? integer 1 if omitted
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new indicator light
---@nodiscard

View File

@ -16,6 +16,7 @@ local element = require("graphics.element")
---@field y? integer 1 if omitted
---@field width integer length
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new power indicator
---@nodiscard

View File

@ -17,6 +17,7 @@ local element = require("graphics.element")
---@field y? integer 1 if omitted
---@field width integer length
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new radiation indicator
---@nodiscard

View File

@ -18,6 +18,7 @@ local element = require("graphics.element")
---@field y? integer 1 if omitted
---@field height? integer 1 if omitted, must be an odd number
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new state indicator
---@nodiscard

View File

@ -18,6 +18,7 @@ local flasher = require("graphics.flasher")
---@field x? integer 1 if omitted
---@field y? integer 1 if omitted
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new tri-state indicator light
---@nodiscard

View File

@ -13,6 +13,7 @@ local element = require("graphics.element")
---@field height? integer parent height if omitted
---@field gframe? graphics_frame frame instead of x/y/width/height
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new vertical bar
---@nodiscard

View File

@ -12,6 +12,7 @@ local element = require("graphics.element")
---@field height? integer parent height if omitted
---@field gframe? graphics_frame frame instead of x/y/width/height
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new multipane element
---@nodiscard

View File

@ -12,6 +12,7 @@ local element = require("graphics.element")
---@field id? string element id
---@field x? integer 1 if omitted
---@field y? integer 1 if omitted
---@field hidden? boolean true to hide on initial draw
-- new pipe network
---@param args pipenet_args

View File

@ -16,6 +16,7 @@ local element = require("graphics.element")
---@field height? integer parent height if omitted
---@field gframe? graphics_frame frame instead of x/y/width/height
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new rectangle
---@param args rectangle_args

View File

@ -18,6 +18,7 @@ local TEXT_ALIGN = core.TEXT_ALIGN
---@field height? integer parent height if omitted
---@field gframe? graphics_frame frame instead of x/y/width/height
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new text box
---@param args textbox_args

View File

@ -16,6 +16,7 @@ local element = require("graphics.element")
---@field height? integer parent height if omitted
---@field gframe? graphics_frame frame instead of x/y/width/height
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new tiling box
---@param args tiling_args

View File

@ -17,7 +17,7 @@ local coreio = require("pocket.coreio")
local pocket = require("pocket.pocket")
local renderer = require("pocket.renderer")
local POCKET_VERSION = "alpha-v0.3.2"
local POCKET_VERSION = "alpha-v0.3.3"
local println = util.println
local println_ts = util.println_ts

View File

@ -18,7 +18,7 @@ local plc = require("reactor-plc.plc")
local renderer = require("reactor-plc.renderer")
local threads = require("reactor-plc.threads")
local R_PLC_VERSION = "v1.3.2"
local R_PLC_VERSION = "v1.3.3"
local println = util.println
local println_ts = util.println_ts

View File

@ -28,7 +28,7 @@ local sna_rtu = require("rtu.dev.sna_rtu")
local sps_rtu = require("rtu.dev.sps_rtu")
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
local RTU_VERSION = "v1.2.2"
local RTU_VERSION = "v1.2.3"
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE

View File

@ -19,7 +19,7 @@ local supervisor = require("supervisor.supervisor")
local svsessions = require("supervisor.session.svsessions")
local SUPERVISOR_VERSION = "v0.16.2"
local SUPERVISOR_VERSION = "v0.16.3"
local println = util.println
local println_ts = util.println_ts