diff --git a/LibDropDownMenu.lua b/LibDropDownMenu.lua index f3dd724..e7bbbdb 100644 --- a/LibDropDownMenu.lua +++ b/LibDropDownMenu.lua @@ -300,6 +300,8 @@ function UIDropDownMenuButton_OnEnter(self) end GetValueOrCallFunction(self, "funcOnEnter", self); + --self.NewFeature:Hide(); -- in retail, but why? + self.NewFeature:SetShown(self.showNewLabel); end function UIDropDownMenuButton_OnLeave(self) @@ -666,6 +668,7 @@ function UIDropDownMenu_AddButton(info, level) button.iconXOffset = info.iconXOffset; button.mouseOverIcon = info.mouseOverIcon; button.ignoreAsMenuSelection = info.ignoreAsMenuSelection; + button.showNewLabel = info.showNewLabel; if ( info.value ~= nil) then button.value = info.value; @@ -795,6 +798,7 @@ function UIDropDownMenu_AddButton(info, level) _G[listFrameName.."Button"..index.."UnCheck"]:Hide(); end button.checked = info.checked; + button.NewFeature:SetShown(button.showNewLabel); -- If has a colorswatch, show it and vertex color it local colorSwatch = _G[listFrameName.."Button"..index.."ColorSwatch"]; @@ -895,6 +899,9 @@ function UIDropDownMenu_GetButtonWidth(button) if ( button.hasArrow or button.hasColorSwatch ) then width = width + 10; end + if (button.showNewLabel) then + width = width + button.NewFeature.Label:GetUnboundedStringWidth(); + end if ( button.notCheckable ) then width = width - 30; end @@ -967,6 +974,10 @@ function UIDropDownMenu_Refresh(frame, useValue, dropdownLevel) end end + local normalText = _G[button:GetName().."NormalText"]; + button.NewFeature:SetShown(button.showNewLabel); + button.NewFeature:SetPoint("LEFT", normalText, "RIGHT", 20, 0); + if ( button:IsShown() ) then local width = UIDropDownMenu_GetButtonWidth(button); if ( width > maxWidth ) then diff --git a/LibDropDownMenuTemplates.lua b/LibDropDownMenuTemplates.lua index ceb0f88..0a1d577 100644 --- a/LibDropDownMenuTemplates.lua +++ b/LibDropDownMenuTemplates.lua @@ -104,3 +104,30 @@ ColorSwatchMixin = {} function ColorSwatchMixin:SetColor(color) self.Color:SetVertexColor(color:GetRGB()); end + +-- copied from SharedXML/NewFeatureLabel.lua; not present in classic +NewFeatureLabelMixin = {}; + +function NewFeatureLabelMixin:OnLoad() + self.BGLabel:SetText(self.label); + self.Label:SetText(self.label); + self.Label:SetJustifyH(self.justifyH); + self.BGLabel:SetJustifyH(self.justifyH); +end + +function NewFeatureLabelMixin:ClearAlert() + -- derive + self:SetShown(false); +end + +function NewFeatureLabelMixin:OnShow() + if self.animateGlow then + self.Fade:Play(); + end +end + +function NewFeatureLabelMixin:OnHide() + if self.animateGlow then + self.Fade:Stop(); + end +end diff --git a/LibDropDownMenuTemplatesCreate.lua b/LibDropDownMenuTemplatesCreate.lua index b68b354..cb46f07 100644 --- a/LibDropDownMenuTemplatesCreate.lua +++ b/LibDropDownMenuTemplatesCreate.lua @@ -3,6 +3,7 @@ local Mixin,CreateFromMixins,CreateFrame,_G = Mixin,CreateFromMixins,CreateFrame local TOOLTIP_DEFAULT_COLOR,select = TOOLTIP_DEFAULT_COLOR,select; local TOOLTIP_DEFAULT_BACKGROUND_COLOR = TOOLTIP_DEFAULT_BACKGROUND_COLOR; local NORMAL_FONT_COLOR,HIGHLIGHT_FONT_COLOR,BLACK_FONT_COLOR = NORMAL_FONT_COLOR,HIGHLIGHT_FONT_COLOR,BLACK_FONT_COLOR; +local NEW_FEATURE_SHADOW_COLOR,NEW_CAPS = NEW_FEATURE_SHADOW_COLOR,NEW_CAPS or NEW; local BackdropTemplateMixin = BackdropTemplateMixin; local GetPhysicalScreenSize = GetPhysicalScreenSize; local Round,Lerp,min,max = Round,Lerp,min,max; @@ -79,6 +80,63 @@ if not PixelUtil then -- classic compatibilty end end +local function Create_NewFeature(parent) + local NewFeature = CreateFrame("Frame",nil,parent); -- ResizeLayoutFrame template unusable + NewFeature:Hide(); + Mixin(NewFeature,NewFeatureLabelMixin); + + -- + NewFeature.animateFlow = true; + NewFeature.label = NEW_CAPS; + NewFeature.justifyH = "CENTER"; + -- + -- + -- + NewFeature.BGLabel = NewFeature:CreateFontString(nil,"OVERLAY","GameFontNormal_NoShadow",1); + NewFeature.BGLabel:SetMaxLines(1); + NewFeature.BGLabel:SetJustifyH("CENTER") + NewFeature.BGLabel:SetText(NEW_CAPS); + NewFeature.BGLabel:SetShadowColor(NEW_FEATURE_SHADOW_COLOR:GetRGBA()) + NewFeature.BGLabel:SetPoint("CENTER",0.5,-0.5) + NewFeature.Label = NewFeature:CreateFontString(nil,"OVERLAY","GameFontHighlight",1); + NewFeature.Label:SetMaxLines(1) + NewFeature.Label:SetJustifyH("CENTER") + NewFeature.Label:SetText(NEW_CAPS) + NewFeature.Label:SetShadowColor(NEW_FEATURE_SHADOW_COLOR:GetRGBA()) + NewFeature.Label:SetPoint("CENTER") + NewFeature.Glow = NewFeature:CreateTexture(nil,"OVERLAY",nil,1) + NewFeature.Glow:SetPoint("TOPLEFT",NewFeature.Label,-20,10) + NewFeature.Glow:SetPoint("BOTTOMRIGHT",NewFeature.Label,20,-10) + -- + -- + + -- + NewFeature.Fade = NewFeature:CreateAnimationGroup() + NewFeature.Fade:SetLooping("REPEAT") + local A1 = NewFeature.Fade:CreateAnimation("Alpha") + A1:SetTarget(NewFeature.Glow) + A1:SetDuration(1.0) + A1:SetOrder(1) + A1:SetFromAlpha(1) + A1:SetToAlpha(0.5) + local A2 = NewFeature.Fade:CreateAnimation("Alpha") + A2:SetTarget(NewFeature.Glow) + A2:SetDuration(1.0) + A2:SetOrder(2) + A2:SetFromAlpha(0.5) + A2:SetToAlpha(1) + -- + + -- + NewFeature:SetScript("OnShow",NewFeature.OnShow); + --NewFeature:SetScript("OnLoad",NewFeature.OnLoad); + NewFeature:SetScript("OnHide",NewFeature.OnHide); + -- + + + return NewFeature +end + -- lua replacement of UIDropDownCustomMenuEntryTemplate function Create_DropDownCustomMenuEntry(name,parent,opts) @@ -232,6 +290,14 @@ function Create_DropDownMenuButton(name,parent,opts) button.invisibleButton:SetScript("OnEnter",UIDropDownMenuButtonInvisibleButton_OnEnter); button.invisibleButton:SetScript("OnLeave",UIDropDownMenuButtonInvisibleButton_OnLeave); -- + -- + button.NewFeature = Create_NewFeature(button); + button.NewFeature:SetFrameStrata("HIGH"); + button.NewFeature:SetScale(0.8); + button.NewFeature:SetFrameLevel(100); + button.NewFeature:SetSize(1,1); + button.NewFeature:Hide(); + -- -- -- @@ -248,6 +314,8 @@ function Create_DropDownMenuButton(name,parent,opts) button:SetFontString(button.NormalText); -- + button.NewFeature:SetPoint("LEFT", button.NormalText, "RIGHT", 20, 0); + button:SetNormalFontObject("GameFontHighlightSmallLeft") button:SetHighlightFontObject("GameFontHighlightSmallLeft"); button:SetDisabledFontObject("GameFontDisableSmallLeft");