Thread Tools Display Modes
08-01-16, 10:42 AM   #1
gempir
A Black Drake
 
gempir's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 84
Backdrop issues - 1px border

I haven't looked at my addons in a while and am now in the process of updating them when I noticed some issues with my panels/frames borders



This is my main panel and it has a perfect 1px border on top but seems to have a 2px border or so on the left and right side. (Outter panel, not the buttons)

I ran this UI scale script

Code:
/script SetCVar("uiScale", 768/string.match(({GetScreenResolutions()})[GetCurrentResolution()], "%d+x(%d+)"))
But that didn't change anything about the issue sadly.

My frame code looks something like this:


Lua Code:
  1. local gempUI_mainpanel = CreateFrame("Frame",nil,UIParent)
  2. gempUI_mainpanel:SetFrameStrata("BACKGROUND")
  3. gempUI_mainpanel:SetWidth(476)
  4. gempUI_mainpanel:SetHeight(85+extrabars_1)
  5. gempUI_mainpanel:SetBackdrop({
  6.     bgFile = [[Interface\Buttons\WHITE8x8]],
  7.     edgeFile = [[Interface\Buttons\WHITE8x8]],
  8.     edgeSize = 1,
  9. })
  10. gempUI_mainpanel:SetBackdropColor(G.color.r,G.color.g,G.color.b,G.color.a)
  11. gempUI_mainpanel:SetBackdropBorderColor(G.bordercolor.r, G.bordercolor.g, G.bordercolor.b, G.bordercolor.a)
  12. gempUI_mainpanel:SetPoint("BOTTOM",0,-1)
  13. gempUI_mainpanel:Show()

Did the Interface\Buttons\WHITE8x8 texture change or something, or am I doing something wrong? I want a simple 1px border on my frames all around.

I have a 1440p screen if thats relevant

Last edited by gempir : 08-01-16 at 11:06 AM.
  Reply With Quote
08-01-16, 10:52 AM   #2
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by gempir View Post
I haven't looked at my addons in a while and am now in the process of updating them when I noticed some issues with my panels/frames borders



This is my main panel and it has a perfect 1px border on top but seems to have a 2px border or so on the left and right side. (Outter panel, not the buttons)

I ran this UI scale script

Code:
/script SetCVar("uiScale", 768/string.match(({GetScreenResolutions()})[GetCurrentResolution()], "%d+x(%d+)"))
But that didn't change anything about the issue sadly.

My frame code looks something like this:


Lua Code:
  1. local gempUI_mainpanel = CreateFrame("Frame",nil,UIParent)
  2. gempUI_mainpanel:SetFrameStrata("BACKGROUND")
  3. gempUI_mainpanel:SetWidth(476)
  4. gempUI_mainpanel:SetHeight(85+extrabars_1)
  5. gempUI_mainpanel:SetBackdrop({
  6.     bgFile = [[Interface\Buttons\WHITE8x8]],
  7.     edgeFile = [[Interface\Buttons\WHITE8x8]],
  8.     edgeSize = 1,
  9. })
  10. gempUI_mainpanel:SetBackdropColor(G.color.r,G.color.g,G.color.b,G.color.a)
  11. gempUI_mainpanel:SetBackdropBorderColor(G.bordercolor.r, G.bordercolor.g, G.bordercolor.b, G.bordercolor.a)
  12. gempUI_mainpanel:SetPoint("BOTTOM",0,-1)
  13. gempUI_mainpanel:Show()

Did the Interface\Buttons\WHITE8x8 texture change or something, or am I doing something wrong? I want a simple 1px border on my frames all around.

Try this

Lua Code:
  1. local PerfectBorders = 768/string.match(GetCVar("gxWindowedResolution"), "%d+x(%d+)") / Insert Your UIScale Here
  2. local PerfectScale = function(ScaleObject)
  3.     return PerfectBorders*math.floor(ScaleObject/PerfectBorders)
  4. end
  Reply With Quote
08-01-16, 11:04 AM   #3
gempir
A Black Drake
 
gempir's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 84
Originally Posted by Game92 View Post
Try this

Lua Code:
  1. local PerfectBorders = 768/string.match(GetCVar("gxWindowedResolution"), "%d+x(%d+)") / Insert Your UIScale Here
  2. local PerfectScale = function(ScaleObject)
  3.     return PerfectBorders*math.floor(ScaleObject/PerfectBorders)
  4. end
So do I use it like this?

Lua Code:
  1. local newScale = PerfectScale(frame)
  2. frame:SetScale(newScale)

Edit:

I found out setting the UI scale to 0.5333333 works out on my 1440p screen but it's only possible via chat with the command /run UIParent:SetScale(0.5333333)

I would like to set it automaticly in my addon and dynamicly depending on the resolution

Okay this is my solution for now:

Lua Code:
  1. local f = CreateFrame("Frame", nil, UIParent)
  2. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  3. f:SetScript("OnEvent", function(self, event)
  4.     local newScale = 768 / string.match(({GetScreenResolutions()})[GetCurrentResolution()], "%d+x(%d+)")
  5.     UIParent:SetScale(newScale) -- change the size and reload your ui (/reloadui) or restart the game
  6.     f:UnregisterAllEvents()
  7. end)

Only thing with this is that the user can't edit his UIscaling

Last edited by gempir : 08-01-16 at 11:48 AM.
  Reply With Quote
08-01-16, 02:20 PM   #4
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by gempir View Post
So do I use it like this?

Lua Code:
  1. local newScale = PerfectScale(frame)
  2. frame:SetScale(newScale)

Edit:

I found out setting the UI scale to 0.5333333 works out on my 1440p screen but it's only possible via chat with the command /run UIParent:SetScale(0.5333333)

I would like to set it automaticly in my addon and dynamicly depending on the resolution

Okay this is my solution for now:

Lua Code:
  1. local f = CreateFrame("Frame", nil, UIParent)
  2. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  3. f:SetScript("OnEvent", function(self, event)
  4.     local newScale = 768 / string.match(({GetScreenResolutions()})[GetCurrentResolution()], "%d+x(%d+)")
  5.     UIParent:SetScale(newScale) -- change the size and reload your ui (/reloadui) or restart the game
  6.     f:UnregisterAllEvents()
  7. end)

Only thing with this is that the user can't edit his UIscaling
You use it like this =)

Lua Code:
  1. AGlow:SetBackdrop({
  2.             bgFile = nil,
  3.             insets = {top = -1, left = 1, bottom = 1, right = 1},
  4.             edgeFile = "Interface\\Buttons\\WHITE8x8", edgeSize = PerfectBorders+PerfectScale(1.50),
  5.         })

and you can set ur UIScale just by doing this too =)

Lua Code:
  1. SetCVar("uiScale", YourUIScale)

Last edited by Aftermathhqt : 08-01-16 at 02:23 PM.
  Reply With Quote
08-01-16, 02:35 PM   #5
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
The uiscale cvar can't go below 0.64, basically if you're at or above 1200 pixels in height you need to set the cvar to 1 and scale with UIParent instead.

I made this after upgrading my monitors earlier this year:
https://github.com/p3lim-wow/Inomena...re/scaling.lua
  Reply With Quote
08-01-16, 11:15 PM   #6
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Or you can get LibUtilities to do the pixel perfect math stuff for you.From the description:
Code:
SetCVar("uiScale", tostring(self:PixelPerfect(1)))
SetCVar("useUiScale", "1")
local uiScale, resolutionX, resolutionY = MyAddOn:VisualData()
if resolutionY >= 1200 then
    UIParent:SetScale(uiScale)
end
  Reply With Quote
08-02-16, 03:56 AM   #7
gempir
A Black Drake
 
gempir's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 84
Thank you all for your suggestions!

I don't see the advantage of using LibUtilites-1.0 since I can achieve the same with a small snippet and without modifying all elements of my UI.

I've found this is the solution I prefer:

Lua Code:
  1. local f = CreateFrame("Frame", nil, UIParent)
  2. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  3. f:SetScript("OnEvent", function(self, event)
  4.     SetCVar("uiScale", "1")
  5.     SetCVar("useUiScale", "1")
  6.     local newScale = 768 / string.match(({GetScreenResolutions()})[GetCurrentResolution()], "%d+x(%d+)")
  7.     UIParent:SetScale(newScale) -- change the size and reload your ui (/reloadui) or restart the game
  8.     f:UnregisterAllEvents()
  9. end)

I will make it a one time loading thing though and give the player the option to redo it or just use his own scaling.
Thanks for all the fast and helpful answers.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Backdrop issues - 1px border


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off