LibFuBarPlugin-3.0

From WowAce Wiki
Jump to: navigation, search
Summary
Lib: FuBarPlugin-3.0
A library to provide a means create a FuBar-compatible plugin.
TOC 2.4 (20400)
Category Libraries
Author ckknight
Details
Version 2.0 ision
OptionalDeps FuBar
Dependencies LibRock-1.0
Links
Betas Ace SVN Zip
Changelog FishEye

Contents

Example

ExampleFu = Rock:NewAddon("ExampleFu", "LibFuBarPlugin-3.0", "LibRockConfig-1.0")

function ExampleFu:IsValue()
    return self.value
end

function ExampleFu:ToggleValue()
    self.value = not self.value
    self:UpdateFuBarPlugin()
end

-- using LibRockConfig-1.0, this will automatically
-- open with the FuBar plugin when right-clicked.
ExampleFu:SetConfigTable({
    name = "FuBar_ExampleFu",
    desc = "An example plugin for FuBar using LibFuBarPlugin-3.0",
    type = 'group',
    args = {
        value = {
            type = 'boolean',
            name = "Value",
            desc = "Description",
            get = "IsValue",
            set = "ToggleValue",
        }
    }
})

ExampleFu.num = 0
function ExampleFu:OnUpdateFuBarText()
    self.num = self.num + 1
    self:SetFuBarText(("Num: %d"):format(self.num))
end

function ExampleFu:OnUpdateFuBarTooltip()
    GameTooltip:AddLine("ExampleFu")
    GameTooltip:AddDoubleLine("Apple", "Banana")
    GameTooltip:AddDoubleLine("Cookie", "Monster")
    
    GameTooltip:AddLine("Hint: Click to do something", 0, 1, 0)
    -- as a rule, if you have an OnFuBarClick or OnFuBarDoubleClick
    -- or OnFuBarMouseUp or OnFuBarMouseDown, you should set a hint.
end

function ExampleFu:OnFuBarClick(button)
    -- do something
end


API Documentation

Note: This documentation is auto-generated. Please note that direct modifications may be overwritten on next autogenerate. boolean

:CheckWidth([force])

Arguments

force
boolean - if true, Shrink/expand no matter what, otherwise if the width is less than 8 pixels smaller, don't shrink.

Notes

Checks the current width of the icon and text, then updates frame to expand/shrink to it if necessary.

Example

self:CheckWidth(true)

string

:CreateBasicPluginFrame([name])

Arguments

name
string - name of the frame

Returns

frame - a frame with the basic scripts to be considered a plugin frame.

Example

MyPlugin.frame = MyPlugin:CreateBasicPluginFrame("FuBar_MyPluginFrame")

string frame

:CreatePluginChildFrame("frameType" [, name] [, parent])

Arguments

"frameType"
string - type of the frame, e.g. "Frame", "Button", etc.
name
string - name of the frame
parent
frame - parent frame

Returns

frame - a child frame that can be manipulated and used

Example

local child = self:CreatePluginChildFrame("Frame", nil, self.frame)

:DetachFuBarTooltip()

Notes

  • Detaches the tooltip from the plugin.
  • This does nothing if already detached.

Example

self:DetachFuBarTooltip()

:GetCategory()

Notes

This is here for FuBar core to communicate properly.

Returns

string - category of the plugin.

Example

local category = self:GetCategory()

:GetDefaultPosition()

Notes

This is here for FuBar core to communicate properly.

Returns

string - default position of the plugin.

Example

local pos = self:GetDefaultPosition()

:GetFrame()

Notes

This is here for FuBar core to communicate properly.

Returns

frame - frame for the plugin.

Example

local frame = self:GetFrame()

:GetFuBarIcon()

Returns

string or nil - The path to the icon for the plugin. If nil, then no icon.

Example

local path = self:GetFuBarIcon()

:GetFuBarText()

Returns

string - The current text of the plugin.

Example

local text = self:GetFuBarText()

:GetName()

Notes

This is here for FuBar core to communicate properly.

Returns

string - name of the plugin.

Example

local name = self:GetName()

:GetPanel()

Notes

This is here for FuBar core to communicate properly.

Returns

object - panel for the plugin.

Example

local panel = self:GetPanel()

:GetTitle()

Returns

string - the localized name of the plugin, not including the "FuBar - " part. Example local title = self:GetTitle()


boolean

:Hide([check])

Arguments

check
boolean - internal variable. Do not set this.

Notes

Hides the plugin, disables the plugin if cannot hide without standby.

Example

self:Hide()

:HideFuBarIcon()

Notes

Hides the icon of the plugin if shown.

Example

self:HideFuBarIcon()

:HideFuBarText()

Notes

Hides the text of the plugin if shown.

Example

self:HideFuBarText()

:IsFuBarIconShown()

Returns

boolean - whether the icon for the plugin is showing.

Example

local isIconShowing = self:IsFuBarIconShown()

:IsFuBarMinimapAttached()

Returns

boolean - whether the plugin is attached to the minimap.

Example

local attached = self:IsMinimapAttached()

:IsFuBarTextColored()

Returns

boolean - whether the text has color applied.

Example

local colored = self:IsFuBarTextColored()

:IsFuBarTextShown()

Returns

boolean - whether the text for the plugin is showing.

Example

local isTextShowing = self:IsFuBarTextShown()

:IsFuBarTooltipDetached()

Returns

boolean - Whether the tooltip is detached.

Example

local detached = self:IsFuBarTooltipDetached()

:OpenMenu(frame)

Arguments

frame
type - (needs documentation)

Notes

Opens the configuration menu associated with this plugin.

Example

self:OpenMenu()

:ReattachFuBarTooltip()

Notes

Reattaches the tooltip to the plugin. This does nothing if already attached.

Example

self:ReattachFuBarTooltip()

:SetFuBarIcon(path)

Arguments

path
string or nil - The path to the icon. If nil, then no icon.

Notes

Sets the path to the icon for the plugin.

Example

self:SetFuBarIcon("Interface\\AddOns\\MyAddon\\otherIcon")

:SetFuBarOption("key" , value)

Arguments

"key"
string - the key to set
value
value - the value to set said key to.

Notes

  • Set metadata about a certain plugin.
tooltipType 
string -
"GameTooltip"
Use Blizzard's GameTooltip. (default if not given)
"Tablet-2.0"
Use Tablet-2.0.
"Custom"
LibFuBarPlugin-3.0 will not provide any extra mechanisms, all done manually.
configType 
string -
"LibRockConfig-1.0"
Use LibRockConfig-1.0 to show configuration. (default if not given)
"Dewdrop-2.0"
Use Dewdrop-2.0.
hasNoText 
boolean - If set to true, then it will be a text-less frame.
iconPath 
string - the path of the icon to show.
hasNoColor 
boolean - If set to true, then it is assumed that no color will be in the text (and thus not show the menu item)
cannotHideText 
boolean - If set to true, then the menu item to hide text will not be shown.
overrideMenu 
boolean - If set to true, then the menu will not show any of the standard menu items
hideMenuTitle 
boolean - If set to true, the plugins name will not be added to the top of the menu as a header.
defaultPosition 
string -
"LEFT"
show on the left. (default if not given)
"CENTER"
show in the center.
"RIGHT"
show on the right.
"MINIMAP"
show on the minimap.
defaultMinimapPosition 
number - Angle on the minimap, in degrees. [0, 360)
clickableTooltip 
boolean - Whether you can drag your mouse onto the tooltip and click a line
tooltipHiddenWhenEmpty 
boolean - Whether the detached tooltip is hidden when it is empty.
cannotDetachTooltip 
boolean - Whether the tooltip cannot be detached from the plugin text.
Normally, a tooltip can detach (if using Tablet-2.0). This should be set if there is no relevant data in the tooltip.
independentProfile 
boolean - If set to true, then the profile setting will not be stripped from .OnMenuRequest, and FuBar will not set the plugin's profile when it changes.
non-FuBar-centric plugins should set this to true.

Example

self:SetFuBarOption('tooltipType', "Tablet-2.0")

:SetFuBarText("text")

Arguments

"text"
string - text to set the plugin to. If not given, set to title.

Notes

Sets the text of the plugin. Should only be called from within :OnFuBarUpdateText()

Example

myAddon.OnFuBarUpdateText = function(self)
	self:SetFuBarText("Hello")
fend

:Show(panelId)

Arguments

panelId
type - (needs documentation)

Notes

Shows the plugin, enables the plugin if previously disabled, and calls :UpdateFuBarPlugin().

Example

self:Show()

:ShowFuBarIcon()

Notes

Shows the icon of the plugin if hidden.

Example

self:ShowFuBarIcon()

:ShowFuBarText()

Notes

Shows the text of the plugin if hidden.

Example

self:ShowFuBarText()

:ToggleFuBarIconShown()

Notes

Toggles whether the icon for the plugin is showing.

Example

self:ToggleFuBarIconShown()

:ToggleFuBarMinimapAttached()

Notes

Toggles whether the plugin is attached to the minimap.

Example

self:ToggleMinimapAttached()

:ToggleFuBarTextColored()

Notes

Toggles whether the text has color applied

Example

self:ToggleTextColored()

:ToggleFuBarTextShown()

Notes

Toggles whether the text for the plugin is showing.

Example

self:ToggleFuBarTextShown()

:ToggleFuBarTooltipDetached()

Notes

Toggles whether the tooltip is detached.

Example

self:ToggleFuBarTooltipDetached()

:UpdateFuBarPlugin()

Notes

Calls :UpdateFuBarText() and :UpdateFuBarTooltip(), in that order.

Example

self:UpdateFuBarPlugin()

:UpdateFuBarText()

Notes

  • Calls :OnUpdateFuBarText() if it is available and the plugin is not disabled.
  • It is expected to update the icon in :OnUpdateFuBarText as well as text.

Example

self:UpdateFuBarText()

:UpdateFuBarTooltip()

Notes

Calls :OnUpdateFuBarTooltip() if it is available, the plugin is not disabled, and the tooltip is shown.

Example

self:UpdateFuBarTooltip()