Mercurial > wow > hansgar_and_franzok_assist
changeset 56:7c0f819a85c6 v7.3.5.056
- Framework update.
| author | Tercio |
|---|---|
| date | Sun, 11 Mar 2018 10:50:12 -0300 |
| parents | 307f5af3ad02 |
| children | b1c62eed8999 |
| files | Libs/DF/cooltip.lua Libs/DF/fw.lua Libs/DF/panel.lua Libs/DF/slider.lua Libs/DF/textentry.lua |
| diffstat | 5 files changed, 231 insertions(+), 75 deletions(-) [+] |
line wrap: on
line diff
--- a/Libs/DF/cooltip.lua Sat Dec 09 11:49:01 2017 -0200 +++ b/Libs/DF/cooltip.lua Sun Mar 11 10:50:12 2018 -0300 @@ -1623,7 +1623,7 @@ end end - + if (CoolTip.OptionsTable.FixedHeight) then frame1:SetHeight (CoolTip.OptionsTable.FixedHeight) else @@ -1683,6 +1683,7 @@ frame1:ClearAllPoints() local anchor = CoolTip.OptionsTable.Anchor or CoolTip.Host + frame1:SetPoint (CoolTip.OptionsTable.MyAnchor, anchor, CoolTip.OptionsTable.RelativeAnchor, 0 + moveX + CoolTip.OptionsTable.WidthAnchorMod, 10 + CoolTip.OptionsTable.HeightAnchorMod + moveY) if (not x_mod) then @@ -1850,12 +1851,12 @@ function CoolTip:SetHost (frame, myPoint, hisPoint, x, y) --> check data integrity if (type (frame) ~= "table" or not frame.GetObjectType) then - print ("host need to be a frame") + print ("host needs to be a frame") return --> error end CoolTip.Host = frame - + CoolTip.frame1:SetFrameLevel (frame:GetFrameLevel()+1) --> defaults @@ -2964,6 +2965,11 @@ CoolTip:SetColor ("main", host.CoolTip.MainColor or "transparent") CoolTip:SetColor ("sec", host.CoolTip.SubColor or "transparent") + local okay, errortext = pcall (host.CoolTip.BuildFunc, host, host.CoolTip and host.CoolTip.FixedValue) --resetting anchors + if (not okay) then + print ("Cooltip Injected Fucntion Error:", errortext) + end + CoolTip:SetOwner (host, host.CoolTip.MyAnchor, host.CoolTip.HisAnchor, host.CoolTip.X, host.CoolTip.Y) local options = host.CoolTip.Options @@ -2976,15 +2982,13 @@ end end - host.CoolTip.BuildFunc() - if (CoolTip.Indexes == 0) then if (host.CoolTip.Default) then CoolTip:SetType ("tooltip") CoolTip:AddLine (host.CoolTip.Default, nil, 1, "white") end end - + CoolTip:ShowCooltip() if (fromClick) then
--- a/Libs/DF/fw.lua Sat Dec 09 11:49:01 2017 -0200 +++ b/Libs/DF/fw.lua Sun Mar 11 10:50:12 2018 -0300 @@ -1,5 +1,5 @@ -local dversion = 62 +local dversion = 68 local major, minor = "DetailsFramework-1.0", dversion local DF, oldminor = LibStub:NewLibrary (major, minor) @@ -999,11 +999,15 @@ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --> templates -DF.font_templates = {} +--fonts + +DF.font_templates = DF.font_templates or {} DF.font_templates ["ORANGE_FONT_TEMPLATE"] = {color = "orange", size = 11, font = "Accidental Presidency"} DF.font_templates ["OPTIONS_FONT_TEMPLATE"] = {color = "yellow", size = 12, font = "Accidental Presidency"} -DF.dropdown_templates = {} +-- dropdowns + +DF.dropdown_templates = DF.dropdown_templates or {} DF.dropdown_templates ["OPTIONS_DROPDOWN_TEMPLATE"] = { backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}, backdropcolor = {1, 1, 1, .5}, @@ -1012,7 +1016,9 @@ onenterbordercolor = {1, 1, 1, 1}, } -DF.switch_templates = {} +-- switches + +DF.switch_templates = DF.switch_templates or {} DF.switch_templates ["OPTIONS_CHECKBOX_TEMPLATE"] = { backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}, backdropcolor = {1, 1, 1, .5}, @@ -1034,14 +1040,18 @@ onenterbordercolor = {1, 1, 1, 1}, } -DF.button_templates = {} +-- buttons + +DF.button_templates = DF.button_templates or {} DF.button_templates ["OPTIONS_BUTTON_TEMPLATE"] = { backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}, backdropcolor = {1, 1, 1, .5}, backdropbordercolor = {0, 0, 0, 1}, } -DF.slider_templates = {} +-- sliders + +DF.slider_templates = DF.slider_templates or {} DF.slider_templates ["OPTIONS_SLIDER_TEMPLATE"] = { backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}, backdropcolor = {1, 1, 1, .5}, @@ -1054,7 +1064,21 @@ thumbcolor = {0, 0, 0, 0.5}, } -function DF:InstallTemplate (widget_type, template_name, template) +function DF:InstallTemplate (widget_type, template_name, template, parent_name) + + local newTemplate = {} + + --if has a parent, just copy the parent to the new template + if (parent_name and type (parent_name) == "string") then + local parentTemplate = DF:GetTemplate (widget_type, parent_name) + if (parentTemplate) then + DF.table.copy (newTemplate, parentTemplate) + end + end + + --copy the template passed into the new template + DF.table.copy (newTemplate, template) + widget_type = string.lower (widget_type) local template_table @@ -1070,9 +1094,9 @@ template_table = DF.slider_templates end - template_table [template_name] = template + template_table [template_name] = newTemplate - return template + return newTemplate end function DF:GetTemplate (widget_type, template_name)
--- a/Libs/DF/panel.lua Sat Dec 09 11:49:01 2017 -0200 +++ b/Libs/DF/panel.lua Sun Mar 11 10:50:12 2018 -0300 @@ -2415,24 +2415,21 @@ end local chart_panel_set_scale = function (self, amt, func, text) - if (type (amt) ~= "number") then return end - local piece = amt / 1000 / 8 - if (not text or text == "") then - text = amt > 1000000 and "M" or amt > 1000 and "K" - end - + --each line amount, then multiply the line index by this number + local piece = amt / 8 + for i = 1, 8 do if (func) then - self ["dpsamt" .. math.abs (i-9)]:SetText ( func (piece*i) .. (text or "")) + self ["dpsamt" .. math.abs (i-9)]:SetText (func (piece*i)) else if (piece*i > 1) then - self ["dpsamt" .. math.abs (i-9)]:SetText ( format ("%.1f", piece*i) .. (text or "")) + self ["dpsamt" .. math.abs (i-9)]:SetText (DF.FormatNumber (piece*i)) else - self ["dpsamt" .. math.abs (i-9)]:SetText ( format ("%.3f", piece*i) .. (text or "")) + self ["dpsamt" .. math.abs (i-9)]:SetText (format ("%.3f", piece*i)) end end end @@ -2535,7 +2532,6 @@ self.BoxLabels [next_box] = thisbox local box = DF:NewImage (self.Graphic, nil, 16, 16, "border") - local text = DF:NewLabel (self.Graphic) local border = DF:NewImage (self.Graphic, [[Interface\DialogFrame\UI-DialogBox-Gold-Corner]], 30, 30, "artwork") @@ -2543,7 +2539,7 @@ border:SetTexture ([[Interface\DialogFrame\UI-DialogBox-Gold-Corner]]) local checktexture = DF:NewImage (self.Graphic, [[Interface\Buttons\UI-CheckBox-Check]], 18, 18, "overlay") - checktexture:SetPoint ("center", box, "center", -1, -1) + checktexture:SetPoint ("center", box, "center", 0, -1) checktexture:SetTexture ([[Interface\Buttons\UI-CheckBox-Check]]) thisbox.box = box @@ -2557,7 +2553,12 @@ button:SetScript ("OnClick", function() chart_panel_enable_line (self, thisbox) end) - button:SetPoint ("center", box.widget or box, "center") + button:SetPoint ("topleft", box.widget or box, "topleft", 0, 0) + button:SetPoint ("bottomright", box.widget or box, "bottomright", 0, 0) + + button:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}) + button:SetBackdropColor (0, 0, 0, 0.0) + button:SetBackdropBorderColor (0, 0, 0, 1) thisbox.button = button @@ -2566,7 +2567,7 @@ if (next_box == 1) then thisbox.text:SetPoint ("topright", self, "topright", -35, -16) else - thisbox.text:SetPoint ("right", self.BoxLabels [next_box-1].box, "left", -7, 0) + thisbox.text:SetPoint ("right", self.BoxLabels [next_box-1].box, "left", -17, 0) end return thisbox @@ -2575,6 +2576,17 @@ local realign_labels = function (self) + if (not self.ShowHeader) then + for _, box in ipairs (self.BoxLabels) do + box.check:Hide() + box.button:Hide() + box.border:Hide() + box.box:Hide() + box.text:Hide() + end + return + end + local width = self:GetWidth() - 108 local first_box = self.BoxLabels [1] @@ -2594,17 +2606,25 @@ line_width = box.text:GetStringWidth() + 26 box.text:SetPoint ("topright", self, "topright", -35, -40) else - box.text:SetPoint ("right", self.BoxLabels [i-1].box, "left", -7, 0) + box.text:SetPoint ("right", self.BoxLabels [i-1].box, "left", -27, 0) end else break end end + if (self.HeaderOnlyIndicator) then + for _, box in ipairs (self.BoxLabels) do + box.check:Hide() + box.button:Hide() + end + return + end + end local chart_panel_add_label = function (self, color, name, type, number) - + local next_box = self.BoxLabelsAmount local thisbox = self.BoxLabels [next_box] @@ -2613,19 +2633,19 @@ end self.BoxLabelsAmount = self.BoxLabelsAmount + 1 - + thisbox.type = type thisbox.index = number - + thisbox.box:SetColorTexture (unpack (color)) thisbox.text:SetText (name) thisbox.check:Show() thisbox.button:Show() - thisbox.border:Show() + thisbox.border:Hide() thisbox.box:Show() thisbox.text:Show() - + thisbox.showing = true thisbox.enabled = true @@ -2638,7 +2658,7 @@ local pixel = self.Graphic:GetWidth() / self.TimeScale local index = 1 - local r, g, b = unpack (color or line_default_color) + local r, g, b, a = unpack (color or line_default_color) for i = 1, #overlayData, 2 do local aura_start = overlayData [i] @@ -2659,7 +2679,7 @@ this_block:SetWidth (pixel*5) end - this_block:SetColorTexture (r, g, b, 0.25) + this_block:SetColorTexture (r, g, b, a or 0.25) this_block:Show() index = index + 1 @@ -2686,7 +2706,7 @@ draw_overlay (self, this_overlay, overlayData, color) tinsert (self.OData, {overlayData, color or line_default_color}) - if (name) then + if (name and self.HeaderShowOverlays) then self:AddLabel (color or line_default_color, name, "overlay", #self.OData) end end @@ -2694,6 +2714,80 @@ self.OverlaysAmount = self.OverlaysAmount + 1 end +-- Define the tricube weight function +function calc_cubeweight (i, j, d) + local w = ( 1 - math.abs ((j-i)/d)^3)^3 + if w < 0 then + w = 0; + end + return w +end + +local calc_lowess_smoothing = function (self, data, bandwidth) + local length = #data + local newData = {} + + for i = 1, length do + local A = 0 + local B = 0 + local C = 0 + local D = 0 + local E = 0 + + -- Calculate span of values to be included in the regression + local jmin = floor (i-bandwidth/2) + local jmax = ceil (i+bandwidth/2) + if jmin < 1 then + jmin = 1 + end + if jmax > length then + jmax = length + end + + -- For all the values in the span, compute the weight and then the linear fit + + for j = jmin, jmax do + w = calc_cubeweight (i, j, bandwidth/2) + x = j + y = data [j] + + A = A + w*x + B = B + w*y + C = C + w*x^2 + D = D + w*x*y + E = E + w + end + + -- Calculate a (slope) and b (offset) for the linear fit + local a = (A*B-D*E)/(A^2 - C*E); + local b = (A*D-B*C)/(A^2 - C*E); + + -- Calculate the smoothed value by the formula y=a*x+b (x <- i) + newData [i] = a*i+b; + + end + + return newData +end + +local calc_stddev = function (self, data) + local total = 0 + for i = 1, #data do + total = total + data[i] + end + local mean = total / #data + + local totalDistance = 0 + for i = 1, #data do + totalDistance = totalDistance + ((data[i] - mean) ^ 2) + end + + local deviation = math.sqrt (totalDistance / #data) + return deviation +end + + + local SMA_table = {} local SMA_max = 0 local reset_SMA = function() @@ -2736,7 +2830,7 @@ for i = 1, 17 do local label = self.TimeLabels [i] - label:SetPoint ("bottomleft", self, "bottomleft", 78 + ((i-1)*spacement), 13) + label:SetPoint ("bottomleft", self, "bottomleft", 78 + ((i-1)*spacement), self.TimeLabelsHeight) label.line:SetHeight (height - 45) end @@ -2760,7 +2854,7 @@ local amount = #graphicData local scaleW = 1/self:GetWidth() - + local content = graphicData tinsert (content, 1, 0) tinsert (content, 1, 0) @@ -2885,11 +2979,11 @@ f:SetTime (max_time) chart_panel_onresize (f) - end + local chart_panel_vlines_on = function (self) for i = 1, 17 do local label = self.TimeLabels [i] @@ -2974,31 +3068,15 @@ local title = DF:NewLabel (f, nil, "$parentTitle", "chart_title", "Chart!", nil, 20, {1, 1, 0}) title:SetPoint ("topleft", f, "topleft", 110, -13) - local bottom_texture = DF:NewImage (f, nil, 702, 25, "background", nil, nil, "$parentBottomTexture") - bottom_texture:SetColorTexture (0, 0, 0, .6) - bottom_texture:SetPoint ("bottomleft", f, "bottomleft", 8, 7) - bottom_texture:SetPoint ("bottomright", f, "bottomright", -8, 7) - f.Overlays = {} f.OverlaysAmount = 1 f.BoxLabels = {} f.BoxLabelsAmount = 1 - f.TimeLabels = {} - for i = 1, 17 do - local time = f:CreateFontString (nil, "overlay", "GameFontHighlightSmall") - time:SetText ("00:00") - time:SetPoint ("bottomleft", f, "bottomleft", 78 + ((i-1)*36), 13) - f.TimeLabels [i] = time - - local line = f:CreateTexture (nil, "border") - line:SetSize (1, h-45) - line:SetColorTexture (1, 1, 1, .1) - line:SetPoint ("bottomleft", time, "topright", 0, -10) - line:Hide() - time.line = line - end + f.ShowHeader = true + f.HeaderOnlyIndicator = false + f.HeaderShowOverlays = true --graphic local g = LibStub:GetLibrary("LibGraph-2.0"):CreateGraphLine (name .. "Graphic", f, "topleft","topleft", 108, -35, w - 120, h - 67) @@ -3022,11 +3100,12 @@ f.Graphic = g f.GData = {} f.OData = {} + f.ChartFrames = {} --div lines for i = 1, 8, 1 do local line = g:CreateTexture (nil, "overlay") - line:SetColorTexture (1, 1, 1, .2) + line:SetColorTexture (1, 1, 1, .05) line:SetWidth (670) line:SetHeight (1.1) @@ -3036,9 +3115,35 @@ s:SetPoint ("topleft", f, "topleft", 27, -61 + (-(24.6*i))) line:SetPoint ("topleft", s, "bottom", -27, 0) + line:SetPoint ("topright", g, "right", 0, 0) s.line = line end + --create time labels and the bottom texture to use as a background to these labels + f.TimeLabels = {} + f.TimeLabelsHeight = 16 + + for i = 1, 17 do + local time = f:CreateFontString (nil, "overlay", "GameFontHighlightSmall") + time:SetText ("00:00") + time:SetPoint ("bottomleft", f, "bottomleft", 78 + ((i-1)*36), f.TimeLabelsHeight) + f.TimeLabels [i] = time + + local line = f:CreateTexture (nil, "border") + line:SetSize (1, h-45) + line:SetColorTexture (1, 1, 1, .1) + line:SetPoint ("bottomleft", time, "topright", 0, -10) + line:Hide() + time.line = line + end + + local bottom_texture = DF:NewImage (f, nil, 702, 25, "background", nil, nil, "$parentBottomTexture") + bottom_texture:SetColorTexture (.1, .1, .1, .7) + bottom_texture:SetPoint ("topright", g, "bottomright", 0, 0) + bottom_texture:SetPoint ("bottomleft", f, "bottomleft", 8, 12) + + + f.SetTime = chart_panel_align_timelabels f.EnableVerticalLines = chart_panel_vlines_on f.DisableVerticalLines = chart_panel_vlines_off @@ -3051,6 +3156,8 @@ f.AddOverlay = chart_panel_add_overlay f.HideCloseButton = chart_panel_hide_close_button f.RightClickClose = chart_panel_right_click_close + f.CalcStdDev = calc_stddev + f.CalcLowessSmoothing = calc_lowess_smoothing f:SetScript ("OnSizeChanged", chart_panel_onresize) chart_panel_onresize (f)
--- a/Libs/DF/slider.lua Sat Dec 09 11:49:01 2017 -0200 +++ b/Libs/DF/slider.lua Sun Mar 11 10:50:12 2018 -0300 @@ -583,6 +583,25 @@ self:SetScript ("OnUpdate", on_update) end) + local do_precision = function (text) + if (type (text) == "string" and text:find ("%.")) then + local left, right = strsplit (".", text) + left = tonumber (left) + right = tonumber (right) + + if (left and right) then + local newString = tostring (left) .. "." .. tostring (right) + local newNumber = tonumber (newString) + + if (newNumber) then + return newNumber + end + end + end + + return tonumber (text) + end + function DFSliderMetaFunctions:TypeValue() if (not self.isSwitch) then @@ -601,24 +620,20 @@ editbox:ClearFocus() editbox:Hide() editbox:GetParent().MyObject.typing_value = false - editbox:GetParent().MyObject.value = tonumber (editbox:GetText()) + editbox:GetParent().MyObject.value = tonumber (editbox:GetText()) --do_precision (editbox:GetText()) end) editbox:SetScript ("OnEscapePressed", function() editbox:ClearFocus() editbox:Hide() editbox:GetParent().MyObject.typing_value = false - editbox:GetParent().MyObject.value = tonumber (self.typing_value_started) + editbox:GetParent().MyObject.value = self.typing_value_started --do_precision (self.typing_value_started) end) editbox:SetScript ("OnTextChanged", function() editbox:GetParent().MyObject.typing_can_change = true - editbox:GetParent().MyObject.value = tonumber (editbox:GetText()) + editbox:GetParent().MyObject.value = tonumber (editbox:GetText()) --do_precision editbox:GetParent().MyObject.typing_can_change = false - - -- esse self fica como o primeiro a ser alterado - --print ("text changed", self:GetName()) - --print () end) DFSliderMetaFunctions.editbox_typevalue = editbox @@ -703,14 +718,14 @@ if (slider.MyObject.useDecimals) then amt = slider:GetValue() else - amt = _math_floor (slider:GetValue()) + amt = do_precision (slider:GetValue()) end - + if (slider.MyObject.typing_value and not slider.MyObject.typing_can_change) then slider.MyObject:SetValue (slider.MyObject.typing_value_started) return end - + table_insert (slider.MyObject.previous_value, 1, amt) table_remove (slider.MyObject.previous_value, 4) @@ -910,7 +925,7 @@ if (not container) then container = parent end - + --> defaults ltext = ltext or "OFF" rtext = rtext or "ON" @@ -1096,11 +1111,18 @@ --> default members: SliderObject.lockdown = false SliderObject.container = container - SliderObject.useDecimals = isDecemal or false SliderObject.slider = CreateFrame ("slider", name, parent) SliderObject.widget = SliderObject.slider + SliderObject.useDecimals = isDecemal or false + + if (SliderObject.useDecimals) then + SliderObject.slider:SetValueStep (0.01) + else + SliderObject.slider:SetValueStep (step) + end + if (not APISliderFunctions) then APISliderFunctions = true local idx = getmetatable (SliderObject.slider).__index @@ -1119,7 +1141,6 @@ SliderObject.slider:SetHeight (h) SliderObject.slider:SetOrientation ("horizontal") SliderObject.slider:SetMinMaxValues (min, max) - SliderObject.slider:SetValueStep (step) SliderObject.slider:SetValue (defaultv) SliderObject.ivalue = defaultv
--- a/Libs/DF/textentry.lua Sat Dec 09 11:49:01 2017 -0200 +++ b/Libs/DF/textentry.lua Sun Mar 11 10:50:12 2018 -0300 @@ -721,13 +721,13 @@ local borderframe = CreateFrame ("Frame", name, parent) borderframe:SetSize (w, h) - + if (member) then parent [member] = borderframe end local scrollframe = CreateFrame ("ScrollFrame", name, borderframe, "DetailsFrameworkEditBoxMultiLineTemplate") - + scrollframe:SetScript ("OnSizeChanged", function (self) scrollframe.editbox:SetSize (self:GetSize()) end)
