-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
602 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
---@meta _ | ||
|
||
Menu = {} | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/Menu.GetManager) | ||
---@return MenuManagerProxy | ||
function Menu.GetManager() end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/Menu.CreateRootMenuDescription) | ||
---@generic M: table | ||
---@param menuMixin M | ||
---@return RootMenuDescriptionProxy|M rootMenuDescription | ||
function Menu.CreateRootMenuDescription(menuMixin) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/Menu.CreateMenuElementDescription) | ||
---@return ElementMenuDescriptionProxy | ||
function Menu.CreateMenuElementDescription() end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/Menu.PopulateDescription) | ||
---@param menuGenerator fun(ownerRegion: Region, description: RootMenuDescriptionProxy, ...) | ||
---@param ownerRegion Region | ||
---@param description RootMenuDescriptionProxy | ||
---@param ... any? # passed to the generator | ||
function Menu.PopulateDescription(menuGenerator, ownerRegion, description, ...) end | ||
|
||
---Can be used by addons to modify blizzard's menus in a taint-safe manner | ||
---[FrameXML](https://www.townlong-yak.com/framexml/go/Menu.ModifyMenu) | ||
---@param tag string | ||
---@param callback fun(ownerRegion: Region, description: RootMenuDescriptionProxy, contextData: any?) | ||
function Menu.ModifyMenu(tag, callback) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/Menu.GetOpenMenuTags) | ||
---@return string[] tags | ||
function Menu.GetOpenMenuTags() end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/Menu.PrintOpenMenuTags) | ||
function Menu.PrintOpenMenuTags() end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
---@meta _ | ||
|
||
---@alias MenuResponder fun(data: any, menuInputData: MenuInputData, menu: MenuProxy): MenuResponse # data = element:GetData() | ||
|
||
---@alias MenuDescriptionInitializer fun(frame: Frame, elementDescription: ElementMenuDescriptionProxy, menu: MenuProxy) | ||
|
||
---@class MenuInputData | ||
---@field context MenuInputContext | ||
---@field buttonName mouseButton? | ||
|
||
---@alias MenuResponse | ||
---| 1 # `MenuResponse.Open` - Menu remains open and unchanged | ||
---| 2 # `MenuResponse.Refresh` - All frames in the menu are reinitialized | ||
---| 3 # `MenuResponse.Close` - Parent menus remain open but this menu closes | ||
---| 4 # `MenuResponse.CloseAll` - All menus close | ||
|
||
---@alias MenuInputContext | ||
---| 1 # `MenuInputContext.None` | ||
---| 2 # `MenuInputContext.MouseButton` | ||
---| 3 # `MenuInputContext.MouseWheel` | ||
|
||
---@alias MenuGridDirection | ||
---| 2 # `MenuConstants.VerticalGridDirection` | ||
---| 3 # `MenuConstants.HorizontalGridDirection` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
---@meta _ | ||
|
||
MenuUtil = {} | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.TraverseMenu) | ||
---@param elementDescription RootMenuDescriptionProxy|ElementMenuDescriptionProxy | ||
---@param op fun(elementDescription: ElementMenuDescriptionProxy): boolean? # return true to stop traversal | ||
---@param condition nil|fun(elementDescription: ElementMenuDescriptionProxy): boolean # return true to apply `op` to the element description; if nil, all elements are processed | ||
---@return boolean stopped # true if the traversal was stopped by `op` returning true | ||
function MenuUtil.TraverseMenu(elementDescription, op, condition) end | ||
|
||
---Return a list of all selected elements, optionally filtered by a condition | ||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.GetSelections) | ||
---@param elementDescription RootMenuDescriptionProxy|ElementMenuDescriptionProxy | ||
---@param condition nil|fun(elementDescription: ElementMenuDescriptionProxy): boolean # return true to include the element description | ||
function MenuUtil.GetSelections(elementDescription, condition) end | ||
|
||
---Sets up a tooltip anchored to the right of the owner, applying the given function to it, and showing it | ||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.ShowTooltip) | ||
---@param owner Region | ||
---@param func fun(tooltip: GameTooltip, ...) | ||
---@param ... any? | ||
function MenuUtil.ShowTooltip(owner, func, ...) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.HideTooltip) | ||
---@param owner Region | ||
function MenuUtil.HideTooltip(owner) end | ||
|
||
---Hooks OnEnter and OnLeave for a reagion, configures a tooltip, calls the given function, and shows the tooltip | ||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.HookTooltipScripts) | ||
---@param owner Region | ||
---@param func fun(tooltip: GameTooltip) # called both in OnEnter and OnLeave | ||
function MenuUtil.HookTooltipScripts(owner, func) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.CreateRootMenuDescription) | ||
---@generic M: table | ||
---@param menuMixin M | ||
---@return RootMenuDescriptionProxy|M rootMenuDescription | ||
function MenuUtil.CreateRootMenuDescription(menuMixin) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.CreateContextMenu) | ||
---@param ownerRegion Region? # if nil, defaults to UIParent | ||
---@param generator fun(ownerRegion: Region, description: RootMenuDescriptionProxy, ...) | ||
---@param ... any? # passed to the generator | ||
---@return MenuProxy? menu | ||
function MenuUtil.CreateContextMenu(ownerRegion, generator, ...) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.SetElementText) | ||
---@param elementDescription ElementMenuDescriptionProxy | ||
---@param text string | ||
function MenuUtil.SetElementText(elementDescription, text) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.GetElementText) | ||
---@param elementDescription ElementMenuDescriptionProxy | ||
---@return string text | ||
function MenuUtil.GetElementText(elementDescription) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.CreateFrame) | ||
---@return ElementMenuDescriptionProxy | ||
function MenuUtil.CreateFrame() end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.CreateTemplate) | ||
---@param template Template | ||
---@return ElementMenuDescriptionProxy | ||
function MenuUtil.CreateTemplate(template) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.CreateTitle) | ||
---@param text string | ||
---@param color ColorMixin? # defaults to NORMAL_FONT_COLOR | ||
---@return ElementMenuDescriptionProxy | ||
function MenuUtil.CreateTitle(text, color) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.CreateButton) | ||
---@param text string | ||
---@param callback MenuResponder | ||
---@param data any? # stored as element's data | ||
---@return ElementMenuDescriptionProxy | ||
function MenuUtil.CreateButton(text, callback, data) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.CreateCheckbox) | ||
---@param text string | ||
---@param isSelected fun(data: any): boolean # data = data param -> element:GetData() | ||
---@param setSelected MenuResponder | ||
---@param data any? # stored as element's data | ||
---@return ElementMenuDescriptionProxy | ||
function MenuUtil.CreateCheckbox(text, isSelected, setSelected, data) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.CreateRadio) | ||
---@param text string | ||
---@param isSelected fun(data: any): boolean # data = data param -> element:GetData() | ||
---@param setSelected MenuResponder | ||
---@param data any? # stored as element's data | ||
---@return ElementMenuDescriptionProxy | ||
function MenuUtil.CreateRadio(text, isSelected, setSelected, data) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.CreateColorSwatch) | ||
---@param text string | ||
---@param callback MenuResponder | ||
---@param colorInfo ColorMixin # stored as element's data | ||
---@return ElementMenuDescriptionProxy | ||
function MenuUtil.CreateColorSwatch(text, callback, colorInfo) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuTemplates.CreateDivider) | ||
---@return ElementMenuDescriptionProxy # some inserters and utility functions are missing | ||
function MenuUtil.CreateDivider() end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuTemplates.CreateSpacer) | ||
---@param extend number? # height of the spacer, default = 10 | ||
---@return ElementMenuDescriptionProxy # some inserters and utility functions are missing | ||
function MenuUtil.CreateSpacer(extend) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.CreateButtonMenu) | ||
---@param dropdown DropdownButton | ||
---@param ... {[1]:string, [2]: MenuResponder, [3]: any?} # list of {text, callback, data} | ||
function MenuUtil.CreateButtonMenu(dropdown, ...) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.CreateButtonContextMenu) | ||
---@param ownerRegion Region? # if nil, defaults to UIParent | ||
---@param ... {[1]:string, [2]: MenuResponder, [3]: any?} # list of {text, callback, data} | ||
---@return MenuProxy? menu | ||
function MenuUtil.CreateButtonContextMenu(ownerRegion, ...) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.CreateCheckboxMenu) | ||
---@param dropdown DropdownButton | ||
---@param isSelected fun(data: any): boolean # shared between all menu items | ||
---@param setSelected MenuResponder # shared between all menu items | ||
---@param ... {[1]:string, [2]: any?} # list of {text, data} | ||
function MenuUtil.CreateCheckboxMenu(dropdown, isSelected, setSelected, ...) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.CreateCheckboxContextMenu) | ||
---@param ownerRegion Region? # if nil, defaults to UIParent | ||
---@param isSelected fun(data: any): boolean # shared between all menu items | ||
---@param setSelected MenuResponder # shared between all menu items | ||
---@param ... {[1]:string, [2]: any?} # list of {text, data} | ||
---@return MenuProxy? menu | ||
function MenuUtil.CreateCheckboxContextMenu(ownerRegion, isSelected, setSelected, ...) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.CreateRadioMenu) | ||
---@param dropdown DropdownButton | ||
---@param isSelected fun(data: any): boolean # shared between all menu items | ||
---@param setSelected MenuResponder # shared between all menu items | ||
---@param ... {[1]:string, [2]: any?} # list of {text, data} | ||
function MenuUtil.CreateRadioMenu(dropdown, isSelected, setSelected, ...) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.CreateRadioContextMenu) | ||
---@param ownerRegion Region? # if nil, defaults to UIParent | ||
---@param isSelected fun(data: any): boolean # shared between all menu items | ||
---@param setSelected MenuResponder # shared between all menu items | ||
---@param ... {[1]:string, [2]: any?} # list of {text, data} | ||
---@return MenuProxy? menu | ||
function MenuUtil.CreateRadioContextMenu(ownerRegion, isSelected, setSelected, ...) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.CreateEnumRadioMenu) | ||
---@generic V | ||
---@param dropdown DropdownButton | ||
---@param enum table<V> # a list of values; the value is saved as the element's data | ||
---@param enumTranslator fun(enumValue: V): string # translate the enum value into the text to display | ||
---@param isSelected fun(data: any): boolean # data = enum value | ||
---@param setSelected MenuResponder | ||
---@param orderTbl table<V, number>? # optional table to specify the order of the menu buttons, defaults to ordering by enum value | ||
function MenuUtil.CreateEnumRadioMenu(dropdown, enum, enumTranslator, isSelected, setSelected, orderTbl) end | ||
|
||
---[FrameXML](https://www.townlong-yak.com/framexml/go/MenuUtil.CreateEnumRadioContextMenu) | ||
---@generic V | ||
---@param dropdown Region? # if nil, defaults to UIParent | ||
---@param enum table<V> # a list of values; the value is saved as the element's data | ||
---@param enumTranslator fun(enumValue: V): string # translate the enum value into the text to display | ||
---@param isSelected fun(data: any): boolean # data = enum value | ||
---@param setSelected MenuResponder | ||
---@param orderTbl table<V, number>? # optional table to specify the order of the menu buttons, defaults to ordering by enum value | ||
---@return MenuProxy? menu | ||
function MenuUtil.CreateEnumRadioContextMenu(dropdown, enum, enumTranslator, isSelected, setSelected, orderTbl) end |
118 changes: 118 additions & 0 deletions
118
Annotations/Interface/Blizzard_Menu/Proxies/ElementMenuDescriptionProxy.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
---@meta _ | ||
|
||
---@class ElementMenuDescriptionProxy: SharedMenuDescriptionProxy | ||
local ElementMenuDescriptionProxy = {} | ||
|
||
function ElementMenuDescriptionProxy:SetSelectionIgnored() end | ||
|
||
---@return boolean | ||
function ElementMenuDescriptionProxy:IsSelectionIgnored() end | ||
|
||
---@param data any | ||
function ElementMenuDescriptionProxy:SetData(data) end | ||
|
||
---@return any data # from SetData or element creation | ||
function ElementMenuDescriptionProxy:GetData() end | ||
|
||
---simulates selecting/clicking a dropdown option | ||
---@param menuInputContext MenuInputContext | ||
---@param menuInputButtonName mouseButton? | ||
function ElementMenuDescriptionProxy:Pick(menuInputContext, menuInputButtonName) end | ||
|
||
---@param isEnabled boolean|fun(elementDescription: ElementMenuDescriptionProxy): boolean | ||
function ElementMenuDescriptionProxy:SetEnabled(isEnabled) end | ||
|
||
---@return boolean | ||
function ElementMenuDescriptionProxy:IsEnabled() end | ||
|
||
---@return boolean # true if a function was passed to SetEnabled() | ||
function ElementMenuDescriptionProxy:ShouldPollEnabled() end | ||
|
||
---@param onLeave fun(frame: Frame, elementDescription: ElementMenuDescriptionProxy) | ||
function ElementMenuDescriptionProxy:SetOnLeave(onLeave) end | ||
|
||
---hooks OnLeave if it exists, else calls SetOnLeave | ||
---@param onLeave fun(frame: Frame, elementDescription: ElementMenuDescriptionProxy) | ||
function ElementMenuDescriptionProxy:HookOnLeave(onLeave) end | ||
|
||
---@return nil|fun(frame: Frame, elementDescription: ElementMenuDescriptionProxy) onLeave | ||
function ElementMenuDescriptionProxy:GetOnLeave() end | ||
|
||
---@param frame Frame # frame:OnLeave(elementDescription) is called if it exists, otherwise the onLeave callback is called | ||
function ElementMenuDescriptionProxy:HandleOnLeave(frame) end | ||
|
||
---@param onEnter fun(frame: Frame, elementDescription: ElementMenuDescriptionProxy) | ||
function ElementMenuDescriptionProxy:SetOnEnter(onEnter) end | ||
|
||
---hooks OnEnter if it exists, else calls SetOnEnter | ||
---@param onEnter fun(frame: Frame, elementDescription: ElementMenuDescriptionProxy) | ||
function ElementMenuDescriptionProxy:HookOnEnter(onEnter) end | ||
|
||
---@return nil|fun(frame: Frame, elementDescription: ElementMenuDescriptionProxy) onEnter | ||
function ElementMenuDescriptionProxy:GetOnEnter() end | ||
|
||
---@param frame Frame # frame:OnEnter(elementDescription) is called if it exists, otherwise the onEnter callback is called | ||
function ElementMenuDescriptionProxy:HandleOnEnter(frame) end | ||
|
||
---@param canSelect boolean | ||
function ElementMenuDescriptionProxy:SetCanSelect(canSelect) end | ||
|
||
---@return boolean | ||
function ElementMenuDescriptionProxy:CanSelect() end | ||
|
||
---@param isSelected fun(data: any): boolean # data = element:GetData() | ||
function ElementMenuDescriptionProxy:SetIsSelected(isSelected) end | ||
|
||
---@return boolean isSelected # calls the isSelected callback with the element's data; if no callback is set, returns false | ||
function ElementMenuDescriptionProxy:IsSelected() end | ||
|
||
---@param isRadio boolean | ||
function ElementMenuDescriptionProxy:SetRadio(isRadio) end | ||
|
||
---@return boolean | ||
function ElementMenuDescriptionProxy:IsRadio() end | ||
|
||
---@param defaultResponse MenuResponse|fun(menuInputContext: MenuInputContext, menuInputButtonName: mouseButton): MenuResponse | ||
function ElementMenuDescriptionProxy:SetResponse(defaultResponse) end | ||
|
||
---@param menuInputContext MenuInputContext | ||
---@param menuInputButtonName mouseButton | ||
---@return MenuResponse | ||
function ElementMenuDescriptionProxy:GetDefaultResponse(menuInputContext, menuInputButtonName) end | ||
|
||
---@param responder MenuResponder | ||
function ElementMenuDescriptionProxy:SetResponder(responder) end | ||
|
||
---hooks responder if it exists, else calls SetResponder | ||
---@param responder MenuResponder | ||
function ElementMenuDescriptionProxy:HookResponder(responder) end | ||
|
||
function ElementMenuDescriptionProxy:SetElementFactory(callback) end | ||
|
||
---@param soundKit number|fun(elementDescription: ElementMenuDescriptionProxy): number | ||
function ElementMenuDescriptionProxy:SetSoundKit(soundKit) end | ||
|
||
---@return number soundKit | ||
function ElementMenuDescriptionProxy:GetSoundKit() end | ||
|
||
---@param canPlay boolean | ||
function ElementMenuDescriptionProxy:SetShouldPlaySoundOnSubmenuClick(canPlay) end | ||
|
||
---@return boolean | ||
function ElementMenuDescriptionProxy:ShouldPlaySoundOnSubmenuClick() end | ||
|
||
function ElementMenuDescriptionProxy:DeactivateSubmenu() end | ||
|
||
---@param canRespond boolean | ||
function ElementMenuDescriptionProxy:SetShouldRespondIfSubmenu(canRespond) end | ||
|
||
---@return boolean | ||
function ElementMenuDescriptionProxy:ShouldRespondIfSubmenu() end | ||
|
||
---@return boolean canOpenSubmenu # true if there are subItems and opening submenus isn't blocked | ||
function ElementMenuDescriptionProxy:CanOpenSubmenu() end | ||
|
||
function ElementMenuDescriptionProxy:ForceOpenSubmenu() end | ||
|
||
---@param callback fun(frame: Frame, descriptionProxy: ElementMenuDescriptionProxy, menuFrame: Frame, finalColumns: number, finalRows: number) | ||
function ElementMenuDescriptionProxy:SetFinalizeGridLayout(callback) end |
41 changes: 41 additions & 0 deletions
41
Annotations/Interface/Blizzard_Menu/Proxies/MenuManagerProxy.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
---@meta _ | ||
|
||
---@see MenuManagerProxyMixin | ||
---@class MenuManagerProxy | ||
local MenuManagerProxy = {} | ||
|
||
---@see MenuManagerProxyMixin.GetOpenMenu | ||
---@return MenuProxy? | ||
function MenuManagerProxy:GetOpenMenu() end | ||
|
||
---@see MenuManagerProxyMixin.CloseMenu | ||
---@param menu MenuProxy | ||
function MenuManagerProxy:CloseMenu(menu) end | ||
|
||
---@see MenuManagerProxyMixin.CloseMenus | ||
function MenuManagerProxy:CloseMenus() end | ||
|
||
---@see MenuManagerProxyMixin.IsAnyMenuOpen | ||
---@return boolean | ||
function MenuManagerProxy:IsAnyMenuOpen() end | ||
|
||
---@see MenuManagerProxyMixin.OpenMenu | ||
---@param ownerRegion Region | ||
---@param menuDescriptionProxy RootMenuDescriptionProxy | ||
---@param anchor AnchorMixin | ||
---@return MenuProxy? menu | ||
function MenuManagerProxy:OpenMenu(ownerRegion, menuDescriptionProxy, anchor) end | ||
|
||
---@see MenuManagerProxyMixin.OpenContextMenu | ||
---@param ownerRegion Region | ||
---@param menuDescriptionProxy RootMenuDescriptionProxy | ||
---@return MenuProxy? menu | ||
function MenuManagerProxy:OpenContextMenu(ownerRegion, menuDescriptionProxy) end | ||
|
||
---@see MenuManagerMixin.HandleESC | ||
function MenuManagerProxy:HandleESC() end | ||
|
||
---@see MenuManagerMixin.HandleGlobalMouseEvent | ||
---@param buttonName mouseButton | ||
---@param event FrameEvent | ||
function MenuManagerProxy:HandleGlobalMouseEvent(buttonName, event) end |
Oops, something went wrong.