#544 #545 updates to graphics animations, controls, and form elements

This commit is contained in:
Mikayla Fischler
2024-09-21 22:49:36 -04:00
parent b15c60fdab
commit 0daf314918
19 changed files with 111 additions and 134 deletions

View File

@@ -23,10 +23,10 @@ local element = require("graphics.element")
---@field fg_bg? cpair foreground/background colors
---@field hidden? boolean true to hide on initial draw
-- new 2D radio button list (latch selection, exclusively one color at a time)
-- Create a new 2D radio button list control element (latch selection, exclusively one color at a time).
---@param args radio_2d_args
---@return graphics_element element, element_id id
local function radio_2d_button(args)
---@return Radio2D element, element_id id
return function (args)
element.assert(type(args.options) == "table" and #args.options > 0, "options should be a table with length >= 1")
element.assert(util.is_int(args.rows) and util.is_int(args.columns), "rows/columns must be integers")
element.assert((args.rows * args.columns) >= #args.options, "rows x columns size insufficient for provided number of options")
@@ -70,7 +70,7 @@ local function radio_2d_button(args)
args.height = max_rows
-- create new graphics element base object
local e = element.new(args)
local e = element.new(args --[[@as graphics_args]])
-- selected option (convert nil to 1 if missing)
e.value = args.default or 1
@@ -194,10 +194,8 @@ local function radio_2d_button(args)
e.on_enabled = e.redraw
e.on_disabled = e.redraw
-- initial draw
e.redraw()
---@class Radio2D:graphics_element
local Radio2D, id = e.complete(true)
return e.complete()
return Radio2D, id
end
return radio_2d_button