Backdrop and resizable/movable frames
I have a frame using this backdrop:
Lua Code:
The edge file is made up of 8x8 tiles and is correctly configured, however, when the frame can be moved and resized, the backdrop doesn't always draw correctly. Any idea why this is happening, and if so, a way to circumvent or even prevent it? It looks like it moves one line from the top edge to the bottom edge, or occassionally it moves a line from the left edge to the right edge. Correct: Incorrect: |
Here's a gif, vaguely showing the issue inside a moving scrollframe:
Quality is bad, but good enough to spot the flickering edge file. |
That gif is hard to follow with the bouncing. It is just better to post with the code tags or Lua button.
Anyway, the error is simple: loc1 is presumably undefined, or if it is, your assignment of it is incorrect. Depending on what you want (can't see the rest of your code): Code:
loc1 = 11 |
Quote:
|
Quote:
|
Quote:
|
This is a general issue with single pixel lines. As the tooltip moves, the border will occasionally get between pixels which results in that line becoming dimmer.
One way you can work around this is ensuring that 1) both the width and height are whole numbers and 2) the frame is positioned on whole pixels. Using floor() and/or ceil() can help in both cases. Also, if you're not anchoring corner to corner, you may need to add .5. |
I've used
Lua Code:
to fix borders with this issue on corner to corner offsets |
Quote:
I tried applying this: Lua Code:
However, the problem remains. Adding .5 at the end of each calculation doesn't do the trick either. Quote:
|
It's hard to say what else would need to be done without seeing the rest of your code, though I would also look at your scroll update too.
|
Here's the git.
It's just a simple draft atm. Note that I removed the border from the tooltip, but the border still exists on the main frame. The frame is constructed here, and the editor resizing happens here. /dev to open the editor. |
First, your OnDragStart/Stop hooks do not call your custom Move and StopMoveSize methods.
Second, instead of ceil() (not sure why I mentioned it tbh), I would round the vars using floor(var + 0.5). This is mostly to combat the fact that the numbers from GetPoint/GetSize could be +/- 0.0000002430 from the actual value. Rounding it simply gets the value back to what it should be, because when dealing with exact pixels such details make a difference. UIParent can in most cases be assumed to have even numbered sides, and since the editor is anchored to UIParent it would be easier to just clamp the frame down the the nearest even number rather than worrying about half pixel positioning. This can easily be done using modulus (%). (Var % 2) evals to 1 if Var is odd, and evals to 0 if it's even. The SetPoint was taken out of the if block to account for the width/height potentially being odd, and changing it to even. After using :StartSizing() the anchors of the frame are updated dynamically in the background, so if the width ends up being odd (e.g. 345) and you are anchored to the CENTER, the x offset might end up with a half (e.g. 45.5). When the side is then resized (e.g. 344), that point still remains and results in the border looking off. Lua Code:
|
Quote:
I initially tried to even the numbers using modulus, but took it out since it didn't solve the issue. I was not, however, clever enough to account for the centered anchor point. It seems to work as intended now. Thanks for taking the time to investigate this. :) |
All times are GMT -6. The time now is 08:59 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI