Reply
 
Thread Tools Display Modes
Old 01-15-13, 08:37 PM   #1
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 122
Question EffectiveScale vs width and height

Hi again.

I've got a sort..of..viewport border around my screen which I've made to change colour depending on whether I'm in combat, resting, away, dead, etc.

Is there a way to make a frame 'immune' to changes in scale?

I've tried using, for example:

Lua Code:
  1. myFrame:SetWidth(GetScreenWidth() * 0.005);

... instead of using a conventional fixed width, but surprisingly, even that doesn't remain the same size when scale is changed.

EDIT: I know there isn't any OnScaleChanged handler that I can use. If I change the scale and re-submit the above code, all seems okay. Is there any way around this necessity?

Is there a magic formula that I'm unaware of?

Thanks in advance as always,

Aanson
__________________
__________________

Last edited by Aanson : 01-15-13 at 08:47 PM.
Aanson is offline   Reply With Quote
Old 01-15-13, 09:13 PM   #2
Ekaterina
A Cyclonian
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 43
Try setting the scale for the frame in code.

myFrame:SetScale(1)

Ekat.
Ekaterina is offline   Reply With Quote
Old 01-16-13, 04:44 AM   #3
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 122
Originally Posted by Ekaterina View Post
Try setting the scale for the frame in code.

myFrame:SetScale(1)

Ekat.
I don't think that'll do anything. The frame is parented to UIParent. Setting it's scale to 1 will simply make it's scale 100% of it's parent's scale which is currently 83%. GetScale() will return 1 whereas GetEffectiveScale() will return 0.83.

Now that I've slept on it, I don't think it can be done. There's just no way to respond to changes in scale.

Hooking to the appropriate function would work perhaps but I prefer not to do that whenever possible.

Cheers for the suggestion.
__________________
__________________
Aanson is offline   Reply With Quote
Old 01-16-13, 12:26 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 9,477
You could just not parent the frame to UI Parent... Do you want it to hide when you hide the interface with Alt-Z?
__________________
"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

Seerah is offline   Reply With Quote
Old 01-16-13, 02:29 PM   #5
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 903
I used SetPoint() to cover my viewport with a texture, like this:

Code:
	local toppanel = CreateFrame("Frame", nil, UIParent)
Code:
 	toppanel:SetPoint("TOPLEFT", -2, 0)
	toppanel:SetPoint("TOPRIGHT", 2, 0)
	toppanel:SetHeight(15)
or consequently

Code:
 	toppanel:SetPoint("TOPLEFT", -2, 0)
	toppanel:SetPoint("TOPRIGHT", 2, -15)

Using a small offset for x just to make sure there's no clipping (aka a little visual gap). Not necessarily needed, I suppose.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

Dawn is offline   Reply With Quote
Old 01-16-13, 03:30 PM   #6
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 3,675
frame:SetScale(1 / frame:GetParent():GetEffectiveScale())
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Old 01-17-13, 09:44 AM   #7
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 122
Originally Posted by Seerah View Post
You could just not parent the frame to UI Parent... Do you want it to hide when you hide the interface with Alt-Z?
That's an interesting thought. I had always thought that everything in any UI was either directly or indirectly parented to UIParent? What would it parent to if not UIParent?

Kind Regs

Aanson
__________________
__________________
Aanson is offline   Reply With Quote
Old 01-17-13, 09:47 AM   #8
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 122
Originally Posted by Phanx View Post
frame:SetScale(1 / frame:GetParent():GetEffectiveScale())
That's perfect Phanx and exactly the kind of thing that I'm after.

Thank you very much as always and thank's everyone for your help.


Aanson
__________________
__________________
Aanson is offline   Reply With Quote
Old 01-18-13, 04:39 PM   #9
SDPhantom
A Molten Giant
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 933
Having a parent is completely optional. The only reason to parent to UIParent is practically to be able to show and hide when the UI is shown or hidden and also scale with the rest of the UI. If you don't want to set a parent to a frame, you can pass nil to the respective function argument.
__________________
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
SDPhantom is offline   Reply With Quote
Old 01-18-13, 04:41 PM   #10
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 3,675
There's also the scaling issue -- if your frame doesn't descend from UIParent, then it annoyingly ignores the user's UI Scale preference.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » Lua/XML Help » EffectiveScale vs width and height

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