{"action":"created","issue":{"url":"https://api.github.com/repos/oUF-wow/oUF/issues/316","repository_url":"https://api.github.com/repos/oUF-wow/oUF","labels_url":"https://api.github.com/repos/oUF-wow/oUF/issues/316/labels{/name}","comments_url":"https://api.github.com/repos/oUF-wow/oUF/issues/316/comments","events_url":"https://api.github.com/repos/oUF-wow/oUF/issues/316/events","html_url":"https://github.com/oUF-wow/oUF/pull/316","id":183204953,"number":316,"title":"element: Add power gain/loss indicator [WIP]","user":{"login":"ls-","id":2725970,"avatar_url":"https://avatars.githubusercontent.com/u/2725970?v=3","gravatar_id":"","url":"https://api.github.com/users/ls-","html_url":"https://github.com/ls-","followers_url":"https://api.github.com/users/ls-/followers","following_url":"https://api.github.com/users/ls-/following{/other_user}","gists_url":"https://api.github.com/users/ls-/gists{/gist_id}","starred_url":"https://api.github.com/users/ls-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ls-/subscriptions","organizations_url":"https://api.github.com/users/ls-/orgs","repos_url":"https://api.github.com/users/ls-/repos","events_url":"https://api.github.com/users/ls-/events{/privacy}","received_events_url":"https://api.github.com/users/ls-/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/oUF-wow/oUF/labels/element","name":"element","color":"444444"},{"url":"https://api.github.com/repos/oUF-wow/oUF/labels/feature","name":"feature","color":"c2e0c6"},{"url":"https://api.github.com/repos/oUF-wow/oUF/labels/testing%20required","name":"testing required","color":"1d76db"}],"state":"open","locked":false,"assignee":{"login":"ls-","id":2725970,"avatar_url":"https://avatars.githubusercontent.com/u/2725970?v=3","gravatar_id":"","url":"https://api.github.com/users/ls-","html_url":"https://github.com/ls-","followers_url":"https://api.github.com/users/ls-/followers","following_url":"https://api.github.com/users/ls-/following{/other_user}","gists_url":"https://api.github.com/users/ls-/gists{/gist_id}","starred_url":"https://api.github.com/users/ls-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ls-/subscriptions","organizations_url":"https://api.github.com/users/ls-/orgs","repos_url":"https://api.github.com/users/ls-/repos","events_url":"https://api.github.com/users/ls-/events{/privacy}","received_events_url":"https://api.github.com/users/ls-/received_events","type":"User","site_admin":false},"assignees":[{"login":"ls-","id":2725970,"avatar_url":"https://avatars.githubusercontent.com/u/2725970?v=3","gravatar_id":"","url":"https://api.github.com/users/ls-","html_url":"https://github.com/ls-","followers_url":"https://api.github.com/users/ls-/followers","following_url":"https://api.github.com/users/ls-/following{/other_user}","gists_url":"https://api.github.com/users/ls-/gists{/gist_id}","starred_url":"https://api.github.com/users/ls-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ls-/subscriptions","organizations_url":"https://api.github.com/users/ls-/orgs","repos_url":"https://api.github.com/users/ls-/repos","events_url":"https://api.github.com/users/ls-/events{/privacy}","received_events_url":"https://api.github.com/users/ls-/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2016-10-15T11:36:50Z","updated_at":"2016-10-16T23:07:45Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/oUF-wow/oUF/pulls/316","html_url":"https://github.com/oUF-wow/oUF/pull/316","diff_url":"https://github.com/oUF-wow/oUF/pull/316.diff","patch_url":"https://github.com/oUF-wow/oUF/pull/316.patch"},"body":"This one addresses #308.\r\n\r\n![](http://i.imgur.com/bj4dL0t.gif)\r\n\r\nIssues:\r\n- [ ] Has no proper name;\r\n- [ ] Doesn't support additional power bar;\r\n- [ ] Monstrous `PostUpdate`.\r\n\r\nExample. Please, pay attention to frames' levels, here `lossBar` is **below** `frame.Power`, cuz A) it looks better this way, B) you'll be able to see exact power level (you can't see shit on default personal resource display, btw)\r\n```Lua\r\n-- This part isn't related to element in question,\r\n-- however it may help to understand how things work\r\nlocal power = CreateFrame('StatusBar', nil, frame)\r\npower:SetFrameLevel(frame:GetFrameLevel() + 2)\r\npower:SetPoint('CENTER', 'UIParent', 'CENTER', -256, 256)\r\npower:SetSize(238, 24)\r\npower.colorPower = true\r\npower.frequentUpdates = true\r\n\r\nlocal bg = frame:CreateTexture(nil, 'BACKGROUND')\r\nbg:SetAllPoints(power)\r\nbg:SetColorTexture(1, 1, 1)\r\nbg.multiplier = 0.2\r\npower.bg = bg\r\n\r\nframe.Power = power\r\n\r\n-- Interesting stuff starts here :D\r\nlocal gainBar = CreateFrame('StatusBar', nil, frame.Power)\r\ngainBar:SetWidth(frame.Power:GetWidth())\r\ngainBar:SetReverseFill(false) -- you don't really need this one :p\r\ngainBar:SetStatusBarTexture([[Interface\\TargetingFrame\\UI-StatusBar]])\r\ngainBar:SetStatusBarColor(0, 1, 0)\r\n\r\nlocal lossBar = CreateFrame('StatusBar', nil, frame.Power)\r\nlossBar:SetFrameLevel(power:GetFrameLevel() - 1)\r\nlossBar:SetWidth(frame.Power:GetWidth())\r\nlossBar:SetReverseFill(true)\r\nlossBar:SetStatusBarTexture([[Interface\\TargetingFrame\\UI-StatusBar]])\r\nlossBar:SetStatusBarColor(1, 0, 0)\r\n\r\nframe.TempName = {\r\n\tgainBar = gainBar,\r\n\tlossBar = lossBar\r\n}\r\n\r\nframe.TempName.PostUpdate = function(self, unit, gain, loss, old, cur, max)\r\n\tif gain ~= 0 then\r\n\t\tlocal powerBar = self.gainBar:GetParent()\r\n\t\tlocal offset = powerBar:GetWidth() * (1 - old / max)\r\n\r\n\t\tself.gainBar:ClearAllPoints()\r\n\t\tself.gainBar:SetPoint('TOPLEFT', powerBar, 'TOPRIGHT', -offset, 0)\r\n\t\tself.gainBar:SetPoint('BOTTOMLEFT', powerBar, 'BOTTOMRIGHT', -offset, 0)\r\n\telseif loss ~= 0 then\r\n\t\tlocal powerBar = self.lossBar:GetParent()\r\n\t\tlocal offset = powerBar:GetWidth() * (1 - old / max)\r\n\r\n\t\tself.lossBar:ClearAllPoints()\r\n\t\tself.lossBar:SetPoint('TOPRIGHT', powerBar, 'TOPRIGHT', -offset, 0)\r\n\t\tself.lossBar:SetPoint('BOTTOMRIGHT', powerBar, 'BOTTOMRIGHT', -offset, 0)\r\n\tend\r\nend\r\n```\r\n\r\nOptions:\r\n```Lua\r\n.diffThreshold\t-- All power changes below threshold % will be ignored.\r\n\t\t\t\t-- Defaults to 0.1 or 10%.\r\n\r\n.updateDelay \t-- Period of time during which all updates below threshold will be ignored.\r\n\t\t\t\t-- Also defines amount of time for how long bars will be shown.\r\n\t\t\t\t-- Defaults to 0.4.\r\n```\r\nThe reason why I opted for such an ugly `PostUpdate` example, cuz this way gain/loss bar is still, and it doesn't wobble, it has to be attached to a point where `frame.Power:GetStatusBarTexture()` **was**.\r\n"},"comment":{"url":"https://api.github.com/repos/oUF-wow/oUF/issues/comments/254081981","html_url":"https://github.com/oUF-wow/oUF/pull/316#issuecomment-254081981","issue_url":"https://api.github.com/repos/oUF-wow/oUF/issues/316","id":254081981,"user":{"login":"p3lim","id":26496,"avatar_url":"https://avatars.githubusercontent.com/u/26496?v=3","gravatar_id":"","url":"https://api.github.com/users/p3lim","html_url":"https://github.com/p3lim","followers_url":"https://api.github.com/users/p3lim/followers","following_url":"https://api.github.com/users/p3lim/following{/other_user}","gists_url":"https://api.github.com/users/p3lim/gists{/gist_id}","starred_url":"https://api.github.com/users/p3lim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/p3lim/subscriptions","organizations_url":"https://api.github.com/users/p3lim/orgs","repos_url":"https://api.github.com/users/p3lim/repos","events_url":"https://api.github.com/users/p3lim/events{/privacy}","received_events_url":"https://api.github.com/users/p3lim/received_events","type":"User","site_admin":false},"created_at":"2016-10-16T23:07:45Z","updated_at":"2016-10-16T23:07:45Z","body":"Blizzard calls it \"Feedback\", it's defined in [FrameXML/BuilderSpenderFrame.lua](https://github.com/tekkub/wow-ui-source/blob/live/FrameXML/BuilderSpenderFrame.lua), where there's also a \"FullResourcePull\" widget (typically used for energy-based classes/specs)."}}
{"actor":{"display_login":"p3lim"}}