forked from your-land-mirror/minetest-flow
fix: bgcolor settings for root node (#7)
This commit is contained in:
parent
238e432251
commit
35fa361f8d
11
init.lua
11
init.lua
@ -459,13 +459,16 @@ local function render_ast(node)
|
|||||||
if node.no_prepend then
|
if node.no_prepend then
|
||||||
res[#res + 1] = {type = "no_prepend"}
|
res[#res + 1] = {type = "no_prepend"}
|
||||||
end
|
end
|
||||||
if node.fbgcolor then
|
if node.fbgcolor or node.bgcolor or node.bg_fullscreen then
|
||||||
-- TODO: Fix this
|
|
||||||
res[#res + 1] = {
|
res[#res + 1] = {
|
||||||
type = "bgcolor",
|
type = "bgcolor",
|
||||||
bgcolor = node.fbgcolor,
|
bgcolor = node.bgcolor,
|
||||||
fullscreen = true
|
fbgcolor = node.fbgcolor,
|
||||||
|
fullscreen = node.bg_fullscreen
|
||||||
}
|
}
|
||||||
|
node.bgcolor = nil
|
||||||
|
node.fbgcolor = nil
|
||||||
|
node.bg_fullscreen = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
for field in formspec_ast.find(node, 'field') do
|
for field in formspec_ast.find(node, 'field') do
|
||||||
|
39
test.lua
39
test.lua
@ -94,6 +94,45 @@ local function test_render(build_func, output)
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe("Flow", function()
|
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()
|
it("renders labels correctly", function()
|
||||||
test_render(gui.Label{label = "Hello world!"}, [[
|
test_render(gui.Label{label = "Hello world!"}, [[
|
||||||
size[3.12,1]
|
size[3.12,1]
|
||||||
|
Loading…
Reference in New Issue
Block a user