Skip to content

Commit

Permalink
[bugfix] Sometimes links dont work in test output
Browse files Browse the repository at this point in the history
Because there are overlapping (yet hidden) components - test summary and
"lights".
  • Loading branch information
elgopher committed Nov 30, 2024
1 parent 43e3124 commit 123ea19
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
8 changes: 4 additions & 4 deletions gui/gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ local function start_test(item)
if test_id != nil then
text_output:scroll_to_line(1)

test_summary.visible = false
lights.visible = false
test_summary:set_visible(false)
lights:set_visible(false)
else
test_summary.visible = true
lights.visible = true
test_summary:set_visible(true)
lights:set_visible(true)
end
end

Expand Down
23 changes: 10 additions & 13 deletions gui/lights.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,23 @@ function attach_lights(parent, el)
local margin <const> = 1

el = parent:attach(el)
el.visible = true -- Picotron's hidden field is broken
el.height_before_hide = el.height

---@param no integer Starting from 1
function el:set_light(no, color)
lights[no] = color
lights_max = max(lights_max, no)
end

-- Picotron's hidden field is broken
function el:set_visible(v)
if not v then
el.height = 0
else
el.height = el.height_before_hide
end
end

local function light_at_cursor_pointer(msg)
if msg.mx == nil and msg.my == nil then
return
Expand All @@ -35,10 +44,6 @@ function attach_lights(parent, el)
end

function el:update(msg)
if not el.visible then
return
end

if light_at_cursor_pointer(msg) != nil then
el.cursor = "pointer"
else
Expand All @@ -47,21 +52,13 @@ function attach_lights(parent, el)
end

function el:click(msg)
if not el.visible then
return
end

local light = light_at_cursor_pointer(msg)
if light != nil then
el.select(light)
end
end

function el:draw()
if not el.visible then
return
end

rectfill(0, 0, el.width, el.height, 0)
local x, y = 0, 0

Expand Down
14 changes: 10 additions & 4 deletions gui/test_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ function attach_test_summary(parent, el)
local succeeded, failed = 0, 0

el = parent:attach(el)
el.visible = true -- Picotron's hidden field is broken
el.height_before_hide = el.height

function el:draw()
if not el.visible then
return
-- Picotron's hidden field is broken
function el:set_visible(v)
if not v then
el.height = 0
else
el.height = el.height_before_hide
end
end

function el:draw()
rectfill(0, 0, el.width, el.height, 0)

color(26)
print("Succeeded: " .. succeeded .. " \f8 Failed: " .. failed)
end
Expand Down

0 comments on commit 123ea19

Please sign in to comment.