Thread Tools Display Modes
Prev Previous Post   Next Post Next
04-01-09, 02:13 AM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Making oUF_Frames movable

Some of you may know this already. Blizzard included a new "Drag" functionality some time ago which allows us to drag frames. The position is saved in the layout-cache.txt for each character. If "isUserPlaced" is set to true all the SetPoints will be ignored when there is a value in the layout-cache.txt.

To make this work you need give your oUF frames a global name when you spawn them.

Example
Code:
local player = oUF:Spawn("player", "oUF_Player")
local target = oUF:Spawn("target", "oUF_Target")
Now add the move function at the end and call it.

Code:
local function oUF_MoveThisFrame(frame,moveit,lock)
  local f = _G[frame]
  if moveit == 1 then
    f:SetMovable(true)
    f:SetUserPlaced(true)
    if lock ~= 1 then
      f:EnableMouse(true)
      f:RegisterForDrag("RightButton")
      f:SetScript("OnDragStart", function(self) self:StartMoving() end)
      f:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
    end
  else
    f:IsUserPlaced(false)
  end  
end

-- function(frame name, movable on/off, frame locked on/off)
oUF_MoveThisFrame("oUF_Player",1,0);
oUF_MoveThisFrame("oUF_Target",1,0);
If you have no more frames that overlap themselves this should work. Hover the frame, hold down the right mousebutton and start pulling the mouse. You can make this function global or local. Your choice.

You still need to give your spawned frames a default SetPoint. This will be used if you set the frame to not movable or if there is no value in the layout-cache.txt.

The function is untested yet.

*Update*

I made a set of two functions that should do it. Thanks Luzzifus
Check: http://www.wowinterface.com/forums/s...30&postcount=7

You are able to create a dragable frame for spawns of your liking and you can lock those frames when finished.
__________________
| 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 : 04-01-09 at 03:37 AM.
  Reply With Quote
 

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Making oUF_Frames movable


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