From 72c9ae3b122e43719e4046749fc996b05145c113 Mon Sep 17 00:00:00 2001 From: luk3yx Date: Sun, 17 Aug 2025 12:02:43 +1200 Subject: [PATCH] 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). --- doc/popovers.md | 8 ++++---- popover.lua | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/popovers.md b/doc/popovers.md index 2ed3cdb..a18d1f1 100644 --- a/doc/popovers.md +++ b/doc/popovers.md @@ -41,13 +41,13 @@ gui.VBox{ padding = 0.2, 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". - anchor = ctx.form.anchor, + side = ctx.form.side, -- align_h and align_v align the popover according to its parent -- 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 -- between different anchor types. align_h = "fill", @@ -56,7 +56,7 @@ gui.VBox{ -- Popover contents gui.Label{label = "Hi there!"}, gui.Dropdown{ - name = "anchor", + name = "side", items = { "bottom", "top", diff --git a/popover.lua b/popover.lua index ac4fe63..b0b905f 100644 --- a/popover.lua +++ b/popover.lua @@ -34,17 +34,17 @@ local function handle_popovers(box, node) local p_w, p_h = apply_padding(popover, 0, 0) 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 - elseif popover.anchor == "left" then + elseif popover.side == "left" then offset_x = offset_x - p_w - elseif popover.anchor == "right" then + elseif popover.side == "right" then offset_x = offset_x + n_w else offset_y = offset_y + n_h 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) else align_types[popover.align_h or "auto"](popover, "x", "w", n_w - p_w)