Skip to content

Conversation

@NoBetaBoredom
Copy link
Contributor

So, the current and former versions didn't have pixel perfect borders for me by default (1440p resolution). I tried the approach I use for some of my WeakAuras, and with this I get pixel perfect borders on every resolution, in every situation I tried (even randomly resizing in windowed mode (after a /reload ofc)). Theres also no text jumping when moving the mouse.
Please test it yourself and see if you can find any edge cases, otherwise I think this is better than the current approach.

@frozn frozn added 1_enhancement New feature or request 2_to develop Development can begin labels Feb 17, 2022
@frozn frozn merged commit 208b7f3 into frozn:main Feb 17, 2022
@frozn
Copy link
Owner

frozn commented Feb 17, 2022

I applied the following modifications to your PR:

  • added option for pixel perfect tooltip border (under "Backdrop")
  • switched to "PixelUtil.GetNearestPixelSize()" to implement pixel perfect tooltip border
  • mouse offsets don't need to be pixel perfect

Background to this:
WoW does not use pixel-perfect sizing by default to ensure that the UI is the same size in every resolution. But in case of a pixel-perfect layout, a workaround is required.

This workaround actually is only necessary for the tooltip border. The mouse offset does not necessarily have to be pixel-perfect, because this isn't visually noticeable. Additionally I added an option for this, because this is only necessary for solid borders and not for "normal" border textures e.g. the default tooltip border.

I think I push out a new release tomorrow with the latest fixes. After that, I continue with the next PR (#48).

Again: Thank you for your input here! Without it, the pixel-perfect-border-issue would still be unsolved. 😉

@NoBetaBoredom
Copy link
Contributor Author

NoBetaBoredom commented Feb 17, 2022

It is absolutely necessary to also convert the mouse offsets, I tested it out. Otherwise either the border will be 0/2px sometimes, or the text inside will jump around very slightly on movement. It makes sense when you think about it, because without converting, you are positioning the tooltip in a non-pixelperfect position.

The same thing is the case with the itemicon and auraicons in the other PR, if you don't convert it they will be positioned incorrectly even though the main tooltip is perfect, because the offsets wouldn't be.

@frozn
Copy link
Owner

frozn commented Feb 17, 2022

But what if the tooltip isn't mouse anchored? I think that by default the textures are snapped to pixel grid. There's a function to disable this on demand: https://www.townlong-yak.com/framexml/live/NineSlice.lua#185

During my tests, I had no problems with a 1-pixel border (under 1920x1080).

@NoBetaBoredom
Copy link
Contributor Author

It only matters if it's mouse anchored, yes

@frozn
Copy link
Owner

frozn commented Feb 17, 2022

I would be interested in how the current version performs in your case with regard to the tooltip borders. Can you perhaps make a test with the current version in main branch?

I think that's a really interesting topic. 🙂

@NoBetaBoredom
Copy link
Contributor Author

NoBetaBoredom commented Feb 17, 2022

Sure, I made a small video for you. First it shows current mainbranch, then after a reload it shows mainbranch with the mouse offsets sent through GetNearestPixelSize().

https://files.catbox.moe/mnmau3.mp4

As you can see, the text inside sometimes jumps one pixel forward even though the tooltip itself doesn't. After the conversion it moves perfectly. You can also see the bottom border being 2px. This is on 1440p.

Edit: it does not seem to happen at 1080p, but that's just coincidence. You can go into windowed mode and change the resolution to an arbitrary one, and a good solution should always produce perfect borders / no text jumping. Current main branch does not, but with the small change of converting the offsets it does.
I forgot to turn on the pixelperfect option, the borders work at every resolution as far as I could test, but the text jumping remains without converting offsets.
Edit2: I can't actually reproduce the text jumping with any other resolution than 1440p fullscreen.

@NoBetaBoredom
Copy link
Contributor Author

NoBetaBoredom commented Feb 17, 2022

After testing things from the other PR again, the conversion for the itemicon is unnecessary and I removed it. For the auraicons it's mainly needed because they usually are very small, and without converting them the errors will pile up resulting in uneven gaps that look ugly:

image

As you can see sometimes the gap is 2 pixels, sometimes it's 3 because of errors adding up (because they are anchored in a chain). Also, for such small icons, you really want to be able to position and define offsets pixel-perfect, which you won't be able to if you don't convert them. For example you might not be able to get a 3 pixel gap because "2" will result in a 2-real-pixel gap and "3" will result in a 4-real-pixel gap. This example with the aura icons would also apply to non-mouseanchored tooltips I believe.

For a truly pixel-perfect tooltip you definitely want to convert the offsets.

The "normal" way to do all this, which wouldn't require any conversions of offsets is to set the scale of the tooltip itself with gtt:SetScale(ppScale), and children would then inherit that and be perfectly positioned automatically, but I ran into some problems with that because tooltips are so weird in this game.

@NoBetaBoredom
Copy link
Contributor Author

NoBetaBoredom commented Feb 18, 2022

Insets need to be converted too, or it will be wrong at different scales ("Special" options):

image

Edit: on retail borders are wrong for me on many resolutions without converted insets also

@frozn
Copy link
Owner

frozn commented Feb 19, 2022

So, I've tinkered with this issue again quite extensively and have made the following modifications:

  • applied pixel perfect insets if activated (-> You're right. Border and Insets need to be pixel perfect to work together.)
  • added snapping of mouse offsets to pixel grid (-> The offset values don't need to be real pixels, but they snap now to the nearest pixel in grid. The cursor position values are already pixel perfect.)
  • reapply settings if display size or scale of UIParent changed (-> Because event UI_SCALE_CHANGED didn't fire if you change the UI scale in addon ElvUI where UIParent:SetScale() is called. This event fires if you change the UI scale in WoW settings.)

Finally, I have optimized the code a bit to prevent multiple calculations (e.g. mouse offsets snapping to pixel grid). I think I have tested all possible combinations/situations with 1 and 2 pixel borders.

If this is also ok for you, I would push out a new release, because there were already 2 issues to bugs that have already been fixed. 🙈

@NoBetaBoredom
Copy link
Contributor Author

Yes, mainbranch now works perfectly on 1440p.

@frozn
Copy link
Owner

frozn commented Feb 19, 2022

It's done: https://github.com/frozn/TipTac/releases/tag/v22.02.19

Next step: item/aura icon with optional (pixel perfect) border and clamping to screen 💪

@frozn frozn added the 3_solved Issue is fixed label Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1_enhancement New feature or request 2_to develop Development can begin 3_solved Issue is fixed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants