comparison Libs/DF/panel.lua @ 22:dbd417f413a8

- framework update.
author Tercio
date Tue, 08 Sep 2015 13:16:49 -0300
parents dc1c77254f80
children e16b1fc13935
comparison
equal deleted inserted replaced
21:7fef991992f6 22:dbd417f413a8
257 257
258 -- backdropcolor 258 -- backdropcolor
259 function PanelMetaFunctions:SetBackdropColor (color, arg2, arg3, arg4) 259 function PanelMetaFunctions:SetBackdropColor (color, arg2, arg3, arg4)
260 if (arg2) then 260 if (arg2) then
261 self.frame:SetBackdropColor (color, arg2, arg3, arg4 or 1) 261 self.frame:SetBackdropColor (color, arg2, arg3, arg4 or 1)
262 self.frame.Gradient.OnLeave = {color, arg2, arg3, arg4 or 1}
263 else 262 else
264 local _value1, _value2, _value3, _value4 = DF:ParseColors (color) 263 local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
265 self.frame:SetBackdropColor (_value1, _value2, _value3, _value4) 264 self.frame:SetBackdropColor (_value1, _value2, _value3, _value4)
266 self.frame.Gradient.OnLeave = {_value1, _value2, _value3, _value4}
267 end 265 end
268 end 266 end
269 267
270 -- border color 268 -- border color
271 function PanelMetaFunctions:SetBackdropBorderColor (color, arg2, arg3, arg4) 269 function PanelMetaFunctions:SetBackdropBorderColor (color, arg2, arg3, arg4)
272 if (arg2) then 270 if (arg2) then
273 return self.frame:SetBackdropBorderColor (color, arg2, arg3, arg4) 271 return self.frame:SetBackdropBorderColor (color, arg2, arg3, arg4)
274 end 272 end
275 local _value1, _value2, _value3, _value4 = DF:ParseColors (color) 273 local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
276 self.frame:SetBackdropBorderColor (_value1, _value2, _value3, _value4) 274 self.frame:SetBackdropBorderColor (_value1, _value2, _value3, _value4)
277 end
278
279 -- gradient colors
280 function PanelMetaFunctions:SetGradient (FadeType, color)
281 local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
282 if (FadeType == "OnEnter") then
283 self.frame.Gradient.OnEnter = {_value1, _value2, _value3, _value4}
284 elseif (FadeType == "OnLeave") then
285 self.frame.Gradient.OnLeave = {_value1, _value2, _value3, _value4}
286 end
287 end 275 end
288 276
289 -- tooltip 277 -- tooltip
290 function PanelMetaFunctions:SetTooltip (tooltip) 278 function PanelMetaFunctions:SetTooltip (tooltip)
291 if (tooltip) then 279 if (tooltip) then
319 if (_type (strata) == "table") then 307 if (_type (strata) == "table") then
320 self.widget:SetFrameStrata (strata:GetFrameStrata()) 308 self.widget:SetFrameStrata (strata:GetFrameStrata())
321 else 309 else
322 self.widget:SetFrameStrata (strata) 310 self.widget:SetFrameStrata (strata)
323 end 311 end
324 end
325
326 -- enable and disable gradients
327 function PanelMetaFunctions:DisableGradient()
328 self.GradientEnabled = false
329 end
330 function PanelMetaFunctions:EnableGradient()
331 self.GradientEnabled = true
332 end 312 end
333 313
334 --> hooks 314 --> hooks
335 function PanelMetaFunctions:SetHook (hookType, func) 315 function PanelMetaFunctions:SetHook (hookType, func)
336 if (func) then 316 if (func) then
487 PanelObject.OnShowHook = nil 467 PanelObject.OnShowHook = nil
488 PanelObject.OnMouseDownHook = nil 468 PanelObject.OnMouseDownHook = nil
489 PanelObject.OnMouseUpHook = nil 469 PanelObject.OnMouseUpHook = nil
490 --> misc 470 --> misc
491 PanelObject.is_locked = true 471 PanelObject.is_locked = true
492 PanelObject.GradientEnabled = true
493 PanelObject.container = container 472 PanelObject.container = container
494 PanelObject.rightButtonClose = false 473 PanelObject.rightButtonClose = false
495 474
496 PanelObject.frame = CreateFrame ("frame", name, parent, "DetailsFrameworkPanelTemplate") 475 PanelObject.frame = CreateFrame ("frame", name, parent, "DetailsFrameworkPanelTemplate")
497 PanelObject.widget = PanelObject.frame 476 PanelObject.widget = PanelObject.frame
586 end 565 end
587 end 566 end
588 567
589 local cur_width = 0 568 local cur_width = 0
590 local row_width = self._width / rows_shown 569 local row_width = self._width / rows_shown
570
591 local sindex = 1 571 local sindex = 1
592 572
593 wipe (self._anchors) 573 wipe (self._anchors)
594 574
595 for index, row in ipairs (self.rows) do 575 for index, row in ipairs (self.rows) do
763 for i = 1, #row.icon_available do 743 for i = 1, #row.icon_available do
764 row.icon_available[i]:Hide() 744 row.icon_available[i]:Hide()
765 end 745 end
766 end 746 end
767 747
748 self.current_header = updated_rows
749
768 self:AlignRows() 750 self:AlignRows()
769 751
770 end 752 end
771 753
772 local create_panel_text = function (self, row) 754 local create_panel_text = function (self, row)
796 end 778 end
797 779
798 local create_panel_button = function (self, row) 780 local create_panel_button = function (self, row)
799 row.button_total = row.button_total + 1 781 row.button_total = row.button_total + 1
800 local button = DF:NewButton (row, nil, "$parentButton" .. row.button_total, "button" .. row.button_total, 120, 20) 782 local button = DF:NewButton (row, nil, "$parentButton" .. row.button_total, "button" .. row.button_total, 120, 20)
801 button:InstallCustomTexture() 783 --, nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")
784 --button:InstallCustomTexture()
802 785
803 --> create icon and the text 786 --> create icon and the text
804 local icon = DF:NewImage (button, nil, 20, 20) 787 local icon = DF:NewImage (button, nil, 20, 20)
805 local text = DF:NewLabel (button) 788 local text = DF:NewLabel (button)
806 789
846 self._totalfunc = func 829 self._totalfunc = func
847 end 830 end
848 local drop_header_function = function (self) 831 local drop_header_function = function (self)
849 wipe (self.rows) 832 wipe (self.rows)
850 end 833 end
834
835 local fillpanel_update_size = function (self, elapsed)
836 local panel = self.MyObject
837
838 panel._width = panel:GetWidth()
839 panel._height = panel:GetHeight()
840
841 panel:UpdateRowAmount()
842 if (panel.current_header) then
843 update_rows (panel, panel.current_header)
844 end
845 panel:Refresh()
846
847 self:SetScript ("OnUpdate", nil)
848 end
849
851 -- ~fillpanel 850 -- ~fillpanel
851 --alias
852 function DF:CreateFillPanel (parent, rows, w, h, total_lines, fill_row, autowidth, options, member, name)
853 return DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options)
854 end
855
852 function DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options) 856 function DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options)
853 857
854 local panel = DF:NewPanel (parent, parent, name, member, w, h) 858 local panel = DF:NewPanel (parent, parent, name, member, w, h)
855 panel.backdrop = nil 859 panel.backdrop = nil
856 860
874 panel._raw_rows = {} 878 panel._raw_rows = {}
875 panel._anchors = {} 879 panel._anchors = {}
876 panel._fillfunc = fill_row 880 panel._fillfunc = fill_row
877 panel._totalfunc = total_lines 881 panel._totalfunc = total_lines
878 panel._autowidth = autowidth 882 panel._autowidth = autowidth
883
884 panel:SetScript ("OnSizeChanged", function()
885 panel:SetScript ("OnUpdate", fillpanel_update_size)
886 end)
879 887
880 for index, t in ipairs (rows) do 888 for index, t in ipairs (rows) do
881 panel.AddRow (panel, t) 889 panel.AddRow (panel, t)
882 end 890 end
883 891
918 elseif (t.type == "button") then 926 elseif (t.type == "button") then
919 local buttonwidget = row.button_inuse [button] 927 local buttonwidget = row.button_inuse [button]
920 button = button + 1 928 button = button + 1
921 buttonwidget.index = real_index 929 buttonwidget.index = real_index
922 930
923 local func = function() 931
924 t.func (real_index, index)
925 panel:Refresh()
926 end
927 buttonwidget:SetClickFunction (func)
928 932
929 if (type (results [index]) == "table") then 933 if (type (results [index]) == "table") then
930 if (results [index].text) then 934 if (results [index].text) then
931 buttonwidget:SetText (results [index].text) 935 buttonwidget:SetText (results [index].text)
932 end 936 end
934 if (results [index].icon) then 938 if (results [index].icon) then
935 buttonwidget._icon:SetTexture (results [index].icon) 939 buttonwidget._icon:SetTexture (results [index].icon)
936 end 940 end
937 941
938 if (results [index].func) then 942 if (results [index].func) then
939 buttonwidget:SetClickFunction (results [index].func, real_index, results [index].value) 943 local func = function()
944 t.func (real_index, results [index].value)
945 panel:Refresh()
946 end
947 buttonwidget:SetClickFunction (func)
948 else
949 local func = function()
950 t.func (real_index, index)
951 panel:Refresh()
952 end
953 buttonwidget:SetClickFunction (func)
940 end 954 end
941 else 955 else
956 local func = function()
957 t.func (real_index, index)
958 panel:Refresh()
959 end
960 buttonwidget:SetClickFunction (func)
942 buttonwidget:SetText (results [index]) 961 buttonwidget:SetText (results [index])
943 end 962 end
944 963
945 buttonwidget:Show() 964 buttonwidget:Show()
946 965
967 end 986 end
968 end 987 end
969 end 988 end
970 989
971 function panel:Refresh() 990 function panel:Refresh()
991 if (type (panel._totalfunc) == "boolean") then
992 --> not yet initialized
993 return
994 end
972 local filled_lines = panel._totalfunc (panel) 995 local filled_lines = panel._totalfunc (panel)
973 local scroll_total_lines = #panel.scrollframe.lines 996 local scroll_total_lines = #panel.scrollframe.lines
974 local line_height = options.rowheight 997 local line_height = options.rowheight
975 refresh_fillbox (panel.scrollframe) 998 refresh_fillbox (panel.scrollframe)
976 FauxScrollFrame_Update (panel.scrollframe, filled_lines, scroll_total_lines, line_height) 999 FauxScrollFrame_Update (panel.scrollframe, filled_lines, scroll_total_lines, line_height)
985 scrollframe:SetSize (w, h) 1008 scrollframe:SetSize (w, h)
986 panel.scrollframe = scrollframe 1009 panel.scrollframe = scrollframe
987 scrollframe.lines = {} 1010 scrollframe.lines = {}
988 1011
989 --create lines 1012 --create lines
990 local size = options.rowheight 1013 function panel:UpdateRowAmount()
991 local amount = math.floor (((h-21) / size)) 1014 local size = options.rowheight
992 1015 local amount = math.floor (((panel._height-21) / size))
993 for i = 1, amount do 1016
994 local row = CreateFrame ("frame", panel:GetName() .. "Row_" .. i, panel.widget) 1017 for i = #scrollframe.lines+1, amount do
995 row:SetSize (1, size) 1018 local row = CreateFrame ("frame", panel:GetName() .. "Row_" .. i, panel.widget)
996 row.color = {1, 1, 1, .2} 1019 row:SetSize (1, size)
997 1020 row.color = {1, 1, 1, .2}
998 row:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]]}) 1021
999 1022 row:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]]})
1000 if (i%2 == 0) then 1023
1001 row:SetBackdropColor (.5, .5, .5, 0.2) 1024 if (i%2 == 0) then
1002 else 1025 row:SetBackdropColor (.5, .5, .5, 0.2)
1003 row:SetBackdropColor (1, 1, 1, 0.00) 1026 else
1004 end 1027 row:SetBackdropColor (1, 1, 1, 0.00)
1005 1028 end
1006 row:SetPoint ("topleft", scrollframe, "topleft", 0, (i-1) * size * -1) 1029
1007 row:SetPoint ("topright", scrollframe, "topright", 0, (i-1) * size * -1) 1030 row:SetPoint ("topleft", scrollframe, "topleft", 0, (i-1) * size * -1)
1008 tinsert (scrollframe.lines, row) 1031 row:SetPoint ("topright", scrollframe, "topright", 0, (i-1) * size * -1)
1009 1032 tinsert (scrollframe.lines, row)
1010 row.text_available = {} 1033
1011 row.text_inuse = {} 1034 row.text_available = {}
1012 row.text_total = 0 1035 row.text_inuse = {}
1013 1036 row.text_total = 0
1014 row.entry_available = {} 1037
1015 row.entry_inuse = {} 1038 row.entry_available = {}
1016 row.entry_total = 0 1039 row.entry_inuse = {}
1017 1040 row.entry_total = 0
1018 row.button_available = {} 1041
1019 row.button_inuse = {} 1042 row.button_available = {}
1020 row.button_total = 0 1043 row.button_inuse = {}
1021 1044 row.button_total = 0
1022 row.icon_available = {} 1045
1023 row.icon_inuse = {} 1046 row.icon_available = {}
1024 row.icon_total = 0 1047 row.icon_inuse = {}
1025 end 1048 row.icon_total = 0
1026 1049 end
1050 end
1051 panel:UpdateRowAmount()
1052
1027 panel.AlignRows (panel) 1053 panel.AlignRows (panel)
1028 1054
1029 return panel 1055 return panel
1030 end 1056 end
1031 1057
1435 DF:SavePositionOnScreen (self) 1461 DF:SavePositionOnScreen (self)
1436 end 1462 end
1437 end 1463 end
1438 end 1464 end
1439 local simple_panel_settitle = function (self, title) 1465 local simple_panel_settitle = function (self, title)
1440 self.title:SetText (title) 1466 self.Title:SetText (title)
1441 end 1467 end
1468
1469 local simple_panel_close_click = function (self)
1470 self:GetParent():GetParent():Hide()
1471 end
1472
1473 local SimplePanel_frame_backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}
1474 local SimplePanel_frame_backdrop_color = {0, 0, 0, 0.9}
1475 local SimplePanel_frame_backdrop_border_color = {0, 0, 0, 1}
1442 1476
1443 function DF:CreateSimplePanel (parent, w, h, title, name) 1477 function DF:CreateSimplePanel (parent, w, h, title, name)
1444 1478
1445 if (not name) then 1479 if (not name) then
1446 name = "DetailsFrameworkSimplePanel" .. simple_panel_counter 1480 name = "DetailsFrameworkSimplePanel" .. simple_panel_counter
1454 f:SetSize (w or 400, h or 250) 1488 f:SetSize (w or 400, h or 250)
1455 f:SetPoint ("center", UIParent, "center", 0, 0) 1489 f:SetPoint ("center", UIParent, "center", 0, 0)
1456 f:SetFrameStrata ("FULLSCREEN") 1490 f:SetFrameStrata ("FULLSCREEN")
1457 f:EnableMouse() 1491 f:EnableMouse()
1458 f:SetMovable (true) 1492 f:SetMovable (true)
1493 f:SetBackdrop (SimplePanel_frame_backdrop)
1494 f:SetBackdropColor (unpack (SimplePanel_frame_backdrop_color))
1495 f:SetBackdropBorderColor (unpack (SimplePanel_frame_backdrop_border_color))
1459 tinsert (UISpecialFrames, name) 1496 tinsert (UISpecialFrames, name)
1460 1497
1498 local title_bar = CreateFrame ("frame", name .. "TitleBar", f)
1499 title_bar:SetPoint ("topleft", f, "topleft", 2, -3)
1500 title_bar:SetPoint ("topright", f, "topright", -2, -3)
1501 title_bar:SetHeight (20)
1502 title_bar:SetBackdrop (SimplePanel_frame_backdrop)
1503 title_bar:SetBackdropColor (.2, .2, .2, 1)
1504 title_bar:SetBackdropBorderColor (0, 0, 0, 1)
1505
1506 local close = CreateFrame ("button", name and name .. "CloseButton", title_bar)
1507 close:SetSize (16, 16)
1508 close:SetNormalTexture (DF.folder .. "icons")
1509 close:SetHighlightTexture (DF.folder .. "icons")
1510 close:SetPushedTexture (DF.folder .. "icons")
1511 close:GetNormalTexture():SetTexCoord (0, 16/128, 0, 1)
1512 close:GetHighlightTexture():SetTexCoord (0, 16/128, 0, 1)
1513 close:GetPushedTexture():SetTexCoord (0, 16/128, 0, 1)
1514 close:SetAlpha (0.7)
1515 close:SetScript ("OnClick", simple_panel_close_click)
1516 f.Close = close
1517
1518 local title_string = title_bar:CreateFontString (name and name .. "Title", "overlay", "GameFontNormal")
1519 title_string:SetTextColor (.8, .8, .8, 1)
1520 title_string:SetText (title or "")
1521 f.Title = title_string
1522
1523 f.Title:SetPoint ("center", title_bar, "center")
1524 f.Close:SetPoint ("right", title_bar, "right", -2, 0)
1525
1461 f:SetScript ("OnMouseDown", simple_panel_mouse_down) 1526 f:SetScript ("OnMouseDown", simple_panel_mouse_down)
1462 f:SetScript ("OnMouseUp", simple_panel_mouse_up) 1527 f:SetScript ("OnMouseUp", simple_panel_mouse_up)
1463
1464 local bg = f:CreateTexture (nil, "background")
1465 bg:SetAllPoints (f)
1466 bg:SetTexture (DF.folder .. "background")
1467
1468 local close = CreateFrame ("button", name .. "Close", f, "UIPanelCloseButton")
1469 close:SetSize (32, 32)
1470 close:SetPoint ("topright", f, "topright", 0, -12)
1471
1472 f.title = DF:CreateLabel (f, title or "", 12, nil, "GameFontNormal")
1473 f.title:SetPoint ("top", f, "top", 0, -22)
1474 1528
1475 f.SetTitle = simple_panel_settitle 1529 f.SetTitle = simple_panel_settitle
1476 1530
1477 simple_panel_counter = simple_panel_counter + 1 1531 simple_panel_counter = simple_panel_counter + 1
1478 1532
1676 -- ~prompt 1730 -- ~prompt
1677 function DF:ShowPromptPanel (message, func_true, func_false) 1731 function DF:ShowPromptPanel (message, func_true, func_false)
1678 1732
1679 if (not DF.prompt_panel) then 1733 if (not DF.prompt_panel) then
1680 local f = CreateFrame ("frame", "DetailsFrameworkPrompt", UIParent) 1734 local f = CreateFrame ("frame", "DetailsFrameworkPrompt", UIParent)
1681 f:SetSize (400, 100) 1735 f:SetSize (400, 65)
1682 f:SetFrameStrata ("DIALOG") 1736 f:SetFrameStrata ("DIALOG")
1683 f:SetPoint ("center", UIParent, "center", 0, -300) 1737 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}) 1738 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) 1739 f:SetBackdropColor (0, 0, 0, 0.8)
1686 f:SetBackdropBorderColor (0, 0, 0, 1) 1740 f:SetBackdropBorderColor (0, 0, 0, 1)
1687 1741
1688 local button_true = DF:CreateButton (f, nil, 60, 20, "") 1742 local prompt = f:CreateFontString (nil, "overlay", "GameFontNormal")
1743 prompt:SetPoint ("top", f, "top", 0, -15)
1744 prompt:SetJustifyH ("center")
1745 f.prompt = prompt
1746
1747 local button_true = DF:CreateButton (f, nil, 60, 20, "Yes")
1689 button_true:SetPoint ("bottomleft", f, "bottomleft", 5, 5) 1748 button_true:SetPoint ("bottomleft", f, "bottomleft", 5, 5)
1690 f.button_true = button_true 1749 f.button_true = button_true
1691 1750
1692 local button_false = DF:CreateButton (f, nil, 60, 20, "") 1751 local button_false = DF:CreateButton (f, nil, 60, 20, "No")
1693 button_false:SetPoint ("bottomright", f, "bottomright", -5, 5) 1752 button_false:SetPoint ("bottomright", f, "bottomright", -5, 5)
1694 f.button_false = button_false 1753 f.button_false = button_false
1695 1754
1696 button_true:SetClickFunction (function() 1755 button_true:SetClickFunction (function()
1697 local my_func = button_true.true_function 1756 local my_func = button_true.true_function
1698 if (my_func) then 1757 if (my_func) then
1699 local okey, errormessage = pcall (my_func, true) 1758 local okey, errormessage = pcall (my_func, true)
1700 if (not okey) then 1759 if (not okey) then
1701 print ("error:", errormessage) 1760 print ("error:", errormessage)
1702 end 1761 end
1762 f:Hide()
1703 end 1763 end
1704 end) 1764 end)
1705 1765
1706 button_false:SetClickFunction (function() 1766 button_false:SetClickFunction (function()
1707 local my_func = button_false.false_function 1767 local my_func = button_false.false_function
1708 if (my_func) then 1768 if (my_func) then
1709 local okey, errormessage = pcall (my_func, true) 1769 local okey, errormessage = pcall (my_func, true)
1710 if (not okey) then 1770 if (not okey) then
1711 print ("error:", errormessage) 1771 print ("error:", errormessage)
1712 end 1772 end
1773 f:Hide()
1713 end 1774 end
1714 end) 1775 end)
1715 1776
1716 f:Hide() 1777 f:Hide()
1717 DF.promtp_panel = f 1778 DF.promtp_panel = f
1718 end 1779 end
1719 1780
1720 assert (type (func_true) == "function" and type (func_false) == "function", "ShowPromptPanel expects two functions.") 1781 assert (type (func_true) == "function" and type (func_false) == "function", "ShowPromptPanel expects two functions.")
1721 1782
1783 DF.promtp_panel.prompt:SetText (message)
1722 DF.promtp_panel.button_true.true_function = func_true 1784 DF.promtp_panel.button_true.true_function = func_true
1723 DF.promtp_panel.button_false.false_function = func_false 1785 DF.promtp_panel.button_false.false_function = func_false
1724 1786
1725 DF.promtp_panel:Show() 1787 DF.promtp_panel:Show()
1726 end 1788 end
1789
1790
1791 function DF:ShowTextPromptPanel (message, callback)
1792
1793 if (not DF.text_prompt_panel) then
1794
1795 local f = CreateFrame ("frame", "DetailsFrameworkPrompt", UIParent)
1796 f:SetSize (400, 100)
1797 f:SetFrameStrata ("DIALOG")
1798 f:SetPoint ("center", UIParent, "center", 0, 300)
1799 f:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
1800 f:SetBackdropColor (0, 0, 0, 0.8)
1801 f:SetBackdropBorderColor (0, 0, 0, 1)
1802
1803 local prompt = f:CreateFontString (nil, "overlay", "GameFontNormal")
1804 prompt:SetPoint ("top", f, "top", 0, -15)
1805 prompt:SetJustifyH ("center")
1806 f.prompt = prompt
1807
1808 local button_true = DF:CreateButton (f, nil, 60, 20, "Okey")
1809 button_true:SetPoint ("bottomleft", f, "bottomleft", 10, 5)
1810 f.button_true = button_true
1811
1812 local button_false = DF:CreateButton (f, function() f.textbox:ClearFocus(); f:Hide() end, 60, 20, "Cancel")
1813 button_false:SetPoint ("bottomright", f, "bottomright", -10, 5)
1814 f.button_false = button_false
1815
1816 local textbox = DF:CreateTextEntry (f, function()end, 380, 20, "textbox", nil, nil, nil, nil)
1817 textbox:SetPoint ("topleft", f, "topleft", 10, -45)
1818
1819 button_true:SetClickFunction (function()
1820 local my_func = button_true.true_function
1821 if (my_func) then
1822 local okey, errormessage = pcall (my_func, textbox:GetText())
1823 textbox:ClearFocus()
1824 if (not okey) then
1825 print ("error:", errormessage)
1826 end
1827 f:Hide()
1828 end
1829 end)
1830
1831 f:Hide()
1832 DF.text_prompt_panel = f
1833 end
1834
1835 DF.text_prompt_panel:Show()
1836
1837 DF.text_prompt_panel.prompt:SetText (message)
1838 DF.text_prompt_panel.button_true.true_function = callback
1839 DF.text_prompt_panel.textbox:SetText ("")
1840 DF.text_prompt_panel.textbox:SetFocus (true)
1841
1842 end
1843
1727 ------------------------------------------------------------------------------------------------------------------------------------------------ 1844 ------------------------------------------------------------------------------------------------------------------------------------------------
1728 --> options button -- ~options 1845 --> options button -- ~options
1729 function DF:CreateOptionsButton (parent, callback, name) 1846 function DF:CreateOptionsButton (parent, callback, name)
1730 1847
1731 local b = CreateFrame ("button", name, parent) 1848 local b = CreateFrame ("button", name, parent)
2124 end 2241 end
2125 2242
2126 end 2243 end
2127 2244
2128 local chart_panel_set_scale = function (self, amt, func, text) 2245 local chart_panel_set_scale = function (self, amt, func, text)
2246
2129 if (type (amt) ~= "number") then 2247 if (type (amt) ~= "number") then
2130 return 2248 return
2131 end 2249 end
2132 2250
2133 local piece = amt / 1000 / 8 2251 local piece = amt / 1000 / 8
2252 if (not text or text == "") then
2253 text = amt > 1000000 and "M" or amt > 1000 and "K"
2254 end
2134 2255
2135 for i = 1, 8 do 2256 for i = 1, 8 do
2136 if (func) then 2257 if (func) then
2137 self ["dpsamt" .. math.abs (i-9)]:SetText ( func (piece*i) .. (text or "")) 2258 self ["dpsamt" .. math.abs (i-9)]:SetText ( func (piece*i) .. (text or ""))
2138 else 2259 else
2139 if (piece*i > 1) then 2260 if (piece*i > 1) then
2140 self ["dpsamt" .. math.abs (i-9)]:SetText ( floor (piece*i) .. (text or "")) 2261 self ["dpsamt" .. math.abs (i-9)]:SetText ( format ("%.1f", piece*i) .. (text or ""))
2141 else 2262 else
2142 self ["dpsamt" .. math.abs (i-9)]:SetText ( format ("%.3f", piece*i) .. (text or "")) 2263 self ["dpsamt" .. math.abs (i-9)]:SetText ( format ("%.3f", piece*i) .. (text or ""))
2143 end 2264 end
2144 end 2265 end
2145 end 2266 end
2262 local button = CreateFrame ("button", nil, self.Graphic) 2383 local button = CreateFrame ("button", nil, self.Graphic)
2263 button:SetSize (20, 20) 2384 button:SetSize (20, 20)
2264 button:SetScript ("OnClick", function() 2385 button:SetScript ("OnClick", function()
2265 chart_panel_enable_line (self, thisbox) 2386 chart_panel_enable_line (self, thisbox)
2266 end) 2387 end)
2267 button:SetPoint ("center", box, "center") 2388 button:SetPoint ("center", box.widget or box, "center")
2268 2389
2269 thisbox.button = button 2390 thisbox.button = button
2270 2391
2271 thisbox.box:SetPoint ("right", text, "left", -4, 0) 2392 thisbox.box:SetPoint ("right", text, "left", -4, 0)
2272 2393
2438 2559
2439 local chart_panel_add_data = function (self, graphicData, color, name, elapsed_time, lineTexture, smoothLevel, firstIndex) 2560 local chart_panel_add_data = function (self, graphicData, color, name, elapsed_time, lineTexture, smoothLevel, firstIndex)
2440 2561
2441 local f = self 2562 local f = self
2442 self = self.Graphic 2563 self = self.Graphic
2443 2564
2444 local _data = {} 2565 local _data = {}
2445 local max_value = graphicData.max_value 2566 local max_value = graphicData.max_value
2446 local amount = #graphicData 2567 local amount = #graphicData
2447 2568
2448 local scaleW = 1/self:GetWidth() 2569 local scaleW = 1/self:GetWidth()