Skip to content

Commit

Permalink
Merge pull request #5 from Edru2/donot_resize_if_not_dynamic
Browse files Browse the repository at this point in the history
fixed/dynamic mixed suggestion
  • Loading branch information
demonnic committed Jun 29, 2020
2 parents 46b9ee4 + de2e360 commit d1e71f3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/mudlet-lua/lua/geyser/GeyserHBox.lua
Expand Up @@ -25,7 +25,6 @@ end
--- Responsible for organizing the elements inside the HBox
-- Called when a new element is added
function Geyser.HBox:organize()
self.parent:reposition()
-- Workaround for issue with width/height being 0 at creation
if self:get_width() == 0 then
self:resize("0.9px", nil)
Expand All @@ -39,6 +38,9 @@ function Geyser.HBox:organize()
local window = self.windowList[window_name]
local width = (window:get_width() / self:get_width()) * 100
local height = (window:get_height() / self:get_height()) * 100
if window.h_policy == Geyser.Fixed or window.v_policy == Geyser.Fixed then
self.contains_fixed = true
end
window:move(start_x.."%", "0%")
if window.h_policy == Geyser.Dynamic then
width = window_width * window.h_stretch_factor
Expand All @@ -56,6 +58,13 @@ function Geyser.HBox:organize()
end
end

function Geyser.HBox:reposition()
Geyser.Container.reposition(self)
if self.contains_fixed then
self:organize()
end
end

Geyser.HBox.parent = Geyser.Container

function Geyser.HBox:new(cons, container)
Expand Down
11 changes: 10 additions & 1 deletion src/mudlet-lua/lua/geyser/GeyserVBox.lua
Expand Up @@ -26,7 +26,6 @@ end
--- Responsible for organizing the elements inside the VBox
-- Called when a new element is added
function Geyser.VBox:organize()
self.parent:reposition()
-- Workaround for issue with width/height being 0 at creation
if self:get_width() == 0 then
self:resize("0.9px", nil)
Expand All @@ -41,6 +40,9 @@ function Geyser.VBox:organize()
window:move("0%", start_y.."%")
local width = (window:get_width() / self:get_width()) * 100
local height = (window:get_height() / self:get_height()) * 100
if window.h_policy == Geyser.Fixed or window.v_policy == Geyser.Fixed then
self.contains_fixed = true
end
if window.h_policy == Geyser.Dynamic then
width = 100
if window.width ~= width .. "%" then
Expand All @@ -57,6 +59,13 @@ function Geyser.VBox:organize()
end
end

function Geyser.VBox:reposition()
Geyser.Container.reposition(self)
if self.contains_fixed then
self:organize()
end
end

Geyser.VBox.parent = Geyser.Container

function Geyser.VBox:new(cons, container)
Expand Down

0 comments on commit d1e71f3

Please sign in to comment.