Thread Tools Display Modes
11-14-11, 11:02 PM   #1
stako
A Deviate Faerie Dragon
 
stako's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 11
Draggable frames maintaining relative frames?

So's I've created a little cooldown icon for each of the blizzard default arena unitframes. It tracks the cooldown of each player's PVP trinket. By default I have the trinket icon sitting a little bit to the right of the unitframe:

Code:
trinket:SetPoint("LEFT", ArenaEnemyFrame1, "RIGHT", 2, -2)
I've also made it draggable. But after dragging it, the icon loses its relativity to ArenaEnmyFrame1 and is instead relative to UIParent. Is there any way to circumvent this? I have the arena frames draggable too, so I want the trinket icon to follow the arena frames when they're dragged, but also allow users to move the trinket icon itself so it doesn't always have to be to the right of the arena frame.

Thanks.
  Reply With Quote
11-14-11, 11:27 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,324
You'll have to hook the OnDeagStop handler, then have it clear and reset the anchor based on its current position.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
11-15-11, 07:52 AM   #3
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Stako I had this with rBBS aswell.

lua Code:
  1. --so we want to move a frame that is actually hooked to the dragframe
  2.   --do make this work we need to trick, because drag functionality ignores the parented frame and used UIParent...we don't want that, because the child would not move with the parent anymore
  3.   local calcPoint = function(s)
  4.     if s:GetParent():GetName() ~= "UIParent" then
  5.       local Hx, Hy = s:GetParent():GetCenter()
  6.       local Ox, Oy = s:GetCenter()
  7.       if(not Ox) then return end
  8.       local scale = s:GetScale()
  9.       Hx, Hy = floor(Hx), floor(Hy)
  10.       Ox, Oy = floor(Ox*scale), floor(Oy*scale)
  11.       local Tx, Ty = (Hx-Ox)*(-1), (Hy-Oy)*(-1)
  12.       s:ClearAllPoints()
  13.       s:SetPoint("CENTER",s:GetParent(),Tx/scale,Ty/scale)
  14.     end
  15.   end

You have to dig into the code I guess...
http://code.google.com/p/rothui/sour...BS/core.lua#74

I have a drag frame container and move frames that are parented to to the drag frame container in relative position to the center of the drag frame container.

calcPoint is called OnDragStop and on PLAYER_LOGIN event (because the position of saved frames in layout-local.txt needs to be rechecked on loadup).
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 11-15-11 at 07:57 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Draggable frames maintaining relative frames?


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