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

- framework update.
author Tercio
date Fri, 16 Oct 2015 14:46:27 -0300
parents dc1c77254f80
children 5da06cb420d4
comparison
equal deleted inserted replaced
25:6bb668a41455 26:e16b1fc13935
186 GameCooltipFrame2_FrameBackgroundRight:SetTexture (DF.folder .. "cooltip_background") 186 GameCooltipFrame2_FrameBackgroundRight:SetTexture (DF.folder .. "cooltip_background")
187 GameCooltipFrame2_FrameBackgroundRight:SetTexCoord (0.896484375, 1, 0, 1) 187 GameCooltipFrame2_FrameBackgroundRight:SetTexCoord (0.896484375, 1, 0, 1)
188 188
189 CoolTip.frame1 = frame1 189 CoolTip.frame1 = frame1
190 CoolTip.frame2 = frame2 190 CoolTip.frame2 = frame2
191 DF:Fade (frame1, 0) 191 DF:FadeFrame (frame1, 0)
192 DF:Fade (frame2, 0) 192 DF:FadeFrame (frame2, 0)
193 193
194 --> button containers 194 --> button containers
195 frame1.Lines = {} 195 frame1.Lines = {}
196 frame2.Lines = {} 196 frame2.Lines = {}
197 197
259 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then --> menu 259 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then --> menu
260 CoolTip.active = true 260 CoolTip.active = true
261 CoolTip.mouseOver = true 261 CoolTip.mouseOver = true
262 CoolTip.had_interaction = true 262 CoolTip.had_interaction = true
263 self:SetScript ("OnUpdate", nil) 263 self:SetScript ("OnUpdate", nil)
264 DF:Fade (self, 0) 264 DF:FadeFrame (self, 0)
265 --rever 265 --rever
266 if (CoolTip.sub_menus) then 266 if (CoolTip.sub_menus) then
267 DF:Fade (frame2, 0) 267 DF:FadeFrame (frame2, 0)
268 end 268 end
269 end 269 end
270 end) 270 end)
271 271
272 frame2:SetScript ("OnEnter", function (self) 272 frame2:SetScript ("OnEnter", function (self)
276 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then 276 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
277 CoolTip.active = true 277 CoolTip.active = true
278 CoolTip.mouseOver = true 278 CoolTip.mouseOver = true
279 CoolTip.had_interaction = true 279 CoolTip.had_interaction = true
280 self:SetScript ("OnUpdate", nil) 280 self:SetScript ("OnUpdate", nil)
281 DF:Fade (self, 0) 281 DF:FadeFrame (self, 0)
282 DF:Fade (frame1, 0) 282 DF:FadeFrame (frame1, 0)
283 end 283 end
284 end) 284 end)
285 285
286 local OnLeaveUpdateFrame1 = function (self, elapsed) 286 local OnLeaveUpdateFrame1 = function (self, elapsed)
287 elapsedTime = elapsedTime+elapsed 287 elapsedTime = elapsedTime+elapsed
288 if (elapsedTime > 0.7) then 288 if (elapsedTime > 0.7) then
289 if (not CoolTip.active and not CoolTip.buttonClicked and self == CoolTip.Host) then 289 if (not CoolTip.active and not CoolTip.buttonClicked and self == CoolTip.Host) then
290 DF:Fade (self, 1) 290 DF:FadeFrame (self, 1)
291 DF:Fade (frame2, 1) 291 DF:FadeFrame (frame2, 1)
292 elseif (not CoolTip.active) then 292 elseif (not CoolTip.active) then
293 DF:Fade (self, 1) 293 DF:FadeFrame (self, 1)
294 DF:Fade (frame2, 1) 294 DF:FadeFrame (frame2, 1)
295 end 295 end
296 self:SetScript ("OnUpdate", nil) 296 self:SetScript ("OnUpdate", nil)
297 frame2:SetScript ("OnUpdate", nil) 297 frame2:SetScript ("OnUpdate", nil)
298 end 298 end
299 end 299 end
315 315
316 local OnLeaveUpdateFrame2 = function (self, elapsed) 316 local OnLeaveUpdateFrame2 = function (self, elapsed)
317 elapsedTime = elapsedTime+elapsed 317 elapsedTime = elapsedTime+elapsed
318 if (elapsedTime > 0.7) then 318 if (elapsedTime > 0.7) then
319 if (not CoolTip.active and not CoolTip.buttonClicked and self == CoolTip.Host) then 319 if (not CoolTip.active and not CoolTip.buttonClicked and self == CoolTip.Host) then
320 DF:Fade (self, 1) 320 DF:FadeFrame (self, 1)
321 DF:Fade (frame2, 1) 321 DF:FadeFrame (frame2, 1)
322 elseif (not CoolTip.active) then 322 elseif (not CoolTip.active) then
323 DF:Fade (self, 1) 323 DF:FadeFrame (self, 1)
324 DF:Fade (frame2, 1) 324 DF:FadeFrame (frame2, 1)
325 end 325 end
326 self:SetScript ("OnUpdate", nil) 326 self:SetScript ("OnUpdate", nil)
327 frame1:SetScript ("OnUpdate", nil) 327 frame1:SetScript ("OnUpdate", nil)
328 end 328 end
329 end 329 end
384 384
385 local OnLeaveUpdateButton = function (self, elapsed) 385 local OnLeaveUpdateButton = function (self, elapsed)
386 elapsedTime = elapsedTime+elapsed 386 elapsedTime = elapsedTime+elapsed
387 if (elapsedTime > 0.7) then 387 if (elapsedTime > 0.7) then
388 if (not CoolTip.active and not CoolTip.buttonClicked) then 388 if (not CoolTip.active and not CoolTip.buttonClicked) then
389 DF:Fade (frame1, 1) 389 DF:FadeFrame (frame1, 1)
390 DF:Fade (frame2, 1) 390 DF:FadeFrame (frame2, 1)
391 391
392 elseif (not CoolTip.active) then 392 elseif (not CoolTip.active) then
393 DF:Fade (frame1, 1) 393 DF:FadeFrame (frame1, 1)
394 DF:Fade (frame2, 1) 394 DF:FadeFrame (frame2, 1)
395 end 395 end
396 frame1:SetScript ("OnUpdate", nil) 396 frame1:SetScript ("OnUpdate", nil)
397 end 397 end
398 end 398 end
399 399
439 botao:SetScript ("OnUpdate", OnEnterUpdateButton) 439 botao:SetScript ("OnUpdate", OnEnterUpdateButton)
440 end 440 end
441 441
442 else 442 else
443 --hide second frame 443 --hide second frame
444 DF:Fade (frame2, 1) 444 DF:FadeFrame (frame2, 1)
445 CoolTip.last_button = nil 445 CoolTip.last_button = nil
446 end 446 end
447 else 447 else
448 CoolTip.mouseOver = true 448 CoolTip.mouseOver = true
449 CoolTip.had_interaction = true 449 CoolTip.had_interaction = true
489 489
490 local OnLeaveUpdateButtonSec = function (self, elapsed) 490 local OnLeaveUpdateButtonSec = function (self, elapsed)
491 elapsedTime = elapsedTime+elapsed 491 elapsedTime = elapsedTime+elapsed
492 if (elapsedTime > 0.7) then 492 if (elapsedTime > 0.7) then
493 if (not CoolTip.active and not CoolTip.buttonClicked) then 493 if (not CoolTip.active and not CoolTip.buttonClicked) then
494 DF:Fade (frame1, 1) 494 DF:FadeFrame (frame1, 1)
495 DF:Fade (frame2, 1) 495 DF:FadeFrame (frame2, 1)
496 elseif (not CoolTip.active) then 496 elseif (not CoolTip.active) then
497 DF:Fade (frame1, 1) 497 DF:FadeFrame (frame1, 1)
498 DF:Fade (frame2, 1) 498 DF:FadeFrame (frame2, 1)
499 end 499 end
500 frame2:SetScript ("OnUpdate", nil) 500 frame2:SetScript ("OnUpdate", nil)
501 end 501 end
502 end 502 end
503 503
522 end 522 end
523 523
524 frame1:SetScript ("OnUpdate", nil) 524 frame1:SetScript ("OnUpdate", nil)
525 frame2:SetScript ("OnUpdate", nil) 525 frame2:SetScript ("OnUpdate", nil)
526 526
527 DF:Fade (frame1, 0) 527 DF:FadeFrame (frame1, 0)
528 DF:Fade (frame2, 0) 528 DF:FadeFrame (frame2, 0)
529 else 529 else
530 CoolTip.mouseOver = true 530 CoolTip.mouseOver = true
531 CoolTip.had_interaction = true 531 CoolTip.had_interaction = true
532 end 532 end
533 end) 533 end)
997 menuButton:SetPoint ("center", frame2, "center") 997 menuButton:SetPoint ("center", frame2, "center")
998 menuButton:SetPoint ("top", frame2, "top", 0, (((index-1)*20)*-1)-3) 998 menuButton:SetPoint ("top", frame2, "top", 0, (((index-1)*20)*-1)-3)
999 menuButton:SetPoint ("left", frame2, "left") 999 menuButton:SetPoint ("left", frame2, "left")
1000 menuButton:SetPoint ("right", frame2, "right") 1000 menuButton:SetPoint ("right", frame2, "right")
1001 1001
1002 DF:Fade (menuButton, 0) 1002 DF:FadeFrame (menuButton, 0)
1003 1003
1004 --> string length 1004 --> string length
1005 local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth() 1005 local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth()
1006 if (stringWidth > frame2.w) then 1006 if (stringWidth > frame2.w) then
1007 frame2.w = stringWidth 1007 frame2.w = stringWidth
1046 -- -- -------------------------------------------------------------------------------------------------------------- 1046 -- -- --------------------------------------------------------------------------------------------------------------
1047 1047
1048 function CoolTip:ShowSub (index) 1048 function CoolTip:ShowSub (index)
1049 1049
1050 if (CoolTip.OptionsTable.IgnoreSubMenu) then 1050 if (CoolTip.OptionsTable.IgnoreSubMenu) then
1051 DF:Fade (frame2, 1) 1051 DF:FadeFrame (frame2, 1)
1052 return 1052 return
1053 end 1053 end
1054 1054
1055 frame2:SetHeight (6) 1055 frame2:SetHeight (6)
1056 1056
1112 else 1112 else
1113 CoolTip:HideSelectedTexture (frame2) 1113 CoolTip:HideSelectedTexture (frame2)
1114 end 1114 end
1115 1115
1116 for i = CoolTip.IndexesSub [index] + 1, #frame2.Lines do 1116 for i = CoolTip.IndexesSub [index] + 1, #frame2.Lines do
1117 DF:Fade (frame2.Lines[i], 1) 1117 DF:FadeFrame (frame2.Lines[i], 1)
1118 end 1118 end
1119 1119
1120 local spacing = 0 1120 local spacing = 0
1121 if (CoolTip.OptionsTable.YSpacingModSub) then 1121 if (CoolTip.OptionsTable.YSpacingModSub) then
1122 spacing = CoolTip.OptionsTable.YSpacingModSub 1122 spacing = CoolTip.OptionsTable.YSpacingModSub
1215 1215
1216 if (not CoolTip.OptionsTable.FixedWidthSub) then 1216 if (not CoolTip.OptionsTable.FixedWidthSub) then
1217 frame2:SetWidth (frame2.w + 44) 1217 frame2:SetWidth (frame2.w + 44)
1218 end 1218 end
1219 1219
1220 DF:Fade (frame2, 0) 1220 DF:FadeFrame (frame2, 0)
1221 1221
1222 CoolTip:CheckOverlap() 1222 CoolTip:CheckOverlap()
1223 1223
1224 if (CoolTip.OptionsTable.SubFollowButton and not CoolTip.frame2_leftside) then 1224 if (CoolTip.OptionsTable.SubFollowButton and not CoolTip.frame2_leftside) then
1225 1225
1244 end 1244 end
1245 1245
1246 end 1246 end
1247 1247
1248 function CoolTip:HideSub() 1248 function CoolTip:HideSub()
1249 DF:Fade (frame2, 1) 1249 DF:FadeFrame (frame2, 1)
1250 end 1250 end
1251 1251
1252 1252
1253 function CoolTip:LeftTextSpace (row) 1253 function CoolTip:LeftTextSpace (row)
1254 row.leftText:SetWidth (row:GetWidth() - 30 - row.leftIcon:GetWidth() - row.rightIcon:GetWidth() - row.rightText:GetStringWidth()) 1254 row.leftText:SetWidth (row:GetWidth() - 30 - row.leftIcon:GetWidth() - row.rightIcon:GetWidth() - row.rightText:GetStringWidth())
1255 row.leftText:SetHeight (10) 1255 row.leftText:SetHeight (10)
1256 end 1256 end
1257 1257
1258 --> ~inicio ~start 1258 --> ~inicio ~start ~tooltip
1259 function CoolTip:monta_tooltip() 1259 function CoolTip:monta_tooltip()
1260 1260
1261 --> hide sub frame 1261 --> hide sub frame
1262 DF:Fade (frame2, 1) 1262 DF:FadeFrame (frame2, 1)
1263 --> hide select bar 1263 --> hide select bar
1264 CoolTip:HideSelectedTexture (frame1) 1264 CoolTip:HideSelectedTexture (frame1)
1265 1265
1266 frame1:EnableMouse (false) 1266 frame1:EnableMouse (false)
1267 1267
1391 else 1391 else
1392 frame1.frameWallpaper:Hide() 1392 frame1.frameWallpaper:Hide()
1393 end 1393 end
1394 1394
1395 --> unhide frame 1395 --> unhide frame
1396 DF:Fade (frame1, 0) 1396 DF:FadeFrame (frame1, 0)
1397 CoolTip:SetMyPoint (host) 1397 CoolTip:SetMyPoint (host)
1398 1398
1399 --> fix sparks 1399 --> fix sparks
1400 for i = 1, CoolTip.Indexes do 1400 for i = 1, CoolTip.Indexes do
1401 local menuButton = frame1.Lines [i] 1401 local menuButton = frame1.Lines [i]
1415 button.divbar:SetAlpha (0.1) 1415 button.divbar:SetAlpha (0.1)
1416 1416
1417 button.divbar:SetDesaturated (true) 1417 button.divbar:SetDesaturated (true)
1418 end 1418 end
1419 1419
1420 --> ~inicio ~start 1420 --> ~inicio ~start ~menu
1421 function CoolTip:monta_cooltip (host, instancia, options, sub_menus, icones, tamanho1, tamanho2, font, fontsize) 1421 function CoolTip:monta_cooltip (host, instancia, options, sub_menus, icones, tamanho1, tamanho2, font, fontsize)
1422 1422
1423 if (CoolTip.Indexes == 0) then 1423 if (CoolTip.Indexes == 0) then
1424 CoolTip:Reset() 1424 CoolTip:Reset()
1425 CoolTip:SetType ("tooltip") 1425 CoolTip:SetType ("tooltip")
1440 1440
1441 if (CoolTip.HaveSubMenu) then --> zera o segundo frame 1441 if (CoolTip.HaveSubMenu) then --> zera o segundo frame
1442 frame2.w = 0 1442 frame2.w = 0
1443 frame2:SetHeight (6) 1443 frame2:SetHeight (6)
1444 if (CoolTip.SelectedIndexMain and CoolTip.IndexesSub [CoolTip.SelectedIndexMain] and CoolTip.IndexesSub [CoolTip.SelectedIndexMain] > 0) then 1444 if (CoolTip.SelectedIndexMain and CoolTip.IndexesSub [CoolTip.SelectedIndexMain] and CoolTip.IndexesSub [CoolTip.SelectedIndexMain] > 0) then
1445 DF:Fade (frame2, 0) 1445 DF:FadeFrame (frame2, 0)
1446 else 1446 else
1447 DF:Fade (frame2, 1) 1447 DF:FadeFrame (frame2, 1)
1448 end 1448 end
1449 else 1449 else
1450 DF:Fade (frame2, 1) 1450 DF:FadeFrame (frame2, 1)
1451 end 1451 end
1452 1452
1453 CoolTip.active = true 1453 CoolTip.active = true
1454 1454
1455 for i = 1, CoolTip.Indexes do 1455 for i = 1, CoolTip.Indexes do
1598 CoolTip:SetupWallpaper (CoolTip.WallpaperTable, frame1.frameWallpaper) 1598 CoolTip:SetupWallpaper (CoolTip.WallpaperTable, frame1.frameWallpaper)
1599 else 1599 else
1600 frame1.frameWallpaper:Hide() 1600 frame1.frameWallpaper:Hide()
1601 end 1601 end
1602 1602
1603 DF:Fade (frame1, 0) 1603 DF:FadeFrame (frame1, 0)
1604 1604
1605 for i = 1, CoolTip.Indexes do 1605 for i = 1, CoolTip.Indexes do
1606 if (CoolTip.SelectedIndexMain and CoolTip.SelectedIndexMain == i) then 1606 if (CoolTip.SelectedIndexMain and CoolTip.SelectedIndexMain == i) then
1607 if (CoolTip.HaveSubMenu and CoolTip.IndexesSub [i] and CoolTip.IndexesSub [i] > 0) then 1607 if (CoolTip.HaveSubMenu and CoolTip.IndexesSub [i] and CoolTip.IndexesSub [i] > 0) then
1608 CoolTip:ShowSub (i) 1608 CoolTip:ShowSub (i)
2856 end 2856 end
2857 2857
2858 function CoolTip:Close() 2858 function CoolTip:Close()
2859 CoolTip.active = false 2859 CoolTip.active = false
2860 CoolTip.Host = nil 2860 CoolTip.Host = nil
2861 DF:Fade (frame1, 1) 2861 DF:FadeFrame (frame1, 1)
2862 DF:Fade (frame2, 1) 2862 DF:FadeFrame (frame2, 1)
2863 2863
2864 end 2864 end
2865 2865
2866 --> old function call 2866 --> old function call
2867 function CoolTip:ShowMe (host, arg2) 2867 function CoolTip:ShowMe (host, arg2)