Skip to content

Commit

Permalink
fix: Padding on frame
Browse files Browse the repository at this point in the history
  • Loading branch information
Lythium4848 committed Aug 16, 2023
1 parent e03f631 commit 84ba20b
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions lua/pixelui/elements/cl_frame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,35 @@ end
function PANEL:OnClose()
end

function PANEL:PerformLayout(w, h)
self.HeaderH = PIXEL.Scale(30)
local btnPad = PIXEL.Scale(6)
local btnSpacing = PIXEL.Scale(6)

if IsValid(self.CloseButton) then
local btnSize = self.HeaderH
self.CloseButton:SetSize(btnSize, btnSize)
self.CloseButton:SetPos(w - btnSize, (self.HeaderH - btnSize) / 2)
btnPad = btnPad + btnSize + btnSpacing
end

for _, btn in ipairs(self.ExtraButtons) do
local btnSize = self.HeaderH * (.6 or btn.HeaderIconSize)
btn:SetSize(btnSize, btnSize)
btn:SetPos(w - btnSize - btnPad, (self.HeaderH / 2) - (btnSize / 2))
btnPad = btnPad + btnSize + btnSpacing
end

if IsValid(self.SideBar) then
self.SideBar:SetPos(0, self.HeaderH)
self.SideBar:SetSize(PIXEL.Scale(200), h - self.HeaderH)
end

self.ContentPadding = PIXEL.Scale(8)
self:DockPadding(self.SideBar and PIXEL.Scale(200) or self.ContentPadding, self.HeaderH, self.ContentPadding, self.ContentPadding)
self:LayoutContent(w, h)
end

function PANEL:PaintHeader(x, y, w, h)
PIXEL.DrawRoundedBoxEx(PIXEL.Scale(8), x, y, w, h, PIXEL.Colors.Header, true, true)
local imgurID = self:GetImgurID()
Expand All @@ -267,8 +296,8 @@ end

function PANEL:Paint(w, h)
PIXEL.DrawRoundedBox(8, 0, 0, w, h, PIXEL.Colors.Header)
local contentX, contentY = self.SideBar and PIXEL.Scale(200) or self.ContentPadding, self.HeaderH + self.ContentPadding
PIXEL.DrawRoundedBoxEx(8, contentX, contentY, w - contentX - self.ContentPadding, h - contentY - self.ContentPadding, PIXEL.Colors.Background, true, true, true, true)
local contentX, contentY = self.SideBar and PIXEL.Scale(200) or self.ContentPadding, self.HeaderH
PIXEL.DrawRoundedBoxEx(8, contentX, contentY, w - contentX - self.ContentPadding, h - contentY, PIXEL.Colors.Background, true, true, true, true)
self:PaintHeader(0, 0, w, self.HeaderH)
self:PaintMore(w, h)
end
Expand Down

0 comments on commit 84ba20b

Please sign in to comment.