annotate Libs/DF/cooltip.lua @ 55:307f5af3ad02

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