If you call this after you created a frame, then the frame is gonna be scaleable, and it's gonna build up everything needed for it:
Lua Code:
function PowaAurasOptions:ResizeFrame(frame)
local Width = frame:GetWidth()
local Height = frame:GetHeight()
local resizeframe = CreateFrame("Frame", nil, frame)
resizeframe:SetPoint("BottomRight", frame, "BottomRight", - 8, 7)
resizeframe:SetWidth(16)
resizeframe:SetHeight(16)
resizeframe:SetFrameLevel(frame:GetFrameLevel() + 7)
resizeframe:EnableMouse(true)
local resizetexture = resizeframe:CreateTexture(nil, "Artwork")
resizetexture:SetPoint("TopLeft", resizeframe, "TopLeft", 0, 0)
resizetexture:SetWidth(16)
resizetexture:SetHeight(16)
resizetexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
frame:SetMaxResize(Width * 1.5, Height * 1.5)
frame:SetMinResize(Width / 1.5, Height / 1.5)
frame:SetResizable(true)
resizeframe:SetScript("OnEnter", function(self)
resizetexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
end)
resizeframe:SetScript("OnLeave", function(self)
resizetexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
end)
resizeframe:SetScript("OnMouseDown", function(self, button)
if button == "RightButton" then
frame:SetWidth(Width)
frame:SetHeight(Height)
else
resizetexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
frame:StartSizing("Right")
end
end)
resizeframe:SetScript("OnMouseUp", function(self, button)
local x, y = GetCursorPosition()
local fx = self:GetLeft() * self:GetEffectiveScale()
local fy = self:GetBottom() * self:GetEffectiveScale()
if x >= fx and x <= (fx + self:GetWidth()) and y >= fy and y <= (fy + self:GetHeight()) then
resizetexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
else
resizetexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
end
frame:StopMovingOrSizing()
end)
local scrollframe = CreateFrame("ScrollFrame", nil, frame)
scrollframe:SetWidth(Width)
scrollframe:SetHeight(Height)
scrollframe:SetPoint("Topleft", frame, "Topleft", 0, 0)
frame:SetScript("OnSizeChanged", function(self)
local s = self:GetWidth() / Width
scrollframe:SetScale(s)
local childrens = {self:GetChildren()}
for _, child in ipairs(childrens) do
if child ~= resizeframe then
child:SetScale(s)
end
end
self:SetHeight(Height * s)
end)
end
There are still a few thing to do it with, like change the resize button's texture onmousedown and up.
Also ot exlude or only scale the scale button itself with lower frequency, to prevent it beeing unclickable. But its working properly.
Right click on the resize texture, reset the frame to the original size.