Mercurial > wow > hansgar_and_franzok_assist
comparison Libs/DF/cooltip.lua @ 20:dc1c77254f80
- added close button to users panel.
- framework update.
| author | Tercio |
|---|---|
| date | Tue, 11 Aug 2015 12:46:46 -0300 |
| parents | 2f09fe4be15c |
| children | e16b1fc13935 |
comparison
equal
deleted
inserted
replaced
| 19:215f0dd37a6c | 20:dc1c77254f80 |
|---|---|
| 1 | 1 |
| 2 local DF = _G ["DetailsFramework"] | 2 local DF = _G ["DetailsFramework"] |
| 3 if (not DF or not DetailsFrameworkCanLoad) then | |
| 4 return | |
| 5 end | |
| 6 | |
| 3 local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0") | 7 local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0") |
| 4 | |
| 5 local _ | 8 local _ |
| 6 --lua locals | 9 --lua locals |
| 7 local _math_floor= math.floor | 10 local _math_floor= math.floor |
| 8 local _type = type | 11 local _type = type |
| 9 local _math_abs = math.abs | 12 local _math_abs = math.abs |
| 17 local _GetScreenWidth = GetScreenWidth | 20 local _GetScreenWidth = GetScreenWidth |
| 18 local _GetScreenHeight = GetScreenHeight | 21 local _GetScreenHeight = GetScreenHeight |
| 19 local _UIParent = UIParent | 22 local _UIParent = UIParent |
| 20 local _CreateFrame = CreateFrame | 23 local _CreateFrame = CreateFrame |
| 21 | 24 |
| 22 local version = 1 | 25 local version = 2 |
| 23 | 26 |
| 24 function DF:CreateCoolTip() | 27 function DF:CreateCoolTip() |
| 25 | 28 |
| 26 ---------------------------------------------------------------------- | 29 ---------------------------------------------------------------------- |
| 27 --> Cooltip Startup | 30 --> Cooltip Startup |
| 48 CoolTip.TopIconTableSub = {} | 51 CoolTip.TopIconTableSub = {} |
| 49 CoolTip.StatusBarTable = {} | 52 CoolTip.StatusBarTable = {} |
| 50 CoolTip.StatusBarTableSub = {} | 53 CoolTip.StatusBarTableSub = {} |
| 51 CoolTip.WallpaperTable = {} | 54 CoolTip.WallpaperTable = {} |
| 52 CoolTip.WallpaperTableSub = {} | 55 CoolTip.WallpaperTableSub = {} |
| 56 | |
| 57 CoolTip.PopupFrameTable = {} | |
| 53 | 58 |
| 54 CoolTip.FunctionsTableMain = {} --> menus | 59 CoolTip.FunctionsTableMain = {} --> menus |
| 55 CoolTip.FunctionsTableSub = {} --> menus | 60 CoolTip.FunctionsTableSub = {} --> menus |
| 56 CoolTip.ParametersTableMain = {} --> menus | 61 CoolTip.ParametersTableMain = {} --> menus |
| 57 CoolTip.ParametersTableSub = {} --> menus | 62 CoolTip.ParametersTableSub = {} --> menus |
| 252 | 257 |
| 253 frame1:SetScript ("OnEnter", function (self) | 258 frame1:SetScript ("OnEnter", function (self) |
| 254 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then --> menu | 259 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then --> menu |
| 255 CoolTip.active = true | 260 CoolTip.active = true |
| 256 CoolTip.mouseOver = true | 261 CoolTip.mouseOver = true |
| 262 CoolTip.had_interaction = true | |
| 257 self:SetScript ("OnUpdate", nil) | 263 self:SetScript ("OnUpdate", nil) |
| 258 DF:Fade (self, 0) | 264 DF:Fade (self, 0) |
| 259 --rever | 265 --rever |
| 260 if (CoolTip.sub_menus) then | 266 if (CoolTip.sub_menus) then |
| 261 DF:Fade (frame2, 0) | 267 DF:Fade (frame2, 0) |
| 268 return CoolTip:Close() | 274 return CoolTip:Close() |
| 269 end | 275 end |
| 270 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then | 276 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then |
| 271 CoolTip.active = true | 277 CoolTip.active = true |
| 272 CoolTip.mouseOver = true | 278 CoolTip.mouseOver = true |
| 279 CoolTip.had_interaction = true | |
| 273 self:SetScript ("OnUpdate", nil) | 280 self:SetScript ("OnUpdate", nil) |
| 274 DF:Fade (self, 0) | 281 DF:Fade (self, 0) |
| 275 DF:Fade (frame1, 0) | 282 DF:Fade (frame1, 0) |
| 276 end | 283 end |
| 277 end) | 284 end) |
| 396 --> serach key: ~onenter | 403 --> serach key: ~onenter |
| 397 botao:SetScript ("OnEnter", function() | 404 botao:SetScript ("OnEnter", function() |
| 398 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not botao.isDiv) then | 405 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not botao.isDiv) then |
| 399 CoolTip.active = true | 406 CoolTip.active = true |
| 400 CoolTip.mouseOver = true | 407 CoolTip.mouseOver = true |
| 408 CoolTip.had_interaction = true | |
| 401 | 409 |
| 402 frame1:SetScript ("OnUpdate", nil) | 410 frame1:SetScript ("OnUpdate", nil) |
| 403 frame2:SetScript ("OnUpdate", nil) | 411 frame2:SetScript ("OnUpdate", nil) |
| 404 | 412 |
| 405 botao.background:Show() | 413 botao.background:Show() |
| 408 botao.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendModeHover) | 416 botao.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendModeHover) |
| 409 else | 417 else |
| 410 botao.leftIcon:SetBlendMode ("BLEND") | 418 botao.leftIcon:SetBlendMode ("BLEND") |
| 411 end | 419 end |
| 412 | 420 |
| 413 if (CoolTip.IndexesSub [botao.index] and CoolTip.IndexesSub [botao.index] > 0) then | 421 if (CoolTip.PopupFrameTable [botao.index]) then |
| 422 local on_enter, on_leave, param1, param2 = unpack (CoolTip.PopupFrameTable [botao.index]) | |
| 423 if (on_enter) then | |
| 424 xpcall (on_enter, geterrorhandler(), frame1, param1, param2) | |
| 425 end | |
| 426 | |
| 427 elseif (CoolTip.IndexesSub [botao.index] and CoolTip.IndexesSub [botao.index] > 0) then | |
| 414 if (CoolTip.OptionsTable.SubMenuIsTooltip) then | 428 if (CoolTip.OptionsTable.SubMenuIsTooltip) then |
| 415 CoolTip:ShowSub (botao.index) | 429 CoolTip:ShowSub (botao.index) |
| 416 botao.index = i | 430 botao.index = i |
| 417 else | 431 else |
| 418 if (CoolTip.last_button) then | 432 if (CoolTip.last_button) then |
| 430 DF:Fade (frame2, 1) | 444 DF:Fade (frame2, 1) |
| 431 CoolTip.last_button = nil | 445 CoolTip.last_button = nil |
| 432 end | 446 end |
| 433 else | 447 else |
| 434 CoolTip.mouseOver = true | 448 CoolTip.mouseOver = true |
| 449 CoolTip.had_interaction = true | |
| 435 end | 450 end |
| 436 end) | 451 end) |
| 437 | 452 |
| 438 botao:SetScript ("OnLeave", function() | 453 botao:SetScript ("OnLeave", function() |
| 439 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not botao.isDiv) then | 454 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not botao.isDiv) then |
| 449 else | 464 else |
| 450 botao.leftIcon:SetBlendMode ("BLEND") | 465 botao.leftIcon:SetBlendMode ("BLEND") |
| 451 botao.rightIcon:SetBlendMode ("BLEND") | 466 botao.rightIcon:SetBlendMode ("BLEND") |
| 452 end | 467 end |
| 453 | 468 |
| 469 if (CoolTip.PopupFrameTable [botao.index]) then | |
| 470 local on_enter, on_leave, param1, param2 = unpack (CoolTip.PopupFrameTable [botao.index]) | |
| 471 if (on_leave) then | |
| 472 xpcall (on_leave, geterrorhandler(), frame1, param1, param2) | |
| 473 end | |
| 474 end | |
| 475 | |
| 454 elapsedTime = 0 | 476 elapsedTime = 0 |
| 455 frame1:SetScript ("OnUpdate", OnLeaveUpdateButton) | 477 frame1:SetScript ("OnUpdate", OnLeaveUpdateButton) |
| 456 --CoolTip:HideSub (i) | 478 --CoolTip:HideSub (i) |
| 457 else | 479 else |
| 458 CoolTip.active = false | 480 CoolTip.active = false |
| 487 return CoolTip:Close() | 509 return CoolTip:Close() |
| 488 end | 510 end |
| 489 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not botao.isDiv) then | 511 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not botao.isDiv) then |
| 490 CoolTip.active = true | 512 CoolTip.active = true |
| 491 CoolTip.mouseOver = true | 513 CoolTip.mouseOver = true |
| 514 CoolTip.had_interaction = true | |
| 492 | 515 |
| 493 botao.background:Show() | 516 botao.background:Show() |
| 494 | 517 |
| 495 if (CoolTip.OptionsTable.IconBlendModeHover) then | 518 if (CoolTip.OptionsTable.IconBlendModeHover) then |
| 496 botao.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendModeHover) | 519 botao.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendModeHover) |
| 503 | 526 |
| 504 DF:Fade (frame1, 0) | 527 DF:Fade (frame1, 0) |
| 505 DF:Fade (frame2, 0) | 528 DF:Fade (frame2, 0) |
| 506 else | 529 else |
| 507 CoolTip.mouseOver = true | 530 CoolTip.mouseOver = true |
| 531 CoolTip.had_interaction = true | |
| 508 end | 532 end |
| 509 end) | 533 end) |
| 510 | 534 |
| 511 botao:SetScript ("OnLeave", function() | 535 botao:SetScript ("OnLeave", function() |
| 512 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then | 536 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then |
| 1954 frame2:SetBackdrop (default_backdrop) | 1978 frame2:SetBackdrop (default_backdrop) |
| 1955 frame2:SetBackdropColor (unpack (default_backdrop_color)) | 1979 frame2:SetBackdropColor (unpack (default_backdrop_color)) |
| 1956 frame2:SetBackdropBorderColor (unpack (default_backdropborder_color)) | 1980 frame2:SetBackdropBorderColor (unpack (default_backdropborder_color)) |
| 1957 | 1981 |
| 1958 --[ | 1982 --[ |
| 1983 _table_wipe (CoolTip.PopupFrameTable) | |
| 1984 | |
| 1959 _table_wipe (CoolTip.LeftTextTable) | 1985 _table_wipe (CoolTip.LeftTextTable) |
| 1960 _table_wipe (CoolTip.LeftTextTableSub) | 1986 _table_wipe (CoolTip.LeftTextTableSub) |
| 1961 _table_wipe (CoolTip.RightTextTable) | 1987 _table_wipe (CoolTip.RightTextTable) |
| 1962 _table_wipe (CoolTip.RightTextTableSub) | 1988 _table_wipe (CoolTip.RightTextTableSub) |
| 1963 | 1989 |
| 2528 | 2554 |
| 2529 return true | 2555 return true |
| 2530 end | 2556 end |
| 2531 | 2557 |
| 2532 ---------------------------------------------------------------------- | 2558 ---------------------------------------------------------------------- |
| 2559 --> popup frame | |
| 2560 function CoolTip:AddPopUpFrame (func_on_show, func_on_hide, param1, param2) | |
| 2561 | |
| 2562 -- act like a sub menu | |
| 2563 if (CoolTip.Indexes > 0) then | |
| 2564 CoolTip.PopupFrameTable [CoolTip.Indexes] = {func_on_show or false, func_on_hide or false, param1, param2} | |
| 2565 end | |
| 2566 | |
| 2567 end | |
| 2568 | |
| 2569 ---------------------------------------------------------------------- | |
| 2533 --> adds a line. | 2570 --> adds a line. |
| 2534 --> only works with cooltip type 1 and 2 (tooltip and tooltip with bars) | 2571 --> only works with cooltip type 1 and 2 (tooltip and tooltip with bars) |
| 2535 --> 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]]] | 2572 --> parameters: left text, right text [, L color R, L color G, L color B, L color A [, R color R, R color G, R color B, R color A [, wrap]]] |
| 2536 | 2573 |
| 2537 --> alias | 2574 --> alias |
| 2778 ---------------------------------------------------------------------- | 2815 ---------------------------------------------------------------------- |
| 2779 --> show cooltip | 2816 --> show cooltip |
| 2780 | 2817 |
| 2781 --> serach key: ~start | 2818 --> serach key: ~start |
| 2782 function CoolTip:Show (frame, menuType, color) | 2819 function CoolTip:Show (frame, menuType, color) |
| 2820 CoolTip.had_interaction = false | |
| 2783 return CoolTip:ShowCooltip (frame, menuType, color) | 2821 return CoolTip:ShowCooltip (frame, menuType, color) |
| 2784 end | 2822 end |
| 2785 | 2823 |
| 2786 function CoolTip:ShowCooltip (frame, menuType, color) | 2824 function CoolTip:ShowCooltip (frame, menuType, color) |
| 2787 | 2825 |
| 2826 CoolTip.had_interaction = false | |
| 2827 | |
| 2788 if (frame) then | 2828 if (frame) then |
| 2789 --> details framework | 2829 --> details framework |
| 2790 if (frame.dframework) then | 2830 if (frame.dframework) then |
| 2791 frame = frame.widget | 2831 frame = frame.widget |
| 2792 end | 2832 end |
