Reset bgimg style when centering labels

This commit is contained in:
luk3yx 2023-07-08 12:17:30 +12:00
parent 82a5a2470e
commit 57c1e20ace
2 changed files with 27 additions and 4 deletions

View File

@ -138,6 +138,7 @@ These utilities likely aren't compatible with flow.
- [Just_Visiting's formspec editor](https://content.minetest.net/packages/Just_Visiting/formspec_editor) is a Minetest (sub)game that lets you edit formspecs and preview them as you go
- [kuto](https://github.com/TerraQuest-Studios/kuto/) is a formspec library that has some extra widgets/components and has a callback API. Some automatic sizing can be done for buttons.
- It may be possible to use kuto's components with flow somehow as they both use formspec_ast internally.
- kuto was the the source of the "on_event" function idea.
- [My web-based formspec editor](https://forum.minetest.net/viewtopic.php?f=14&t=24130) lets you add elements and drag+drop them, however it doesn't support all formspec features.
## Elements

View File

@ -309,29 +309,51 @@ function align_types.fill(node, x, w, extra_space)
-- Hack
node.type = "container"
-- Reset bgimg, some games apply styling to all image_buttons inside
-- the formspec prepend
node[1] = {
type = "style",
-- MT 5.1.0 only supports one style selector
selectors = {"\1"},
-- bgimg_pressed is included for 5.1.0 support
-- bgimg_hovered is unnecessary as it was added in 5.2.0 (which
-- also adds support for :hovered and :pressed)
props = {bgimg = "", bgimg_pressed = ""},
}
-- Use the newer pressed selector as well in case the deprecated one is
-- removed
node[2] = {
type = "style",
selectors = {"\1:hovered", "\1:pressed"},
props = {bgimg = ""},
}
node[3] = {
type = "image_button",
texture_name = "blank.png",
drawborder = false,
x = 0, y = 0,
w = node.w + extra_space, h = node.h,
label = node.label,
name = "\1", label = node.label,
}
-- Overlay button to prevent clicks from doing anything
node[2] = {
node[4] = {
type = "image_button",
texture_name = "blank.png",
drawborder = false,
x = 0, y = 0,
w = node.w + extra_space, h = node.h,
label = "",
name = "\1", label = "",
}
node.y = node.y - LABEL_OFFSET
node.label = nil
node._label_hack = true
assert(#node == 2)
assert(#node == 4)
end
if node[w] then