Tercio@11: Tercio@11: local DF = _G ["DetailsFramework"] Tercio@20: if (not DF or not DetailsFrameworkCanLoad) then Tercio@20: return Tercio@20: end Tercio@20: Tercio@11: local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0") Tercio@11: local _ Tercio@11: --lua locals Tercio@11: local _math_floor= math.floor Tercio@11: local _type = type Tercio@11: local _math_abs = math.abs Tercio@11: local _tinsert = tinsert Tercio@11: local _unpack = unpack Tercio@11: local _ipairs = ipairs Tercio@11: local _table_wipe = table.wipe Tercio@11: local _table_insert = table.insert Tercio@11: local _math_max = math.max Tercio@11: --api locals Tercio@11: local _GetScreenWidth = GetScreenWidth Tercio@11: local _GetScreenHeight = GetScreenHeight Tercio@11: local _UIParent = UIParent Tercio@11: local _CreateFrame = CreateFrame Tercio@11: Tercio@20: local version = 2 Tercio@11: Tercio@11: function DF:CreateCoolTip() Tercio@11: Tercio@11: ---------------------------------------------------------------------- Tercio@11: --> Cooltip Startup Tercio@11: ---------------------------------------------------------------------- Tercio@11: Tercio@55: --> if a cooltip is already created with a higher version Tercio@11: if (_G.GameCooltip2 and _G.GameCooltip2.version >= version) then Tercio@11: return Tercio@11: end Tercio@11: Tercio@55: --> initialize Tercio@55: local CoolTip = { Tercio@55: version = version Tercio@55: } Tercio@11: _G.GameCooltip2 = CoolTip Tercio@11: Tercio@55: --> containers Tercio@11: CoolTip.LeftTextTable = {} Tercio@11: CoolTip.LeftTextTableSub = {} Tercio@11: CoolTip.RightTextTable = {} Tercio@11: CoolTip.RightTextTableSub = {} Tercio@11: CoolTip.LeftIconTable = {} Tercio@11: CoolTip.LeftIconTableSub = {} Tercio@11: CoolTip.RightIconTable = {} Tercio@11: CoolTip.RightIconTableSub = {} Tercio@11: CoolTip.Banner = {false, false, false} Tercio@11: CoolTip.TopIconTableSub = {} Tercio@11: CoolTip.StatusBarTable = {} Tercio@11: CoolTip.StatusBarTableSub = {} Tercio@11: CoolTip.WallpaperTable = {} Tercio@11: CoolTip.WallpaperTableSub = {} Tercio@11: Tercio@20: CoolTip.PopupFrameTable = {} Tercio@20: Tercio@11: CoolTip.FunctionsTableMain = {} --> menus Tercio@11: CoolTip.FunctionsTableSub = {} --> menus Tercio@11: CoolTip.ParametersTableMain = {} --> menus Tercio@11: CoolTip.ParametersTableSub = {} --> menus Tercio@11: Tercio@11: CoolTip.FixedValue = nil --> menus Tercio@11: CoolTip.SelectedIndexMain = nil --> menus Tercio@11: CoolTip.SelectedIndexSec = {} --> menus Tercio@11: Tercio@11: --options table Tercio@11: CoolTip.OptionsList = { Tercioo@30: ["RightTextMargin"] = true, Tercio@11: ["IconSize"] = true, Tercio@11: ["HeightAnchorMod"] = true, Tercio@11: ["WidthAnchorMod"] = true, Tercio@11: ["MinWidth"] = true, Tercio@11: ["FixedWidth"] = true, Tercio@11: ["FixedHeight"] = true, Tercio@11: ["FixedWidthSub"] = true, Tercio@11: ["FixedHeightSub"] = true, Tercio@11: ["AlignAsBlizzTooltip"] = true, Tercio@11: ["IgnoreSubMenu"] = true, Tercio@11: ["IgnoreButtonAutoHeight"] = true, Tercio@11: ["TextHeightMod"] = true, Tercio@11: ["ButtonHeightMod"] = true, Tercio@11: ["ButtonHeightModSub"] = true, Tercio@11: ["YSpacingMod"] = true, Tercio@11: ["YSpacingModSub"] = true, Tercio@11: ["ButtonsYMod"] = true, Tercio@11: ["ButtonsYModSub"] = true, Tercio@11: ["IconHeightMod"] = true, Tercio@11: ["StatusBarHeightMod"] = true, Tercio@11: ["StatusBarTexture"] = true, Tercio@11: ["TextSize"] = true, Tercio@11: ["TextFont"] = true, Tercio@11: ["TextColor"] = true, Tercio@11: ["TextColorRight"] = true, Tercio@11: ["TextShadow"] = true, Tercio@11: ["LeftTextWidth"] = true, Tercio@11: ["RightTextWidth"] = true, Tercio@11: ["LeftTextHeight"] = true, Tercio@11: ["RightTextHeight"] = true, Tercio@11: ["NoFade"] = true, Tercio@11: ["MyAnchor"] = true, Tercio@11: ["Anchor"] = true, Tercio@11: ["RelativeAnchor"] = true, Tercio@11: ["NoLastSelectedBar"] = true, Tercio@11: ["SubMenuIsTooltip"] = true, Tercio@11: ["LeftBorderSize"] = true, Tercio@11: ["RightBorderSize"] = true, Tercio@11: ["HeighMod"] = true, Tercio@11: ["HeighModSub"] = true, Tercio@11: ["IconBlendMode"] = true, Tercio@11: ["IconBlendModeHover"] = true, Tercio@11: ["SubFollowButton"] = true, Tercio@11: ["IgnoreArrows"] = true, Tercio@11: ["SelectedTopAnchorMod"] = true, Tercio@11: ["SelectedBottomAnchorMod"] = true, Tercio@11: ["SelectedLeftAnchorMod"] = true, Tercio@11: ["SelectedRightAnchorMod"] = true, Tercio@11: } Tercio@11: Tercio@58: CoolTip.AliasList = { Tercio@58: ["VerticalOffset"] = "ButtonsYMod", Tercio@58: ["VerticalPadding"] = "YSpacingMod", Tercio@58: ["LineHeightSizeOffset"] = "ButtonHeightMod", Tercio@58: ["FrameHeightSizeOffset"] = "HeighMod", Tercio@58: Tercio@58: } Tercio@58: Tercio@11: CoolTip.OptionsTable = {} Tercio@11: Tercio@11: --cprops Tercio@11: CoolTip.Indexes = 0 --> amount of lines current on shown Tercio@11: CoolTip.IndexesSub = {} --> amount of lines current on shown Tercio@11: CoolTip.HaveSubMenu = false --> amount of lines current on shown Tercio@11: CoolTip.SubIndexes = 0 --> amount of lines current on shown on sub menu Tercio@11: CoolTip.Type = 1 --> 1 tooltip 2 tooltip with bars 3 menu 4 menu + submenus Tercio@11: CoolTip.Host = nil --> frame to anchor Tercio@11: CoolTip.LastSize = 0 --> last size Tercio@11: Tercio@11: CoolTip.LastIndex = 0 Tercio@11: Tercio@11: CoolTip.internal_x_mod = 0 Tercio@11: CoolTip.internal_y_mod = 0 Tercio@11: CoolTip.overlap_checked = false Tercio@11: Tercio@11: --defaults Tercio@11: CoolTip.default_height = 20 Tercio@11: CoolTip.default_text_size = 10.5 Tercio@11: CoolTip.default_text_font = "GameFontHighlight" Tercio@11: Tercio@11: CoolTip.selected_anchor = {} Tercio@11: CoolTip.selected_anchor.left = 2 Tercio@11: CoolTip.selected_anchor.right = 0 Tercio@11: CoolTip.selected_anchor.top = 0 Tercio@11: CoolTip.selected_anchor.bottom = 0 Tercio@11: Tercio@11: CoolTip._default_font = SharedMedia:Fetch ("font", "Friz Quadrata TT") Tercio@11: Tercio@55: --> create frames Tercio@11: Tercio@11: --> main frame Tercio@11: local frame1 Tercio@11: if (not GameCooltipFrame1) then Tercio@11: frame1 = CreateFrame ("Frame", "GameCooltipFrame1", UIParent, "DFCooltipMainFrameTemplate") Tercio@11: tinsert (UISpecialFrames, "GameCooltipFrame1") Tercio@11: DF:CreateFlashAnimation (frame1) Tercio@40: Tercio@40: if (DF.CreateBorder) then Tercio@40: DF:CreateBorder (frame1, .3, .1, .03) Tercio@40: end Tercio@11: else Tercio@11: frame1 = GameCooltipFrame1 Tercio@11: end Tercio@11: Tercio@11: GameCooltipFrame1_FrameBackgroundCenter:SetTexture (DF.folder .. "cooltip_background") Tercio@11: GameCooltipFrame1_FrameBackgroundCenter:SetTexCoord (0.10546875, 0.89453125, 0, 1) Tercio@11: GameCooltipFrame1_FrameBackgroundLeft:SetTexture (DF.folder .. "cooltip_background") Tercio@11: GameCooltipFrame1_FrameBackgroundLeft:SetTexCoord (0, 0.103515625, 0, 1) Tercio@11: GameCooltipFrame1_FrameBackgroundRight:SetTexture (DF.folder .. "cooltip_background") Tercio@11: GameCooltipFrame1_FrameBackgroundRight:SetTexCoord (0.896484375, 1, 0, 1) Tercio@11: Tercio@11: --> secondary frame Tercio@11: local frame2 Tercio@11: if (not GameCooltipFrame2) then Tercio@11: frame2 = CreateFrame ("Frame", "GameCooltipFrame2", UIParent, "DFCooltipMainFrameTemplate") Tercio@11: tinsert (UISpecialFrames, "GameCooltipFrame2") Tercio@11: DF:CreateFlashAnimation (frame2) Tercio@11: frame2:SetClampedToScreen (true) Tercio@40: Tercio@40: if (DF.CreateBorder) then Tercio@40: DF:CreateBorder (frame2, .3, .1, .03) Tercio@40: end Tercio@11: else Tercio@11: frame2 = GameCooltipFrame2 Tercio@11: end Tercio@11: Tercio@40: frame2:SetPoint ("bottomleft", frame1, "bottomright", 4, 0) Tercio@11: Tercio@11: GameCooltipFrame2_FrameBackgroundCenter:SetTexture (DF.folder .. "cooltip_background") Tercio@11: GameCooltipFrame2_FrameBackgroundCenter:SetTexCoord (0.10546875, 0.89453125, 0, 1) Tercio@11: GameCooltipFrame2_FrameBackgroundLeft:SetTexture (DF.folder .. "cooltip_background") Tercio@11: GameCooltipFrame2_FrameBackgroundLeft:SetTexCoord (0, 0.103515625, 0, 1) Tercio@11: GameCooltipFrame2_FrameBackgroundRight:SetTexture (DF.folder .. "cooltip_background") Tercio@11: GameCooltipFrame2_FrameBackgroundRight:SetTexCoord (0.896484375, 1, 0, 1) Tercio@11: Tercio@11: CoolTip.frame1 = frame1 Tercio@11: CoolTip.frame2 = frame2 Tercio@26: DF:FadeFrame (frame1, 0) Tercio@26: DF:FadeFrame (frame2, 0) Tercio@11: Tercio@55: --> line container Tercio@11: frame1.Lines = {} Tercio@11: frame2.Lines = {} Tercio@11: Tercio@11: ---------------------------------------------------------------------- Tercio@11: --> Title Function Tercio@11: ---------------------------------------------------------------------- Tercio@11: Tercio@11: function CoolTip:SetTitle (_f, text) Tercio@11: if (_f == 1) then Tercio@11: CoolTip.title1 = true Tercio@11: CoolTip.title_text = text Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: function CoolTip:SetTitleAnchor (_f, _anchor, ...) Tercio@11: _anchor = string.lower (_anchor) Tercio@11: if (_f == 1) then Tercio@11: self.frame1.titleIcon:ClearAllPoints() Tercio@11: self.frame1.titleText:ClearAllPoints() Tercio@11: Tercio@11: if (_anchor == "left") then Tercio@11: self.frame1.titleIcon:SetPoint ("left", frame1, "left", ...) Tercio@11: self.frame1.titleText:SetPoint ("left", frame1.titleIcon, "right") Tercio@11: Tercio@11: elseif (_anchor == "center") then Tercio@11: self.frame1.titleIcon:SetPoint ("center", frame1, "center") Tercio@11: self.frame1.titleIcon:SetPoint ("bottom", frame1, "top") Tercio@11: self.frame1.titleText:SetPoint ("left", frame1.titleIcon, "right") Tercio@11: self.frame1.titleText:SetText ("TESTE") Tercio@11: Tercio@11: self.frame1.titleText:Show() Tercio@11: self.frame1.titleIcon:Show() Tercio@11: Tercio@11: elseif (_anchor == "right") then Tercio@11: self.frame1.titleIcon:SetPoint ("right", frame1, "right", ...) Tercio@11: self.frame1.titleText:SetPoint ("right", frame1.titleIcon, "left") Tercio@11: Tercio@11: end Tercio@11: elseif (_f == 2) then Tercio@11: self.frame2.titleIcon:ClearAllPoints() Tercio@11: self.frame2.titleText:ClearAllPoints() Tercio@11: if (_anchor == "left") then Tercio@11: self.frame2.titleIcon:SetPoint ("left", frame2, "left", ...) Tercio@11: self.frame2.titleText:SetPoint ("left", frame2.titleIcon, "right") Tercio@11: elseif (_anchor == "center") then Tercio@11: self.frame2.titleIcon:SetPoint ("center", frame2, "center", ...) Tercio@11: self.frame2.titleText:SetPoint ("left", frame2.titleIcon, "right") Tercio@11: elseif (_anchor == "right") then Tercio@11: self.frame2.titleIcon:SetPoint ("right", frame2, "right", ...) Tercio@11: self.frame2.titleText:SetPoint ("right", frame2.titleIcon, "left") Tercio@11: end Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: ---------------------------------------------------------------------- Tercio@11: --> Button Hide and Show Functions Tercio@11: ---------------------------------------------------------------------- Tercio@11: Tercio@11: local elapsedTime = 0 Tercio@11: Tercio@11: CoolTip.mouseOver = false Tercio@11: CoolTip.buttonClicked = false Tercio@11: Tercio@11: frame1:SetScript ("OnEnter", function (self) Tercio@55: --> is cooltip a menu? Tercio@55: if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then Tercio@11: CoolTip.active = true Tercio@11: CoolTip.mouseOver = true Tercio@20: CoolTip.had_interaction = true Tercio@11: self:SetScript ("OnUpdate", nil) Tercio@26: DF:FadeFrame (self, 0) Tercio@55: Tercio@11: if (CoolTip.sub_menus) then Tercio@26: DF:FadeFrame (frame2, 0) Tercio@11: end Tercio@11: end Tercio@11: end) Tercio@11: Tercio@11: frame2:SetScript ("OnEnter", function (self) Tercio@11: if (CoolTip.OptionsTable.SubMenuIsTooltip) then Tercio@11: return CoolTip:Close() Tercio@11: end Tercio@11: if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then Tercio@11: CoolTip.active = true Tercio@11: CoolTip.mouseOver = true Tercio@20: CoolTip.had_interaction = true Tercio@11: self:SetScript ("OnUpdate", nil) Tercio@26: DF:FadeFrame (self, 0) Tercio@26: DF:FadeFrame (frame1, 0) Tercio@11: end Tercio@11: end) Tercio@11: Tercio@11: local OnLeaveUpdateFrame1 = function (self, elapsed) Tercio@11: elapsedTime = elapsedTime+elapsed Tercio@11: if (elapsedTime > 0.7) then Tercio@11: if (not CoolTip.active and not CoolTip.buttonClicked and self == CoolTip.Host) then Tercio@26: DF:FadeFrame (self, 1) Tercio@26: DF:FadeFrame (frame2, 1) Tercio@11: elseif (not CoolTip.active) then Tercio@26: DF:FadeFrame (self, 1) Tercio@26: DF:FadeFrame (frame2, 1) Tercio@11: end Tercio@11: self:SetScript ("OnUpdate", nil) Tercio@11: frame2:SetScript ("OnUpdate", nil) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: frame1:SetScript ("OnLeave", function (self) Tercio@11: Tercio@11: if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then Tercio@11: CoolTip.active = false Tercio@11: CoolTip.mouseOver = false Tercio@11: elapsedTime = 0 Tercio@11: self:SetScript ("OnUpdate", OnLeaveUpdateFrame1) Tercio@11: else Tercio@11: CoolTip.active = false Tercio@11: CoolTip.mouseOver = false Tercio@11: elapsedTime = 0 Tercio@11: self:SetScript ("OnUpdate", OnLeaveUpdateFrame1) Tercio@11: end Tercio@11: end) Tercio@11: Tercio@11: local OnLeaveUpdateFrame2 = function (self, elapsed) Tercio@11: elapsedTime = elapsedTime+elapsed Tercio@11: if (elapsedTime > 0.7) then Tercio@11: if (not CoolTip.active and not CoolTip.buttonClicked and self == CoolTip.Host) then Tercio@26: DF:FadeFrame (self, 1) Tercio@26: DF:FadeFrame (frame2, 1) Tercio@11: elseif (not CoolTip.active) then Tercio@26: DF:FadeFrame (self, 1) Tercio@26: DF:FadeFrame (frame2, 1) Tercio@11: end Tercio@11: self:SetScript ("OnUpdate", nil) Tercio@11: frame1:SetScript ("OnUpdate", nil) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: frame2:SetScript ("OnLeave", function (self) Tercio@11: if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then Tercio@11: CoolTip.active = false Tercio@11: CoolTip.mouseOver = false Tercio@11: elapsedTime = 0 Tercio@11: self:SetScript ("OnUpdate", OnLeaveUpdateFrame2) Tercio@11: else Tercio@11: CoolTip.active = false Tercio@11: CoolTip.mouseOver = false Tercio@11: elapsedTime = 0 Tercio@11: self:SetScript ("OnUpdate", OnLeaveUpdateFrame2) Tercio@11: Tercio@11: end Tercio@11: end) Tercio@53: Tercio@11: frame1:SetScript ("OnHide", function (self) Tercio@11: CoolTip.active = false Tercio@11: CoolTip.buttonClicked = false Tercio@11: CoolTip.mouseOver = false Tercio@53: Tercio@53: --> reset parent and strata Tercio@53: frame1:SetParent (UIParent) Tercio@53: frame2:SetParent (UIParent) Tercio@53: frame1:SetFrameStrata ("TOOLTIP") Tercio@53: frame2:SetFrameStrata ("TOOLTIP") Tercio@11: end) Tercio@53: Tercio@11: ---------------------------------------------------------------------- Tercio@11: --> Button Creation Functions Tercio@11: ---------------------------------------------------------------------- Tercio@11: Tercio@11: function GameCooltipButtonMouseDown (button) Tercio@11: local mod = CoolTip.OptionsTable.TextHeightMod or 0 Tercio@11: button.leftText:SetPoint ("center", button.leftIcon, "center", 0, 0+mod) Tercio@11: button.leftText:SetPoint ("left", button.leftIcon, "right", 4, -1+mod) Tercio@11: end Tercio@11: Tercio@11: function GameCooltipButtonMouseUp (button) Tercio@11: local mod = CoolTip.OptionsTable.TextHeightMod or 0 Tercio@11: button.leftText:SetPoint ("center", button.leftIcon, "center", 0, 0+mod) Tercio@11: button.leftText:SetPoint ("left", button.leftIcon, "right", 3, 0+mod) Tercio@11: end Tercio@11: Tercio@11: function CoolTip:CreateButton (index, frame, name) Tercio@11: local new_button = CreateFrame ("Button", name, frame, "DFCooltipButtonTemplate") Tercio@11: frame.Lines [index] = new_button Tercio@11: return new_button Tercio@11: end Tercio@11: Tercio@11: local OnEnterUpdateButton = function (self, elapsed) Tercio@55: elapsedTime = elapsedTime+elapsed Tercio@55: if (elapsedTime > 0.001) then Tercio@55: --> search key: ~onenterupdatemain Tercio@55: CoolTip:ShowSub (self.index) Tercio@55: CoolTip.last_button = self.index Tercio@55: self:SetScript ("OnUpdate", nil) Tercio@55: end Tercio@55: end Tercio@55: Tercio@11: local OnLeaveUpdateButton = function (self, elapsed) Tercio@55: elapsedTime = elapsedTime+elapsed Tercio@55: if (elapsedTime > 0.7) then Tercio@55: if (not CoolTip.active and not CoolTip.buttonClicked) then Tercio@55: DF:FadeFrame (frame1, 1) Tercio@55: DF:FadeFrame (frame2, 1) Tercio@55: Tercio@55: elseif (not CoolTip.active) then Tercio@55: DF:FadeFrame (frame1, 1) Tercio@55: DF:FadeFrame (frame2, 1) Tercio@55: end Tercio@55: frame1:SetScript ("OnUpdate", nil) Tercio@55: end Tercio@55: end Tercio@55: Tercio@55: local OnEnterMainButton = function (self) Tercio@55: if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not self.isDiv) then Tercio@55: CoolTip.active = true Tercio@55: CoolTip.mouseOver = true Tercio@55: CoolTip.had_interaction = true Tercio@55: Tercio@55: frame1:SetScript ("OnUpdate", nil) Tercio@55: frame2:SetScript ("OnUpdate", nil) Tercio@55: Tercio@55: self.background:Show() Tercio@55: Tercio@55: if (CoolTip.OptionsTable.IconBlendModeHover) then Tercio@55: self.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendModeHover) Tercio@55: else Tercio@55: self.leftIcon:SetBlendMode ("BLEND") Tercio@55: end Tercio@55: Tercio@55: if (CoolTip.PopupFrameTable [self.index]) then Tercio@55: local on_enter, on_leave, param1, param2 = unpack (CoolTip.PopupFrameTable [self.index]) Tercio@55: if (on_enter) then Tercio@55: xpcall (on_enter, geterrorhandler(), frame1, param1, param2) Tercio@55: end Tercio@55: Tercio@55: elseif (CoolTip.IndexesSub [self.index] and CoolTip.IndexesSub [self.index] > 0) then Tercio@55: if (CoolTip.OptionsTable.SubMenuIsTooltip) then Tercio@55: CoolTip:ShowSub (self.index) Tercio@55: self.index = self.ID Tercio@55: else Tercio@55: if (CoolTip.last_button) then Tercio@55: CoolTip:ShowSub (CoolTip.last_button) Tercio@55: else Tercio@55: CoolTip:ShowSub (self.index) Tercio@55: end Tercio@55: elapsedTime = 0 Tercio@55: self.index = self.ID Tercio@55: self:SetScript ("OnUpdate", OnEnterUpdateButton) Tercio@55: end Tercio@55: Tercio@55: else Tercio@55: --hide second frame Tercio@55: DF:FadeFrame (frame2, 1) Tercio@55: CoolTip.last_button = nil Tercio@55: end Tercio@55: else Tercio@55: CoolTip.mouseOver = true Tercio@55: CoolTip.had_interaction = true Tercio@55: end Tercio@55: end Tercio@55: Tercio@55: local OnLeaveMainButton = function (self) Tercio@55: if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not self.isDiv) then Tercio@55: CoolTip.active = false Tercio@55: CoolTip.mouseOver = false Tercio@55: self:SetScript ("OnUpdate", nil) Tercio@55: Tercio@55: self.background:Hide() Tercio@55: Tercio@55: if (CoolTip.OptionsTable.IconBlendMode) then Tercio@55: self.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode) Tercio@55: self.rightIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode) Tercio@55: else Tercio@55: self.leftIcon:SetBlendMode ("BLEND") Tercio@55: self.rightIcon:SetBlendMode ("BLEND") Tercio@55: end Tercio@55: Tercio@55: if (CoolTip.PopupFrameTable [self.index]) then Tercio@55: local on_enter, on_leave, param1, param2 = unpack (CoolTip.PopupFrameTable [self.index]) Tercio@55: if (on_leave) then Tercio@55: xpcall (on_leave, geterrorhandler(), frame1, param1, param2) Tercio@55: end Tercio@55: end Tercio@55: Tercio@55: elapsedTime = 0 Tercio@55: frame1:SetScript ("OnUpdate", OnLeaveUpdateButton) Tercio@55: else Tercio@55: CoolTip.active = false Tercio@55: elapsedTime = 0 Tercio@55: frame1:SetScript ("OnUpdate", OnLeaveUpdateButton) Tercio@55: CoolTip.mouseOver = false Tercio@55: end Tercio@55: end Tercio@11: Tercio@11: function CoolTip:NewMainButton (i) Tercio@55: local newButton = CoolTip:CreateButton (i, frame1, "GameCooltipMainButton"..i) Tercio@11: Tercio@11: --> serach key: ~onenter Tercio@55: newButton.ID = i Tercio@55: newButton:SetScript ("OnEnter", OnEnterMainButton) Tercio@55: newButton:SetScript ("OnLeave", OnLeaveMainButton) Tercio@11: Tercio@55: return newButton Tercio@11: end Tercio@11: Tercio@55: --> buttons for the secondary frame Tercio@55: Tercio@11: local OnLeaveUpdateButtonSec = function (self, elapsed) Tercio@55: elapsedTime = elapsedTime+elapsed Tercio@55: if (elapsedTime > 0.7) then Tercio@55: if (not CoolTip.active and not CoolTip.buttonClicked) then Tercio@55: DF:FadeFrame (frame1, 1) Tercio@55: DF:FadeFrame (frame2, 1) Tercio@55: elseif (not CoolTip.active) then Tercio@55: DF:FadeFrame (frame1, 1) Tercio@55: DF:FadeFrame (frame2, 1) Tercio@55: end Tercio@55: frame2:SetScript ("OnUpdate", nil) Tercio@55: end Tercio@55: end Tercio@55: Tercio@55: local OnEnterSecondaryButton = function (self) Tercio@55: if (CoolTip.OptionsTable.SubMenuIsTooltip) then Tercio@55: return CoolTip:Close() Tercio@55: end Tercio@55: if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not self.isDiv) then Tercio@55: CoolTip.active = true Tercio@55: CoolTip.mouseOver = true Tercio@55: CoolTip.had_interaction = true Tercio@55: Tercio@55: self.background:Show() Tercio@55: Tercio@55: if (CoolTip.OptionsTable.IconBlendModeHover) then Tercio@55: self.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendModeHover) Tercio@55: else Tercio@55: self.leftIcon:SetBlendMode ("BLEND") Tercio@55: end Tercio@55: Tercio@55: frame1:SetScript ("OnUpdate", nil) Tercio@55: frame2:SetScript ("OnUpdate", nil) Tercio@55: Tercio@55: DF:FadeFrame (frame1, 0) Tercio@55: DF:FadeFrame (frame2, 0) Tercio@55: else Tercio@55: CoolTip.mouseOver = true Tercio@55: CoolTip.had_interaction = true Tercio@55: end Tercio@55: end Tercio@55: Tercio@55: local OnLeaveSecondaryButton = function (self) Tercio@55: if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then Tercio@55: CoolTip.active = false Tercio@55: CoolTip.mouseOver = false Tercio@55: Tercio@55: self.background:Hide() Tercio@55: Tercio@55: if (CoolTip.OptionsTable.IconBlendMode) then Tercio@55: self.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode) Tercio@55: self.rightIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode) Tercio@55: else Tercio@55: self.leftIcon:SetBlendMode ("BLEND") Tercio@55: self.rightIcon:SetBlendMode ("BLEND") Tercio@55: end Tercio@55: Tercio@55: elapsedTime = 0 Tercio@55: frame2:SetScript ("OnUpdate", OnLeaveUpdateButtonSec) Tercio@55: else Tercio@55: CoolTip.active = false Tercio@55: CoolTip.mouseOver = false Tercio@55: elapsedTime = 0 Tercio@55: frame2:SetScript ("OnUpdate", OnLeaveUpdateButtonSec) Tercio@55: end Tercio@55: end Tercio@11: Tercio@11: function CoolTip:NewSecondaryButton (i) Tercio@55: local newButton = CoolTip:CreateButton (i, frame2, "GameCooltipSecButton"..i) Tercio@11: Tercio@55: newButton.ID = i Tercio@55: newButton:SetScript ("OnEnter", OnEnterSecondaryButton) Tercio@55: newButton:SetScript ("OnLeave", OnLeaveSecondaryButton) Tercio@11: Tercio@55: return newButton Tercio@11: end Tercio@11: Tercio@11: ---------------------------------------------------------------------- Tercio@11: --> Button Click Functions Tercio@11: ---------------------------------------------------------------------- Tercio@11: Tercio@11: CoolTip.selected_anchor.left = 4 Tercio@11: CoolTip.selected_anchor.right = -4 Tercio@11: CoolTip.selected_anchor.top = 0 Tercio@11: CoolTip.selected_anchor.bottom = 0 Tercio@11: Tercio@11: function CoolTip:HideSelectedTexture (frame) Tercio@11: frame.selectedTop:Hide() Tercio@11: frame.selectedBottom:Hide() Tercio@11: frame.selectedMiddle:Hide() Tercio@11: end Tercio@11: Tercio@11: function CoolTip:ShowSelectedTexture (frame) Tercio@11: frame.selectedTop:Show() Tercio@11: frame.selectedBottom:Show() Tercio@11: frame.selectedMiddle:Show() Tercio@11: end Tercio@11: Tercio@11: function CoolTip:SetSelectedAnchor (frame, button) Tercio@11: Tercio@11: local left = CoolTip.selected_anchor.left + (CoolTip.OptionsTable.SelectedLeftAnchorMod or 0) Tercio@11: local right = CoolTip.selected_anchor.right + (CoolTip.OptionsTable.SelectedRightAnchorMod or 0) Tercio@11: Tercio@11: local top = CoolTip.selected_anchor.top + (CoolTip.OptionsTable.SelectedTopAnchorMod or 0) Tercio@11: local bottom = CoolTip.selected_anchor.bottom + (CoolTip.OptionsTable.SelectedBottomAnchorMod or 0) Tercio@11: Tercio@11: frame.selectedTop:ClearAllPoints() Tercio@11: frame.selectedBottom:ClearAllPoints() Tercio@11: Tercio@40: frame.selectedTop:SetPoint ("topleft", button, "topleft", left+1, top) -- Tercio@40: frame.selectedTop:SetPoint ("topright", button, "topright", right-1, top) -- Tercio@11: Tercio@40: frame.selectedBottom:SetPoint ("bottomleft", button, "bottomleft", left+1, bottom) -- Tercio@40: frame.selectedBottom:SetPoint ("bottomright", button, "bottomright", right-1, bottom) -- Tercio@11: Tercio@11: CoolTip:ShowSelectedTexture (frame) Tercio@11: end Tercio@11: Tercio@55: local OnClickFunctionMainButton = function (self, button) Tercio@55: if (CoolTip.IndexesSub [self.index] and CoolTip.IndexesSub [self.index] > 0) then Tercio@55: CoolTip:ShowSub (self.index) Tercio@55: CoolTip.last_button = self.index Tercio@55: end Tercio@55: Tercio@55: CoolTip.buttonClicked = true Tercio@55: CoolTip:SetSelectedAnchor (frame1, self) Tercio@55: Tercio@55: if (not CoolTip.OptionsTable.NoLastSelectedBar) then Tercio@55: CoolTip:ShowSelectedTexture (frame1) Tercio@55: end Tercio@55: CoolTip.SelectedIndexMain = self.index Tercio@55: Tercio@55: if (CoolTip.FunctionsTableMain [self.index]) then Tercio@55: local parameterTable = CoolTip.ParametersTableMain [self.index] Tercio@55: local func = CoolTip.FunctionsTableMain [self.index] Tercio@55: --> passing nil as the first parameter was a design mistake Tercio@55: --CoolTip.FunctionsTableMain [self.index] (_, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3], button) Tercio@55: local okay, errortext = pcall (func, nil, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3], button) Tercio@55: if (not okay) then Tercio@55: print ("Cooltip OnClick Error:", errortext) Tercio@11: end Tercio@55: end Tercio@55: end Tercio@55: Tercio@55: local OnClickFunctionSecondaryButton = function (self, button) Tercio@55: CoolTip.buttonClicked = true Tercio@55: Tercio@55: CoolTip:SetSelectedAnchor (frame2, self) Tercio@55: Tercio@55: if (CoolTip.FunctionsTableSub [self.mainIndex] and CoolTip.FunctionsTableSub [self.mainIndex] [self.index]) then Tercio@55: local parameterTable = CoolTip.ParametersTableSub [self.mainIndex] [self.index] Tercio@55: local func = CoolTip.FunctionsTableSub [self.mainIndex] [self.index] Tercio@55: --CoolTip.FunctionsTableSub [self.mainIndex] [self.index] (_, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3], button) Tercio@55: local okay, errortext = pcall (func, nil, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3], button) Tercio@55: if (not okay) then Tercio@55: print ("Cooltip OnClick Error:", errortext) Tercio@55: end Tercio@55: end Tercio@55: Tercio@55: local botao_p = frame1.Lines [self.mainIndex] Tercio@55: CoolTip:SetSelectedAnchor (frame1, botao_p) Tercio@11: Tercio@55: if (not CoolTip.OptionsTable.NoLastSelectedBar) then Tercio@55: CoolTip:ShowSelectedTexture (frame1) Tercio@55: end Tercio@55: Tercio@55: CoolTip.SelectedIndexMain = self.mainIndex Tercio@55: CoolTip.SelectedIndexSec [self.mainIndex] = self.index Tercio@55: end Tercio@55: Tercio@55: Tercio@55: --> format functions Tercio@11: Tercio@11: function CoolTip:TextAndIcon (index, frame, menuButton, leftTextTable, rightTextTable, leftIconTable, rightIconTable, isSub) Tercio@11: --> reset width Tercio@11: menuButton.leftText:SetWidth (0) Tercio@11: menuButton.leftText:SetHeight (0) Tercio@11: menuButton.rightText:SetWidth (0) Tercio@11: menuButton.rightText:SetHeight (0) Tercio@11: Tercioo@30: menuButton.rightText:SetPoint ("right", menuButton.rightIcon, "left", CoolTip.OptionsTable.RightTextMargin or -3, 0) Tercioo@30: Tercio@11: --> set text Tercio@11: if (leftTextTable) then Tercio@11: Tercio@11: menuButton.leftText:SetText (leftTextTable [1]) Tercio@11: Tercio@11: local r, g, b, a = leftTextTable [2], leftTextTable [3], leftTextTable [4], leftTextTable [5] Tercio@11: Tercio@11: if (r == 0 and g == 0 and b == 0 and a == 0) then Tercio@11: if (CoolTip.OptionsTable.TextColor) then Tercio@11: r, g, b, a = DF:ParseColors (CoolTip.OptionsTable.TextColor) Tercio@11: menuButton.leftText:SetTextColor (r, g, b, a) Tercio@11: else Tercio@11: menuButton.leftText:SetTextColor (1, 1, 1, 1) Tercio@11: end Tercio@11: else Tercio@11: menuButton.leftText:SetTextColor (r, g, b, a) Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.OptionsTable.TextSize and not leftTextTable [6]) then Tercio@11: DF:SetFontSize (menuButton.leftText, CoolTip.OptionsTable.TextSize) Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.OptionsTable.LeftTextWidth) then Tercio@11: menuButton.leftText:SetWidth (CoolTip.OptionsTable.LeftTextWidth) Tercio@11: else Tercio@11: menuButton.leftText:SetWidth (0) Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.OptionsTable.LeftTextHeight) then Tercio@11: menuButton.leftText:SetHeight (CoolTip.OptionsTable.LeftTextHeight) Tercio@11: else Tercio@11: menuButton.leftText:SetHeight (0) Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.OptionsTable.TextFont and not leftTextTable [7]) then --font Tercio@11: Tercio@11: if (_G [CoolTip.OptionsTable.TextFont]) then Tercio@11: menuButton.leftText:SetFontObject (GameFontRed or CoolTip.OptionsTable.TextFont) Tercio@11: else Tercio@11: local font = SharedMedia:Fetch ("font", CoolTip.OptionsTable.TextFont) Tercio@11: local _, size, flags = menuButton.leftText:GetFont() Tercio@11: flags = leftTextTable [8] or CoolTip.OptionsTable.TextShadow or nil Tercio@11: size = leftTextTable [6] or CoolTip.OptionsTable.TextSize or size Tercio@11: menuButton.leftText:SetFont (font, size, flags) Tercio@11: end Tercio@11: Tercio@11: elseif (leftTextTable [7]) then Tercio@11: if (_G [leftTextTable [7]]) then Tercio@11: menuButton.leftText:SetFontObject (leftTextTable [7]) Tercio@11: local face, size, flags = menuButton.leftText:GetFont() Tercio@11: flags = leftTextTable [8] or CoolTip.OptionsTable.TextShadow or nil Tercio@11: size = leftTextTable [6] or CoolTip.OptionsTable.TextSize or size Tercio@11: menuButton.leftText:SetFont (face, size, flags) Tercio@11: else Tercio@11: local font = SharedMedia:Fetch ("font", leftTextTable [7]) Tercio@11: local face, size, flags = menuButton.leftText:GetFont() Tercio@11: flags = leftTextTable [8] or CoolTip.OptionsTable.TextShadow or nil Tercio@11: size = leftTextTable [6] or CoolTip.OptionsTable.TextSize or size Tercio@11: menuButton.leftText:SetFont (face, size, flags) Tercio@11: end Tercio@11: else Tercio@11: menuButton.leftText:SetFont (CoolTip._default_font, leftTextTable [6] or CoolTip.OptionsTable.TextSize or 10, leftTextTable [8] or CoolTip.OptionsTable.TextShadow) Tercio@11: end Tercio@11: Tercio@11: local height_mod = CoolTip.OptionsTable.TextHeightMod or 0 Tercio@11: menuButton.leftText:SetPoint ("center", menuButton.leftIcon, "center", 0, 0+height_mod) Tercio@11: menuButton.leftText:SetPoint ("left", menuButton.leftIcon, "right", 3, 0+height_mod) Tercio@11: Tercio@11: else Tercio@11: menuButton.leftText:SetText ("") Tercio@11: end Tercio@11: Tercio@11: if (rightTextTable) then Tercio@11: menuButton.rightText:SetText (rightTextTable [1]) Tercio@11: Tercio@11: local r, g, b, a = rightTextTable [2], rightTextTable [3], rightTextTable [4], rightTextTable [5] Tercio@11: Tercio@11: if (r == 0 and g == 0 and b == 0 and a == 0) then Tercio@11: Tercio@11: if (CoolTip.OptionsTable.TextColorRight) then Tercio@11: r, g, b, a = DF:ParseColors (CoolTip.OptionsTable.TextColorRight) Tercio@11: menuButton.rightText:SetTextColor (r, g, b, a) Tercio@11: elseif (CoolTip.OptionsTable.TextColor) then Tercio@11: r, g, b, a = DF:ParseColors (CoolTip.OptionsTable.TextColor) Tercio@11: menuButton.rightText:SetTextColor (r, g, b, a) Tercio@11: else Tercio@11: menuButton.rightText:SetTextColor (1, 1, 1, 1) Tercio@11: end Tercio@11: else Tercio@11: menuButton.rightText:SetTextColor (r, g, b, a) Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.OptionsTable.TextSize and not rightTextTable [6]) then Tercio@11: DF:SetFontSize (menuButton.rightText, CoolTip.OptionsTable.TextSize) Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.OptionsTable.RightTextWidth) then Tercio@11: menuButton.rightText:SetWidth (CoolTip.OptionsTable.RightTextWidth) Tercio@11: else Tercio@11: menuButton.rightText:SetWidth (0) Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.OptionsTable.TextFont and not rightTextTable [7]) then Tercio@11: if (_G [CoolTip.OptionsTable.TextFont]) then Tercio@11: menuButton.rightText:SetFontObject (CoolTip.OptionsTable.TextFont) Tercio@11: else Tercio@11: local font = SharedMedia:Fetch ("font", CoolTip.OptionsTable.TextFont) Tercio@11: local _, size, flags = menuButton.rightText:GetFont() Tercio@11: flags = rightTextTable [8] or CoolTip.OptionsTable.TextShadow or nil Tercio@11: size = rightTextTable [6] or CoolTip.OptionsTable.TextSize or size Tercio@11: menuButton.rightText:SetFont (font, size, flags) Tercio@11: end Tercio@11: Tercio@11: elseif (rightTextTable [7]) then Tercio@11: if (_G [rightTextTable [7]]) then Tercio@11: menuButton.rightText:SetFontObject (rightTextTable [7]) Tercio@11: local face, size, flags = menuButton.rightText:GetFont() Tercio@11: flags = rightTextTable [8] or CoolTip.OptionsTable.TextShadow or nil Tercio@11: size = rightTextTable [6] or CoolTip.OptionsTable.TextSize or size Tercio@11: menuButton.rightText:SetFont (face, size, flags) Tercio@11: else Tercio@11: local font = SharedMedia:Fetch ("font", rightTextTable [7]) Tercio@11: local face, size, flags = menuButton.rightText:GetFont() Tercio@11: flags = rightTextTable [8] or CoolTip.OptionsTable.TextShadow or nil Tercio@11: size = rightTextTable [6] or CoolTip.OptionsTable.TextSize or size Tercio@11: menuButton.rightText:SetFont (face, size, flags) Tercio@11: end Tercio@11: Tercio@11: else Tercio@11: menuButton.rightText:SetFont (CoolTip._default_font, rightTextTable [6] or CoolTip.OptionsTable.TextSize or 10, rightTextTable [8] or CoolTip.OptionsTable.TextShadow) Tercio@11: end Tercio@11: Tercio@11: Tercio@11: else Tercio@11: menuButton.rightText:SetText ("") Tercio@11: end Tercio@11: Tercio@11: --> left icon Tercio@11: if (leftIconTable and leftIconTable [1]) then Tercio@11: menuButton.leftIcon:SetTexture (leftIconTable [1]) Tercio@11: menuButton.leftIcon:SetWidth (leftIconTable [2]) Tercio@11: menuButton.leftIcon:SetHeight (leftIconTable [3]) Tercio@11: menuButton.leftIcon:SetTexCoord (leftIconTable [4], leftIconTable [5], leftIconTable [6], leftIconTable [7]) Tercio@11: Tercio@11: local ColorR, ColorG, ColorB, ColorA = DF:ParseColors (leftIconTable [8]) Tercio@11: menuButton.leftIcon:SetVertexColor (ColorR, ColorG, ColorB, ColorA) Tercio@11: Tercio@11: if (CoolTip.OptionsTable.IconBlendMode) then Tercio@11: menuButton.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode) Tercio@11: else Tercio@11: menuButton.leftIcon:SetBlendMode ("BLEND") Tercio@11: end Tercio@11: Tercio@11: menuButton.leftIcon:SetDesaturated (leftIconTable [9]) Tercio@11: else Tercio@11: menuButton.leftIcon:SetTexture (nil) Tercio@11: menuButton.leftIcon:SetWidth (1) Tercio@11: menuButton.leftIcon:SetHeight (1) Tercio@11: end Tercio@11: Tercio@11: --> right icon Tercio@11: if (rightIconTable and rightIconTable [1]) then Tercio@11: menuButton.rightIcon:SetTexture (rightIconTable [1]) Tercio@11: menuButton.rightIcon:SetWidth (rightIconTable [2]) Tercio@11: menuButton.rightIcon:SetHeight (rightIconTable [3]) Tercio@11: menuButton.rightIcon:SetTexCoord (rightIconTable [4], rightIconTable [5], rightIconTable [6], rightIconTable [7]) Tercio@11: Tercio@11: local ColorR, ColorG, ColorB, ColorA = DF:ParseColors (rightIconTable [8]) Tercio@11: menuButton.rightIcon:SetVertexColor (ColorR, ColorG, ColorB, ColorA) Tercio@11: Tercio@11: if (CoolTip.OptionsTable.IconBlendMode) then Tercio@11: menuButton.rightIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode) Tercio@11: else Tercio@11: menuButton.rightIcon:SetBlendMode ("BLEND") Tercio@11: end Tercio@11: Tercio@11: menuButton.rightIcon:SetDesaturated (rightIconTable [9]) Tercio@11: else Tercio@11: menuButton.rightIcon:SetTexture (nil) Tercio@11: menuButton.rightIcon:SetWidth (1) Tercio@11: menuButton.rightIcon:SetHeight (1) Tercio@11: end Tercio@11: Tercio@11: --> overwrite icon size Tercio@11: if (CoolTip.OptionsTable.IconSize) then Tercio@11: menuButton.leftIcon:SetWidth (CoolTip.OptionsTable.IconSize) Tercio@11: menuButton.leftIcon:SetHeight (CoolTip.OptionsTable.IconSize) Tercio@11: menuButton.rightIcon:SetWidth (CoolTip.OptionsTable.IconSize) Tercio@11: menuButton.rightIcon:SetHeight (CoolTip.OptionsTable.IconSize) Tercio@11: end Tercio@11: Tercio@40: menuButton.leftText:SetHeight (0) Tercio@40: menuButton.rightText:SetHeight (0) Tercio@40: Tercio@11: if (CoolTip.Type == 2) then Tercio@11: CoolTip:LeftTextSpace (menuButton) Tercio@11: end Tercio@40: if (CoolTip.OptionsTable.LeftTextHeight) then Tercio@40: menuButton.leftText:SetHeight (CoolTip.OptionsTable.LeftTextHeight) Tercio@40: end Tercio@40: if (CoolTip.OptionsTable.RightTextHeight) then Tercio@40: menuButton.rightText:SetHeight (CoolTip.OptionsTable.RightTextHeight) Tercio@40: end Tercio@11: Tercio@11: --> string length Tercio@11: if (not isSub) then --> main frame Tercio@11: if (not CoolTip.OptionsTable.FixedWidth) then Tercio@11: if (CoolTip.Type == 1 or CoolTip.Type == 2) then Tercio@11: local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth() + 10 Tercio@11: if (stringWidth > frame.w) then Tercio@11: frame.w = stringWidth Tercio@11: end Tercio@11: end Tercio@11: else Tercio@40: menuButton.leftText:SetWidth (CoolTip.OptionsTable.FixedWidth - menuButton.leftIcon:GetWidth() - menuButton.rightText:GetStringWidth() - menuButton.rightIcon:GetWidth() - 22) Tercio@11: end Tercio@11: else Tercio@11: if (not CoolTip.OptionsTable.FixedWidthSub) then Tercio@11: if (CoolTip.Type == 1 or CoolTip.Type == 2) then Tercio@11: local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth() Tercio@11: if (stringWidth > frame.w) then Tercio@11: frame.w = stringWidth Tercio@11: end Tercio@11: end Tercio@11: else Tercio@40: menuButton.leftText:SetWidth (CoolTip.OptionsTable.FixedWidthSub - menuButton.leftIcon:GetWidth() - 12) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: local height = _math_max ( menuButton.leftIcon:GetHeight(), menuButton.rightIcon:GetHeight(), menuButton.leftText:GetStringHeight(), menuButton.rightText:GetStringHeight() ) Tercio@11: if (height > frame.hHeight) then Tercio@11: frame.hHeight = height Tercio@11: end Tercio@11: Tercio@11: end Tercio@11: Tercio@11: function CoolTip:RefreshSpark (menuButton) Tercio@11: menuButton.spark:ClearAllPoints() Tercio@45: menuButton.spark:SetPoint ("LEFT", menuButton.statusbar, "LEFT", (menuButton.statusbar:GetValue() * (menuButton.statusbar:GetWidth() / 100)) - 5, 0) Tercio@11: menuButton.spark2:ClearAllPoints() Tercio@11: menuButton.spark2:SetPoint ("left", menuButton.statusbar, "left", menuButton.statusbar:GetValue() * (menuButton.statusbar:GetWidth()/100) - 16, 0) Tercio@11: end Tercio@11: Tercio@11: function CoolTip:StatusBar (menuButton, StatusBar) Tercioo@29: Tercio@11: if (StatusBar) then Tercio@11: Tercio@11: menuButton.statusbar:SetValue (StatusBar [1]) Tercio@11: menuButton.statusbar:SetStatusBarColor (StatusBar [2], StatusBar [3], StatusBar [4], StatusBar [5]) Tercio@11: menuButton.statusbar:SetHeight (20 + (CoolTip.OptionsTable.StatusBarHeightMod or 0)) Tercio@11: Tercio@11: menuButton.spark2:Hide() Tercio@11: if (StatusBar [6]) then Tercio@11: menuButton.spark:Show() Tercio@11: --menuButton.spark:ClearAllPoints() Tercio@11: --menuButton.spark:SetPoint ("LEFT", menuButton.statusbar, "LEFT", (StatusBar [1] * (menuButton.statusbar:GetWidth() / 100)) - 3, 0) Tercio@11: else Tercio@11: menuButton.spark:Hide() Tercio@11: end Tercio@11: Tercio@11: if (StatusBar [7]) then Tercio@11: menuButton.statusbar2:SetValue (StatusBar[7].value) Tercio@11: menuButton.statusbar2.texture:SetTexture (StatusBar[7].texture or [[Interface\RaidFrame\Raid-Bar-Hp-Fill]]) Tercio@11: if (StatusBar[7].specialSpark) then Tercio@11: menuButton.spark2:Show() Tercio@11: end Tercio@11: if (StatusBar[7].color) then Tercio@11: local ColorR, ColorG, ColorB, ColorA = DF:ParseColors (StatusBar[7].color) Tercio@11: menuButton.statusbar2:SetStatusBarColor (ColorR, ColorG, ColorB, ColorA) Tercio@11: else Tercio@11: menuButton.statusbar2:SetStatusBarColor (1, 1, 1, 1) Tercio@11: end Tercio@11: else Tercio@11: menuButton.statusbar2:SetValue (0) Tercio@11: menuButton.spark2:Hide() Tercio@11: end Tercio@11: Tercioo@29: if (StatusBar [8]) then Tercioo@29: local texture = SharedMedia:Fetch ("statusbar", StatusBar [8], true) Tercioo@29: if (texture) then Tercioo@29: menuButton.statusbar.texture:SetTexture (texture) Tercioo@29: else Tercioo@29: menuButton.statusbar.texture:SetTexture (StatusBar [8]) Tercioo@29: end Tercioo@29: elseif (CoolTip.OptionsTable.StatusBarTexture) then Tercioo@29: local texture = SharedMedia:Fetch ("statusbar", CoolTip.OptionsTable.StatusBarTexture, true) Tercioo@29: if (texture) then Tercioo@29: menuButton.statusbar.texture:SetTexture (texture) Tercioo@29: else Tercioo@29: menuButton.statusbar.texture:SetTexture (CoolTip.OptionsTable.StatusBarTexture) Tercioo@29: end Tercioo@29: else Tercioo@29: menuButton.statusbar.texture:SetTexture ("Interface\\PaperDollInfoFrame\\UI-Character-Skills-Bar") Tercioo@29: end Tercioo@29: Tercioo@29: --[[ Tercio@11: if (CoolTip.OptionsTable.StatusBarTexture) then Tercio@11: menuButton.statusbar.texture:SetTexture (CoolTip.OptionsTable.StatusBarTexture) Tercio@11: else Tercio@11: menuButton.statusbar.texture:SetTexture ("Interface\\PaperDollInfoFrame\\UI-Character-Skills-Bar") Tercio@11: end Tercioo@29: --]] Tercio@11: else Tercio@11: menuButton.statusbar:SetValue (0) Tercio@11: menuButton.statusbar2:SetValue (0) Tercio@11: menuButton.spark:Hide() Tercio@11: menuButton.spark2:Hide() Tercio@11: end Tercioo@29: Tercio@11: if (CoolTip.OptionsTable.LeftBorderSize) then Tercio@11: menuButton.statusbar:SetPoint ("left", menuButton, "left", 10 + CoolTip.OptionsTable.LeftBorderSize, 0) Tercio@11: else Tercio@11: menuButton.statusbar:SetPoint ("left", menuButton, "left", 10, 0) Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.OptionsTable.RightBorderSize) then Tercio@11: menuButton.statusbar:SetPoint ("right", menuButton, "right", CoolTip.OptionsTable.RightBorderSize + (- 10), 0) Tercio@11: else Tercio@11: menuButton.statusbar:SetPoint ("right", menuButton, "right", -10, 0) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: function CoolTip:SetupMainButton (menuButton, index) Tercio@11: menuButton.index = index Tercio@11: Tercio@11: --> setup texts and icons Tercio@11: CoolTip:TextAndIcon (index, frame1, menuButton, CoolTip.LeftTextTable [index], CoolTip.RightTextTable [index], CoolTip.LeftIconTable [index], CoolTip.RightIconTable [index]) Tercio@11: --> setup statusbar Tercio@11: CoolTip:StatusBar (menuButton, CoolTip.StatusBarTable [index]) Tercio@11: Tercio@11: --> click Tercio@11: menuButton:RegisterForClicks ("LeftButtonDown") Tercio@11: Tercio@11: --> string length Tercio@11: if (not CoolTip.OptionsTable.FixedWidth) then Tercio@11: local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth() Tercio@11: if (stringWidth > frame1.w) then Tercio@11: frame1.w = stringWidth Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: --> register click function Tercio@55: menuButton:SetScript ("OnClick", OnClickFunctionMainButton) Tercio@11: menuButton:Show() Tercio@11: end Tercio@11: Tercio@11: function CoolTip:SetupSecondaryButton (menuButton, index, mainMenuIndex) Tercio@11: Tercio@11: menuButton.index = index Tercio@11: menuButton.mainIndex = mainMenuIndex Tercio@11: Tercio@11: --> setup texts and icons Tercio@11: CoolTip:TextAndIcon (index, frame2, menuButton, CoolTip.LeftTextTableSub [mainMenuIndex] and CoolTip.LeftTextTableSub [mainMenuIndex] [index], Tercio@11: CoolTip.RightTextTableSub [mainMenuIndex] and CoolTip.RightTextTableSub [mainMenuIndex] [index], Tercio@11: CoolTip.LeftIconTableSub [mainMenuIndex] and CoolTip.LeftIconTableSub [mainMenuIndex] [index], Tercio@11: CoolTip.RightIconTableSub [mainMenuIndex] and CoolTip.RightIconTableSub [mainMenuIndex] [index], true) Tercio@11: --> setup statusbar Tercio@11: CoolTip:StatusBar (menuButton, CoolTip.StatusBarTableSub [mainMenuIndex] and CoolTip.StatusBarTableSub [mainMenuIndex] [index]) Tercio@11: Tercio@11: --> click Tercio@11: menuButton:RegisterForClicks ("LeftButtonDown") Tercio@11: Tercio@11: menuButton:ClearAllPoints() Tercio@11: menuButton:SetPoint ("center", frame2, "center") Tercio@11: menuButton:SetPoint ("top", frame2, "top", 0, (((index-1)*20)*-1)-3) Tercio@40: menuButton:SetPoint ("left", frame2, "left", -4, 0) Tercio@40: menuButton:SetPoint ("right", frame2, "right", 4, 0) Tercio@11: Tercio@26: DF:FadeFrame (menuButton, 0) Tercio@11: Tercio@11: --> string length Tercio@11: local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth() Tercio@11: if (stringWidth > frame2.w) then Tercio@11: frame2.w = stringWidth Tercio@11: end Tercio@11: Tercio@55: menuButton:SetScript ("OnClick", OnClickFunctionSecondaryButton) Tercio@11: menuButton:Show() Tercio@11: Tercio@11: return true Tercio@11: end Tercio@11: Tercio@11: -- -- -------------------------------------------------------------------------------------------------------------- Tercio@11: Tercio@11: function CoolTip:SetupWallpaper (wallpaperTable, wallpaper) Tercio@11: local texture = wallpaperTable [1] Tercio@11: if (DF:IsHtmlColor (texture) or type (texture) == "table") then Tercio@11: local r, g, b, a = DF:ParseColors (texture) Tercio@11: wallpaper:SetTexture (r, g, b, a) Tercio@11: else Tercio@11: wallpaper:SetTexture (texture) Tercio@11: end Tercio@11: Tercio@11: wallpaper:SetTexCoord (wallpaperTable[2], wallpaperTable[3], wallpaperTable[4], wallpaperTable[5]) Tercio@11: Tercio@11: local color = wallpaperTable[6] Tercio@11: if (color) then Tercio@11: local r, g, b, a = DF:ParseColors (color) Tercio@11: wallpaper:SetVertexColor (r, g, b, a) Tercio@11: else Tercio@11: wallpaper:SetVertexColor (1, 1, 1, 1) Tercio@11: end Tercio@11: Tercio@11: if (wallpaperTable[7]) then Tercio@11: wallpaper:SetDesaturated (true) Tercio@11: else Tercio@11: wallpaper:SetDesaturated (false) Tercio@11: end Tercio@11: Tercio@11: wallpaper:Show() Tercio@11: end Tercio@11: Tercio@11: -- -- -------------------------------------------------------------------------------------------------------------- Tercio@11: Tercio@11: function CoolTip:ShowSub (index) Tercio@11: Tercio@11: if (CoolTip.OptionsTable.IgnoreSubMenu) then Tercio@26: DF:FadeFrame (frame2, 1) Tercio@11: return Tercio@11: end Tercio@11: Tercio@11: frame2:SetHeight (6) Tercio@11: Tercio@11: local amtIndexes = CoolTip.IndexesSub [index] Tercio@11: if (not amtIndexes) then Tercio@11: --print ("Sub menu called but sub menu indexes is nil") Tercio@11: return Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.OptionsTable.FixedWidthSub) then Tercio@11: frame2:SetWidth (CoolTip.OptionsTable.FixedWidthSub) Tercio@11: end Tercio@11: Tercio@11: frame2.h = CoolTip.IndexesSub [index] * 20 Tercio@11: frame2.hHeight = 0 Tercio@11: frame2.w = 0 Tercio@11: Tercio@11: --> pegar a fontsize da label principal Tercio@11: local mainButton = frame1.Lines [index] Tercio@11: local fontSize = DF:GetFontSize (mainButton.leftText) Tercio@11: Tercio@11: local GotChecked = false Tercio@11: Tercio@11: local IsTooltip = CoolTip.OptionsTable.SubMenuIsTooltip Tercio@11: if (IsTooltip) then Tercio@11: frame2:EnableMouse (false) Tercio@11: else Tercio@11: frame2:EnableMouse (true) Tercio@11: end Tercio@11: Tercio@11: for i = 1, CoolTip.IndexesSub [index] do Tercio@11: Tercio@11: local button = frame2.Lines [i] Tercio@11: Tercio@11: if (not button) then Tercio@11: button = CoolTip:NewSecondaryButton (i) Tercio@11: end Tercio@11: Tercio@11: local checked = CoolTip:SetupSecondaryButton (button, i, index) Tercio@11: if (checked) then Tercio@11: GotChecked = true Tercio@11: end Tercio@11: Tercio@11: if (IsTooltip) then Tercio@11: button:EnableMouse (false) Tercio@11: else Tercio@11: button:EnableMouse (true) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: local selected = CoolTip.SelectedIndexSec [index] Tercio@11: if (selected) then Tercio@11: Tercio@11: CoolTip:SetSelectedAnchor (frame2, frame2.Lines [selected]) Tercio@11: Tercio@11: if (not CoolTip.OptionsTable.NoLastSelectedBar) then Tercio@11: CoolTip:ShowSelectedTexture (frame2) Tercio@11: end Tercio@11: else Tercio@11: CoolTip:HideSelectedTexture (frame2) Tercio@11: end Tercio@11: Tercio@11: for i = CoolTip.IndexesSub [index] + 1, #frame2.Lines do Tercio@26: DF:FadeFrame (frame2.Lines[i], 1) Tercio@11: end Tercio@11: Tercio@11: local spacing = 0 Tercio@11: if (CoolTip.OptionsTable.YSpacingModSub) then Tercio@11: spacing = CoolTip.OptionsTable.YSpacingModSub Tercio@11: end Tercio@11: Tercio@11: --> normalize height of all rows Tercio@11: for i = 1, CoolTip.IndexesSub [index] do Tercio@11: Tercio@11: local menuButton = frame2.Lines [i] Tercio@11: Tercio@11: -- CoolTipFrame2.Lines [2].divbar Tercio@11: Tercio@11: if (menuButton.leftText:GetText() == "$div") then Tercio@11: Tercio@11: --> height Tercio@11: menuButton:SetHeight (4) Tercio@11: Tercio@11: --> points Tercio@11: menuButton:ClearAllPoints() Tercio@11: Tercio@11: menuButton:SetPoint ("center", frame2, "center") Tercio@40: menuButton:SetPoint ("left", frame2, "left", -4, 0) Tercio@40: menuButton:SetPoint ("right", frame2, "right", 4, 0) Tercio@11: Tercio@11: menuButton.rightText:SetText ("") Tercio@11: Tercio@11: local div_size_up = tonumber (CoolTip.RightTextTableSub [index] [i] [2]) Tercio@11: if (not div_size_up) then Tercio@11: div_size_up = 0 Tercio@11: end Tercio@11: local div_size_down = tonumber (CoolTip.RightTextTableSub [index] [i] [3]) Tercio@11: if (not div_size_down) then Tercio@11: div_size_down = 0 Tercio@11: end Tercio@11: Tercio@11: menuButton:SetPoint ("top", frame2, "top", 0, ( ( (i-1) * frame2.hHeight) * -1) - 4 + (CoolTip.OptionsTable.ButtonsYModSub or 0) + spacing + (2 + (div_size_up or 0))) Tercio@11: Tercio@11: if (CoolTip.OptionsTable.YSpacingModSub) then Tercio@11: spacing = spacing + CoolTip.OptionsTable.YSpacingModSub Tercio@11: end Tercio@11: Tercio@11: spacing = spacing + 17 + (div_size_down or 0) Tercio@11: Tercio@11: menuButton.leftText:SetText ("") Tercio@11: menuButton.isDiv = true Tercio@11: Tercio@11: if (not menuButton.divbar) then Tercio@11: CoolTip:CreateDivBar (menuButton) Tercio@11: else Tercio@11: menuButton.divbar:Show() Tercio@11: end Tercio@11: Tercio@11: menuButton.divbar:SetPoint ("left", menuButton, "left", frame1:GetWidth()*0.10, 0) Tercio@11: menuButton.divbar:SetPoint ("right", menuButton, "right", -frame1:GetWidth()*0.10, 0) Tercio@11: Tercio@11: else Tercio@11: --> height Tercio@11: menuButton:SetHeight (frame2.hHeight + (CoolTip.OptionsTable.ButtonHeightModSub or 0)) Tercio@11: --> points Tercio@11: menuButton:ClearAllPoints() Tercio@11: menuButton:SetPoint ("center", frame2, "center") Tercio@11: menuButton:SetPoint ("top", frame2, "top", 0, ( ( (i-1) * frame2.hHeight) * -1) - 4 + (CoolTip.OptionsTable.ButtonsYModSub or 0) + spacing) Tercio@11: if (CoolTip.OptionsTable.YSpacingModSub) then Tercio@11: spacing = spacing + CoolTip.OptionsTable.YSpacingModSub Tercio@11: end Tercio@40: menuButton:SetPoint ("left", frame2, "left", -4, 0) Tercio@40: menuButton:SetPoint ("right", frame2, "right", 4, 0) Tercio@11: Tercio@11: if (menuButton.divbar) then Tercio@11: menuButton.divbar:Hide() Tercio@11: menuButton.isDiv = false Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: end Tercio@11: Tercio@11: local mod = CoolTip.OptionsTable.HeighModSub or 0 Tercio@11: frame2:SetHeight ( (frame2.hHeight * CoolTip.IndexesSub [index]) + 12 + (-spacing) + mod) Tercio@11: Tercio@11: if (CoolTip.TopIconTableSub [index]) then Tercio@11: local upperImageTable = CoolTip.TopIconTableSub [index] Tercio@11: frame2.upperImage:SetTexture (upperImageTable [1]) Tercio@11: frame2.upperImage:SetWidth (upperImageTable [2]) Tercio@11: frame2.upperImage:SetHeight (upperImageTable [3]) Tercio@11: frame2.upperImage:SetTexCoord (upperImageTable[4], upperImageTable[5], upperImageTable[6], upperImageTable[7]) Tercio@11: frame2.upperImage:Show() Tercio@11: else Tercio@11: frame2.upperImage:Hide() Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.WallpaperTableSub [index]) then Tercio@11: CoolTip:SetupWallpaper (CoolTip.WallpaperTableSub [index], frame2.frameWallpaper) Tercio@11: else Tercio@11: frame2.frameWallpaper:Hide() Tercio@11: end Tercio@11: Tercio@11: if (not CoolTip.OptionsTable.FixedWidthSub) then Tercio@11: frame2:SetWidth (frame2.w + 44) Tercio@11: end Tercio@11: Tercio@26: DF:FadeFrame (frame2, 0) Tercio@11: Tercio@11: CoolTip:CheckOverlap() Tercio@11: Tercio@11: if (CoolTip.OptionsTable.SubFollowButton and not CoolTip.frame2_leftside) then Tercio@11: Tercio@11: local button = frame1.Lines [index] Tercio@11: Tercio@11: frame2:ClearAllPoints() Tercio@40: frame2:SetPoint ("left", button, "right", 4, 0) Tercio@11: Tercio@11: elseif (CoolTip.OptionsTable.SubFollowButton and CoolTip.frame2_leftside) then Tercio@11: Tercio@11: local button = frame1.Lines [index] Tercio@11: Tercio@11: frame2:ClearAllPoints() Tercio@40: frame2:SetPoint ("right", button, "left", -4, 0) Tercio@11: Tercio@11: elseif (CoolTip.frame2_leftside) then Tercio@11: frame2:ClearAllPoints() Tercio@40: frame2:SetPoint ("bottomright", frame1, "bottomleft", -4, 0) Tercio@11: else Tercio@11: frame2:ClearAllPoints() Tercio@40: frame2:SetPoint ("bottomleft", frame1, "bottomright", 4, 0) Tercio@11: end Tercio@11: Tercio@11: end Tercio@11: Tercio@11: function CoolTip:HideSub() Tercio@26: DF:FadeFrame (frame2, 1) Tercio@11: end Tercio@11: Tercio@11: Tercio@11: function CoolTip:LeftTextSpace (row) Tercio@11: row.leftText:SetWidth (row:GetWidth() - 30 - row.leftIcon:GetWidth() - row.rightIcon:GetWidth() - row.rightText:GetStringWidth()) Tercio@11: row.leftText:SetHeight (10) Tercio@11: end Tercio@11: Tercio@26: --> ~inicio ~start ~tooltip Tercio@11: function CoolTip:monta_tooltip() Tercio@11: Tercio@11: --> hide sub frame Tercio@26: DF:FadeFrame (frame2, 1) Tercio@11: --> hide select bar Tercio@11: CoolTip:HideSelectedTexture (frame1) Tercio@11: Tercio@11: frame1:EnableMouse (false) Tercio@11: Tercio@11: --> elevator Tercio@11: local yDown = 5 Tercio@11: --> width Tercio@11: if (CoolTip.OptionsTable.FixedWidth) then Tercio@11: frame1:SetWidth (CoolTip.OptionsTable.FixedWidth) Tercio@11: end Tercio@11: Tercio@11: frame1.w = CoolTip.OptionsTable.FixedWidth or 0 Tercio@11: frame1.hHeight = 0 Tercio@11: frame2.hHeight = 0 Tercio@11: Tercio@11: CoolTip.active = true Tercio@11: Tercio@11: for i = 1, CoolTip.Indexes do Tercio@11: Tercio@11: local button = frame1.Lines [i] Tercio@11: if (not button) then Tercio@11: button = CoolTip:NewMainButton (i) Tercio@11: end Tercio@11: Tercio@11: button.index = i Tercio@11: Tercio@11: --> basic stuff Tercio@11: button:Show() Tercio@11: button.background:Hide() Tercio@11: button:SetHeight (CoolTip.OptionsTable.ButtonHeightMod or CoolTip.default_height) Tercio@11: button:RegisterForClicks() Tercio@11: Tercio@11: --> setup texts and icons Tercio@11: CoolTip:TextAndIcon (i, frame1, button, CoolTip.LeftTextTable [i], CoolTip.RightTextTable [i], CoolTip.LeftIconTable [i], CoolTip.RightIconTable [i]) Tercio@11: --> setup statusbar Tercio@11: CoolTip:StatusBar (button, CoolTip.StatusBarTable [i]) Tercio@11: end Tercio@11: Tercio@11: --> hide unused lines Tercio@11: for i = CoolTip.Indexes+1, #frame1.Lines do Tercio@11: frame1.Lines[i]:Hide() Tercio@11: end Tercio@11: CoolTip.NumLines = CoolTip.Indexes Tercio@11: Tercio@11: local spacing = 0 Tercio@11: if (CoolTip.OptionsTable.YSpacingMod) then Tercio@11: spacing = CoolTip.OptionsTable.YSpacingMod Tercio@11: end Tercio@11: Tercio@11: --> normalize height of all rows Tercio@11: local temp = -6 + spacing + (CoolTip.OptionsTable.ButtonsYMod or 0) Tercio@11: for i = 1, CoolTip.Indexes do Tercio@11: local menuButton = frame1.Lines [i] Tercio@11: Tercio@11: menuButton:ClearAllPoints() Tercio@11: menuButton:SetPoint ("center", frame1, "center") Tercio@40: menuButton:SetPoint ("left", frame1, "left", -4, 0) Tercio@40: menuButton:SetPoint ("right", frame1, "right", 4, 0) Tercio@11: Tercio@11: --> height Tercio@11: if (CoolTip.OptionsTable.AlignAsBlizzTooltip) then Tercio@11: local height = _math_max (8, menuButton.leftText:GetStringHeight(), menuButton.rightText:GetStringHeight(), menuButton.leftIcon:GetHeight(), menuButton.rightIcon:GetHeight()) Tercio@11: menuButton:SetHeight (height) Tercio@11: menuButton:SetPoint ("top", frame1, "top", 0, temp) Tercio@11: temp = temp + ( height * -1) Tercio@11: Tercio@11: elseif (CoolTip.OptionsTable.IgnoreButtonAutoHeight) then Tercio@11: Tercio@11: local height = _math_max (menuButton.leftText:GetStringHeight(), menuButton.rightText:GetStringHeight(), menuButton.leftIcon:GetHeight(), menuButton.rightIcon:GetHeight()) Tercio@11: menuButton:SetHeight (height) Tercio@11: menuButton:SetPoint ("top", frame1, "top", 0, temp) Tercio@11: Tercio@11: temp = temp + ( height * -1) + spacing + (CoolTip.OptionsTable.ButtonsYMod or 0) Tercio@11: Tercio@11: else Tercio@11: menuButton:SetHeight (frame1.hHeight + (CoolTip.OptionsTable.ButtonHeightMod or 0)) Tercio@11: menuButton:SetPoint ("top", frame1, "top", 0, ( ( (i-1) * frame1.hHeight) * -1) - 6 + (CoolTip.OptionsTable.ButtonsYMod or 0) + spacing) Tercio@11: end Tercio@11: Tercio@11: --> points Tercio@11: Tercio@11: if (CoolTip.OptionsTable.YSpacingMod and not CoolTip.OptionsTable.IgnoreButtonAutoHeight) then Tercio@11: spacing = spacing + CoolTip.OptionsTable.YSpacingMod Tercio@11: end Tercio@11: Tercio@11: menuButton:EnableMouse (false) Tercio@11: end Tercio@11: Tercio@11: if (not CoolTip.OptionsTable.FixedWidth) then Tercio@11: if (CoolTip.Type == 2) then --> with bars Tercio@11: if (CoolTip.OptionsTable.MinWidth) then Tercio@11: local w = frame1.w + 34 Tercio@11: frame1:SetWidth (math.max (w, CoolTip.OptionsTable.MinWidth)) Tercio@11: else Tercio@11: frame1:SetWidth (frame1.w + 34) Tercio@11: end Tercio@11: else Tercio@11: --> width stability check Tercio@11: local width = frame1.w + 24 Tercio@11: if (width > CoolTip.LastSize-5 and width < CoolTip.LastSize+5) then Tercio@11: width = CoolTip.LastSize Tercio@11: else Tercio@11: CoolTip.LastSize = width Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.OptionsTable.MinWidth) then Tercio@11: frame1:SetWidth (math.max (width, CoolTip.OptionsTable.MinWidth)) Tercio@11: else Tercio@11: frame1:SetWidth (width) Tercio@11: end Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.OptionsTable.FixedHeight) then Tercio@11: frame1:SetHeight (CoolTip.OptionsTable.FixedHeight) Tercio@11: else Tercio@11: if (CoolTip.OptionsTable.AlignAsBlizzTooltip) then Tercio@11: frame1:SetHeight ( (temp-10) * -1) Tercio@11: elseif (CoolTip.OptionsTable.IgnoreButtonAutoHeight) then Tercio@11: frame1:SetHeight ( (temp+spacing) * -1) Tercio@11: else Tercioo@29: frame1:SetHeight ( _math_max ( (frame1.hHeight * CoolTip.Indexes) + 8 + ((CoolTip.OptionsTable.ButtonsYMod or 0)*-1), 22 )) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.WallpaperTable [1]) then Tercio@11: CoolTip:SetupWallpaper (CoolTip.WallpaperTable, frame1.frameWallpaper) Tercio@11: else Tercio@11: frame1.frameWallpaper:Hide() Tercio@11: end Tercio@11: Tercio@11: --> unhide frame Tercio@26: DF:FadeFrame (frame1, 0) Tercio@11: CoolTip:SetMyPoint (host) Tercio@11: Tercio@11: --> fix sparks Tercio@11: for i = 1, CoolTip.Indexes do Tercio@11: local menuButton = frame1.Lines [i] Tercio@11: if (menuButton.spark:IsShown() or menuButton.spark2:IsShown()) then Tercio@11: CoolTip:RefreshSpark (menuButton) Tercio@11: end Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: function CoolTip:CreateDivBar (button) Tercio@11: button.divbar = button:CreateTexture (nil, "overlay") Tercio@11: Tercio@11: button.divbar:SetTexture ([[Interface\QUESTFRAME\AutoQuest-Parts]]) Tercio@11: button.divbar:SetTexCoord (238/512, 445/512, 0/64, 4/64) Tercio@11: Tercio@11: button.divbar:SetHeight (3) Tercio@11: button.divbar:SetAlpha (0.1) Tercio@11: Tercio@11: button.divbar:SetDesaturated (true) Tercio@11: end Tercio@11: Tercio@26: --> ~inicio ~start ~menu Tercio@11: function CoolTip:monta_cooltip (host, instancia, options, sub_menus, icones, tamanho1, tamanho2, font, fontsize) Tercio@11: Tercio@11: if (CoolTip.Indexes == 0) then Tercio@11: CoolTip:Reset() Tercio@11: CoolTip:SetType ("tooltip") Tercio@11: CoolTip:AddLine ("There is no options.") Tercio@11: CoolTip:ShowCooltip() Tercio@11: return Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.OptionsTable.FixedWidth) then Tercio@11: frame1:SetWidth (CoolTip.OptionsTable.FixedWidth) Tercio@11: end Tercio@11: Tercio@11: frame1.w = CoolTip.OptionsTable.FixedWidth or 0 Tercio@11: frame1.hHeight = 0 Tercio@11: frame2.hHeight = 0 Tercio@11: Tercio@11: frame1:EnableMouse (true) Tercio@11: Tercio@11: if (CoolTip.HaveSubMenu) then --> zera o segundo frame Tercio@11: frame2.w = 0 Tercio@11: frame2:SetHeight (6) Tercio@11: if (CoolTip.SelectedIndexMain and CoolTip.IndexesSub [CoolTip.SelectedIndexMain] and CoolTip.IndexesSub [CoolTip.SelectedIndexMain] > 0) then Tercio@26: DF:FadeFrame (frame2, 0) Tercio@11: else Tercio@26: DF:FadeFrame (frame2, 1) Tercio@11: end Tercio@11: else Tercio@26: DF:FadeFrame (frame2, 1) Tercio@11: end Tercio@11: Tercio@11: CoolTip.active = true Tercio@11: Tercio@11: for i = 1, CoolTip.Indexes do Tercio@11: local menuButton = frame1.Lines [i] Tercio@11: if (not menuButton) then Tercio@11: menuButton = CoolTip:NewMainButton (i) Tercio@11: end Tercio@11: Tercio@11: CoolTip:SetupMainButton (menuButton, i) Tercio@11: Tercio@11: menuButton.background:Hide() Tercio@11: end Tercio@11: Tercio@11: --> selected texture Tercio@11: if (CoolTip.SelectedIndexMain) then Tercio@11: CoolTip:SetSelectedAnchor (frame1, frame1.Lines [CoolTip.SelectedIndexMain]) Tercio@11: Tercio@11: if (CoolTip.OptionsTable.NoLastSelectedBar) then Tercio@11: CoolTip:HideSelectedTexture (frame1) Tercio@11: else Tercio@11: CoolTip:ShowSelectedTexture (frame1) Tercio@11: end Tercio@11: else Tercio@11: CoolTip:HideSelectedTexture (frame1) Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.Indexes < #frame1.Lines) then Tercio@11: for i = CoolTip.Indexes+1, #frame1.Lines do Tercio@11: frame1.Lines[i]:Hide() Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: CoolTip.NumLines = CoolTip.Indexes Tercio@11: Tercio@11: local spacing = 0 Tercio@11: if (CoolTip.OptionsTable.YSpacingMod) then Tercio@11: spacing = CoolTip.OptionsTable.YSpacingMod Tercio@11: end Tercio@11: Tercio@11: if (not CoolTip.OptionsTable.FixedWidth) then Tercio@11: if (CoolTip.OptionsTable.MinWidth) then Tercio@11: local w = frame1.w + 24 Tercio@11: frame1:SetWidth (math.max (w, CoolTip.OptionsTable.MinWidth)) Tercio@11: else Tercio@11: frame1:SetWidth (frame1.w + 24) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: --> normalize height of all rows Tercio@11: for i = 1, CoolTip.Indexes do Tercio@11: local menuButton = frame1.Lines [i] Tercio@11: menuButton:EnableMouse (true) Tercio@11: Tercio@11: if (menuButton.leftText:GetText() == "$div") then Tercio@11: Tercio@11: --> height Tercio@11: menuButton:SetHeight (4) Tercio@11: --> points Tercio@11: menuButton:ClearAllPoints() Tercio@40: menuButton:SetPoint ("left", frame1, "left", -4, 0) Tercio@40: menuButton:SetPoint ("right", frame1, "right", 4, 0) Tercio@11: menuButton:SetPoint ("center", frame1, "center") Tercio@11: Tercio@11: local div_size_up = tonumber (CoolTip.LeftTextTable [i] [2]) Tercio@11: if (not div_size_up) then Tercio@11: div_size_up = 0 Tercio@11: end Tercio@11: local div_size_down = tonumber (CoolTip.LeftTextTable [i] [3]) Tercio@11: if (not div_size_down) then Tercio@11: div_size_down = 0 Tercio@11: end Tercio@11: Tercio@11: menuButton:SetPoint ("top", frame1, "top", 0, ( ( (i-1) * frame1.hHeight) * -1) - 4 + (CoolTip.OptionsTable.ButtonsYMod or 0) + spacing - 4 + div_size_up) Tercio@11: if (CoolTip.OptionsTable.YSpacingMod) then Tercio@11: spacing = spacing + CoolTip.OptionsTable.YSpacingMod Tercio@11: end Tercio@11: Tercio@11: spacing = spacing + 4 + div_size_down Tercio@11: Tercio@11: menuButton.leftText:SetText ("") Tercio@11: menuButton.isDiv = true Tercio@11: Tercio@11: if (not menuButton.divbar) then Tercio@11: CoolTip:CreateDivBar (menuButton) Tercio@11: else Tercio@11: menuButton.divbar:Show() Tercio@11: end Tercio@11: Tercio@11: menuButton.divbar:SetPoint ("left", menuButton, "left", frame1:GetWidth()*0.10, 0) Tercio@11: menuButton.divbar:SetPoint ("right", menuButton, "right", -frame1:GetWidth()*0.10, 0) Tercio@11: Tercio@11: else Tercio@11: Tercio@11: --> height Tercio@11: menuButton:SetHeight (frame1.hHeight + (CoolTip.OptionsTable.ButtonHeightMod or 0)) Tercio@11: --> points Tercio@11: menuButton:ClearAllPoints() Tercio@11: menuButton:SetPoint ("center", frame1, "center") Tercio@11: menuButton:SetPoint ("top", frame1, "top", 0, ( ( (i-1) * frame1.hHeight) * -1) - 4 + (CoolTip.OptionsTable.ButtonsYMod or 0) + spacing) Tercio@11: if (CoolTip.OptionsTable.YSpacingMod) then Tercio@11: spacing = spacing + CoolTip.OptionsTable.YSpacingMod Tercio@11: end Tercio@40: menuButton:SetPoint ("left", frame1, "left", -4, 0) Tercio@40: menuButton:SetPoint ("right", frame1, "right", 4, 0) Tercio@11: Tercio@11: if (menuButton.divbar) then Tercio@11: menuButton.divbar:Hide() Tercio@11: menuButton.isDiv = false Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: end Tercio@56: Tercio@11: if (CoolTip.OptionsTable.FixedHeight) then Tercio@11: frame1:SetHeight (CoolTip.OptionsTable.FixedHeight) Tercio@11: else Tercio@11: local mod = CoolTip.OptionsTable.HeighMod or 0 Tercio@11: frame1:SetHeight (_math_max ( (frame1.hHeight * CoolTip.Indexes) + 12 + (-spacing) + mod, 22 )) Tercio@11: end Tercio@11: Tercio@11: --> sub menu arrows Tercio@11: if (CoolTip.HaveSubMenu and not CoolTip.OptionsTable.IgnoreArrows and not CoolTip.OptionsTable.SubMenuIsTooltip) then Tercio@11: for i = 1, CoolTip.Indexes do Tercio@11: if (CoolTip.IndexesSub [i] and CoolTip.IndexesSub [i] > 0) then Tercio@11: frame1.Lines [i].statusbar.subMenuArrow:Show() Tercio@11: else Tercio@11: frame1.Lines [i].statusbar.subMenuArrow:Hide() Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: frame1:SetWidth (frame1:GetWidth() + 16) Tercio@11: end Tercio@11: Tercio@11: frame1:ClearAllPoints() Tercio@11: CoolTip:SetMyPoint (host) Tercio@11: Tercio@11: if (CoolTip.title1) then Tercio@11: CoolTip.frame1.titleText:Show() Tercio@11: CoolTip.frame1.titleIcon:Show() Tercio@11: CoolTip.frame1.titleText:SetText (CoolTip.title_text) Tercio@11: CoolTip.frame1.titleIcon:SetWidth (frame1:GetWidth()) Tercio@11: CoolTip.frame1.titleIcon:SetHeight (40) Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.WallpaperTable [1]) then Tercio@11: CoolTip:SetupWallpaper (CoolTip.WallpaperTable, frame1.frameWallpaper) Tercio@11: else Tercio@11: frame1.frameWallpaper:Hide() Tercio@11: end Tercio@11: Tercio@26: DF:FadeFrame (frame1, 0) Tercio@11: Tercio@11: for i = 1, CoolTip.Indexes do Tercio@11: if (CoolTip.SelectedIndexMain and CoolTip.SelectedIndexMain == i) then Tercio@11: if (CoolTip.HaveSubMenu and CoolTip.IndexesSub [i] and CoolTip.IndexesSub [i] > 0) then Tercio@11: CoolTip:ShowSub (i) Tercio@11: end Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: return true Tercio@11: end Tercio@11: Tercio@11: function CoolTip:SetMyPoint (host, x_mod, y_mod) Tercio@11: Tercio@11: local moveX = x_mod or 0 Tercio@11: local moveY = y_mod or 0 Tercio@11: Tercio@11: --> clear all points Tercio@11: frame1:ClearAllPoints() Tercio@11: Tercio@11: local anchor = CoolTip.OptionsTable.Anchor or CoolTip.Host Tercio@56: Tercio@11: frame1:SetPoint (CoolTip.OptionsTable.MyAnchor, anchor, CoolTip.OptionsTable.RelativeAnchor, 0 + moveX + CoolTip.OptionsTable.WidthAnchorMod, 10 + CoolTip.OptionsTable.HeightAnchorMod + moveY) Tercio@11: Tercio@11: if (not x_mod) then Tercio@11: --> check if cooltip is out of screen bounds Tercio@11: local center_x = frame1:GetCenter() Tercio@11: Tercio@11: if (center_x) then Tercio@11: local screen_x_res = GetScreenWidth() Tercio@11: local half_x = frame1:GetWidth() / 2 Tercio@11: Tercio@11: if (center_x+half_x > screen_x_res) then Tercio@11: --> out of right side Tercio@11: local move_to_left = (center_x + half_x) - screen_x_res Tercio@11: CoolTip.internal_x_mod = -move_to_left Tercio@11: return CoolTip:SetMyPoint (host, -move_to_left, 0) Tercio@11: Tercio@11: elseif (center_x-half_x < 0) then Tercio@11: --> out of left side Tercio@11: local move_to_right = center_x - half_x Tercio@11: CoolTip.internal_x_mod = move_to_right*-1 Tercio@11: return CoolTip:SetMyPoint (host, move_to_right*-1, 0) Tercio@11: end Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: if (not y_mod) then Tercio@11: --> check if cooltip is out of screen bounds Tercio@11: local _, center_y = frame1:GetCenter() Tercio@11: local screen_y_res = GetScreenHeight() Tercio@11: local half_y = frame1:GetHeight() / 2 Tercio@11: Tercio@11: if (center_y) then Tercio@11: if (center_y+half_y > screen_y_res) then Tercio@11: --> out of top side Tercio@11: local move_to_down = (center_y + half_y) - screen_y_res Tercio@11: CoolTip.internal_y_mod = -move_to_down Tercio@11: return CoolTip:SetMyPoint (host, 0, -move_to_down) Tercio@11: Tercio@11: elseif (center_y-half_y < 0) then Tercio@11: --> out of bottom side Tercio@11: local move_to_up = center_y - half_y Tercio@11: CoolTip.internal_y_mod = move_to_up*-1 Tercio@11: return CoolTip:SetMyPoint (host, 0, move_to_up*-1) Tercio@11: Tercio@11: end Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: if (frame2:IsShown() and not CoolTip.overlap_checked) then Tercio@11: Tercio@11: local frame_2_center_x = frame2:GetCenter() Tercio@11: if (frame_2_center_x) then Tercio@11: local frame_2_half_x = frame2:GetWidth() / 2 Tercio@11: Tercio@11: local frame_1_center_x = frame1:GetCenter() Tercio@11: if (frame_1_center_x) then Tercio@11: Tercio@11: local frame_1_half_x = frame1:GetWidth() / 2 Tercio@11: Tercio@11: local f1_end_point = frame_1_center_x + frame_1_half_x - 3 Tercio@11: local f2_start_point = frame_2_center_x - frame_2_half_x Tercio@11: Tercio@11: if (f2_start_point < f1_end_point) then Tercio@11: local diff = f2_start_point - f1_end_point Tercio@11: CoolTip.overlap_checked = true Tercio@11: Tercio@11: frame2:ClearAllPoints() Tercio@40: frame2:SetPoint ("bottomright", frame1, "bottomleft", 4, 0) Tercio@11: CoolTip.frame2_leftside = true Tercio@11: --> diff Tercio@11: return CoolTip:SetMyPoint (host, CoolTip.internal_x_mod , CoolTip.internal_y_mod) Tercio@11: end Tercio@11: Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: end Tercio@11: Tercio@11: end Tercio@11: Tercio@11: function CoolTip:CheckOverlap() Tercio@11: if (frame2:IsShown()) then Tercio@11: Tercio@11: local frame_2_center_x = frame2:GetCenter() Tercio@11: if (frame_2_center_x) then Tercio@11: local frame_2_half_x = frame2:GetWidth() / 2 Tercio@11: Tercio@11: local frame_1_center_x = frame1:GetCenter() Tercio@11: if (frame_1_center_x) then Tercio@11: Tercio@11: local frame_1_half_x = frame1:GetWidth() / 2 Tercio@11: Tercio@11: local f1_end_point = frame_1_center_x + frame_1_half_x - 3 Tercio@11: local f2_start_point = frame_2_center_x - frame_2_half_x Tercio@11: Tercio@11: if (f2_start_point < f1_end_point) then Tercio@11: local diff = f2_start_point - f1_end_point Tercio@11: Tercio@11: frame2:ClearAllPoints() Tercio@40: frame2:SetPoint ("bottomright", frame1, "bottomleft", 4, 0) Tercio@11: CoolTip.frame2_leftside = true Tercio@11: end Tercio@11: Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: function CoolTip:GetText (buttonIndex) Tercio@11: local button1 = frame1.Lines [buttonIndex] Tercio@11: if (not button1) then Tercio@11: return "", "" Tercio@11: else Tercio@11: return button1.leftText:GetText() or "", button1.rightText:GetText() or "" Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: ---------------------------------------------------------------------- Tercio@11: --> Get the number of lines current shown on cooltip Tercio@11: Tercio@11: function CoolTip:GetNumLines() Tercio@11: return CoolTip.NumLines or 0 Tercio@11: end Tercio@11: Tercio@11: ---------------------------------------------------------------------- Tercio@11: --> Remove all options actived Tercio@11: --> Set a option on current cooltip Tercio@11: Tercio@11: function CoolTip:ClearAllOptions() Tercio@11: for option, _ in pairs (CoolTip.OptionsTable) do Tercio@11: CoolTip.OptionsTable [option] = nil Tercio@11: end Tercio@11: Tercio@11: CoolTip:SetOption ("MyAnchor", "bottom") Tercio@11: CoolTip:SetOption ("RelativeAnchor", "top") Tercio@11: CoolTip:SetOption ("WidthAnchorMod", 0) Tercio@11: CoolTip:SetOption ("HeightAnchorMod", 0) Tercio@11: end Tercio@11: Tercio@58: function CoolTip:SetOption (optionName, value) Tercio@58: Tercio@58: --> check for name alias Tercio@58: optionName = CoolTip.AliasList [optionName] or optionName Tercio@58: Tercio@11: --> check if this options exists Tercio@58: if (not CoolTip.OptionsList [optionName]) then Tercio@11: return --> error Tercio@11: end Tercio@58: Tercio@11: --> set options Tercio@58: CoolTip.OptionsTable [optionName] = value Tercio@11: end Tercio@11: Tercio@11: ---------------------------------------------------------------------- Tercio@11: --> set the anchor of cooltip Tercio@11: --> parameters: frame [, cooltip anchor point, frame anchor point [, x mod, y mod]] Tercio@11: --> frame [, x mod, y mod] Tercio@11: Tercio@11: --> alias Tercio@11: function CoolTip:GetOwner() Tercio@11: return CoolTip.Host Tercio@11: end Tercio@11: Tercio@11: function CoolTip:SetOwner (frame, myPoint, hisPoint, x, y) Tercio@11: return CoolTip:SetHost (frame, myPoint, hisPoint, x, y) Tercio@11: end Tercio@11: Tercio@11: function CoolTip:SetHost (frame, myPoint, hisPoint, x, y) Tercio@11: --> check data integrity Tercio@11: if (type (frame) ~= "table" or not frame.GetObjectType) then Tercio@56: print ("host needs to be a frame") Tercio@11: return --> error Tercio@11: end Tercio@11: Tercio@11: CoolTip.Host = frame Tercio@56: Tercio@11: CoolTip.frame1:SetFrameLevel (frame:GetFrameLevel()+1) Tercio@11: Tercio@11: --> defaults Tercio@11: myPoint = myPoint or CoolTip.OptionsTable.MyAnchor or "bottom" Tercio@11: hisPoint = hisPoint or CoolTip.OptionsTable.hisPoint or "top" Tercio@11: Tercio@11: x = x or CoolTip.OptionsTable.WidthAnchorMod or 0 Tercio@11: y = y or CoolTip.OptionsTable.HeightAnchorMod or 0 Tercio@11: Tercio@11: --> check options Tercio@11: if (type (myPoint) == "string") then Tercio@11: CoolTip:SetOption ("MyAnchor", myPoint) Tercio@11: CoolTip:SetOption ("WidthAnchorMod", x) Tercio@11: elseif (type (myPoint) == "number") then Tercio@11: CoolTip:SetOption ("HeightAnchorMod", myPoint) Tercio@11: end Tercio@11: Tercio@11: if (type (hisPoint) == "string") then Tercio@11: CoolTip:SetOption ("RelativeAnchor", hisPoint) Tercio@11: CoolTip:SetOption ("HeightAnchorMod", y) Tercio@11: elseif (type (hisPoint) == "number") then Tercio@11: CoolTip:SetOption ("WidthAnchorMod", hisPoint) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: ---------------------------------------------------------------------- Tercio@11: --> set cooltip type Tercio@11: --> parameters: type (1 = tooltip | 2 = tooltip with bars | 3 = menu) Tercio@11: Tercio@11: function CoolTip:IsMenu() Tercio@11: return CoolTip.frame1:IsShown() and CoolTip.Type == 3 Tercio@11: end Tercio@11: Tercio@11: function CoolTip:IsTooltip() Tercio@11: return CoolTip.frame1:IsShown() and (CoolTip.Type == 1 or CoolTip.Type == 2) Tercio@11: end Tercio@11: Tercio@11: function CoolTip:GetType() Tercio@11: if (CoolTip.Type == 1 or CoolTip.Type == 2) then Tercio@11: return "tooltip" Tercio@11: elseif (CoolTip.Type == 3) then Tercio@11: return "menu" Tercio@11: else Tercio@11: return "none" Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: function CoolTip:SetType (newType) Tercio@11: if (type (newType) == "string") then Tercio@11: if (newType == "tooltip") then Tercio@11: CoolTip.Type = 1 Tercio@11: elseif (newType == "tooltipbar") then Tercio@11: CoolTip.Type = 2 Tercio@11: elseif (newType == "menu") then Tercio@11: CoolTip.Type = 3 Tercio@11: else Tercio@11: --> error Tercio@11: end Tercio@11: elseif (type (newType) == "number") then Tercio@11: if (newType == 1) then Tercio@11: CoolTip.Type = 1 Tercio@11: elseif (newType == 2) then Tercio@11: CoolTip.Type = 2 Tercio@11: elseif (newType == 3) then Tercio@11: CoolTip.Type = 3 Tercio@11: else Tercio@11: --> error Tercio@11: end Tercio@11: else Tercio@11: --> error Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: --> Set a fixed value for menu Tercio@11: function CoolTip:SetFixedParameter (value, injected) Tercio@11: if (injected ~= nil) then Tercio@11: local frame = value Tercio@11: if (frame.dframework) then Tercio@11: frame = frame.widget Tercio@11: end Tercio@11: if (frame.CoolTip) then Tercio@11: frame.CoolTip.FixedValue = injected Tercio@11: else Tercio@11: --debug Tercio@11: end Tercio@11: end Tercio@11: CoolTip.FixedValue = value Tercio@11: end Tercio@11: Tercio@11: function CoolTip:SetColor (menuType, ...) Tercio@11: local ColorR, ColorG, ColorB, ColorA = DF:ParseColors (...) Tercio@11: if ((type (menuType) == "string" and menuType == "main") or (type (menuType) == "number" and menuType == 1)) then Tercio@11: frame1.framebackgroundLeft:SetVertexColor (ColorR, ColorG, ColorB, ColorA) Tercio@11: frame1.framebackgroundRight:SetVertexColor (ColorR, ColorG, ColorB, ColorA) Tercio@11: frame1.framebackgroundCenter:SetVertexColor (ColorR, ColorG, ColorB, ColorA) Tercio@11: Tercio@11: elseif ((type (menuType) == "string" and menuType == "sec") or (type (menuType) == "number" and menuType == 2)) then Tercio@11: frame2.framebackgroundLeft:SetVertexColor (ColorR, ColorG, ColorB, ColorA) Tercio@11: frame2.framebackgroundRight:SetVertexColor (ColorR, ColorG, ColorB, ColorA) Tercio@11: frame2.framebackgroundCenter:SetVertexColor (ColorR, ColorG, ColorB, ColorA) Tercio@11: Tercio@11: else Tercio@11: return --> error Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: --> Set last selected option Tercio@11: function CoolTip:SetLastSelected (menuType, index, index2) Tercio@11: Tercio@11: if (CoolTip.Type == 3) then Tercio@11: if ((type (menuType) == "string" and menuType == "main") or (type (menuType) == "number" and menuType == 1)) then Tercio@11: CoolTip.SelectedIndexMain = index Tercio@11: elseif ((type (menuType) == "string" and menuType == "sec") or (type (menuType) == "number" and menuType == 2)) then Tercio@11: CoolTip.SelectedIndexSec [index] = index2 Tercio@11: else Tercio@11: return --> error Tercio@11: end Tercio@11: else Tercio@11: return --> error Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: --> serack key: ~select Tercio@11: function CoolTip:Select (menuType, option, mainIndex) Tercio@11: if (menuType == 1) then --main menu Tercio@11: local botao = frame1.Lines [option] Tercio@11: CoolTip.buttonClicked = true Tercio@11: CoolTip:SetSelectedAnchor (frame1, botao) Tercio@11: Tercio@11: --UIFrameFlash (frame1.selected, 0.05, 0.05, 0.2, true, 0, 0) Tercio@11: Tercio@11: elseif (menuType == 2) then --sub menu Tercio@11: CoolTip:ShowSub (mainIndex) Tercio@11: local botao = frame2.Lines [option] Tercio@11: CoolTip.buttonClicked = true Tercio@11: Tercio@11: CoolTip:SetSelectedAnchor (frame2, botao) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: ---------------------------------------------------------------------- Tercio@11: --> Reset cooltip Tercio@11: Tercioo@29: local default_backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], tile = true, Tercioo@29: edgeSize = 1, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}} Tercio@11: local default_backdrop_color = {0.09019, 0.09019, 0.18823, 1} Tercio@11: local default_backdropborder_color = {1, 1, 1, 1} Tercio@11: Tercio@11: --borda preta sem usar unpack Tercio@11: Tercio@11: --> wipe all data ~reset Tercio@11: function CoolTip:Reset() Tercio@11: Tercio@11: frame2:ClearAllPoints() Tercio@40: frame2:SetPoint ("bottomleft", frame1, "bottomright", 4, 0) Tercio@40: Tercio@40: frame1:SetParent (UIParent) Tercio@40: frame2:SetParent (UIParent) Tercio@40: frame1:SetFrameStrata ("TOOLTIP") Tercio@40: frame2:SetFrameStrata ("TOOLTIP") Tercio@40: Tercio@11: CoolTip:HideSelectedTexture (frame1) Tercio@11: CoolTip:HideSelectedTexture (frame2) Tercio@11: Tercio@11: CoolTip.FixedValue = nil Tercio@11: CoolTip.HaveSubMenu = false Tercio@11: Tercio@11: CoolTip.SelectedIndexMain = nil Tercio@11: _table_wipe (CoolTip.SelectedIndexSec) Tercio@11: Tercio@11: CoolTip.Indexes = 0 Tercio@11: CoolTip.SubIndexes = 0 Tercio@11: _table_wipe (CoolTip.IndexesSub) Tercio@11: Tercio@11: CoolTip.internal_x_mod = 0 Tercio@11: CoolTip.internal_y_mod = 0 Tercio@11: CoolTip.current_anchor = nil Tercio@11: CoolTip.overlap_checked = false Tercio@11: Tercio@11: CoolTip.frame2_leftside = nil Tercio@11: Tercio@11: frame1:SetBackdrop (default_backdrop) Tercio@11: frame1:SetBackdropColor (unpack (default_backdrop_color)) Tercio@11: frame1:SetBackdropBorderColor (unpack (default_backdropborder_color)) Tercio@11: Tercio@11: frame2:SetBackdrop (default_backdrop) Tercio@11: frame2:SetBackdropColor (unpack (default_backdrop_color)) Tercio@11: frame2:SetBackdropBorderColor (unpack (default_backdropborder_color)) Tercio@11: Tercio@11: --[ Tercio@20: _table_wipe (CoolTip.PopupFrameTable) Tercio@20: Tercio@11: _table_wipe (CoolTip.LeftTextTable) Tercio@11: _table_wipe (CoolTip.LeftTextTableSub) Tercio@11: _table_wipe (CoolTip.RightTextTable) Tercio@11: _table_wipe (CoolTip.RightTextTableSub) Tercio@11: Tercio@11: _table_wipe (CoolTip.LeftIconTable) Tercio@11: _table_wipe (CoolTip.LeftIconTableSub) Tercio@11: _table_wipe (CoolTip.RightIconTable) Tercio@11: _table_wipe (CoolTip.RightIconTableSub) Tercio@11: Tercio@11: _table_wipe (CoolTip.StatusBarTable) Tercio@11: _table_wipe (CoolTip.StatusBarTableSub) Tercio@11: Tercio@11: _table_wipe (CoolTip.FunctionsTableMain) Tercio@11: _table_wipe (CoolTip.FunctionsTableSub) Tercio@11: Tercio@11: _table_wipe (CoolTip.ParametersTableMain) Tercio@11: _table_wipe (CoolTip.ParametersTableSub) Tercio@11: Tercio@11: _table_wipe (CoolTip.WallpaperTable) Tercio@11: _table_wipe (CoolTip.WallpaperTableSub) Tercio@11: --]] Tercio@11: Tercio@11: _table_wipe (CoolTip.TopIconTableSub) Tercio@11: CoolTip.Banner [1] = false Tercio@11: CoolTip.Banner [2] = false Tercio@11: CoolTip.Banner [3] = false Tercio@11: Tercio@11: frame1.upperImage:Hide() Tercio@11: frame1.upperImage2:Hide() Tercio@11: frame1.upperImageText:Hide() Tercio@11: frame1.upperImageText2:Hide() Tercio@11: Tercio@11: frame1.frameWallpaper:Hide() Tercio@11: frame2.frameWallpaper:Hide() Tercio@11: Tercio@11: frame2.upperImage:Hide() Tercio@11: Tercio@11: CoolTip.title1 = nil Tercio@11: CoolTip.title_text = nil Tercio@11: Tercio@11: CoolTip.frame1.titleText:Hide() Tercio@11: CoolTip.frame1.titleIcon:Hide() Tercio@11: Tercio@11: CoolTip:ClearAllOptions() Tercio@11: CoolTip:SetColor (1, "transparent") Tercio@11: CoolTip:SetColor (2, "transparent") Tercio@11: Tercio@11: local f1Lines = frame1.Lines Tercio@11: for i = 1, #f1Lines do Tercio@11: f1Lines [i].statusbar.subMenuArrow:Hide() Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: ---------------------------------------------------------------------- Tercio@11: --> Menu functions Tercio@11: Tercio@11: local _default_color = {1, 1, 1} Tercio@11: local _default_point = {"center", "center", 0, -3} Tercio@11: Tercio@11: function CoolTip:AddMenu (menuType, func, param1, param2, param3, leftText, leftIcon, indexUp) Tercio@11: Tercio@11: if (leftText and indexUp and ((type (menuType) == "string" and menuType == "main") or (type (menuType) == "number" and menuType == 1))) then Tercio@11: CoolTip.Indexes = CoolTip.Indexes + 1 Tercio@11: Tercio@11: if (not CoolTip.IndexesSub [CoolTip.Indexes]) then Tercio@11: CoolTip.IndexesSub [CoolTip.Indexes] = 0 Tercio@11: end Tercio@11: Tercio@11: CoolTip.SubIndexes = 0 Tercio@11: end Tercio@11: Tercio@11: --> need a previous line Tercio@11: if (CoolTip.Indexes == 0) then Tercio@11: print ("Indexes are 0") Tercio@11: return --> return error Tercio@11: end Tercio@11: Tercio@11: --> check data integrity Tercio@11: if (type (func) ~= "function") then Tercio@11: print ("No function") Tercio@11: return --> erroe Tercio@11: end Tercio@11: Tercio@11: --> add Tercio@11: Tercio@11: if ((type (menuType) == "string" and menuType == "main") or (type (menuType) == "number" and menuType == 1)) then Tercio@11: Tercio@11: local parameterTable Tercio@11: if (CoolTip.isSpecial) then Tercio@11: parameterTable = {} Tercio@11: _table_insert (CoolTip.FunctionsTableMain, CoolTip.Indexes, func) Tercio@11: _table_insert (CoolTip.ParametersTableMain, CoolTip.Indexes, parameterTable) Tercio@11: else Tercio@11: Tercio@11: CoolTip.FunctionsTableMain [CoolTip.Indexes] = func Tercio@11: Tercio@11: parameterTable = CoolTip.ParametersTableMain [CoolTip.Indexes] Tercio@11: if (not parameterTable) then Tercio@11: parameterTable = {} Tercio@11: CoolTip.ParametersTableMain [CoolTip.Indexes] = parameterTable Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: parameterTable [1] = param1 Tercio@11: parameterTable [2] = param2 Tercio@11: parameterTable [3] = param3 Tercio@11: Tercio@11: if (leftIcon) then Tercio@11: local iconTable = CoolTip.LeftIconTable [CoolTip.Indexes] Tercio@11: Tercio@11: if (not iconTable or CoolTip.isSpecial) then Tercio@11: iconTable = {} Tercio@11: CoolTip.LeftIconTable [CoolTip.Indexes] = iconTable Tercio@11: end Tercio@11: Tercio@11: iconTable [1] = leftIcon Tercio@11: iconTable [2] = 16 --> default 16 Tercio@11: iconTable [3] = 16 --> default 16 Tercio@11: iconTable [4] = 0 --> default 0 Tercio@11: iconTable [5] = 1 --> default 1 Tercio@11: iconTable [6] = 0 --> default 0 Tercio@11: iconTable [7] = 1 --> default 1 Tercio@11: iconTable [8] = _default_color Tercio@11: end Tercio@11: Tercio@11: if (leftText) then Tercio@11: local lineTable_left = CoolTip.LeftTextTable [CoolTip.Indexes] Tercio@11: Tercio@11: if (not lineTable_left or CoolTip.isSpecial) then Tercio@11: lineTable_left = {} Tercio@11: CoolTip.LeftTextTable [CoolTip.Indexes] = lineTable_left Tercio@11: end Tercio@11: Tercio@11: lineTable_left [1] = leftText --> line text Tercio@11: lineTable_left [2] = 0 Tercio@11: lineTable_left [3] = 0 Tercio@11: lineTable_left [4] = 0 Tercio@11: lineTable_left [5] = 0 Tercio@11: lineTable_left [6] = false Tercio@11: lineTable_left [7] = false Tercio@11: lineTable_left [8] = false Tercio@11: Tercio@11: end Tercio@11: Tercio@11: elseif ((type (menuType) == "string" and menuType == "sec") or (type (menuType) == "number" and menuType == 2)) then Tercio@11: Tercio@11: if (CoolTip.SubIndexes == 0) then Tercio@11: if (not indexUp or not leftText) then Tercio@11: print ("not indexUp or not leftText") Tercio@11: return --> error Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: if (indexUp and leftText) then Tercio@11: CoolTip.SubIndexes = CoolTip.SubIndexes + 1 Tercio@11: CoolTip.IndexesSub [CoolTip.Indexes] = CoolTip.IndexesSub [CoolTip.Indexes] + 1 Tercio@11: elseif (indexUp and not leftText) then Tercio@11: print ("indexUp and not leftText") Tercio@11: return --> error [leftText can't be nil if indexUp are true] Tercio@11: end Tercio@11: Tercio@11: --> menu container Tercio@11: local subMenuContainerParameters = CoolTip.ParametersTableSub [CoolTip.Indexes] Tercio@11: if (not subMenuContainerParameters) then Tercio@11: subMenuContainerParameters = {} Tercio@11: CoolTip.ParametersTableSub [CoolTip.Indexes] = subMenuContainerParameters Tercio@11: end Tercio@11: Tercio@11: local subMenuContainerFunctions = CoolTip.FunctionsTableSub [CoolTip.Indexes] Tercio@11: if (not subMenuContainerFunctions or CoolTip.isSpecial) then Tercio@11: subMenuContainerFunctions = {} Tercio@11: CoolTip.FunctionsTableSub [CoolTip.Indexes] = subMenuContainerFunctions Tercio@11: end Tercio@11: Tercio@11: --> menu table Tercio@11: local subMenuTablesParameters = subMenuContainerParameters [CoolTip.SubIndexes] Tercio@11: if (not subMenuTablesParameters or CoolTip.isSpecial) then Tercio@11: subMenuTablesParameters = {} Tercio@11: subMenuContainerParameters [CoolTip.SubIndexes] = subMenuTablesParameters Tercio@11: end Tercio@11: Tercio@11: --> add Tercio@11: subMenuContainerFunctions [CoolTip.SubIndexes] = func Tercio@11: Tercio@11: subMenuTablesParameters [1] = param1 Tercio@11: subMenuTablesParameters [2] = param2 Tercio@11: subMenuTablesParameters [3] = param3 Tercio@11: Tercio@11: --> text and icon Tercio@11: if (leftIcon) then Tercio@11: Tercio@11: local subMenuContainerIcons = CoolTip.LeftIconTableSub [CoolTip.Indexes] Tercio@11: if (not subMenuContainerIcons) then Tercio@11: subMenuContainerIcons = {} Tercio@11: CoolTip.LeftIconTableSub [CoolTip.Indexes] = subMenuContainerIcons Tercio@11: end Tercio@11: local subMenuTablesIcons = subMenuContainerIcons [CoolTip.SubIndexes] Tercio@11: if (not subMenuTablesIcons or CoolTip.isSpecial) then Tercio@11: subMenuTablesIcons = {} Tercio@11: subMenuContainerIcons [CoolTip.SubIndexes] = subMenuTablesIcons Tercio@11: end Tercio@11: Tercio@11: subMenuTablesIcons [1] = leftIcon Tercio@11: subMenuTablesIcons [2] = 16 --> default 16 Tercio@11: subMenuTablesIcons [3] = 16 --> default 16 Tercio@11: subMenuTablesIcons [4] = 0 --> default 0 Tercio@11: subMenuTablesIcons [5] = 1 --> default 1 Tercio@11: subMenuTablesIcons [6] = 0 --> default 0 Tercio@11: subMenuTablesIcons [7] = 1 --> default 1 Tercio@11: subMenuTablesIcons [8] = _default_color Tercio@11: end Tercio@11: Tercio@11: if (leftText) then Tercio@11: Tercio@11: local subMenuContainerTexts = CoolTip.LeftTextTableSub [CoolTip.Indexes] Tercio@11: if (not subMenuContainerTexts) then Tercio@11: subMenuContainerTexts = {} Tercio@11: CoolTip.LeftTextTableSub [CoolTip.Indexes] = subMenuContainerTexts Tercio@11: end Tercio@11: local subMenuTablesTexts = subMenuContainerTexts [CoolTip.SubIndexes] Tercio@11: if (not subMenuTablesTexts or CoolTip.isSpecial) then Tercio@11: subMenuTablesTexts = {} Tercio@11: subMenuContainerTexts [CoolTip.SubIndexes] = subMenuTablesTexts Tercio@11: end Tercio@11: Tercio@11: subMenuTablesTexts [1] = leftText --> line text Tercio@11: subMenuTablesTexts [2] = 0 Tercio@11: subMenuTablesTexts [3] = 0 Tercio@11: subMenuTablesTexts [4] = 0 Tercio@11: subMenuTablesTexts [5] = 0 Tercio@11: subMenuTablesTexts [6] = false Tercio@11: subMenuTablesTexts [7] = false Tercio@11: subMenuTablesTexts [8] = false Tercio@11: Tercio@11: end Tercio@11: Tercio@11: CoolTip.HaveSubMenu = true Tercio@11: Tercio@11: else Tercio@11: return --> error Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: ---------------------------------------------------------------------- Tercio@11: --> adds a statusbar to the last line added. Tercio@11: --> only works with cooltip type 2 (tooltip with bars) Tercio@11: --> parameters: value [, color red, color green, color blue, color alpha [, glow]] Tercio@11: --> can also use a table or html color name in color red and send glow in color green Tercio@11: Tercioo@29: function CoolTip:AddStatusBar (statusbarValue, frame, ColorR, ColorG, ColorB, ColorA, statusbarGlow, backgroundBar, barTexture) Tercio@11: Tercio@11: --> need a previous line Tercio@11: if (CoolTip.Indexes == 0) then Tercio@11: return --> return error Tercio@11: end Tercio@11: Tercio@11: --> check data integrity Tercio@11: if (type (statusbarValue) ~= "number") then Tercio@11: return --> error Tercio@11: end Tercio@11: Tercio@11: if (type (ColorR) == "table" or type (ColorR) == "string") then Tercio@11: statusbarGlow, backgroundBar, ColorR, ColorG, ColorB, ColorA = ColorG, ColorB, DF:ParseColors (ColorR) Tercio@11: elseif (type (ColorR) == "boolean") then Tercio@11: backgroundBar = ColorG Tercio@11: statusbarGlow = ColorR Tercio@11: ColorR, ColorG, ColorB, ColorA = 1, 1, 1, 1 Tercio@11: else Tercio@11: --> error Tercio@11: end Tercio@11: Tercio@11: --> add Tercio@11: local frameTable Tercio@11: local statusbarTable Tercio@11: Tercio@11: if (not frame or (type (frame) == "string" and frame == "main") or (type (frame) == "number" and frame == 1)) then Tercio@11: frameTable = CoolTip.StatusBarTable Tercio@11: Tercio@11: if (CoolTip.isSpecial) then Tercio@11: statusbarTable = {} Tercio@11: _table_insert (frameTable, CoolTip.Indexes, statusbarTable) Tercio@11: else Tercio@11: statusbarTable = frameTable [CoolTip.Indexes] Tercio@11: if (not statusbarTable) then Tercio@11: statusbarTable = {} Tercio@11: _table_insert (frameTable, CoolTip.Indexes, statusbarTable) Tercio@11: --frameTable [CoolTip.Indexes] = statusbarTable Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: elseif ((type (frame) == "string" and frame == "sub") or (type (frame) == "number" and frame == 2)) then Tercio@11: Tercio@11: frameTable = CoolTip.StatusBarTableSub Tercio@11: Tercio@11: local subMenuContainerStatusBar = frameTable [CoolTip.Indexes] Tercio@11: if (not subMenuContainerStatusBar) then Tercio@11: subMenuContainerStatusBar = {} Tercio@11: frameTable [CoolTip.Indexes] = subMenuContainerStatusBar Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.isSpecial) then Tercio@11: statusbarTable = {} Tercio@11: _table_insert (subMenuContainerStatusBar, CoolTip.SubIndexes, statusbarTable) Tercio@11: else Tercio@11: statusbarTable = subMenuContainerStatusBar [CoolTip.SubIndexes] Tercio@11: if (not statusbarTable) then Tercio@11: statusbarTable = {} Tercio@11: _table_insert (subMenuContainerStatusBar, CoolTip.SubIndexes, statusbarTable) Tercio@11: end Tercio@11: end Tercio@11: else Tercio@11: print ("unknow frame") Tercio@11: return --> error Tercio@11: end Tercio@11: Tercio@11: statusbarTable [1] = statusbarValue Tercio@11: statusbarTable [2] = ColorR Tercio@11: statusbarTable [3] = ColorG Tercio@11: statusbarTable [4] = ColorB Tercio@11: statusbarTable [5] = ColorA Tercio@11: statusbarTable [6] = statusbarGlow Tercio@11: statusbarTable [7] = backgroundBar Tercioo@29: statusbarTable [8] = barTexture Tercio@11: Tercio@11: end Tercio@11: Tercio@11: frame1.frameWallpaper:Hide() Tercio@11: frame2.frameWallpaper:Hide() Tercio@11: Tercio@11: function CoolTip:SetWallpaper (index, texture, texcoord, color, desaturate) Tercio@11: Tercio@11: if (CoolTip.Indexes == 0) then Tercio@11: return --> return error Tercio@11: end Tercio@11: Tercio@11: local frameTable Tercio@11: local wallpaperTable Tercio@11: Tercio@11: if ( (type (index) == "number" and index == 1) or (type (index) == "string" and index == "main") ) then Tercio@11: wallpaperTable = CoolTip.WallpaperTable Tercio@11: Tercio@11: elseif ( (type (index) == "number" and index == 2) or (type (index) == "string" and index == "sub") ) then Tercio@11: frameTable = CoolTip.WallpaperTableSub Tercio@11: Tercio@11: local subMenuContainerWallpapers = frameTable [CoolTip.Indexes] Tercio@11: if (not subMenuContainerWallpapers) then Tercio@11: subMenuContainerWallpapers = {} Tercio@11: frameTable [CoolTip.Indexes] = subMenuContainerWallpapers Tercio@11: end Tercio@11: Tercio@11: wallpaperTable = subMenuContainerWallpapers Tercio@11: end Tercio@11: Tercio@11: wallpaperTable [1] = texture Tercio@11: if (texcoord) then Tercio@11: wallpaperTable [2] = texcoord [1] Tercio@11: wallpaperTable [3] = texcoord [2] Tercio@11: wallpaperTable [4] = texcoord [3] Tercio@11: wallpaperTable [5] = texcoord [4] Tercio@11: else Tercio@11: wallpaperTable [2] = 0 Tercio@11: wallpaperTable [3] = 1 Tercio@11: wallpaperTable [4] = 0 Tercio@11: wallpaperTable [5] = 1 Tercio@11: end Tercio@11: wallpaperTable [6] = color Tercio@11: wallpaperTable [7] = desaturate Tercio@11: end Tercio@11: Tercio@11: function CoolTip:SetBannerText (index, text, anchor, color, fontsize, fontface, fontflag) Tercio@11: local fontstring Tercio@11: Tercio@11: if (index == 1) then Tercio@11: fontstring = frame1.upperImageText Tercio@11: elseif (index == 2) then Tercio@11: fontstring = frame1.upperImageText2 Tercio@11: end Tercio@11: Tercio@11: fontstring:SetText (text or "") Tercio@11: Tercio@11: if (anchor and index == 1) then Tercio@11: local myAnchor, hisAnchor, x, y = unpack (anchor) Tercio@11: fontstring:SetPoint (myAnchor, frame1.upperImage, hisAnchor or myAnchor, x or 0, y or 0) Tercio@11: elseif (anchor and index == 2) then Tercio@11: local myAnchor, hisAnchor, x, y = unpack (anchor) Tercio@11: fontstring:SetPoint (myAnchor, frame1, hisAnchor or myAnchor, x or 0, y or 0) Tercio@11: end Tercio@11: Tercio@11: if (color) then Tercio@11: local r, g, b, a = DF:ParseColors (color) Tercio@11: fontstring:SetTextColor (r, g, b, a) Tercio@11: end Tercio@11: Tercio@11: local face, size, flags = fontstring:GetFont() Tercio@11: face = fontface or [[Fonts\FRIZQT__.TTF]] Tercio@11: size = fontsize or 13 Tercio@11: flags = fontflag or nil Tercio@11: fontstring:SetFont (face, size, flags) Tercio@11: fontstring:Show() Tercio@11: end Tercio@11: Tercio@11: function CoolTip:SetBackdrop (index, backdrop, backdropcolor, bordercolor) Tercio@11: Tercio@11: local f Tercio@11: if (index == 1) then Tercio@11: f = frame1 Tercio@11: elseif (index == 2) then Tercio@11: f = frame2 Tercio@11: end Tercio@11: Tercio@11: if (backdrop) then Tercio@11: f:SetBackdrop (backdrop) Tercio@11: end Tercio@11: if (backdropcolor) then Tercio@11: local r, g, b, a = DF:ParseColors (backdropcolor) Tercio@11: f:SetBackdropColor (r, g, b, a) Tercio@11: end Tercio@11: if (bordercolor) then Tercio@11: local r, g, b, a = DF:ParseColors (bordercolor) Tercio@11: f:SetBackdropBorderColor (r, g, b, a) Tercio@11: end Tercio@11: Tercio@11: end Tercio@11: Tercio@11: function CoolTip:SetBannerImage (index, texturepath, width, height, anchor, texcoord, overlay) Tercio@11: Tercio@11: local texture Tercio@11: Tercio@11: if (index == 1) then Tercio@11: texture = frame1.upperImage Tercio@11: elseif (index == 2) then Tercio@11: texture = frame1.upperImage2 Tercio@11: end Tercio@11: Tercio@11: if (texturepath) then Tercio@11: texture:SetTexture (texturepath) Tercio@11: end Tercio@11: Tercio@11: if (width) then Tercio@11: texture:SetWidth (width) Tercio@11: end Tercio@11: if (height) then Tercio@11: texture:SetHeight (height) Tercio@11: end Tercio@11: Tercio@11: if (anchor) then Tercio@11: if (type (anchor[1]) == "table") then Tercio@11: for _, t in _ipairs (anchor) do Tercio@11: local myAnchor, hisAnchor, x, y = unpack (t) Tercio@11: texture:SetPoint (myAnchor, frame1, hisAnchor or myAnchor, x or 0, y or 0) Tercio@11: end Tercio@11: else Tercio@11: local myAnchor, hisAnchor, x, y = unpack (anchor) Tercio@11: texture:SetPoint (myAnchor, frame1, hisAnchor or myAnchor, x or 0, y or 0) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: if (texcoord) then Tercio@11: local L, R, T, B = unpack (texcoord) Tercio@11: texture:SetTexCoord (L, R, T, B) Tercio@11: end Tercio@11: Tercio@11: if (overlay) then Tercio@11: texture:SetVertexColor (unpack (overlay)) Tercio@11: end Tercio@11: Tercio@11: CoolTip.Banner [index] = true Tercio@11: texture:Show() Tercio@11: Tercio@11: end Tercio@11: Tercio@11: ---------------------------------------------------------------------- Tercio@11: --> adds a icon to the last line added. Tercio@11: --> only works with cooltip type 1 and 2 (tooltip and tooltip with bars) Tercio@11: --> parameters: icon [, width [, height [, TexCoords L R T B ]]] Tercio@11: --> texture support string path or texture object Tercio@11: Tercio@11: function CoolTip:AddTexture (iconTexture, frame, side, iconWidth, iconHeight, L, R, T, B, overlayColor, point, desaturated) Tercio@11: return CoolTip:AddIcon (iconTexture, frame, side, iconWidth, iconHeight, L, R, T, B, overlayColor, point, desaturated) Tercio@11: end Tercio@11: function CoolTip:AddIcon (iconTexture, frame, side, iconWidth, iconHeight, L, R, T, B, overlayColor, point, desaturated) Tercio@11: Tercio@11: --> need a previous line Tercio@11: if (CoolTip.Indexes == 0) then Tercio@11: return --> return error Tercio@11: end Tercio@11: Tercio@11: --> check data integrity Tercio@39: if ( (type (iconTexture) ~= "string" and type (iconTexture) ~= "number") and (type (iconTexture) ~= "table" or not iconTexture.GetObjectType or iconTexture:GetObjectType() ~= "Texture") ) then Tercio@11: return --> return error Tercio@11: end Tercio@11: Tercio@11: side = side or 1 Tercio@11: Tercio@11: local frameTable Tercio@11: local iconTable Tercio@11: Tercio@11: if (not frame or (type (frame) == "string" and frame == "main") or (type (frame) == "number" and frame == 1)) then Tercio@11: Tercio@11: if (not side or (type (side) == "string" and side == "left") or (type (side) == "number" and side == 1)) then Tercio@11: frameTable = CoolTip.LeftIconTable Tercio@11: Tercio@11: elseif ((type (side) == "string" and side == "right") or (type (side) == "number" and side == 2)) then Tercio@11: frameTable = CoolTip.RightIconTable Tercio@11: Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.isSpecial) then Tercio@11: iconTable = {} Tercio@11: _table_insert (frameTable, CoolTip.Indexes, iconTable) Tercio@11: else Tercio@11: iconTable = frameTable [CoolTip.Indexes] Tercio@11: if (not iconTable) then Tercio@11: iconTable = {} Tercio@11: _table_insert (frameTable, CoolTip.Indexes, iconTable) Tercio@11: --frameTable [CoolTip.Indexes] = iconTable Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: elseif ((type (frame) == "string" and frame == "sub") or (type (frame) == "number" and frame == 2)) then Tercio@11: Tercio@11: if ((type (side) == "string" and side == "left") or (type (side) == "number" and side == 1)) then Tercio@11: frameTable = CoolTip.LeftIconTableSub Tercio@11: elseif ((type (side) == "string" and side == "right") or (type (side) == "number" and side == 2)) then Tercio@11: frameTable = CoolTip.RightIconTableSub Tercio@11: elseif ((type (side) == "string" and side == "top") or (type (side) == "number" and side == 3)) then Tercio@11: CoolTip.TopIconTableSub [CoolTip.Indexes] = CoolTip.TopIconTableSub [CoolTip.Indexes] or {} Tercio@11: CoolTip.TopIconTableSub [CoolTip.Indexes] [1] = iconTexture Tercio@11: CoolTip.TopIconTableSub [CoolTip.Indexes] [2] = iconWidth or 16 Tercio@11: CoolTip.TopIconTableSub [CoolTip.Indexes] [3] = iconHeight or 16 Tercio@11: CoolTip.TopIconTableSub [CoolTip.Indexes] [4] = L or 0 Tercio@11: CoolTip.TopIconTableSub [CoolTip.Indexes] [5] = R or 1 Tercio@11: CoolTip.TopIconTableSub [CoolTip.Indexes] [6] = T or 0 Tercio@11: CoolTip.TopIconTableSub [CoolTip.Indexes] [7] = B or 1 Tercio@11: CoolTip.TopIconTableSub [CoolTip.Indexes] [8] = overlayColor or _default_color Tercio@11: CoolTip.TopIconTableSub [CoolTip.Indexes] [9] = desaturated Tercio@11: return Tercio@11: end Tercio@11: Tercio@11: local subMenuContainerIcons = frameTable [CoolTip.Indexes] Tercio@11: if (not subMenuContainerIcons) then Tercio@11: subMenuContainerIcons = {} Tercio@11: frameTable [CoolTip.Indexes] = subMenuContainerIcons Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.isSpecial) then Tercio@11: iconTable = {} Tercio@11: subMenuContainerIcons [CoolTip.SubIndexes] = iconTable Tercio@11: else Tercio@11: iconTable = subMenuContainerIcons [CoolTip.SubIndexes] Tercio@11: if (not iconTable) then Tercio@11: iconTable = {} Tercio@11: subMenuContainerIcons [CoolTip.SubIndexes] = iconTable Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: else Tercio@11: return --> error Tercio@11: end Tercio@11: Tercio@11: iconTable [1] = iconTexture Tercio@11: iconTable [2] = iconWidth or 16 --> default 16 Tercio@11: iconTable [3] = iconHeight or 16 --> default 16 Tercio@11: iconTable [4] = L or 0 --> default 0 Tercio@11: iconTable [5] = R or 1 --> default 1 Tercio@11: iconTable [6] = T or 0 --> default 0 Tercio@11: iconTable [7] = B or 1 --> default 1 Tercio@11: iconTable [8] = overlayColor or _default_color --> default 1, 1, 1 Tercio@11: iconTable [9] = desaturated Tercio@11: Tercio@11: return true Tercio@11: end Tercio@11: Tercio@11: ---------------------------------------------------------------------- Tercio@20: --> popup frame Tercio@20: function CoolTip:AddPopUpFrame (func_on_show, func_on_hide, param1, param2) Tercio@20: Tercio@20: -- act like a sub menu Tercio@20: if (CoolTip.Indexes > 0) then Tercio@20: CoolTip.PopupFrameTable [CoolTip.Indexes] = {func_on_show or false, func_on_hide or false, param1, param2} Tercio@20: end Tercio@20: Tercio@20: end Tercio@20: Tercio@20: ---------------------------------------------------------------------- Tercio@11: --> adds a line. Tercio@11: --> only works with cooltip type 1 and 2 (tooltip and tooltip with bars) Tercio@11: --> parameters: left text, right text [, L color R, L color G, L color B, L color A [, R color R, R color G, R color B, R color A [, wrap]]] Tercio@11: Tercio@11: --> alias Tercio@11: function CoolTip:AddDoubleLine (leftText, rightText, frame, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag) Tercio@11: return CoolTip:AddLine (leftText, rightText, frame, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag) Tercio@11: end Tercio@11: Tercio@11: --> adds a line for tooltips Tercio@11: function CoolTip:AddLine (leftText, rightText, frame, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag) Tercio@11: Tercio@11: --> check data integrity Tercio@11: local t = type (leftText) Tercio@11: if (t ~= "string") then Tercio@11: if (t == "number") then Tercio@11: leftText = tostring (leftText) Tercio@11: else Tercio@11: leftText = "" Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: local t = type (rightText) Tercio@11: if (t ~= "string") then Tercio@11: if (t == "number") then Tercio@11: rightText = tostring (rightText) Tercio@11: else Tercio@11: rightText = "" Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: if (type (ColorR1) ~= "number") then Tercio@11: ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag = ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2 Tercio@11: Tercio@11: if (type (ColorR1) == "boolean" or not ColorR1) then Tercio@11: ColorR1, ColorG1, ColorB1, ColorA1 = 0, 0, 0, 0 Tercio@11: else Tercio@11: ColorR1, ColorG1, ColorB1, ColorA1 = DF:ParseColors (ColorR1) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: if (type (ColorR2) ~= "number") then Tercio@11: fontSize, fontFace, fontFlag = ColorG2, ColorB2, ColorA2 Tercio@11: Tercio@11: if (type (ColorR2) == "boolean" or not ColorR2) then Tercio@11: ColorR2, ColorG2, ColorB2, ColorA2 = 0, 0, 0, 0 Tercio@11: else Tercio@11: ColorR2, ColorG2, ColorB2, ColorA2 = DF:ParseColors (ColorR2) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: local frameTableLeft Tercio@11: local frameTableRight Tercio@11: local lineTable_left Tercio@11: local lineTable_right Tercio@11: Tercio@11: if (not frame or (type (frame) == "string" and frame == "main") or (type (frame) == "number" and frame == 1)) then Tercio@11: Tercio@11: CoolTip.Indexes = CoolTip.Indexes + 1 Tercio@11: Tercio@11: if (not CoolTip.IndexesSub [CoolTip.Indexes]) then Tercio@11: CoolTip.IndexesSub [CoolTip.Indexes] = 0 Tercio@11: end Tercio@11: Tercio@11: CoolTip.SubIndexes = 0 Tercio@11: Tercio@11: frameTableLeft = CoolTip.LeftTextTable Tercio@11: frameTableRight = CoolTip.RightTextTable Tercio@11: Tercio@11: if (CoolTip.isSpecial) then Tercio@11: lineTable_left = {} Tercio@11: _table_insert (frameTableLeft, CoolTip.Indexes, lineTable_left) Tercio@11: lineTable_right = {} Tercio@11: _table_insert (frameTableRight, CoolTip.Indexes, lineTable_right) Tercio@11: else Tercio@11: lineTable_left = frameTableLeft [CoolTip.Indexes] Tercio@11: lineTable_right = frameTableRight [CoolTip.Indexes] Tercio@11: Tercio@11: if (not lineTable_left) then Tercio@11: lineTable_left = {} Tercio@11: _table_insert (frameTableLeft, CoolTip.Indexes, lineTable_left) Tercio@11: end Tercio@11: if (not lineTable_right) then Tercio@11: lineTable_right = {} Tercio@11: _table_insert (frameTableRight, CoolTip.Indexes, lineTable_right) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: elseif ((type (frame) == "string" and frame == "sub") or (type (frame) == "number" and frame == 2)) then Tercio@11: Tercio@11: CoolTip.SubIndexes = CoolTip.SubIndexes + 1 Tercio@11: CoolTip.IndexesSub [CoolTip.Indexes] = CoolTip.IndexesSub [CoolTip.Indexes] + 1 Tercio@11: CoolTip.HaveSubMenu = true Tercio@11: Tercio@11: frameTableLeft = CoolTip.LeftTextTableSub Tercio@11: frameTableRight = CoolTip.RightTextTableSub Tercio@11: Tercio@11: local subMenuContainerTexts = frameTableLeft [CoolTip.Indexes] Tercio@11: if (not subMenuContainerTexts) then Tercio@11: subMenuContainerTexts = {} Tercio@11: _table_insert (frameTableLeft, CoolTip.Indexes, subMenuContainerTexts) Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.isSpecial) then Tercio@11: lineTable_left = {} Tercio@11: _table_insert (subMenuContainerTexts, CoolTip.SubIndexes, lineTable_left) Tercio@11: else Tercio@11: lineTable_left = subMenuContainerTexts [CoolTip.SubIndexes] Tercio@11: if (not lineTable_left) then Tercio@11: lineTable_left = {} Tercio@11: --subMenuContainerTexts [CoolTip.SubIndexes] = lineTable_left Tercio@11: _table_insert (subMenuContainerTexts, CoolTip.SubIndexes, lineTable_left) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: local subMenuContainerTexts = frameTableRight [CoolTip.Indexes] Tercio@11: if (not subMenuContainerTexts) then Tercio@11: subMenuContainerTexts = {} Tercio@11: _table_insert (frameTableRight, CoolTip.Indexes, subMenuContainerTexts) Tercio@11: --frameTableRight [CoolTip.Indexes] = subMenuContainerTexts Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.isSpecial) then Tercio@11: lineTable_right = {} Tercio@11: _table_insert (subMenuContainerTexts, CoolTip.SubIndexes, lineTable_right) Tercio@11: else Tercio@11: lineTable_right = subMenuContainerTexts [CoolTip.SubIndexes] Tercio@11: if (not lineTable_right) then Tercio@11: lineTable_right = {} Tercio@11: _table_insert (subMenuContainerTexts, CoolTip.SubIndexes, lineTable_right) Tercio@11: --subMenuContainerTexts [CoolTip.SubIndexes] = lineTable_right Tercio@11: end Tercio@11: end Tercio@11: else Tercio@11: return --> error Tercio@11: end Tercio@11: Tercio@11: lineTable_left [1] = leftText --> line text Tercio@11: lineTable_left [2] = ColorR1 Tercio@11: lineTable_left [3] = ColorG1 Tercio@11: lineTable_left [4] = ColorB1 Tercio@11: lineTable_left [5] = ColorA1 Tercio@11: lineTable_left [6] = fontSize Tercio@11: lineTable_left [7] = fontFace Tercio@11: lineTable_left [8] = fontFlag Tercio@11: Tercio@11: lineTable_right [1] = rightText --> line text Tercio@11: lineTable_right [2] = ColorR2 Tercio@11: lineTable_right [3] = ColorG2 Tercio@11: lineTable_right [4] = ColorB2 Tercio@11: lineTable_right [5] = ColorA2 Tercio@11: lineTable_right [6] = fontSize Tercio@11: lineTable_right [7] = fontFace Tercio@11: lineTable_right [8] = fontFlag Tercio@11: end Tercio@11: Tercio@11: function CoolTip:AddSpecial (widgetType, index, subIndex, ...) Tercio@11: Tercio@11: local currentIndex = CoolTip.Indexes Tercio@11: local currentSubIndex = CoolTip.SubIndexes Tercio@11: CoolTip.isSpecial = true Tercio@11: Tercio@11: widgetType = string.lower (widgetType) Tercio@11: Tercio@11: if (widgetType == "line") then Tercio@11: Tercio@11: if (subIndex) then Tercio@11: CoolTip.Indexes = index Tercio@11: CoolTip.SubIndexes = subIndex-1 Tercio@11: else Tercio@11: CoolTip.Indexes = index-1 Tercio@11: end Tercio@11: Tercio@11: CoolTip:AddLine (...) Tercio@11: Tercio@11: if (subIndex) then Tercio@11: CoolTip.Indexes = currentIndex Tercio@11: CoolTip.SubIndexes = currentSubIndex+1 Tercio@11: else Tercio@11: CoolTip.Indexes = currentIndex+1 Tercio@11: end Tercio@11: Tercio@11: elseif (widgetType == "icon") then Tercio@11: Tercio@11: CoolTip.Indexes = index Tercio@11: if (subIndex) then Tercio@11: CoolTip.SubIndexes = subIndex Tercio@11: end Tercio@11: Tercio@11: CoolTip:AddIcon (...) Tercio@11: Tercio@11: CoolTip.Indexes = currentIndex Tercio@11: if (subIndex) then Tercio@11: CoolTip.SubIndexes = currentSubIndex Tercio@11: end Tercio@11: Tercio@11: elseif (widgetType == "statusbar") then Tercio@11: Tercio@11: CoolTip.Indexes = index Tercio@11: if (subIndex) then Tercio@11: CoolTip.SubIndexes = subIndex Tercio@11: end Tercio@11: Tercio@11: CoolTip:AddStatusBar (...) Tercio@11: Tercio@11: CoolTip.Indexes = currentIndex Tercio@11: if (subIndex) then Tercio@11: CoolTip.SubIndexes = currentSubIndex Tercio@11: end Tercio@11: Tercio@11: elseif (widgetType == "menu") then Tercio@11: Tercio@11: CoolTip.Indexes = index Tercio@11: if (subIndex) then Tercio@11: CoolTip.SubIndexes = subIndex Tercio@11: end Tercio@11: Tercio@11: CoolTip:AddMenu (...) Tercio@11: Tercio@11: CoolTip.Indexes = currentIndex Tercio@11: if (subIndex) then Tercio@11: CoolTip.SubIndexes = currentSubIndex Tercio@11: end Tercio@11: Tercio@11: end Tercio@11: Tercio@11: CoolTip.isSpecial = false Tercio@11: Tercio@11: end Tercio@11: Tercio@11: --> search key: ~fromline Tercio@11: function CoolTip:AddFromTable (_table) Tercio@11: for index, menu in _ipairs (_table) do Tercio@11: if (menu.func) then Tercio@11: CoolTip:AddMenu (menu.type or 1, menu.func, menu.param1, menu.param2, menu.param3, nil, menu.icon) Tercio@11: elseif (menu.statusbar) then Tercio@11: CoolTip:AddStatusBar (menu.value, menu.type or 1, menu.color, true) Tercio@11: elseif (menu.icon) then Tercio@11: CoolTip:AddIcon (menu.icon, menu.type or 1, menu.side or 1, menu.width, menu.height, menu.l, menu.r, menu.t, menu.b, menu.color) Tercio@11: elseif (menu.textleft or menu.textright or menu.text) then Tercio@11: CoolTip:AddLine (menu.text, "", menu.type, menu.color, menu.color) Tercio@11: end Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: ---------------------------------------------------------------------- Tercio@11: --> show cooltip Tercio@11: Tercio@11: --> serach key: ~start Tercio@11: function CoolTip:Show (frame, menuType, color) Tercio@20: CoolTip.had_interaction = false Tercio@11: return CoolTip:ShowCooltip (frame, menuType, color) Tercio@11: end Tercio@11: Tercio@11: function CoolTip:ShowCooltip (frame, menuType, color) Tercio@11: Tercio@40: frame1:SetFrameStrata ("TOOLTIP") Tercio@40: frame2:SetFrameStrata ("TOOLTIP") Tercio@40: frame1:SetParent (UIParent) Tercio@40: frame2:SetParent (UIParent) Tercio@40: Tercio@20: CoolTip.had_interaction = false Tercio@20: Tercio@11: if (frame) then Tercio@11: --> details framework Tercio@11: if (frame.dframework) then Tercio@11: frame = frame.widget Tercio@11: end Tercio@11: CoolTip:SetHost (frame) Tercio@11: end Tercio@11: if (menuType) then Tercio@11: CoolTip:SetType (menuType) Tercio@11: end Tercio@11: if (color) then Tercio@11: CoolTip:SetColor (1, color) Tercio@11: CoolTip:SetColor (2, color) Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.Type == 1 or CoolTip.Type == 2) then Tercio@11: return CoolTip:monta_tooltip() Tercio@11: Tercio@11: elseif (CoolTip.Type == 3) then Tercio@11: return CoolTip:monta_cooltip() Tercio@11: Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: local emptyOptions = {} Tercio@11: Tercio@11: function CoolTip:Hide() Tercio@11: return CoolTip:Close() Tercio@11: end Tercio@11: Tercio@11: function CoolTip:Close() Tercio@11: CoolTip.active = false Tercio@11: CoolTip.Host = nil Tercio@26: DF:FadeFrame (frame1, 1) Tercio@26: DF:FadeFrame (frame2, 1) Tercio@11: end Tercio@11: Tercio@53: Tercio@53: Tercio@11: --> old function call Tercio@11: function CoolTip:ShowMe (host, arg2) Tercio@11: --> ignore if mouse is up me Tercio@11: if (CoolTip.mouseOver) then Tercio@11: return Tercio@11: end Tercio@11: Tercio@11: if (not host or not arg2) then --> hideme Tercio@11: CoolTip:Close() Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: --> search key: ~inject Tercio@11: function CoolTip:ExecFunc (host, fromClick) Tercio@11: Tercio@11: if (host.dframework) then Tercio@11: if (not host.widget.CoolTip) then Tercio@11: host.widget.CoolTip = host.CoolTip Tercio@11: end Tercio@11: host = host.widget Tercio@11: end Tercio@11: Tercio@11: CoolTip:Reset() Tercio@11: CoolTip:SetType (host.CoolTip.Type) Tercio@11: CoolTip:SetFixedParameter (host.CoolTip.FixedValue) Tercio@11: CoolTip:SetColor ("main", host.CoolTip.MainColor or "transparent") Tercio@11: CoolTip:SetColor ("sec", host.CoolTip.SubColor or "transparent") Tercio@11: Tercio@56: local okay, errortext = pcall (host.CoolTip.BuildFunc, host, host.CoolTip and host.CoolTip.FixedValue) --resetting anchors Tercio@56: if (not okay) then Tercio@56: print ("Cooltip Injected Fucntion Error:", errortext) Tercio@56: end Tercio@56: Tercio@11: CoolTip:SetOwner (host, host.CoolTip.MyAnchor, host.CoolTip.HisAnchor, host.CoolTip.X, host.CoolTip.Y) Tercio@11: Tercio@11: local options = host.CoolTip.Options Tercio@11: if (type (options) == "function") then Tercio@11: options = options() Tercio@11: end Tercio@11: if (options) then Tercio@11: for optionName, optionValue in pairs (options) do Tercio@11: CoolTip:SetOption (optionName, optionValue) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: if (CoolTip.Indexes == 0) then Tercio@11: if (host.CoolTip.Default) then Tercio@11: CoolTip:SetType ("tooltip") Tercio@11: CoolTip:AddLine (host.CoolTip.Default, nil, 1, "white") Tercio@11: end Tercio@11: end Tercio@56: Tercio@11: CoolTip:ShowCooltip() Tercio@11: Tercio@11: if (fromClick) then Tercio@11: --UIFrameFlash (frame1, ) Tercio@11: frame1:Flash (0.05, 0.05, 0.2, true, 0, 0) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: local wait = 0.2 Tercio@11: Tercio@11: local InjectOnUpdateEnter = function (self, elapsed) Tercio@11: elapsedTime = elapsedTime+elapsed Tercio@11: if (elapsedTime > wait) then Tercio@11: self:SetScript ("OnUpdate", nil) Tercio@11: CoolTip:ExecFunc (self) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: local InjectOnUpdateLeave = function (self, elapsed) Tercio@11: elapsedTime = elapsedTime+elapsed Tercio@11: if (elapsedTime > 0.2) then Tercio@11: if (not CoolTip.mouseOver and not CoolTip.buttonOver and self == CoolTip.Host) then Tercio@11: CoolTip:ShowMe (false) Tercio@11: end Tercio@11: self:SetScript ("OnUpdate", nil) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: local InjectOnLeave = function (self) Tercio@11: CoolTip.buttonOver = false Tercio@11: Tercio@11: if (CoolTip.active) then Tercio@11: elapsedTime = 0 Tercio@11: self:SetScript ("OnUpdate", InjectOnUpdateLeave) Tercio@11: else Tercio@11: self:SetScript ("OnUpdate", nil) Tercio@11: end Tercio@11: Tercio@11: if (self.CoolTip.OnLeaveFunc) then Tercio@11: self.CoolTip.OnLeaveFunc (self) Tercio@11: end Tercio@11: Tercio@11: if (self.OldOnLeaveScript) then Tercio@11: self:OldOnLeaveScript() Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: local InjectOnEnter = function (self) Tercio@11: CoolTip.buttonOver = true Tercio@11: if (CoolTip.active) then Tercio@11: CoolTip:ExecFunc (self) Tercio@11: else Tercio@11: elapsedTime = 0 Tercio@11: wait = self.CoolTip.ShowSpeed or 0.2 Tercio@11: self:SetScript ("OnUpdate", InjectOnUpdateEnter) Tercio@11: end Tercio@11: Tercio@11: if (self.CoolTip.OnEnterFunc) then Tercio@11: self.CoolTip.OnEnterFunc (self) Tercio@11: end Tercio@11: Tercio@11: if (self.OldOnEnterScript) then Tercio@11: self:OldOnEnterScript() Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: function CoolTip:CoolTipInject (host, openOnClick) Tercio@11: if (host.dframework) then Tercio@11: if (not host.widget.CoolTip) then Tercio@11: host.widget.CoolTip = host.CoolTip Tercio@11: end Tercio@11: host = host.widget Tercio@11: end Tercio@11: Tercio@11: local coolTable = host.CoolTip Tercio@11: if (not coolTable) then Tercio@11: print ("Host nao tem uma CoolTable.") Tercio@11: return false Tercio@11: end Tercio@11: Tercio@11: host.OldOnEnterScript = host:GetScript ("OnEnter") Tercio@11: host.OldOnLeaveScript = host:GetScript ("OnLeave") Tercio@11: Tercio@11: host:SetScript ("OnEnter", InjectOnEnter) Tercio@11: host:SetScript ("OnLeave", InjectOnLeave) Tercio@11: Tercio@11: if (openOnClick) then Tercio@11: if (host:GetObjectType() == "Button") then Tercio@11: host:SetScript ("OnClick", function() CoolTip:ExecFunc (host, true) end) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: return ture Tercio@11: end Tercio@11: Tercio@11: --> all done Tercio@11: CoolTip:ClearAllOptions() Tercio@11: Tercio@39: -- local preset2_backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = DF.folder .. "border_3", tile=true, Tercio@39: -- edgeSize = 16, tileSize = 64, insets = {left = 3, right = 3, top = 4, bottom = 4}} Tercio@11: Tercio@39: local preset2_backdrop = {bgFile = DF.folder .. "background", edgeFile = [[Interface\Buttons\WHITE8X8]], tile = true, Tercio@39: edgeSize = 1, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}} Tercio@39: local default_backdrop_color = {0.09019, 0.09019, 0.18823, 0.8} Tercio@39: local default_backdropborder_color = {1, 1, 1, 1} Tercio@39: Tercio@39: local gray_table = {0.37, 0.37, 0.37, 0.95} Tercio@11: local white_table = {1, 1, 1, 1} Tercio@39: local black_table = {0.2, 0.2, 0.2, 1} Tercio@11: Tercio@11: function CoolTip:Preset (number) Tercio@11: self:Reset() Tercio@11: Tercio@11: if (number == 1) then Tercio@11: self:SetOption ("TextFont", "Friz Quadrata TT") Tercio@11: self:SetOption ("TextColor", "orange") Tercio@11: self:SetOption ("TextSize", 12) Tercio@11: self:SetOption ("ButtonsYMod", -4) Tercio@11: self:SetOption ("YSpacingMod", -4) Tercio@11: self:SetOption ("IgnoreButtonAutoHeight", true) Tercio@11: self:SetColor (1, 0.5, 0.5, 0.5, 0.5) Tercio@11: Tercio@11: elseif (number == 2) then Tercio@11: self:SetOption ("TextFont", "Friz Quadrata TT") Tercio@11: self:SetOption ("TextColor", "orange") Tercio@11: self:SetOption ("TextSize", 12) Tercio@11: self:SetOption ("FixedWidth", 220) Tercio@11: self:SetOption ("ButtonsYMod", -4) Tercio@11: self:SetOption ("YSpacingMod", -4) Tercio@11: self:SetOption ("IgnoreButtonAutoHeight", true) Tercio@11: Tercio@39: self:SetColor (1, 0.5, 0.5, 0.5, 0) Tercio@39: Tercio@39: self:SetBackdrop (1, preset2_backdrop, gray_table, black_table) Tercio@40: self:SetBackdrop (2, preset2_backdrop, gray_table, black_table) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: return CoolTip Tercio@11: Tercio@11: end Tercio@11: Tercio@58: DF:CreateCoolTip()