Thread Tools Display Modes
09-09-05, 01:38 PM   #1
Kasheen
A Wyrmkin Dreamwalker
 
Kasheen's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 58
SetScale causing frames to "jump"

Has anyone else encountered a little annoyance whereby when you use SetScale on a frame which is anchored to UIParent the frame "jumps" up or down the screen? Setting the scale higher will cause it to jump down and sometimes to the right as well, and setting it lower will cause it to jump up and sometimes to the left. Frames which are anchored to other frames and then scaled stay anchored at the correct point.

So does anyone know of a way to use SetScale without the frame "jumping" about the screen?
  Reply With Quote
09-09-05, 02:20 PM   #2
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
I have a lot of trouble with scaling so I'm not the best to answer, but I think setting anchor to another frame is the best solution.

If it must be anchored to UIParent, you can :SetPoint after :SetScale to put it back in its scale-adjusted place:

function ScaleFrameToUIParent(frame,scale)
local oldscale = frame:GetScale() or 1
local framex = (frame:GetLeft() or 0)* oldscale
local framey = (frame:GetTop() or 0)* oldscale

frame:SetScale(scale)
frame:SetPoint("TOPLEFT","UIParent","BOTTOMLEFT",framex/scale,framey/scale)
end

This poses other problems like layout-cache may not be aware of the frame's new position and stuff. Scaling seems extremely messy to me but it's probably my inexperience.
  Reply With Quote
09-09-05, 04:57 PM   #3
mondinga
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 66
Offset distances get scaled whether you're anchoring to UIParent or anything else, and it's definitely not always convenient >< I dunno that I'd call it messy, but it gets a bit overused because it's quick.

Anytime you're using SetPoint on a frame you want to assure stays user-placed, using SetUserPlaced(1) afterwords should keep it so.
  Reply With Quote
09-09-05, 05:05 PM   #4
Kasheen
A Wyrmkin Dreamwalker
 
Kasheen's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 58
Thanks to both of you, I was thinking about moving the frame back to its original location like Gello suggested so I might take that approach.

but it gets a bit overused because it's quick.
Mondinga, could you clarify a bit, I lost you here, is that using SetScale() is overused?

Could you also clarify on SetUserPlaced(1), should that be used even after a user has dragged the frame about, and does it make the game automatically move it to where it was after a scaling?

Thanks for both your inputs, its really helpful .
  Reply With Quote
09-09-05, 07:46 PM   #5
mondinga
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 66
Well you can slap a rescale on anything on the screen, but making sure a frame stays usable, and that everything in relation to it does, is tricky at times. It does work great for a lotta stuff though.

To my understanding, anytime you do frame:SetUserPlaced(1), no matter where it is, it should be saved to layout-cache.txt.

Inversly, anytime you do frame:SetPoint(), it overrides the user-placement, and will not save to layout-cache.txt.

Any time you are dragging, using frame:StartMoving() and frame:StopMovingOrSizing(), you should not need to use it. There is a possible bug here I'm not sure has been taken care of where if you did frame:SetPoint() in between a frame:StartMoving() and frame:StopMovingOrSizing() it would not save as user-placed.

None of this has any impact on scaling. The movement you are seeing is the offset pixels defined in the frame's anchoring having the frame's scale applied to them as well. To make up for this, you can do as Gello posted, using frame:SetUserPlaced(1) to then save the position.

If unclear, user-placed frames ARE still anchored, to UIParent's BOTTOMLEFT. The GetLeft() and GetBottom() functions will give you the offset here.
  Reply With Quote
09-10-05, 06:10 AM   #6
Kasheen
A Wyrmkin Dreamwalker
 
Kasheen's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 58
Thank you, that fully explains it all .
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SetScale causing frames to "jump"

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