mirror of
https://gitlab.com/luk3yx/minetest-flow.git
synced 2025-09-18 20:56:31 +02:00
Rename popover "anchor" to "side"
I don't think "anchor" makes sense unless I invert the words (so anchor = "bottom" would mean the popup is above the parent). Hopefully no-one was relying on this yet (though there was a warning about breaking changes).
This commit is contained in:
parent
db3bd02ccd
commit
72c9ae3b12
@ -41,13 +41,13 @@ gui.VBox{
|
|||||||
padding = 0.2,
|
padding = 0.2,
|
||||||
bgcolor = "#222e",
|
bgcolor = "#222e",
|
||||||
|
|
||||||
-- "anchor" specifies how the popover is positioned relative to the
|
-- "side" specifies how the popover is positioned relative to the
|
||||||
-- parent, and can be "bottom" (default), "top", "left", or "right".
|
-- parent, and can be "bottom" (default), "top", "left", or "right".
|
||||||
anchor = ctx.form.anchor,
|
side = ctx.form.side,
|
||||||
|
|
||||||
-- align_h and align_v align the popover according to its parent
|
-- align_h and align_v align the popover according to its parent
|
||||||
-- element. You only need to specify align_h for
|
-- element. You only need to specify align_h for
|
||||||
-- anchor = "top"/"bottom" or align_v for anchor = "left"/"right",
|
-- side = "top"/"bottom" or align_v for side = "left"/"right",
|
||||||
-- this example specifies both so that it can demonstrate switching
|
-- this example specifies both so that it can demonstrate switching
|
||||||
-- between different anchor types.
|
-- between different anchor types.
|
||||||
align_h = "fill",
|
align_h = "fill",
|
||||||
@ -56,7 +56,7 @@ gui.VBox{
|
|||||||
-- Popover contents
|
-- Popover contents
|
||||||
gui.Label{label = "Hi there!"},
|
gui.Label{label = "Hi there!"},
|
||||||
gui.Dropdown{
|
gui.Dropdown{
|
||||||
name = "anchor",
|
name = "side",
|
||||||
items = {
|
items = {
|
||||||
"bottom",
|
"bottom",
|
||||||
"top",
|
"top",
|
||||||
|
@ -34,17 +34,17 @@ local function handle_popovers(box, node)
|
|||||||
local p_w, p_h = apply_padding(popover, 0, 0)
|
local p_w, p_h = apply_padding(popover, 0, 0)
|
||||||
local n_w, n_h = get_and_fill_in_sizes(node)
|
local n_w, n_h = get_and_fill_in_sizes(node)
|
||||||
|
|
||||||
if popover.anchor == "top" then
|
if popover.side == "top" then
|
||||||
offset_y = offset_y - p_h
|
offset_y = offset_y - p_h
|
||||||
elseif popover.anchor == "left" then
|
elseif popover.side == "left" then
|
||||||
offset_x = offset_x - p_w
|
offset_x = offset_x - p_w
|
||||||
elseif popover.anchor == "right" then
|
elseif popover.side == "right" then
|
||||||
offset_x = offset_x + n_w
|
offset_x = offset_x + n_w
|
||||||
else
|
else
|
||||||
offset_y = offset_y + n_h
|
offset_y = offset_y + n_h
|
||||||
end
|
end
|
||||||
|
|
||||||
if popover.anchor == "left" or popover.anchor == "right" then
|
if popover.side == "left" or popover.side == "right" then
|
||||||
align_types[popover.align_v or "auto"](popover, "y", "h", n_h - p_h)
|
align_types[popover.align_v or "auto"](popover, "y", "h", n_h - p_h)
|
||||||
else
|
else
|
||||||
align_types[popover.align_h or "auto"](popover, "x", "w", n_w - p_w)
|
align_types[popover.align_h or "auto"](popover, "x", "w", n_w - p_w)
|
||||||
|
Loading…
Reference in New Issue
Block a user