Tablet-2.0
From WowAce Wiki
Tablet-2.0 is a library to provide an efficient, featureful tooltip-style display.
Example
tablet:Register(Minimap,
'children', function()
local cat = tablet:AddCategory()
cat:AddLine(
'text', "Text"
)
end
)
API Documentation
:Register(parent, ...) or (parent, otherParent)
Registers a given parent with TabletLib. Settings are initialized from the other arguments given.
Args
- parent
- Frame - parent frame to register or a filler string (a fake parent frame).
- ...
- Register Arguments.
- otherParent
- other parent to get information from.
Example
tablet:Register(Minimap,
'children', function()
local cat = tablet:AddCategory()
cat:AddLine(
'text', "Text"
)
end
)
:Unregister(parent)
Unregisters a given parent from TabletLib.
Args
- parent
- Frame - registered parent frame.
Example
tablet:Unregister(Minimap)
:IsRegistered(parent)
Returns whether a given parent is registered with TabletLib.
Args
- parent
- Frame - parent frame.
Returns
boolean - whether a given parent is registered with TabletLib.
Example
isRegged = tablet:IsRegistered(Minimap)
:Open(parent [, otherParent])
Open the tablet registered with the given parent frame.
Args
- parent
- Frame - registered parent frame.
- [otherParent]
- Frame - registered frame to use data from. (parent does not need to be registered if provided)
Remarks
You typically won't need to call this, unless you close a detached tablet and want to get it back.
Example
tablet:Open(Minimap)
:Close([parent])
Close the tablet registered with the given parent frame.
Args
- parent
- Frame - registered parent frame. If not given, it closes the currently open attached tablet.
Remarks
You typically won't need to call this, unless you want to close a detached tablet. Attached tablets close by themselves when you stop hovering.
Example
tablet:Close(Minimap)
:Refresh(parent)
Refresh the contents of a tablet.
Args
- parent
- Frame - registered parent frame.
Remarks
If the parent frame's tablet isn't open, this does nothing. Otherwise it calls the function registered as "children" in Tablet:Register().
Example
tablet:Refresh(Minimap)
:AddCategory(...)
Adds a category to the tablet.
Args
- ...
- A list of arguments to represent the data and style of the category and its children. AddCategory Arguments
Returns
table - A category object to add lines to.
Remarks
This is the initial block of all tablets. In order to add lines, they need to be located within a category.
This can only be called within the children section of the registration process.
Example
local category = tablet:AddCategory()
category:AddLine(
'text', "Text"
)
:AddLine(...)
Adds a line to a category.
Args
- ...
- A list of arguments to represent the data and style of a line. AddLine Arguments
Remarks
This can only be called on a category created by the AddCategory(...) method.
Example
local cat = tablet:AddCategory()
cat:AddLine(
'text', "Text"
)
:SetHint("text")
Set the hint of a tablet.
Args
- "text"
- string - text of the hint.
Remarks
This essentially adds a green line of text to the bottom of the tablet that says "Hint: text" where text is what you provided. This must be called within a registration statement. Hints do not show up on detached tablets.
Example
tablet:SetHint("Click for happy fun time!")
:SetTitle("text")
Set the title of a tablet.
Args
- "text"
- string - text of the title.
Remarks =
This essentially sets the text of the top line of the tablet.
This must be called within a registration statement.
Titles do not show up on detached tablets, unless there is no other text available.
Example
tablet:SetTitle("This is a title")
:SetTitleColor(r, g, b)
Set the color of the title of a tablet.
Args
- r
- number - red [0, 1]
- g
- number - green [0, 1]
- b
- number - blue [0, 1]
Remarks =
This changes the color of the title.
Example
tablet:SetTitleColor(1, 0, 1) -- fuchsia
:GetNormalFontSize()
Returns the font size of normal tablet text.
Returns
number - the font size of normal tablet text
Remarks
Use this instead of hard numbers because some font packages (such as ClearFont) may change the size.
Example
local normal = tablet:GetNormalFontSize()
:GetHeaderFontSize()
Returns the font size of header tablet text.
Returns
number - the font size of header tablet text
Remarks
Use this instead of hard numbers because some font packages (such as ClearFont) may change the size.
Example
local header = tablet:GetHeaderFontSize()
:GetNormalFontObject()
Returns the font object of normal tablet text.
Returns
Font - the font object of normal tablet text
Remarks
Use this instead of hard numbers because some font packages (such as ClearFont) may change the size/boldness/etc.
Example
local normalFont = tablet:GetNormalFontObject()
:GetHeaderFontObject()
Returns the font object of header tablet text.
Returns
Font - the font object of header tablet text
Remarks
Use this instead of hard numbers because some font packages (such as ClearFont) may change the size/boldness/etc.
Example
local headerFont = tablet:GetHeaderFontObject()
:SetFontSizePercent(parent, scale)
Sets the relative font size of the tablet.
Args
- parent
- Frame - registered parent frame.
- scale
- number - relative font size from 0.25 to 4. (25% to 400%)
Example
tablet:SetFontSizePercent(Minimap, 1)
:GetFontSizePercent(parent)
Returns the relative font size of the tablet.
Args
- parent
- Frame - registered parent frame.
Returns
number - The relative font size of the tablet.
Example
local percent = tablet:GetFontSizePercent(Minimap)
:SetTransparency(parent, alpha)
Sets the transparency of the tablet.
Args
- parent
- Frame - registered parent frame.
- alpha
- number - alpha level from 0 to 1. (clear to solid)
Example
tablet:SetTransparency(Minimap, 0.75)
:GetTransparency(parent)
Returns the transparency of the tablet.
Args
- parent
- Frame - registered parent frame.
Returns
number - The alpha level of the tablet.
Example
local percent = tablet:GetTransparency(Minimap)
:SetColor(parent, r, g, b)
Sets the color of the tablet.
Args
- parent
- Frame - registered parent frame.
- r
- number [0,1] - red value
- g
- number [0,1] - green value
- b
- number [0,1] - blue value
Example
tablet:SetColor(Minimap, 1, 1, 0) -- yellow
:GetColor(parent)
Returns the color of the tablet.
Args
- parent
- Frame - registered parent frame.
Returns
r, g, b
- r
- number [0,1] - red value
- g
- number [0,1] - green value
- b
- number [0,1] - blue value
Example
local r, g, b = tablet:GetColor(Minimap)
:Detach(parent)
Detaches a tablet, thus making it sticky.
Args
- parent
- Frame - registered parent frame.
Remarks
This will also make the tablet show.
Example
tablet:Detach(Minimap)
:Attach(parent)
Attaches a tablet back to the parent.
Args
- parent
- Frame - registered parent frame.
Example
tablet:Attach(Minimap)
:IsAttached(parent)
Returns whether the tablet is attached.
Args
- parent
- Frame - registered parent frame.
Returns
boolean - whether the tablet is attached.
Example
local isAttached = tablet:IsAttached(Minimap)
:IsLocked(parent)
Returns whether the tablet is locked.
Args
- parent
- Frame - registered parent frame.
Returns
boolean - whether the tablet is locked.
Example
local locked = tablet:IsLocked(Minimap)
:ToggleLocked(parent)
Toggles the lock status of a tablet.
Args
- parent
- Frame - registered parent frame.
Example
tablet:ToggleLocked(Minimap)
:UpdateDetachedData(parent, detachedData)
Updates the detached data of a tablet.
Args
- parent
- Frame - registered parent frame.
Example
tablet:UpdateDetachedData(Minimap, myNewData)

