A number of addons, notably Details and Recount among others, have resizable frames. I, too, want resizable frames, but I’ve been looking through Gamepedia and a number of other resources and cannot find any references to how such frames might be implemented. I’m sure they are there, I just can’t find them.
I would be very grateful if someone could point me to a URL (or doc) that explained how to make a resizable frame?
Thanks
Simple example of dragging when the shift-key is down and resizing the bottom right corner when alt-key is down.
--[[
DotDeathSavedVars implied addon Saved Variables table
]]--
local function OnMoveStart(self)
if IsShiftKeyDown() then
self:StartMoving()
elseif IsAltKeyDown() then
self:StartSizing("BOTTOMRIGHT")
end
end
local function OnMovingStop(self)
self:StopMovingOrSizing()
end
local function OnSizeChanged(self)
if not DotDeathSavedVars then return end
DotDeathSavedVars.Width = self:GetWidth() -- Save the new width
DotDeathSavedVars.Height = self:GetHeight() -- and height to SavedVariables
end
local f = CreateFrame("Frame", "FizzleFrame", UIParent)
f:SetPoint("CENTER")
f:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background",edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 10, edgeSize = 11,insets = { left = 1, right = 1, top = 1, bottom = 1 }
})
f:SetBackdropColor(.15, .15, .15, .50)
f:SetBackdropBorderColor(.75, .75, .75, .5)
f:SetMovable(true)
f:SetResizable(true)
f:SetUserPlaced()
f:EnableMouse(true)
f:SetMinResize(60,12)
f:SetMaxResize(1000,500)
f:RegisterForDrag("LeftButton")
f:SetScript("OnDragStart", OnMoveStart)
f:SetScript("OnDragStop", OnMovingStop)
f:SetScript("OnSizeChanged", OnSizeChanged)
f:RegisterEvent("PLAYER_LOGIN")
f:SetScript("OnEvent", function(self, event, ...)
if not DotDeathSavedVars then
DotDeathSavedVars = {
Width = 100,
Height = 50,
}
end
self:SetSize(DotDeathSavedVars.Width, DotDeathSavedVars.Height)
end)
1 Like
and another one. there surprisingly is little documentation on resizable frames
local f = CreateFrame("Frame", nil, UIParent, "DialogBoxFrame")
f:SetPoint("CENTER")
f:SetSize(500, 400)
f:SetResizable(true)
f:SetMinResize(250, 200)
f:Show()
local rb = CreateFrame("Button", nil, f)
rb:SetPoint("BOTTOMRIGHT", -6, 7)
rb:SetSize(16, 16)
rb:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
rb:SetHighlightTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
rb:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
rb:SetScript("OnMouseDown", function()
f:StartSizing("BOTTOMRIGHT")
end)
rb:SetScript("OnMouseUp", function()
f:StopMovingOrSizing()
end)
3 Likes
Thank you both. Well, I contintued to search through various addons and, while there were many that supported resizable frames, I found the TellMeWhen addon started me down the path to answering my question.
However, the examples each of you presented seems even more straightforward. So, thank you again.
Now, I need to learn how to scale the frame’s other buttons, i.e., reposition themselves in the same relative position no matter what the size of the parent frame.
Cheers,
Never mind. Figured it out right away. I had specified the position of the buttons with actual numerical values for x,y position. When I changed to “BOTTOMLEFT” and “BOTTOMRIGHT”, it worked perfectly.
Cheers,