Reply
Thread Tools Display Modes
Unread 10-25-10, 07:50 AM   #1
maltese
A Wyrmkin Dreamwalker
 
maltese's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 54
Anchoring an addon frame to another addon

Recently I've been trying to finalize the changes to my UI and I'd really like to anchor my cooldown monitors frame to the top of my raid frames. I'm using Vlakcooldowns which I'd like to anchor to the top center of my oUF raid frames so the monitor is always right at the top of my raid frames regardless of if I', in a 10 or 25 man group.

How would I go about accomplishing this?
maltese is offline   Reply With Quote
Unread 10-25-10, 08:20 AM   #2
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 765
This is how I would do it:
1. /fstack and turn on showing the name of frames when you mouse over stuff.
2. Mouse over the frame you wish to move and write it's name down
3. Mouse over the frame you wish to anchor something to and write it's name down
4. /run local a,b=FrameA,FrameB a:ClearAllPoints() a:SetPoint("TOPLEFT", b, "TOPLEFT", 0, 0)
You may have to play around a bit, the documentation of "SetPoint" is http://www.wowpedia.org/API_Region_SetPoint and it may help if you are stuck on what values for "TOPLEFT" there are and what the different stuff mean.
Vlad is offline   Reply With Quote
Unread 10-25-10, 08:27 AM   #3
Duugu
Premium Member
 
Duugu's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 768
Keep in mind that frame names are case sensitive when doing this.
Duugu is offline   Reply With Quote
Unread 10-25-10, 10:06 AM   #4
maltese
A Wyrmkin Dreamwalker
 
maltese's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 54
Originally Posted by Vladinator View Post
This is how I would do it:
1. /fstack and turn on showing the name of frames when you mouse over stuff.
2. Mouse over the frame you wish to move and write it's name down
3. Mouse over the frame you wish to anchor something to and write it's name down
4. /run local a,b=FrameA,FrameB a:ClearAllPoints() a:SetPoint("TOPLEFT", b, "TOPLEFT", 0, 0)
You may have to play around a bit, the documentation of "SetPoint" is http://www.wowpedia.org/API_Region_SetPoint and it may help if you are stuck on what values for "TOPLEFT" there are and what the different stuff mean.
ok, I've got it semi worked out. Reloading my UI resets it obviously. Is there a way to set this in lua within the cooldown mod so I don't have to type this in/press a macro on every reload?

This is what I have right now
/run local a,b=vlakCooldownsAnchor,oUF_Raid a:ClearAllPoints() a:SetPoint("TOP", b, "TOP", 15, 70)


Code:
local anchor = CreateFrame("Frame", "vlakCooldownsAnchor", UIParent)
anchor:SetHeight(size)
anchor:SetPoint("BOTTOM", UIParent, "BOTTOM", xpos, ypos)
is the anchor code within VlakCooldowns. I tried using:
Code:
anchor:ClearAllPoints()
anchor:SetPoint("TOP", oUF_Raid, "TOP", 15, 70)
but thats not setting the anchor correctly for some reason

Last edited by maltese : 10-25-10 at 10:16 AM.
maltese is offline   Reply With Quote
Unread 10-25-10, 10:25 AM   #5
Duugu
Premium Member
 
Duugu's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 768
You could replace

Code:
if event == "SPELLS_CHANGED" or event == "PLAYER_ENTERING_WORLD" or event == "PLAYER_TALENT_UPDATE" then
with

Code:
if event == "SPELLS_CHANGED" or event == "PLAYER_ENTERING_WORLD" or event == "PLAYER_TALENT_UPDATE" then
_G["vlakCooldownsAnchor"]:ClearAllPoints()
_G["vlakCooldownsAnchor"]:SetPoint("TOP", _G["oUF_Raid"], "TOP", 15, 70)
in vlakCooldowns.lua
Duugu is offline   Reply With Quote
Unread 10-25-10, 10:33 AM   #6
maltese
A Wyrmkin Dreamwalker
 
maltese's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 54
works perfectly. Thanks
maltese is offline   Reply With Quote
Unread 10-25-10, 02:53 PM   #7
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 765
Also mate, this is the perfect time to bring this up: why not make yourself an addon for your private needs?

I myself got one that I use to add special functions and features, like moving frames around, anchoring, e.g. Problem by editing other addons is that when they get a new version you must remember to apply the modifications to the new version, it's a hard task if you wish to use an updater or if you don't know addon coding. Instead make your own addon that you do stuff like this in. Just a tip!
Vlad is offline   Reply With Quote
Unread 10-26-10, 07:21 AM   #8
maltese
A Wyrmkin Dreamwalker
 
maltese's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 54
Ultimately that is the goal, but I'm in the process of learning lua right now (slow and steady process). I comment out the original lua and document what I change so I know exactly what I did so when it comes to update addons I can recreate what I have pretty effectively. I could upload "my" versions of the addons and keep them updated but it would basically be a 99.5% copy of others addons and I'd hate to get any credit for others hard work.
maltese is offline   Reply With Quote
Unread 10-26-10, 05:30 PM   #9
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 765
Don't worry about using other peoples work for your own private addon.

By the way one way you can do a "fix" for the position of vlakCooldowns is to make an addon and a lua file and in that file put this code (this is just a suggestion, there are far better ways of doing this, programing is like art).

lua Code:
  1. local addon = CreateFrame("Frame")
  2. addon.temp = {}
  3. addon:RegisterEvent("ADDON_LOADED")
  4. addon:SetScript("OnEvent", function(self, event, ...)
  5.   addon:HookVlak() -- will try hook each time an addon is loaded
  6. end)
  7. addon.HookVlak = function(self)
  8.   local a, b = vlakCooldownsAnchor, oUF_Raid
  9.   if self.temp.vlakHooked or not (a and b) then return end -- stop if hooked or frames do not exist yet
  10.   a:HookScript("OnShow", function(self) -- whne the frame is shown it automatically positions itself at oUF_Raid
  11.     self:ClearAllPoints()
  12.     self:SetPoint("TOP", b, "TOP", 15, 70)
  13.   end)
  14.   self.temp.vlakHooked = 1
  15. end
Vlad is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » Lua/XML Help » Anchoring an addon frame to another addon

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