diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index cddd690e6..39bd57046 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -4420,6 +4420,13 @@ Subclass of Panel; automatically adjusts its own frame height and width to the minimum required to show its subviews. Pairs nicely with a parent Panel that has ``autoarrange_subviews`` enabled. +It has the following attributes: + +:auto_height: Sets self.frame.h from the positions and height of its subviews + (default is ``true``). +:auto_width: Sets self.frame.w from the positions and width of its subviews + (default is ``false``). + Pages class ----------- diff --git a/library/lua/gui/widgets.lua b/library/lua/gui/widgets.lua index dc598c8ad..e3cdfc808 100644 --- a/library/lua/gui/widgets.lua +++ b/library/lua/gui/widgets.lua @@ -530,6 +530,11 @@ Window.ATTRS { ResizingPanel = defclass(ResizingPanel, Panel) +ResizingPanel.ATTRS{ + auto_height = true, + auto_width = false, +} + -- adjust our frame dimensions according to positions and sizes of our subviews function ResizingPanel:postUpdateLayout(frame_body) local w, h = 0, 0 @@ -550,6 +555,8 @@ function ResizingPanel:postUpdateLayout(frame_body) end if not self.frame then self.frame = {} end local oldw, oldh = self.frame.w, self.frame.h + if not self.auto_height then h = oldh end + if not self.auto_width then w = oldw end self.frame.w, self.frame.h = w, h if not self._updateLayoutGuard and (oldw ~= w or oldh ~= h) then self._updateLayoutGuard = true -- protect against infinite loops