View Single Post
08-17-19, 01:51 AM   #1
spychalski
A Kobold Labourer
Join Date: Jun 2008
Posts: 1
Adding one pixel in a frame's height instead adds two?

Hey, it's my first time messing around with addons, trying to make a simple frame and ran into a very intriguing issue.

For starters, here is some code:
Lua Code:
  1. local function CreateUnitFrame(self, unit)
  2.     self:SetSize(220, 41)
  3.     self:SetBackdrop(settings.textures.backdrop)
  4.     self:SetBackdropColor(0, 0, 0)
  5.  
  6.     -- health bar
  7.     local hp = CreateFrame("StatusBar", nil, self)
  8.     hp:SetPoint("TOPLEFT")
  9.     hp:SetPoint("TOPRIGHT")
  10.     hp:SetHeight(30)
  11.     hp:SetStatusBarTexture(settings.textures.main)
  12.     hp:SetStatusBarColor(unpack(settings.colors.hpBar))
  13.  
  14.     hp.bg = hp:CreateTexture(nil, "BACKGROUND")
  15.     hp.bg:SetAllPoints(hp)
  16.     hp.bg:SetTexture(settings.textures.backdrop.bgFile)
  17.  
  18.     hp.frequentUpdates = true
  19.     hp.PostUpdate = core.SetBackground
  20.     self.Health = hp
  21.  
  22.     -- power bar
  23.     local pb = CreateFrame("StatusBar", nil, self)
  24.     pb:SetPoint("BOTTOMLEFT", 0, 0)
  25.     pb:SetPoint("BOTTOMRIGHT", 0, 0)
  26.     pb:SetHeight(10)
  27.     pb:SetStatusBarTexture(settings.textures.main)
  28.  
  29.     pb.bg = pb:CreateTexture(nil, "BACKGROUND")
  30.     pb.bg:SetAllPoints(pb)
  31.     pb.bg:SetTexture(settings.textures.backdrop.bgFile)
  32.     pb.bg:SetVertexColor(unpack(settings.colors.hpBar))
  33.  
  34.     pb.colorPower = true
  35.     self.Power = pb
  36. end

This is a simple Frame with a Health bar and a Power bar. My goal is to have 1px borders around the frame itself and one pixel separating the two bars. Instead, this is what I get:



and in case you can't see it:


the frame's height is 44, when it should be 43:

1 px top
40 px health
1 px gap
10 px power
1 px bottom

Now, checking the second image, I can tell you the Power bar is only 9 pixels high. The underlying frame is "taking" one pixel from it.

Does anybody have any ideas how to approach and fix this?

I already messed around with UI scales, no matter what it is (0.5333, 0.64, 0.7111 and 1 tested), the issue persists.

The only way I can fix this is by instead drawing one of the inner bars with one less pixel.
  Reply With Quote