diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 17fcc6f..0faf0fb 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -20,7 +20,7 @@ local sounder = require("coordinator.sounder") local apisessions = require("coordinator.session.apisessions") -local COORDINATOR_VERSION = "v0.15.4" +local COORDINATOR_VERSION = "v0.15.5" local println = util.println local println_ts = util.println_ts diff --git a/graphics/element.lua b/graphics/element.lua index d0e6a3b..a775eb7 100644 --- a/graphics/element.lua +++ b/graphics/element.lua @@ -12,8 +12,6 @@ local element = {} ---@field id? string element id ---@field x? integer 1 if omitted ---@field y? integer next line if omitted ----@field offset_x? integer 0 if omitted ----@field offset_y? integer 0 if omitted ---@field width? integer parent width if omitted ---@field height? integer parent height if omitted ---@field gframe? graphics_frame frame instead of x/y/width/height @@ -103,10 +101,8 @@ function element.new(args) ------------------------- -- prepare the template - ---@param offset_x integer x offset - ---@param offset_y integer y offset ---@param next_y integer next line if no y was provided - function protected.prepare_template(offset_x, offset_y, next_y) + function protected.prepare_template(next_y) -- get frame coordinates/size if args.gframe ~= nil then protected.frame.x = args.gframe.x @@ -116,36 +112,18 @@ function element.new(args) else local w, h = self.p_window.getSize() protected.frame.x = args.x or 1 - - if args.parent ~= nil then - protected.frame.y = args.y or (next_y - offset_y) - else protected.frame.y = args.y or next_y - end - protected.frame.w = args.width or w protected.frame.h = args.height or h end - -- inner offsets - if args.offset_x ~= nil then self.child_offset.x = args.offset_x end - if args.offset_y ~= nil then self.child_offset.y = args.offset_y end - -- adjust window frame if applicable local f = protected.frame - local x = f.x - local y = f.y - - -- apply offsets if args.parent ~= nil then -- constrain to parent inner width/height local w, h = self.p_window.getSize() - f.w = math.min(f.w, w - ((2 * offset_x) + (f.x - 1))) - f.h = math.min(f.h, h - ((2 * offset_y) + (f.y - 1))) - - -- offset x/y - f.x = x + offset_x - f.y = y + offset_y + f.w = math.min(f.w, w - (f.x - 1)) + f.h = math.min(f.h, h - (f.y - 1)) end -- check frame @@ -304,7 +282,7 @@ function element.new(args) -- prepare the template if args.parent == nil then - protected.prepare_template(0, 0, 1) + protected.prepare_template(1) else self.id = args.parent.__add_child(args.id, protected) end @@ -319,14 +297,16 @@ function element.new(args) -- delete this element (hide and unsubscribe from PSIL) function public.delete() - -- grab parent fg/bg so we can clear cleanly + local fg_bg = protected.fg_bg + if args.parent ~= nil then - local fg_bg = args.parent.get_fg_bg() - protected.window.setBackgroundColor(fg_bg.bkg) - protected.window.setTextColor(fg_bg.fgd) + -- grab parent fg/bg so we can clear cleanly as a child element + fg_bg = args.parent.get_fg_bg() end -- clear, hide, and stop animations + protected.window.setBackgroundColor(fg_bg.bkg) + protected.window.setTextColor(fg_bg.fgd) protected.window.clear() public.hide() @@ -351,12 +331,7 @@ function element.new(args) ---@param child graphics_base ---@return integer|string key function public.__add_child(key, child) - -- offset first automatic placement - if self.next_y <= self.child_offset.y then - self.next_y = self.child_offset.y + 1 - end - - child.prepare_template(self.child_offset.x, self.child_offset.y, self.next_y) + child.prepare_template(self.next_y) self.next_y = child.frame.y + child.frame.h diff --git a/graphics/elements/displaybox.lua b/graphics/elements/displaybox.lua index 992f34b..3578a63 100644 --- a/graphics/elements/displaybox.lua +++ b/graphics/elements/displaybox.lua @@ -4,6 +4,7 @@ local element = require("graphics.element") ---@class displaybox_args ---@field window table +---@field id? string element id ---@field x? integer 1 if omitted ---@field y? integer 1 if omitted ---@field width? integer parent width if omitted @@ -15,6 +16,7 @@ local element = require("graphics.element") -- new root display box ---@nodiscard ---@param args displaybox_args +---@return graphics_element element, element_id id local function displaybox(args) -- create new graphics element base object return element.new(args).complete() diff --git a/graphics/elements/rectangle.lua b/graphics/elements/rectangle.lua index 72f9739..cd4b8cf 100644 --- a/graphics/elements/rectangle.lua +++ b/graphics/elements/rectangle.lua @@ -31,27 +31,35 @@ local function rectangle(args) end -- offset children + local offset_x = 0 + local offset_y = 0 if args.border ~= nil then - args.offset_x = args.border.width - args.offset_y = args.border.width + offset_x = args.border.width + offset_y = args.border.width -- slightly different y offset if the border is set to even if args.border.even then local width_x2 = (2 * args.border.width) - args.offset_y = math.floor(width_x2 / 3) + util.trinary(width_x2 % 3 > 0, 1, 0) + offset_y = math.floor(width_x2 / 3) + util.trinary(width_x2 % 3 > 0, 1, 0) end end -- create new graphics element base object local e = element.new(args) + -- create content window for child elements + e.content_window = window.create(e.window, 1 + offset_x, 1 + offset_y, e.frame.w - (2 * offset_x), e.frame.h - (2 * offset_y)) + e.content_window.setBackgroundColor(e.fg_bg.bkg) + e.content_window.setTextColor(e.fg_bg.fgd) + e.content_window.clear() + -- draw bordered box if requested -- element constructor will have drawn basic colored rectangle regardless if args.border ~= nil then e.window.setCursorPos(1, 1) - local border_width = args.offset_x - local border_height = args.offset_y + local border_width = offset_x + local border_height = offset_y local border_blit = colors.toBlit(args.border.color) local width_x2 = border_width * 2 local inner_width = e.frame.w - width_x2 diff --git a/pocket/startup.lua b/pocket/startup.lua index c1a924c..2a48042 100644 --- a/pocket/startup.lua +++ b/pocket/startup.lua @@ -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.4" +local POCKET_VERSION = "alpha-v0.3.5" local println = util.println local println_ts = util.println_ts diff --git a/reactor-plc/startup.lua b/reactor-plc/startup.lua index 687c022..cf3b08a 100644 --- a/reactor-plc/startup.lua +++ b/reactor-plc/startup.lua @@ -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.4" +local R_PLC_VERSION = "v1.3.5" local println = util.println local println_ts = util.println_ts diff --git a/rtu/startup.lua b/rtu/startup.lua index c7f3a66..1ae38ed 100644 --- a/rtu/startup.lua +++ b/rtu/startup.lua @@ -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.4" +local RTU_VERSION = "v1.2.5" local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE diff --git a/supervisor/startup.lua b/supervisor/startup.lua index cf7c8fe..6e2dd95 100644 --- a/supervisor/startup.lua +++ b/supervisor/startup.lua @@ -19,7 +19,7 @@ local supervisor = require("supervisor.supervisor") local svsessions = require("supervisor.session.svsessions") -local SUPERVISOR_VERSION = "v0.16.4" +local SUPERVISOR_VERSION = "v0.16.5" local println = util.println local println_ts = util.println_ts