WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Statusbar borders (https://www.wowinterface.com/forums/showthread.php?t=41299)

Malakahh 08-30-11 08:39 AM

Statusbar borders
 
1 Attachment(s)
Hello =)

I'm currently playing around with some status bars, and I've been having some trouble fitting the border textures. As far as I've been able to google myself to, I need to use the SetBackdrop() method, however this places the borders behind my status bar and after even further investigation, I still haven't been able to get them placed in a proper position. I've included an image to clarify what I'm talking about.

Code:

local time = 0
local value = 30
local totalValue = 100

MyStatusBar = CreateFrame("StatusBar", nil, UIParent)
MyStatusBar:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar")
MyStatusBar:GetStatusBarTexture():SetHorizTile(false)
MyStatusBar:SetMinMaxValues(0, 100)
MyStatusBar:SetValue(totalValue)
MyStatusBar:SetWidth(200)
MyStatusBar:SetHeight(10)
MyStatusBar:SetPoint("CENTER",UIParent,"CENTER")
MyStatusBar:SetStatusBarColor(1,0,0) 
 

MyStatusBar:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background",
                                            edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
                                            tile = true, tileSize = 32, edgeSize = 8,
                                            insets = { left = 2, right = 2, top = 2, bottom = 2 }
                                            })
MyStatusBar:SetBackdropColor(0,0,0,1)



SLASH_MSB1 = "/msb"
SlashCmdList["MSB"] = function()
  MyStatusBar:SetScript("OnUpdate", function(self, elapsed)
    time = time + elapsed
    local percent = (value-time)/value
    MyStatusBar:SetValue(totalValue*percent)
    print("hi "..time)
  end)
end

SLASH_MSBSTOP1 = "/msb_stop"
SlashCmdList["MSBSTOP"] = function()
  MyStatusBar:SetScript("OnUpdate", nil)
end

Attachment 6469

Unkn 08-30-11 08:54 AM

Try changing the insets...

lua Code:
  1. insets = { left = 2, right = 2, top = 2, bottom = 2 }


Play with those values, until you get the border positioned where you wont... you can also do negative numbers for the inset as well. That will move the border out from its anchored position - or making it larger than the bg its attached to - Which might be what you need to do.

Example:
lua Code:
  1. insets = { left = -2, right = -2, top = -2, bottom = -2 }

Malakahh 08-30-11 08:59 AM

Thanks for your answer. I just tried entering an exaggerated amount. It only appears to affect the background texture, the edgetexture stay where it is. =/

Unkn 08-30-11 11:54 PM

Hrm I'll play with my crappy oUF layout tomorrow see if I can come up with something else to help you. If you figure it out before then YAY!

Haleth 08-31-11 01:42 AM

I'm fairly certain that you can't use regular backdrop borders on status bars because a status bar texture covers the entire frame, and a backdrop cannot be larger than its parent. So, you have to use a separate frame or texture.

Malakahh 08-31-11 06:02 AM

Quote:

Originally Posted by Haleth (Post 244021)
I'm fairly certain that you can't use regular backdrop borders on status bars because a status bar texture covers the entire frame, and a backdrop cannot be larger than its parent. So, you have to use a separate frame or texture.

Alright, I'll try it when I get home. Thanks a bunch! =)

Sniffles 08-31-11 07:55 AM

Code:

frame.border = CreateFrame("Frame", nil, MyStatusBar)
frame.border:SetPoint("TOPLEFT", MyStatusBar, "TOPLEFT", -2, 2)
frame.border:SetPoint("BOTTOMRIGHT", MyStatusBar, "BOTTOMRIGHT", 2, -2)
frame.border:SetBackdrop({
bgFile = YOUR_TEXTURE,
edgeFile = YOUR_TEXTURE,
tile = false, tileSize = 0, edgeSize = 1,
insets = { left = -1, right = -1, top = -1, bottom = -1}
})
frame.border:SetFrameLevel(MyStatusBar:GetFrameLevel())


Malakahh 08-31-11 10:25 AM

I copied the code from Sniffles and made the proper adjustments and now it works flawlessly. =)

Thanks for the help!

Unkn 08-31-11 10:58 AM

Yay! Glad you got it working.


All times are GMT -6. The time now is 10:31 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI