Quantcast
Resizing Frames - WoWInterface
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-06-18, 12:02 PM   #1
JDoubleU00
A Firelord
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 454
Resizing Frames

I've tried a bit of searching both here and Google, and only found a few examples. I'm trying to make JWXPBar and JWRepBar re-sizable. The frame moves regardless of which modifier I use. Here is my code (I've included the entire addon just in case ). Lines 31-34 and 60-79 is the code related to resizing.

Lua Code:
  1. -- Yes Another XP Bar.
  2.  
  3. --Config area
  4. local JWBarHeight = 28
  5. local JWBarWidth = 350
  6. local JWBarPoint = {"CENTER", "JWRepBarFrame","CENTER", 0, 0}
  7. local JWBarTexture = "Interface\\TargetingFrame\\UI-StatusBar"
  8. --local JWBarFont = [[Fonts\FRIZQT__.TTF]]
  9. --local JWBarFont = [[Interface\addons\JWRepBar\ROADWAY_.ttf]]
  10. --local JWBarFontSize = 18
  11. --local JWBarFontFlags = "NONE"
  12.  
  13. --Beyond here be dragons
  14. function comma_value(n)
  15.   return tostring(math.floor(n)):reverse():gsub("(%d%d%d)","%1,"):gsub(",(%-?)$","%1"):reverse()
  16. end
  17.  
  18. local function tchelper(first, rest)
  19.   return first:upper()..rest:lower()
  20. end
  21.  
  22. local JWRepBarFrame = CreateFrame("Frame", "JWRepBarFrame", UIParent)
  23. JWRepBarFrame:SetFrameStrata("HIGH")
  24. JWRepBarFrame:SetHeight(JWBarHeight)
  25. JWRepBarFrame:SetWidth(JWBarWidth)
  26. if IsAddOnLoaded("JWXPBar") then
  27.     JWRepBarFrame:SetPoint("BOTTOM", "JWXPBar", "TOP", 0, 5)
  28. else
  29.     JWRepBarFrame:SetPoint("CENTER", UIPARENT, "CENTER", 0, -275)
  30. end
  31. JWRepBarFrame:EnableMouse(true)
  32. JWRepBarFrame:SetMovable(true)
  33. JWRepBarFrame:SetClampedToScreen(true)
  34. JWRepBarFrame:SetResizable(true)
  35.  
  36. --Create Background and Border
  37. local backdrop = JWRepBarFrame:CreateTexture(nil, "BACKGROUND")
  38. backdrop:SetHeight(JWBarHeight)
  39. backdrop:SetWidth(JWBarWidth)
  40. backdrop:SetPoint(unpack(JWBarPoint))
  41. backdrop:SetTexture(JWBarTexture)
  42. backdrop:SetVertexColor(0.1, 0.1, 0.1)
  43. JWRepBarFrame.backdrop = backdrop
  44.  
  45. --Rep Bar
  46. local JWRepBar = CreateFrame("StatusBar", "JWRepBar", JWRepBarFrame)
  47. JWRepBar:SetWidth(JWBarWidth)
  48. JWRepBar:SetHeight(JWBarHeight)
  49. JWRepBar:SetPoint(unpack(JWBarPoint))
  50. JWRepBar:SetStatusBarTexture(JWBarTexture)
  51. JWRepBar:GetStatusBarTexture():SetHorizTile(false)
  52. JWRepBarFrame.JWRepBar = JWRepBar
  53.  
  54. --Create XP Text
  55. local Text = JWRepBar:CreateFontString("JWRepBarText", "OVERLAY", "NumberFontNormal") --GameFontNormal
  56. --Text:SetFont(JWBarFont, JWBarFontSize, JWBarFontFlags)
  57. Text:SetPoint("CENTER", JWRepBar, "CENTER",0,1)
  58. Text:SetAlpha(1)
  59.  
  60. JWRepBarFrame:SetScript("OnMouseDown", function(self, button)
  61.   if button == "LeftButton" and (IsShiftKeyDown()) and not self.isMoving then
  62.     self:StartMoving();
  63.     self.isMoving = true;
  64.   elseif (IsShiftKeyDown() ) and (button == "RightButton" and not self.isSizing) then
  65.     self:StartSizing();
  66.     self.isSizing = true;
  67.   end
  68. end)
  69.  
  70. JWRepBarFrame:SetScript("OnMouseUp", function(self, button)
  71.   --if button == "LeftButton" and (IsShiftKeyDown()) and self.isMoving then
  72.   if button == "LeftButton" and self.isMoving then
  73.     self:StopMovingOrSizing();
  74.     self.isMoving = false;
  75.   elseif (button == "RightButton" and self.isSizing) then
  76.     self:StopMovingOrSizing();
  77.     self.isSizing = false;
  78.   end
  79. end)
  80.    
  81. local function UpdateStatus()
  82.     local JWRepName, JWRepStanding, JWRepMin, JWRepMax, JWRepCur = GetWatchedFactionInfo()
  83.     if JWRepName then
  84.         local JWRepColor = FACTION_BAR_COLORS[JWRepStanding]
  85.         JWRepBar:SetStatusBarColor(JWRepColor.r * 0.8, JWRepColor.g * 0.8, JWRepColor.b * 0.8)
  86.         JWRepBar:SetMinMaxValues(JWRepMin, JWRepMax)
  87.         JWRepBar:SetValue(JWRepCur)
  88.         JWRepName = JWRepName:gsub("(%a)([%w_']*)", tchelper) --Proper case
  89.         Text:SetText(format("%s %s/%s ", JWRepName, comma_value(JWRepCur), comma_value(JWRepMax)))
  90.         return
  91.     end
  92. end
  93.  
  94. JWRepBarFrame:RegisterEvent("UPDATE_FACTION")
  95. JWRepBarFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
  96. JWRepBarFrame:SetScript("OnEvent", UpdateStatus)

Any help or pointers in the right direction is appreciated.
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Resizing Frames

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off