2016-10-10 19:48:47 +00:00
|
|
|
--[[customData = {
|
2019-02-10 14:12:44 +00:00
|
|
|
type = "custom",
|
|
|
|
reference = "MyAddonCustomControl", --(optional) unique name for your control to use as reference
|
|
|
|
refreshFunc = function(customControl) end, --(optional) function to call when panel/controls refresh
|
|
|
|
width = "full", --or "half" (optional)
|
|
|
|
} ]]
|
2016-10-10 19:48:47 +00:00
|
|
|
|
2019-02-10 14:12:44 +00:00
|
|
|
local widgetVersion = 7
|
2016-10-10 19:48:47 +00:00
|
|
|
local LAM = LibStub("LibAddonMenu-2.0")
|
|
|
|
if not LAM:RegisterWidget("custom", widgetVersion) then return end
|
|
|
|
|
|
|
|
local function UpdateValue(control)
|
2019-02-10 14:12:44 +00:00
|
|
|
if control.data.refreshFunc then
|
|
|
|
control.data.refreshFunc(control)
|
|
|
|
end
|
2016-10-10 19:48:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local MIN_HEIGHT = 26
|
|
|
|
function LAMCreateControl.custom(parent, customData, controlName)
|
2019-02-10 14:12:44 +00:00
|
|
|
local control = LAM.util.CreateBaseControl(parent, customData, controlName)
|
|
|
|
local width = control:GetWidth()
|
|
|
|
control:SetResizeToFitDescendents(true)
|
2016-10-10 19:48:47 +00:00
|
|
|
|
2019-02-10 14:12:44 +00:00
|
|
|
if control.isHalfWidth then --note these restrictions
|
|
|
|
control:SetDimensionConstraints(width / 2, MIN_HEIGHT, width / 2, MIN_HEIGHT * 4)
|
|
|
|
else
|
|
|
|
control:SetDimensionConstraints(width, MIN_HEIGHT, width, MIN_HEIGHT * 4)
|
|
|
|
end
|
2016-10-10 19:48:47 +00:00
|
|
|
|
2019-02-10 14:12:44 +00:00
|
|
|
control.UpdateValue = UpdateValue
|
2016-10-10 19:48:47 +00:00
|
|
|
|
2019-02-10 14:12:44 +00:00
|
|
|
LAM.util.RegisterForRefreshIfNeeded(control)
|
2016-10-10 19:48:47 +00:00
|
|
|
|
2019-02-10 14:12:44 +00:00
|
|
|
return control
|
|
|
|
end
|