Merge pull request #2603 from myk002/myk_resizingpanel

give more control over the resizing dimensions of ResizingPanels
develop
Myk 2023-01-14 01:10:26 -08:00 committed by GitHub
commit 977946e5bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

@ -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 minimum required to show its subviews. Pairs nicely with a parent Panel that has
``autoarrange_subviews`` enabled. ``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 Pages class
----------- -----------

@ -530,6 +530,11 @@ Window.ATTRS {
ResizingPanel = defclass(ResizingPanel, Panel) ResizingPanel = defclass(ResizingPanel, Panel)
ResizingPanel.ATTRS{
auto_height = true,
auto_width = false,
}
-- adjust our frame dimensions according to positions and sizes of our subviews -- adjust our frame dimensions according to positions and sizes of our subviews
function ResizingPanel:postUpdateLayout(frame_body) function ResizingPanel:postUpdateLayout(frame_body)
local w, h = 0, 0 local w, h = 0, 0
@ -550,6 +555,8 @@ function ResizingPanel:postUpdateLayout(frame_body)
end end
if not self.frame then self.frame = {} end if not self.frame then self.frame = {} end
local oldw, oldh = self.frame.w, self.frame.h 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 self.frame.w, self.frame.h = w, h
if not self._updateLayoutGuard and (oldw ~= w or oldh ~= h) then if not self._updateLayoutGuard and (oldw ~= w or oldh ~= h) then
self._updateLayoutGuard = true -- protect against infinite loops self._updateLayoutGuard = true -- protect against infinite loops