Skip to content

Commit

Permalink
Merge pull request #4 from erikbrgn/reduce-text-size
Browse files Browse the repository at this point in the history
Reduce long keybinds recursively until they fit the frame
  • Loading branch information
erikbrgn authored Jan 24, 2022
2 parents 6c0212c + a69861b commit 5b4289a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions AutoHideBinds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function AHB:HookBinds()
_G[btn.."Name"].Show = ef

_G[btn]:HookScript("OnEnter", function ()
self:AdjustTextSize(_G[btn.."HotKey"])
-- :Show() has been "unbound" because it's run all the time for some reason,
-- making it impossible to hide binds. We use the alternative function to show binds.
_G[btn.."HotKey"]:SetShown(true)
Expand All @@ -44,6 +45,17 @@ function AHB:StyleBind(frame)
end
end

function AHB:AdjustTextSize(frame)
if frame:GetStringHeight() <=12 then
return
end

if frame:IsTruncated() then
frame:SetTextHeight(frame:GetStringHeight() - 2)
self:AdjustTextSize(frame)
end
end

AHBFrame:RegisterEvent("ADDON_LOADED")
AHBFrame:SetScript("OnEvent", function (self, event, ...)
local name = ...
Expand Down

0 comments on commit 5b4289a

Please sign in to comment.