Thread: Resize frame
View Single Post
07-10-14, 03:33 PM   #28
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
I recently updated this code to allow the user 4 way rescaling, also some other tweaks.

Lua Code:
  1. -- This should be the saved variable which locks the scale
  2. local ScaleLocked = false
  3.  
  4. -- Frame must have a global reference to properly save it's postion
  5. function ResizeFrame(frame)
  6.     if not frame then
  7.         return
  8.     end
  9.     if frame.resizeable then
  10.         return
  11.     end
  12.     frame.width = frame:GetWidth()
  13.     frame.height = frame:GetHeight()
  14.     frame.scale = frame:GetScale()
  15.     frame.frameLevel = frame:GetFrameLevel()
  16.     frame:SetMovable(true)
  17.     frame:SetResizable(true)
  18.     frame:SetMaxResize(frame.width * 1.5, frame.height * 1.5)
  19.     frame:SetMinResize(frame.width / 1.5, frame.height / 1.5)
  20.     frame:SetUserPlaced(true)
  21.     if not frame.bottomrightframe then
  22.         frame.bottomrightframe = CreateFrame("Frame", nil, frame)
  23.         frame.bottomrightframe:SetFrameStrata(frame:GetFrameStrata())
  24.         frame.bottomrightframe:SetPoint("BottomRight", frame, "BottomRight", -8, 7)
  25.         frame.bottomrightframe:SetWidth(16)
  26.         frame.bottomrightframe:SetHeight(16)
  27.         frame.bottomrightframe:SetFrameLevel(frame.frameLevel + 7 or 20)
  28.         frame.bottomrightframe:EnableMouse(true)
  29.     end
  30.     if ScaleLocked then
  31.         frame.bottomrightframe:Hide()
  32.     else
  33.         frame.bottomrightframe:Show()
  34.     end
  35.     if not frame.bottomrighttexture then
  36.         frame.bottomrighttexture = frame.bottomrightframe:CreateTexture(nil, "Overlay")
  37.         frame.bottomrighttexture:SetPoint("TopLeft", frame.bottomrightframe, "TopLeft", 0, 0)
  38.         frame.bottomrighttexture:SetWidth(16)
  39.         frame.bottomrighttexture:SetHeight(16)
  40.         frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  41.     end
  42.     frame.bottomrightframe:SetScript("OnEnter", function(self)
  43.         frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  44.         frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  45.         frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  46.     end)
  47.     frame.bottomrightframe:SetScript("OnLeave", function(self)
  48.         frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  49.         frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  50.         frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  51.     end)
  52.     frame.bottomrightframe:SetScript("OnMouseDown", function(self, button)
  53.         if button == "RightButton" then
  54.             frame.resizing = nil
  55.             frame:SetWidth(frame.width)
  56.             frame:SetHeight(frame.height)
  57.             local childrens = {frame:GetChildren()}
  58.             for _, child in ipairs(childrens) do
  59.                 if child ~= frame.bottomleftframe and child ~= frame.bottomrightframe and child ~= frame.toprightframe and child ~= frame.topleftframe then
  60.                     child:SetScale(frame.scale)
  61.                 end
  62.             end
  63.             frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  64.             frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  65.             frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  66.         end
  67.         if button == "MiddleButton" then
  68.             frame.bottomrightframe:Hide()
  69.             frame.bottomleftframe:Hide()
  70.             frame.toprightframe:Hide()
  71.             frame.topleftframe:Hide()
  72.             ScaleLocked = true
  73.             frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  74.             frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  75.             frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  76.         elseif button == "LeftButton" then
  77.             frame.resizing = true
  78.             frame.direction = "BottomRight"
  79.             frame:StartSizing("Right")
  80.             frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  81.             frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  82.             frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  83.         end
  84.     end)
  85.     frame.bottomrightframe:SetScript("OnMouseUp", function(self, button)
  86.         local x, y = GetCursorPosition()
  87.         local fx = self:GetLeft() * self:GetEffectiveScale()
  88.         local fy = self:GetBottom() * self:GetEffectiveScale()
  89.         if x >= fx and x <= (fx + self:GetWidth()) and y >= fy and y <= (fy + self:GetHeight()) then
  90.             frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  91.             frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  92.             frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  93.         else
  94.             frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  95.             frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  96.             frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  97.         end
  98.         frame.resizing = nil
  99.         frame.direction = nil
  100.         frame:StopMovingOrSizing()
  101.     end)
  102.     if not frame.bottomleftframe then
  103.         frame.bottomleftframe = CreateFrame("Frame", nil, frame)
  104.         frame.bottomleftframe:SetFrameStrata(frame:GetFrameStrata())
  105.         frame.bottomleftframe:SetPoint("BottomLeft", frame, "BottomLeft", 8, 7)
  106.         frame.bottomleftframe:SetWidth(16)
  107.         frame.bottomleftframe:SetHeight(16)
  108.         frame.bottomleftframe:SetFrameLevel(frame.frameLevel + 7 or 20)
  109.         frame.bottomleftframe:EnableMouse(true)
  110.     end
  111.     if ScaleLocked then
  112.         frame.bottomleftframe:Hide()
  113.     else
  114.         frame.bottomleftframe:Show()
  115.     end
  116.     if not frame.bottomlefttexture then
  117.         frame.bottomlefttexture = frame.bottomleftframe:CreateTexture(nil, "Overlay")
  118.         local ULx, ULy, LLx, LLy, URx, URy, LRx, LRy = frame.bottomlefttexture:GetTexCoord()
  119.         frame.bottomlefttexture:SetTexCoord(URx, URy, LRx, LRy, ULx, ULy, LLx, LLy)
  120.         frame.bottomlefttexture:SetPoint("TopLeft", frame.bottomleftframe, "TopLeft", 0, 0)
  121.         frame.bottomlefttexture:SetWidth(16)
  122.         frame.bottomlefttexture:SetHeight(16)
  123.         frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  124.     end
  125.     frame.bottomleftframe:SetScript("OnEnter", function(self)
  126.         frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  127.         frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  128.         frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  129.     end)
  130.     frame.bottomleftframe:SetScript("OnLeave", function(self)
  131.         frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  132.         frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  133.         frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  134.     end)
  135.     frame.bottomleftframe:SetScript("OnMouseDown", function(self, button)
  136.         if button == "RightButton" then
  137.             frame.resizing = nil
  138.             frame:SetWidth(frame.width)
  139.             frame:SetHeight(frame.height)
  140.             local childrens = {frame:GetChildren()}
  141.             for _, child in ipairs(childrens) do
  142.                 if child ~= frame.bottomleftframe and child ~= frame.bottomrightframe and child ~= frame.toprightframe and child ~= frame.topleftframe then
  143.                     child:SetScale(frame.scale)
  144.                 end
  145.             end
  146.             frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  147.             frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  148.             frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  149.         end
  150.         if button == "MiddleButton" then
  151.             frame.bottomrightframe:Hide()
  152.             frame.bottomleftframe:Hide()
  153.             frame.toprightframe:Hide()
  154.             frame.topleftframe:Hide()
  155.             ScaleLocked = true
  156.             frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  157.             frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  158.             frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  159.         elseif button == "LeftButton" then
  160.             frame.resizing = true
  161.             frame.direction = "BottomLeft"
  162.             frame:StartSizing("Left")
  163.             frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  164.             frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  165.             frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  166.         end
  167.     end)
  168.     frame.bottomleftframe:SetScript("OnMouseUp", function(self, button)
  169.         local x, y = GetCursorPosition()
  170.         local fx = self:GetLeft() * self:GetEffectiveScale()
  171.         local fy = self:GetBottom() * self:GetEffectiveScale()
  172.         if x >= fx and x <= (fx + self:GetWidth()) and y >= fy and y <= (fy + self:GetHeight()) then
  173.             frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  174.             frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  175.             frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  176.         else
  177.             frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  178.             frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  179.             frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  180.         end
  181.         frame.resizing = nil
  182.         frame.direction = nil
  183.         frame:StopMovingOrSizing()
  184.     end)
  185.     if not frame.topleftframe then
  186.         frame.topleftframe = CreateFrame("Frame", nil, frame)
  187.         frame.topleftframe:SetFrameStrata(frame:GetFrameStrata())
  188.         frame.topleftframe:SetPoint("TopLeft", frame, "TopLeft", 8, -7)
  189.         frame.topleftframe:SetWidth(16)
  190.         frame.topleftframe:SetHeight(16)
  191.         frame.topleftframe:SetFrameLevel(frame.frameLevel + 7 or 20)
  192.         frame.topleftframe:EnableMouse(true)
  193.     end
  194.     if ScaleLocked then
  195.         frame.topleftframe:Hide()
  196.     else
  197.         frame.topleftframe:Show()
  198.     end
  199.     if not frame.toplefttexture then
  200.         frame.toplefttexture = frame.topleftframe:CreateTexture(nil, "Overlay")
  201.         local ULx, ULy, LLx, LLy, URx, URy, LRx, LRy = frame.toplefttexture:GetTexCoord()
  202.         frame.toplefttexture:SetTexCoord(LRx, LRy, URx, URy, LLx, LLy, ULx, ULy)
  203.         frame.toplefttexture:SetPoint("TopLeft", frame.topleftframe, "TopLeft", 0, 0)
  204.         frame.toplefttexture:SetWidth(16)
  205.         frame.toplefttexture:SetHeight(16)
  206.         frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  207.     end
  208.     frame.topleftframe:SetScript("OnEnter", function(self)
  209.         frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  210.         frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  211.         frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  212.     end)
  213.     frame.topleftframe:SetScript("OnLeave", function(self)
  214.         frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  215.         frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  216.         frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  217.     end)
  218.     frame.topleftframe:SetScript("OnMouseDown", function(self, button)
  219.         frame.direction = "TopLeft"
  220.         if button == "RightButton" then
  221.             frame:SetWidth(frame.width)
  222.             frame:SetHeight(frame.height)
  223.             local childrens = {frame:GetChildren()}
  224.             for _, child in ipairs(childrens) do
  225.                 if child ~= frame.bottomleftframe and child ~= frame.bottomrightframe and child ~= frame.toprightframe and child ~= frame.topleftframe then
  226.                     child:SetScale(frame.scale)
  227.                 end
  228.             end
  229.             frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  230.             frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  231.             frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  232.         end
  233.         if button == "MiddleButton" then
  234.             frame.bottomrightframe:Hide()
  235.             frame.bottomleftframe:Hide()
  236.             frame.toprightframe:Hide()
  237.             frame.topleftframe:Hide()
  238.             ScaleLocked = true
  239.             frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  240.             frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  241.             frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  242.         elseif button == "LeftButton" then
  243.             frame.resizing = true
  244.             frame:StartSizing("Top")
  245.             frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  246.             frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  247.             frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  248.         end
  249.     end)
  250.     frame.topleftframe:SetScript("OnMouseUp", function(self, button)
  251.         local x, y = GetCursorPosition()
  252.         local fx = self:GetLeft() * self:GetEffectiveScale()
  253.         local fy = self:GetBottom() * self:GetEffectiveScale()
  254.         if x >= fx and x <= (fx + self:GetWidth()) and y >= fy and y <= (fy + self:GetHeight()) then
  255.             frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  256.             frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  257.             frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  258.         else
  259.             frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  260.             frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  261.             frame.bottomlefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  262.         end
  263.         frame.resizing = nil
  264.         frame.direction = nil
  265.         frame:StopMovingOrSizing()
  266.     end)
  267.     if not frame.toprightframe then
  268.         frame.toprightframe = CreateFrame("Frame", nil, frame)
  269.         frame.toprightframe:SetFrameStrata(frame:GetFrameStrata())
  270.         frame.toprightframe:SetPoint("TopRight", frame, "TopRight", -8, -7)
  271.         frame.toprightframe:SetWidth(16)
  272.         frame.toprightframe:SetHeight(16)
  273.         frame.toprightframe:SetFrameLevel(frame.frameLevel + 7 or 20)
  274.         frame.toprightframe:EnableMouse(true)
  275.     end
  276.     if ScaleLocked then
  277.         frame.toprightframe:Hide()
  278.     else
  279.         frame.toprightframe:Show()
  280.     end
  281.     if not frame.toprighttexture then
  282.         frame.toprighttexture = frame.toprightframe:CreateTexture(nil, "Overlay")
  283.         local ULx, ULy, LLx, LLy, URx, URy, LRx, LRy = frame.toprighttexture:GetTexCoord()
  284.         frame.toprighttexture:SetTexCoord(LLx, LLy, ULx, ULy, LRx, LRy, URx, URy)
  285.         frame.toprighttexture:SetPoint("TopLeft", frame.toprightframe, "TopLeft", 0, 0)
  286.         frame.toprighttexture:SetWidth(16)
  287.         frame.toprighttexture:SetHeight(16)
  288.         frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  289.     end
  290.     frame.toprightframe:SetScript("OnEnter", function(self)
  291.         frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  292.         frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  293.         frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  294.     end)
  295.     frame.toprightframe:SetScript("OnLeave", function(self)
  296.         frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  297.         frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  298.         frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  299.     end)
  300.     frame.toprightframe:SetScript("OnMouseDown", function(self, button)
  301.         frame.direction = "TopRight"
  302.         if button == "RightButton" then
  303.             frame:SetWidth(frame.width)
  304.             frame:SetHeight(frame.height)
  305.             local childrens = {frame:GetChildren()}
  306.             for _, child in ipairs(childrens) do
  307.                 if child ~= frame.bottomleftframe and child ~= frame.bottomrightframe and child ~= frame.toprightframe and child ~= frame.topleftframe then
  308.                     child:SetScale(frame.scale)
  309.                 end
  310.             end
  311.             frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  312.             frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  313.             frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  314.         end
  315.         if button == "MiddleButton" then
  316.             frame.bottomrightframe:Hide()
  317.             frame.bottomleftframe:Hide()
  318.             frame.toprightframe:Hide()
  319.             frame.topleftframe:Hide()
  320.             ScaleLocked = true
  321.             frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  322.             frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  323.             frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  324.         elseif button == "LeftButton" then
  325.             frame.resizing = true
  326.             frame:StartSizing("Top")
  327.             frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  328.             frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  329.             frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  330.         end
  331.     end)
  332.     frame.toprightframe:SetScript("OnMouseUp", function(self, button)
  333.         local x, y = GetCursorPosition()
  334.         local fx = self:GetLeft() * self:GetEffectiveScale()
  335.         local fy = self:GetBottom() * self:GetEffectiveScale()
  336.         if x >= fx and x <= (fx + self:GetWidth()) and y >= fy and y <= (fy + self:GetHeight()) then
  337.             frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  338.             frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  339.             frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  340.         else
  341.             frame.toprighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  342.             frame.toplefttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  343.             frame.bottomrighttexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  344.         end
  345.         frame.resizing = nil
  346.         frame.direction = nil
  347.         frame:StopMovingOrSizing()
  348.     end)
  349.     frame:SetScript("OnSizeChanged", function(self)
  350.         local left, bottom = self:GetLeft(), self:GetBottom()
  351.         if self.direction == "TopLeft" or self.direction == "TopRight" then
  352.             if self.resizing then
  353.                 self:ClearAllPoints()
  354.                 if frame.direction == "TopLeft" then
  355.                     self:SetPoint("BottomRight", UIParent, "BottomRight", - (UIParent:GetWidth() - (left + self:GetWidth())), bottom)
  356.                 else
  357.                     self:SetPoint("BottomLeft", UIParent, "BottomLeft", left, bottom)
  358.                 end
  359.             end
  360.             local s = self:GetHeight() / frame.height
  361.             local childrens = {self:GetChildren()}
  362.             for _, child in ipairs(childrens) do
  363.                 if child ~= self.bottomleftframe and child ~= self.bottomrightframe and child ~= self.toprightframe and child ~= self.topleftframe then
  364.                     child:SetScale(s)
  365.                 end
  366.             end
  367.             self:SetWidth(frame.width * s)
  368.         else
  369.             if self.resizing then
  370.                 self:ClearAllPoints()
  371.                 if frame.direction == "BottomLeft" then
  372.                     self:SetPoint("TopLeft", UIParent, "TopLeft", left, (UIParent:GetWidth() - (bottom + self:GetHeight())))
  373.                 else
  374.                     self:SetPoint("TopLeft", UIParent, "TopLeft", left, (UIParent:GetWidth() - (bottom + self:GetHeight())))
  375.                 end
  376.             end
  377.             local s = self:GetWidth() / frame.width
  378.             local childrens = {self:GetChildren()}
  379.             for _, child in ipairs(childrens) do
  380.                 if child ~= self.bottomleftframe and child ~= self.bottomrightframe and child ~= self.toprightframe and child ~= self.topleftframe then
  381.                     child:SetScale(s)
  382.                 end
  383.             end
  384.             self:SetHeight(frame.height * s)
  385.         end
  386.     end)
  387.     frame.resizeable = true
  388. end

Last edited by Resike : 07-11-14 at 07:23 AM.
  Reply With Quote