Thread Tools Display Modes
01-15-13, 09:37 PM   #1
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
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 09:47 PM.
  Reply With Quote
01-15-13, 10:13 PM   #2
Ekaterina
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 65
Try setting the scale for the frame in code.

myFrame:SetScale(1)

Ekat.
  Reply With Quote
01-16-13, 05:44 AM   #3
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
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.
__________________
__________________
  Reply With Quote
01-16-13, 01:26 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
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

  Reply With Quote
01-16-13, 03:29 PM   #5
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
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..."

  Reply With Quote
01-16-13, 04:30 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
frame:SetScale(1 / frame:GetParent():GetEffectiveScale())
__________________
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
01-17-13, 10:44 AM   #7
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
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
__________________
__________________
  Reply With Quote
01-17-13, 10:47 AM   #8
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
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
__________________
__________________
  Reply With Quote
01-18-13, 05:39 PM   #9
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
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.
__________________
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
01-18-13, 05:41 PM   #10
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
There's also the scaling issue -- if your frame doesn't descend from UIParent, then it annoyingly ignores the user's UI Scale preference.
__________________
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

WoWInterface » 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