Thread Tools Display Modes
07-06-13, 04:18 AM   #1
shurshik
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 31
How to deal with UIScale

Hi! I got 1 problem...

My addon has a frame which has many other frames/buttons in it.. I use only Width and Height in px to set their size.

But for some people it is too big due to their scaling..

What is the best way to fix it? I've read a lot here on forums and found:

s:SetPoint("CENTER",s:GetParent(),Tx/scale,Ty/scale)
Should I change ALL frames, buttons, text's position adding "/scale" ? Or there is another way to deal with "my main frame" and scale everything in it?

Sorry for my english -_-
  Reply With Quote
07-06-13, 04:20 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Scale is inherited, so just scale your main frame, and everything parented to it automatically scales with it. For example, to make your frame 80% regular size, use:

Code:
MyFrame:SetScale(0.8)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
07-06-13, 04:38 AM   #3
shurshik
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 31
Originally Posted by Phanx View Post
Scale is inherited, so just scale your main frame, and everything parented to it automatically scales with it. For example, to make your frame 80% regular size, use:

Code:
MyFrame:SetScale(0.8)
Awesome! Thank you I designed my frame using 0.7 scale, so I have 2 options:
1. Set my Scale to 1 and redesign my addon's UI and then use /script MyFrame:SetScale(UIParent:GetScale())
2. Create a function to determinate difference between UIParent:GetScale() and 0.7 and change size

Better to use the first one, right?

Update: no. wait... When I increase UI scaling I have to decrease Addon's scale. I'll test a little first :/

Last edited by shurshik : 07-06-13 at 04:44 AM.
  Reply With Quote
07-06-13, 06:10 AM   #4
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Generally you should just let your addons scale with the user's UI scale, unless it has to be UI scale independent for a specific reason.

Example: if you have borders which are exactly 1 px in size, you'll want them to appear at exactly 1 px, meaning you have to counter the UI scale so they have an 'effective scale' (= actual scale taking the scale of every parent frame including the UIParent into account) of 1.

You'll want to use:

Code:
frame:SetScale(1 / UIParent:GetScale())
You need to wait to get the UI scale though until the VARIABLES_LOADED event has fired. Also, you'll want to register UI_SCALE_CHANGED in case the user or a different addon changes the UI scale later on.

So:

Code:
frame:RegisterEvent("VARIABLES_LOADED")
frame:RegisterEvent("UI_SCALE_CHANGED")
frame:SetScript("OnEvent", function(self)
	self:SetScale(1 / UIParent:GetScale())
end)
  Reply With Quote
07-06-13, 08:38 AM   #5
shurshik
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 31
Thank you!

It works perfect for me. Hope there is no problem with other resolutions Should test it
  Reply With Quote
07-06-13, 10:44 AM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
It sounds like your main frame is not parented to the UIParent. If it were, then UIParent would already be handling the scaling of your frame based on resolution and UI scale.

(hint: it's the third arg passed to CreateFrame)
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to deal with UIScale


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