View Single Post
10-15-17, 04:19 PM   #5
CC_WOW
A Deviate Faerie Dragon
 
CC_WOW's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2016
Posts: 19
Thanks, but wouldn't setting the CVar change the entire UI's scaling? That seems like something the user ought to do for themselves, I merely want my UI to not glitch at whatever scale is currently set.

Example: With my resolution, the proper (and automatic) UI scale is 0.71111. However, I normally have set mine to about 0.89999 to scale things the way I like them, which has now caused at least some parts of the frames to not be on integer pixels (apparently). Setting UI scale to 1 works fine (the frame is perfect, but way too big), and on 0.7111 it also is perfect, but way too small. Thusly, I want to simply take the UI scale that the user set, and maybe a separate setting to scale the addon itself, and apply that to the frames without the glitches.

From your reply, I believe I can just take the same approach you did except using those values (and not setting the CVar) to calculate the proper scale (BEFORE fixing the floating point pixel coordinates). I would then run the "pixel perfect" function on the window frames, which seems reasonable. However, does that also fix all the child frames (which are the main concern here) with their 1px margins etc? Or do I run that function on every single frame? Also, why do I want to SetScale, twice? What I did was simply

Code:
    local scaleFactor = GetScaleFactor()
    local padding = settings.someValue * scaleFactor
    
    frame:SetPoint("TOPLEFT", padding, -padding)
and that would basically turn a 2 px padding into 2 / (768/1080) = 2.8125 - which is obviously not an integer value.

My idea as described would then simply be to round it via math.floor(2.8125 + 0.5) = 3 and get a 3 px padding instead on the given resolution, which should (?) be able to be positioned correctly if my main frame is using integer coords and everything is rounded like that.

The only issue then is centering elements with odd sizes, but I can maybe force them to always be even values (if they need to be centered, or contain elements that need to be centered).

PS: The addon in question is not an actual UI, it just has a bunch of frames with finely-tuned elements and the glitching drives me nuts. Here is how an early draft looked (no visible glitches, but to give an idea of the type of child elements that need to be placed correctly from using pixel settings):


Last edited by CC_WOW : 10-15-17 at 04:22 PM.
  Reply With Quote