Mercurial > wow > hansgar_and_franzok_assist
comparison Libs/DF/panel.lua @ 20:dc1c77254f80
- added close button to users panel.
- framework update.
| author | Tercio |
|---|---|
| date | Tue, 11 Aug 2015 12:46:46 -0300 |
| parents | 215f0dd37a6c |
| children | dbd417f413a8 |
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 _ | 7 local _ |
| 4 | |
| 5 if (not DF) then -- or not DetailsFrameWorkLoadValid | |
| 6 return | |
| 7 end | |
| 8 | |
| 9 --> lua locals | 8 --> lua locals |
| 10 local _rawset = rawset --> lua local | 9 local _rawset = rawset --> lua local |
| 11 local _rawget = rawget --> lua local | 10 local _rawget = rawget --> lua local |
| 12 local _setmetatable = setmetatable --> lua local | 11 local _setmetatable = setmetatable --> lua local |
| 13 local _unpack = unpack --> lua local | 12 local _unpack = unpack --> lua local |
| 501 APIFrameFunctions = {} | 500 APIFrameFunctions = {} |
| 502 local idx = getmetatable (PanelObject.frame).__index | 501 local idx = getmetatable (PanelObject.frame).__index |
| 503 for funcName, funcAddress in pairs (idx) do | 502 for funcName, funcAddress in pairs (idx) do |
| 504 if (not PanelMetaFunctions [funcName]) then | 503 if (not PanelMetaFunctions [funcName]) then |
| 505 PanelMetaFunctions [funcName] = function (object, ...) | 504 PanelMetaFunctions [funcName] = function (object, ...) |
| 506 local x = loadstring ( "return _G."..object.frame:GetName()..":"..funcName.."(...)") | 505 local x = loadstring ( "return _G['"..object.frame:GetName().."']:"..funcName.."(...)") |
| 507 return x (...) | 506 return x (...) |
| 508 end | 507 end |
| 509 end | 508 end |
| 510 end | 509 end |
| 511 end | 510 end |
| 549 end | 548 end |
| 550 local button_on_leave = function (self) | 549 local button_on_leave = function (self) |
| 551 self.MyObject._icon:SetBlendMode ("BLEND") | 550 self.MyObject._icon:SetBlendMode ("BLEND") |
| 552 end | 551 end |
| 553 | 552 |
| 554 function DF:CreateFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options) | 553 local add_row = function (self, t, need_update) |
| 555 return DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options) | 554 local index = #self.rows+1 |
| 556 end | 555 |
| 557 | 556 local thisrow = DF:NewPanel (self, self, "$parentHeader_" .. self._name .. index, nil, 1, 20) |
| 558 function DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options) | 557 thisrow.backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Gold-Background]]} |
| 559 | 558 thisrow.color = "silver" |
| 560 local panel = DF:NewPanel (parent, parent, name, member, w, h) | 559 thisrow.type = t.type |
| 561 panel.backdrop = nil | 560 thisrow.func = t.func |
| 562 | 561 thisrow.name = t.name |
| 563 options = options or {rowheight = 20} | 562 thisrow.notext = t.notext |
| 564 panel.rows = {} | 563 thisrow.icon = t.icon |
| 565 | 564 thisrow.iconalign = t.iconalign |
| 566 for index, t in ipairs (rows) do | 565 |
| 567 local thisrow = DF:NewPanel (panel, panel, "$parentHeader_" .. name .. index, nil, 1, 20) | 566 thisrow.hidden = t.hidden or false |
| 568 thisrow.backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Gold-Background]]} | 567 |
| 569 thisrow.color = "silver" | 568 local text = DF:NewLabel (thisrow, nil, self._name .. "$parentLabel" .. index, "text") |
| 570 thisrow.type = t.type | 569 text:SetPoint ("left", thisrow, "left", 2, 0) |
| 571 thisrow.func = t.func | 570 text:SetText (t.name) |
| 572 thisrow.name = t.name | 571 |
| 573 thisrow.notext = t.notext | 572 tinsert (self._raw_rows, t) |
| 574 thisrow.icon = t.icon | 573 tinsert (self.rows, thisrow) |
| 575 thisrow.iconalign = t.iconalign | 574 |
| 576 | 575 if (need_update) then |
| 577 local text = DF:NewLabel (thisrow, nil, name .. "$parentLabel", "text") | 576 self:AlignRows() |
| 578 text:SetPoint ("left", thisrow, "left", 2, 0) | 577 end |
| 579 text:SetText (t.name) | 578 end |
| 580 | 579 |
| 581 tinsert (panel.rows, thisrow) | 580 local align_rows = function (self) |
| 581 | |
| 582 local rows_shown = 0 | |
| 583 for index, row in ipairs (self.rows) do | |
| 584 if (not row.hidden) then | |
| 585 rows_shown = rows_shown + 1 | |
| 586 end | |
| 582 end | 587 end |
| 583 | 588 |
| 584 local cur_width = 0 | 589 local cur_width = 0 |
| 585 local row_width = w / #rows | 590 local row_width = self._width / rows_shown |
| 586 | 591 local sindex = 1 |
| 587 local anchors = {} | 592 |
| 588 | 593 wipe (self._anchors) |
| 589 for index, row in ipairs (panel.rows) do | 594 |
| 590 if (autowidth) then | 595 for index, row in ipairs (self.rows) do |
| 591 row:SetWidth (row_width) | 596 if (not row.hidden) then |
| 592 row:SetPoint ("topleft", panel, "topleft", cur_width, 0) | 597 if (self._autowidth) then |
| 593 tinsert (anchors, cur_width) | 598 if (self._raw_rows [index].width) then |
| 594 cur_width = cur_width + row_width + 1 | 599 row.width = self._raw_rows [index].width |
| 595 else | 600 else |
| 596 row:SetPoint ("topleft", panel, "topleft", cur_width, 0) | 601 row.width = row_width |
| 597 row.width = rows [index].width | 602 end |
| 598 tinsert (anchors, cur_width) | 603 row:SetPoint ("topleft", self, "topleft", cur_width, 0) |
| 599 cur_width = cur_width + rows [index].width + 1 | 604 tinsert (self._anchors, cur_width) |
| 600 end | 605 cur_width = cur_width + row_width + 1 |
| 601 end | 606 else |
| 602 | 607 row:SetPoint ("topleft", self, "topleft", cur_width, 0) |
| 603 if (autowidth) then | 608 row.width = self._raw_rows [index].width |
| 604 panel.rows [#panel.rows]:SetWidth (row_width - #rows + 1) | 609 tinsert (self._anchors, cur_width) |
| 605 else | 610 cur_width = cur_width + self._raw_rows [index].width + 1 |
| 606 panel.rows [#panel.rows]:SetWidth (rows [#rows].width - #rows + 1) | 611 end |
| 607 end | 612 row:Show() |
| 608 | 613 |
| 609 local refresh_fillbox = function (self) | 614 local type = row.type |
| 610 local offset = FauxScrollFrame_GetOffset (self) | 615 |
| 611 local filled_lines = total_lines() | 616 if (type == "text") then |
| 612 | 617 for i = 1, #self.scrollframe.lines do |
| 613 for index = 1, #self.lines do | 618 local line = self.scrollframe.lines [i] |
| 614 | 619 local text = tremove (line.text_available) |
| 615 local row = self.lines [index] | 620 if (not text) then |
| 616 if (index <= filled_lines) then | 621 self:CreateRowText (line) |
| 617 | 622 text = tremove (line.text_available) |
| 618 local real_index = index + offset | 623 end |
| 619 | 624 tinsert (line.text_inuse, text) |
| 620 local results = fill_row (real_index) | 625 text:SetPoint ("left", line, "left", self._anchors [#self._anchors], 0) |
| 621 | 626 text:SetWidth (row.width) |
| 622 if (results [1]) then | 627 end |
| 623 | 628 elseif (type == "entry") then |
| 624 row:Show() | 629 for i = 1, #self.scrollframe.lines do |
| 630 local line = self.scrollframe.lines [i] | |
| 631 local entry = tremove (line.entry_available) | |
| 632 if (not entry) then | |
| 633 self:CreateRowEntry (line) | |
| 634 entry = tremove (line.entry_available) | |
| 635 end | |
| 636 tinsert (line.entry_inuse, entry) | |
| 637 entry:SetPoint ("left", line, "left", self._anchors [#self._anchors], 0) | |
| 638 if (sindex == rows_shown) then | |
| 639 entry:SetWidth (row.width - 25) | |
| 640 else | |
| 641 entry:SetWidth (row.width) | |
| 642 end | |
| 643 entry.func = row.func | |
| 644 end | |
| 645 elseif (type == "button") then | |
| 646 for i = 1, #self.scrollframe.lines do | |
| 647 local line = self.scrollframe.lines [i] | |
| 648 local button = tremove (line.button_available) | |
| 649 if (not button) then | |
| 650 self:CreateRowButton (line) | |
| 651 button = tremove (line.button_available) | |
| 652 end | |
| 653 tinsert (line.button_inuse, button) | |
| 654 button:SetPoint ("left", line, "left", self._anchors [#self._anchors], 0) | |
| 655 if (sindex == rows_shown) then | |
| 656 button:SetWidth (row.width - 25) | |
| 657 else | |
| 658 button:SetWidth (row.width) | |
| 659 end | |
| 625 | 660 |
| 626 for i = 1, #row.row_widgets do | 661 if (row.icon) then |
| 627 | 662 button._icon.texture = row.icon |
| 628 row.row_widgets [i].index = real_index | 663 button._icon:ClearAllPoints() |
| 629 | 664 if (row.iconalign) then |
| 630 if (panel.rows [i].type == "icon") then | 665 if (row.iconalign == "center") then |
| 631 | 666 button._icon:SetPoint ("center", button, "center") |
| 632 local result = results [i]:gsub (".-%\\", "") | 667 elseif (row.iconalign == "right") then |
| 633 row.row_widgets [i]._icon.texture = results [i] | 668 button._icon:SetPoint ("right", button, "right") |
| 634 | |
| 635 elseif (panel.rows [i].type == "button") then | |
| 636 | |
| 637 if (type (results [i]) == "table") then | |
| 638 | |
| 639 if (results [i].text) then | |
| 640 row.row_widgets [i]:SetText (results [i].text) | |
| 641 end | |
| 642 | |
| 643 if (results [i].icon) then | |
| 644 row.row_widgets [i]._icon:SetTexture (results [i].icon) | |
| 645 end | |
| 646 | |
| 647 if (results [i].func) then | |
| 648 row.row_widgets [i]:SetClickFunction (results [i].func, real_index, results [i].value) | |
| 649 end | |
| 650 | |
| 651 else | |
| 652 row.row_widgets [i]:SetText (results [i]) | |
| 653 end | 669 end |
| 654 | |
| 655 else | 670 else |
| 656 --> text | 671 button._icon:SetPoint ("left", button, "left") |
| 657 row.row_widgets [i]:SetText (results [i]) | |
| 658 if (panel.rows [i].type == "entry") then | |
| 659 row.row_widgets [i]:SetCursorPosition (0) | |
| 660 end | |
| 661 | |
| 662 end | 672 end |
| 663 end | 673 end |
| 664 | 674 |
| 675 if (row.name and not row.notext) then | |
| 676 button._text:SetPoint ("left", button._icon, "right", 2, 0) | |
| 677 button._text.text = row.name | |
| 678 end | |
| 679 | |
| 680 end | |
| 681 elseif (type == "icon") then | |
| 682 for i = 1, #self.scrollframe.lines do | |
| 683 local line = self.scrollframe.lines [i] | |
| 684 local icon = tremove (line.icon_available) | |
| 685 if (not icon) then | |
| 686 self:CreateRowIcon (line) | |
| 687 icon = tremove (line.icon_available) | |
| 688 end | |
| 689 tinsert (line.icon_inuse, icon) | |
| 690 icon:SetPoint ("left", line, "left", self._anchors [#self._anchors] + ( ((row.width or 22) - 22) / 2), 0) | |
| 691 icon.func = row.func | |
| 692 end | |
| 693 end | |
| 694 | |
| 695 sindex = sindex + 1 | |
| 696 else | |
| 697 row:Hide() | |
| 698 end | |
| 699 end | |
| 700 | |
| 701 if (#self.rows > 0) then | |
| 702 if (self._autowidth) then | |
| 703 self.rows [#self.rows]:SetWidth (row_width - rows_shown + 1) | |
| 704 else | |
| 705 self.rows [#self.rows]:SetWidth (self._raw_rows [rows_shown].width - rows_shown + 1) | |
| 706 end | |
| 707 end | |
| 708 | |
| 709 self.showing_amt = rows_shown | |
| 710 end | |
| 711 | |
| 712 local update_rows = function (self, updated_rows) | |
| 713 for i = 1, #updated_rows do | |
| 714 local t = updated_rows [i] | |
| 715 local raw = self._raw_rows [i] | |
| 716 | |
| 717 if (not raw) then | |
| 718 self:AddRow (t) | |
| 719 else | |
| 720 raw.name = t.name | |
| 721 raw.hidden = t.hidden or false | |
| 722 | |
| 723 local widget = self.rows [i] | |
| 724 widget.name = t.name | |
| 725 widget.hidden = t.hidden or false | |
| 726 | |
| 727 widget.text:SetText (t.name) | |
| 728 end | |
| 729 end | |
| 730 | |
| 731 for i = #updated_rows+1, #self._raw_rows do | |
| 732 local raw = self._raw_rows [i] | |
| 733 local widget = self.rows [i] | |
| 734 raw.hidden = true | |
| 735 widget.hidden = true | |
| 736 end | |
| 737 | |
| 738 for index, row in ipairs (self.scrollframe.lines) do | |
| 739 for i = #row.text_inuse, 1, -1 do | |
| 740 tinsert (row.text_available, tremove (row.text_inuse, i)) | |
| 741 end | |
| 742 for i = 1, #row.text_available do | |
| 743 row.text_available[i]:Hide() | |
| 744 end | |
| 745 | |
| 746 for i = #row.entry_inuse, 1, -1 do | |
| 747 tinsert (row.entry_available, tremove (row.entry_inuse, i)) | |
| 748 end | |
| 749 for i = 1, #row.entry_available do | |
| 750 row.entry_available[i]:Hide() | |
| 751 end | |
| 752 | |
| 753 for i = #row.button_inuse, 1, -1 do | |
| 754 tinsert (row.button_available, tremove (row.button_inuse, i)) | |
| 755 end | |
| 756 for i = 1, #row.button_available do | |
| 757 row.button_available[i]:Hide() | |
| 758 end | |
| 759 | |
| 760 for i = #row.icon_inuse, 1, -1 do | |
| 761 tinsert (row.icon_available, tremove (row.icon_inuse, i)) | |
| 762 end | |
| 763 for i = 1, #row.icon_available do | |
| 764 row.icon_available[i]:Hide() | |
| 765 end | |
| 766 end | |
| 767 | |
| 768 self:AlignRows() | |
| 769 | |
| 770 end | |
| 771 | |
| 772 local create_panel_text = function (self, row) | |
| 773 row.text_total = row.text_total + 1 | |
| 774 local text = DF:NewLabel (row, nil, self._name .. "$parentLabel" .. row.text_total, "text" .. row.text_total) | |
| 775 tinsert (row.text_available, text) | |
| 776 end | |
| 777 | |
| 778 local create_panel_entry = function (self, row) | |
| 779 row.entry_total = row.entry_total + 1 | |
| 780 local editbox = DF:NewTextEntry (row, nil, "$parentEntry" .. row.entry_total, "entry", 120, 20) | |
| 781 editbox.align = "left" | |
| 782 | |
| 783 editbox:SetHook ("OnEnterPressed", function() | |
| 784 editbox.widget.focuslost = true | |
| 785 editbox:ClearFocus() | |
| 786 editbox.func (editbox.index, editbox.text) | |
| 787 return true | |
| 788 end) | |
| 789 | |
| 790 editbox:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = 1}) | |
| 791 editbox:SetBackdropColor (1, 1, 1, 0.1) | |
| 792 editbox:SetBackdropBorderColor (1, 1, 1, 0.1) | |
| 793 editbox.editbox.current_bordercolor = {1, 1, 1, 0.1} | |
| 794 | |
| 795 tinsert (row.entry_available, editbox) | |
| 796 end | |
| 797 | |
| 798 local create_panel_button = function (self, row) | |
| 799 row.button_total = row.button_total + 1 | |
| 800 local button = DF:NewButton (row, nil, "$parentButton" .. row.button_total, "button" .. row.button_total, 120, 20) | |
| 801 button:InstallCustomTexture() | |
| 802 | |
| 803 --> create icon and the text | |
| 804 local icon = DF:NewImage (button, nil, 20, 20) | |
| 805 local text = DF:NewLabel (button) | |
| 806 | |
| 807 button._icon = icon | |
| 808 button._text = text | |
| 809 | |
| 810 button:SetHook ("OnEnter", button_on_enter) | |
| 811 button:SetHook ("OnLeave", button_on_leave) | |
| 812 | |
| 813 tinsert (row.button_available, button) | |
| 814 end | |
| 815 | |
| 816 local icon_onclick = function (texture, iconbutton) | |
| 817 iconbutton._icon.texture = texture | |
| 818 iconbutton.func (iconbutton.index, texture) | |
| 819 end | |
| 820 | |
| 821 local create_panel_icon = function (self, row) | |
| 822 row.icon_total = row.icon_total + 1 | |
| 823 local iconbutton = DF:NewButton (row, nil, "$parentIconButton" .. row.icon_total, "iconbutton", 22, 20) | |
| 824 iconbutton:InstallCustomTexture() | |
| 825 | |
| 826 iconbutton:SetHook ("OnEnter", button_on_enter) | |
| 827 iconbutton:SetHook ("OnLeave", button_on_leave) | |
| 828 | |
| 829 iconbutton:SetHook ("OnMouseUp", function() | |
| 830 DF:IconPick (icon_onclick, true, iconbutton) | |
| 831 return true | |
| 832 end) | |
| 833 | |
| 834 local icon = DF:NewImage (iconbutton, nil, 20, 20, "artwork", nil, "_icon", "$parentIcon" .. row.icon_total) | |
| 835 iconbutton._icon = icon | |
| 836 | |
| 837 icon:SetPoint ("center", iconbutton, "center", 0, 0) | |
| 838 | |
| 839 tinsert (row.icon_available, iconbutton) | |
| 840 end | |
| 841 | |
| 842 local set_fill_function = function (self, func) | |
| 843 self._fillfunc = func | |
| 844 end | |
| 845 local set_total_function = function (self, func) | |
| 846 self._totalfunc = func | |
| 847 end | |
| 848 local drop_header_function = function (self) | |
| 849 wipe (self.rows) | |
| 850 end | |
| 851 -- ~fillpanel | |
| 852 function DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options) | |
| 853 | |
| 854 local panel = DF:NewPanel (parent, parent, name, member, w, h) | |
| 855 panel.backdrop = nil | |
| 856 | |
| 857 options = options or {rowheight = 20} | |
| 858 panel.rows = {} | |
| 859 | |
| 860 panel.AddRow = add_row | |
| 861 panel.AlignRows = align_rows | |
| 862 panel.UpdateRows = update_rows | |
| 863 panel.CreateRowText = create_panel_text | |
| 864 panel.CreateRowEntry = create_panel_entry | |
| 865 panel.CreateRowButton = create_panel_button | |
| 866 panel.CreateRowIcon = create_panel_icon | |
| 867 panel.SetFillFunction = set_fill_function | |
| 868 panel.SetTotalFunction = set_total_function | |
| 869 panel.DropHeader = drop_header_function | |
| 870 | |
| 871 panel._name = name | |
| 872 panel._width = w | |
| 873 panel._height = h | |
| 874 panel._raw_rows = {} | |
| 875 panel._anchors = {} | |
| 876 panel._fillfunc = fill_row | |
| 877 panel._totalfunc = total_lines | |
| 878 panel._autowidth = autowidth | |
| 879 | |
| 880 for index, t in ipairs (rows) do | |
| 881 panel.AddRow (panel, t) | |
| 882 end | |
| 883 | |
| 884 local refresh_fillbox = function (self) | |
| 885 | |
| 886 local offset = FauxScrollFrame_GetOffset (self) | |
| 887 local filled_lines = panel._totalfunc (panel) | |
| 888 | |
| 889 for index = 1, #self.lines do | |
| 890 | |
| 891 local row = self.lines [index] | |
| 892 if (index <= filled_lines) then | |
| 893 | |
| 894 local real_index = index + offset | |
| 895 local results = panel._fillfunc (real_index, panel) | |
| 896 | |
| 897 if (results [1]) then | |
| 898 row:Show() | |
| 899 | |
| 900 local text, entry, button, icon = 1, 1, 1, 1 | |
| 901 | |
| 902 for index, t in ipairs (panel.rows) do | |
| 903 if (not t.hidden) then | |
| 904 if (t.type == "text") then | |
| 905 local fontstring = row.text_inuse [text] | |
| 906 text = text + 1 | |
| 907 fontstring:SetText (results [index]) | |
| 908 fontstring.index = real_index | |
| 909 fontstring:Show() | |
| 910 | |
| 911 elseif (t.type == "entry") then | |
| 912 local entrywidget = row.entry_inuse [entry] | |
| 913 entry = entry + 1 | |
| 914 entrywidget:SetText (results [index]) | |
| 915 entrywidget.index = real_index | |
| 916 entrywidget:Show() | |
| 917 | |
| 918 elseif (t.type == "button") then | |
| 919 local buttonwidget = row.button_inuse [button] | |
| 920 button = button + 1 | |
| 921 buttonwidget.index = real_index | |
| 922 | |
| 923 local func = function() | |
| 924 t.func (real_index, index) | |
| 925 panel:Refresh() | |
| 926 end | |
| 927 buttonwidget:SetClickFunction (func) | |
| 928 | |
| 929 if (type (results [index]) == "table") then | |
| 930 if (results [index].text) then | |
| 931 buttonwidget:SetText (results [index].text) | |
| 932 end | |
| 933 | |
| 934 if (results [index].icon) then | |
| 935 buttonwidget._icon:SetTexture (results [index].icon) | |
| 936 end | |
| 937 | |
| 938 if (results [index].func) then | |
| 939 buttonwidget:SetClickFunction (results [index].func, real_index, results [index].value) | |
| 940 end | |
| 941 else | |
| 942 buttonwidget:SetText (results [index]) | |
| 943 end | |
| 944 | |
| 945 buttonwidget:Show() | |
| 946 | |
| 947 elseif (t.type == "icon") then | |
| 948 local iconwidget = row.icon_inuse [icon] | |
| 949 icon = icon + 1 | |
| 950 | |
| 951 iconwidget.line = index | |
| 952 iconwidget.index = real_index | |
| 953 | |
| 954 local result = results [index]:gsub (".-%\\", "") | |
| 955 iconwidget._icon.texture = results [index] | |
| 956 | |
| 957 iconwidget:Show() | |
| 958 end | |
| 959 end | |
| 960 end | |
| 961 | |
| 665 else | 962 else |
| 666 row:Hide() | 963 row:Hide() |
| 667 for i = 1, #row.row_widgets do | |
| 668 row.row_widgets [i]:SetText ("") | |
| 669 if (panel.rows [i].type == "icon") then | |
| 670 row.row_widgets [i]._icon.texture = "" | |
| 671 end | |
| 672 end | |
| 673 end | 964 end |
| 674 else | 965 else |
| 675 row:Hide() | 966 row:Hide() |
| 676 for i = 1, #row.row_widgets do | |
| 677 row.row_widgets [i]:SetText ("") | |
| 678 if (panel.rows [i].type == "icon") then | |
| 679 row.row_widgets [i]._icon.texture = "" | |
| 680 end | |
| 681 end | |
| 682 end | 967 end |
| 683 end | 968 end |
| 684 end | 969 end |
| 685 | 970 |
| 686 function panel:Refresh() | 971 function panel:Refresh() |
| 687 local filled_lines = total_lines() | 972 local filled_lines = panel._totalfunc (panel) |
| 688 local scroll_total_lines = #panel.scrollframe.lines | 973 local scroll_total_lines = #panel.scrollframe.lines |
| 689 local line_height = options.rowheight | 974 local line_height = options.rowheight |
| 690 | 975 refresh_fillbox (panel.scrollframe) |
| 691 FauxScrollFrame_Update (panel.scrollframe, filled_lines, scroll_total_lines, line_height) | 976 FauxScrollFrame_Update (panel.scrollframe, filled_lines, scroll_total_lines, line_height) |
| 692 refresh_fillbox (panel.scrollframe) | |
| 693 end | 977 end |
| 694 | 978 |
| 695 local scrollframe = CreateFrame ("scrollframe", name .. "Scroll", panel.widget, "FauxScrollFrameTemplate") | 979 local scrollframe = CreateFrame ("scrollframe", name .. "Scroll", panel.widget, "FauxScrollFrameTemplate") |
| 696 scrollframe:SetScript ("OnVerticalScroll", function (self, offset) FauxScrollFrame_OnVerticalScroll (self, offset, 20, panel.Refresh) end) | 980 scrollframe:SetScript ("OnVerticalScroll", function (self, offset) FauxScrollFrame_OnVerticalScroll (self, offset, 20, panel.Refresh) end) |
| 697 scrollframe:SetPoint ("topleft", panel.widget, "topleft", 0, -21) | 981 scrollframe:SetPoint ("topleft", panel.widget, "topleft", 0, -21) |
| 704 | 988 |
| 705 --create lines | 989 --create lines |
| 706 local size = options.rowheight | 990 local size = options.rowheight |
| 707 local amount = math.floor (((h-21) / size)) | 991 local amount = math.floor (((h-21) / size)) |
| 708 | 992 |
| 709 | |
| 710 for i = 1, amount do | 993 for i = 1, amount do |
| 711 | 994 local row = CreateFrame ("frame", panel:GetName() .. "Row_" .. i, panel.widget) |
| 712 local row = DF:NewPanel (panel, nil, "$parentRow_" .. i, nil, 1, size) | 995 row:SetSize (1, size) |
| 713 row.backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]]} | |
| 714 row.color = {1, 1, 1, .2} | 996 row.color = {1, 1, 1, .2} |
| 997 | |
| 998 row:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]]}) | |
| 999 | |
| 1000 if (i%2 == 0) then | |
| 1001 row:SetBackdropColor (.5, .5, .5, 0.2) | |
| 1002 else | |
| 1003 row:SetBackdropColor (1, 1, 1, 0.00) | |
| 1004 end | |
| 1005 | |
| 715 row:SetPoint ("topleft", scrollframe, "topleft", 0, (i-1) * size * -1) | 1006 row:SetPoint ("topleft", scrollframe, "topleft", 0, (i-1) * size * -1) |
| 716 row:SetPoint ("topright", scrollframe, "topright", 0, (i-1) * size * -1) | 1007 row:SetPoint ("topright", scrollframe, "topright", 0, (i-1) * size * -1) |
| 717 tinsert (scrollframe.lines, row) | 1008 tinsert (scrollframe.lines, row) |
| 718 | 1009 |
| 719 row.row_widgets = {} | 1010 row.text_available = {} |
| 720 | 1011 row.text_inuse = {} |
| 721 for o = 1, #rows do | 1012 row.text_total = 0 |
| 722 | 1013 |
| 723 local _type = panel.rows [o].type | 1014 row.entry_available = {} |
| 724 | 1015 row.entry_inuse = {} |
| 725 if (_type == "text") then | 1016 row.entry_total = 0 |
| 726 | 1017 |
| 727 --> create text | 1018 row.button_available = {} |
| 728 local text = DF:NewLabel (row, nil, name .. "$parentLabel" .. o, "text" .. o) | 1019 row.button_inuse = {} |
| 729 text:SetPoint ("left", row, "left", anchors [o], 0) | 1020 row.button_total = 0 |
| 730 | 1021 |
| 731 --> insert in the table | 1022 row.icon_available = {} |
| 732 tinsert (row.row_widgets, text) | 1023 row.icon_inuse = {} |
| 733 | 1024 row.icon_total = 0 |
| 734 elseif (_type == "entry") then | 1025 end |
| 735 | 1026 |
| 736 --> create editbox | 1027 panel.AlignRows (panel) |
| 737 local editbox = DF:NewTextEntry (row, nil, "$parentEntry" .. o, "entry", panel.rows [o].width, 20, panel.rows [o].func, i, o) | |
| 738 editbox.align = "left" | |
| 739 editbox:SetHook ("OnEnterPressed", function() | |
| 740 editbox.widget.focuslost = true | |
| 741 editbox:ClearFocus() | |
| 742 editbox.func (editbox.index, editbox.text) | |
| 743 return true | |
| 744 end) | |
| 745 editbox:SetPoint ("left", row, "left", anchors [o], 0) | |
| 746 editbox:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = 1}) | |
| 747 editbox:SetBackdropColor (1, 1, 1, 0.1) | |
| 748 editbox:SetBackdropBorderColor (1, 1, 1, 0.1) | |
| 749 editbox.editbox.current_bordercolor = {1, 1, 1, 0.1} | |
| 750 | |
| 751 --> insert in the table | |
| 752 tinsert (row.row_widgets, editbox) | |
| 753 | |
| 754 elseif (_type == "button") then | |
| 755 | |
| 756 --> create button | |
| 757 local button = DF:NewButton (row, nil, "$parentButton" .. o, "button", panel.rows [o].width, 20) | |
| 758 | |
| 759 local func = function() | |
| 760 panel.rows [o].func (button.index, o) | |
| 761 panel:Refresh() | |
| 762 end | |
| 763 button:SetClickFunction (func) | |
| 764 | |
| 765 button:SetPoint ("left", row, "left", anchors [o], 0) | |
| 766 | |
| 767 --> create icon and the text | |
| 768 local icon = DF:NewImage (button, nil, 20, 20) | |
| 769 local text = DF:NewLabel (button) | |
| 770 | |
| 771 button._icon = icon | |
| 772 button._text = text | |
| 773 | |
| 774 button:SetHook ("OnEnter", button_on_enter) | |
| 775 button:SetHook ("OnLeave", button_on_leave) | |
| 776 | |
| 777 if (panel.rows [o].icon) then | |
| 778 icon.texture = panel.rows [o].icon | |
| 779 if (panel.rows [o].iconalign) then | |
| 780 if (panel.rows [o].iconalign == "center") then | |
| 781 icon:SetPoint ("center", button, "center") | |
| 782 elseif (panel.rows [o].iconalign == "right") then | |
| 783 icon:SetPoint ("right", button, "right") | |
| 784 end | |
| 785 else | |
| 786 icon:SetPoint ("left", button, "left") | |
| 787 end | |
| 788 end | |
| 789 | |
| 790 if (panel.rows [o].name and not panel.rows [o].notext) then | |
| 791 text:SetPoint ("left", icon, "right", 2, 0) | |
| 792 text.text = panel.rows [o].name | |
| 793 end | |
| 794 | |
| 795 --> inser in the table | |
| 796 tinsert (row.row_widgets, button) | |
| 797 | |
| 798 elseif (_type == "icon") then | |
| 799 | |
| 800 --> create button and icon | |
| 801 local iconbutton = DF:NewButton (row, nil, "$parentIconButton" .. o, "iconbutton", 22, 20) | |
| 802 iconbutton:InstallCustomTexture() | |
| 803 | |
| 804 iconbutton:SetHook ("OnEnter", button_on_enter) | |
| 805 iconbutton:SetHook ("OnLeave", button_on_leave) | |
| 806 | |
| 807 --iconbutton:InstallCustomTexture() | |
| 808 local icon = DF:NewImage (iconbutton, nil, 20, 20, "artwork", nil, "_icon", "$parentIcon" .. o) | |
| 809 iconbutton._icon = icon | |
| 810 | |
| 811 iconbutton:SetPoint ("left", row, "left", anchors [o] + ( (panel.rows [o].width - 22) / 2), 0) | |
| 812 icon:SetPoint ("center", iconbutton, "center", 0, 0) | |
| 813 | |
| 814 --> set functions | |
| 815 local function iconcallback (texture) | |
| 816 iconbutton._icon.texture = texture | |
| 817 panel.rows [o].func (iconbutton.index, texture) | |
| 818 end | |
| 819 | |
| 820 iconbutton:SetClickFunction (function() | |
| 821 DF:IconPick (iconcallback, true) | |
| 822 return true | |
| 823 end) | |
| 824 | |
| 825 --> insert in the table | |
| 826 tinsert (row.row_widgets, iconbutton) | |
| 827 | |
| 828 end | |
| 829 | |
| 830 end | |
| 831 end | |
| 832 | 1028 |
| 833 return panel | 1029 return panel |
| 834 end | 1030 end |
| 835 | 1031 |
| 836 | 1032 |
| 869 ColorPickerFrame:Show() | 1065 ColorPickerFrame:Show() |
| 870 | 1066 |
| 871 end | 1067 end |
| 872 | 1068 |
| 873 ------------icon pick | 1069 ------------icon pick |
| 874 function DF:IconPick (callback, close_when_select) | 1070 function DF:IconPick (callback, close_when_select, param1, param2) |
| 875 | 1071 |
| 876 if (not DF.IconPickFrame) then | 1072 if (not DF.IconPickFrame) then |
| 877 | 1073 |
| 878 local string_lower = string.lower | 1074 local string_lower = string.lower |
| 879 | 1075 |
| 978 end) | 1174 end) |
| 979 | 1175 |
| 980 DF.IconPickFrame.buttons = {} | 1176 DF.IconPickFrame.buttons = {} |
| 981 | 1177 |
| 982 local OnClickFunction = function (self) | 1178 local OnClickFunction = function (self) |
| 983 DF.IconPickFrame.callback (self.icon:GetTexture()) | 1179 DF.IconPickFrame.callback (self.icon:GetTexture(), DF.IconPickFrame.param1, DF.IconPickFrame.param2) |
| 984 if (DF.IconPickFrame.click_close) then | 1180 if (DF.IconPickFrame.click_close) then |
| 985 close_button:Click() | 1181 close_button:Click() |
| 986 end | 1182 end |
| 987 end | 1183 end |
| 988 | 1184 |
| 1200 DF.IconPickFrameScroll = scroll | 1396 DF.IconPickFrameScroll = scroll |
| 1201 DF.IconPickFrame:Hide() | 1397 DF.IconPickFrame:Hide() |
| 1202 | 1398 |
| 1203 end | 1399 end |
| 1204 | 1400 |
| 1401 DF.IconPickFrame.param1, DF.IconPickFrame.param2 = param1, param2 | |
| 1402 | |
| 1205 DF.IconPickFrame:Show() | 1403 DF.IconPickFrame:Show() |
| 1206 DF.IconPickFrameScroll.update (DF.IconPickFrameScroll) | 1404 DF.IconPickFrameScroll.update (DF.IconPickFrameScroll) |
| 1207 DF.IconPickFrame.callback = callback or DF.IconPickFrame.emptyFunction | 1405 DF.IconPickFrame.callback = callback or DF.IconPickFrame.emptyFunction |
| 1208 DF.IconPickFrame.click_close = close_when_select | 1406 DF.IconPickFrame.click_close = close_when_select |
| 1209 | 1407 |
| 1322 end | 1520 end |
| 1323 local Panel1PxSetTitle = function (self, text) | 1521 local Panel1PxSetTitle = function (self, text) |
| 1324 self.Title:SetText (text or "") | 1522 self.Title:SetText (text or "") |
| 1325 end | 1523 end |
| 1326 | 1524 |
| 1525 local Panel1PxSetLocked= function (self, lock_state) | |
| 1526 if (type (lock_state) ~= "boolean") then | |
| 1527 return | |
| 1528 end | |
| 1529 if (lock_state) then | |
| 1530 -- lock it | |
| 1531 self.IsLocked = false | |
| 1532 Panel1PxOnClickLock (self.Lock) | |
| 1533 else | |
| 1534 -- unlockit | |
| 1535 self.IsLocked = true | |
| 1536 Panel1PxOnClickLock (self.Lock) | |
| 1537 end | |
| 1538 end | |
| 1539 | |
| 1327 local Panel1PxReadConfig = function (self) | 1540 local Panel1PxReadConfig = function (self) |
| 1328 local db = self.db | 1541 local db = self.db |
| 1329 if (db) then | 1542 if (db) then |
| 1330 db.IsLocked = db.IsLocked or false | 1543 db.IsLocked = db.IsLocked or false |
| 1331 self.IsLocked = db.IsLocked | 1544 self.IsLocked = db.IsLocked |
| 1366 frame.db.position.y = frame.db.position.y or 0 | 1579 frame.db.position.y = frame.db.position.y or 0 |
| 1367 frame:SetPoint ("center", UIParent, "center", frame.db.position.x * UIscale / scale, frame.db.position.y * UIscale / scale) | 1580 frame:SetPoint ("center", UIParent, "center", frame.db.position.x * UIscale / scale, frame.db.position.y * UIscale / scale) |
| 1368 end | 1581 end |
| 1369 end | 1582 end |
| 1370 | 1583 |
| 1584 local Panel1PxSavePosition= function (self) | |
| 1585 DF:SavePositionOnScreen (self) | |
| 1586 end | |
| 1587 | |
| 1371 local Panel1PxHasPosition = function (self) | 1588 local Panel1PxHasPosition = function (self) |
| 1372 local db = self.db | 1589 local db = self.db |
| 1373 if (db) then | 1590 if (db) then |
| 1374 if (db.position and db.position.x and (db.position.x ~= 0 or db.position.y ~= 0)) then | 1591 if (db.position and db.position.x and (db.position.x ~= 0 or db.position.y ~= 0)) then |
| 1375 return true | 1592 return true |
| 1444 f.SetTitle = Panel1PxSetTitle | 1661 f.SetTitle = Panel1PxSetTitle |
| 1445 f.Title = title_string | 1662 f.Title = title_string |
| 1446 f.Lock = lock | 1663 f.Lock = lock |
| 1447 f.Close = close | 1664 f.Close = close |
| 1448 f.HasPosition = Panel1PxHasPosition | 1665 f.HasPosition = Panel1PxHasPosition |
| 1666 f.SavePosition = Panel1PxSavePosition | |
| 1449 | 1667 |
| 1450 f.IsLocked = not f.IsLocked | 1668 f.IsLocked = not f.IsLocked |
| 1669 f.SetLocked = Panel1PxSetLocked | |
| 1451 Panel1PxOnToggleLock (f) | 1670 Panel1PxOnToggleLock (f) |
| 1452 | 1671 |
| 1453 return f | 1672 return f |
| 1454 end | 1673 end |
| 1455 | 1674 |
| 1675 ------------------------------------------------------------------------------------------------------------------------------------------------ | |
| 1676 -- ~prompt | |
| 1677 function DF:ShowPromptPanel (message, func_true, func_false) | |
| 1678 | |
| 1679 if (not DF.prompt_panel) then | |
| 1680 local f = CreateFrame ("frame", "DetailsFrameworkPrompt", UIParent) | |
| 1681 f:SetSize (400, 100) | |
| 1682 f:SetFrameStrata ("DIALOG") | |
| 1683 f:SetPoint ("center", UIParent, "center", 0, -300) | |
| 1684 f:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}) | |
| 1685 f:SetBackdropColor (0, 0, 0, 0.8) | |
| 1686 f:SetBackdropBorderColor (0, 0, 0, 1) | |
| 1687 | |
| 1688 local button_true = DF:CreateButton (f, nil, 60, 20, "") | |
| 1689 button_true:SetPoint ("bottomleft", f, "bottomleft", 5, 5) | |
| 1690 f.button_true = button_true | |
| 1691 | |
| 1692 local button_false = DF:CreateButton (f, nil, 60, 20, "") | |
| 1693 button_false:SetPoint ("bottomright", f, "bottomright", -5, 5) | |
| 1694 f.button_false = button_false | |
| 1695 | |
| 1696 button_true:SetClickFunction (function() | |
| 1697 local my_func = button_true.true_function | |
| 1698 if (my_func) then | |
| 1699 local okey, errormessage = pcall (my_func, true) | |
| 1700 if (not okey) then | |
| 1701 print ("error:", errormessage) | |
| 1702 end | |
| 1703 end | |
| 1704 end) | |
| 1705 | |
| 1706 button_false:SetClickFunction (function() | |
| 1707 local my_func = button_false.false_function | |
| 1708 if (my_func) then | |
| 1709 local okey, errormessage = pcall (my_func, true) | |
| 1710 if (not okey) then | |
| 1711 print ("error:", errormessage) | |
| 1712 end | |
| 1713 end | |
| 1714 end) | |
| 1715 | |
| 1716 f:Hide() | |
| 1717 DF.promtp_panel = f | |
| 1718 end | |
| 1719 | |
| 1720 assert (type (func_true) == "function" and type (func_false) == "function", "ShowPromptPanel expects two functions.") | |
| 1721 | |
| 1722 DF.promtp_panel.button_true.true_function = func_true | |
| 1723 DF.promtp_panel.button_false.false_function = func_false | |
| 1724 | |
| 1725 DF.promtp_panel:Show() | |
| 1726 end | |
| 1456 ------------------------------------------------------------------------------------------------------------------------------------------------ | 1727 ------------------------------------------------------------------------------------------------------------------------------------------------ |
| 1457 --> options button -- ~options | 1728 --> options button -- ~options |
| 1458 function DF:CreateOptionsButton (parent, callback, name) | 1729 function DF:CreateOptionsButton (parent, callback, name) |
| 1459 | 1730 |
| 1460 local b = CreateFrame ("button", name, parent) | 1731 local b = CreateFrame ("button", name, parent) |
| 2487 f:SetScript ("OnSizeChanged", chart_panel_onresize) | 2758 f:SetScript ("OnSizeChanged", chart_panel_onresize) |
| 2488 chart_panel_onresize (f) | 2759 chart_panel_onresize (f) |
| 2489 | 2760 |
| 2490 return f | 2761 return f |
| 2491 end | 2762 end |
| 2763 | |
| 2764 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | |
| 2765 -- ~gframe | |
| 2766 local gframe_on_enter_line = function (self) | |
| 2767 self:SetBackdropColor (0, 0, 0, 0) | |
| 2768 | |
| 2769 local parent = self:GetParent() | |
| 2770 local ball = self.ball | |
| 2771 ball:SetBlendMode ("ADD") | |
| 2772 | |
| 2773 local on_enter = parent._onenter_line | |
| 2774 if (on_enter) then | |
| 2775 return on_enter (self, parent) | |
| 2776 end | |
| 2777 end | |
| 2778 | |
| 2779 local gframe_on_leave_line = function (self) | |
| 2780 self:SetBackdropColor (0, 0, 0, .6) | |
| 2781 | |
| 2782 local parent = self:GetParent() | |
| 2783 local ball = self.ball | |
| 2784 ball:SetBlendMode ("BLEND") | |
| 2785 | |
| 2786 local on_leave = parent._onleave_line | |
| 2787 if (on_leave) then | |
| 2788 return on_leave (self, parent) | |
| 2789 end | |
| 2790 end | |
| 2791 | |
| 2792 local gframe_create_line = function (self) | |
| 2793 local index = #self._lines+1 | |
| 2794 | |
| 2795 local f = CreateFrame ("frame", nil, self) | |
| 2796 self._lines [index] = f | |
| 2797 f.id = index | |
| 2798 f:SetScript ("OnEnter", gframe_on_enter_line) | |
| 2799 f:SetScript ("OnLeave", gframe_on_leave_line) | |
| 2800 | |
| 2801 f:SetWidth (self._linewidth) | |
| 2802 | |
| 2803 if (index == 1) then | |
| 2804 f:SetPoint ("topleft", self, "topleft") | |
| 2805 f:SetPoint ("bottomleft", self, "bottomleft") | |
| 2806 else | |
| 2807 local previous_line = self._lines [index-1] | |
| 2808 f:SetPoint ("topleft", previous_line, "topright") | |
| 2809 f:SetPoint ("bottomleft", previous_line, "bottomright") | |
| 2810 end | |
| 2811 | |
| 2812 local t = f:CreateTexture (nil, "background") | |
| 2813 t:SetWidth (1) | |
| 2814 t:SetPoint ("topright", f, "topright") | |
| 2815 t:SetPoint ("bottomright", f, "bottomright") | |
| 2816 t:SetTexture (1, 1, 1, .1) | |
| 2817 f.grid = t | |
| 2818 | |
| 2819 local b = f:CreateTexture (nil, "overlay") | |
| 2820 b:SetTexture ([[Interface\COMMON\Indicator-Yellow]]) | |
| 2821 b:SetSize (16, 16) | |
| 2822 f.ball = b | |
| 2823 local anchor = CreateFrame ("frame", nil, f) | |
| 2824 anchor:SetAllPoints (b) | |
| 2825 b.tooltip_anchor = anchor | |
| 2826 | |
| 2827 local spellicon = f:CreateTexture (nil, "artwork") | |
| 2828 spellicon:SetPoint ("bottom", b, "bottom", 0, 10) | |
| 2829 spellicon:SetSize (16, 16) | |
| 2830 f.spellicon = spellicon | |
| 2831 | |
| 2832 local timeline = f:CreateFontString (nil, "overlay", "GameFontNormal") | |
| 2833 timeline:SetPoint ("bottomright", f, "bottomright", -2, 0) | |
| 2834 _detalhes:SetFontSize (timeline, 8) | |
| 2835 f.timeline = timeline | |
| 2836 | |
| 2837 return f | |
| 2838 end | |
| 2839 | |
| 2840 local gframe_getline = function (self, index) | |
| 2841 local line = self._lines [index] | |
| 2842 if (not line) then | |
| 2843 line = gframe_create_line (self) | |
| 2844 end | |
| 2845 return line | |
| 2846 end | |
| 2847 | |
| 2848 local gframe_reset = function (self) | |
| 2849 for i, line in ipairs (self._lines) do | |
| 2850 line:Hide() | |
| 2851 end | |
| 2852 if (self.GraphLib_Lines_Used) then | |
| 2853 for i = #self.GraphLib_Lines_Used, 1, -1 do | |
| 2854 local line = tremove (self.GraphLib_Lines_Used) | |
| 2855 tinsert (self.GraphLib_Lines, line) | |
| 2856 line:Hide() | |
| 2857 end | |
| 2858 end | |
| 2859 end | |
| 2860 | |
| 2861 local gframe_update = function (self, lines) | |
| 2862 | |
| 2863 local g = LibStub:GetLibrary ("LibGraph-2.0") | |
| 2864 local h = self:GetHeight()/100 | |
| 2865 local amtlines = #lines | |
| 2866 local linewidth = self._linewidth | |
| 2867 | |
| 2868 local max_value = 0 | |
| 2869 for i = 1, amtlines do | |
| 2870 if (lines [i].value > max_value) then | |
| 2871 max_value = lines [i].value | |
| 2872 end | |
| 2873 end | |
| 2874 | |
| 2875 local o = 1 | |
| 2876 local lastvalue = self:GetHeight()/2 | |
| 2877 | |
| 2878 for i = 1, min (amtlines, self._maxlines) do | |
| 2879 | |
| 2880 local data = lines [i] | |
| 2881 | |
| 2882 local pvalue = data.value / max_value * 100 | |
| 2883 if (pvalue > 98) then | |
| 2884 pvalue = 98 | |
| 2885 end | |
| 2886 pvalue = pvalue * h | |
| 2887 | |
| 2888 g:DrawLine (self, (o-1)*linewidth, lastvalue, o*linewidth, pvalue, linewidth, {1, 1, 1, 1}, "overlay") | |
| 2889 lastvalue = pvalue | |
| 2890 | |
| 2891 local line = self:GetLine (i) | |
| 2892 line:Show() | |
| 2893 line.ball:Show() | |
| 2894 | |
| 2895 line.ball:SetPoint ("bottomleft", self, "bottomleft", (o*linewidth)-8, pvalue-8) | |
| 2896 line.spellicon:SetTexture (nil) | |
| 2897 line.timeline:SetText (data.text) | |
| 2898 line.timeline:Show() | |
| 2899 | |
| 2900 line.data = data | |
| 2901 | |
| 2902 o = o + 1 | |
| 2903 end | |
| 2904 | |
| 2905 end | |
| 2906 | |
| 2907 function DF:CreateGFrame (parent, w, h, linewidth, onenter, onleave, member, name) | |
| 2908 local f = CreateFrame ("frame", name, parent) | |
| 2909 f:SetSize (w or 450, h or 150) | |
| 2910 f.CustomLine = [[Interface\AddOns\Details\Libs\LibGraph-2.0\line]] | |
| 2911 | |
| 2912 if (member) then | |
| 2913 parent [member] = f | |
| 2914 end | |
| 2915 | |
| 2916 f.CreateLine = gframe_create_line | |
| 2917 f.GetLine = gframe_getline | |
| 2918 f.Reset = gframe_reset | |
| 2919 f.UpdateLines = gframe_update | |
| 2920 | |
| 2921 f._lines = {} | |
| 2922 | |
| 2923 f._onenter_line = onenter | |
| 2924 f._onleave_line = onleave | |
| 2925 | |
| 2926 f._linewidth = linewidth or 50 | |
| 2927 f._maxlines = floor (f:GetWidth() / f._linewidth) | |
| 2928 | |
| 2929 return f | |
| 2930 end |
