From 2910c5406022b2d79ebcf7d4c6d3380fe6506e2c Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Tue, 19 Aug 2014 19:31:46 +0200 Subject: [PATCH] Clip the portraits to match the healthbar using some ScrollFrame trickery - Thanks to @zorker for his PoC with DiscoKugel --- oUF_P3lim.lua | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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) -- 1.7.9.5