Thread: Resize frame
View Single Post
01-24-14, 05:12 AM   #1
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Resize frame

I would like to resize a frame with the mouse, just like the chat frame resizing, however i don't want anything fancy i just want to increase and decrase the scale of the frame based on the mouse's position. Here is my code so far:

Lua Code:
  1. local function LeftButtonOnUpdate(frame, elapsed)
  2.     --frame.x = math.floor(frame:GetLeft() + (frame:GetWidth() - UIParent:GetWidth()) / 2 + 0.5)
  3.     --frame.y = math.floor(frame:GetTop() - (frame:GetHeight() + UIParent:GetHeight()) / 2 + 0.5)
  4.     FRAMETORESIZE:SetScale(FRAMETORESIZE:GetScale() * 1.001)
  5. end
  6.  
  7. local function SizeOnMouseDown(frame, button)
  8.     if button == "LeftButton" then
  9.         frame.x, frame.y = GetCursorPosition()
  10.         frame:SetScript("OnUpdate", LeftButtonOnUpdate)
  11.     end
  12. end
  13.  
  14. local function SizeOnMouseUp(frame, button)
  15.     if button == "LeftButton" then
  16.         frame:SetScript("OnUpdate", nil)
  17.     end
  18. end
  19.  
  20. function ResizeStart(frame)
  21.     frame:SetScript("OnMouseDown", SizeOnMouseDown)
  22.     frame:SetScript("OnMouseUp", SizeOnMouseUp)
  23. end

Last edited by Resike : 01-24-14 at 05:17 AM.
  Reply With Quote