Thread Tools Display Modes
05-12-17, 06:33 AM   #1
VincentSDSH
Non-Canadian Luzer!
 
VincentSDSH's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 350
:SetPoint(), :GetPoint(), & :GetAspirin()

Lua Code:
  1. region:SetPoint(point, relativeTo, relativePoint, offset_x, offset_y)
Lua Code:
  1. point, relativeTo, relativePoint, offset_x, offset_y = region:GetPoint(n)

If :SetPoint() is used to set one (or more) points on a region and said region is then repositioned via drag, :GetPoint() acts as if :ClearAllPoints() has been run, towit, UIParent is the new relativeTo and only 1 point is set.

This...this seems to be bloody absurd, even Microsoftian, behavior. Logically, since each point already has a set of rel characteristics, those would be retained and each point's offset coords updated. Instead, you have relationship-breaking behavior.

I could, frankly, forgive this if there was a API for getting relative offsets between two points, even if restricted to UIParent points, a sort of...
Lua Code:
  1. dx, dy = GetRelOffset(frame, framePoint, UIParent_relPoint, UIParent_offset_x, UIParent_offfset_y)
...but I can't find one.

To reassert an updated and proper relative-to/offset relationship, you'd need to crawl recursively though the :GetParent() chain, checking points and offsets, heights/widths, etc, and try to work back to UIParent, then find an offset. I...call me crazy but that seems a tad excessive.

Am I missing something stunningly obvious or should I just bend over and take it like a tax audit?

(Since 'why' is often asked: Series of frames anchored to blizzardUI frames which may, or may not, be in their original positions; when created, the frames position relative to their respective blizzardUI frames; when adjusted, however, :GetPoint() won't return an offset to the original relativeTo region so the coords can't be used with the relativeTo region which, naturally, means that when the associated blizzardUI frames are moved, the custom frames stay put rather than move w/ the blizzardUI frames as they should.)
__________________
AddonsExecutive Assistant User Configurable To-Do ListLegible Mail Choose the Font for Your Mail
  Reply With Quote
05-12-17, 09:46 AM   #2
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
If you don't like that the drag handler anchors your frame to UIParent, then just write your own OnUpdate script and track the offsets with the cursor. Alternatively, measure the distance between your anchor point and your relative point after you've finished moving the frame and then reset the offset.
__________________
  Reply With Quote
05-12-17, 11:10 AM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
You could register an OnDragStop handler to query :GetCenter() or any combination of the other functions that returns absolute positions in order to reconstruct your anchor(s).
__________________
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
05-12-17, 11:21 AM   #4
VincentSDSH
Non-Canadian Luzer!
 
VincentSDSH's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 350
Originally Posted by MunkDev View Post
Alternatively, measure the distance between your anchor point and your relative point after you've finished moving the frame and then reset the offset.
Care to toss in a snippet? 'Cause I spent a fair while trying to figure out how to do just that but I couldn't get a common frame of reference b/c of the different contexts of the points.

GetCursorPosition() was my next fallback position but I wanted to ask before I took another run at it b/c I couldn't -- still can't -- believe that something that simple is this unnecessarily complicated.

[Edit]
Originally Posted by SDPhantom View Post
You could register an OnDragStop handler to query :GetCenter() or any combination of the other functions that returns absolute positions in order to reconstruct your anchor(s).
Ok, maybe that's what MunkDev is trying to say. I bloody forgot about the :GetLeft/Top/Bottom/Right/Center family; haven't used them in a decade or so. Do one of those on both the anchor and target to get a common coord context, then do the before/after math. Sounds like it should work.

Thanks guys.
__________________
AddonsExecutive Assistant User Configurable To-Do ListLegible Mail Choose the Font for Your Mail

Last edited by VincentSDSH : 05-12-17 at 11:50 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » :SetPoint(), :GetPoint(), & :GetAspirin()

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