Index: core.lua
===================================================================
--- core.lua	(revision 16072)
+++ core.lua	(working copy)
@@ -3,6 +3,8 @@
 	max = 600,
 	growth = true,
 	texture = "Glaze",
+	alertTime = 2.0,
+	alertSpells = {},
 }
 
 local surface = AceLibrary("Surface-1.0")
@@ -63,6 +65,42 @@
 				end,
 				validate = surface:List()
 			},
+			alert = {
+				name = "Alert frame", type = "group",
+				desc = "Alert frame related settings",
+				args = {
+					lock = {
+						name = "Lock", type = "toggle",
+						desc = "Lock the frame",
+						get = function() return self.db.profile.alertLocked end,
+						set = function(v) self:ToggleAlertMove(v) end,
+					},
+					add = {
+						name = "Add", type = "text",
+						desc = "Add spell you want alert for",
+						get = false, usage = "<spellname>",
+						set = function(v) self:AddAlertSpell(v) end,
+					},
+					remove = {
+						name = "Remove", type = "text",
+						desc = "Remove a spell from alert",
+						get = false, usage = "<spellname>",
+						set = function(v) self:RemoveAlertSpell(v) end,
+					},
+					list = {
+						name = "List", type = "execute",
+						desc = "Show what spells will be alerted",
+						func = function() self:ListAlertSpells() end,
+					},
+					time = {
+						name = "Show Time", type = "range",
+						desc = "How long the alert should be shown",
+						min = 1.0, max = 10, step = 0.1,
+						get = function() return self.db.profile.alertTime end,
+						set = function(v) self.db.profile.alertTime = tonumber(v) end,
+					},
+				},
+			},
 		}
 	}
 	
@@ -70,6 +108,7 @@
 	self.def = AceLibrary("Deformat-2.0")
 	
 	self:CreateFrame()
+	self:CreateAlertFrame()
 	
 	self:RegisterCandyBarGroup("oCD")
 	self:SetCandyBarGroupPoint("oCD", "TOP", self.frame, "TOP", 0, -12)
@@ -214,6 +253,9 @@
 		self:SetCandyBarFade(id, 1)
 		self:SetCandyBarTexture(id, surface:Fetch(self.db.profile.texture))
 		self:StartCandyBar(id, 1)
+		if self.db.profile.alertSpells[text] then
+			self:SetCandyBarCompletion(id, oCD.SetAlert, self, string.format("%s is ready",text));
+		end
 	end
 end
 
@@ -228,4 +270,113 @@
 		tinsert(arr, msg);
 	end
 	return arr;
-end
\ No newline at end of file
+end
+
+function oCD:CreateAlertFrame()
+	self.alertFrame = CreateFrame("Frame", "oCDAlertFrame", UIParent)
+	self.alertFrame:EnableMouse(true)
+	self.alertFrame:SetMovable(true)
+	self.alertFrame:SetWidth(800)
+	self.alertFrame:SetHeight(32)
+	self.alertFrame:ClearAllPoints()
+	self.alertFrame:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
+	self.alertFrame.text = self.alertFrame:CreateFontString("oCDAlertText","ARTWORK","ZoneTextFont")
+	self.alertFrame.text:SetPoint("TOP",0, 0)
+	self.alertFrame:SetScript("OnMouseDown",function()
+		if ( arg1 == "LeftButton" ) then
+			this:StartMoving()
+		end
+	end)
+	self.alertFrame:SetScript("OnMouseUp",function()
+		if ( arg1 == "LeftButton" ) then
+			this:StopMovingOrSizing()
+			self:SaveAlertPosition()
+		end
+	end)
+	self:UpdateAlertPositions()
+	self:ToggleAlertMove(self.db.profile.alertLocked)
+	self.alertFrame:Show()
+end
+
+function oCD:UpdateAlertPositions()
+	if(self.db.profile.alertPos) then
+		local z = self:Split(self.db.profile.alertPos, " ")
+		local s = self.alertFrame:GetEffectiveScale()
+		
+		self.alertFrame:ClearAllPoints()
+		self.alertFrame:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", z[1]/s, z[2]/s)
+	else
+		self.alertFrame:ClearAllPoints()
+		self.alertFrame:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
+	end
+end
+
+function oCD:SaveAlertPosition()
+	local x,y = self.alertFrame:GetLeft(), self.alertFrame:GetTop()
+	local s = self.alertFrame:GetEffectiveScale()
+	
+	x,y = x*s,y*s
+	
+	self.db.profile.alertPos = string.format("%s %s", x, y)
+end
+
+function oCD:ToggleAlertMove(a1)
+	self.db.profile.alertLocked = a1
+	if a1 then
+		self.alertFrame:EnableMouse(false)
+		self.alertFrame:SetBackdrop(nil)
+	else
+		self.alertFrame:EnableMouse(true)
+		self.alertFrame:SetBackdrop( { 
+			bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", 
+			edgeFile = "", tile = true, tileSize = 16, edgeSize = 16, 
+			insets = { left = 5, right = 5, top = 5, bottom = 5 }
+		})
+		self.alertFrame:SetBackdropColor(0, 0, 0, .6)
+	end
+end
+
+function oCD:AddAlertSpell(spellName)
+	self:Print("Added %s to the list of alert spells.",spellName) 
+	self.db.profile.alertSpells[spellName] = true
+end
+
+function oCD:RemoveAlertSpell(spellName)
+	if self.db.profile.alertSpells[spellName] then
+		self:Print("Removed %s from the list of alert spells.",spellName) 
+		self.db.profile.alertSpells[spellName] = nil
+	else
+		self:Print("%s is not in the list of alert spells.",spellName) 
+	end		
+end
+
+function oCD:ListAlertSpells()
+	local num = 0;
+	for name in pairs(self.db.profile.alertSpells) do
+		if num == 0 then
+			self:Print("Listing spells in the alert spells list.");
+		end
+		self:Print(name);
+		num = num + 1;
+	end
+	if num == 0 then
+		self:Print("No spells in the alert spells list.");
+	end
+end
+
+function oCD:SetAlert(message)
+	local text = self.alertFrame.text:GetText();
+	if text and text~="" then
+		text = text.."\n"..message;
+	else
+		text = message;
+	end
+	self.alertFrame.text:SetText(text);
+	self:ScheduleEvent(oCD.ClearAlert, self.db.profile.alertTime, self);
+end
+
+function oCD:ClearAlert()
+	local text = self.alertFrame.text:GetText();
+	local _,_,newText = string.find(text,".-\n(.+)")
+	self.alertFrame.text:SetText(newText);
+end
