SetScale on Dialog?

Pretty much at the tidy up phase for my addon now and still pulling hair out. I have the following code;

    NS.MyScale = 1
    print ("MyAddonScale: "..NS.MyAddonScale);
    MyAddon:SetScale(MyScale)

In my addon to set the scale. That worked fine until I cut my dialog frames out and put them into their own files. The dialogs still load but the scale is weird. They appear to be ignoring the scale setting now. They’re far larger, at least 150% I’d guess (maybe even 200%).

I tried adding the same code to the dialogs but using a scale of “1” still results in huge dialogs. Scale still words, in a sense, because if I use

    NS.MyDialogScale = .5
    print ("MyAddonScale: "..NS.MyAddonScale);
    MyAddon:SetScale(MyDialogScale)

Then I can get them back to roughly the size they should be at scale of “1”. I thought it might be because I had their framestrata set to DIALOG and maybe WoW was treating that differently. But I reset it to MEDIUM and scaling is still weird.

edit: Nope, I was wrong. Removing scale from the parent didn’t affect them at all. I tried removing the scale from the main form (which is the parent of the dialogs) and the scaling behaviour of the dialogs goes back to what I’d expect. So it looks like the scaling is somehow additive? I’m confused because it didn’t appear to be additive when they were all in the same lua file. It’s only once I split them into multiple files that it’s become a problem.

I’ve looked at: https://wowpedia.fandom.com/wiki/API_Region_SetScale

But I’m not sure how to interpret;

Since the API presentation is scaled, each object has its own internal notion of size, which is only relative to the actual size it appears on-screen. UIParent will have a reasonable scaling factor selected by the game engine, from which all of the child UI elements are then derived. This function can be used to selectively change the scale of a component relative to its parent such that it appears to become bigger or smaller. UI elements with appropriately specified anchor points and sizes should scale quite cleanly.

That seems to indicate that this weird scaling is based on the relationship between my child and parent frames which I’d figured out. But it doesn’t really explain why the child (dialog) is double size. I thought I had “UI elements with appropriately specified anchor points and sizes” but I guess not?

Latest edit: Incidentally, I tried

NS.MyAddonSettingsFrame:SetIgnoreParentScale(true);
NS.MyAddonsSettingsFrame:SetScale(NS.MyAddonScale);
print ("MyAdddonScale: "..NS.MyAddonScale);
print ("Effective scale: "..NS.MyAddonSettingsFrame:GetEffectiveScale());
if NS.MyAddonSettingsFrame:IsIgnoringParentScale() then 
	print ("Is ignoring parent scale: TRUE");
end 

It returns:

MyAddonScale: 1
EffectiveScale: 1
Is ignoring parent scale: TRUE

So I’m still at a loss. It’s even ignoring the parent scale but still appearing far larger than it should be.

When you change the game’s scale (esc to game menu → System → Graphics → UI Scale), does your oversized frames rescale with the rest of the UI?

I suspect not. It sounds like when you split your UI up across files, you lost a reference to a parent, either UIParent or another frame.

What you think is a frame reference is likely nil.

1 Like

In the meantime I created a simple test addon that just shows a main form and a child form same sort of way. It works perfectly. As in it scales exactly how I’d expect with the parent and child code contained in two separate LUA files.

After what you said I took a closer look at the difference between that and my original and you’re spot on.

In the original the frame creation was:

local CarnTest, NS = ...
local CarnTest = CreateFrame("Frame", nil, UIParent);
CarnTest:SetFrameStrata("MEDIUM");

Compared to the test

local CarnTest, NS = ...
local CarnTestMainFrame = CreateFrame("Frame", "CarnTestMainFrame", UIParent)
CarnTest:SetFrameStrata("MEDIUM");

If I set the frame name in the test to nil it causes the scaling problem. So I guess it was scaling properly before splitting because the child’s create frame was finding the local “CarnTest” which was pointing to a frame so it worked. After splitting it was pointing at NS.CarnTest which is I guess the “addon” not a frame. I’d have expected it to throw an error though… not just keep working with minor weirdness.

Thanks. I think I’d have stumbled onto the problem eventually but you saved me a bunch of time.

Just thinking through that it also explains why the sizes seemed so weird…

I was thinking the Main Form’s scale was 1 when it was parented to UI but it’s effective scale was really 0.69 the whole time and I just wasn’t aware. That’s why when I forced the scale to 1 on the child it didn’t change, and why ignore parent scale did nothing…because it wasn’t parented to EITHER to Main Form OR the UI… and it was actually displaying at what a scale of 1 really looked like. That’s a lightbulb moment.

edit: re-read this and my typing before was atrocious. Corrected some typos and weird grammar.