+local function unitUpdate(self, elapsed)
+ -- there's no in/out of range event, have to check each frame
+ -- from FrameXML/CompactUnitFrame.lua
+ local inRange, checked = UnitInRange(self.unit);
+ if checked and not inRange then
+ self:SetAlpha(0.55);
+ else
+ self:SetAlpha(1);
+ end
+end
+
+local function frameShow(frame)
+ -- events are taken from FrameXML/CompactUnitFrame.lua
+ -- TODO vehicle support, ready check support, raid marker support,
+ -- player flags support (/afk, /dnd)
+ -- TODO only update for vehicle events here
+ frame:RegisterEvent("PARTY_MEMBER_ENABLE");
+ frame:RegisterEvent("PARTY_MEMBER_DISABLE");
+ frame:RegisterUnitEvent("UNIT_HEALTH", frame.unit);
+ frame:RegisterUnitEvent("UNIT_HEALTH_FREQUENT", frame.unit);
+ frame:RegisterUnitEvent("UNIT_MAXHEALTH", frame.unit);
+ frame:RegisterUnitEvent("UNIT_POWER", frame.unit);
+ frame:RegisterUnitEvent("UNIT_MAXPOWER", frame.unit);
+ frame:RegisterUnitEvent("UNIT_DISPLAYPOWER", frame.unit);
+ frame:RegisterUnitEvent("UNIT_NAME_UPDATE", frame.unit);
+ frame:RegisterUnitEvent("UNIT_AURA", frame.unit);
+ frame:RegisterUnitEvent("UNIT_HEAL_PREDICTION", frame.unit);
+ frame:RegisterUnitEvent("UNIT_ABSORB_AMOUNT_CHANGED", frame.unit);
+ frame:RegisterUnitEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", frame.unit);
+ frame:RegisterUnitEvent("UNIT_THREAT_SITUATION_UPDATE", frame.unit);
+ frame:RegisterUnitEvent("UNIT_CONNECTION", frame.unit);
+ frame:RegisterUnitEvent("INCOMING_RESURRECT_CHANGED", frame.unit);
+ frame:SetScript("OnUpdate", unitUpdate);
+ unitEvent(frame, "UPDATE_ALL_BARS", frame.unit);
+end
+
+local function frameHide(frame)
+ frame:UnregisterAllEvents();
+ frame:SetScript("OnUpdate", nil);
+end
+