GithubHelp home page GithubHelp logo

flypaper-2.0's Introduction

FlyPaper

A library for finding the closest points between regions, usually for anchoring

Examples

local FlyPaper = LibStub("FlyPaper-2.0")

--------------------------------------------------------------------------------
-- Public API
--------------------------------------------------------------------------------

-- returns the nearest points between frame and the closest registered frame
local point, relFrame, relPoint, x, y, distance = FlyPaper.GetBestAnchor(frame, [tolerance, xOff, yOff])

-- returns the nearest points between frame and the closest frame in groupName
local point, relFrame, relPoint, x, y, distance = FlyPaper.GetBestAnchorForGroup(frame, groupName, [tolerance, xOff, yOff])

-- returns the nearest points between frame and relFrame
local point, relPoint, x, y, distance = FlyPaper.GetBestAnchorForFrame(frame, relFrame, [tolerance, xOff, yOff])

-- returns the nearest relative point on any registrered frame to point on frrame
local relFrame, relPoint, x, y, distance = FlyPaper.GetBestAnchorToPoint(frame, point, [tolerance, xOff, yOff])

-- returns the nearest relative point on any frame within group to point on frrame
local relFrame, relPoint, x, y, distance = FlyPaper.GetBestAnchorToPointForGroup(frame, groupName, [tolerance, xOff, yOff])

-- returns the nearest relative point on relFrame to point on frrame
local relPoint, x, y, distance = FlyPaper.GetBestAnchorToPointForFrame(frame, point, relFrame, [tolerance, xOff, yOff])

-- returns the nearest anchor to the frame's parent
local point, relPoint, x, y, distance = FlyPaper.GetBestAnchorForParent(frame, [tolerance, xOff, yOff])

-- returns the nearest anchor for point to the frame's parent
local relPoint, x, y, distance = FlyPaper.GetBestAnchorToPointForParent(frame, point, [tolerance, xOff, yOff])

-- returns the nearest point on frame relative to the position of the mouse cursor
-- relPoint is BOTTOMLEFT
local point, relPoint, x, y, distance = FlyPaper.GetBestAnchorToParentGridPoint(frame, xScale, yScale, [tolerance, xOff, yOff])

-- returns the nearest point on frame relative to the position of the mouse cursor
-- relFrame is UIParent, relPoint is BOTTOMLEFT
local point, relFrame, relPoint, x, y, distance = FlyPaper.GetNearestPointToCursor(frame, [tolerance, xOff, yOff])

-- sets scale while keeping frame in the same relative place
local changed = FlyPaper.SetScale(frame, scale)

-- returns true if frame is anchored to a frame other than its parent and false otherwise
local hasAnchor = FlyPaper.IsAnchored(frame)

-- Attempts to anchor frame to a specific anchor point on otherFrame
-- point: any non nil return value of FlyPaper.Stick
-- xOff: horizontal spacing to include between each frame
-- yOff: vertical spacing to include between each frame
-- returns an anchor point if attached and nil otherwise
local anchor = FlyPaper.StickToAnchor(frame, otherFrame, anchor, [xOff, yOff])

-- Iterates through all frames registered with FlyPaper and anchors to the
-- closest one that is within tolerance distance, if it exists
local anchor, group, id = FlyPaper.StickToClosestFrame(frame, [tolerance, xOff, yOff])

-- Iterates through all frames registered with FlyPaper within the specified
-- group and anchors to the closest one that is within tolerance distance
-- if it exists
local anchor, id = FlyPaper.StickToClosestFrameInGroup(frame, groupName, [tolerance, xOff, yOff])

-- registers the frame with FlyPaper
local registered = FlyPaper.AddFrame(groupName, id, frame)

-- unregisters the frame with flypaper
local uregistered = FlyPaper.RemoveFrame(groupName, id)

-- retrieves the specified frame, if it exists
local frame = FlyPaper.GetFrame(groupName, id)

-- retrieves the group information for the specified frame, if it exists
local groupName, id = FlyPaper.GetFrameInfo(frame)

--------------------------------------------------------------------------------
-- Callbacks
--------------------------------------------------------------------------------

local owner = {}

FlyPaper.AddCallback(owner, 'OnAddFrame')
FlyPaper.AddCallback(owner, 'OnRemoveFrame')

-- called when a frame is registered with FlyPaper
-- frame: what frame was added
-- group: the group the frame was added to
-- id: the id of the frame within the group
function owner:OnAddFrame(msg, frame, groupName, id) end

-- called when a frame is unregistered from FlyPaper
-- frame: what frame was removed
-- group: the group the frame was removed to from
-- id: the id of the frame within the group
function owner:OnRemoveFrame(msg, frame, groupName, id) end

flypaper-2.0's People

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

swanarog

flypaper-2.0's Issues

config mode registration

Could we include an option for addons to register a config mode toggle function, so that when one addon using flypaper activates config mode, it turns on all config modes for all addons using flypaper?

I foresee this being able toggle on, but it would be up to the user to close each addon's config mode. This would be to prevent conflicts in the way each addon handles exiting their config modes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.