  HOW TO REGISTER CUSTOM BAR STYLERS FROM OUTSIDE BIGWIGS

If you're applying anything custom to a LibCandyBar that is
not available as a function directly on the bar (i.e. :SetIcon), you
need to reset that in your BarStopped function manually. If not, other
addons using LibCandyBar will be screwed.

You should not be creating new frames every time a bar
is spawned - you should free up unused frames when a bar is stopped,
and reuse those same frames again on the next bar.
>> The code for the "Beauty Case" style has an example of how that works. <<

Note that if you're putting your bar style in a 3rd party addon - so
that you don't have to edit BigWigs every time you update it - you
>> should follow the TOC file guide below and set the correct fields. <<

When reusing a frame it's important to re-parent it to something else
when a bar stops, and to clear all points and such. And :Hide it.

Bar style table properties;
  version
    Must be a number.
    The version of the style you're registering. If a style with the
    same identifier has already been registered, your attempt to
    re-register will be ignored if the given version is less than
    or the same as the one already registered.
  apiVersion
    Must be a number.
    Currently the BW bar style API is at version 1. If, at any point,
    the API version is incremented, any style that tries to register
    with an older version number will be automatically discarded.
  GetSpacing
    Must be a function reference or nil. The function will be invoked
    every time BW positions a bar to see how far apart it should be
    from other bars.
  ApplyStyle
    Must be a function reference or nil. Called every time a bar is
    created.
  BarStopped
    Must be a function reference or nil. Called every time a bar is
    stopped.
  GetStyleName
    Must be a function reference or nil, and return the name you want
    your bar style to have in the user interface.

The following 2 examples assume you want to create a whole separate addon
to handle skins:

========================================
==   Example MyBigWigsSkin.lua file   ==
========================================

BigWigs:GetPlugin("Bars"):RegisterBarStyle("MyBigWigsSkin", {
	apiVersion = 1,
	version = 1,
	GetSpacing = function(bar) return 4 end,
	ApplyStyle = function(bar) end,
	BarStopped = function(bar) end,
	GetStyleName = function() return "My Big Wigs Skin" end,
})

========================================
==   Example MyBigWigsSkin.toc file   ==
========================================

## Interface: 50200
## Title: MyBigWigsSkin
## Notes: My Big Wigs Skin
## Author: Me
## LoadOnDemand: 1
## Dependencies: BigWigs, BigWigs_Core, BigWigs_Plugins
## LoadWith: BigWigs_Plugins
MyBigWigsSkin.lua





The following example assumes you >>DON'T<< want to create a new addon
for skins and just want to add the code to one of your current addons:

local f = CreateFrame("Frame")
local function registerMyStyle()
	if not BigWigs then return end
	local bars = BigWigs:GetPlugin("Bars", true)
	if not bars then return end
	f:UnregisterEvent("ADDON_LOADED")
	f:UnregisterEvent("PLAYER_LOGIN")
	bars:RegisterBarStyle("identifier", {
		apiVersion = 1,
		version = 1,
		GetSpacing = function(bar) return 4 end,
		ApplyStyle = function(bar) end,
		BarStopped = function(bar) end,
		GetStyleName = function() return "My Style Name" end,
	})
end
f:RegisterEvent("ADDON_LOADED")
f:RegisterEvent("PLAYER_LOGIN")

local reason = nil
f:SetScript("OnEvent", function(self, event, msg)
	if event == "ADDON_LOADED" then
		if not reason then reason = (select(6, GetAddOnInfo("BigWigs_Plugins"))) end
		if (reason == "MISSING" and msg == "BigWigs") or msg == "BigWigs_Plugins" then
			registerMyStyle()
		end
	elseif event == "PLAYER_LOGIN" then
		registerMyStyle()
	end
end)

