Geyser H/VBox: Do not resize if policy is not dynamic#3941
Geyser H/VBox: Do not resize if policy is not dynamic#3941demonnic wants to merge 8 commits intoMudlet:developmentfrom
Conversation
…licy for that constraint is not dynamic
|
Hey there! Thanks for helping Mudlet improve. 🌟 Test versionsYou can directly test the changes here:
No need to install anything - just unzip and run. |
|
@Edru2 could you review? |
|
I agree with you that Geyser.fixed shouldn't convert pixel values to percentages but this creates another (new) issue. TestHBox = Geyser.HBox:new({
name="HBox",
x=0, y=0,
width="30%", height="10%",
})
local label1 = Geyser.Label:new({
name="Label1",
width="250px",
h_policy=Geyser.Fixed,
},
TestHBox)
label1:echo("Label 1", "black", "c")
label1:setColor(255, 0, 0)
local label2 = Geyser.Label:new({
name="Label2",
},
TestHBox)
label2:echo("Label 2", "black", "c")
label2:setColor(0, 255, 0)
local label3 = Geyser.Label:new({
name="Label3",
h_stretch_factor=2.0,
},
TestHBox)
label3:echo("Label 3", nil, "c")
label3:setColor(0, 0, 255)
local label4 = Geyser.Label:new({
name="Label4",
width="200px",
h_policy=Geyser.Fixed,
},
TestHBox)
label4:echo("Label 4", "black", "c")
label4:setColor(0, 255, 255)And then use in the command line. |
|
@demonnic check out demonnic#5 |
fixed/dynamic mixed suggestion
|
That does indeed fix that. Good catch, and thanks for the fix |
|
should we set self.contains_fixed to false at the start of the organize loop, so that if it later does not contain fixed items it will report properly? |
Yes, I missed that one :) |
…ixed items have been removed
|
added |
|
ok, I think this is good now. @Edru2 ? |
vadi2
left a comment
There was a problem hiding this comment.
Haven't tested it myself, approving based on demonnics and Edru's work.
|
Closing this PR so I can open a new one without the bogus unfinished checks. |

Brief overview of PR changes/additions
Right now, if you create an item with a fixed pixel height and v_policy of fixed, and add it to a VBox, then it will not visibly change size but it does get resized from that static pixel height to a % of the vbox's height which represents the same number of pixels.
This is ok, unless your vbox changes size, as now the item inside of it will change sizes to be the same percentage of the new size. With this change, the height or width is only resized if the policy actually calls for it.
Motivation for adding to Mudlet
I was working on an elastic version of VBox which grows or shrinks to fit its contents, but it quickly ran away as the items inside changed size, which told the vbox to get bigger, which made the items inside bigger...
Other info (issues closed, discussion etc)
This does involve a small performance hit the first time an item is added to an H/VBox if both h_policy and v_policy are Geyser.Dynamic, but because I guard against calling resize if the height or width is already where it should be, every change after that should result in the same or better performance as it currently has.
Given the VBox makes it the full width if h_policy is dynamic, you can also reduce this by setting the width to 100% and it won't need to resize it. Same with HBox and the v_policy/height