Intro (feel free to skip)
After a few months away from wow, I returned and have been doing some good progress on some wow addons. Basically as a bit of a learning project have been writing a complete UI replacement (an amalgum of grid, omen, icehud, rBuff, power auras, dkp mod, minimap, etc).
Most of the core functionality has been fairly routine to implement, but now I'm starting to do a 'sexy' pass and there's some basic behaviours that I'm being stumped with.
Right now, my rBuff type implementation (it has a few tricks in the way it lays things outs and time formatting, but nothing super crazy) is not looking the way I'd like. I'd like to have a user configurable width square border around my buff icons.
Actual Question
I want to set my frame up with an empty background (done) and with a border (edge file) that can be coloured via Frame:SetBackdropBorderColor() to generate a nice square border.
My question is how do I create this border? I've tried creating a PNG file that is 8 pixels wide of white (1, 1, 1, 1) and another and my code does:
Now, am I doing something super dumb here or should that be the way to have a 1 pixel wide square red border? If I'm on the right track, I'll muddle my way to work out what's going wrong, but if not, could someone just give me a kick in the right direction please.
Many thanks in advance.
bubble
P.S. My only reason for asking is because there seems to be a reasonably large lack of documentation on this function anywhere. I've tried wowwiki and wowprogramming websites and the wowprogramming book: nothing really covers it in a little more detail.
I've also tried looking through the code for ButtonFacade but tbh it got a little complicated and I still couldn't see how they were forming the border.
I did cheat by using a flat colour texture behind my icon but this obviously fails when I want to have my 'buff' textures at some alpha transparency as the flat colour washes out the texture.
cheers tek. I was typing the code from memory and perhaps I did something as dumb as that in my real code.
In truth, I just wanted to ensure that I wasn't somehow misunderstanding how SetBackdrop() worked. So using an 8x1 pixel, solid white image with edgeSize=1 is reasonable for a border yeh?
(ie. it will scale to fill whatever inserts={} I use and will get coloured via SetBackdropBorderColor()?)
If so, then it's something dumb I'm doing (and it could quite likely be the [[""]] trick. I'll check it when I get home from work)
ummm, isn't 2^3 by 2^0 ok? So should I make it 8x2?
Or are you saying both files of the edge inner components must be positive powers of 2?
(ie. it must be minimum size of 16x2 so that the actual edges are 2x2?)
I'll try this when I get home tonight - perhaps this was the problem. Many thanks.
The minimum size for either dimension in textures for WoW is 8 pixels.
Therefore, your border texture file must be a minimum of 8x8 pixels in size.
Border textures are actually comprised of 8 sub-textures. So if you want to make a "real" border texture, it should be 64 x 8 pixels, or a multiple thereof.
Your 8x8 texture may still work. Presumably, it would stretch each 1 x 8 pixel chunk to your desired edge size and then tile it.
The minimum size for either dimension in textures for WoW is 8 pixels.
Therefore, your border texture file must be a minimum of 8x8 pixels in size.
Border textures are actually comprised of 8 sub-textures. So if you want to make a "real" border texture, it should be 64 x 8 pixels, or a multiple thereof.
Your 8x8 texture may still work. Presumably, it would stretch each 1 x 8 pixel chunk to your desired edge size and then tile it.
thanks heaps nandini! I'll give that a crack tonight and see how it goes. I hadn't read (well at least noticed) the minimum of 8x8 before anywhere.
i actually wrote a bit of code that simulates the blizzard setbackdrop function because it has (or had?) a bug in the texture coordinate calculation. my interpretation of "insets" probably differs from blizzards, tho...
anyway, what you should do is take something that works (like a tooltip frame or something) and then slowly change the params to be what you want, that way you're not having to debug every different aspect at the same time.
swap the texture first to make sure it's loading properly. then swap the edge size to make sure that a size of 1 is okay. then play with the insets to see what you need there to make it look right...
i actually wrote a bit of code that simulates the blizzard setbackdrop function because it has (or had?) a bug in the texture coordinate calculation. my interpretation of "insets" probably differs from blizzards, tho...
Blizzard's code is littered with these imprecise interpretations of texture coordinates. Similar lack of precision is evident in their division of the minimap blip textures and the mapping of hundreds of model textures to vertexes. In general, these imprecisions and edge defects get smoothed out by scaling and filtering, but they can be annoying for UI perfectionists. :)
If I comment out the 'tooltips' file and uncomment white.blp I just get a blank frame. I know it's there but you can't see it.
I've tested that the PNG file is correct (or at least I believe it is correct). I've placed the white.blp file in the root directory of my addon rather than "Textures" subdirectory. Reloaded wow. Still can't seem to get it to work.
I've pretty much done everything I can think of to fix this. I'm guessing it has to be the path to the bitmap, or somehow there's a problem with the bitmap itself. I've checked the bitmap by placing it on a simple html file with a black background (excuse the awful html hack) and it works fine.
So either blpconv is doing something screwy or it's the path, but either option has me farked how.
(I've attached the original white.png and white.blp files I'm using)
[[Textures/white.blp]] and [[white.blp]] are not paths into your addons folder.
All paths for files are from the WoW root directory. If your white.blp file is in your addon's folder, then the path will look like this:
[[Interface\AddOns\yourmodfolder\white.blp]] or
[[Interface\AddOns\yourmodfolder\Textures\white.blp]]
(the extension isn't even necessary, actually, but doesn't hurt)
If you use the "" method (instead of [[ ]]) then you need to escape the backslashes so that the code is compiled correctly.
"Interface\\AddOns\\yourmodfolder\\white.blp"
Seerah, thanks heaps again! Damn that was a frustrating bug to track down.
If I may ask another favour. Could someone correct my understanding of coordinate scale within wow:
I was under the impression if UIParent:GetScale() returned 1 that if you did something like:
local frm=CreateFrame("Frame", nil, UIParent)
frm:SetWidth(100)
frm:SetHeight(100)
would create a frame 100 pixels x 100 pixels (in true screen pixels). However I'm finding this is not the case. My wow screen is 1650 pixels wide yet with UIParent:GetScale() returning 1, a frame width of approximately 1230 pixels covers the entire screen.
Am I missing something obvious here? (Note, I do not have the 'Use UI scale' flag ticked in video settings)
The reason I ask, is that as some of the others have mentioned in these forums, I'm getting a few weird texture renderings and am having to do weird stuff like use sub pixel edgeSize's to make my UI look right. Is there a 'right' way to do screen pixel coordinate calculations?
My wow screen is 1650 pixels wide yet with UIParent:GetScale() returning 1, a frame width of approximately 1230 pixels covers the entire screen.
Try GetEffectiveScale(). Also note that UIParent does not start out with your screen's native resolution; check out http://www.wowwiki.com/UI_coordinates.
thanks very much talden. My development so far really hasn't worried about exact positioning so I hadn't noticed this issue. Looks like I'm going to have to do some reading on how the wow layout manager decides to round pixels.
Blizzard's code is littered with these imprecise interpretations of texture coordinates. Similar lack of precision is evident in their division of the minimap blip textures and the mapping of hundreds of model textures to vertexes. In general, these imprecisions and edge defects get smoothed out by scaling and filtering, but they can be annoying for UI perfectionists. :)
oh it's worse than that -- they actually have a miscalculation somewhere. if you have a resizable frame and grow/shrink it, you can see the textures "slide" when they really ought to be pretty much locked in place. in fact, if you resize your frame small enough, the side textures (that is, the parts that aren't corners) actually invert at a certain point. it doesn't show up very distinctly with the normal blizz textures, but if you do something more detailed you see it pretty clearly.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Intro (feel free to skip)
After a few months away from wow, I returned and have been doing some good progress on some wow addons. Basically as a bit of a learning project have been writing a complete UI replacement (an amalgum of grid, omen, icehud, rBuff, power auras, dkp mod, minimap, etc).
Most of the core functionality has been fairly routine to implement, but now I'm starting to do a 'sexy' pass and there's some basic behaviours that I'm being stumped with.
Right now, my rBuff type implementation (it has a few tricks in the way it lays things outs and time formatting, but nothing super crazy) is not looking the way I'd like. I'd like to have a user configurable width square border around my buff icons.
Actual Question
I want to set my frame up with an empty background (done) and with a border (edge file) that can be coloured via Frame:SetBackdropBorderColor() to generate a nice square border.
My question is how do I create this border? I've tried creating a PNG file that is 8 pixels wide of white (1, 1, 1, 1) and another and my code does:
Now, am I doing something super dumb here or should that be the way to have a 1 pixel wide square red border? If I'm on the right track, I'll muddle my way to work out what's going wrong, but if not, could someone just give me a kick in the right direction please.
Many thanks in advance.
bubble
P.S. My only reason for asking is because there seems to be a reasonably large lack of documentation on this function anywhere. I've tried wowwiki and wowprogramming websites and the wowprogramming book: nothing really covers it in a little more detail.
I've also tried looking through the code for ButtonFacade but tbh it got a little complicated and I still couldn't see how they were forming the border.
I did cheat by using a flat colour texture behind my icon but this obviously fails when I want to have my 'buff' textures at some alpha transparency as the flat colour washes out the texture.
In truth, I just wanted to ensure that I wasn't somehow misunderstanding how SetBackdrop() worked. So using an 8x1 pixel, solid white image with edgeSize=1 is reasonable for a border yeh?
(ie. it will scale to fill whatever inserts={} I use and will get coloured via SetBackdropBorderColor()?)
If so, then it's something dumb I'm doing (and it could quite likely be the [[""]] trick. I'll check it when I get home from work)
ummm, isn't 2^3 by 2^0 ok? So should I make it 8x2?
Or are you saying both files of the edge inner components must be positive powers of 2?
(ie. it must be minimum size of 16x2 so that the actual edges are 2x2?)
I'll try this when I get home tonight - perhaps this was the problem. Many thanks.
Therefore, your border texture file must be a minimum of 8x8 pixels in size.
Border textures are actually comprised of 8 sub-textures. So if you want to make a "real" border texture, it should be 64 x 8 pixels, or a multiple thereof.
Your 8x8 texture may still work. Presumably, it would stretch each 1 x 8 pixel chunk to your desired edge size and then tile it.
thanks heaps nandini! I'll give that a crack tonight and see how it goes. I hadn't read (well at least noticed) the minimum of 8x8 before anywhere.
f:SetBackdrop({ edgeFile = "Interface\\Buttons\\WHITE8X8", edgeSize = 1 })
anyway, what you should do is take something that works (like a tooltip frame or something) and then slowly change the params to be what you want, that way you're not having to debug every different aspect at the same time.
swap the texture first to make sure it's loading properly. then swap the edge size to make sure that a size of 1 is okay. then play with the insets to see what you need there to make it look right...
Inset is the distance, in pixels, between the outer edge of the frame and the surface covered by the background texture.
Blizzard's code is littered with these imprecise interpretations of texture coordinates. Similar lack of precision is evident in their division of the minimap blip textures and the mapping of hundreds of model textures to vertexes. In general, these imprecisions and edge defects get smoothed out by scaling and filtering, but they can be annoying for UI perfectionists. :)
If I comment out the 'tooltips' file and uncomment white.blp I just get a blank frame. I know it's there but you can't see it.
I've tested that the PNG file is correct (or at least I believe it is correct). I've placed the white.blp file in the root directory of my addon rather than "Textures" subdirectory. Reloaded wow. Still can't seem to get it to work.
I've pretty much done everything I can think of to fix this. I'm guessing it has to be the path to the bitmap, or somehow there's a problem with the bitmap itself. I've checked the bitmap by placing it on a simple html file with a black background (excuse the awful html hack) and it works fine.
So either blpconv is doing something screwy or it's the path, but either option has me farked how.
(I've attached the original white.png and white.blp files I'm using)
All paths for files are from the WoW root directory. If your white.blp file is in your addon's folder, then the path will look like this:
[[Interface\AddOns\yourmodfolder\white.blp]] or
[[Interface\AddOns\yourmodfolder\Textures\white.blp]]
(the extension isn't even necessary, actually, but doesn't hurt)
If you use the "" method (instead of [[ ]]) then you need to escape the backslashes so that the code is compiled correctly.
"Interface\\AddOns\\yourmodfolder\\white.blp"
Thanks heaps for that seerah :) Seriously, I've been beating my head against a wall with that for like 3 evenings.
Apologies for the language. Works brilliantly now. Christ, glad that it's fixed but so much time down toilet :(
If I may ask another favour. Could someone correct my understanding of coordinate scale within wow:
I was under the impression if UIParent:GetScale() returned 1 that if you did something like:
would create a frame 100 pixels x 100 pixels (in true screen pixels). However I'm finding this is not the case. My wow screen is 1650 pixels wide yet with UIParent:GetScale() returning 1, a frame width of approximately 1230 pixels covers the entire screen.
Am I missing something obvious here? (Note, I do not have the 'Use UI scale' flag ticked in video settings)
The reason I ask, is that as some of the others have mentioned in these forums, I'm getting a few weird texture renderings and am having to do weird stuff like use sub pixel edgeSize's to make my UI look right. Is there a 'right' way to do screen pixel coordinate calculations?
Try GetEffectiveScale(). Also note that UIParent does not start out with your screen's native resolution; check out http://www.wowwiki.com/UI_coordinates.
oh it's worse than that -- they actually have a miscalculation somewhere. if you have a resizable frame and grow/shrink it, you can see the textures "slide" when they really ought to be pretty much locked in place. in fact, if you resize your frame small enough, the side textures (that is, the parts that aren't corners) actually invert at a certain point. it doesn't show up very distinctly with the normal blizz textures, but if you do something more detailed you see it pretty clearly.