ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Absolute positioning and Custom Scale (https://www.esoui.com/forums/showthread.php?t=424)

Dio 03/30/14 04:50 PM

Absolute positioning and Custom Scale
 
I have a control centered horizontally on the screen. If possible, how would I vertically position this control at exactly 1/2 distance between the top of the screen and the center, and have this control stay there despite UI custom scale changes?

Seerah 03/30/14 07:53 PM

I would do
Lua Code:
  1. local height = GuiRoot:GetHeight()
  2. myFrame:SetAnchor(TOP, GuiRoot, TOP, 0, height/4)


/edit: if you want the center of your frame to be at that point, then do this instead:
Lua Code:
  1. local height = GuiRoot:GetHeight()
  2. myFrame:SetAnchor(CENTER, GuiRoot, TOP, 0, height/4)

Dio 03/30/14 08:20 PM

Quote:

Originally Posted by Seerah (Post 2039)
/edit: if you want the center of your frame to be at that point, then do this instead:
Lua Code:
  1. local height = GuiRoot:GetHeight()
  2. myFrame:SetAnchor(CENTER, GuiRoot, TOP, 0, height/4)


Thanks! I'm using that inside a EVENT_SCREEN_RESIZED event, and it does the trick for screen resizing or Custom Scale changes.

Code:

EVENT_MANAGER:RegisterForEvent(name, EVENT_SCREEN_RESIZED, function()
    myFrame:SetAnchor(CENTER, GuiRoot, TOP, 0, GuiRoot:GetHeight() / 4)
end)


Seerah 03/30/14 08:24 PM

Clear your frame's anchor before setting a new one.

Dio 03/30/14 08:41 PM

Quote:

Originally Posted by Seerah (Post 2042)
Clear your frame's anchor before setting a new one.

Ah, I just assumed it set over the old one. Thanks.


All times are GMT -6. The time now is 09:11 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI