Skins API - Jaliborc/BagBrother GitHub Wiki
You can create your own skins for Bagnon or Bagnonium frames.
Skins are managed through a shared API in BagBrother, registering a rule in one addon is exactly the same as on the other. However, due to their different frame designs, a skin that functions properly in one addon might not be adequate for the other. In the remainder of this page, please consider BagBrother
to correspond to either Bagnon and Bagnonium.
Basic Usage
To create a skin, all you need is to make an XML frame template:
BagBrother.Skins:Register {
id: 'MySkin',
template: 'MyXMLTemplate'
}
This template will be applied to a frame that will act as a background for the Bagnon/Bagnonium panel.
Parameters
As described, Skins:Register
has two mandatory proprieties:
Required | Type | Description |
---|---|---|
id | string (unique) | A unique identifier for your skin. It should not change and will appear in the options menu. |
template | string | Name of the xml template to use. |
Any type of skin can be achieved through the use of the template and callbacks alone. However, a few optional parameters are available as well that simplify common operations:
Optional Parameters | Type | Description |
---|---|---|
x, y, x1, y1 | numbers | Repositions the entire background frame in relation to the panel. |
cloxeX, closeY | numbers | Repositions the close button. |
font | font/string | Changes the font of the panel header. |
fontH | font/string | Changes the highlight font of the panel header. |
margin | number | Shifts exterior elements (tabs) in relation to the edges of the panel. |
inset | number | Shifts interior elements (items, bags) away from the panel edges, keeping the header unchanged. |
Callbacks
Additional functionality can be achieved through the use of callbacks. For example, if centerColor
or borderColor
are defined, the addon will allow the user to configure the corresponding colors, while load
, layout
and reset
allow you to customize the addon panel itself. The first argument passed to all callbacks is the background frame
created using your xml template.
Optional Callbacks | Description |
---|---|
centerColor(frame, r,g,b,a) | Called when the user selects a background color. If you support color selection, it should be applied here. |
borderColor(frame, r,g,b,a) | Called when the user selects a border color. |
load(frame) | Called after your skin is parented to the addon panel, allowing you to make modifications to it. |
reset(frame) | Called when your skin is unapplied to the panel. Any modifications done at load or layout should be undone here. |
layout(frame) | Called whenever the panel updates the position of its elements, allowing you to react to it or modify it. |