annotate Libs/DF/cooltip.lua @ 26:e16b1fc13935

- framework update.
author Tercio
date Fri, 16 Oct 2015 14:46:27 -0300
parents dc1c77254f80
children 5da06cb420d4
rev   line source
Tercio@11 1
Tercio@11 2 local DF = _G ["DetailsFramework"]
Tercio@20 3 if (not DF or not DetailsFrameworkCanLoad) then
Tercio@20 4 return
Tercio@20 5 end
Tercio@20 6
Tercio@11 7 local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
Tercio@11 8 local _
Tercio@11 9 --lua locals
Tercio@11 10 local _math_floor= math.floor
Tercio@11 11 local _type = type
Tercio@11 12 local _math_abs = math.abs
Tercio@11 13 local _tinsert = tinsert
Tercio@11 14 local _unpack = unpack
Tercio@11 15 local _ipairs = ipairs
Tercio@11 16 local _table_wipe = table.wipe
Tercio@11 17 local _table_insert = table.insert
Tercio@11 18 local _math_max = math.max
Tercio@11 19 --api locals
Tercio@11 20 local _GetScreenWidth = GetScreenWidth
Tercio@11 21 local _GetScreenHeight = GetScreenHeight
Tercio@11 22 local _UIParent = UIParent
Tercio@11 23 local _CreateFrame = CreateFrame
Tercio@11 24
Tercio@20 25 local version = 2
Tercio@11 26
Tercio@11 27 function DF:CreateCoolTip()
Tercio@11 28
Tercio@11 29 ----------------------------------------------------------------------
Tercio@11 30 --> Cooltip Startup
Tercio@11 31 ----------------------------------------------------------------------
Tercio@11 32
Tercio@11 33 if (_G.GameCooltip2 and _G.GameCooltip2.version >= version) then
Tercio@11 34 return
Tercio@11 35 end
Tercio@11 36
Tercio@11 37 --> Start Cooltip Table
Tercio@11 38 local CoolTip = {version = version}
Tercio@11 39 _G.GameCooltip2 = CoolTip
Tercio@11 40
Tercio@11 41 --> Containers
Tercio@11 42 CoolTip.LeftTextTable = {}
Tercio@11 43 CoolTip.LeftTextTableSub = {}
Tercio@11 44 CoolTip.RightTextTable = {}
Tercio@11 45 CoolTip.RightTextTableSub = {}
Tercio@11 46 CoolTip.LeftIconTable = {}
Tercio@11 47 CoolTip.LeftIconTableSub = {}
Tercio@11 48 CoolTip.RightIconTable = {}
Tercio@11 49 CoolTip.RightIconTableSub = {}
Tercio@11 50 CoolTip.Banner = {false, false, false}
Tercio@11 51 CoolTip.TopIconTableSub = {}
Tercio@11 52 CoolTip.StatusBarTable = {}
Tercio@11 53 CoolTip.StatusBarTableSub = {}
Tercio@11 54 CoolTip.WallpaperTable = {}
Tercio@11 55 CoolTip.WallpaperTableSub = {}
Tercio@11 56
Tercio@20 57 CoolTip.PopupFrameTable = {}
Tercio@20 58
Tercio@11 59 CoolTip.FunctionsTableMain = {} --> menus
Tercio@11 60 CoolTip.FunctionsTableSub = {} --> menus
Tercio@11 61 CoolTip.ParametersTableMain = {} --> menus
Tercio@11 62 CoolTip.ParametersTableSub = {} --> menus
Tercio@11 63
Tercio@11 64 CoolTip.FixedValue = nil --> menus
Tercio@11 65 CoolTip.SelectedIndexMain = nil --> menus
Tercio@11 66 CoolTip.SelectedIndexSec = {} --> menus
Tercio@11 67
Tercio@11 68 --options table
Tercio@11 69 CoolTip.OptionsList = {
Tercio@11 70 ["IconSize"] = true,
Tercio@11 71 ["HeightAnchorMod"] = true,
Tercio@11 72 ["WidthAnchorMod"] = true,
Tercio@11 73 ["MinWidth"] = true,
Tercio@11 74 ["FixedWidth"] = true,
Tercio@11 75 ["FixedHeight"] = true,
Tercio@11 76 ["FixedWidthSub"] = true,
Tercio@11 77 ["FixedHeightSub"] = true,
Tercio@11 78 ["AlignAsBlizzTooltip"] = true,
Tercio@11 79 ["IgnoreSubMenu"] = true,
Tercio@11 80 ["IgnoreButtonAutoHeight"] = true,
Tercio@11 81 ["TextHeightMod"] = true,
Tercio@11 82 ["ButtonHeightMod"] = true,
Tercio@11 83 ["ButtonHeightModSub"] = true,
Tercio@11 84 ["YSpacingMod"] = true,
Tercio@11 85 ["YSpacingModSub"] = true,
Tercio@11 86 ["ButtonsYMod"] = true,
Tercio@11 87 ["ButtonsYModSub"] = true,
Tercio@11 88 ["IconHeightMod"] = true,
Tercio@11 89 ["StatusBarHeightMod"] = true,
Tercio@11 90 ["StatusBarTexture"] = true,
Tercio@11 91 ["TextSize"] = true,
Tercio@11 92 ["TextFont"] = true,
Tercio@11 93 ["TextColor"] = true,
Tercio@11 94 ["TextColorRight"] = true,
Tercio@11 95 ["TextShadow"] = true,
Tercio@11 96 ["LeftTextWidth"] = true,
Tercio@11 97 ["RightTextWidth"] = true,
Tercio@11 98 ["LeftTextHeight"] = true,
Tercio@11 99 ["RightTextHeight"] = true,
Tercio@11 100 ["NoFade"] = true,
Tercio@11 101 ["MyAnchor"] = true,
Tercio@11 102 ["Anchor"] = true,
Tercio@11 103 ["RelativeAnchor"] = true,
Tercio@11 104 ["NoLastSelectedBar"] = true,
Tercio@11 105 ["SubMenuIsTooltip"] = true,
Tercio@11 106 ["LeftBorderSize"] = true,
Tercio@11 107 ["RightBorderSize"] = true,
Tercio@11 108 ["HeighMod"] = true,
Tercio@11 109 ["HeighModSub"] = true,
Tercio@11 110 ["IconBlendMode"] = true,
Tercio@11 111 ["IconBlendModeHover"] = true,
Tercio@11 112 ["SubFollowButton"] = true,
Tercio@11 113 ["IgnoreArrows"] = true,
Tercio@11 114 ["SelectedTopAnchorMod"] = true,
Tercio@11 115 ["SelectedBottomAnchorMod"] = true,
Tercio@11 116 ["SelectedLeftAnchorMod"] = true,
Tercio@11 117 ["SelectedRightAnchorMod"] = true,
Tercio@11 118 }
Tercio@11 119
Tercio@11 120 CoolTip.OptionsTable = {}
Tercio@11 121
Tercio@11 122 --cprops
Tercio@11 123 CoolTip.Indexes = 0 --> amount of lines current on shown
Tercio@11 124 CoolTip.IndexesSub = {} --> amount of lines current on shown
Tercio@11 125 CoolTip.HaveSubMenu = false --> amount of lines current on shown
Tercio@11 126 CoolTip.SubIndexes = 0 --> amount of lines current on shown on sub menu
Tercio@11 127 CoolTip.Type = 1 --> 1 tooltip 2 tooltip with bars 3 menu 4 menu + submenus
Tercio@11 128 CoolTip.Host = nil --> frame to anchor
Tercio@11 129 CoolTip.LastSize = 0 --> last size
Tercio@11 130
Tercio@11 131 CoolTip.LastIndex = 0
Tercio@11 132
Tercio@11 133 CoolTip.internal_x_mod = 0
Tercio@11 134 CoolTip.internal_y_mod = 0
Tercio@11 135 CoolTip.overlap_checked = false
Tercio@11 136
Tercio@11 137 --defaults
Tercio@11 138 CoolTip.default_height = 20
Tercio@11 139 CoolTip.default_text_size = 10.5
Tercio@11 140 CoolTip.default_text_font = "GameFontHighlight"
Tercio@11 141
Tercio@11 142 CoolTip.selected_anchor = {}
Tercio@11 143 CoolTip.selected_anchor.left = 2
Tercio@11 144 CoolTip.selected_anchor.right = 0
Tercio@11 145 CoolTip.selected_anchor.top = 0
Tercio@11 146 CoolTip.selected_anchor.bottom = 0
Tercio@11 147
Tercio@11 148 CoolTip._default_font = SharedMedia:Fetch ("font", "Friz Quadrata TT")
Tercio@11 149
Tercio@11 150 --> Create Frames
Tercio@11 151
Tercio@11 152 --> main frame
Tercio@11 153 local frame1
Tercio@11 154 if (not GameCooltipFrame1) then
Tercio@11 155 frame1 = CreateFrame ("Frame", "GameCooltipFrame1", UIParent, "DFCooltipMainFrameTemplate")
Tercio@11 156 tinsert (UISpecialFrames, "GameCooltipFrame1")
Tercio@11 157 DF:CreateFlashAnimation (frame1)
Tercio@11 158 else
Tercio@11 159 frame1 = GameCooltipFrame1
Tercio@11 160 end
Tercio@11 161
Tercio@11 162 GameCooltipFrame1_FrameBackgroundCenter:SetTexture (DF.folder .. "cooltip_background")
Tercio@11 163 GameCooltipFrame1_FrameBackgroundCenter:SetTexCoord (0.10546875, 0.89453125, 0, 1)
Tercio@11 164 GameCooltipFrame1_FrameBackgroundLeft:SetTexture (DF.folder .. "cooltip_background")
Tercio@11 165 GameCooltipFrame1_FrameBackgroundLeft:SetTexCoord (0, 0.103515625, 0, 1)
Tercio@11 166 GameCooltipFrame1_FrameBackgroundRight:SetTexture (DF.folder .. "cooltip_background")
Tercio@11 167 GameCooltipFrame1_FrameBackgroundRight:SetTexCoord (0.896484375, 1, 0, 1)
Tercio@11 168
Tercio@11 169 --> secondary frame
Tercio@11 170 local frame2
Tercio@11 171 if (not GameCooltipFrame2) then
Tercio@11 172 frame2 = CreateFrame ("Frame", "GameCooltipFrame2", UIParent, "DFCooltipMainFrameTemplate")
Tercio@11 173 tinsert (UISpecialFrames, "GameCooltipFrame2")
Tercio@11 174 DF:CreateFlashAnimation (frame2)
Tercio@11 175 frame2:SetClampedToScreen (true)
Tercio@11 176 else
Tercio@11 177 frame2 = GameCooltipFrame2
Tercio@11 178 end
Tercio@11 179
Tercio@11 180 frame2:SetPoint ("bottomleft", frame1, "bottomright")
Tercio@11 181
Tercio@11 182 GameCooltipFrame2_FrameBackgroundCenter:SetTexture (DF.folder .. "cooltip_background")
Tercio@11 183 GameCooltipFrame2_FrameBackgroundCenter:SetTexCoord (0.10546875, 0.89453125, 0, 1)
Tercio@11 184 GameCooltipFrame2_FrameBackgroundLeft:SetTexture (DF.folder .. "cooltip_background")
Tercio@11 185 GameCooltipFrame2_FrameBackgroundLeft:SetTexCoord (0, 0.103515625, 0, 1)
Tercio@11 186 GameCooltipFrame2_FrameBackgroundRight:SetTexture (DF.folder .. "cooltip_background")
Tercio@11 187 GameCooltipFrame2_FrameBackgroundRight:SetTexCoord (0.896484375, 1, 0, 1)
Tercio@11 188
Tercio@11 189 CoolTip.frame1 = frame1
Tercio@11 190 CoolTip.frame2 = frame2
Tercio@26 191 DF:FadeFrame (frame1, 0)
Tercio@26 192 DF:FadeFrame (frame2, 0)
Tercio@11 193
Tercio@11 194 --> button containers
Tercio@11 195 frame1.Lines = {}
Tercio@11 196 frame2.Lines = {}
Tercio@11 197
Tercio@11 198 ----------------------------------------------------------------------
Tercio@11 199 --> Title Function
Tercio@11 200 ----------------------------------------------------------------------
Tercio@11 201
Tercio@11 202 function CoolTip:SetTitle (_f, text)
Tercio@11 203 if (_f == 1) then
Tercio@11 204 CoolTip.title1 = true
Tercio@11 205 CoolTip.title_text = text
Tercio@11 206 end
Tercio@11 207 end
Tercio@11 208
Tercio@11 209 function CoolTip:SetTitleAnchor (_f, _anchor, ...)
Tercio@11 210 _anchor = string.lower (_anchor)
Tercio@11 211 if (_f == 1) then
Tercio@11 212 self.frame1.titleIcon:ClearAllPoints()
Tercio@11 213 self.frame1.titleText:ClearAllPoints()
Tercio@11 214
Tercio@11 215 if (_anchor == "left") then
Tercio@11 216 self.frame1.titleIcon:SetPoint ("left", frame1, "left", ...)
Tercio@11 217 self.frame1.titleText:SetPoint ("left", frame1.titleIcon, "right")
Tercio@11 218
Tercio@11 219 elseif (_anchor == "center") then
Tercio@11 220 self.frame1.titleIcon:SetPoint ("center", frame1, "center")
Tercio@11 221 self.frame1.titleIcon:SetPoint ("bottom", frame1, "top")
Tercio@11 222 self.frame1.titleText:SetPoint ("left", frame1.titleIcon, "right")
Tercio@11 223 self.frame1.titleText:SetText ("TESTE")
Tercio@11 224
Tercio@11 225 self.frame1.titleText:Show()
Tercio@11 226 self.frame1.titleIcon:Show()
Tercio@11 227
Tercio@11 228 elseif (_anchor == "right") then
Tercio@11 229 self.frame1.titleIcon:SetPoint ("right", frame1, "right", ...)
Tercio@11 230 self.frame1.titleText:SetPoint ("right", frame1.titleIcon, "left")
Tercio@11 231
Tercio@11 232 end
Tercio@11 233 elseif (_f == 2) then
Tercio@11 234 self.frame2.titleIcon:ClearAllPoints()
Tercio@11 235 self.frame2.titleText:ClearAllPoints()
Tercio@11 236 if (_anchor == "left") then
Tercio@11 237 self.frame2.titleIcon:SetPoint ("left", frame2, "left", ...)
Tercio@11 238 self.frame2.titleText:SetPoint ("left", frame2.titleIcon, "right")
Tercio@11 239 elseif (_anchor == "center") then
Tercio@11 240 self.frame2.titleIcon:SetPoint ("center", frame2, "center", ...)
Tercio@11 241 self.frame2.titleText:SetPoint ("left", frame2.titleIcon, "right")
Tercio@11 242 elseif (_anchor == "right") then
Tercio@11 243 self.frame2.titleIcon:SetPoint ("right", frame2, "right", ...)
Tercio@11 244 self.frame2.titleText:SetPoint ("right", frame2.titleIcon, "left")
Tercio@11 245 end
Tercio@11 246 end
Tercio@11 247 end
Tercio@11 248
Tercio@11 249 ----------------------------------------------------------------------
Tercio@11 250 --> Button Hide and Show Functions
Tercio@11 251 ----------------------------------------------------------------------
Tercio@11 252
Tercio@11 253 local elapsedTime = 0
Tercio@11 254
Tercio@11 255 CoolTip.mouseOver = false
Tercio@11 256 CoolTip.buttonClicked = false
Tercio@11 257
Tercio@11 258 frame1:SetScript ("OnEnter", function (self)
Tercio@11 259 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then --> menu
Tercio@11 260 CoolTip.active = true
Tercio@11 261 CoolTip.mouseOver = true
Tercio@20 262 CoolTip.had_interaction = true
Tercio@11 263 self:SetScript ("OnUpdate", nil)
Tercio@26 264 DF:FadeFrame (self, 0)
Tercio@11 265 --rever
Tercio@11 266 if (CoolTip.sub_menus) then
Tercio@26 267 DF:FadeFrame (frame2, 0)
Tercio@11 268 end
Tercio@11 269 end
Tercio@11 270 end)
Tercio@11 271
Tercio@11 272 frame2:SetScript ("OnEnter", function (self)
Tercio@11 273 if (CoolTip.OptionsTable.SubMenuIsTooltip) then
Tercio@11 274 return CoolTip:Close()
Tercio@11 275 end
Tercio@11 276 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
Tercio@11 277 CoolTip.active = true
Tercio@11 278 CoolTip.mouseOver = true
Tercio@20 279 CoolTip.had_interaction = true
Tercio@11 280 self:SetScript ("OnUpdate", nil)
Tercio@26 281 DF:FadeFrame (self, 0)
Tercio@26 282 DF:FadeFrame (frame1, 0)
Tercio@11 283 end
Tercio@11 284 end)
Tercio@11 285
Tercio@11 286 local OnLeaveUpdateFrame1 = function (self, elapsed)
Tercio@11 287 elapsedTime = elapsedTime+elapsed
Tercio@11 288 if (elapsedTime > 0.7) then
Tercio@11 289 if (not CoolTip.active and not CoolTip.buttonClicked and self == CoolTip.Host) then
Tercio@26 290 DF:FadeFrame (self, 1)
Tercio@26 291 DF:FadeFrame (frame2, 1)
Tercio@11 292 elseif (not CoolTip.active) then
Tercio@26 293 DF:FadeFrame (self, 1)
Tercio@26 294 DF:FadeFrame (frame2, 1)
Tercio@11 295 end
Tercio@11 296 self:SetScript ("OnUpdate", nil)
Tercio@11 297 frame2:SetScript ("OnUpdate", nil)
Tercio@11 298 end
Tercio@11 299 end
Tercio@11 300
Tercio@11 301 frame1:SetScript ("OnLeave", function (self)
Tercio@11 302
Tercio@11 303 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
Tercio@11 304 CoolTip.active = false
Tercio@11 305 CoolTip.mouseOver = false
Tercio@11 306 elapsedTime = 0
Tercio@11 307 self:SetScript ("OnUpdate", OnLeaveUpdateFrame1)
Tercio@11 308 else
Tercio@11 309 CoolTip.active = false
Tercio@11 310 CoolTip.mouseOver = false
Tercio@11 311 elapsedTime = 0
Tercio@11 312 self:SetScript ("OnUpdate", OnLeaveUpdateFrame1)
Tercio@11 313 end
Tercio@11 314 end)
Tercio@11 315
Tercio@11 316 local OnLeaveUpdateFrame2 = function (self, elapsed)
Tercio@11 317 elapsedTime = elapsedTime+elapsed
Tercio@11 318 if (elapsedTime > 0.7) then
Tercio@11 319 if (not CoolTip.active and not CoolTip.buttonClicked and self == CoolTip.Host) then
Tercio@26 320 DF:FadeFrame (self, 1)
Tercio@26 321 DF:FadeFrame (frame2, 1)
Tercio@11 322 elseif (not CoolTip.active) then
Tercio@26 323 DF:FadeFrame (self, 1)
Tercio@26 324 DF:FadeFrame (frame2, 1)
Tercio@11 325 end
Tercio@11 326 self:SetScript ("OnUpdate", nil)
Tercio@11 327 frame1:SetScript ("OnUpdate", nil)
Tercio@11 328 end
Tercio@11 329 end
Tercio@11 330
Tercio@11 331 frame2:SetScript ("OnLeave", function (self)
Tercio@11 332 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
Tercio@11 333 CoolTip.active = false
Tercio@11 334 CoolTip.mouseOver = false
Tercio@11 335 elapsedTime = 0
Tercio@11 336 self:SetScript ("OnUpdate", OnLeaveUpdateFrame2)
Tercio@11 337 else
Tercio@11 338 CoolTip.active = false
Tercio@11 339 CoolTip.mouseOver = false
Tercio@11 340 elapsedTime = 0
Tercio@11 341 self:SetScript ("OnUpdate", OnLeaveUpdateFrame2)
Tercio@11 342
Tercio@11 343 end
Tercio@11 344 end)
Tercio@11 345
Tercio@11 346 frame1:SetScript ("OnHide", function (self)
Tercio@11 347 CoolTip.active = false
Tercio@11 348 CoolTip.buttonClicked = false
Tercio@11 349 CoolTip.mouseOver = false
Tercio@11 350 end)
Tercio@11 351
Tercio@11 352
Tercio@11 353 ----------------------------------------------------------------------
Tercio@11 354 --> Button Creation Functions
Tercio@11 355 ----------------------------------------------------------------------
Tercio@11 356
Tercio@11 357 function GameCooltipButtonMouseDown (button)
Tercio@11 358 local mod = CoolTip.OptionsTable.TextHeightMod or 0
Tercio@11 359 button.leftText:SetPoint ("center", button.leftIcon, "center", 0, 0+mod)
Tercio@11 360 button.leftText:SetPoint ("left", button.leftIcon, "right", 4, -1+mod)
Tercio@11 361 end
Tercio@11 362
Tercio@11 363 function GameCooltipButtonMouseUp (button)
Tercio@11 364 local mod = CoolTip.OptionsTable.TextHeightMod or 0
Tercio@11 365 button.leftText:SetPoint ("center", button.leftIcon, "center", 0, 0+mod)
Tercio@11 366 button.leftText:SetPoint ("left", button.leftIcon, "right", 3, 0+mod)
Tercio@11 367 end
Tercio@11 368
Tercio@11 369 function CoolTip:CreateButton (index, frame, name)
Tercio@11 370 local new_button = CreateFrame ("Button", name, frame, "DFCooltipButtonTemplate")
Tercio@11 371 frame.Lines [index] = new_button
Tercio@11 372 return new_button
Tercio@11 373 end
Tercio@11 374
Tercio@11 375 local OnEnterUpdateButton = function (self, elapsed)
Tercio@11 376 elapsedTime = elapsedTime+elapsed
Tercio@11 377 if (elapsedTime > 0.001) then
Tercio@11 378 --> search key: ~onenterupdatemain
Tercio@11 379 CoolTip:ShowSub (self.index)
Tercio@11 380 CoolTip.last_button = self.index
Tercio@11 381 self:SetScript ("OnUpdate", nil)
Tercio@11 382 end
Tercio@11 383 end
Tercio@11 384
Tercio@11 385 local OnLeaveUpdateButton = function (self, elapsed)
Tercio@11 386 elapsedTime = elapsedTime+elapsed
Tercio@11 387 if (elapsedTime > 0.7) then
Tercio@11 388 if (not CoolTip.active and not CoolTip.buttonClicked) then
Tercio@26 389 DF:FadeFrame (frame1, 1)
Tercio@26 390 DF:FadeFrame (frame2, 1)
Tercio@11 391
Tercio@11 392 elseif (not CoolTip.active) then
Tercio@26 393 DF:FadeFrame (frame1, 1)
Tercio@26 394 DF:FadeFrame (frame2, 1)
Tercio@11 395 end
Tercio@11 396 frame1:SetScript ("OnUpdate", nil)
Tercio@11 397 end
Tercio@11 398 end
Tercio@11 399
Tercio@11 400 function CoolTip:NewMainButton (i)
Tercio@11 401 local botao = CoolTip:CreateButton (i, frame1, "GameCooltipMainButton"..i)
Tercio@11 402
Tercio@11 403 --> serach key: ~onenter
Tercio@11 404 botao:SetScript ("OnEnter", function()
Tercio@11 405 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not botao.isDiv) then
Tercio@11 406 CoolTip.active = true
Tercio@11 407 CoolTip.mouseOver = true
Tercio@20 408 CoolTip.had_interaction = true
Tercio@11 409
Tercio@11 410 frame1:SetScript ("OnUpdate", nil)
Tercio@11 411 frame2:SetScript ("OnUpdate", nil)
Tercio@11 412
Tercio@11 413 botao.background:Show()
Tercio@11 414
Tercio@11 415 if (CoolTip.OptionsTable.IconBlendModeHover) then
Tercio@11 416 botao.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendModeHover)
Tercio@11 417 else
Tercio@11 418 botao.leftIcon:SetBlendMode ("BLEND")
Tercio@11 419 end
Tercio@11 420
Tercio@20 421 if (CoolTip.PopupFrameTable [botao.index]) then
Tercio@20 422 local on_enter, on_leave, param1, param2 = unpack (CoolTip.PopupFrameTable [botao.index])
Tercio@20 423 if (on_enter) then
Tercio@20 424 xpcall (on_enter, geterrorhandler(), frame1, param1, param2)
Tercio@20 425 end
Tercio@20 426
Tercio@20 427 elseif (CoolTip.IndexesSub [botao.index] and CoolTip.IndexesSub [botao.index] > 0) then
Tercio@11 428 if (CoolTip.OptionsTable.SubMenuIsTooltip) then
Tercio@11 429 CoolTip:ShowSub (botao.index)
Tercio@11 430 botao.index = i
Tercio@11 431 else
Tercio@11 432 if (CoolTip.last_button) then
Tercio@11 433 CoolTip:ShowSub (CoolTip.last_button)
Tercio@11 434 else
Tercio@11 435 CoolTip:ShowSub (botao.index)
Tercio@11 436 end
Tercio@11 437 elapsedTime = 0
Tercio@11 438 botao.index = i
Tercio@11 439 botao:SetScript ("OnUpdate", OnEnterUpdateButton)
Tercio@11 440 end
Tercio@11 441
Tercio@11 442 else
Tercio@11 443 --hide second frame
Tercio@26 444 DF:FadeFrame (frame2, 1)
Tercio@11 445 CoolTip.last_button = nil
Tercio@11 446 end
Tercio@11 447 else
Tercio@11 448 CoolTip.mouseOver = true
Tercio@20 449 CoolTip.had_interaction = true
Tercio@11 450 end
Tercio@11 451 end)
Tercio@11 452
Tercio@11 453 botao:SetScript ("OnLeave", function()
Tercio@11 454 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not botao.isDiv) then
Tercio@11 455 CoolTip.active = false
Tercio@11 456 CoolTip.mouseOver = false
Tercio@11 457 botao:SetScript ("OnUpdate", nil)
Tercio@11 458
Tercio@11 459 botao.background:Hide()
Tercio@11 460
Tercio@11 461 if (CoolTip.OptionsTable.IconBlendMode) then
Tercio@11 462 botao.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
Tercio@11 463 botao.rightIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
Tercio@11 464 else
Tercio@11 465 botao.leftIcon:SetBlendMode ("BLEND")
Tercio@11 466 botao.rightIcon:SetBlendMode ("BLEND")
Tercio@11 467 end
Tercio@11 468
Tercio@20 469 if (CoolTip.PopupFrameTable [botao.index]) then
Tercio@20 470 local on_enter, on_leave, param1, param2 = unpack (CoolTip.PopupFrameTable [botao.index])
Tercio@20 471 if (on_leave) then
Tercio@20 472 xpcall (on_leave, geterrorhandler(), frame1, param1, param2)
Tercio@20 473 end
Tercio@20 474 end
Tercio@20 475
Tercio@11 476 elapsedTime = 0
Tercio@11 477 frame1:SetScript ("OnUpdate", OnLeaveUpdateButton)
Tercio@11 478 --CoolTip:HideSub (i)
Tercio@11 479 else
Tercio@11 480 CoolTip.active = false
Tercio@11 481 elapsedTime = 0
Tercio@11 482 frame1:SetScript ("OnUpdate", OnLeaveUpdateButton)
Tercio@11 483 CoolTip.mouseOver = false
Tercio@11 484 end
Tercio@11 485 end)
Tercio@11 486
Tercio@11 487 return botao
Tercio@11 488 end
Tercio@11 489
Tercio@11 490 local OnLeaveUpdateButtonSec = function (self, elapsed)
Tercio@11 491 elapsedTime = elapsedTime+elapsed
Tercio@11 492 if (elapsedTime > 0.7) then
Tercio@11 493 if (not CoolTip.active and not CoolTip.buttonClicked) then
Tercio@26 494 DF:FadeFrame (frame1, 1)
Tercio@26 495 DF:FadeFrame (frame2, 1)
Tercio@11 496 elseif (not CoolTip.active) then
Tercio@26 497 DF:FadeFrame (frame1, 1)
Tercio@26 498 DF:FadeFrame (frame2, 1)
Tercio@11 499 end
Tercio@11 500 frame2:SetScript ("OnUpdate", nil)
Tercio@11 501 end
Tercio@11 502 end
Tercio@11 503
Tercio@11 504 function CoolTip:NewSecondaryButton (i)
Tercio@11 505 local botao = CoolTip:CreateButton (i, frame2, "GameCooltipSecButton"..i)
Tercio@11 506
Tercio@11 507 botao:SetScript ("OnEnter", function()
Tercio@11 508 if (CoolTip.OptionsTable.SubMenuIsTooltip) then
Tercio@11 509 return CoolTip:Close()
Tercio@11 510 end
Tercio@11 511 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not botao.isDiv) then
Tercio@11 512 CoolTip.active = true
Tercio@11 513 CoolTip.mouseOver = true
Tercio@20 514 CoolTip.had_interaction = true
Tercio@11 515
Tercio@11 516 botao.background:Show()
Tercio@11 517
Tercio@11 518 if (CoolTip.OptionsTable.IconBlendModeHover) then
Tercio@11 519 botao.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendModeHover)
Tercio@11 520 else
Tercio@11 521 botao.leftIcon:SetBlendMode ("BLEND")
Tercio@11 522 end
Tercio@11 523
Tercio@11 524 frame1:SetScript ("OnUpdate", nil)
Tercio@11 525 frame2:SetScript ("OnUpdate", nil)
Tercio@11 526
Tercio@26 527 DF:FadeFrame (frame1, 0)
Tercio@26 528 DF:FadeFrame (frame2, 0)
Tercio@11 529 else
Tercio@11 530 CoolTip.mouseOver = true
Tercio@20 531 CoolTip.had_interaction = true
Tercio@11 532 end
Tercio@11 533 end)
Tercio@11 534
Tercio@11 535 botao:SetScript ("OnLeave", function()
Tercio@11 536 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
Tercio@11 537 CoolTip.active = false
Tercio@11 538 CoolTip.mouseOver = false
Tercio@11 539
Tercio@11 540 botao.background:Hide()
Tercio@11 541
Tercio@11 542 if (CoolTip.OptionsTable.IconBlendMode) then
Tercio@11 543 botao.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
Tercio@11 544 botao.rightIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
Tercio@11 545 else
Tercio@11 546 botao.leftIcon:SetBlendMode ("BLEND")
Tercio@11 547 botao.rightIcon:SetBlendMode ("BLEND")
Tercio@11 548 end
Tercio@11 549
Tercio@11 550 elapsedTime = 0
Tercio@11 551 frame2:SetScript ("OnUpdate", OnLeaveUpdateButtonSec)
Tercio@11 552 else
Tercio@11 553 CoolTip.active = false
Tercio@11 554 CoolTip.mouseOver = false
Tercio@11 555 elapsedTime = 0
Tercio@11 556 frame2:SetScript ("OnUpdate", OnLeaveUpdateButtonSec)
Tercio@11 557 end
Tercio@11 558 end)
Tercio@11 559
Tercio@11 560 return botao
Tercio@11 561 end
Tercio@11 562
Tercio@11 563 ----------------------------------------------------------------------
Tercio@11 564 --> Button Click Functions
Tercio@11 565 ----------------------------------------------------------------------
Tercio@11 566
Tercio@11 567 CoolTip.selected_anchor.left = 4
Tercio@11 568 CoolTip.selected_anchor.right = -4
Tercio@11 569 CoolTip.selected_anchor.top = 0
Tercio@11 570 CoolTip.selected_anchor.bottom = 0
Tercio@11 571
Tercio@11 572 function CoolTip:HideSelectedTexture (frame)
Tercio@11 573 frame.selectedTop:Hide()
Tercio@11 574 frame.selectedBottom:Hide()
Tercio@11 575 frame.selectedMiddle:Hide()
Tercio@11 576 end
Tercio@11 577
Tercio@11 578 function CoolTip:ShowSelectedTexture (frame)
Tercio@11 579 frame.selectedTop:Show()
Tercio@11 580 frame.selectedBottom:Show()
Tercio@11 581 frame.selectedMiddle:Show()
Tercio@11 582 end
Tercio@11 583
Tercio@11 584 function CoolTip:SetSelectedAnchor (frame, button)
Tercio@11 585
Tercio@11 586 local left = CoolTip.selected_anchor.left + (CoolTip.OptionsTable.SelectedLeftAnchorMod or 0)
Tercio@11 587 local right = CoolTip.selected_anchor.right + (CoolTip.OptionsTable.SelectedRightAnchorMod or 0)
Tercio@11 588
Tercio@11 589 local top = CoolTip.selected_anchor.top + (CoolTip.OptionsTable.SelectedTopAnchorMod or 0)
Tercio@11 590 local bottom = CoolTip.selected_anchor.bottom + (CoolTip.OptionsTable.SelectedBottomAnchorMod or 0)
Tercio@11 591
Tercio@11 592 frame.selectedTop:ClearAllPoints()
Tercio@11 593 frame.selectedBottom:ClearAllPoints()
Tercio@11 594
Tercio@11 595 frame.selectedTop:SetPoint ("topleft", button, "topleft", left, top) --
Tercio@11 596 frame.selectedTop:SetPoint ("topright", button, "topright", right, top) --
Tercio@11 597
Tercio@11 598 frame.selectedBottom:SetPoint ("bottomleft", button, "bottomleft", left, bottom) --
Tercio@11 599 frame.selectedBottom:SetPoint ("bottomright", button, "bottomright", right, bottom) --
Tercio@11 600
Tercio@11 601 CoolTip:ShowSelectedTexture (frame)
Tercio@11 602 end
Tercio@11 603
Tercio@11 604 local OnClickFunctionButtonPrincipal = function (self)
Tercio@11 605 if (CoolTip.IndexesSub [self.index] and CoolTip.IndexesSub [self.index] > 0) then
Tercio@11 606 CoolTip:ShowSub (self.index)
Tercio@11 607 CoolTip.last_button = self.index
Tercio@11 608 end
Tercio@11 609
Tercio@11 610 CoolTip.buttonClicked = true
Tercio@11 611 CoolTip:SetSelectedAnchor (frame1, self)
Tercio@11 612
Tercio@11 613 if (not CoolTip.OptionsTable.NoLastSelectedBar) then
Tercio@11 614 CoolTip:ShowSelectedTexture (frame1)
Tercio@11 615
Tercio@11 616 end
Tercio@11 617 CoolTip.SelectedIndexMain = self.index
Tercio@11 618
Tercio@11 619 if (CoolTip.FunctionsTableMain [self.index]) then
Tercio@11 620 local parameterTable = CoolTip.ParametersTableMain [self.index]
Tercio@11 621 CoolTip.FunctionsTableMain [self.index] (_, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3])
Tercio@11 622 end
Tercio@11 623 end
Tercio@11 624
Tercio@11 625 local OnClickFunctionButtonSecundario = function (self)
Tercio@11 626 CoolTip.buttonClicked = true
Tercio@11 627
Tercio@11 628 CoolTip:SetSelectedAnchor (frame2, self)
Tercio@11 629
Tercio@11 630 if (CoolTip.FunctionsTableSub [self.mainIndex] and CoolTip.FunctionsTableSub [self.mainIndex] [self.index]) then
Tercio@11 631 local parameterTable = CoolTip.ParametersTableSub [self.mainIndex] [self.index]
Tercio@11 632 CoolTip.FunctionsTableSub [self.mainIndex] [self.index] (_, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3])
Tercio@11 633 end
Tercio@11 634
Tercio@11 635 local botao_p = frame1.Lines [self.mainIndex]
Tercio@11 636 CoolTip:SetSelectedAnchor (frame1, botao_p)
Tercio@11 637
Tercio@11 638 if (not CoolTip.OptionsTable.NoLastSelectedBar) then
Tercio@11 639 CoolTip:ShowSelectedTexture (frame1)
Tercio@11 640 end
Tercio@11 641
Tercio@11 642 CoolTip.SelectedIndexMain = self.mainIndex
Tercio@11 643 CoolTip.SelectedIndexSec [self.mainIndex] = self.index
Tercio@11 644
Tercio@11 645 end
Tercio@11 646
Tercio@11 647 function CoolTip:TextAndIcon (index, frame, menuButton, leftTextTable, rightTextTable, leftIconTable, rightIconTable, isSub)
Tercio@11 648
Tercio@11 649 --> reset width
Tercio@11 650 menuButton.leftText:SetWidth (0)
Tercio@11 651 menuButton.leftText:SetHeight (0)
Tercio@11 652 menuButton.rightText:SetWidth (0)
Tercio@11 653 menuButton.rightText:SetHeight (0)
Tercio@11 654
Tercio@11 655 --> set text
Tercio@11 656 if (leftTextTable) then
Tercio@11 657
Tercio@11 658 menuButton.leftText:SetText (leftTextTable [1])
Tercio@11 659
Tercio@11 660 local r, g, b, a = leftTextTable [2], leftTextTable [3], leftTextTable [4], leftTextTable [5]
Tercio@11 661
Tercio@11 662 if (r == 0 and g == 0 and b == 0 and a == 0) then
Tercio@11 663 if (CoolTip.OptionsTable.TextColor) then
Tercio@11 664 r, g, b, a = DF:ParseColors (CoolTip.OptionsTable.TextColor)
Tercio@11 665 menuButton.leftText:SetTextColor (r, g, b, a)
Tercio@11 666 else
Tercio@11 667 menuButton.leftText:SetTextColor (1, 1, 1, 1)
Tercio@11 668 end
Tercio@11 669 else
Tercio@11 670 menuButton.leftText:SetTextColor (r, g, b, a)
Tercio@11 671 end
Tercio@11 672
Tercio@11 673 if (CoolTip.OptionsTable.TextSize and not leftTextTable [6]) then
Tercio@11 674 DF:SetFontSize (menuButton.leftText, CoolTip.OptionsTable.TextSize)
Tercio@11 675 end
Tercio@11 676
Tercio@11 677 if (CoolTip.OptionsTable.LeftTextWidth) then
Tercio@11 678 menuButton.leftText:SetWidth (CoolTip.OptionsTable.LeftTextWidth)
Tercio@11 679 else
Tercio@11 680 menuButton.leftText:SetWidth (0)
Tercio@11 681 end
Tercio@11 682
Tercio@11 683 if (CoolTip.OptionsTable.LeftTextHeight) then
Tercio@11 684 menuButton.leftText:SetHeight (CoolTip.OptionsTable.LeftTextHeight)
Tercio@11 685 else
Tercio@11 686 menuButton.leftText:SetHeight (0)
Tercio@11 687 end
Tercio@11 688
Tercio@11 689 if (CoolTip.OptionsTable.TextFont and not leftTextTable [7]) then --font
Tercio@11 690
Tercio@11 691 if (_G [CoolTip.OptionsTable.TextFont]) then
Tercio@11 692 menuButton.leftText:SetFontObject (GameFontRed or CoolTip.OptionsTable.TextFont)
Tercio@11 693 else
Tercio@11 694 local font = SharedMedia:Fetch ("font", CoolTip.OptionsTable.TextFont)
Tercio@11 695 local _, size, flags = menuButton.leftText:GetFont()
Tercio@11 696 flags = leftTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
Tercio@11 697 size = leftTextTable [6] or CoolTip.OptionsTable.TextSize or size
Tercio@11 698 menuButton.leftText:SetFont (font, size, flags)
Tercio@11 699 end
Tercio@11 700
Tercio@11 701 elseif (leftTextTable [7]) then
Tercio@11 702 if (_G [leftTextTable [7]]) then
Tercio@11 703 menuButton.leftText:SetFontObject (leftTextTable [7])
Tercio@11 704 local face, size, flags = menuButton.leftText:GetFont()
Tercio@11 705 flags = leftTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
Tercio@11 706 size = leftTextTable [6] or CoolTip.OptionsTable.TextSize or size
Tercio@11 707 menuButton.leftText:SetFont (face, size, flags)
Tercio@11 708 else
Tercio@11 709 local font = SharedMedia:Fetch ("font", leftTextTable [7])
Tercio@11 710 local face, size, flags = menuButton.leftText:GetFont()
Tercio@11 711 flags = leftTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
Tercio@11 712 size = leftTextTable [6] or CoolTip.OptionsTable.TextSize or size
Tercio@11 713 menuButton.leftText:SetFont (face, size, flags)
Tercio@11 714 end
Tercio@11 715 else
Tercio@11 716 menuButton.leftText:SetFont (CoolTip._default_font, leftTextTable [6] or CoolTip.OptionsTable.TextSize or 10, leftTextTable [8] or CoolTip.OptionsTable.TextShadow)
Tercio@11 717 end
Tercio@11 718
Tercio@11 719 local height_mod = CoolTip.OptionsTable.TextHeightMod or 0
Tercio@11 720 menuButton.leftText:SetPoint ("center", menuButton.leftIcon, "center", 0, 0+height_mod)
Tercio@11 721 menuButton.leftText:SetPoint ("left", menuButton.leftIcon, "right", 3, 0+height_mod)
Tercio@11 722
Tercio@11 723 else
Tercio@11 724 menuButton.leftText:SetText ("")
Tercio@11 725 end
Tercio@11 726
Tercio@11 727 if (rightTextTable) then
Tercio@11 728 menuButton.rightText:SetText (rightTextTable [1])
Tercio@11 729
Tercio@11 730 local r, g, b, a = rightTextTable [2], rightTextTable [3], rightTextTable [4], rightTextTable [5]
Tercio@11 731
Tercio@11 732 if (r == 0 and g == 0 and b == 0 and a == 0) then
Tercio@11 733
Tercio@11 734 if (CoolTip.OptionsTable.TextColorRight) then
Tercio@11 735 r, g, b, a = DF:ParseColors (CoolTip.OptionsTable.TextColorRight)
Tercio@11 736 menuButton.rightText:SetTextColor (r, g, b, a)
Tercio@11 737 elseif (CoolTip.OptionsTable.TextColor) then
Tercio@11 738 r, g, b, a = DF:ParseColors (CoolTip.OptionsTable.TextColor)
Tercio@11 739 menuButton.rightText:SetTextColor (r, g, b, a)
Tercio@11 740 else
Tercio@11 741 menuButton.rightText:SetTextColor (1, 1, 1, 1)
Tercio@11 742 end
Tercio@11 743 else
Tercio@11 744 menuButton.rightText:SetTextColor (r, g, b, a)
Tercio@11 745 end
Tercio@11 746
Tercio@11 747 if (CoolTip.OptionsTable.TextSize and not rightTextTable [6]) then
Tercio@11 748 DF:SetFontSize (menuButton.rightText, CoolTip.OptionsTable.TextSize)
Tercio@11 749 end
Tercio@11 750
Tercio@11 751 if (CoolTip.OptionsTable.RightTextWidth) then
Tercio@11 752 menuButton.rightText:SetWidth (CoolTip.OptionsTable.RightTextWidth)
Tercio@11 753 else
Tercio@11 754 menuButton.rightText:SetWidth (0)
Tercio@11 755 end
Tercio@11 756
Tercio@11 757 if (CoolTip.OptionsTable.RightTextHeight) then
Tercio@11 758 menuButton.rightText:SetHeight (CoolTip.OptionsTable.RightTextHeight)
Tercio@11 759 else
Tercio@11 760 menuButton.rightText:SetHeight (0)
Tercio@11 761 end
Tercio@11 762
Tercio@11 763 if (CoolTip.OptionsTable.TextFont and not rightTextTable [7]) then
Tercio@11 764 if (_G [CoolTip.OptionsTable.TextFont]) then
Tercio@11 765 menuButton.rightText:SetFontObject (CoolTip.OptionsTable.TextFont)
Tercio@11 766 else
Tercio@11 767 local font = SharedMedia:Fetch ("font", CoolTip.OptionsTable.TextFont)
Tercio@11 768 local _, size, flags = menuButton.rightText:GetFont()
Tercio@11 769 flags = rightTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
Tercio@11 770 size = rightTextTable [6] or CoolTip.OptionsTable.TextSize or size
Tercio@11 771 menuButton.rightText:SetFont (font, size, flags)
Tercio@11 772 end
Tercio@11 773
Tercio@11 774 elseif (rightTextTable [7]) then
Tercio@11 775 if (_G [rightTextTable [7]]) then
Tercio@11 776 menuButton.rightText:SetFontObject (rightTextTable [7])
Tercio@11 777 local face, size, flags = menuButton.rightText:GetFont()
Tercio@11 778 flags = rightTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
Tercio@11 779 size = rightTextTable [6] or CoolTip.OptionsTable.TextSize or size
Tercio@11 780 menuButton.rightText:SetFont (face, size, flags)
Tercio@11 781 else
Tercio@11 782 local font = SharedMedia:Fetch ("font", rightTextTable [7])
Tercio@11 783 local face, size, flags = menuButton.rightText:GetFont()
Tercio@11 784 flags = rightTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
Tercio@11 785 size = rightTextTable [6] or CoolTip.OptionsTable.TextSize or size
Tercio@11 786 menuButton.rightText:SetFont (face, size, flags)
Tercio@11 787 end
Tercio@11 788
Tercio@11 789 else
Tercio@11 790 menuButton.rightText:SetFont (CoolTip._default_font, rightTextTable [6] or CoolTip.OptionsTable.TextSize or 10, rightTextTable [8] or CoolTip.OptionsTable.TextShadow)
Tercio@11 791 end
Tercio@11 792
Tercio@11 793
Tercio@11 794 else
Tercio@11 795 menuButton.rightText:SetText ("")
Tercio@11 796 end
Tercio@11 797
Tercio@11 798 --> left icon
Tercio@11 799 if (leftIconTable and leftIconTable [1]) then
Tercio@11 800 menuButton.leftIcon:SetTexture (leftIconTable [1])
Tercio@11 801 menuButton.leftIcon:SetWidth (leftIconTable [2])
Tercio@11 802 menuButton.leftIcon:SetHeight (leftIconTable [3])
Tercio@11 803 menuButton.leftIcon:SetTexCoord (leftIconTable [4], leftIconTable [5], leftIconTable [6], leftIconTable [7])
Tercio@11 804
Tercio@11 805 local ColorR, ColorG, ColorB, ColorA = DF:ParseColors (leftIconTable [8])
Tercio@11 806 menuButton.leftIcon:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
Tercio@11 807
Tercio@11 808 if (CoolTip.OptionsTable.IconBlendMode) then
Tercio@11 809 menuButton.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
Tercio@11 810 else
Tercio@11 811 menuButton.leftIcon:SetBlendMode ("BLEND")
Tercio@11 812 end
Tercio@11 813
Tercio@11 814 menuButton.leftIcon:SetDesaturated (leftIconTable [9])
Tercio@11 815 else
Tercio@11 816 menuButton.leftIcon:SetTexture (nil)
Tercio@11 817 menuButton.leftIcon:SetWidth (1)
Tercio@11 818 menuButton.leftIcon:SetHeight (1)
Tercio@11 819 end
Tercio@11 820
Tercio@11 821 --> right icon
Tercio@11 822 if (rightIconTable and rightIconTable [1]) then
Tercio@11 823 menuButton.rightIcon:SetTexture (rightIconTable [1])
Tercio@11 824 menuButton.rightIcon:SetWidth (rightIconTable [2])
Tercio@11 825 menuButton.rightIcon:SetHeight (rightIconTable [3])
Tercio@11 826 menuButton.rightIcon:SetTexCoord (rightIconTable [4], rightIconTable [5], rightIconTable [6], rightIconTable [7])
Tercio@11 827
Tercio@11 828 local ColorR, ColorG, ColorB, ColorA = DF:ParseColors (rightIconTable [8])
Tercio@11 829 menuButton.rightIcon:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
Tercio@11 830
Tercio@11 831 if (CoolTip.OptionsTable.IconBlendMode) then
Tercio@11 832 menuButton.rightIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
Tercio@11 833 else
Tercio@11 834 menuButton.rightIcon:SetBlendMode ("BLEND")
Tercio@11 835 end
Tercio@11 836
Tercio@11 837 menuButton.rightIcon:SetDesaturated (rightIconTable [9])
Tercio@11 838 else
Tercio@11 839 menuButton.rightIcon:SetTexture (nil)
Tercio@11 840 menuButton.rightIcon:SetWidth (1)
Tercio@11 841 menuButton.rightIcon:SetHeight (1)
Tercio@11 842 end
Tercio@11 843
Tercio@11 844 --> overwrite icon size
Tercio@11 845 if (CoolTip.OptionsTable.IconSize) then
Tercio@11 846 menuButton.leftIcon:SetWidth (CoolTip.OptionsTable.IconSize)
Tercio@11 847 menuButton.leftIcon:SetHeight (CoolTip.OptionsTable.IconSize)
Tercio@11 848 menuButton.rightIcon:SetWidth (CoolTip.OptionsTable.IconSize)
Tercio@11 849 menuButton.rightIcon:SetHeight (CoolTip.OptionsTable.IconSize)
Tercio@11 850 end
Tercio@11 851
Tercio@11 852 if (CoolTip.Type == 2) then
Tercio@11 853 CoolTip:LeftTextSpace (menuButton)
Tercio@11 854 end
Tercio@11 855
Tercio@11 856 --> string length
Tercio@11 857 if (not isSub) then --> main frame
Tercio@11 858 if (not CoolTip.OptionsTable.FixedWidth) then
Tercio@11 859 if (CoolTip.Type == 1 or CoolTip.Type == 2) then
Tercio@11 860 local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth() + 10
Tercio@11 861 if (stringWidth > frame.w) then
Tercio@11 862 frame.w = stringWidth
Tercio@11 863 end
Tercio@11 864 end
Tercio@11 865 else
Tercio@11 866 menuButton.leftText:SetWidth (CoolTip.OptionsTable.FixedWidth - menuButton.leftIcon:GetWidth() - menuButton.rightText:GetStringWidth() - menuButton.rightIcon:GetWidth() - 30)
Tercio@11 867 end
Tercio@11 868 else
Tercio@11 869 if (not CoolTip.OptionsTable.FixedWidthSub) then
Tercio@11 870 if (CoolTip.Type == 1 or CoolTip.Type == 2) then
Tercio@11 871 local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth()
Tercio@11 872 if (stringWidth > frame.w) then
Tercio@11 873 frame.w = stringWidth
Tercio@11 874 end
Tercio@11 875 end
Tercio@11 876 else
Tercio@11 877 menuButton.leftText:SetWidth (CoolTip.OptionsTable.FixedWidthSub - menuButton.leftIcon:GetWidth() - 20)
Tercio@11 878 end
Tercio@11 879 end
Tercio@11 880
Tercio@11 881 local height = _math_max ( menuButton.leftIcon:GetHeight(), menuButton.rightIcon:GetHeight(), menuButton.leftText:GetStringHeight(), menuButton.rightText:GetStringHeight() )
Tercio@11 882 if (height > frame.hHeight) then
Tercio@11 883 frame.hHeight = height
Tercio@11 884 end
Tercio@11 885
Tercio@11 886 end
Tercio@11 887
Tercio@11 888 function CoolTip:RefreshSpark (menuButton)
Tercio@11 889 menuButton.spark:ClearAllPoints()
Tercio@11 890 menuButton.spark:SetPoint ("LEFT", menuButton.statusbar, "LEFT", (menuButton.statusbar:GetValue() * (menuButton.statusbar:GetWidth() / 100)) - 3, 0)
Tercio@11 891 menuButton.spark2:ClearAllPoints()
Tercio@11 892 menuButton.spark2:SetPoint ("left", menuButton.statusbar, "left", menuButton.statusbar:GetValue() * (menuButton.statusbar:GetWidth()/100) - 16, 0)
Tercio@11 893 end
Tercio@11 894
Tercio@11 895 function CoolTip:StatusBar (menuButton, StatusBar)
Tercio@11 896
Tercio@11 897 if (StatusBar) then
Tercio@11 898
Tercio@11 899 menuButton.statusbar:SetValue (StatusBar [1])
Tercio@11 900 menuButton.statusbar:SetStatusBarColor (StatusBar [2], StatusBar [3], StatusBar [4], StatusBar [5])
Tercio@11 901 menuButton.statusbar:SetHeight (20 + (CoolTip.OptionsTable.StatusBarHeightMod or 0))
Tercio@11 902
Tercio@11 903 menuButton.spark2:Hide()
Tercio@11 904 if (StatusBar [6]) then
Tercio@11 905 menuButton.spark:Show()
Tercio@11 906 --menuButton.spark:ClearAllPoints()
Tercio@11 907 --menuButton.spark:SetPoint ("LEFT", menuButton.statusbar, "LEFT", (StatusBar [1] * (menuButton.statusbar:GetWidth() / 100)) - 3, 0)
Tercio@11 908 else
Tercio@11 909 menuButton.spark:Hide()
Tercio@11 910 end
Tercio@11 911
Tercio@11 912 if (StatusBar [7]) then
Tercio@11 913 menuButton.statusbar2:SetValue (StatusBar[7].value)
Tercio@11 914 menuButton.statusbar2.texture:SetTexture (StatusBar[7].texture or [[Interface\RaidFrame\Raid-Bar-Hp-Fill]])
Tercio@11 915 if (StatusBar[7].specialSpark) then
Tercio@11 916 menuButton.spark2:Show()
Tercio@11 917 end
Tercio@11 918 if (StatusBar[7].color) then
Tercio@11 919 local ColorR, ColorG, ColorB, ColorA = DF:ParseColors (StatusBar[7].color)
Tercio@11 920 menuButton.statusbar2:SetStatusBarColor (ColorR, ColorG, ColorB, ColorA)
Tercio@11 921 else
Tercio@11 922 menuButton.statusbar2:SetStatusBarColor (1, 1, 1, 1)
Tercio@11 923 end
Tercio@11 924 else
Tercio@11 925 menuButton.statusbar2:SetValue (0)
Tercio@11 926 menuButton.spark2:Hide()
Tercio@11 927 end
Tercio@11 928
Tercio@11 929 if (CoolTip.OptionsTable.StatusBarTexture) then
Tercio@11 930 menuButton.statusbar.texture:SetTexture (CoolTip.OptionsTable.StatusBarTexture)
Tercio@11 931 else
Tercio@11 932 menuButton.statusbar.texture:SetTexture ("Interface\\PaperDollInfoFrame\\UI-Character-Skills-Bar")
Tercio@11 933 end
Tercio@11 934
Tercio@11 935 else
Tercio@11 936 menuButton.statusbar:SetValue (0)
Tercio@11 937 menuButton.statusbar2:SetValue (0)
Tercio@11 938 menuButton.spark:Hide()
Tercio@11 939 menuButton.spark2:Hide()
Tercio@11 940 end
Tercio@11 941
Tercio@11 942 if (CoolTip.OptionsTable.LeftBorderSize) then
Tercio@11 943 menuButton.statusbar:SetPoint ("left", menuButton, "left", 10 + CoolTip.OptionsTable.LeftBorderSize, 0)
Tercio@11 944 else
Tercio@11 945 menuButton.statusbar:SetPoint ("left", menuButton, "left", 10, 0)
Tercio@11 946 end
Tercio@11 947
Tercio@11 948 if (CoolTip.OptionsTable.RightBorderSize) then
Tercio@11 949 menuButton.statusbar:SetPoint ("right", menuButton, "right", CoolTip.OptionsTable.RightBorderSize + (- 10), 0)
Tercio@11 950 else
Tercio@11 951 menuButton.statusbar:SetPoint ("right", menuButton, "right", -10, 0)
Tercio@11 952 end
Tercio@11 953 end
Tercio@11 954
Tercio@11 955 function CoolTip:SetupMainButton (menuButton, index)
Tercio@11 956 menuButton.index = index
Tercio@11 957
Tercio@11 958 --> setup texts and icons
Tercio@11 959 CoolTip:TextAndIcon (index, frame1, menuButton, CoolTip.LeftTextTable [index], CoolTip.RightTextTable [index], CoolTip.LeftIconTable [index], CoolTip.RightIconTable [index])
Tercio@11 960 --> setup statusbar
Tercio@11 961 CoolTip:StatusBar (menuButton, CoolTip.StatusBarTable [index])
Tercio@11 962
Tercio@11 963 --> click
Tercio@11 964 menuButton:RegisterForClicks ("LeftButtonDown")
Tercio@11 965
Tercio@11 966 --> string length
Tercio@11 967 if (not CoolTip.OptionsTable.FixedWidth) then
Tercio@11 968 local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth()
Tercio@11 969 if (stringWidth > frame1.w) then
Tercio@11 970 frame1.w = stringWidth
Tercio@11 971 end
Tercio@11 972 end
Tercio@11 973
Tercio@11 974 --> register click function
Tercio@11 975 menuButton:SetScript ("OnClick", OnClickFunctionButtonPrincipal)
Tercio@11 976 menuButton:Show()
Tercio@11 977 end
Tercio@11 978
Tercio@11 979 function CoolTip:SetupSecondaryButton (menuButton, index, mainMenuIndex)
Tercio@11 980
Tercio@11 981 menuButton.index = index
Tercio@11 982 menuButton.mainIndex = mainMenuIndex
Tercio@11 983
Tercio@11 984 --> setup texts and icons
Tercio@11 985 CoolTip:TextAndIcon (index, frame2, menuButton, CoolTip.LeftTextTableSub [mainMenuIndex] and CoolTip.LeftTextTableSub [mainMenuIndex] [index],
Tercio@11 986 CoolTip.RightTextTableSub [mainMenuIndex] and CoolTip.RightTextTableSub [mainMenuIndex] [index],
Tercio@11 987 CoolTip.LeftIconTableSub [mainMenuIndex] and CoolTip.LeftIconTableSub [mainMenuIndex] [index],
Tercio@11 988 CoolTip.RightIconTableSub [mainMenuIndex] and CoolTip.RightIconTableSub [mainMenuIndex] [index], true)
Tercio@11 989 --> setup statusbar
Tercio@11 990 CoolTip:StatusBar (menuButton, CoolTip.StatusBarTableSub [mainMenuIndex] and CoolTip.StatusBarTableSub [mainMenuIndex] [index])
Tercio@11 991
Tercio@11 992
Tercio@11 993 --> click
Tercio@11 994 menuButton:RegisterForClicks ("LeftButtonDown")
Tercio@11 995
Tercio@11 996 menuButton:ClearAllPoints()
Tercio@11 997 menuButton:SetPoint ("center", frame2, "center")
Tercio@11 998 menuButton:SetPoint ("top", frame2, "top", 0, (((index-1)*20)*-1)-3)
Tercio@11 999 menuButton:SetPoint ("left", frame2, "left")
Tercio@11 1000 menuButton:SetPoint ("right", frame2, "right")
Tercio@11 1001
Tercio@26 1002 DF:FadeFrame (menuButton, 0)
Tercio@11 1003
Tercio@11 1004 --> string length
Tercio@11 1005 local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth()
Tercio@11 1006 if (stringWidth > frame2.w) then
Tercio@11 1007 frame2.w = stringWidth
Tercio@11 1008 end
Tercio@11 1009
Tercio@11 1010 menuButton:SetScript ("OnClick", OnClickFunctionButtonSecundario)
Tercio@11 1011 menuButton:Show()
Tercio@11 1012
Tercio@11 1013 return true
Tercio@11 1014 end
Tercio@11 1015
Tercio@11 1016 -- -- --------------------------------------------------------------------------------------------------------------
Tercio@11 1017
Tercio@11 1018 function CoolTip:SetupWallpaper (wallpaperTable, wallpaper)
Tercio@11 1019 local texture = wallpaperTable [1]
Tercio@11 1020 if (DF:IsHtmlColor (texture) or type (texture) == "table") then
Tercio@11 1021 local r, g, b, a = DF:ParseColors (texture)
Tercio@11 1022 wallpaper:SetTexture (r, g, b, a)
Tercio@11 1023 else
Tercio@11 1024 wallpaper:SetTexture (texture)
Tercio@11 1025 end
Tercio@11 1026
Tercio@11 1027 wallpaper:SetTexCoord (wallpaperTable[2], wallpaperTable[3], wallpaperTable[4], wallpaperTable[5])
Tercio@11 1028
Tercio@11 1029 local color = wallpaperTable[6]
Tercio@11 1030 if (color) then
Tercio@11 1031 local r, g, b, a = DF:ParseColors (color)
Tercio@11 1032 wallpaper:SetVertexColor (r, g, b, a)
Tercio@11 1033 else
Tercio@11 1034 wallpaper:SetVertexColor (1, 1, 1, 1)
Tercio@11 1035 end
Tercio@11 1036
Tercio@11 1037 if (wallpaperTable[7]) then
Tercio@11 1038 wallpaper:SetDesaturated (true)
Tercio@11 1039 else
Tercio@11 1040 wallpaper:SetDesaturated (false)
Tercio@11 1041 end
Tercio@11 1042
Tercio@11 1043 wallpaper:Show()
Tercio@11 1044 end
Tercio@11 1045
Tercio@11 1046 -- -- --------------------------------------------------------------------------------------------------------------
Tercio@11 1047
Tercio@11 1048 function CoolTip:ShowSub (index)
Tercio@11 1049
Tercio@11 1050 if (CoolTip.OptionsTable.IgnoreSubMenu) then
Tercio@26 1051 DF:FadeFrame (frame2, 1)
Tercio@11 1052 return
Tercio@11 1053 end
Tercio@11 1054
Tercio@11 1055 frame2:SetHeight (6)
Tercio@11 1056
Tercio@11 1057 local amtIndexes = CoolTip.IndexesSub [index]
Tercio@11 1058 if (not amtIndexes) then
Tercio@11 1059 --print ("Sub menu called but sub menu indexes is nil")
Tercio@11 1060 return
Tercio@11 1061 end
Tercio@11 1062
Tercio@11 1063 if (CoolTip.OptionsTable.FixedWidthSub) then
Tercio@11 1064 frame2:SetWidth (CoolTip.OptionsTable.FixedWidthSub)
Tercio@11 1065 end
Tercio@11 1066
Tercio@11 1067 frame2.h = CoolTip.IndexesSub [index] * 20
Tercio@11 1068 frame2.hHeight = 0
Tercio@11 1069 frame2.w = 0
Tercio@11 1070
Tercio@11 1071 --> pegar a fontsize da label principal
Tercio@11 1072 local mainButton = frame1.Lines [index]
Tercio@11 1073 local fontSize = DF:GetFontSize (mainButton.leftText)
Tercio@11 1074
Tercio@11 1075 local GotChecked = false
Tercio@11 1076
Tercio@11 1077 local IsTooltip = CoolTip.OptionsTable.SubMenuIsTooltip
Tercio@11 1078 if (IsTooltip) then
Tercio@11 1079 frame2:EnableMouse (false)
Tercio@11 1080 else
Tercio@11 1081 frame2:EnableMouse (true)
Tercio@11 1082 end
Tercio@11 1083
Tercio@11 1084 for i = 1, CoolTip.IndexesSub [index] do
Tercio@11 1085
Tercio@11 1086 local button = frame2.Lines [i]
Tercio@11 1087
Tercio@11 1088 if (not button) then
Tercio@11 1089 button = CoolTip:NewSecondaryButton (i)
Tercio@11 1090 end
Tercio@11 1091
Tercio@11 1092 local checked = CoolTip:SetupSecondaryButton (button, i, index)
Tercio@11 1093 if (checked) then
Tercio@11 1094 GotChecked = true
Tercio@11 1095 end
Tercio@11 1096
Tercio@11 1097 if (IsTooltip) then
Tercio@11 1098 button:EnableMouse (false)
Tercio@11 1099 else
Tercio@11 1100 button:EnableMouse (true)
Tercio@11 1101 end
Tercio@11 1102 end
Tercio@11 1103
Tercio@11 1104 local selected = CoolTip.SelectedIndexSec [index]
Tercio@11 1105 if (selected) then
Tercio@11 1106
Tercio@11 1107 CoolTip:SetSelectedAnchor (frame2, frame2.Lines [selected])
Tercio@11 1108
Tercio@11 1109 if (not CoolTip.OptionsTable.NoLastSelectedBar) then
Tercio@11 1110 CoolTip:ShowSelectedTexture (frame2)
Tercio@11 1111 end
Tercio@11 1112 else
Tercio@11 1113 CoolTip:HideSelectedTexture (frame2)
Tercio@11 1114 end
Tercio@11 1115
Tercio@11 1116 for i = CoolTip.IndexesSub [index] + 1, #frame2.Lines do
Tercio@26 1117 DF:FadeFrame (frame2.Lines[i], 1)
Tercio@11 1118 end
Tercio@11 1119
Tercio@11 1120 local spacing = 0
Tercio@11 1121 if (CoolTip.OptionsTable.YSpacingModSub) then
Tercio@11 1122 spacing = CoolTip.OptionsTable.YSpacingModSub
Tercio@11 1123 end
Tercio@11 1124
Tercio@11 1125 --> normalize height of all rows
Tercio@11 1126 for i = 1, CoolTip.IndexesSub [index] do
Tercio@11 1127
Tercio@11 1128 local menuButton = frame2.Lines [i]
Tercio@11 1129
Tercio@11 1130 -- CoolTipFrame2.Lines [2].divbar
Tercio@11 1131
Tercio@11 1132 if (menuButton.leftText:GetText() == "$div") then
Tercio@11 1133
Tercio@11 1134 --> height
Tercio@11 1135 menuButton:SetHeight (4)
Tercio@11 1136
Tercio@11 1137 --> points
Tercio@11 1138 menuButton:ClearAllPoints()
Tercio@11 1139
Tercio@11 1140 menuButton:SetPoint ("center", frame2, "center")
Tercio@11 1141 menuButton:SetPoint ("left", frame2, "left")
Tercio@11 1142 menuButton:SetPoint ("right", frame2, "right")
Tercio@11 1143
Tercio@11 1144 menuButton.rightText:SetText ("")
Tercio@11 1145
Tercio@11 1146 local div_size_up = tonumber (CoolTip.RightTextTableSub [index] [i] [2])
Tercio@11 1147 if (not div_size_up) then
Tercio@11 1148 div_size_up = 0
Tercio@11 1149 end
Tercio@11 1150 local div_size_down = tonumber (CoolTip.RightTextTableSub [index] [i] [3])
Tercio@11 1151 if (not div_size_down) then
Tercio@11 1152 div_size_down = 0
Tercio@11 1153 end
Tercio@11 1154
Tercio@11 1155 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 1156
Tercio@11 1157 if (CoolTip.OptionsTable.YSpacingModSub) then
Tercio@11 1158 spacing = spacing + CoolTip.OptionsTable.YSpacingModSub
Tercio@11 1159 end
Tercio@11 1160
Tercio@11 1161 spacing = spacing + 17 + (div_size_down or 0)
Tercio@11 1162
Tercio@11 1163 menuButton.leftText:SetText ("")
Tercio@11 1164 menuButton.isDiv = true
Tercio@11 1165
Tercio@11 1166 if (not menuButton.divbar) then
Tercio@11 1167 CoolTip:CreateDivBar (menuButton)
Tercio@11 1168 else
Tercio@11 1169 menuButton.divbar:Show()
Tercio@11 1170 end
Tercio@11 1171
Tercio@11 1172 menuButton.divbar:SetPoint ("left", menuButton, "left", frame1:GetWidth()*0.10, 0)
Tercio@11 1173 menuButton.divbar:SetPoint ("right", menuButton, "right", -frame1:GetWidth()*0.10, 0)
Tercio@11 1174
Tercio@11 1175 else
Tercio@11 1176 --> height
Tercio@11 1177 menuButton:SetHeight (frame2.hHeight + (CoolTip.OptionsTable.ButtonHeightModSub or 0))
Tercio@11 1178 --> points
Tercio@11 1179 menuButton:ClearAllPoints()
Tercio@11 1180 menuButton:SetPoint ("center", frame2, "center")
Tercio@11 1181 menuButton:SetPoint ("top", frame2, "top", 0, ( ( (i-1) * frame2.hHeight) * -1) - 4 + (CoolTip.OptionsTable.ButtonsYModSub or 0) + spacing)
Tercio@11 1182 if (CoolTip.OptionsTable.YSpacingModSub) then
Tercio@11 1183 spacing = spacing + CoolTip.OptionsTable.YSpacingModSub
Tercio@11 1184 end
Tercio@11 1185 menuButton:SetPoint ("left", frame2, "left")
Tercio@11 1186 menuButton:SetPoint ("right", frame2, "right")
Tercio@11 1187
Tercio@11 1188 if (menuButton.divbar) then
Tercio@11 1189 menuButton.divbar:Hide()
Tercio@11 1190 menuButton.isDiv = false
Tercio@11 1191 end
Tercio@11 1192 end
Tercio@11 1193
Tercio@11 1194 end
Tercio@11 1195
Tercio@11 1196 local mod = CoolTip.OptionsTable.HeighModSub or 0
Tercio@11 1197 frame2:SetHeight ( (frame2.hHeight * CoolTip.IndexesSub [index]) + 12 + (-spacing) + mod)
Tercio@11 1198
Tercio@11 1199 if (CoolTip.TopIconTableSub [index]) then
Tercio@11 1200 local upperImageTable = CoolTip.TopIconTableSub [index]
Tercio@11 1201 frame2.upperImage:SetTexture (upperImageTable [1])
Tercio@11 1202 frame2.upperImage:SetWidth (upperImageTable [2])
Tercio@11 1203 frame2.upperImage:SetHeight (upperImageTable [3])
Tercio@11 1204 frame2.upperImage:SetTexCoord (upperImageTable[4], upperImageTable[5], upperImageTable[6], upperImageTable[7])
Tercio@11 1205 frame2.upperImage:Show()
Tercio@11 1206 else
Tercio@11 1207 frame2.upperImage:Hide()
Tercio@11 1208 end
Tercio@11 1209
Tercio@11 1210 if (CoolTip.WallpaperTableSub [index]) then
Tercio@11 1211 CoolTip:SetupWallpaper (CoolTip.WallpaperTableSub [index], frame2.frameWallpaper)
Tercio@11 1212 else
Tercio@11 1213 frame2.frameWallpaper:Hide()
Tercio@11 1214 end
Tercio@11 1215
Tercio@11 1216 if (not CoolTip.OptionsTable.FixedWidthSub) then
Tercio@11 1217 frame2:SetWidth (frame2.w + 44)
Tercio@11 1218 end
Tercio@11 1219
Tercio@26 1220 DF:FadeFrame (frame2, 0)
Tercio@11 1221
Tercio@11 1222 CoolTip:CheckOverlap()
Tercio@11 1223
Tercio@11 1224 if (CoolTip.OptionsTable.SubFollowButton and not CoolTip.frame2_leftside) then
Tercio@11 1225
Tercio@11 1226 local button = frame1.Lines [index]
Tercio@11 1227
Tercio@11 1228 frame2:ClearAllPoints()
Tercio@11 1229 frame2:SetPoint ("left", button, "right")
Tercio@11 1230
Tercio@11 1231 elseif (CoolTip.OptionsTable.SubFollowButton and CoolTip.frame2_leftside) then
Tercio@11 1232
Tercio@11 1233 local button = frame1.Lines [index]
Tercio@11 1234
Tercio@11 1235 frame2:ClearAllPoints()
Tercio@11 1236 frame2:SetPoint ("right", button, "left")
Tercio@11 1237
Tercio@11 1238 elseif (CoolTip.frame2_leftside) then
Tercio@11 1239 frame2:ClearAllPoints()
Tercio@11 1240 frame2:SetPoint ("bottomright", frame1, "bottomleft")
Tercio@11 1241 else
Tercio@11 1242 frame2:ClearAllPoints()
Tercio@11 1243 frame2:SetPoint ("bottomleft", frame1, "bottomright")
Tercio@11 1244 end
Tercio@11 1245
Tercio@11 1246 end
Tercio@11 1247
Tercio@11 1248 function CoolTip:HideSub()
Tercio@26 1249 DF:FadeFrame (frame2, 1)
Tercio@11 1250 end
Tercio@11 1251
Tercio@11 1252
Tercio@11 1253 function CoolTip:LeftTextSpace (row)
Tercio@11 1254 row.leftText:SetWidth (row:GetWidth() - 30 - row.leftIcon:GetWidth() - row.rightIcon:GetWidth() - row.rightText:GetStringWidth())
Tercio@11 1255 row.leftText:SetHeight (10)
Tercio@11 1256 end
Tercio@11 1257
Tercio@26 1258 --> ~inicio ~start ~tooltip
Tercio@11 1259 function CoolTip:monta_tooltip()
Tercio@11 1260
Tercio@11 1261 --> hide sub frame
Tercio@26 1262 DF:FadeFrame (frame2, 1)
Tercio@11 1263 --> hide select bar
Tercio@11 1264 CoolTip:HideSelectedTexture (frame1)
Tercio@11 1265
Tercio@11 1266 frame1:EnableMouse (false)
Tercio@11 1267
Tercio@11 1268 --> elevator
Tercio@11 1269 local yDown = 5
Tercio@11 1270 --> width
Tercio@11 1271 if (CoolTip.OptionsTable.FixedWidth) then
Tercio@11 1272 frame1:SetWidth (CoolTip.OptionsTable.FixedWidth)
Tercio@11 1273 end
Tercio@11 1274
Tercio@11 1275 frame1.w = CoolTip.OptionsTable.FixedWidth or 0
Tercio@11 1276 frame1.hHeight = 0
Tercio@11 1277 frame2.hHeight = 0
Tercio@11 1278
Tercio@11 1279 CoolTip.active = true
Tercio@11 1280
Tercio@11 1281 for i = 1, CoolTip.Indexes do
Tercio@11 1282
Tercio@11 1283 local button = frame1.Lines [i]
Tercio@11 1284 if (not button) then
Tercio@11 1285 button = CoolTip:NewMainButton (i)
Tercio@11 1286 end
Tercio@11 1287
Tercio@11 1288 button.index = i
Tercio@11 1289
Tercio@11 1290 --> basic stuff
Tercio@11 1291 button:Show()
Tercio@11 1292 button.background:Hide()
Tercio@11 1293 button:SetHeight (CoolTip.OptionsTable.ButtonHeightMod or CoolTip.default_height)
Tercio@11 1294 button:RegisterForClicks()
Tercio@11 1295
Tercio@11 1296 --> setup texts and icons
Tercio@11 1297 CoolTip:TextAndIcon (i, frame1, button, CoolTip.LeftTextTable [i], CoolTip.RightTextTable [i], CoolTip.LeftIconTable [i], CoolTip.RightIconTable [i])
Tercio@11 1298 --> setup statusbar
Tercio@11 1299 CoolTip:StatusBar (button, CoolTip.StatusBarTable [i])
Tercio@11 1300 end
Tercio@11 1301
Tercio@11 1302 --> hide unused lines
Tercio@11 1303 for i = CoolTip.Indexes+1, #frame1.Lines do
Tercio@11 1304 frame1.Lines[i]:Hide()
Tercio@11 1305 end
Tercio@11 1306 CoolTip.NumLines = CoolTip.Indexes
Tercio@11 1307
Tercio@11 1308 local spacing = 0
Tercio@11 1309 if (CoolTip.OptionsTable.YSpacingMod) then
Tercio@11 1310 spacing = CoolTip.OptionsTable.YSpacingMod
Tercio@11 1311 end
Tercio@11 1312
Tercio@11 1313 --> normalize height of all rows
Tercio@11 1314 local temp = -6 + spacing + (CoolTip.OptionsTable.ButtonsYMod or 0)
Tercio@11 1315 for i = 1, CoolTip.Indexes do
Tercio@11 1316 local menuButton = frame1.Lines [i]
Tercio@11 1317
Tercio@11 1318 menuButton:ClearAllPoints()
Tercio@11 1319 menuButton:SetPoint ("center", frame1, "center")
Tercio@11 1320 menuButton:SetPoint ("left", frame1, "left")
Tercio@11 1321 menuButton:SetPoint ("right", frame1, "right")
Tercio@11 1322
Tercio@11 1323 --> height
Tercio@11 1324 if (CoolTip.OptionsTable.AlignAsBlizzTooltip) then
Tercio@11 1325 local height = _math_max (8, menuButton.leftText:GetStringHeight(), menuButton.rightText:GetStringHeight(), menuButton.leftIcon:GetHeight(), menuButton.rightIcon:GetHeight())
Tercio@11 1326 menuButton:SetHeight (height)
Tercio@11 1327 menuButton:SetPoint ("top", frame1, "top", 0, temp)
Tercio@11 1328 temp = temp + ( height * -1)
Tercio@11 1329
Tercio@11 1330 elseif (CoolTip.OptionsTable.IgnoreButtonAutoHeight) then
Tercio@11 1331
Tercio@11 1332 local height = _math_max (menuButton.leftText:GetStringHeight(), menuButton.rightText:GetStringHeight(), menuButton.leftIcon:GetHeight(), menuButton.rightIcon:GetHeight())
Tercio@11 1333 menuButton:SetHeight (height)
Tercio@11 1334 menuButton:SetPoint ("top", frame1, "top", 0, temp)
Tercio@11 1335
Tercio@11 1336 temp = temp + ( height * -1) + spacing + (CoolTip.OptionsTable.ButtonsYMod or 0)
Tercio@11 1337
Tercio@11 1338 else
Tercio@11 1339 menuButton:SetHeight (frame1.hHeight + (CoolTip.OptionsTable.ButtonHeightMod or 0))
Tercio@11 1340 menuButton:SetPoint ("top", frame1, "top", 0, ( ( (i-1) * frame1.hHeight) * -1) - 6 + (CoolTip.OptionsTable.ButtonsYMod or 0) + spacing)
Tercio@11 1341 end
Tercio@11 1342
Tercio@11 1343 --> points
Tercio@11 1344
Tercio@11 1345 if (CoolTip.OptionsTable.YSpacingMod and not CoolTip.OptionsTable.IgnoreButtonAutoHeight) then
Tercio@11 1346 spacing = spacing + CoolTip.OptionsTable.YSpacingMod
Tercio@11 1347 end
Tercio@11 1348
Tercio@11 1349 menuButton:EnableMouse (false)
Tercio@11 1350 end
Tercio@11 1351
Tercio@11 1352 if (not CoolTip.OptionsTable.FixedWidth) then
Tercio@11 1353 if (CoolTip.Type == 2) then --> with bars
Tercio@11 1354 if (CoolTip.OptionsTable.MinWidth) then
Tercio@11 1355 local w = frame1.w + 34
Tercio@11 1356 frame1:SetWidth (math.max (w, CoolTip.OptionsTable.MinWidth))
Tercio@11 1357 else
Tercio@11 1358 frame1:SetWidth (frame1.w + 34)
Tercio@11 1359 end
Tercio@11 1360 else
Tercio@11 1361 --> width stability check
Tercio@11 1362 local width = frame1.w + 24
Tercio@11 1363 if (width > CoolTip.LastSize-5 and width < CoolTip.LastSize+5) then
Tercio@11 1364 width = CoolTip.LastSize
Tercio@11 1365 else
Tercio@11 1366 CoolTip.LastSize = width
Tercio@11 1367 end
Tercio@11 1368
Tercio@11 1369 if (CoolTip.OptionsTable.MinWidth) then
Tercio@11 1370 frame1:SetWidth (math.max (width, CoolTip.OptionsTable.MinWidth))
Tercio@11 1371 else
Tercio@11 1372 frame1:SetWidth (width)
Tercio@11 1373 end
Tercio@11 1374 end
Tercio@11 1375 end
Tercio@11 1376
Tercio@11 1377 if (CoolTip.OptionsTable.FixedHeight) then
Tercio@11 1378 frame1:SetHeight (CoolTip.OptionsTable.FixedHeight)
Tercio@11 1379 else
Tercio@11 1380 if (CoolTip.OptionsTable.AlignAsBlizzTooltip) then
Tercio@11 1381 frame1:SetHeight ( (temp-10) * -1)
Tercio@11 1382 elseif (CoolTip.OptionsTable.IgnoreButtonAutoHeight) then
Tercio@11 1383 frame1:SetHeight ( (temp+spacing) * -1)
Tercio@11 1384 else
Tercio@11 1385 frame1:SetHeight ( _math_max ( (frame1.hHeight * CoolTip.Indexes) + 12, 22 ))
Tercio@11 1386 end
Tercio@11 1387 end
Tercio@11 1388
Tercio@11 1389 if (CoolTip.WallpaperTable [1]) then
Tercio@11 1390 CoolTip:SetupWallpaper (CoolTip.WallpaperTable, frame1.frameWallpaper)
Tercio@11 1391 else
Tercio@11 1392 frame1.frameWallpaper:Hide()
Tercio@11 1393 end
Tercio@11 1394
Tercio@11 1395 --> unhide frame
Tercio@26 1396 DF:FadeFrame (frame1, 0)
Tercio@11 1397 CoolTip:SetMyPoint (host)
Tercio@11 1398
Tercio@11 1399 --> fix sparks
Tercio@11 1400 for i = 1, CoolTip.Indexes do
Tercio@11 1401 local menuButton = frame1.Lines [i]
Tercio@11 1402 if (menuButton.spark:IsShown() or menuButton.spark2:IsShown()) then
Tercio@11 1403 CoolTip:RefreshSpark (menuButton)
Tercio@11 1404 end
Tercio@11 1405 end
Tercio@11 1406 end
Tercio@11 1407
Tercio@11 1408 function CoolTip:CreateDivBar (button)
Tercio@11 1409 button.divbar = button:CreateTexture (nil, "overlay")
Tercio@11 1410
Tercio@11 1411 button.divbar:SetTexture ([[Interface\QUESTFRAME\AutoQuest-Parts]])
Tercio@11 1412 button.divbar:SetTexCoord (238/512, 445/512, 0/64, 4/64)
Tercio@11 1413
Tercio@11 1414 button.divbar:SetHeight (3)
Tercio@11 1415 button.divbar:SetAlpha (0.1)
Tercio@11 1416
Tercio@11 1417 button.divbar:SetDesaturated (true)
Tercio@11 1418 end
Tercio@11 1419
Tercio@26 1420 --> ~inicio ~start ~menu
Tercio@11 1421 function CoolTip:monta_cooltip (host, instancia, options, sub_menus, icones, tamanho1, tamanho2, font, fontsize)
Tercio@11 1422
Tercio@11 1423 if (CoolTip.Indexes == 0) then
Tercio@11 1424 CoolTip:Reset()
Tercio@11 1425 CoolTip:SetType ("tooltip")
Tercio@11 1426 CoolTip:AddLine ("There is no options.")
Tercio@11 1427 CoolTip:ShowCooltip()
Tercio@11 1428 return
Tercio@11 1429 end
Tercio@11 1430
Tercio@11 1431 if (CoolTip.OptionsTable.FixedWidth) then
Tercio@11 1432 frame1:SetWidth (CoolTip.OptionsTable.FixedWidth)
Tercio@11 1433 end
Tercio@11 1434
Tercio@11 1435 frame1.w = CoolTip.OptionsTable.FixedWidth or 0
Tercio@11 1436 frame1.hHeight = 0
Tercio@11 1437 frame2.hHeight = 0
Tercio@11 1438
Tercio@11 1439 frame1:EnableMouse (true)
Tercio@11 1440
Tercio@11 1441 if (CoolTip.HaveSubMenu) then --> zera o segundo frame
Tercio@11 1442 frame2.w = 0
Tercio@11 1443 frame2:SetHeight (6)
Tercio@11 1444 if (CoolTip.SelectedIndexMain and CoolTip.IndexesSub [CoolTip.SelectedIndexMain] and CoolTip.IndexesSub [CoolTip.SelectedIndexMain] > 0) then
Tercio@26 1445 DF:FadeFrame (frame2, 0)
Tercio@11 1446 else
Tercio@26 1447 DF:FadeFrame (frame2, 1)
Tercio@11 1448 end
Tercio@11 1449 else
Tercio@26 1450 DF:FadeFrame (frame2, 1)
Tercio@11 1451 end
Tercio@11 1452
Tercio@11 1453 CoolTip.active = true
Tercio@11 1454
Tercio@11 1455 for i = 1, CoolTip.Indexes do
Tercio@11 1456 local menuButton = frame1.Lines [i]
Tercio@11 1457 if (not menuButton) then
Tercio@11 1458 menuButton = CoolTip:NewMainButton (i)
Tercio@11 1459 end
Tercio@11 1460
Tercio@11 1461 CoolTip:SetupMainButton (menuButton, i)
Tercio@11 1462
Tercio@11 1463 menuButton.background:Hide()
Tercio@11 1464 end
Tercio@11 1465
Tercio@11 1466 --> selected texture
Tercio@11 1467 if (CoolTip.SelectedIndexMain) then
Tercio@11 1468 CoolTip:SetSelectedAnchor (frame1, frame1.Lines [CoolTip.SelectedIndexMain])
Tercio@11 1469
Tercio@11 1470 if (CoolTip.OptionsTable.NoLastSelectedBar) then
Tercio@11 1471 CoolTip:HideSelectedTexture (frame1)
Tercio@11 1472 else
Tercio@11 1473 CoolTip:ShowSelectedTexture (frame1)
Tercio@11 1474 end
Tercio@11 1475 else
Tercio@11 1476 CoolTip:HideSelectedTexture (frame1)
Tercio@11 1477 end
Tercio@11 1478
Tercio@11 1479 if (CoolTip.Indexes < #frame1.Lines) then
Tercio@11 1480 for i = CoolTip.Indexes+1, #frame1.Lines do
Tercio@11 1481 frame1.Lines[i]:Hide()
Tercio@11 1482 end
Tercio@11 1483 end
Tercio@11 1484
Tercio@11 1485 CoolTip.NumLines = CoolTip.Indexes
Tercio@11 1486
Tercio@11 1487 local spacing = 0
Tercio@11 1488 if (CoolTip.OptionsTable.YSpacingMod) then
Tercio@11 1489 spacing = CoolTip.OptionsTable.YSpacingMod
Tercio@11 1490 end
Tercio@11 1491
Tercio@11 1492 if (not CoolTip.OptionsTable.FixedWidth) then
Tercio@11 1493 if (CoolTip.OptionsTable.MinWidth) then
Tercio@11 1494 local w = frame1.w + 24
Tercio@11 1495 frame1:SetWidth (math.max (w, CoolTip.OptionsTable.MinWidth))
Tercio@11 1496 else
Tercio@11 1497 frame1:SetWidth (frame1.w + 24)
Tercio@11 1498 end
Tercio@11 1499 end
Tercio@11 1500
Tercio@11 1501 --> normalize height of all rows
Tercio@11 1502 for i = 1, CoolTip.Indexes do
Tercio@11 1503 local menuButton = frame1.Lines [i]
Tercio@11 1504 menuButton:EnableMouse (true)
Tercio@11 1505
Tercio@11 1506 if (menuButton.leftText:GetText() == "$div") then
Tercio@11 1507
Tercio@11 1508 --> height
Tercio@11 1509 menuButton:SetHeight (4)
Tercio@11 1510 --> points
Tercio@11 1511 menuButton:ClearAllPoints()
Tercio@11 1512 menuButton:SetPoint ("left", frame1, "left")
Tercio@11 1513 menuButton:SetPoint ("right", frame1, "right")
Tercio@11 1514 menuButton:SetPoint ("center", frame1, "center")
Tercio@11 1515
Tercio@11 1516 local div_size_up = tonumber (CoolTip.LeftTextTable [i] [2])
Tercio@11 1517 if (not div_size_up) then
Tercio@11 1518 div_size_up = 0
Tercio@11 1519 end
Tercio@11 1520 local div_size_down = tonumber (CoolTip.LeftTextTable [i] [3])
Tercio@11 1521 if (not div_size_down) then
Tercio@11 1522 div_size_down = 0
Tercio@11 1523 end
Tercio@11 1524
Tercio@11 1525 menuButton:SetPoint ("top", frame1, "top", 0, ( ( (i-1) * frame1.hHeight) * -1) - 4 + (CoolTip.OptionsTable.ButtonsYMod or 0) + spacing - 4 + div_size_up)
Tercio@11 1526 if (CoolTip.OptionsTable.YSpacingMod) then
Tercio@11 1527 spacing = spacing + CoolTip.OptionsTable.YSpacingMod
Tercio@11 1528 end
Tercio@11 1529
Tercio@11 1530 spacing = spacing + 4 + div_size_down
Tercio@11 1531
Tercio@11 1532 menuButton.leftText:SetText ("")
Tercio@11 1533 menuButton.isDiv = true
Tercio@11 1534
Tercio@11 1535 if (not menuButton.divbar) then
Tercio@11 1536 CoolTip:CreateDivBar (menuButton)
Tercio@11 1537 else
Tercio@11 1538 menuButton.divbar:Show()
Tercio@11 1539 end
Tercio@11 1540
Tercio@11 1541 menuButton.divbar:SetPoint ("left", menuButton, "left", frame1:GetWidth()*0.10, 0)
Tercio@11 1542 menuButton.divbar:SetPoint ("right", menuButton, "right", -frame1:GetWidth()*0.10, 0)
Tercio@11 1543
Tercio@11 1544 else
Tercio@11 1545
Tercio@11 1546 --> height
Tercio@11 1547 menuButton:SetHeight (frame1.hHeight + (CoolTip.OptionsTable.ButtonHeightMod or 0))
Tercio@11 1548 --> points
Tercio@11 1549 menuButton:ClearAllPoints()
Tercio@11 1550 menuButton:SetPoint ("center", frame1, "center")
Tercio@11 1551 menuButton:SetPoint ("top", frame1, "top", 0, ( ( (i-1) * frame1.hHeight) * -1) - 4 + (CoolTip.OptionsTable.ButtonsYMod or 0) + spacing)
Tercio@11 1552 if (CoolTip.OptionsTable.YSpacingMod) then
Tercio@11 1553 spacing = spacing + CoolTip.OptionsTable.YSpacingMod
Tercio@11 1554 end
Tercio@11 1555 menuButton:SetPoint ("left", frame1, "left")
Tercio@11 1556 menuButton:SetPoint ("right", frame1, "right")
Tercio@11 1557
Tercio@11 1558 if (menuButton.divbar) then
Tercio@11 1559 menuButton.divbar:Hide()
Tercio@11 1560 menuButton.isDiv = false
Tercio@11 1561 end
Tercio@11 1562 end
Tercio@11 1563
Tercio@11 1564 end
Tercio@11 1565
Tercio@11 1566 if (CoolTip.OptionsTable.FixedHeight) then
Tercio@11 1567 frame1:SetHeight (CoolTip.OptionsTable.FixedHeight)
Tercio@11 1568 else
Tercio@11 1569 local mod = CoolTip.OptionsTable.HeighMod or 0
Tercio@11 1570 frame1:SetHeight (_math_max ( (frame1.hHeight * CoolTip.Indexes) + 12 + (-spacing) + mod, 22 ))
Tercio@11 1571 end
Tercio@11 1572
Tercio@11 1573 --> sub menu arrows
Tercio@11 1574 if (CoolTip.HaveSubMenu and not CoolTip.OptionsTable.IgnoreArrows and not CoolTip.OptionsTable.SubMenuIsTooltip) then
Tercio@11 1575 for i = 1, CoolTip.Indexes do
Tercio@11 1576 if (CoolTip.IndexesSub [i] and CoolTip.IndexesSub [i] > 0) then
Tercio@11 1577 frame1.Lines [i].statusbar.subMenuArrow:Show()
Tercio@11 1578 else
Tercio@11 1579 frame1.Lines [i].statusbar.subMenuArrow:Hide()
Tercio@11 1580 end
Tercio@11 1581 end
Tercio@11 1582
Tercio@11 1583 frame1:SetWidth (frame1:GetWidth() + 16)
Tercio@11 1584 end
Tercio@11 1585
Tercio@11 1586 frame1:ClearAllPoints()
Tercio@11 1587 CoolTip:SetMyPoint (host)
Tercio@11 1588
Tercio@11 1589 if (CoolTip.title1) then
Tercio@11 1590 CoolTip.frame1.titleText:Show()
Tercio@11 1591 CoolTip.frame1.titleIcon:Show()
Tercio@11 1592 CoolTip.frame1.titleText:SetText (CoolTip.title_text)
Tercio@11 1593 CoolTip.frame1.titleIcon:SetWidth (frame1:GetWidth())
Tercio@11 1594 CoolTip.frame1.titleIcon:SetHeight (40)
Tercio@11 1595 end
Tercio@11 1596
Tercio@11 1597 if (CoolTip.WallpaperTable [1]) then
Tercio@11 1598 CoolTip:SetupWallpaper (CoolTip.WallpaperTable, frame1.frameWallpaper)
Tercio@11 1599 else
Tercio@11 1600 frame1.frameWallpaper:Hide()
Tercio@11 1601 end
Tercio@11 1602
Tercio@26 1603 DF:FadeFrame (frame1, 0)
Tercio@11 1604
Tercio@11 1605 for i = 1, CoolTip.Indexes do
Tercio@11 1606 if (CoolTip.SelectedIndexMain and CoolTip.SelectedIndexMain == i) then
Tercio@11 1607 if (CoolTip.HaveSubMenu and CoolTip.IndexesSub [i] and CoolTip.IndexesSub [i] > 0) then
Tercio@11 1608 CoolTip:ShowSub (i)
Tercio@11 1609 end
Tercio@11 1610 end
Tercio@11 1611 end
Tercio@11 1612
Tercio@11 1613 return true
Tercio@11 1614 end
Tercio@11 1615
Tercio@11 1616 function CoolTip:SetMyPoint (host, x_mod, y_mod)
Tercio@11 1617
Tercio@11 1618 local moveX = x_mod or 0
Tercio@11 1619 local moveY = y_mod or 0
Tercio@11 1620
Tercio@11 1621 --> clear all points
Tercio@11 1622 frame1:ClearAllPoints()
Tercio@11 1623
Tercio@11 1624 local anchor = CoolTip.OptionsTable.Anchor or CoolTip.Host
Tercio@11 1625 frame1:SetPoint (CoolTip.OptionsTable.MyAnchor, anchor, CoolTip.OptionsTable.RelativeAnchor, 0 + moveX + CoolTip.OptionsTable.WidthAnchorMod, 10 + CoolTip.OptionsTable.HeightAnchorMod + moveY)
Tercio@11 1626
Tercio@11 1627 if (not x_mod) then
Tercio@11 1628 --> check if cooltip is out of screen bounds
Tercio@11 1629 local center_x = frame1:GetCenter()
Tercio@11 1630
Tercio@11 1631 if (center_x) then
Tercio@11 1632 local screen_x_res = GetScreenWidth()
Tercio@11 1633 local half_x = frame1:GetWidth() / 2
Tercio@11 1634
Tercio@11 1635 if (center_x+half_x > screen_x_res) then
Tercio@11 1636 --> out of right side
Tercio@11 1637 local move_to_left = (center_x + half_x) - screen_x_res
Tercio@11 1638 CoolTip.internal_x_mod = -move_to_left
Tercio@11 1639 return CoolTip:SetMyPoint (host, -move_to_left, 0)
Tercio@11 1640
Tercio@11 1641 elseif (center_x-half_x < 0) then
Tercio@11 1642 --> out of left side
Tercio@11 1643 local move_to_right = center_x - half_x
Tercio@11 1644 CoolTip.internal_x_mod = move_to_right*-1
Tercio@11 1645 return CoolTip:SetMyPoint (host, move_to_right*-1, 0)
Tercio@11 1646 end
Tercio@11 1647 end
Tercio@11 1648 end
Tercio@11 1649
Tercio@11 1650 if (not y_mod) then
Tercio@11 1651 --> check if cooltip is out of screen bounds
Tercio@11 1652 local _, center_y = frame1:GetCenter()
Tercio@11 1653 local screen_y_res = GetScreenHeight()
Tercio@11 1654 local half_y = frame1:GetHeight() / 2
Tercio@11 1655
Tercio@11 1656 if (center_y) then
Tercio@11 1657 if (center_y+half_y > screen_y_res) then
Tercio@11 1658 --> out of top side
Tercio@11 1659 local move_to_down = (center_y + half_y) - screen_y_res
Tercio@11 1660 CoolTip.internal_y_mod = -move_to_down
Tercio@11 1661 return CoolTip:SetMyPoint (host, 0, -move_to_down)
Tercio@11 1662
Tercio@11 1663 elseif (center_y-half_y < 0) then
Tercio@11 1664 --> out of bottom side
Tercio@11 1665 local move_to_up = center_y - half_y
Tercio@11 1666 CoolTip.internal_y_mod = move_to_up*-1
Tercio@11 1667 return CoolTip:SetMyPoint (host, 0, move_to_up*-1)
Tercio@11 1668
Tercio@11 1669 end
Tercio@11 1670 end
Tercio@11 1671 end
Tercio@11 1672
Tercio@11 1673 if (frame2:IsShown() and not CoolTip.overlap_checked) then
Tercio@11 1674
Tercio@11 1675 local frame_2_center_x = frame2:GetCenter()
Tercio@11 1676 if (frame_2_center_x) then
Tercio@11 1677 local frame_2_half_x = frame2:GetWidth() / 2
Tercio@11 1678
Tercio@11 1679 local frame_1_center_x = frame1:GetCenter()
Tercio@11 1680 if (frame_1_center_x) then
Tercio@11 1681
Tercio@11 1682 local frame_1_half_x = frame1:GetWidth() / 2
Tercio@11 1683
Tercio@11 1684 local f1_end_point = frame_1_center_x + frame_1_half_x - 3
Tercio@11 1685 local f2_start_point = frame_2_center_x - frame_2_half_x
Tercio@11 1686
Tercio@11 1687 if (f2_start_point < f1_end_point) then
Tercio@11 1688 local diff = f2_start_point - f1_end_point
Tercio@11 1689 CoolTip.overlap_checked = true
Tercio@11 1690
Tercio@11 1691 frame2:ClearAllPoints()
Tercio@11 1692 frame2:SetPoint ("bottomright", frame1, "bottomleft")
Tercio@11 1693 CoolTip.frame2_leftside = true
Tercio@11 1694 --> diff
Tercio@11 1695 return CoolTip:SetMyPoint (host, CoolTip.internal_x_mod , CoolTip.internal_y_mod)
Tercio@11 1696 end
Tercio@11 1697
Tercio@11 1698 end
Tercio@11 1699 end
Tercio@11 1700
Tercio@11 1701 end
Tercio@11 1702
Tercio@11 1703 end
Tercio@11 1704
Tercio@11 1705 function CoolTip:CheckOverlap()
Tercio@11 1706 if (frame2:IsShown()) then
Tercio@11 1707
Tercio@11 1708 local frame_2_center_x = frame2:GetCenter()
Tercio@11 1709 if (frame_2_center_x) then
Tercio@11 1710 local frame_2_half_x = frame2:GetWidth() / 2
Tercio@11 1711
Tercio@11 1712 local frame_1_center_x = frame1:GetCenter()
Tercio@11 1713 if (frame_1_center_x) then
Tercio@11 1714
Tercio@11 1715 local frame_1_half_x = frame1:GetWidth() / 2
Tercio@11 1716
Tercio@11 1717 local f1_end_point = frame_1_center_x + frame_1_half_x - 3
Tercio@11 1718 local f2_start_point = frame_2_center_x - frame_2_half_x
Tercio@11 1719
Tercio@11 1720 if (f2_start_point < f1_end_point) then
Tercio@11 1721 local diff = f2_start_point - f1_end_point
Tercio@11 1722
Tercio@11 1723 frame2:ClearAllPoints()
Tercio@11 1724 frame2:SetPoint ("bottomright", frame1, "bottomleft")
Tercio@11 1725 CoolTip.frame2_leftside = true
Tercio@11 1726 end
Tercio@11 1727
Tercio@11 1728 end
Tercio@11 1729 end
Tercio@11 1730
Tercio@11 1731 end
Tercio@11 1732 end
Tercio@11 1733
Tercio@11 1734 function CoolTip:GetText (buttonIndex)
Tercio@11 1735 local button1 = frame1.Lines [buttonIndex]
Tercio@11 1736 if (not button1) then
Tercio@11 1737 return "", ""
Tercio@11 1738 else
Tercio@11 1739 return button1.leftText:GetText() or "", button1.rightText:GetText() or ""
Tercio@11 1740 end
Tercio@11 1741 end
Tercio@11 1742
Tercio@11 1743 ----------------------------------------------------------------------
Tercio@11 1744 --> Get the number of lines current shown on cooltip
Tercio@11 1745
Tercio@11 1746 function CoolTip:GetNumLines()
Tercio@11 1747 return CoolTip.NumLines or 0
Tercio@11 1748 end
Tercio@11 1749
Tercio@11 1750 ----------------------------------------------------------------------
Tercio@11 1751 --> Remove all options actived
Tercio@11 1752 --> Set a option on current cooltip
Tercio@11 1753
Tercio@11 1754 function CoolTip:ClearAllOptions()
Tercio@11 1755 for option, _ in pairs (CoolTip.OptionsTable) do
Tercio@11 1756 CoolTip.OptionsTable [option] = nil
Tercio@11 1757 end
Tercio@11 1758
Tercio@11 1759 CoolTip:SetOption ("MyAnchor", "bottom")
Tercio@11 1760 CoolTip:SetOption ("RelativeAnchor", "top")
Tercio@11 1761 CoolTip:SetOption ("WidthAnchorMod", 0)
Tercio@11 1762 CoolTip:SetOption ("HeightAnchorMod", 0)
Tercio@11 1763 end
Tercio@11 1764
Tercio@11 1765 function CoolTip:SetOption (option, value)
Tercio@11 1766 --> check if this options exists
Tercio@11 1767 if (not CoolTip.OptionsList [option]) then
Tercio@11 1768 return --> error
Tercio@11 1769 end
Tercio@11 1770
Tercio@11 1771 --> set options
Tercio@11 1772 CoolTip.OptionsTable [option] = value
Tercio@11 1773 end
Tercio@11 1774
Tercio@11 1775 ----------------------------------------------------------------------
Tercio@11 1776 --> set the anchor of cooltip
Tercio@11 1777 --> parameters: frame [, cooltip anchor point, frame anchor point [, x mod, y mod]]
Tercio@11 1778 --> frame [, x mod, y mod]
Tercio@11 1779
Tercio@11 1780 --> alias
Tercio@11 1781 function CoolTip:GetOwner()
Tercio@11 1782 return CoolTip.Host
Tercio@11 1783 end
Tercio@11 1784
Tercio@11 1785 function CoolTip:SetOwner (frame, myPoint, hisPoint, x, y)
Tercio@11 1786 return CoolTip:SetHost (frame, myPoint, hisPoint, x, y)
Tercio@11 1787 end
Tercio@11 1788
Tercio@11 1789 function CoolTip:SetHost (frame, myPoint, hisPoint, x, y)
Tercio@11 1790 --> check data integrity
Tercio@11 1791 if (type (frame) ~= "table" or not frame.GetObjectType) then
Tercio@11 1792 print ("host need to be a frame")
Tercio@11 1793 return --> error
Tercio@11 1794 end
Tercio@11 1795
Tercio@11 1796 CoolTip.Host = frame
Tercio@11 1797
Tercio@11 1798 CoolTip.frame1:SetFrameLevel (frame:GetFrameLevel()+1)
Tercio@11 1799
Tercio@11 1800 --> defaults
Tercio@11 1801 myPoint = myPoint or CoolTip.OptionsTable.MyAnchor or "bottom"
Tercio@11 1802 hisPoint = hisPoint or CoolTip.OptionsTable.hisPoint or "top"
Tercio@11 1803
Tercio@11 1804 x = x or CoolTip.OptionsTable.WidthAnchorMod or 0
Tercio@11 1805 y = y or CoolTip.OptionsTable.HeightAnchorMod or 0
Tercio@11 1806
Tercio@11 1807 --> check options
Tercio@11 1808 if (type (myPoint) == "string") then
Tercio@11 1809 CoolTip:SetOption ("MyAnchor", myPoint)
Tercio@11 1810 CoolTip:SetOption ("WidthAnchorMod", x)
Tercio@11 1811 elseif (type (myPoint) == "number") then
Tercio@11 1812 CoolTip:SetOption ("HeightAnchorMod", myPoint)
Tercio@11 1813 end
Tercio@11 1814
Tercio@11 1815 if (type (hisPoint) == "string") then
Tercio@11 1816 CoolTip:SetOption ("RelativeAnchor", hisPoint)
Tercio@11 1817 CoolTip:SetOption ("HeightAnchorMod", y)
Tercio@11 1818 elseif (type (hisPoint) == "number") then
Tercio@11 1819 CoolTip:SetOption ("WidthAnchorMod", hisPoint)
Tercio@11 1820 end
Tercio@11 1821 end
Tercio@11 1822
Tercio@11 1823 ----------------------------------------------------------------------
Tercio@11 1824 --> set cooltip type
Tercio@11 1825 --> parameters: type (1 = tooltip | 2 = tooltip with bars | 3 = menu)
Tercio@11 1826
Tercio@11 1827 function CoolTip:IsMenu()
Tercio@11 1828 return CoolTip.frame1:IsShown() and CoolTip.Type == 3
Tercio@11 1829 end
Tercio@11 1830
Tercio@11 1831 function CoolTip:IsTooltip()
Tercio@11 1832 return CoolTip.frame1:IsShown() and (CoolTip.Type == 1 or CoolTip.Type == 2)
Tercio@11 1833 end
Tercio@11 1834
Tercio@11 1835 function CoolTip:GetType()
Tercio@11 1836 if (CoolTip.Type == 1 or CoolTip.Type == 2) then
Tercio@11 1837 return "tooltip"
Tercio@11 1838 elseif (CoolTip.Type == 3) then
Tercio@11 1839 return "menu"
Tercio@11 1840 else
Tercio@11 1841 return "none"
Tercio@11 1842 end
Tercio@11 1843 end
Tercio@11 1844
Tercio@11 1845 function CoolTip:SetType (newType)
Tercio@11 1846 if (type (newType) == "string") then
Tercio@11 1847 if (newType == "tooltip") then
Tercio@11 1848 CoolTip.Type = 1
Tercio@11 1849 elseif (newType == "tooltipbar") then
Tercio@11 1850 CoolTip.Type = 2
Tercio@11 1851 elseif (newType == "menu") then
Tercio@11 1852 CoolTip.Type = 3
Tercio@11 1853 else
Tercio@11 1854 --> error
Tercio@11 1855 end
Tercio@11 1856 elseif (type (newType) == "number") then
Tercio@11 1857 if (newType == 1) then
Tercio@11 1858 CoolTip.Type = 1
Tercio@11 1859 elseif (newType == 2) then
Tercio@11 1860 CoolTip.Type = 2
Tercio@11 1861 elseif (newType == 3) then
Tercio@11 1862 CoolTip.Type = 3
Tercio@11 1863 else
Tercio@11 1864 --> error
Tercio@11 1865 end
Tercio@11 1866 else
Tercio@11 1867 --> error
Tercio@11 1868 end
Tercio@11 1869 end
Tercio@11 1870
Tercio@11 1871 --> Set a fixed value for menu
Tercio@11 1872 function CoolTip:SetFixedParameter (value, injected)
Tercio@11 1873 if (injected ~= nil) then
Tercio@11 1874 local frame = value
Tercio@11 1875 if (frame.dframework) then
Tercio@11 1876 frame = frame.widget
Tercio@11 1877 end
Tercio@11 1878 if (frame.CoolTip) then
Tercio@11 1879 frame.CoolTip.FixedValue = injected
Tercio@11 1880 else
Tercio@11 1881 --debug
Tercio@11 1882 end
Tercio@11 1883 end
Tercio@11 1884 CoolTip.FixedValue = value
Tercio@11 1885 end
Tercio@11 1886
Tercio@11 1887 function CoolTip:SetColor (menuType, ...)
Tercio@11 1888 local ColorR, ColorG, ColorB, ColorA = DF:ParseColors (...)
Tercio@11 1889 if ((type (menuType) == "string" and menuType == "main") or (type (menuType) == "number" and menuType == 1)) then
Tercio@11 1890 frame1.framebackgroundLeft:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
Tercio@11 1891 frame1.framebackgroundRight:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
Tercio@11 1892 frame1.framebackgroundCenter:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
Tercio@11 1893
Tercio@11 1894 elseif ((type (menuType) == "string" and menuType == "sec") or (type (menuType) == "number" and menuType == 2)) then
Tercio@11 1895 frame2.framebackgroundLeft:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
Tercio@11 1896 frame2.framebackgroundRight:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
Tercio@11 1897 frame2.framebackgroundCenter:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
Tercio@11 1898
Tercio@11 1899 else
Tercio@11 1900 return --> error
Tercio@11 1901 end
Tercio@11 1902 end
Tercio@11 1903
Tercio@11 1904 --> Set last selected option
Tercio@11 1905 function CoolTip:SetLastSelected (menuType, index, index2)
Tercio@11 1906
Tercio@11 1907 if (CoolTip.Type == 3) then
Tercio@11 1908 if ((type (menuType) == "string" and menuType == "main") or (type (menuType) == "number" and menuType == 1)) then
Tercio@11 1909 CoolTip.SelectedIndexMain = index
Tercio@11 1910 elseif ((type (menuType) == "string" and menuType == "sec") or (type (menuType) == "number" and menuType == 2)) then
Tercio@11 1911 CoolTip.SelectedIndexSec [index] = index2
Tercio@11 1912 else
Tercio@11 1913 return --> error
Tercio@11 1914 end
Tercio@11 1915 else
Tercio@11 1916 return --> error
Tercio@11 1917 end
Tercio@11 1918 end
Tercio@11 1919
Tercio@11 1920 --> serack key: ~select
Tercio@11 1921 function CoolTip:Select (menuType, option, mainIndex)
Tercio@11 1922 if (menuType == 1) then --main menu
Tercio@11 1923 local botao = frame1.Lines [option]
Tercio@11 1924 CoolTip.buttonClicked = true
Tercio@11 1925 CoolTip:SetSelectedAnchor (frame1, botao)
Tercio@11 1926
Tercio@11 1927 --UIFrameFlash (frame1.selected, 0.05, 0.05, 0.2, true, 0, 0)
Tercio@11 1928
Tercio@11 1929 elseif (menuType == 2) then --sub menu
Tercio@11 1930 CoolTip:ShowSub (mainIndex)
Tercio@11 1931 local botao = frame2.Lines [option]
Tercio@11 1932 CoolTip.buttonClicked = true
Tercio@11 1933
Tercio@11 1934 CoolTip:SetSelectedAnchor (frame2, botao)
Tercio@11 1935 end
Tercio@11 1936 end
Tercio@11 1937
Tercio@11 1938 ----------------------------------------------------------------------
Tercio@11 1939 --> Reset cooltip
Tercio@11 1940
Tercio@11 1941 local default_backdrop = {bgFile=[[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile=[[Interface\Tooltips\UI-Tooltip-Border]], tile=true,
Tercio@11 1942 edgeSize=16, tileSize=16, insets = {left=3, right=3, top=4, bottom=4}}
Tercio@11 1943 local default_backdrop_color = {0.09019, 0.09019, 0.18823, 1}
Tercio@11 1944 local default_backdropborder_color = {1, 1, 1, 1}
Tercio@11 1945
Tercio@11 1946 --borda preta sem usar unpack
Tercio@11 1947
Tercio@11 1948 --> wipe all data ~reset
Tercio@11 1949 function CoolTip:Reset()
Tercio@11 1950
Tercio@11 1951 frame2:ClearAllPoints()
Tercio@11 1952 frame2:SetPoint ("bottomleft", frame1, "bottomright")
Tercio@11 1953
Tercio@11 1954 CoolTip:HideSelectedTexture (frame1)
Tercio@11 1955 CoolTip:HideSelectedTexture (frame2)
Tercio@11 1956
Tercio@11 1957 CoolTip.FixedValue = nil
Tercio@11 1958 CoolTip.HaveSubMenu = false
Tercio@11 1959
Tercio@11 1960 CoolTip.SelectedIndexMain = nil
Tercio@11 1961 _table_wipe (CoolTip.SelectedIndexSec)
Tercio@11 1962
Tercio@11 1963 CoolTip.Indexes = 0
Tercio@11 1964 CoolTip.SubIndexes = 0
Tercio@11 1965 _table_wipe (CoolTip.IndexesSub)
Tercio@11 1966
Tercio@11 1967 CoolTip.internal_x_mod = 0
Tercio@11 1968 CoolTip.internal_y_mod = 0
Tercio@11 1969 CoolTip.current_anchor = nil
Tercio@11 1970 CoolTip.overlap_checked = false
Tercio@11 1971
Tercio@11 1972 CoolTip.frame2_leftside = nil
Tercio@11 1973
Tercio@11 1974 frame1:SetBackdrop (default_backdrop)
Tercio@11 1975 frame1:SetBackdropColor (unpack (default_backdrop_color))
Tercio@11 1976 frame1:SetBackdropBorderColor (unpack (default_backdropborder_color))
Tercio@11 1977
Tercio@11 1978 frame2:SetBackdrop (default_backdrop)
Tercio@11 1979 frame2:SetBackdropColor (unpack (default_backdrop_color))
Tercio@11 1980 frame2:SetBackdropBorderColor (unpack (default_backdropborder_color))
Tercio@11 1981
Tercio@11 1982 --[
Tercio@20 1983 _table_wipe (CoolTip.PopupFrameTable)
Tercio@20 1984
Tercio@11 1985 _table_wipe (CoolTip.LeftTextTable)
Tercio@11 1986 _table_wipe (CoolTip.LeftTextTableSub)
Tercio@11 1987 _table_wipe (CoolTip.RightTextTable)
Tercio@11 1988 _table_wipe (CoolTip.RightTextTableSub)
Tercio@11 1989
Tercio@11 1990 _table_wipe (CoolTip.LeftIconTable)
Tercio@11 1991 _table_wipe (CoolTip.LeftIconTableSub)
Tercio@11 1992 _table_wipe (CoolTip.RightIconTable)
Tercio@11 1993 _table_wipe (CoolTip.RightIconTableSub)
Tercio@11 1994
Tercio@11 1995 _table_wipe (CoolTip.StatusBarTable)
Tercio@11 1996 _table_wipe (CoolTip.StatusBarTableSub)
Tercio@11 1997
Tercio@11 1998 _table_wipe (CoolTip.FunctionsTableMain)
Tercio@11 1999 _table_wipe (CoolTip.FunctionsTableSub)
Tercio@11 2000
Tercio@11 2001 _table_wipe (CoolTip.ParametersTableMain)
Tercio@11 2002 _table_wipe (CoolTip.ParametersTableSub)
Tercio@11 2003
Tercio@11 2004 _table_wipe (CoolTip.WallpaperTable)
Tercio@11 2005 _table_wipe (CoolTip.WallpaperTableSub)
Tercio@11 2006 --]]
Tercio@11 2007
Tercio@11 2008 _table_wipe (CoolTip.TopIconTableSub)
Tercio@11 2009 CoolTip.Banner [1] = false
Tercio@11 2010 CoolTip.Banner [2] = false
Tercio@11 2011 CoolTip.Banner [3] = false
Tercio@11 2012
Tercio@11 2013 frame1.upperImage:Hide()
Tercio@11 2014 frame1.upperImage2:Hide()
Tercio@11 2015 frame1.upperImageText:Hide()
Tercio@11 2016 frame1.upperImageText2:Hide()
Tercio@11 2017
Tercio@11 2018 frame1.frameWallpaper:Hide()
Tercio@11 2019 frame2.frameWallpaper:Hide()
Tercio@11 2020
Tercio@11 2021 frame2.upperImage:Hide()
Tercio@11 2022
Tercio@11 2023 CoolTip.title1 = nil
Tercio@11 2024 CoolTip.title_text = nil
Tercio@11 2025
Tercio@11 2026 CoolTip.frame1.titleText:Hide()
Tercio@11 2027 CoolTip.frame1.titleIcon:Hide()
Tercio@11 2028
Tercio@11 2029 CoolTip:ClearAllOptions()
Tercio@11 2030 CoolTip:SetColor (1, "transparent")
Tercio@11 2031 CoolTip:SetColor (2, "transparent")
Tercio@11 2032
Tercio@11 2033 local f1Lines = frame1.Lines
Tercio@11 2034 for i = 1, #f1Lines do
Tercio@11 2035 f1Lines [i].statusbar.subMenuArrow:Hide()
Tercio@11 2036 end
Tercio@11 2037 end
Tercio@11 2038
Tercio@11 2039 ----------------------------------------------------------------------
Tercio@11 2040 --> Menu functions
Tercio@11 2041
Tercio@11 2042 local _default_color = {1, 1, 1}
Tercio@11 2043 local _default_point = {"center", "center", 0, -3}
Tercio@11 2044
Tercio@11 2045 function CoolTip:AddMenu (menuType, func, param1, param2, param3, leftText, leftIcon, indexUp)
Tercio@11 2046
Tercio@11 2047 if (leftText and indexUp and ((type (menuType) == "string" and menuType == "main") or (type (menuType) == "number" and menuType == 1))) then
Tercio@11 2048 CoolTip.Indexes = CoolTip.Indexes + 1
Tercio@11 2049
Tercio@11 2050 if (not CoolTip.IndexesSub [CoolTip.Indexes]) then
Tercio@11 2051 CoolTip.IndexesSub [CoolTip.Indexes] = 0
Tercio@11 2052 end
Tercio@11 2053
Tercio@11 2054 CoolTip.SubIndexes = 0
Tercio@11 2055 end
Tercio@11 2056
Tercio@11 2057 --> need a previous line
Tercio@11 2058 if (CoolTip.Indexes == 0) then
Tercio@11 2059 print ("Indexes are 0")
Tercio@11 2060 return --> return error
Tercio@11 2061 end
Tercio@11 2062
Tercio@11 2063 --> check data integrity
Tercio@11 2064 if (type (func) ~= "function") then
Tercio@11 2065 print ("No function")
Tercio@11 2066 return --> erroe
Tercio@11 2067 end
Tercio@11 2068
Tercio@11 2069 --> add
Tercio@11 2070
Tercio@11 2071 if ((type (menuType) == "string" and menuType == "main") or (type (menuType) == "number" and menuType == 1)) then
Tercio@11 2072
Tercio@11 2073 local parameterTable
Tercio@11 2074 if (CoolTip.isSpecial) then
Tercio@11 2075 parameterTable = {}
Tercio@11 2076 _table_insert (CoolTip.FunctionsTableMain, CoolTip.Indexes, func)
Tercio@11 2077 _table_insert (CoolTip.ParametersTableMain, CoolTip.Indexes, parameterTable)
Tercio@11 2078 else
Tercio@11 2079
Tercio@11 2080 CoolTip.FunctionsTableMain [CoolTip.Indexes] = func
Tercio@11 2081
Tercio@11 2082 parameterTable = CoolTip.ParametersTableMain [CoolTip.Indexes]
Tercio@11 2083 if (not parameterTable) then
Tercio@11 2084 parameterTable = {}
Tercio@11 2085 CoolTip.ParametersTableMain [CoolTip.Indexes] = parameterTable
Tercio@11 2086 end
Tercio@11 2087 end
Tercio@11 2088
Tercio@11 2089 parameterTable [1] = param1
Tercio@11 2090 parameterTable [2] = param2
Tercio@11 2091 parameterTable [3] = param3
Tercio@11 2092
Tercio@11 2093 if (leftIcon) then
Tercio@11 2094 local iconTable = CoolTip.LeftIconTable [CoolTip.Indexes]
Tercio@11 2095
Tercio@11 2096 if (not iconTable or CoolTip.isSpecial) then
Tercio@11 2097 iconTable = {}
Tercio@11 2098 CoolTip.LeftIconTable [CoolTip.Indexes] = iconTable
Tercio@11 2099 end
Tercio@11 2100
Tercio@11 2101 iconTable [1] = leftIcon
Tercio@11 2102 iconTable [2] = 16 --> default 16
Tercio@11 2103 iconTable [3] = 16 --> default 16
Tercio@11 2104 iconTable [4] = 0 --> default 0
Tercio@11 2105 iconTable [5] = 1 --> default 1
Tercio@11 2106 iconTable [6] = 0 --> default 0
Tercio@11 2107 iconTable [7] = 1 --> default 1
Tercio@11 2108 iconTable [8] = _default_color
Tercio@11 2109 end
Tercio@11 2110
Tercio@11 2111 if (leftText) then
Tercio@11 2112 local lineTable_left = CoolTip.LeftTextTable [CoolTip.Indexes]
Tercio@11 2113
Tercio@11 2114 if (not lineTable_left or CoolTip.isSpecial) then
Tercio@11 2115 lineTable_left = {}
Tercio@11 2116 CoolTip.LeftTextTable [CoolTip.Indexes] = lineTable_left
Tercio@11 2117 end
Tercio@11 2118
Tercio@11 2119 lineTable_left [1] = leftText --> line text
Tercio@11 2120 lineTable_left [2] = 0
Tercio@11 2121 lineTable_left [3] = 0
Tercio@11 2122 lineTable_left [4] = 0
Tercio@11 2123 lineTable_left [5] = 0
Tercio@11 2124 lineTable_left [6] = false
Tercio@11 2125 lineTable_left [7] = false
Tercio@11 2126 lineTable_left [8] = false
Tercio@11 2127
Tercio@11 2128 end
Tercio@11 2129
Tercio@11 2130 elseif ((type (menuType) == "string" and menuType == "sec") or (type (menuType) == "number" and menuType == 2)) then
Tercio@11 2131
Tercio@11 2132 if (CoolTip.SubIndexes == 0) then
Tercio@11 2133 if (not indexUp or not leftText) then
Tercio@11 2134 print ("not indexUp or not leftText")
Tercio@11 2135 return --> error
Tercio@11 2136 end
Tercio@11 2137 end
Tercio@11 2138
Tercio@11 2139 if (indexUp and leftText) then
Tercio@11 2140 CoolTip.SubIndexes = CoolTip.SubIndexes + 1
Tercio@11 2141 CoolTip.IndexesSub [CoolTip.Indexes] = CoolTip.IndexesSub [CoolTip.Indexes] + 1
Tercio@11 2142 elseif (indexUp and not leftText) then
Tercio@11 2143 print ("indexUp and not leftText")
Tercio@11 2144 return --> error [leftText can't be nil if indexUp are true]
Tercio@11 2145 end
Tercio@11 2146
Tercio@11 2147 --> menu container
Tercio@11 2148 local subMenuContainerParameters = CoolTip.ParametersTableSub [CoolTip.Indexes]
Tercio@11 2149 if (not subMenuContainerParameters) then
Tercio@11 2150 subMenuContainerParameters = {}
Tercio@11 2151 CoolTip.ParametersTableSub [CoolTip.Indexes] = subMenuContainerParameters
Tercio@11 2152 end
Tercio@11 2153
Tercio@11 2154 local subMenuContainerFunctions = CoolTip.FunctionsTableSub [CoolTip.Indexes]
Tercio@11 2155 if (not subMenuContainerFunctions or CoolTip.isSpecial) then
Tercio@11 2156 subMenuContainerFunctions = {}
Tercio@11 2157 CoolTip.FunctionsTableSub [CoolTip.Indexes] = subMenuContainerFunctions
Tercio@11 2158 end
Tercio@11 2159
Tercio@11 2160 --> menu table
Tercio@11 2161 local subMenuTablesParameters = subMenuContainerParameters [CoolTip.SubIndexes]
Tercio@11 2162 if (not subMenuTablesParameters or CoolTip.isSpecial) then
Tercio@11 2163 subMenuTablesParameters = {}
Tercio@11 2164 subMenuContainerParameters [CoolTip.SubIndexes] = subMenuTablesParameters
Tercio@11 2165 end
Tercio@11 2166
Tercio@11 2167 --> add
Tercio@11 2168 subMenuContainerFunctions [CoolTip.SubIndexes] = func
Tercio@11 2169
Tercio@11 2170 subMenuTablesParameters [1] = param1
Tercio@11 2171 subMenuTablesParameters [2] = param2
Tercio@11 2172 subMenuTablesParameters [3] = param3
Tercio@11 2173
Tercio@11 2174 --> text and icon
Tercio@11 2175 if (leftIcon) then
Tercio@11 2176
Tercio@11 2177 local subMenuContainerIcons = CoolTip.LeftIconTableSub [CoolTip.Indexes]
Tercio@11 2178 if (not subMenuContainerIcons) then
Tercio@11 2179 subMenuContainerIcons = {}
Tercio@11 2180 CoolTip.LeftIconTableSub [CoolTip.Indexes] = subMenuContainerIcons
Tercio@11 2181 end
Tercio@11 2182 local subMenuTablesIcons = subMenuContainerIcons [CoolTip.SubIndexes]
Tercio@11 2183 if (not subMenuTablesIcons or CoolTip.isSpecial) then
Tercio@11 2184 subMenuTablesIcons = {}
Tercio@11 2185 subMenuContainerIcons [CoolTip.SubIndexes] = subMenuTablesIcons
Tercio@11 2186 end
Tercio@11 2187
Tercio@11 2188 subMenuTablesIcons [1] = leftIcon
Tercio@11 2189 subMenuTablesIcons [2] = 16 --> default 16
Tercio@11 2190 subMenuTablesIcons [3] = 16 --> default 16
Tercio@11 2191 subMenuTablesIcons [4] = 0 --> default 0
Tercio@11 2192 subMenuTablesIcons [5] = 1 --> default 1
Tercio@11 2193 subMenuTablesIcons [6] = 0 --> default 0
Tercio@11 2194 subMenuTablesIcons [7] = 1 --> default 1
Tercio@11 2195 subMenuTablesIcons [8] = _default_color
Tercio@11 2196 end
Tercio@11 2197
Tercio@11 2198 if (leftText) then
Tercio@11 2199
Tercio@11 2200 local subMenuContainerTexts = CoolTip.LeftTextTableSub [CoolTip.Indexes]
Tercio@11 2201 if (not subMenuContainerTexts) then
Tercio@11 2202 subMenuContainerTexts = {}
Tercio@11 2203 CoolTip.LeftTextTableSub [CoolTip.Indexes] = subMenuContainerTexts
Tercio@11 2204 end
Tercio@11 2205 local subMenuTablesTexts = subMenuContainerTexts [CoolTip.SubIndexes]
Tercio@11 2206 if (not subMenuTablesTexts or CoolTip.isSpecial) then
Tercio@11 2207 subMenuTablesTexts = {}
Tercio@11 2208 subMenuContainerTexts [CoolTip.SubIndexes] = subMenuTablesTexts
Tercio@11 2209 end
Tercio@11 2210
Tercio@11 2211 subMenuTablesTexts [1] = leftText --> line text
Tercio@11 2212 subMenuTablesTexts [2] = 0
Tercio@11 2213 subMenuTablesTexts [3] = 0
Tercio@11 2214 subMenuTablesTexts [4] = 0
Tercio@11 2215 subMenuTablesTexts [5] = 0
Tercio@11 2216 subMenuTablesTexts [6] = false
Tercio@11 2217 subMenuTablesTexts [7] = false
Tercio@11 2218 subMenuTablesTexts [8] = false
Tercio@11 2219
Tercio@11 2220 end
Tercio@11 2221
Tercio@11 2222 CoolTip.HaveSubMenu = true
Tercio@11 2223
Tercio@11 2224 else
Tercio@11 2225 return --> error
Tercio@11 2226 end
Tercio@11 2227 end
Tercio@11 2228
Tercio@11 2229 ----------------------------------------------------------------------
Tercio@11 2230 --> adds a statusbar to the last line added.
Tercio@11 2231 --> only works with cooltip type 2 (tooltip with bars)
Tercio@11 2232 --> parameters: value [, color red, color green, color blue, color alpha [, glow]]
Tercio@11 2233 --> can also use a table or html color name in color red and send glow in color green
Tercio@11 2234
Tercio@11 2235 function CoolTip:AddStatusBar (statusbarValue, frame, ColorR, ColorG, ColorB, ColorA, statusbarGlow, backgroundBar)
Tercio@11 2236
Tercio@11 2237 --> need a previous line
Tercio@11 2238 if (CoolTip.Indexes == 0) then
Tercio@11 2239 return --> return error
Tercio@11 2240 end
Tercio@11 2241
Tercio@11 2242 --> check data integrity
Tercio@11 2243 if (type (statusbarValue) ~= "number") then
Tercio@11 2244 return --> error
Tercio@11 2245 end
Tercio@11 2246
Tercio@11 2247 if (type (ColorR) == "table" or type (ColorR) == "string") then
Tercio@11 2248 statusbarGlow, backgroundBar, ColorR, ColorG, ColorB, ColorA = ColorG, ColorB, DF:ParseColors (ColorR)
Tercio@11 2249 elseif (type (ColorR) == "boolean") then
Tercio@11 2250 backgroundBar = ColorG
Tercio@11 2251 statusbarGlow = ColorR
Tercio@11 2252 ColorR, ColorG, ColorB, ColorA = 1, 1, 1, 1
Tercio@11 2253 else
Tercio@11 2254 --> error
Tercio@11 2255 end
Tercio@11 2256
Tercio@11 2257 --> add
Tercio@11 2258 local frameTable
Tercio@11 2259 local statusbarTable
Tercio@11 2260
Tercio@11 2261 if (not frame or (type (frame) == "string" and frame == "main") or (type (frame) == "number" and frame == 1)) then
Tercio@11 2262 frameTable = CoolTip.StatusBarTable
Tercio@11 2263
Tercio@11 2264 if (CoolTip.isSpecial) then
Tercio@11 2265 statusbarTable = {}
Tercio@11 2266 _table_insert (frameTable, CoolTip.Indexes, statusbarTable)
Tercio@11 2267 else
Tercio@11 2268 statusbarTable = frameTable [CoolTip.Indexes]
Tercio@11 2269 if (not statusbarTable) then
Tercio@11 2270 statusbarTable = {}
Tercio@11 2271 _table_insert (frameTable, CoolTip.Indexes, statusbarTable)
Tercio@11 2272 --frameTable [CoolTip.Indexes] = statusbarTable
Tercio@11 2273 end
Tercio@11 2274 end
Tercio@11 2275
Tercio@11 2276 elseif ((type (frame) == "string" and frame == "sub") or (type (frame) == "number" and frame == 2)) then
Tercio@11 2277
Tercio@11 2278 frameTable = CoolTip.StatusBarTableSub
Tercio@11 2279
Tercio@11 2280 local subMenuContainerStatusBar = frameTable [CoolTip.Indexes]
Tercio@11 2281 if (not subMenuContainerStatusBar) then
Tercio@11 2282 subMenuContainerStatusBar = {}
Tercio@11 2283 frameTable [CoolTip.Indexes] = subMenuContainerStatusBar
Tercio@11 2284 end
Tercio@11 2285
Tercio@11 2286 if (CoolTip.isSpecial) then
Tercio@11 2287 statusbarTable = {}
Tercio@11 2288 _table_insert (subMenuContainerStatusBar, CoolTip.SubIndexes, statusbarTable)
Tercio@11 2289 else
Tercio@11 2290 statusbarTable = subMenuContainerStatusBar [CoolTip.SubIndexes]
Tercio@11 2291 if (not statusbarTable) then
Tercio@11 2292 statusbarTable = {}
Tercio@11 2293 _table_insert (subMenuContainerStatusBar, CoolTip.SubIndexes, statusbarTable)
Tercio@11 2294 end
Tercio@11 2295 end
Tercio@11 2296 else
Tercio@11 2297 print ("unknow frame")
Tercio@11 2298 return --> error
Tercio@11 2299 end
Tercio@11 2300
Tercio@11 2301 statusbarTable [1] = statusbarValue
Tercio@11 2302 statusbarTable [2] = ColorR
Tercio@11 2303 statusbarTable [3] = ColorG
Tercio@11 2304 statusbarTable [4] = ColorB
Tercio@11 2305 statusbarTable [5] = ColorA
Tercio@11 2306 statusbarTable [6] = statusbarGlow
Tercio@11 2307 statusbarTable [7] = backgroundBar
Tercio@11 2308
Tercio@11 2309 end
Tercio@11 2310
Tercio@11 2311 frame1.frameWallpaper:Hide()
Tercio@11 2312 frame2.frameWallpaper:Hide()
Tercio@11 2313
Tercio@11 2314 function CoolTip:SetWallpaper (index, texture, texcoord, color, desaturate)
Tercio@11 2315
Tercio@11 2316 if (CoolTip.Indexes == 0) then
Tercio@11 2317 return --> return error
Tercio@11 2318 end
Tercio@11 2319
Tercio@11 2320 local frameTable
Tercio@11 2321 local wallpaperTable
Tercio@11 2322
Tercio@11 2323 if ( (type (index) == "number" and index == 1) or (type (index) == "string" and index == "main") ) then
Tercio@11 2324 wallpaperTable = CoolTip.WallpaperTable
Tercio@11 2325
Tercio@11 2326 elseif ( (type (index) == "number" and index == 2) or (type (index) == "string" and index == "sub") ) then
Tercio@11 2327 frameTable = CoolTip.WallpaperTableSub
Tercio@11 2328
Tercio@11 2329 local subMenuContainerWallpapers = frameTable [CoolTip.Indexes]
Tercio@11 2330 if (not subMenuContainerWallpapers) then
Tercio@11 2331 subMenuContainerWallpapers = {}
Tercio@11 2332 frameTable [CoolTip.Indexes] = subMenuContainerWallpapers
Tercio@11 2333 end
Tercio@11 2334
Tercio@11 2335 wallpaperTable = subMenuContainerWallpapers
Tercio@11 2336 end
Tercio@11 2337
Tercio@11 2338 wallpaperTable [1] = texture
Tercio@11 2339 if (texcoord) then
Tercio@11 2340 wallpaperTable [2] = texcoord [1]
Tercio@11 2341 wallpaperTable [3] = texcoord [2]
Tercio@11 2342 wallpaperTable [4] = texcoord [3]
Tercio@11 2343 wallpaperTable [5] = texcoord [4]
Tercio@11 2344 else
Tercio@11 2345 wallpaperTable [2] = 0
Tercio@11 2346 wallpaperTable [3] = 1
Tercio@11 2347 wallpaperTable [4] = 0
Tercio@11 2348 wallpaperTable [5] = 1
Tercio@11 2349 end
Tercio@11 2350 wallpaperTable [6] = color
Tercio@11 2351 wallpaperTable [7] = desaturate
Tercio@11 2352 end
Tercio@11 2353
Tercio@11 2354 function CoolTip:SetBannerText (index, text, anchor, color, fontsize, fontface, fontflag)
Tercio@11 2355 local fontstring
Tercio@11 2356
Tercio@11 2357 if (index == 1) then
Tercio@11 2358 fontstring = frame1.upperImageText
Tercio@11 2359 elseif (index == 2) then
Tercio@11 2360 fontstring = frame1.upperImageText2
Tercio@11 2361 end
Tercio@11 2362
Tercio@11 2363 fontstring:SetText (text or "")
Tercio@11 2364
Tercio@11 2365 if (anchor and index == 1) then
Tercio@11 2366 local myAnchor, hisAnchor, x, y = unpack (anchor)
Tercio@11 2367 fontstring:SetPoint (myAnchor, frame1.upperImage, hisAnchor or myAnchor, x or 0, y or 0)
Tercio@11 2368 elseif (anchor and index == 2) then
Tercio@11 2369 local myAnchor, hisAnchor, x, y = unpack (anchor)
Tercio@11 2370 fontstring:SetPoint (myAnchor, frame1, hisAnchor or myAnchor, x or 0, y or 0)
Tercio@11 2371 end
Tercio@11 2372
Tercio@11 2373 if (color) then
Tercio@11 2374 local r, g, b, a = DF:ParseColors (color)
Tercio@11 2375 fontstring:SetTextColor (r, g, b, a)
Tercio@11 2376 end
Tercio@11 2377
Tercio@11 2378 local face, size, flags = fontstring:GetFont()
Tercio@11 2379 face = fontface or [[Fonts\FRIZQT__.TTF]]
Tercio@11 2380 size = fontsize or 13
Tercio@11 2381 flags = fontflag or nil
Tercio@11 2382 fontstring:SetFont (face, size, flags)
Tercio@11 2383 fontstring:Show()
Tercio@11 2384 end
Tercio@11 2385
Tercio@11 2386 function CoolTip:SetBackdrop (index, backdrop, backdropcolor, bordercolor)
Tercio@11 2387
Tercio@11 2388 local f
Tercio@11 2389 if (index == 1) then
Tercio@11 2390 f = frame1
Tercio@11 2391 elseif (index == 2) then
Tercio@11 2392 f = frame2
Tercio@11 2393 end
Tercio@11 2394
Tercio@11 2395 if (backdrop) then
Tercio@11 2396 f:SetBackdrop (backdrop)
Tercio@11 2397 end
Tercio@11 2398 if (backdropcolor) then
Tercio@11 2399 local r, g, b, a = DF:ParseColors (backdropcolor)
Tercio@11 2400 f:SetBackdropColor (r, g, b, a)
Tercio@11 2401 end
Tercio@11 2402 if (bordercolor) then
Tercio@11 2403 local r, g, b, a = DF:ParseColors (bordercolor)
Tercio@11 2404 f:SetBackdropBorderColor (r, g, b, a)
Tercio@11 2405 end
Tercio@11 2406
Tercio@11 2407 end
Tercio@11 2408
Tercio@11 2409 function CoolTip:SetBannerImage (index, texturepath, width, height, anchor, texcoord, overlay)
Tercio@11 2410
Tercio@11 2411 local texture
Tercio@11 2412
Tercio@11 2413 if (index == 1) then
Tercio@11 2414 texture = frame1.upperImage
Tercio@11 2415 elseif (index == 2) then
Tercio@11 2416 texture = frame1.upperImage2
Tercio@11 2417 end
Tercio@11 2418
Tercio@11 2419 if (texturepath) then
Tercio@11 2420 texture:SetTexture (texturepath)
Tercio@11 2421 end
Tercio@11 2422
Tercio@11 2423 if (width) then
Tercio@11 2424 texture:SetWidth (width)
Tercio@11 2425 end
Tercio@11 2426 if (height) then
Tercio@11 2427 texture:SetHeight (height)
Tercio@11 2428 end
Tercio@11 2429
Tercio@11 2430 if (anchor) then
Tercio@11 2431 if (type (anchor[1]) == "table") then
Tercio@11 2432 for _, t in _ipairs (anchor) do
Tercio@11 2433 local myAnchor, hisAnchor, x, y = unpack (t)
Tercio@11 2434 texture:SetPoint (myAnchor, frame1, hisAnchor or myAnchor, x or 0, y or 0)
Tercio@11 2435 end
Tercio@11 2436 else
Tercio@11 2437 local myAnchor, hisAnchor, x, y = unpack (anchor)
Tercio@11 2438 texture:SetPoint (myAnchor, frame1, hisAnchor or myAnchor, x or 0, y or 0)
Tercio@11 2439 end
Tercio@11 2440 end
Tercio@11 2441
Tercio@11 2442 if (texcoord) then
Tercio@11 2443 local L, R, T, B = unpack (texcoord)
Tercio@11 2444 texture:SetTexCoord (L, R, T, B)
Tercio@11 2445 end
Tercio@11 2446
Tercio@11 2447 if (overlay) then
Tercio@11 2448 texture:SetVertexColor (unpack (overlay))
Tercio@11 2449 end
Tercio@11 2450
Tercio@11 2451 CoolTip.Banner [index] = true
Tercio@11 2452 texture:Show()
Tercio@11 2453
Tercio@11 2454 end
Tercio@11 2455
Tercio@11 2456 ----------------------------------------------------------------------
Tercio@11 2457 --> adds a icon to the last line added.
Tercio@11 2458 --> only works with cooltip type 1 and 2 (tooltip and tooltip with bars)
Tercio@11 2459 --> parameters: icon [, width [, height [, TexCoords L R T B ]]]
Tercio@11 2460 --> texture support string path or texture object
Tercio@11 2461
Tercio@11 2462 function CoolTip:AddTexture (iconTexture, frame, side, iconWidth, iconHeight, L, R, T, B, overlayColor, point, desaturated)
Tercio@11 2463 return CoolTip:AddIcon (iconTexture, frame, side, iconWidth, iconHeight, L, R, T, B, overlayColor, point, desaturated)
Tercio@11 2464 end
Tercio@11 2465 function CoolTip:AddIcon (iconTexture, frame, side, iconWidth, iconHeight, L, R, T, B, overlayColor, point, desaturated)
Tercio@11 2466
Tercio@11 2467 --> need a previous line
Tercio@11 2468 if (CoolTip.Indexes == 0) then
Tercio@11 2469 return --> return error
Tercio@11 2470 end
Tercio@11 2471
Tercio@11 2472 --> check data integrity
Tercio@11 2473 if (type (iconTexture) ~= "string" and (type (iconTexture) ~= "table" or not iconTexture.GetObjectType or iconTexture:GetObjectType() ~= "Texture") ) then
Tercio@11 2474 return --> return error
Tercio@11 2475 end
Tercio@11 2476
Tercio@11 2477 side = side or 1
Tercio@11 2478
Tercio@11 2479 local frameTable
Tercio@11 2480 local iconTable
Tercio@11 2481
Tercio@11 2482 if (not frame or (type (frame) == "string" and frame == "main") or (type (frame) == "number" and frame == 1)) then
Tercio@11 2483
Tercio@11 2484 if (not side or (type (side) == "string" and side == "left") or (type (side) == "number" and side == 1)) then
Tercio@11 2485 frameTable = CoolTip.LeftIconTable
Tercio@11 2486
Tercio@11 2487 elseif ((type (side) == "string" and side == "right") or (type (side) == "number" and side == 2)) then
Tercio@11 2488 frameTable = CoolTip.RightIconTable
Tercio@11 2489
Tercio@11 2490 end
Tercio@11 2491
Tercio@11 2492 if (CoolTip.isSpecial) then
Tercio@11 2493 iconTable = {}
Tercio@11 2494 _table_insert (frameTable, CoolTip.Indexes, iconTable)
Tercio@11 2495 else
Tercio@11 2496 iconTable = frameTable [CoolTip.Indexes]
Tercio@11 2497 if (not iconTable) then
Tercio@11 2498 iconTable = {}
Tercio@11 2499 _table_insert (frameTable, CoolTip.Indexes, iconTable)
Tercio@11 2500 --frameTable [CoolTip.Indexes] = iconTable
Tercio@11 2501 end
Tercio@11 2502 end
Tercio@11 2503
Tercio@11 2504 elseif ((type (frame) == "string" and frame == "sub") or (type (frame) == "number" and frame == 2)) then
Tercio@11 2505
Tercio@11 2506 if ((type (side) == "string" and side == "left") or (type (side) == "number" and side == 1)) then
Tercio@11 2507 frameTable = CoolTip.LeftIconTableSub
Tercio@11 2508 elseif ((type (side) == "string" and side == "right") or (type (side) == "number" and side == 2)) then
Tercio@11 2509 frameTable = CoolTip.RightIconTableSub
Tercio@11 2510 elseif ((type (side) == "string" and side == "top") or (type (side) == "number" and side == 3)) then
Tercio@11 2511 CoolTip.TopIconTableSub [CoolTip.Indexes] = CoolTip.TopIconTableSub [CoolTip.Indexes] or {}
Tercio@11 2512 CoolTip.TopIconTableSub [CoolTip.Indexes] [1] = iconTexture
Tercio@11 2513 CoolTip.TopIconTableSub [CoolTip.Indexes] [2] = iconWidth or 16
Tercio@11 2514 CoolTip.TopIconTableSub [CoolTip.Indexes] [3] = iconHeight or 16
Tercio@11 2515 CoolTip.TopIconTableSub [CoolTip.Indexes] [4] = L or 0
Tercio@11 2516 CoolTip.TopIconTableSub [CoolTip.Indexes] [5] = R or 1
Tercio@11 2517 CoolTip.TopIconTableSub [CoolTip.Indexes] [6] = T or 0
Tercio@11 2518 CoolTip.TopIconTableSub [CoolTip.Indexes] [7] = B or 1
Tercio@11 2519 CoolTip.TopIconTableSub [CoolTip.Indexes] [8] = overlayColor or _default_color
Tercio@11 2520 CoolTip.TopIconTableSub [CoolTip.Indexes] [9] = desaturated
Tercio@11 2521 return
Tercio@11 2522 end
Tercio@11 2523
Tercio@11 2524 local subMenuContainerIcons = frameTable [CoolTip.Indexes]
Tercio@11 2525 if (not subMenuContainerIcons) then
Tercio@11 2526 subMenuContainerIcons = {}
Tercio@11 2527 frameTable [CoolTip.Indexes] = subMenuContainerIcons
Tercio@11 2528 end
Tercio@11 2529
Tercio@11 2530 if (CoolTip.isSpecial) then
Tercio@11 2531 iconTable = {}
Tercio@11 2532 subMenuContainerIcons [CoolTip.SubIndexes] = iconTable
Tercio@11 2533 else
Tercio@11 2534 iconTable = subMenuContainerIcons [CoolTip.SubIndexes]
Tercio@11 2535 if (not iconTable) then
Tercio@11 2536 iconTable = {}
Tercio@11 2537 subMenuContainerIcons [CoolTip.SubIndexes] = iconTable
Tercio@11 2538 end
Tercio@11 2539 end
Tercio@11 2540
Tercio@11 2541 else
Tercio@11 2542 return --> error
Tercio@11 2543 end
Tercio@11 2544
Tercio@11 2545 iconTable [1] = iconTexture
Tercio@11 2546 iconTable [2] = iconWidth or 16 --> default 16
Tercio@11 2547 iconTable [3] = iconHeight or 16 --> default 16
Tercio@11 2548 iconTable [4] = L or 0 --> default 0
Tercio@11 2549 iconTable [5] = R or 1 --> default 1
Tercio@11 2550 iconTable [6] = T or 0 --> default 0
Tercio@11 2551 iconTable [7] = B or 1 --> default 1
Tercio@11 2552 iconTable [8] = overlayColor or _default_color --> default 1, 1, 1
Tercio@11 2553 iconTable [9] = desaturated
Tercio@11 2554
Tercio@11 2555 return true
Tercio@11 2556 end
Tercio@11 2557
Tercio@11 2558 ----------------------------------------------------------------------
Tercio@20 2559 --> popup frame
Tercio@20 2560 function CoolTip:AddPopUpFrame (func_on_show, func_on_hide, param1, param2)
Tercio@20 2561
Tercio@20 2562 -- act like a sub menu
Tercio@20 2563 if (CoolTip.Indexes > 0) then
Tercio@20 2564 CoolTip.PopupFrameTable [CoolTip.Indexes] = {func_on_show or false, func_on_hide or false, param1, param2}
Tercio@20 2565 end
Tercio@20 2566
Tercio@20 2567 end
Tercio@20 2568
Tercio@20 2569 ----------------------------------------------------------------------
Tercio@11 2570 --> adds a line.
Tercio@11 2571 --> only works with cooltip type 1 and 2 (tooltip and tooltip with bars)
Tercio@11 2572 --> 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 2573
Tercio@11 2574 --> alias
Tercio@11 2575 function CoolTip:AddDoubleLine (leftText, rightText, frame, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag)
Tercio@11 2576 return CoolTip:AddLine (leftText, rightText, frame, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag)
Tercio@11 2577 end
Tercio@11 2578
Tercio@11 2579 --> adds a line for tooltips
Tercio@11 2580 function CoolTip:AddLine (leftText, rightText, frame, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag)
Tercio@11 2581
Tercio@11 2582 --> check data integrity
Tercio@11 2583 local t = type (leftText)
Tercio@11 2584 if (t ~= "string") then
Tercio@11 2585 if (t == "number") then
Tercio@11 2586 leftText = tostring (leftText)
Tercio@11 2587 else
Tercio@11 2588 leftText = ""
Tercio@11 2589 end
Tercio@11 2590 end
Tercio@11 2591
Tercio@11 2592 local t = type (rightText)
Tercio@11 2593 if (t ~= "string") then
Tercio@11 2594 if (t == "number") then
Tercio@11 2595 rightText = tostring (rightText)
Tercio@11 2596 else
Tercio@11 2597 rightText = ""
Tercio@11 2598 end
Tercio@11 2599 end
Tercio@11 2600
Tercio@11 2601 if (type (ColorR1) ~= "number") then
Tercio@11 2602 ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag = ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2
Tercio@11 2603
Tercio@11 2604 if (type (ColorR1) == "boolean" or not ColorR1) then
Tercio@11 2605 ColorR1, ColorG1, ColorB1, ColorA1 = 0, 0, 0, 0
Tercio@11 2606 else
Tercio@11 2607 ColorR1, ColorG1, ColorB1, ColorA1 = DF:ParseColors (ColorR1)
Tercio@11 2608 end
Tercio@11 2609 end
Tercio@11 2610
Tercio@11 2611 if (type (ColorR2) ~= "number") then
Tercio@11 2612 fontSize, fontFace, fontFlag = ColorG2, ColorB2, ColorA2
Tercio@11 2613
Tercio@11 2614 if (type (ColorR2) == "boolean" or not ColorR2) then
Tercio@11 2615 ColorR2, ColorG2, ColorB2, ColorA2 = 0, 0, 0, 0
Tercio@11 2616 else
Tercio@11 2617 ColorR2, ColorG2, ColorB2, ColorA2 = DF:ParseColors (ColorR2)
Tercio@11 2618 end
Tercio@11 2619 end
Tercio@11 2620
Tercio@11 2621 local frameTableLeft
Tercio@11 2622 local frameTableRight
Tercio@11 2623 local lineTable_left
Tercio@11 2624 local lineTable_right
Tercio@11 2625
Tercio@11 2626 if (not frame or (type (frame) == "string" and frame == "main") or (type (frame) == "number" and frame == 1)) then
Tercio@11 2627
Tercio@11 2628 CoolTip.Indexes = CoolTip.Indexes + 1
Tercio@11 2629
Tercio@11 2630 if (not CoolTip.IndexesSub [CoolTip.Indexes]) then
Tercio@11 2631 CoolTip.IndexesSub [CoolTip.Indexes] = 0
Tercio@11 2632 end
Tercio@11 2633
Tercio@11 2634 CoolTip.SubIndexes = 0
Tercio@11 2635
Tercio@11 2636 frameTableLeft = CoolTip.LeftTextTable
Tercio@11 2637 frameTableRight = CoolTip.RightTextTable
Tercio@11 2638
Tercio@11 2639 if (CoolTip.isSpecial) then
Tercio@11 2640 lineTable_left = {}
Tercio@11 2641 _table_insert (frameTableLeft, CoolTip.Indexes, lineTable_left)
Tercio@11 2642 lineTable_right = {}
Tercio@11 2643 _table_insert (frameTableRight, CoolTip.Indexes, lineTable_right)
Tercio@11 2644 else
Tercio@11 2645 lineTable_left = frameTableLeft [CoolTip.Indexes]
Tercio@11 2646 lineTable_right = frameTableRight [CoolTip.Indexes]
Tercio@11 2647
Tercio@11 2648 if (not lineTable_left) then
Tercio@11 2649 lineTable_left = {}
Tercio@11 2650 _table_insert (frameTableLeft, CoolTip.Indexes, lineTable_left)
Tercio@11 2651 end
Tercio@11 2652 if (not lineTable_right) then
Tercio@11 2653 lineTable_right = {}
Tercio@11 2654 _table_insert (frameTableRight, CoolTip.Indexes, lineTable_right)
Tercio@11 2655 end
Tercio@11 2656 end
Tercio@11 2657
Tercio@11 2658 elseif ((type (frame) == "string" and frame == "sub") or (type (frame) == "number" and frame == 2)) then
Tercio@11 2659
Tercio@11 2660 CoolTip.SubIndexes = CoolTip.SubIndexes + 1
Tercio@11 2661 CoolTip.IndexesSub [CoolTip.Indexes] = CoolTip.IndexesSub [CoolTip.Indexes] + 1
Tercio@11 2662 CoolTip.HaveSubMenu = true
Tercio@11 2663
Tercio@11 2664 frameTableLeft = CoolTip.LeftTextTableSub
Tercio@11 2665 frameTableRight = CoolTip.RightTextTableSub
Tercio@11 2666
Tercio@11 2667 local subMenuContainerTexts = frameTableLeft [CoolTip.Indexes]
Tercio@11 2668 if (not subMenuContainerTexts) then
Tercio@11 2669 subMenuContainerTexts = {}
Tercio@11 2670 _table_insert (frameTableLeft, CoolTip.Indexes, subMenuContainerTexts)
Tercio@11 2671 end
Tercio@11 2672
Tercio@11 2673 if (CoolTip.isSpecial) then
Tercio@11 2674 lineTable_left = {}
Tercio@11 2675 _table_insert (subMenuContainerTexts, CoolTip.SubIndexes, lineTable_left)
Tercio@11 2676 else
Tercio@11 2677 lineTable_left = subMenuContainerTexts [CoolTip.SubIndexes]
Tercio@11 2678 if (not lineTable_left) then
Tercio@11 2679 lineTable_left = {}
Tercio@11 2680 --subMenuContainerTexts [CoolTip.SubIndexes] = lineTable_left
Tercio@11 2681 _table_insert (subMenuContainerTexts, CoolTip.SubIndexes, lineTable_left)
Tercio@11 2682 end
Tercio@11 2683 end
Tercio@11 2684
Tercio@11 2685 local subMenuContainerTexts = frameTableRight [CoolTip.Indexes]
Tercio@11 2686 if (not subMenuContainerTexts) then
Tercio@11 2687 subMenuContainerTexts = {}
Tercio@11 2688 _table_insert (frameTableRight, CoolTip.Indexes, subMenuContainerTexts)
Tercio@11 2689 --frameTableRight [CoolTip.Indexes] = subMenuContainerTexts
Tercio@11 2690 end
Tercio@11 2691
Tercio@11 2692 if (CoolTip.isSpecial) then
Tercio@11 2693 lineTable_right = {}
Tercio@11 2694 _table_insert (subMenuContainerTexts, CoolTip.SubIndexes, lineTable_right)
Tercio@11 2695 else
Tercio@11 2696 lineTable_right = subMenuContainerTexts [CoolTip.SubIndexes]
Tercio@11 2697 if (not lineTable_right) then
Tercio@11 2698 lineTable_right = {}
Tercio@11 2699 _table_insert (subMenuContainerTexts, CoolTip.SubIndexes, lineTable_right)
Tercio@11 2700 --subMenuContainerTexts [CoolTip.SubIndexes] = lineTable_right
Tercio@11 2701 end
Tercio@11 2702 end
Tercio@11 2703 else
Tercio@11 2704 return --> error
Tercio@11 2705 end
Tercio@11 2706
Tercio@11 2707 lineTable_left [1] = leftText --> line text
Tercio@11 2708 lineTable_left [2] = ColorR1
Tercio@11 2709 lineTable_left [3] = ColorG1
Tercio@11 2710 lineTable_left [4] = ColorB1
Tercio@11 2711 lineTable_left [5] = ColorA1
Tercio@11 2712 lineTable_left [6] = fontSize
Tercio@11 2713 lineTable_left [7] = fontFace
Tercio@11 2714 lineTable_left [8] = fontFlag
Tercio@11 2715
Tercio@11 2716 lineTable_right [1] = rightText --> line text
Tercio@11 2717 lineTable_right [2] = ColorR2
Tercio@11 2718 lineTable_right [3] = ColorG2
Tercio@11 2719 lineTable_right [4] = ColorB2
Tercio@11 2720 lineTable_right [5] = ColorA2
Tercio@11 2721 lineTable_right [6] = fontSize
Tercio@11 2722 lineTable_right [7] = fontFace
Tercio@11 2723 lineTable_right [8] = fontFlag
Tercio@11 2724 end
Tercio@11 2725
Tercio@11 2726 function CoolTip:AddSpecial (widgetType, index, subIndex, ...)
Tercio@11 2727
Tercio@11 2728 local currentIndex = CoolTip.Indexes
Tercio@11 2729 local currentSubIndex = CoolTip.SubIndexes
Tercio@11 2730 CoolTip.isSpecial = true
Tercio@11 2731
Tercio@11 2732 widgetType = string.lower (widgetType)
Tercio@11 2733
Tercio@11 2734 if (widgetType == "line") then
Tercio@11 2735
Tercio@11 2736 if (subIndex) then
Tercio@11 2737 CoolTip.Indexes = index
Tercio@11 2738 CoolTip.SubIndexes = subIndex-1
Tercio@11 2739 else
Tercio@11 2740 CoolTip.Indexes = index-1
Tercio@11 2741 end
Tercio@11 2742
Tercio@11 2743 CoolTip:AddLine (...)
Tercio@11 2744
Tercio@11 2745 if (subIndex) then
Tercio@11 2746 CoolTip.Indexes = currentIndex
Tercio@11 2747 CoolTip.SubIndexes = currentSubIndex+1
Tercio@11 2748 else
Tercio@11 2749 CoolTip.Indexes = currentIndex+1
Tercio@11 2750 end
Tercio@11 2751
Tercio@11 2752 elseif (widgetType == "icon") then
Tercio@11 2753
Tercio@11 2754 CoolTip.Indexes = index
Tercio@11 2755 if (subIndex) then
Tercio@11 2756 CoolTip.SubIndexes = subIndex
Tercio@11 2757 end
Tercio@11 2758
Tercio@11 2759 CoolTip:AddIcon (...)
Tercio@11 2760
Tercio@11 2761 CoolTip.Indexes = currentIndex
Tercio@11 2762 if (subIndex) then
Tercio@11 2763 CoolTip.SubIndexes = currentSubIndex
Tercio@11 2764 end
Tercio@11 2765
Tercio@11 2766 elseif (widgetType == "statusbar") then
Tercio@11 2767
Tercio@11 2768 CoolTip.Indexes = index
Tercio@11 2769 if (subIndex) then
Tercio@11 2770 CoolTip.SubIndexes = subIndex
Tercio@11 2771 end
Tercio@11 2772
Tercio@11 2773 CoolTip:AddStatusBar (...)
Tercio@11 2774
Tercio@11 2775 CoolTip.Indexes = currentIndex
Tercio@11 2776 if (subIndex) then
Tercio@11 2777 CoolTip.SubIndexes = currentSubIndex
Tercio@11 2778 end
Tercio@11 2779
Tercio@11 2780 elseif (widgetType == "menu") then
Tercio@11 2781
Tercio@11 2782 CoolTip.Indexes = index
Tercio@11 2783 if (subIndex) then
Tercio@11 2784 CoolTip.SubIndexes = subIndex
Tercio@11 2785 end
Tercio@11 2786
Tercio@11 2787 CoolTip:AddMenu (...)
Tercio@11 2788
Tercio@11 2789 CoolTip.Indexes = currentIndex
Tercio@11 2790 if (subIndex) then
Tercio@11 2791 CoolTip.SubIndexes = currentSubIndex
Tercio@11 2792 end
Tercio@11 2793
Tercio@11 2794 end
Tercio@11 2795
Tercio@11 2796 CoolTip.isSpecial = false
Tercio@11 2797
Tercio@11 2798 end
Tercio@11 2799
Tercio@11 2800 --> search key: ~fromline
Tercio@11 2801 function CoolTip:AddFromTable (_table)
Tercio@11 2802 for index, menu in _ipairs (_table) do
Tercio@11 2803 if (menu.func) then
Tercio@11 2804 CoolTip:AddMenu (menu.type or 1, menu.func, menu.param1, menu.param2, menu.param3, nil, menu.icon)
Tercio@11 2805 elseif (menu.statusbar) then
Tercio@11 2806 CoolTip:AddStatusBar (menu.value, menu.type or 1, menu.color, true)
Tercio@11 2807 elseif (menu.icon) then
Tercio@11 2808 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 2809 elseif (menu.textleft or menu.textright or menu.text) then
Tercio@11 2810 CoolTip:AddLine (menu.text, "", menu.type, menu.color, menu.color)
Tercio@11 2811 end
Tercio@11 2812 end
Tercio@11 2813 end
Tercio@11 2814
Tercio@11 2815 ----------------------------------------------------------------------
Tercio@11 2816 --> show cooltip
Tercio@11 2817
Tercio@11 2818 --> serach key: ~start
Tercio@11 2819 function CoolTip:Show (frame, menuType, color)
Tercio@20 2820 CoolTip.had_interaction = false
Tercio@11 2821 return CoolTip:ShowCooltip (frame, menuType, color)
Tercio@11 2822 end
Tercio@11 2823
Tercio@11 2824 function CoolTip:ShowCooltip (frame, menuType, color)
Tercio@11 2825
Tercio@20 2826 CoolTip.had_interaction = false
Tercio@20 2827
Tercio@11 2828 if (frame) then
Tercio@11 2829 --> details framework
Tercio@11 2830 if (frame.dframework) then
Tercio@11 2831 frame = frame.widget
Tercio@11 2832 end
Tercio@11 2833 CoolTip:SetHost (frame)
Tercio@11 2834 end
Tercio@11 2835 if (menuType) then
Tercio@11 2836 CoolTip:SetType (menuType)
Tercio@11 2837 end
Tercio@11 2838 if (color) then
Tercio@11 2839 CoolTip:SetColor (1, color)
Tercio@11 2840 CoolTip:SetColor (2, color)
Tercio@11 2841 end
Tercio@11 2842
Tercio@11 2843 if (CoolTip.Type == 1 or CoolTip.Type == 2) then
Tercio@11 2844 return CoolTip:monta_tooltip()
Tercio@11 2845
Tercio@11 2846 elseif (CoolTip.Type == 3) then
Tercio@11 2847 return CoolTip:monta_cooltip()
Tercio@11 2848
Tercio@11 2849 end
Tercio@11 2850 end
Tercio@11 2851
Tercio@11 2852 local emptyOptions = {}
Tercio@11 2853
Tercio@11 2854 function CoolTip:Hide()
Tercio@11 2855 return CoolTip:Close()
Tercio@11 2856 end
Tercio@11 2857
Tercio@11 2858 function CoolTip:Close()
Tercio@11 2859 CoolTip.active = false
Tercio@11 2860 CoolTip.Host = nil
Tercio@26 2861 DF:FadeFrame (frame1, 1)
Tercio@26 2862 DF:FadeFrame (frame2, 1)
Tercio@11 2863
Tercio@11 2864 end
Tercio@11 2865
Tercio@11 2866 --> old function call
Tercio@11 2867 function CoolTip:ShowMe (host, arg2)
Tercio@11 2868 --> ignore if mouse is up me
Tercio@11 2869 if (CoolTip.mouseOver) then
Tercio@11 2870 return
Tercio@11 2871 end
Tercio@11 2872
Tercio@11 2873 if (not host or not arg2) then --> hideme
Tercio@11 2874 CoolTip:Close()
Tercio@11 2875 end
Tercio@11 2876 end
Tercio@11 2877
Tercio@11 2878 --> search key: ~inject
Tercio@11 2879 function CoolTip:ExecFunc (host, fromClick)
Tercio@11 2880
Tercio@11 2881 if (host.dframework) then
Tercio@11 2882 if (not host.widget.CoolTip) then
Tercio@11 2883 host.widget.CoolTip = host.CoolTip
Tercio@11 2884 end
Tercio@11 2885 host = host.widget
Tercio@11 2886 end
Tercio@11 2887
Tercio@11 2888 CoolTip:Reset()
Tercio@11 2889 CoolTip:SetType (host.CoolTip.Type)
Tercio@11 2890 CoolTip:SetFixedParameter (host.CoolTip.FixedValue)
Tercio@11 2891 CoolTip:SetColor ("main", host.CoolTip.MainColor or "transparent")
Tercio@11 2892 CoolTip:SetColor ("sec", host.CoolTip.SubColor or "transparent")
Tercio@11 2893
Tercio@11 2894 CoolTip:SetOwner (host, host.CoolTip.MyAnchor, host.CoolTip.HisAnchor, host.CoolTip.X, host.CoolTip.Y)
Tercio@11 2895
Tercio@11 2896 local options = host.CoolTip.Options
Tercio@11 2897 if (type (options) == "function") then
Tercio@11 2898 options = options()
Tercio@11 2899 end
Tercio@11 2900 if (options) then
Tercio@11 2901 for optionName, optionValue in pairs (options) do
Tercio@11 2902 CoolTip:SetOption (optionName, optionValue)
Tercio@11 2903 end
Tercio@11 2904 end
Tercio@11 2905
Tercio@11 2906 host.CoolTip.BuildFunc()
Tercio@11 2907
Tercio@11 2908 if (CoolTip.Indexes == 0) then
Tercio@11 2909 if (host.CoolTip.Default) then
Tercio@11 2910 CoolTip:SetType ("tooltip")
Tercio@11 2911 CoolTip:AddLine (host.CoolTip.Default, nil, 1, "white")
Tercio@11 2912 end
Tercio@11 2913 end
Tercio@11 2914
Tercio@11 2915 CoolTip:ShowCooltip()
Tercio@11 2916
Tercio@11 2917 if (fromClick) then
Tercio@11 2918 --UIFrameFlash (frame1, )
Tercio@11 2919 frame1:Flash (0.05, 0.05, 0.2, true, 0, 0)
Tercio@11 2920 end
Tercio@11 2921 end
Tercio@11 2922
Tercio@11 2923 local wait = 0.2
Tercio@11 2924
Tercio@11 2925 local InjectOnUpdateEnter = function (self, elapsed)
Tercio@11 2926 elapsedTime = elapsedTime+elapsed
Tercio@11 2927 if (elapsedTime > wait) then
Tercio@11 2928 self:SetScript ("OnUpdate", nil)
Tercio@11 2929 CoolTip:ExecFunc (self)
Tercio@11 2930 end
Tercio@11 2931 end
Tercio@11 2932
Tercio@11 2933 local InjectOnUpdateLeave = function (self, elapsed)
Tercio@11 2934 elapsedTime = elapsedTime+elapsed
Tercio@11 2935 if (elapsedTime > 0.2) then
Tercio@11 2936 if (not CoolTip.mouseOver and not CoolTip.buttonOver and self == CoolTip.Host) then
Tercio@11 2937 CoolTip:ShowMe (false)
Tercio@11 2938 end
Tercio@11 2939 self:SetScript ("OnUpdate", nil)
Tercio@11 2940 end
Tercio@11 2941 end
Tercio@11 2942
Tercio@11 2943 local InjectOnLeave = function (self)
Tercio@11 2944 CoolTip.buttonOver = false
Tercio@11 2945
Tercio@11 2946 if (CoolTip.active) then
Tercio@11 2947 elapsedTime = 0
Tercio@11 2948 self:SetScript ("OnUpdate", InjectOnUpdateLeave)
Tercio@11 2949 else
Tercio@11 2950 self:SetScript ("OnUpdate", nil)
Tercio@11 2951 end
Tercio@11 2952
Tercio@11 2953 if (self.CoolTip.OnLeaveFunc) then
Tercio@11 2954 self.CoolTip.OnLeaveFunc (self)
Tercio@11 2955 end
Tercio@11 2956
Tercio@11 2957 if (self.OldOnLeaveScript) then
Tercio@11 2958 self:OldOnLeaveScript()
Tercio@11 2959 end
Tercio@11 2960 end
Tercio@11 2961
Tercio@11 2962 local InjectOnEnter = function (self)
Tercio@11 2963 CoolTip.buttonOver = true
Tercio@11 2964 if (CoolTip.active) then
Tercio@11 2965 CoolTip:ExecFunc (self)
Tercio@11 2966 else
Tercio@11 2967 elapsedTime = 0
Tercio@11 2968 wait = self.CoolTip.ShowSpeed or 0.2
Tercio@11 2969 self:SetScript ("OnUpdate", InjectOnUpdateEnter)
Tercio@11 2970 end
Tercio@11 2971
Tercio@11 2972 if (self.CoolTip.OnEnterFunc) then
Tercio@11 2973 self.CoolTip.OnEnterFunc (self)
Tercio@11 2974 end
Tercio@11 2975
Tercio@11 2976 if (self.OldOnEnterScript) then
Tercio@11 2977 self:OldOnEnterScript()
Tercio@11 2978 end
Tercio@11 2979 end
Tercio@11 2980
Tercio@11 2981 function CoolTip:CoolTipInject (host, openOnClick)
Tercio@11 2982 if (host.dframework) then
Tercio@11 2983 if (not host.widget.CoolTip) then
Tercio@11 2984 host.widget.CoolTip = host.CoolTip
Tercio@11 2985 end
Tercio@11 2986 host = host.widget
Tercio@11 2987 end
Tercio@11 2988
Tercio@11 2989 local coolTable = host.CoolTip
Tercio@11 2990 if (not coolTable) then
Tercio@11 2991 print ("Host nao tem uma CoolTable.")
Tercio@11 2992 return false
Tercio@11 2993 end
Tercio@11 2994
Tercio@11 2995 host.OldOnEnterScript = host:GetScript ("OnEnter")
Tercio@11 2996 host.OldOnLeaveScript = host:GetScript ("OnLeave")
Tercio@11 2997
Tercio@11 2998 host:SetScript ("OnEnter", InjectOnEnter)
Tercio@11 2999 host:SetScript ("OnLeave", InjectOnLeave)
Tercio@11 3000
Tercio@11 3001 if (openOnClick) then
Tercio@11 3002 if (host:GetObjectType() == "Button") then
Tercio@11 3003 host:SetScript ("OnClick", function() CoolTip:ExecFunc (host, true) end)
Tercio@11 3004 end
Tercio@11 3005 end
Tercio@11 3006
Tercio@11 3007 return ture
Tercio@11 3008 end
Tercio@11 3009
Tercio@11 3010 --> all done
Tercio@11 3011 CoolTip:ClearAllOptions()
Tercio@11 3012
Tercio@11 3013 local preset2_backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = DF.folder .. "border_3", tile=true,
Tercio@11 3014 edgeSize = 16, tileSize = 64, insets = {left = 3, right = 3, top = 4, bottom = 4}}
Tercio@11 3015
Tercio@11 3016 local white_table = {1, 1, 1, 1}
Tercio@11 3017
Tercio@11 3018 function CoolTip:Preset (number)
Tercio@11 3019 self:Reset()
Tercio@11 3020
Tercio@11 3021 if (number == 1) then
Tercio@11 3022 self:SetOption ("TextFont", "Friz Quadrata TT")
Tercio@11 3023 self:SetOption ("TextColor", "orange")
Tercio@11 3024 self:SetOption ("TextSize", 12)
Tercio@11 3025 self:SetOption ("ButtonsYMod", -4)
Tercio@11 3026 self:SetOption ("YSpacingMod", -4)
Tercio@11 3027 self:SetOption ("IgnoreButtonAutoHeight", true)
Tercio@11 3028 self:SetColor (1, 0.5, 0.5, 0.5, 0.5)
Tercio@11 3029
Tercio@11 3030 elseif (number == 2) then
Tercio@11 3031 self:SetOption ("TextFont", "Friz Quadrata TT")
Tercio@11 3032 self:SetOption ("TextColor", "orange")
Tercio@11 3033 self:SetOption ("TextSize", 12)
Tercio@11 3034 self:SetOption ("FixedWidth", 220)
Tercio@11 3035 self:SetOption ("ButtonsYMod", -4)
Tercio@11 3036 self:SetOption ("YSpacingMod", -4)
Tercio@11 3037 self:SetOption ("IgnoreButtonAutoHeight", true)
Tercio@11 3038 self:SetColor (1, 0.5, 0.5, 0.5, 0.5)
Tercio@11 3039
Tercio@11 3040 self:SetBackdrop (1, preset2_backdrop, nil, white_table)
Tercio@11 3041 end
Tercio@11 3042 end
Tercio@11 3043
Tercio@11 3044 return CoolTip
Tercio@11 3045
Tercio@11 3046 end
Tercio@11 3047
Tercio@11 3048 DF:CreateCoolTip()