Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TrinketMenu] Frame explodes when resized #53

Open
Arcitec opened this issue Jan 18, 2019 · 7 comments
Open

[TrinketMenu] Frame explodes when resized #53

Arcitec opened this issue Jan 18, 2019 · 7 comments

Comments

@Arcitec
Copy link
Contributor

Arcitec commented Jan 18, 2019

Thanks a lot for the TrinketMenu skin. Great work.

Everything is perfect except the resizing feature. Hover over the bottom right of the TrinketMenu frame and click and drag the handle to resize the icons.

The whole frame explodes and becomes super wide, hehe.

I am using the latest Git commit from this repo. And TrinketMenu 3.71.

@Apollyonn
Copy link
Contributor

trinket
Can't reproduce.

@Arcitec
Copy link
Contributor Author

Arcitec commented Jan 19, 2019

Hmm.

I use TrinketMenu 3.71 for 2.4.2 here:

https://wow.curseforge.com/projects/trinket-menu/files?filter-game-version=2020709689%3A3

And I updated all ElvUI to latest git commits today.

Trinketmenu is skinned and looks like yours. When I drag and resize, the frame ”explodes” in width and becomes superwide. Like this:

————————————————————————
|<icon>          <icon>|
————————————————————————

@Apollyonn
Copy link
Contributor

I'm using the same version. If you disable the skin everything is ok? I didn't touch the addons scaling functions.
Try to comment these out:
TrinketMenu_MainFrame:SetClampedToScreen(true)
TrinketMenu_MenuFrame:SetClampedToScreen(true)

@Arcitec
Copy link
Contributor Author

Arcitec commented Jan 20, 2019

Hi, thanks for your suggestions. I am home and researching this now. I’ll post my results soon!

@Arcitec
Copy link
Contributor Author

Arcitec commented Jan 20, 2019

Alright @Apollyonn, thanks for the help! TrinketMenu had worked for me before it became skinned, so I assumed it was the skin. But I found the cause now.

Here's what the bug looks like, btw: https://imgur.com/MaSOGNO (it can also happen with a "horizontal explosion" as I described earlier in this thread; the difference that decides how it breaks seems to be which corner of the screen TrinketMenu is closest to).

I tried with/without the clamping. No difference. Disabled the skin. No difference. (!)

But then I discovered what causes the bug: If you move TrinketMenu near one of the screen edges, and then resize it, THAT is when it explodes. If you have it in the center of the screen while resizing, it works well.

It's actually a bug in TrinketMenu itself.

I am pretty sure the author has some math bug. They probably have something like "getcursorposition" at drag start and then while dragging they do some math that they've messed up when the cursor is near a screen edge.

Any thoughts? This wasn't a bug in the addon skin itself, but since it's seriously breaking TrinketMenu's functionality (because I'd wager most people put theirs in a screen corner, which means it'll break), then maybe it's something the skin can fix by overriding TrinketMenu's resize function? If not, just close this ticket. :) At least this ticket will be a reference for anyone else who sees this bug.

Either way, thank you so much for your incredible kindness in helping the community with ElvUI for TBC. You are awesome!

PS: The workaround is: Move TrinketMenu to the center of the screen (where it's safe to resize without breaking the frame), then resize it, then move it back where you wanted it.

@Apollyonn
Copy link
Contributor

Unfortunately most tbc addons are badly written. I think in this case the problem is that the addon uses scale instead of size. Probably the whole scaling functions would need a rewrite in order to fix it

@Arcitec
Copy link
Contributor Author

Arcitec commented Jan 20, 2019

@Apollyonn Hmm yeah, you're right... the scaling functions in TrinketMenu are a total mess.

function TrinketMenu.ScaleFrame(scale)
	local frame = TrinketMenu.FrameToScale
	local oldscale = frame:GetScale() or 1
	local framex = (frame:GetLeft() or TrinketMenuPerOptions.XPos)* oldscale
	local framey = (frame:GetTop() or TrinketMenuPerOptions.YPos)* oldscale

	frame:SetScale(scale)
	if frame:GetName() == "TrinketMenu_MainFrame" then
		TrinketMenu_MainFrame:SetPoint("TOPLEFT","UIParent","BOTTOMLEFT",framex/scale,framey/scale)
		TrinketMenuPerOptions.XPos = TrinketMenu_MainFrame:GetLeft()
		TrinketMenuPerOptions.YPos = TrinketMenu_MainFrame:GetTop()
	elseif TrinketMenuOptions.KeepDocked=="OFF" then
		TrinketMenu_MenuFrame:ClearAllPoints()
		TrinketMenu_MenuFrame:SetPoint("TOPLEFT","UIParent","BOTTOMLEFT",framex/scale,framey/scale)
	end
end

function TrinketMenu.Scaling()
	local frame = TrinketMenu.FrameToScale
	local oldscale = frame:GetEffectiveScale()
	local framex, framey, cursorx, cursory = frame:GetLeft()*oldscale, frame:GetTop()*oldscale, GetCursorPosition()
	if (cursorx-framex)>32 then
		local newscale = (cursorx-framex)/TrinketMenu.ScalingWidth
		TrinketMenu.ScaleFrame(newscale)
	end
end

That code looks like some "let's throw some shit together and pray that it works" solution. What's all this about "look at the frame width, then check the new width and figure out the new scale from that" etc... Weird code.

I don't know how to fix it, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants