Skip to content

Commit a7dc3a2

Browse files
authored
Fix for Geyser HBox/VBox with width/height at 0 (Mudlet#3909)
* prevent height/width of 0 * better solution still keeps hbox at 0 * small correction
1 parent 46320c3 commit a7dc3a2

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

src/mudlet-lua/lua/geyser/GeyserHBox.lua

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ end
2626
-- Called when a new element is added
2727
function Geyser.HBox:organize()
2828
self.parent:reposition()
29+
-- Workaround for issue with width/height being 0 at creation
30+
if self:get_width() == 0 then
31+
self:resize("0.9px", nil)
32+
end
33+
if self:get_height() == 0 then
34+
self:resize(nil, "0.9px")
35+
end
2936
local window_width = (self:calculate_dynamic_window_size().width / self:get_width()) * 100
3037
local start_x = 0
3138
for _, window_name in ipairs(self.windows) do
@@ -40,7 +47,7 @@ function Geyser.HBox:organize()
4047
height = 100
4148
end
4249
window:resize(width.."%", height.."%")
43-
start_x = start_x + (window:get_width() / self:get_width()) * 100
50+
start_x = start_x + width
4451
end
4552
end
4653

@@ -65,12 +72,4 @@ function Geyser.HBox:new2 (cons, container)
6572
cons.useAdd2 = true
6673
local me = self:new(cons, container)
6774
return me
68-
end
69-
70-
--- Overridden constructor to use add2
71-
function Geyser.HBox:new2 (cons, container)
72-
cons = cons or {}
73-
cons.useAdd2 = true
74-
local me = self:new(cons, container)
75-
return me
76-
end
75+
end

src/mudlet-lua/lua/geyser/GeyserVBox.lua

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@ end
2727
-- Called when a new element is added
2828
function Geyser.VBox:organize()
2929
self.parent:reposition()
30-
31-
local window_height = (self:calculate_dynamic_window_size().height / self.get_height()) * 100
30+
-- Workaround for issue with width/height being 0 at creation
31+
if self:get_width() == 0 then
32+
self:resize("0.9px", nil)
33+
end
34+
if self:get_height() == 0 then
35+
self:resize(nil, "0.9px")
36+
end
37+
local window_height = (self:calculate_dynamic_window_size().height / self:get_height()) * 100
3238
local start_y = 0
3339
for _, window_name in ipairs(self.windows) do
3440
local window = self.windowList[window_name]
@@ -42,7 +48,7 @@ function Geyser.VBox:organize()
4248
height = window_height * window.v_stretch_factor
4349
end
4450
window:resize(width.."%", height.."%")
45-
start_y = start_y + (window:get_height() / self:get_height()) * 100
51+
start_y = start_y + height
4652
end
4753
end
4854

@@ -66,4 +72,4 @@ function Geyser.VBox:new2 (cons, container)
6672
cons.useAdd2 = true
6773
local me = self:new(cons, container)
6874
return me
69-
end
75+
end

0 commit comments

Comments
 (0)