listbox debugging

This commit is contained in:
Mikayla 2024-08-16 21:17:36 +00:00
parent 5597ea2097
commit affe2d6c6d
2 changed files with 9 additions and 0 deletions

View File

@ -3,6 +3,7 @@
-- --
local util = require("scada-common.util") local util = require("scada-common.util")
local log = require("scada-common.log")
local core = require("graphics.core") local core = require("graphics.core")
@ -503,7 +504,10 @@ function element.new(args, constraint, child_offset_x, child_offset_y)
if args.parent ~= nil then if args.parent ~= nil then
-- remove self from parent -- remove self from parent
log.debug("removing " .. self.id .. " from parent")
args.parent.__remove_child(self.id) args.parent.__remove_child(self.id)
else
log.debug("no parent for " .. self.id .. " on delete attempt")
end end
end end

View File

@ -1,6 +1,7 @@
-- Scroll-able List Box Display Graphics Element -- Scroll-able List Box Display Graphics Element
local tcd = require("scada-common.tcd") local tcd = require("scada-common.tcd")
local log = require("scada-common.log")
local core = require("graphics.core") local core = require("graphics.core")
local element = require("graphics.element") local element = require("graphics.element")
@ -152,6 +153,7 @@ local function listbox(args)
next_y = next_y + item.h + item_pad next_y = next_y + item.h + item_pad
item.e.reposition(1, item.y) item.e.reposition(1, item.y)
item.e.show() item.e.show()
log.debug("iterated " .. item.e.get_id())
end end
content_height = next_y content_height = next_y
@ -210,6 +212,7 @@ local function listbox(args)
---@param child graphics_element child element ---@param child graphics_element child element
function e.on_added(id, child) function e.on_added(id, child)
table.insert(list, { id = id, e = child, y = 0, h = child.get_height() }) table.insert(list, { id = id, e = child, y = 0, h = child.get_height() })
log.debug("added child " .. id .. " into slot " .. #list)
update_positions() update_positions()
end end
@ -219,10 +222,12 @@ local function listbox(args)
for idx, elem in ipairs(list) do for idx, elem in ipairs(list) do
if elem.id == id then if elem.id == id then
table.remove(list, idx) table.remove(list, idx)
log.debug("removed child " .. id .. " from slot " .. idx)
update_positions() update_positions()
return return
end end
end end
log.debug("failed to remove child " .. id)
end end
-- handle focus -- handle focus