LibFrameAnchorRegistry-1.0

Last Updated: Oct 19, 2014 Game Version: 6.0.2

14,546

Oct 23, 2010

Owner: mangeg

Central registry for addons to register their frames as possible frame anchor. Other addons can then retrieve the list of anchor and then let their user anchor the addon to whatever frame they like.

To register a frame with the registry:

LibStub("LibFrameAnchorRegistry-1.0"):RegisterAnchor("MyCateogry", "NameOfFrame", "Identidy", frame)

To register with sub-categories:

LibStub("LibFrameAnchorRegistry-1.0"):RegisterAnchor("MyCateogry\001MySub-Category", "NameOfFrame", "Identidy", frame)

To retrieve the actual frame:

local anchor = LibStub("LibFrameAnchorRegistry-1.0"):GetAnchor(db.AnchorID)

To use with AceConfig:

local frame CreateFrame("Frame", nil, UIparent)
local options = {
   type = "group",
   args = {
      drop = {
         name = "Test",
         desc = "Some testing",
         type = "select",
         width = "double",
         values = function() return LibStub("LibFrameAnchorRegistry-1.0"):GetAnchors(frame) end,
         set = function(info, ident, name, frame)
            db.AnchorID = ident
         end,
         get = function() return db.AnchorID end,
         dialogControl = "FrameAnchorDropdown",
      },
   },
}

LibStub("AceConfig-3.0"):RegisterOptionsTable("Options", options, {"/myslash", "/my"})

To use stand-alone:

local frame CreateFrame("Frame", nil, UIparent)
local t = AceGUI:Create("FrameAnchorDropdown")
t:SetList(FA:GetAnchors(frame ))
t:SetLabel("Anchor")
t:SetValue(db.FrameAnchorID)
t:SetCallback("OnValueChanged", function(self, event, ident, name, frame)
	db.FrameAnchorID = ident
end)