Clip the portraits to match the healthbar using some ScrollFrame trickery
Adrian L Lange [08-19-14 - 17:31]
Clip the portraits to match the healthbar using some ScrollFrame trickery
- Thanks to @zorker for his PoC with DiscoKugel
diff --git a/oUF_P3lim.lua b/oUF_P3lim.lua
index 6393759..d3bf507 100644
--- a/oUF_P3lim.lua
+++ b/oUF_P3lim.lua
@@ -19,6 +19,14 @@ local function PostUpdatePower(element, unit, cur, max)
element.__owner.Health:SetHeight(max ~= 0 and 20 or 22)
end
+local function PostUpdateHealth(element, unit, cur, max)
+ local ScrollFrame = element.__owner.Portrait.scrollFrame
+
+ local offset = -(230 * (1 - cur / max))
+ ScrollFrame:SetPoint('LEFT', offset, 0)
+ ScrollFrame:SetHorizontalScroll(offset)
+end
+
local function PostUpdateCast(element, unit)
local Spark = element.Spark
if(not element.interrupt and UnitCanAttack('player', unit)) then
@@ -446,13 +454,23 @@ local function Shared(self, unit)
Buffs.PostCreateIcon = PostCreateAura
self.Buffs = Buffs
- local Portrait = CreateFrame('PlayerModel', nil, Health)
+ local ScrollFrame = CreateFrame('ScrollFrame', nil, Health)
+ ScrollFrame:SetPoint('LEFT')
+ ScrollFrame:SetSize(230, 20)
+
+ local ScrollChild = CreateFrame('Frame')
+ ScrollChild:SetSize(ScrollFrame:GetSize())
+ ScrollFrame:SetScrollChild(ScrollChild)
+
+ local Portrait = CreateFrame('PlayerModel', nil, ScrollChild)
Portrait:SetAllPoints()
Portrait:SetAlpha(0.1)
+ Portrait.scrollFrame = ScrollFrame
self.Portrait = Portrait
- self:SetHeight(22)
+ Health.PostUpdate = PostUpdateHealth
Health:SetHeight(20)
+ self:SetHeight(22)
end
local Castbar = CreateFrame('StatusBar', nil, self)