TitanPanelTemplate.lua
TitanPanelTemplate.lua Contains the routines to handle a frame created as a Titan plugin.
Titan templates See TitanPanelButtonTemplate.xml also.
A Titan plugin is a frame created using one of the button types in TitanPanelButtonTemplate.xml which inherits TitanPanelButtonTemplate. The available plugin types are: TitanPanelTextTemplate - A frame that only displays text ("$parentText") TitanPanelIconTemplate - A frame that only displays an icon ("$parentIcon") TitanPanelComboTemplate - A frame that displays an icon then text ("$parentIcon" "$parentText")
Most plugins use the combo template.
TitanPanelButtonTemplate.xml contains other templates available to be used. TitanOptionsSliderTemplate - A frame that contains the basics of a slider control. See TitanVolume for an example. TitanPanelChildButtonTemplate - A frame that allows a plugin within a plugin. The older version of TitanGold was an example. This may not be used anymore.
Each template contains: - a frame to handle a menu invoked by a right mouse click ("$parentRightClickMenu") - default event handlers for OnLoad: TitanPanelButton_OnLoad(self); OnShow: TitanPanelButton_OnShow(self); OnClick: TitanPanelButton_OnClick(self, button); OnEnter: TitanPanelButton_OnEnter(self); OnLeave: TitanPanelButton_OnLeave(self); If these events are overridden then the default routine needs to be included!
TitanTooltip_AddTooltipText Helper to add a line of tooltip text to the tooltip.
Inputs text - string
Outputs None
Notes - Append a "\n" to the end if there is not one already there
TitanTooltip_SetOwnerPosition Set both the parent and the position of GameTooltip for the plugin tooltip.
Inputs parent - reference to the frame to attach the tooltip to anchorPoint - tooltip anchor location (side or corner) to use relativeToFrame - string name name of the frame, usually the plugin), to attach the tooltip to relativePoint - parent anchor location (side or corner) to use xOffset - X offset from the anchor point yOffset - Y offset from the anchor point frame - reference to the tooltip
Outputs None
TitanTooltip_SetGameTooltip Helper to set the tooltip of the given Titan plugin. First check for a custom function. If no function then use the plugin tooltip title and text.
Inputs self - frame reference of the plugin
Outputs None
Notes - If a custom function is given pcall (protected call) is used in case the function errors out. Currently the error is allowed to occur silently because it could generate a lot of text to chat.
TitanTooltip_SetPanelTooltip Helper to set the screen position of the tooltip of the given Titan plugin.
Inputs self - frame reference of the plugin id - string name of the plugin frame - reference to the tooltip
Outputs None
TitanPanelButton_SetTooltip Set the tooltip of the given Titan plugin.
Inputs self - frame reference of the plugin id - string name of the plugin
TitanPanelButton_IsText Is the given Titan plugin of type text?
Inputs id - string name of the plugin
Outputs boolean
TitanPanelButton_IsIcon Is the given Titan plugin of type icon?
Inputs id - string name of the plugin
Outputs boolean
TitanPanelButton_IsCombo Is the given Titan plugin of type combo?
Inputs id - string name of the plugin
Outputs boolean
TitanPanelButton_IsCustom Is the given Titan plugin of type custom?
Inputs id - string name of the plugin
Outputs boolean
TitanPanelButton_OnDragStart Handle the OnDragStart event of the given Titan plugin.
Inputs self - frame reference of the plugin ChildButton - boolean
Outputs None
Notes - Do nothing if the user has locked plugins or if in combat. - Set the .isMoving of the plugin (frame) so other routine can check it. - Set TITAN_PANEL_MOVING so any Titan routine will know a 'drag & drop' is in progress. - Set TITAN_PANEL_MOVE_ADDON so sanity checks can be done on the 'drop'.
TitanPanelButton_OnDragStop Handle the OnDragStop event of the given Titan plugin.
Inputs self - frame reference of the plugin ChildButton - boolean
Outputs None
Notes - Clear the .isMoving of the plugin (frame). - Clear TITAN_PANEL_MOVING. - Clear TITAN_PANEL_MOVE_ADDON.
TitanTooltip_SetOwnerPosition Set both the parent and the position of GameTooltip for the plugin tooltip.
Inputs parent - reference to the frame to attach the tooltip to anchorPoint - tooltip anchor location (side or corner) to use relativeToFrame - string name name of the frame, usually the plugin), to attach the tooltip to relativePoint - parent anchor location (side or corner) to use xOffset - X offset from the anchor point yOffset - Y offset from the anchor point frame - reference to the tooltip
Outputs None
TitanOptionSlider_TooltipText Set the color of the tooltip text to normal (white) with the value in green.
Inputs text - the label for value value - the value
Outputs colored string of text and value
TitanPanelButton_OnLoad Handle the OnLoad event of the requested Titan plugin. Ensure the plugin is set to be registered.
Inputs self - the frame of the plugin isChildButton - boolean
Notes - This is called from the Titan plugin frame in the OnLoad event - usually as the frame is created. - This starts the plugin registration process. See TitanUtils for more details on plugin registration. - The plugin registration is a two step process because not all addons create Titan plugins in the frame create. The Titan feature of converting LDB addons to Titan plugins is an example.
TitanPanelPluginHandle_OnUpdate A method to refresh the display of a Titan plugin.
Inputs table - the frame of the plugin oldarg - nil or command
Notes - This is used by some plugins. It is not used within Titan. - The expected usage is either: 1) Table contains {<plugin id>, <update command>} 2) table = <plugin id> and oldarg = <update command> Update commands include: 1 = refresh button 2 = refresh tooltip 3 = refresh button and tooltip
TitanPanelDetectPluginMethod Poorly named routine that sets the OnDragStart & OnDragStop scripts of a Titan plugin.
Inputs id - the string name of the plugin isChildButton - boolean
TitanPanelButton_OnShow Handle the OnShow event of the requested Titan plugin.
Inputs self - frame reference of the plugin
TitanPanelButton_OnClick Handle the OnClick mouse event of the requested Titan plugin.
Inputs self - frame reference of the plugin button - mouse button that was clicked isChildButton - boolean
Notes - Only the left and right mouse buttons are handled by Titan.
TitanPanelButton_OnEnter Handle the OnEnter cursor event of the requested Titan plugin.
Inputs self - frame reference of the plugin isChildButton - boolean
Notes - The cursor has moved over the plugin so show the plugin tooltip. - Save same hassle by doing nothing if the tooltip is already shown or if the cursor is moving. - If the "is moving" is set the user is dragging this plugin around so do nothing here.
TitanPanelButton_OnLeave Handle the OnLeave cursor event of the requested Titan plugin.
Inputs self - frame reference of the plugin isChildButton - boolean
Notes - The cursor has moved off the plugin so hide the plugin tooltip.
TitanPanelButton_SetButtonText Set / update the text of the given Titan plugin.
Inputs id - string name of the plugin
Notes - The plugin is expected to tell Titan what routine is to be called in <self>.registry.buttonTextFunction. - The text routine is called in protected mode (pcall) to ensure the Titan main routines still run.
TitanPanelButton_SetTextButtonWidth Set the text width of the given Titan plugin that is text only.
Inputs id - string name of the plugin setButtonWidth - new width
Notes - Titan uses a tolerance setting to prevent endless updating of the text width.
TitanPanelButton_SetIconButtonWidth Set the icon width of the given Titan plugin that is icon only.
Inputs id - string name of the plugin
Notes - The plugin is expected to tell Titan what the icon width is in <self>.registry.iconButtonWidth.
TitanPanelButton_SetComboButtonWidth Set the icon width of the given Titan plugin that is a combo - icon & text.
Inputs id - string name of the plugin setButtonWidth - new width
Notes - The plugin is expected to tell Titan what the icon width is in <self>.registry.iconButtonWidth.
TitanPanelButton_UpdateButton Update the display of the given Titan plugin.
Inputs id - string name of the plugin setButtonWidth - new width
TitanPanelButton_UpdateTooltip Update the tooltip of the given Titan plugin.
Inputs self - frame reference of the plugin
TitanPanelButton_SetButtonIcon Set the icon of the given Titan plugin.
Inputs id - string name of the plugin iconCoords - if given, this is the placing of the icon within the plugin iconR - if given, this is the Red (RBG) setting of the icon iconG - if given, this is the Green (RBG) setting of the icon iconB - if given, this is the Blue (RBG) setting of the icon
TitanPanelButton_GetType Get the type of the given Titan plugin.
Inputs id - string name of the plugin
Outputs - The type of the plugin (text, icon, combo (default))
Notes - This assumes that the developer is playing nice and is using the Titan templates as is...
|