View Single Post
10-17-17, 11:55 AM   #16
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
This is my hack for it, it works on every full screen resolution on every UIParent scale ratio. Currently not working in windowed mode with a custom screen size.

There are 2 frames a PixelPerfect one and a standard game scaled one (NotPixelPerfect).

How does it works?

Instead of scaling you basically let a base frame do the sizing (which is always pixel perfect) and you do the rounded anchoring yourself, instead of letting the game do it.
There are other safety roundings for the base frame, however those only works properly if you use the default UIParent scale for your screen resolution. Generalizing that for every UIParent scale needs more math.

Lua Code:
  1. local AddonName, Addon = ...
  2.  
  3. local AddOn = { }
  4.  
  5. math.round = function(self)
  6.     return math.floor(self + 0.5)
  7. end
  8.  
  9. AddOn.events = CreateFrame("Frame")
  10. AddOn.events:RegisterEvent("ADDON_LOADED")
  11.  
  12. AddOn.events:SetScript("OnEvent", function(self, event, ...)
  13.     AddOn[event](AddOn, ...)
  14. end)
  15.  
  16.  
  17. function AddOn:ADDON_LOADED(addon)
  18.     if addon == AddonName then
  19.         self:OnLoad()
  20.         self:OnLoad2()
  21.     end
  22. end
  23.  
  24. function AddOn:OnLoad()
  25.     local frame = CreateFrame("Frame", "TestFrame", UIParent)
  26.     frame:SetSize(84, 84)
  27.     frame.width = 84
  28.     frame.height = 84
  29.     frame:SetPoint("TOPLEFT", UIParent, "TOPLEFT", (UIParent:GetWidth() / 2) - (frame:GetWidth() / 2), (-UIParent:GetHeight() / 2) + (frame:GetHeight() / 2))
  30.     frame:SetClampedToScreen(true)
  31.  
  32.     frame.backdrop = {
  33.         bgFile = "Interface\\Buttons\\WHITE8X8",
  34.         edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
  35.         tile = true,
  36.         tileSize = 16,
  37.         edgeSize = 14,
  38.         insets = {left = 3, right = 3, top = 3, bottom = 3},
  39.     }
  40.  
  41.     frame:SetBackdrop(frame.backdrop)
  42.     frame:SetBackdropColor(0.0, 0.0, 0.0, 0.5)
  43.     frame:SetBackdropBorderColor(0.3, 0.3, 0.3, 1.0)
  44.  
  45.     frame.scaled = CreateFrame("Frame", nil, frame)
  46.     frame.scaled:SetAllPoints(frame)
  47.  
  48.     frame.texture1 = frame:CreateTexture(nil, "ARTWORK", nil, -8)
  49.     frame.texture1:SetPoint("TOPLEFT", frame, "TOPLEFT", 10, -10)
  50.     frame.texture1:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -10, 10)
  51.     frame.texture1:SetColorTexture(1, 1, 1, 1)
  52.  
  53.     frame.texture2 = frame:CreateTexture(nil, "ARTWORK", nil, -7)
  54.     frame.texture2:SetPoint("TOPLEFT", frame.texture1, "TOPLEFT", 2, -2)
  55.     frame.texture2:SetPoint("BOTTOMRIGHT", frame.texture1, "BOTTOMRIGHT", -2, 2)
  56.     frame.texture2:SetColorTexture(0, 0, 0, 1)
  57.  
  58.     frame.texture3 = frame:CreateTexture(nil, "ARTWORK", nil, -6)
  59.     frame.texture3:SetPoint("TOPLEFT", frame.texture2, "TOPLEFT", 2, -2)
  60.     frame.texture3:SetPoint("BOTTOMRIGHT", frame.texture2, "BOTTOMRIGHT", -2, 2)
  61.     frame.texture3:SetColorTexture(1, 1, 1, 1)
  62.  
  63.     frame.texture4 = frame:CreateTexture(nil, "ARTWORK", nil, -5)
  64.     frame.texture4:SetPoint("TOPLEFT", frame.texture3, "TOPLEFT", 2, -2)
  65.     frame.texture4:SetPoint("BOTTOMRIGHT", frame.texture3, "BOTTOMRIGHT", -2, 2)
  66.     frame.texture4:SetColorTexture(0, 0, 0, 1)
  67.  
  68.     frame.texture5 = frame:CreateTexture(nil, "ARTWORK", nil, -4)
  69.     frame.texture5:SetPoint("TOPLEFT", frame.texture4, "TOPLEFT", 2, -2)
  70.     frame.texture5:SetPoint("BOTTOMRIGHT", frame.texture4, "BOTTOMRIGHT", -2, 2)
  71.     frame.texture5:SetColorTexture(1, 1, 1, 1)
  72.  
  73.     frame.texture6 = frame:CreateTexture(nil, "ARTWORK", nil, -3)
  74.     frame.texture6:SetPoint("TOPLEFT", frame.texture5, "TOPLEFT", 2, -2)
  75.     frame.texture6:SetPoint("BOTTOMRIGHT", frame.texture5, "BOTTOMRIGHT", -2, 2)
  76.     frame.texture6:SetColorTexture(0, 0, 0, 1)
  77.  
  78.     frame.texture7 = frame:CreateTexture(nil, "ARTWORK", nil, -2)
  79.     frame.texture7:SetPoint("TOPLEFT", frame.texture6, "TOPLEFT", 2, -2)
  80.     frame.texture7:SetPoint("BOTTOMRIGHT", frame.texture6, "BOTTOMRIGHT", -2, 2)
  81.     frame.texture7:SetColorTexture(1, 1, 1, 1)
  82.  
  83.     frame.texture8 = frame:CreateTexture(nil, "ARTWORK", nil, -1)
  84.     frame.texture8:SetPoint("TOPLEFT", frame.texture7, "TOPLEFT", 2, -2)
  85.     frame.texture8:SetPoint("BOTTOMRIGHT", frame.texture7, "BOTTOMRIGHT", -2, 2)
  86.     frame.texture8:SetColorTexture(0, 0, 0, 1)
  87.  
  88.     frame.texture9 = frame:CreateTexture(nil, "ARTWORK", nil, 0)
  89.     frame.texture9:SetPoint("TOPLEFT", frame.texture8, "TOPLEFT", 2, -2)
  90.     frame.texture9:SetPoint("BOTTOMRIGHT", frame.texture8, "BOTTOMRIGHT", -2, 2)
  91.     frame.texture9:SetColorTexture(1, 1, 1, 1)
  92.  
  93.     frame.texture10 = frame:CreateTexture(nil, "ARTWORK", nil, 1)
  94.     frame.texture10:SetPoint("TOPLEFT", frame.texture9, "TOPLEFT", 2, -2)
  95.     frame.texture10:SetPoint("BOTTOMRIGHT", frame.texture9, "BOTTOMRIGHT", -2, 2)
  96.     frame.texture10:SetColorTexture(0, 0, 0, 1)
  97.  
  98.     frame.texture11 = frame:CreateTexture(nil, "ARTWORK", nil, 2)
  99.     frame.texture11:SetPoint("TOPLEFT", frame.texture10, "TOPLEFT", 2, -2)
  100.     frame.texture11:SetPoint("BOTTOMRIGHT", frame.texture10, "BOTTOMRIGHT", -2, 2)
  101.     frame.texture11:SetColorTexture(1, 1, 1, 1)
  102.  
  103.     frame.pixel = frame.scaled:CreateFontString(nil, "ARTWORK")
  104.     frame.pixel:SetPoint("TOPLEFT", frame.texture11, "TOPLEFT", 2, -2)
  105.     frame.pixel:SetPoint("BOTTOMRIGHT", frame.texture11, "BOTTOMRIGHT", -2, 2)
  106.     frame.pixel:SetFontObject(GameFontNormalSmall)
  107.     frame.pixel:SetText("PP")
  108.  
  109.     -- Hooks
  110.     -- These roundings only work properly on the default UIParent scales:
  111.     hooksecurefunc(frame, "SetPoint", function(self)
  112.         if self.moving then
  113.             return
  114.         end
  115.  
  116.         if math.round(768 / (select(2, GetPhysicalScreenSize())) * 1000) / 1000 ~= math.round(UIParent:GetScale() * 1000) / 1000 then
  117.             return
  118.         end
  119.  
  120.         self.moving = true
  121.         self:SetMovable(true)
  122.  
  123.         local left, bottom = self:GetLeft(), self:GetBottom()
  124.  
  125.         if left and bottom then
  126.             local x = math.round(left)
  127.             local y = math.round(-UIParent:GetHeight() + bottom + self:GetHeight())
  128.  
  129.             self:ClearAllPoints()
  130.             self:SetPoint("TOPLEFT", UIParent, "TOPLEFT", x, y)
  131.         end
  132.  
  133.         self:SetMovable(false)
  134.         self.moving = nil
  135.     end)
  136.  
  137.     -- These roundings only work properly on the default UIParent scales:
  138.     hooksecurefunc(frame, "StopMovingOrSizing", function(self)
  139.         if math.round(768 / (select(2, GetPhysicalScreenSize())) * 1000) / 1000 ~= math.round(UIParent:GetScale() * 1000) / 1000 then
  140.             return
  141.         end
  142.  
  143.         self:SetMovable(true)
  144.  
  145.         local left, bottom = self:GetLeft(), self:GetBottom()
  146.  
  147.         if left and bottom then
  148.             local x = math.round(left)
  149.             local y = math.round(-UIParent:GetHeight() + bottom + self:GetHeight())
  150.  
  151.             self:ClearAllPoints()
  152.             self:SetPoint("TOPLEFT", UIParent, "TOPLEFT", x, y)
  153.         end
  154.  
  155.         self:SetMovable(false)
  156.     end)
  157.  
  158.     frame:HookScript("OnSizeChanged", function(self)
  159.         -- These roundings only work properly on the default UIParent scales:
  160.         if math.round(768 / (select(2, GetPhysicalScreenSize())) * 1000) / 1000 == math.round(UIParent:GetScale() * 1000) / 1000 then
  161.             self:SetSize(math.round(self:GetWidth()), math.round(self:GetHeight()))
  162.         end
  163.  
  164.         local UIScale = (768 / (select(2, GetPhysicalScreenSize())) / UIParent:GetScale())
  165.  
  166.         local scale = self:GetWidth() / self.width
  167.  
  168.         self.scaled:SetScale(scale)
  169.  
  170.         self.texture2:SetPoint("TOPLEFT", self.texture1, "TOPLEFT", math.round(2 * scale) * UIScale, math.round(-2 * scale) * UIScale)
  171.         self.texture2:SetPoint("BOTTOMRIGHT", self.texture1, "BOTTOMRIGHT", math.round(-2 * scale) * UIScale, math.round(2 * scale) * UIScale)
  172.  
  173.         self.texture3:SetPoint("TOPLEFT", self.texture2, "TOPLEFT", math.round(2 * scale) * UIScale, math.round(-2 * scale) * UIScale)
  174.         self.texture3:SetPoint("BOTTOMRIGHT", self.texture2, "BOTTOMRIGHT", math.round(-2 * scale) * UIScale, math.round(2 * scale) * UIScale)
  175.  
  176.         self.texture4:SetPoint("TOPLEFT", self.texture3, "TOPLEFT", math.round(2 * scale) * UIScale, math.round(-2 * scale) * UIScale)
  177.         self.texture4:SetPoint("BOTTOMRIGHT", self.texture3, "BOTTOMRIGHT", math.round(-2 * scale) * UIScale, math.round(2 * scale) * UIScale)
  178.  
  179.         self.texture5:SetPoint("TOPLEFT", self.texture4, "TOPLEFT", math.round(2 * scale) * UIScale, math.round(-2 * scale) * UIScale)
  180.         self.texture5:SetPoint("BOTTOMRIGHT", self.texture4, "BOTTOMRIGHT", math.round(-2 * scale) * UIScale, math.round(2 * scale) * UIScale)
  181.  
  182.         self.texture6:SetPoint("TOPLEFT", self.texture5, "TOPLEFT", math.round(2 * scale) * UIScale, math.round(-2 * scale) * UIScale)
  183.         self.texture6:SetPoint("BOTTOMRIGHT", self.texture5, "BOTTOMRIGHT", math.round(-2 * scale) * UIScale, math.round(2 * scale) * UIScale)
  184.  
  185.         self.texture7:SetPoint("TOPLEFT", self.texture6, "TOPLEFT", math.round(2 * scale) * UIScale, math.round(-2 * scale) * UIScale)
  186.         self.texture7:SetPoint("BOTTOMRIGHT", self.texture6, "BOTTOMRIGHT", math.round(-2 * scale) * UIScale, math.round(2 * scale) * UIScale)
  187.  
  188.         self.texture8:SetPoint("TOPLEFT", self.texture7, "TOPLEFT", math.round(2 * scale) * UIScale, math.round(-2 * scale) * UIScale)
  189.         self.texture8:SetPoint("BOTTOMRIGHT", self.texture7, "BOTTOMRIGHT", math.round(-2 * scale) * UIScale, math.round(2 * scale) * UIScale)
  190.  
  191.         self.texture9:SetPoint("TOPLEFT", self.texture8, "TOPLEFT", math.round(2 * scale) * UIScale, math.round(-2 * scale) * UIScale)
  192.         self.texture9:SetPoint("BOTTOMRIGHT", self.texture8, "BOTTOMRIGHT", math.round(-2 * scale) * UIScale, math.round(2 * scale) * UIScale)
  193.  
  194.         self.texture10:SetPoint("TOPLEFT", self.texture9, "TOPLEFT", math.round(2 * scale) * UIScale, math.round(-2 * scale) * UIScale)
  195.         self.texture10:SetPoint("BOTTOMRIGHT", self.texture9, "BOTTOMRIGHT", math.round(-2 * scale) * UIScale, math.round(2 * scale) * UIScale)
  196.  
  197.         self.texture11:SetPoint("TOPLEFT", self.texture10, "TOPLEFT", math.round(2 * scale) * UIScale, math.round(-2 * scale) * UIScale)
  198.         self.texture11:SetPoint("BOTTOMRIGHT", self.texture10, "BOTTOMRIGHT", math.round(-2 * scale) * UIScale, math.round(2 * scale) * UIScale)
  199.     end)
  200.  
  201.     -- Moving and Resizing functions
  202.     frame:EnableMouse(true)
  203.     --frame:SetMaxResize(800, 400)
  204.     frame:SetMinResize(42, 42)
  205.  
  206.     frame:SetScript("OnMouseDown", function(self, button)
  207.         if button == "LeftButton" then
  208.             self:SetMovable(true)
  209.             self:StartMoving()
  210.         end
  211.     end)
  212.     frame:SetScript("OnMouseUp", function(self, button)
  213.         if button == "LeftButton" then
  214.             self:StopMovingOrSizing()
  215.             self:SetMovable(false)
  216.  
  217.             -- These roundings only work properly on the default UIParent scales:
  218.             if math.round(768 / (select(2, GetPhysicalScreenSize())) * 1000) / 1000 ~= math.round(UIParent:GetScale() * 1000) / 1000 then
  219.                 return
  220.             end
  221.  
  222.             local left, bottom = self:GetLeft(), self:GetBottom()
  223.  
  224.             if left and bottom then
  225.                 local x = math.round(left)
  226.                 local y = math.round(-UIParent:GetHeight() + bottom + self:GetHeight())
  227.  
  228.                 self:ClearAllPoints()
  229.                 self:SetPoint("TOPLEFT", UIParent, "TOPLEFT", x, y)
  230.             end
  231.         end
  232.     end)
  233.  
  234.     frame.br = CreateFrame("Frame", nil, frame)
  235.     frame.br:SetPoint("TOPLEFT", frame, "BOTTOMRIGHT", 0, 0)
  236.     frame.br:SetSize(12, 12)
  237.     frame.br:EnableMouse(true)
  238.  
  239.     frame.br.texture = frame.br:CreateTexture(nil, "OVERLAY")
  240.     frame.br.texture:SetPoint("TOPLEFT", frame.br, "TOPLEFT", 0, 0)
  241.     frame.br.texture:SetSize(12, 12)
  242.     frame.br.texture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  243.  
  244.     frame.br:SetScript("OnEnter", function(self)
  245.         frame.br.texture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  246.     end)
  247.     frame.br:SetScript("OnLeave", function(self)
  248.         frame.br.texture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  249.     end)
  250.  
  251.     frame.br:SetScript("OnMouseDown", function(self, button)
  252.         if button == "LeftButton" then
  253.             frame.br.texture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  254.  
  255.             frame:SetResizable(true)
  256.             frame:StartSizing("BottomRight")
  257.         end
  258.     end)
  259.     frame.br:SetScript("OnMouseUp", function(self, button)
  260.         frame:StopMovingOrSizing()
  261.         frame:SetResizable(false)
  262.  
  263.         frame.br.texture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  264.     end)
  265. end
  266.  
  267. function AddOn:OnLoad2()
  268.     local frame = CreateFrame("Frame", "TestFrame2", UIParent)
  269.     frame:SetSize(84, 84)
  270.     frame.width = 84
  271.     frame.height = 84
  272.     frame:SetPoint("TOPLEFT", UIParent, "TOPLEFT", (UIParent:GetWidth() / 2) - (frame:GetWidth() / 2) + 100, (-UIParent:GetHeight() / 2) + (frame:GetHeight() / 2))
  273.     frame:SetClampedToScreen(true)
  274.  
  275.     frame.backdrop = {
  276.         bgFile = "Interface\\Buttons\\WHITE8X8",
  277.         edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
  278.         tile = true,
  279.         tileSize = 16,
  280.         edgeSize = 14,
  281.         insets = {left = 3, right = 3, top = 3, bottom = 3},
  282.     }
  283.  
  284.     frame:SetBackdrop(frame.backdrop)
  285.     frame:SetBackdropColor(0.0, 0.0, 0.0, 0.5)
  286.     frame:SetBackdropBorderColor(0.3, 0.3, 0.3, 1.0)
  287.  
  288.     frame.scaled = CreateFrame("Frame", nil, frame)
  289.     frame.scaled:SetAllPoints(frame)
  290.  
  291.     frame.texture1 = frame:CreateTexture(nil, "ARTWORK", nil, -8)
  292.     frame.texture1:SetPoint("TOPLEFT", frame, "TOPLEFT", 10, -10)
  293.     frame.texture1:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -10, 10)
  294.     frame.texture1:SetColorTexture(1, 1, 1, 1)
  295.  
  296.     frame.texture2 = frame.scaled:CreateTexture(nil, "ARTWORK", nil, -7)
  297.     frame.texture2:SetPoint("TOPLEFT", frame.texture1, "TOPLEFT", 2, -2)
  298.     frame.texture2:SetPoint("BOTTOMRIGHT", frame.texture1, "BOTTOMRIGHT", -2, 2)
  299.     frame.texture2:SetColorTexture(0, 0, 0, 2)
  300.  
  301.     frame.texture3 = frame.scaled:CreateTexture(nil, "ARTWORK", nil, -6)
  302.     frame.texture3:SetPoint("TOPLEFT", frame.texture2, "TOPLEFT", 2, -2)
  303.     frame.texture3:SetPoint("BOTTOMRIGHT", frame.texture2, "BOTTOMRIGHT", -2, 2)
  304.     frame.texture3:SetColorTexture(1, 1, 1, 1)
  305.  
  306.     frame.texture4 = frame.scaled:CreateTexture(nil, "ARTWORK", nil, -5)
  307.     frame.texture4:SetPoint("TOPLEFT", frame.texture3, "TOPLEFT", 2, -2)
  308.     frame.texture4:SetPoint("BOTTOMRIGHT", frame.texture3, "BOTTOMRIGHT", -2, 2)
  309.     frame.texture4:SetColorTexture(0, 0, 0, 1)
  310.  
  311.     frame.texture5 = frame.scaled:CreateTexture(nil, "ARTWORK", nil, -4)
  312.     frame.texture5:SetPoint("TOPLEFT", frame.texture4, "TOPLEFT", 2, -2)
  313.     frame.texture5:SetPoint("BOTTOMRIGHT", frame.texture4, "BOTTOMRIGHT", -2, 2)
  314.     frame.texture5:SetColorTexture(1, 1, 1, 1)
  315.  
  316.     frame.texture6 = frame.scaled:CreateTexture(nil, "ARTWORK", nil, -3)
  317.     frame.texture6:SetPoint("TOPLEFT", frame.texture5, "TOPLEFT", 2, -2)
  318.     frame.texture6:SetPoint("BOTTOMRIGHT", frame.texture5, "BOTTOMRIGHT", -2, 2)
  319.     frame.texture6:SetColorTexture(0, 0, 0, 1)
  320.  
  321.     frame.texture7 = frame.scaled:CreateTexture(nil, "ARTWORK", nil, -2)
  322.     frame.texture7:SetPoint("TOPLEFT", frame.texture6, "TOPLEFT", 2, -2)
  323.     frame.texture7:SetPoint("BOTTOMRIGHT", frame.texture6, "BOTTOMRIGHT", -2, 2)
  324.     frame.texture7:SetColorTexture(1, 1, 1, 1)
  325.  
  326.     frame.texture8 = frame.scaled:CreateTexture(nil, "ARTWORK", nil, -1)
  327.     frame.texture8:SetPoint("TOPLEFT", frame.texture7, "TOPLEFT", 2, -2)
  328.     frame.texture8:SetPoint("BOTTOMRIGHT", frame.texture7, "BOTTOMRIGHT", -2, 2)
  329.     frame.texture8:SetColorTexture(0, 0, 0, 1)
  330.  
  331.     frame.texture9 = frame.scaled:CreateTexture(nil, "ARTWORK", nil, 0)
  332.     frame.texture9:SetPoint("TOPLEFT", frame.texture8, "TOPLEFT", 2, -2)
  333.     frame.texture9:SetPoint("BOTTOMRIGHT", frame.texture8, "BOTTOMRIGHT", -2, 2)
  334.     frame.texture9:SetColorTexture(1, 1, 1, 1)
  335.  
  336.     frame.texture10 = frame.scaled:CreateTexture(nil, "ARTWORK", nil, 1)
  337.     frame.texture10:SetPoint("TOPLEFT", frame.texture9, "TOPLEFT", 2, -2)
  338.     frame.texture10:SetPoint("BOTTOMRIGHT", frame.texture9, "BOTTOMRIGHT", -2, 2)
  339.     frame.texture10:SetColorTexture(0, 0, 0, 1)
  340.  
  341.     frame.texture11 = frame.scaled:CreateTexture(nil, "ARTWORK", nil, 2)
  342.     frame.texture11:SetPoint("TOPLEFT", frame.texture10, "TOPLEFT", 2, -2)
  343.     frame.texture11:SetPoint("BOTTOMRIGHT", frame.texture10, "BOTTOMRIGHT", -2, 2)
  344.     frame.texture11:SetColorTexture(1, 1, 1, 1)
  345.  
  346.     frame.pixel = frame.scaled:CreateFontString(nil, "ARTWORK")
  347.     frame.pixel:SetPoint("TOPLEFT", frame.texture11, "TOPLEFT", 2, -2)
  348.     frame.pixel:SetPoint("BOTTOMRIGHT", frame.texture11, "BOTTOMRIGHT", -2, 2)
  349.     frame.pixel:SetFontObject(GameFontNormalSmall)
  350.     frame.pixel:SetText("NPP")
  351.  
  352.     frame:HookScript("OnSizeChanged", function(self)
  353.         local scale = self:GetWidth() / self.width
  354.  
  355.         self.scaled:SetScale(scale)
  356.     end)
  357.  
  358.     -- Moving and Resizing functions
  359.     frame:EnableMouse(true)
  360.     --frame:SetMaxResize(800, 400)
  361.     frame:SetMinResize(42, 42)
  362.  
  363.     frame:SetScript("OnMouseDown", function(self, button)
  364.         if button == "LeftButton" then
  365.             self:SetMovable(true)
  366.             self:StartMoving()
  367.         end
  368.     end)
  369.     frame:SetScript("OnMouseUp", function(self, button)
  370.         if button == "LeftButton" then
  371.             self:StopMovingOrSizing()
  372.             self:SetMovable(false)
  373.         end
  374.     end)
  375.  
  376.     frame.br = CreateFrame("Frame", nil, frame)
  377.     frame.br:SetPoint("TOPLEFT", frame, "BOTTOMRIGHT", 0, 0)
  378.     frame.br:SetSize(12, 12)
  379.     frame.br:EnableMouse(true)
  380.  
  381.     frame.br.texture = frame.br:CreateTexture(nil, "OVERLAY")
  382.     frame.br.texture:SetPoint("TOPLEFT", frame.br, "TOPLEFT", 0, 0)
  383.     frame.br.texture:SetSize(12, 12)
  384.     frame.br.texture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  385.  
  386.     frame.br:SetScript("OnEnter", function(self)
  387.         frame.br.texture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
  388.     end)
  389.     frame.br:SetScript("OnLeave", function(self)
  390.         frame.br.texture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  391.     end)
  392.  
  393.     frame.br:SetScript("OnMouseDown", function(self, button)
  394.         if button == "LeftButton" then
  395.             frame.br.texture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
  396.  
  397.             frame:SetResizable(true)
  398.             frame:StartSizing("BottomRight")
  399.         end
  400.     end)
  401.     frame.br:SetScript("OnMouseUp", function(self, button)
  402.         frame:StopMovingOrSizing()
  403.         frame:SetResizable(false)
  404.  
  405.         frame.br.texture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
  406.     end)
  407. end

Edit: Made some fixes.

Last edited by Resike : 10-17-17 at 03:30 PM.
  Reply With Quote