fix: bgcolor settings for root node (#7)

This commit is contained in:
Lazerbeak12345 2023-05-31 22:56:03 -06:00 committed by GitHub
parent 238e432251
commit 35fa361f8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 4 deletions

View File

@ -459,13 +459,16 @@ local function render_ast(node)
if node.no_prepend then
res[#res + 1] = {type = "no_prepend"}
end
if node.fbgcolor then
-- TODO: Fix this
if node.fbgcolor or node.bgcolor or node.bg_fullscreen then
res[#res + 1] = {
type = "bgcolor",
bgcolor = node.fbgcolor,
fullscreen = true
bgcolor = node.bgcolor,
fbgcolor = node.fbgcolor,
fullscreen = node.bg_fullscreen
}
node.bgcolor = nil
node.fbgcolor = nil
node.bg_fullscreen = nil
end
for field in formspec_ast.find(node, 'field') do

View File

@ -94,6 +94,45 @@ local function test_render(build_func, output)
end
describe("Flow", function()
describe("bgcolor settings", function ()
it("renders bgcolor only correctly", function ()
test_render(gui.VBox{ bgcolor = "green" }, [[
size[0.6,0.6]
bgcolor[green]
]])
end)
it("renders fbgcolor only correctly", function ()
test_render(gui.VBox{ fbgcolor = "green" }, [[
size[0.6,0.6]
bgcolor[;;green]
]])
end)
it("renders both correctly", function ()
test_render(gui.VBox{ bgcolor = "orange", fbgcolor = "green" }, [[
size[0.6,0.6]
bgcolor[orange;;green]
]])
end)
it("passes fullscreen setting", function ()
test_render(gui.VBox{ bg_fullscreen = true }, [[
size[0.6,0.6]
bgcolor[;true]
]])
end)
it("passes fullscreen setting when string", function ()
test_render(gui.VBox{ bg_fullscreen = "both" }, [[
size[0.6,0.6]
bgcolor[;both]
]])
end)
it("handles it all together", function ()
test_render(gui.VBox{ bgcolor = "blue", fbgcolor = "red", bg_fullscreen = "neither" }, [[
size[0.6,0.6]
bgcolor[blue;neither;red]
]])
end)
end)
it("renders labels correctly", function()
test_render(gui.Label{label = "Hello world!"}, [[
size[3.12,1]