You both missed the last argument of the ClassIcons' PostUpdate function, which tells you whether the number of bars changed. Here is what I use for reference:
Register the element:
lua Code:
local AddClassPowerIcons = function(self, width, height, spacing)
self.ClassIcons = {}
self.ClassIcons.width = width
self.ClassIcons.height = height
self.ClassIcons.spacing = spacing
local maxPower = 5
for i = 1, maxPower do
self.ClassIcons[i] = self.Overlay:CreateTexture("oUF_Rain_ComboPoint_"..i, "OVERLAY")
self.ClassIcons[i]:SetSize((width - spacing * (maxPower - 1)) / maxPower, height)
self.ClassIcons[i]:SetPoint("BOTTOMLEFT", self.Overlay, (i - 1) * self.ClassIcons[i]:GetWidth() + i * spacing, 1)
self.ClassIcons[i]:SetTexture(ns.media.TEXTURE)
end
self.ClassIcons.PostUpdate = ns.PostUpdateClassPowerIcons
end
ns.AddClassPowerIcons = AddClassPowerIcons
The PostUpdate function:
lua Code:
local PostUpdateClassPowerIcons = function(element, power, maxPower, maxPowerChanged)
if (not maxPowerChanged) then return end
local self = element.__owner
local width = element.width
local height = element.height
local spacing = element.spacing
for i = 1, maxPower do
element[i]:SetSize((width - spacing * (maxPower - 1)) / maxPower, height)
element[i]:SetPoint("BOTTOMLEFT", self.Overlay, (i - 1) * element[i]:GetWidth() + i * spacing, 1)
end
end
ns.PostUpdateClassPowerIcons = PostUpdateClassPowerIcons
Add the element to the frame appropriate unit frames:
lua Code:
if (playerClass == "DEATHKNIGHT") then
ns.AddRuneBar(self, 215, 5, 1)
ns.AddTotems(self, 60, 5)
elseif (playerClass == "DRUID") then
ns.AddEclipseBar(self, 230, 7)
ns.AddTotems(self, 30, 5)
elseif (playerClass == "HUNTER") then
ns.AddFocusHelper(self)
elseif (playerClass == "MONK") then
ns.AddClassPowerIcons(self, 215, 5, 1)
elseif (playerClass == "PALADIN") then
ns.AddClassPowerIcons(self, 215, 5, 1)
elseif (playerClass == "PRIEST") then
ns.AddClassPowerIcons(self, 215, 5, 1)
elseif (playerClass == "SHAMAN") then
ns.AddTotems(self, nil, 5)
elseif (playerClass == "WARLOCK") then
ns.AddWarlockPowerBar(self, 215, 5, 1)
end
Apart from that, adding combo points only for druid and rogue is a bad idea, as other classes can use them too when in vehicle (
Aces High! comes to mind)
EDIT: Ouch, Phanx got it right of course, I kind of have the annoying habit of reading too fast and thinking to slow. I don't think the call to ForceUpdate is needed, as oUF does this for you when it sets up the unit frame. But I would trust Phanx more than me, so you'd better check.