From 6d2643d709cb86dec2edd21f2d6f5c43ef761432 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Thu, 2 Jan 2025 16:54:55 +0100 Subject: [PATCH] Add frame docs --- ui/Frame.lua | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 ui/Frame.lua diff --git a/ui/Frame.lua b/ui/Frame.lua new file mode 100644 index 0000000..d09c98e --- /dev/null +++ b/ui/Frame.lua @@ -0,0 +1,56 @@ +---@meta + +---Frame is in many ways the most fundamental widget object. Other types of widget derivatives such as FontStrings, Textures and Animations can only be created attached to a Frame or other derivative of a Frame. Frames provide the basis for interaction with the user, and registering and responding to game events. +--- +---When an addon needs to respond to game events or state changes and needs no visible components, this is typically accomplished using a Frame. Visibly, widgets that display game information such as threat or cooldowns and aren't directly interactive beyond being draggable are typically Frames. They are also commonly used as ways to group other related frames, either visibly (such as the way the Talents pane groups the buttons representing your character's talents) or invisibly (such as the way MultiBarRight groups twelve action buttons). +--- +---You create a plain frame by specifying "Frame" as the first argument to CreateFrame, or with a element in an XML file: +--- +---- Create a new frame in Lua +--- +--- local self = CreateFrame("Frame", "FunWidget", UIParent) +--- +--- +--- +--- +--- +---Frames in the FrameXML include the action bars (the frames that group the action buttons together), the panels that display information like your character status and quest log, and the grand-daddy of the rest of the UI, UIParent. +---@class Frame +Frame = { + ---Sets whether the frame should automatically come to the front when clicked. When a frame with Toplevel behavior enabled is clicked, it automatically changes its frame level such that it is greater than (and therefore drawn "in front of") all other frames in its strata. + ---@param self Frame + ---@param enable boolean True to cause the frame to automatically come to the front when clicked; false otherwise + SetTopLevel = function(self, enable) end, + + ---Flags the frame for automatic saving and restoration of position and dimensions. The position and size of frames so flagged is automatically saved when the UI is shut down (as when quitting, logging out, or reloading) and restored when the UI next starts up (as when logging in or reloading). If the frame does not have a name (set at creation time) specified, its position will not be saved. As implied by its name, enabling this property is useful for frames which can be moved or resized by the user. + --- + ---This function is automatically called with the value true when frame:StartMoving() is called. + --- + ---In order for the saved position to be applied to the frame in later sessions, the frame must have been made movable with frame:SetMovable(true). + ---@param self Frame + ---@param enable boolean True to enable automatic saving and restoration of the frame's position and dimensions; false to disable + SetUserPlaced = function(self, enable) end, + + ---Begins repositioning the frame via mouse movement. + ---@param self Frame + StartMoving = function(self) end, + + ---Begins resizing the frame via mouse movement. + ---@param self Frame + StartSizing = function(self) end, + + ---Ends movement or resizing of the frame initiated with :StartMoving() or :StartSizing(). + ---@param self Frame + StopMovingOrSizing = function(self) end, + + ---Unregisters the frame from any events for which it is registered. + ---@param self Frame + UnregisterAllEvents = function(self) end, + + ---Unregisters the frame for an event. Once unregistered, the frame's OnEvent script handler will not be called for that event. + --- + ---Unregistering from notifications for an event can be useful for improving addon performance at times when it's not necessary to process the event. For example, a frame which monitors target health does not need to receive the UNIT_HEALTH event while the player has no target. An addon that sorts the contents of the player's bags can register for the BAG_UPDATE event to keep track of when items are picked up, but unregister from the event while it performs its sorting. + ---@param self Frame + ---@param event string Name of an event + UnregisterEvent = function(self, event) end +}