vrtc / chorus (public) (License: CC0) (since 2023-08-12) (hash sha1)
World of Warcraft add-on stub. The overall goal is to create a specialized raid frame.

/src/ChorusAuraTooltipFrameTemplate.lua (a1630c50c54dcded086856c481c3cd7a0a953e85) (3845 bytes) (mode 100644) (type blob)

--[[--
@submodule chorus
]]

local Chorus = Chorus

local strtrim = strtrim

local function getButtonAssociatedTooltipFrame(self)
	assert(self ~= nil)

	local p = self:GetParent()

	assert(p ~= nil, 'invalid state: aura tooltip toggle button ' ..
	'must have siblings and therefore must have a parent')

	local tooltipFrame = _G[p:GetName() .. 'AuraTooltipFrame']

	return tooltipFrame
end

--[[--
Initialize the button to toggle `ChorusAuraTooltipFrame` in restricted
environment.

When this button is clicked, it must show a frame, that contains an exhaustive
list of auras that effect the corresponding unit.

@function auraTooltipToggleButtonMain
@tparam frame self this aura tooltip toggle button
]]
local function auraTooltipToggleButtonMain(self)
	assert(self ~= nil)

	--[[ @warning For some bizzare reason, only programmatically created
	secure handlers, or secure handlers that descend from secure frames,
	define the required method of `SetFrameRef`. ]]--

	local nama = (self:GetName() or '') .. 'SecureClickHandlerFrame'

	local secureClickHandler = _G[nama] or CreateFrame('FRAME', nama, self,
	'SecureHandlerClickTemplate')

	assert(secureClickHandler ~= nil)

	local tooltipFrame = getButtonAssociatedTooltipFrame(self)
	assert(tooltipFrame ~= nil, 'invalid state: sibling aura tooltip frame must exist');

	secureClickHandler:SetFrameRef('ChorusAuraTooltipFrame', tooltipFrame);

	secureClickHandler:WrapScript(self, 'OnClick', [=[
		local tooltipFrame = self:GetFrameRef('ChorusAuraTooltipFrame')
		if not tooltipFrame then
			tooltipFrame = owner:GetFrameRef('ChorusAuraTooltipFrame')
		end
		if tooltipFrame then
			tooltipFrame:Show()
		else
			error('ChorusAuraTooltipFrameTemplate.lua: invalid state ' ..
				'could not access aura tooltip frame')
			return
		end
	]=]);

	--[[ Aura tooltip toggle button is a protected frame. It's visibility
	must be toggled with a unit watch. Most likely. ]]--

	RegisterUnitWatch(self)
end

--[[--
`ChorusAuraTooltipFrameTemplate` is *not* the familiar tooltip frame. Instead,
it is intended to conditionally show all auras on a given unit.

`ChorusAuraFrameTemplate` is intended to show only a relevant subset of auras
on a given unit at a time. Almost never all of the auras. When the need arises
for the user to read all auras on a particular unit, they click a specific
button, and it displays a detailed tooltip for all auras.
`ChorusAuraTooltipFrameTemplate` that is this module handles this tooltip.

Note that showing a frame in combat is a restricted action. This template
accounts for that and must work in combat as expected.

@function auraTooltipFrameMain
@tparam frame self this Chorus aura tooltip frame
]]
local function auraTooltipFrameMain(self)
	assert(self ~= nil)

	local n = self:GetName()
	assert(n ~= nil)
	assert('string' == type(n))
	n = strtrim(n)
	assert(string.len(n) >= 1)
	assert(string.len(n) <= 8192)

	local secureToggleHandler = _G[n .. 'SecureHandlerShowHideFrame']
	assert(secureToggleHandler ~= nil)

	local secureClickHandler = _G[n .. 'SecureHandlerClickFrame']
	assert(secureClickHandler ~= nil)

	local closeButton = _G[n .. 'CloseButton']
	assert(closeButton ~= nil)

	--[[ When button is shown, ESCAPE key press will always click this button first. ]]--
	secureToggleHandler:WrapScript(closeButton, 'OnShow', [=[
		self:SetBindingClick(true, 'ESCAPE', self)
		self:SetBindingClick(true, 'CTRL-W', self)
	]=])

	secureToggleHandler:WrapScript(closeButton, 'OnHide', [=[
		self:ClearBindings()
	]=])

	secureClickHandler:WrapScript(closeButton, 'OnClick', [=[
		local p = self:GetFrameRef('closeframe') or self:GetParent()
		if p then
			p:Hide()
		end
	]=])
end

Chorus.auraTooltipToggleButtonMain = function(...)
	return auraTooltipToggleButtonMain(...)
end

Chorus.auraTooltipFrameMain = function(...)
	return auraTooltipFrameMain(...)
end


Mode Type Size Ref File
100644 blob 35 5c40e6e2862d70b5c51c326a13073a4012ac05c7 .gitignore
100644 blob 3606 f73da473168d1897963fd2e32d89841ca0461ec0 README.adoc
040000 tree - 271296b4bafcaa151458a0192fd313641ca9b409 bin
100644 blob 228 c7dd24afa7d5c2375ff60a91c73623a304b808f9 chorus.toc
040000 tree - 99c99c3cbc641f8954a5be291e61681cb5e74629 conf
040000 tree - efa7258757edf7b888ea13c215e14b497fef8a16 doc
100644 blob 2391 1b0ca1bc25f74a34476360e5a8f14e28767b204e makefile
040000 tree - b9d3ea9d61b99ee71b5fcdbc6b18843df20c8c3c src
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/vrtc/chorus

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/vrtc/chorus

Clone this repository using git:
git clone git://git.rocketgit.com/user/vrtc/chorus

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main