Introduction
Notifications is an addon that does nothing by itself, but allows other addons to easily show a notification banner at the top of the screen which can display a message + the name of the addon, an icon, play a sound, animate when showing and hiding, and optionally execute a function when clicked. If no icon is provided, the default icon is shown.
If more notifications come in while one is still showing, they will be displayed one by one, so you have time to read and react to each of them.
Additionally, when you are away, these notifications are stored and shown to you as soon as you come back.
Usage
Moving the cursor over the banner prevents it from disappearing as long as the cursor is in place. Clicking it will execute the function specified by the addon upon display if present, and dismiss the banner. Right-clicking will only dismiss the banner.
Type '/testalert' to show a test notification. '/testalert true' shows a custom icon.
Examples of usage in addons is notifying you of incoming mail, calendar events, whispers while you are afk, UI messages, etc. It all depends on the people implementing it.
Options
Users can change all options at the top of notifications.lua, including appearance and animation behaviour. Explanation is added where necessary.
Developers who include Notifications in their UI can modify it in their code, allowing users to update Notifications without needing to edit the lua code. Read the 'Developer' section below for more info.
Plugins
EventNotifier - alerts you of mail, calendar events and guild events.
Bug reports
Please report all issues at my GitHub.
Developer
Showing a notification is easy. There is only one function used for this:
Notifications:Alert(message, clickFunc, texture, ...)
(string) message: message to display
(function) clickFunc (optional): function to execute on click. Set to nil when not using, but still adding a texture.
(string) texture (optional): path of a texture to use for the icon. Default icon is shown if omitted.
(numbers) ... (optional): arguments passed to SetTexCoord() for the icon; defaults to .08, .92, .08, .92 if omitted.
Your addon's name is passed automatically and does not need to be provided as a parameter.
You can also customize the behaviour and appearance of Notifications when embedded in your UI, so that users can update this addon without having to wait for you to upload a custom version.
Add Notifications as an optional dependency to your addon's ToC, and make sure it is loaded before accessing the options through Notifications.options. After your edits, call Notifications:Update() to apply the new settings.
This example code applies the Tukui style to Notifications if it is loaded.
## OptionalDeps: Notifications, Tukui
if Notifications and Tukui then
-- locally import option table references
local options = Notifications.options
local _, C = unpack(Tukui)
local borderR, borderG, borderB = unpack(C.general.bordercolor)
-- set the new values
options.bgRed, options.bgGreen, options.bgBlue = unpack(C.general.backdropcolor)
options.bgAlpha = 1
options.borderRed, options.borderGreen, options.borderBlue = borderR, borderG, borderB
options.separatorRed, options.separatorGreen, options.separatorBlue = borderR, borderG, borderB
options.inset = -1
-- call the update function
Notifications:Update()
end
If your addon supports Notifications, you can PM me or leave a comment and I'll add it to the list of supported addons.
Credits
Sound effect obtained from http://www.freesfx.co.uk
Notifications is an addon that does nothing by itself, but allows other addons to easily show a notification banner at the top of the screen which can display a message + the name of the addon, an icon, play a sound, animate when showing and hiding, and optionally execute a function when clicked. If no icon is provided, the default icon is shown.
If more notifications come in while one is still showing, they will be displayed one by one, so you have time to read and react to each of them.
Additionally, when you are away, these notifications are stored and shown to you as soon as you come back.
Usage
Moving the cursor over the banner prevents it from disappearing as long as the cursor is in place. Clicking it will execute the function specified by the addon upon display if present, and dismiss the banner. Right-clicking will only dismiss the banner.
Type '/testalert' to show a test notification. '/testalert true' shows a custom icon.
Examples of usage in addons is notifying you of incoming mail, calendar events, whispers while you are afk, UI messages, etc. It all depends on the people implementing it.
Options
Users can change all options at the top of notifications.lua, including appearance and animation behaviour. Explanation is added where necessary.
Developers who include Notifications in their UI can modify it in their code, allowing users to update Notifications without needing to edit the lua code. Read the 'Developer' section below for more info.
Plugins
EventNotifier - alerts you of mail, calendar events and guild events.
Bug reports
Please report all issues at my GitHub.
Developer
Showing a notification is easy. There is only one function used for this:
Notifications:Alert(message, clickFunc, texture, ...)
(string) message: message to display
(function) clickFunc (optional): function to execute on click. Set to nil when not using, but still adding a texture.
(string) texture (optional): path of a texture to use for the icon. Default icon is shown if omitted.
(numbers) ... (optional): arguments passed to SetTexCoord() for the icon; defaults to .08, .92, .08, .92 if omitted.
Your addon's name is passed automatically and does not need to be provided as a parameter.
You can also customize the behaviour and appearance of Notifications when embedded in your UI, so that users can update this addon without having to wait for you to upload a custom version.
Add Notifications as an optional dependency to your addon's ToC, and make sure it is loaded before accessing the options through Notifications.options. After your edits, call Notifications:Update() to apply the new settings.
This example code applies the Tukui style to Notifications if it is loaded.
## OptionalDeps: Notifications, Tukui
if Notifications and Tukui then
-- locally import option table references
local options = Notifications.options
local _, C = unpack(Tukui)
local borderR, borderG, borderB = unpack(C.general.bordercolor)
-- set the new values
options.bgRed, options.bgGreen, options.bgBlue = unpack(C.general.backdropcolor)
options.bgAlpha = 1
options.borderRed, options.borderGreen, options.borderBlue = borderR, borderG, borderB
options.separatorRed, options.separatorGreen, options.separatorBlue = borderR, borderG, borderB
options.inset = -1
-- call the update function
Notifications:Update()
end
If your addon supports Notifications, you can PM me or leave a comment and I'll add it to the list of supported addons.
Credits
Sound effect obtained from http://www.freesfx.co.uk