fixed layout resizing
This commit is contained in:
@@ -1048,6 +1048,7 @@ function Element:update(dt)
|
|||||||
-- set pressed flag
|
-- set pressed flag
|
||||||
self._pressed = true
|
self._pressed = true
|
||||||
elseif not love.mouse.isDown(1) and self._pressed then
|
elseif not love.mouse.isDown(1) and self._pressed then
|
||||||
|
Logger:debug("calling callback")
|
||||||
self.callback(self)
|
self.callback(self)
|
||||||
self._pressed = false
|
self._pressed = false
|
||||||
end
|
end
|
||||||
@@ -1083,7 +1084,7 @@ function Element:resize(newGameWidth, newGameHeight)
|
|||||||
self.y = self.y * ratioH
|
self.y = self.y * ratioH
|
||||||
-- Update children positions and sizes
|
-- Update children positions and sizes
|
||||||
for _, child in ipairs(self.children) do
|
for _, child in ipairs(self.children) do
|
||||||
child:resize(ratioW, ratioH)
|
child:resize(newGameWidth, newGameHeight)
|
||||||
end
|
end
|
||||||
|
|
||||||
self:layoutChildren()
|
self:layoutChildren()
|
||||||
|
|||||||
51
simple_resize_test.lua
Normal file
51
simple_resize_test.lua
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/env lua
|
||||||
|
|
||||||
|
-- Load test framework and dependencies
|
||||||
|
package.path = package.path .. ";?.lua"
|
||||||
|
require("testing/loveStub") -- Required to mock LOVE functions
|
||||||
|
local FlexLove = require("FlexLove")
|
||||||
|
local Gui, enums = FlexLove.GUI, FlexLove.enums
|
||||||
|
local Positioning, FlexDirection, AlignItems =
|
||||||
|
enums.Positioning, enums.FlexDirection, enums.AlignItems
|
||||||
|
|
||||||
|
-- Simple resize test
|
||||||
|
print("=== Simple Resize Test ===")
|
||||||
|
|
||||||
|
-- Initial window size: 800x600
|
||||||
|
love.window.setMode(800, 600)
|
||||||
|
|
||||||
|
local parent = Gui.new({
|
||||||
|
id = "parent",
|
||||||
|
x = 100,
|
||||||
|
y = 100,
|
||||||
|
w = 200,
|
||||||
|
h = 150,
|
||||||
|
positioning = Positioning.FLEX,
|
||||||
|
flexDirection = FlexDirection.HORIZONTAL,
|
||||||
|
alignItems = AlignItems.STRETCH,
|
||||||
|
})
|
||||||
|
|
||||||
|
local child = Gui.new({
|
||||||
|
id = "child",
|
||||||
|
w = 100,
|
||||||
|
h = 80,
|
||||||
|
positioning = Positioning.FLEX,
|
||||||
|
})
|
||||||
|
|
||||||
|
parent:addChild(child)
|
||||||
|
|
||||||
|
print("Before resize:")
|
||||||
|
print(" Parent: x=" .. parent.x .. ", y=" .. parent.y .. ", w=" .. parent.width .. ", h=" .. parent.height)
|
||||||
|
print(" Child: x=" .. child.x .. ", y=" .. child.y .. ", w=" .. child.width .. ", h=" .. child.height)
|
||||||
|
|
||||||
|
-- Resize window to 1600x1200 (2x scale)
|
||||||
|
love.window.setMode(1600, 1200)
|
||||||
|
Gui.resize()
|
||||||
|
|
||||||
|
print("After resize to 1600x1200:")
|
||||||
|
print(" Parent: x=" .. parent.x .. ", y=" .. parent.y .. ", w=" .. parent.width .. ", h=" .. parent.height)
|
||||||
|
print(" Child: x=" .. child.x .. ", y=" .. child.y .. ", w=" .. child.width .. ", h=" .. child.height)
|
||||||
|
|
||||||
|
print("Expected child dimensions after 2x resize:")
|
||||||
|
print(" Child width: 200 (100 * 2)")
|
||||||
|
print(" Child height: 160 (80 * 2)")
|
||||||
36
testing/test_font_resize.lua
Normal file
36
testing/test_font_resize.lua
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
-- Test current font behavior during resize
|
||||||
|
package.path = package.path .. ";?.lua"
|
||||||
|
|
||||||
|
require("testing/loveStub") -- Required to mock LOVE functions
|
||||||
|
local FlexLove = require("FlexLove")
|
||||||
|
local Gui = FlexLove.GUI
|
||||||
|
|
||||||
|
local function testCurrentFontBehavior()
|
||||||
|
print("=== Testing Current Font Behavior During Resize ===")
|
||||||
|
|
||||||
|
Gui.destroy() -- Clean slate
|
||||||
|
|
||||||
|
-- Create element with text and specific font size
|
||||||
|
local element = Gui.new({
|
||||||
|
id = "textElement",
|
||||||
|
x = 100, y = 100,
|
||||||
|
w = 400, h = 200,
|
||||||
|
text = "Hello World",
|
||||||
|
textSize = 16
|
||||||
|
})
|
||||||
|
element.prevGameSize = { width = 800, height = 600 }
|
||||||
|
|
||||||
|
print("Before resize:")
|
||||||
|
print(string.format("Element: %dx%d, textSize: %s", element.width, element.height, element.textSize or "nil"))
|
||||||
|
|
||||||
|
-- Resize from 800x600 to 1200x900 (1.5x scale)
|
||||||
|
element:resize(1200, 900)
|
||||||
|
|
||||||
|
print("\nAfter resize (1200x900):")
|
||||||
|
print(string.format("Element: %dx%d, textSize: %s", element.width, element.height, element.textSize or "nil"))
|
||||||
|
|
||||||
|
print("\nExpected: Element should be 600x300, textSize should scale to 24 (16 * 1.5)")
|
||||||
|
print("Current: textSize doesn't scale - this is the issue we need to fix")
|
||||||
|
end
|
||||||
|
|
||||||
|
testCurrentFontBehavior()
|
||||||
Reference in New Issue
Block a user