WoWInterface

WoWInterface (http://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (http://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   EffectiveScale vs width and height (http://www.wowinterface.com/forums/showthread.php?t=45661)

Aanson 01-15-13 09:37 PM

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

Ekaterina 01-15-13 10:13 PM

Try setting the scale for the frame in code.

myFrame:SetScale(1)

Ekat.

Aanson 01-16-13 05:44 AM

Quote:

Originally Posted by Ekaterina (Post 271920)
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.

Seerah 01-16-13 01:26 PM

You could just not parent the frame to UI Parent... Do you want it to hide when you hide the interface with Alt-Z?

Dawn 01-16-13 03:29 PM

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.

Phanx 01-16-13 04:30 PM

frame:SetScale(1 / frame:GetParent():GetEffectiveScale())

Aanson 01-17-13 10:44 AM

Quote:

Originally Posted by Seerah (Post 271947)
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 01-17-13 10:47 AM

Quote:

Originally Posted by Phanx (Post 271952)
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

SDPhantom 01-18-13 05:39 PM

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.

Phanx 01-18-13 05:41 PM

There's also the scaling issue -- if your frame doesn't descend from UIParent, then it annoyingly ignores the user's UI Scale preference.


All times are GMT -6. The time now is 06:04 AM.

vBulletin © 2014, Jelsoft Enterprises Ltd
©2012 ZAM Network LLC