Mercurial > wow > squawk
changeset 16:6c28e55a00cf
hmm
author | wobin |
---|---|
date | Sat, 02 May 2009 23:54:32 +1000 |
parents | 9e61a930b822 |
children | 2a73deb7bc54 |
files | .pkgmeta Squawk.lua embeds.xml |
diffstat | 3 files changed, 95 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/.pkgmeta Sat Apr 25 21:42:27 2009 +1000 +++ b/.pkgmeta Sat May 02 23:54:32 2009 +1000 @@ -19,6 +19,6 @@ Libs/AceEvent-3.0: url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceEvent-3.0 tag: latest - Libs/LibQTip-1.0: - url: svn://svn.wowace.com/wow/libqtip-1-0/mainline/trunk + Libs/LibQTipClick-1.0: + url: svn://svn.wowace.com/wow/libqtipclick-1-0/mainline/trunk tag: latest
--- a/Squawk.lua Sat Apr 25 21:42:27 2009 +1000 +++ b/Squawk.lua Sat May 02 23:54:32 2009 +1000 @@ -444,22 +444,46 @@ local LDBFeed = LibStub("LibDataBroker-1.1"):NewDataObject("Squawk", {type = "data source", text = "Awk!"}) local QTip = LibStub("LibQTip-1.0") +local QTipClick = LibStub("LibQTipClick-1.0") +local tooltip = {} + +local function HideTooltip() + if MouseIsOver(tooltip) then return end + tooltip:SetScript("OnLeave", nil) + tooltip:Hide() + QTip:Release(tooltip) + tooltip = nil +end + +local function ReplyToMe(cell, Owner, event) + View:Print("Replying to @"..Owner) +end local function AddLine(tooltip, Line, Number, Owner, TimeStamp) + local x,y if #Line < 79 then - tooltip:AddLine(Number, Owner, Line, TimeStamp) + y,x = tooltip:AddNormalLine(Number, Owner, Line, TimeStamp) else - tooltip:AddLine(Number, Owner, Line:sub(1, 80).."-", TimeStamp) + y,x = tooltip:AddNormalLine(Number, Owner, Line:sub(1, 80).."-", TimeStamp) AddLine(tooltip, Line:sub(81)) end + if not TimeStamp then return end + + -- Now add the reply clickback + tooltip:SetCell(y, 5, " ", Owner) + tooltip.lines[y].cells[5]:SetBackdrop({bgFile= "Interface\\Addons\\Squawk\\reply"}) + if not tooltip.lines[y].cells[5]:GetScript("OnHide") then + tooltip.lines[y].cells[5]:SetScript("OnHide", function(self) self:SetBackdrop(nil) self:SetScript("OnHide", nil) end) + end + -- Reply clickback finished end function LDBFeed:OnEnter() - local tooltip = QTip:Acquire("Squawk",4, "LEFT", "LEFT", "LEFT", "RIGHT") + tooltip = QTipClick:Acquire("Squawk",5, "LEFT", "CENTER", "LEFT", "RIGHT", "RIGHT") + tooltip:Clear() + tooltip:SetCallback("OnMouseDown", ReplyToMe) self.tooltip = tooltip - tooltip:AddHeader('Squawk') - for i,squawk in ipairs(Squawk:GetLast10()) do - if #squawk.Message > 79 then + for i,squawk in ipairs(Squawk:GetLast10(Model.Squawks)) do local head = true local message = {strsplit("\n",squawk.Message)} for _,line in ipairs(message) do @@ -470,17 +494,73 @@ AddLine(tooltip, line) end end - else - tooltip:AddLine(i..".", squawk.Owner, squawk.Message, View:GetTime(squawk.Time)) - end end tooltip:SmartAnchorTo(self) + tooltip:SetScript("OnLeave", HideTooltip) tooltip:Show() end -function LDBFeed:OnTooltipShow() +function LDBFeed:OnLeave() + HideTooltip() +end +--[[ + +function LDBFeed:OnClick(button) + editbox:ClearAllPoints() + editbox:SetPoint(GetTipAnchor(self)) + editbox:Show() end -function LDBFeed:OnLeave() - QTip:Release(self.tooltip) +local function GetTipAnchor(frame) + if not x or not y then return "TOPLEFT", frame, "BOTTOMLEFT" end + local hhalf = (x > UIParent:GetWidth()*2/3) and "RIGHT" or (x < UIParent:GetWidth()/3) and "LEFT" or "" + local vhalf = (y > UIParent:GetHeight()/2) and "TOP" or "BOTTOM" + return vhalf..hhalf, frame, (vhalf == "TOP" and "BOTTOM" or "TOP")..hhalf end + +local editbox = CreateFrame('EditBox', nil, UIParent) +editbox:Hide() +editbox:SetAutoFocus(true) +editbox:SetHeight(32) +editbox:SetWidth(350) +editbox:SetFrameStrata("HIGH") +editbox:SetFontObject('GameFontHighlightSmall') +lib.editbox = editbox + +editbox:SetScript("OnEscapePressed", editbox.ClearFocus) +editbox:SetScript("OnEnterPressed", editbox.ClearFocus) +editbox:SetScript("OnEditFocusLost", editbox.Hide) +editbox:SetScript("OnEditFocusGained", editbox.HighlightText) +editbox:SetScript("OnTextChanged", function(self) + self:SetText(self:GetParent().val) + self:HighlightText() +end) + + local left = editbox:CreateTexture(nil, "BACKGROUND") + left:SetWidth(8) left:SetHeight(20) + left:SetPoint("LEFT", -5, 0) + left:SetTexture("Interface\\Common\\Common-Input-Border") + left:SetTexCoord(0, 0.0625, 0, 0.625) + + local right = editbox:CreateTexture(nil, "BACKGROUND") + right:SetWidth(8) right:SetHeight(20) + right:SetPoint("RIGHT", 0, 0) + right:SetTexture("Interface\\Common\\Common-Input-Border") + right:SetTexCoord(0.9375, 1, 0, 0.625) + + local center = editbox:CreateTexture(nil, "BACKGROUND") + center:SetHeight(20) + center:SetPoint("RIGHT", right, "LEFT", 0, 0) + center:SetPoint("LEFT", left, "RIGHT", 0, 0) + center:SetTexture("Interface\\Common\\Common-Input-Border") + center:SetTexCoord(0.0625, 0.9375, 0, 0.625) + +function lib.OpenEditbox(self) + editbox:SetText(self.val) + editbox:SetParent(self) + editbox:SetPoint("LEFT", self) + editbox:SetPoint("RIGHT", self) + editbox:Show() +end +--]] +
--- a/embeds.xml Sat Apr 25 21:42:27 2009 +1000 +++ b/embeds.xml Sat May 02 23:54:32 2009 +1000 @@ -3,6 +3,7 @@ <Script file="Libs\Ace3\LibStub\LibStub.lua"/> <Script file="Libs\LibDataBroker-1.1\LibDataBroker-1.1.lua"/> <Include file="Libs\LibQTip-1.0\lib.xml"/> + <Include file="Libs\LibQTipClick-1.0\lib.xml"/> <Include file="Libs\Ace3\CallbackHandler-1.0\CallbackHandler-1.0.xml"/> <Include file="Libs\Ace3\AceTimer-3.0\AceTimer-3.0.xml"/> <Include file="Libs\Ace3\AceEvent-3.0\AceEvent-3.0.xml"/>