Pyroxenium / Basalt

A UI Framework for CC:Tweaked
MIT License
189 stars 34 forks source link

feature: fill in both sides of the border (i.e. the full box) when a frame becomes 1-wide #53

Open luiz00martins opened 1 year ago

luiz00martins commented 1 year ago

Problem

Making a frame with borders 1-wide creates seemingly undefined behaviour (in terms of how the borders will be drawn). In general, only one side is drawn at a time, leading to the other side being "open".

Minimal Working Example

-- Basalt configurated installer
local filePath = "/basalt.lua" --here you can change the file path default: basalt
if not(fs.exists(filePath))then
    shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command
end
local basalt = require(filePath:gsub(".lua", ""))

local main = basalt.createFrame("mainFrame")
local W, H = main:getSize()

local frame = main:addFrame("frame")
frame:setSize(W-2, math.floor(H/2))
    frame:setPosition(2, 5)
    frame:setBackground(colors.black)
    frame:setBorder(colors.white)

local animation = main:addAnimation("animation")
    :setObject(frame)
    :size(1, math.floor(H/2), 0.5, 0.5)

animation:play()

basalt.autoUpdate()

https://user-images.githubusercontent.com/43142209/229351360-cd6fb427-2057-4244-a3f4-4342c04e1992.mp4

Desired Solution

When becoming one-wide, a frame with border of color X should be completely filled by color X (simulating drawing on both sides of the border).

Minimal Working Example (Simulation)

-- Basalt configurated installer
local filePath = "/basalt.lua" --here you can change the file path default: basalt
if not(fs.exists(filePath))then
        shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command
end
local basalt = require(filePath:gsub(".lua", ""))

local main = basalt.createFrame("mainFrame")
local W, H = main:getSize()

local frame = main:addFrame("frame")
frame:setSize(W-2, math.floor(H/2))
    frame:setPosition(2, 5)
    frame:setBackground(colors.black)
    frame:setBorder(colors.white)

local animation = main:addAnimation("animation")
    :setObject(frame)
    :size(2, math.floor(H/2), 0.5, 0.5)
    :onDone(function()
        frame:setSize(1, math.floor(H/2))
        frame:setBackground(colors.white)
    end)

animation:play()

basalt.autoUpdate()

https://user-images.githubusercontent.com/43142209/229351943-e2d042cb-c9e3-4578-ba8a-4de086906e99.mp4

NoryiE commented 1 year ago

Hello. Sorry for not responding, i thought i had already responded.. >.<! I will fix this in basalt 1.7, thank you very much!