WoWInterface SVN mikma

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /Ribbon
    from Rev 430 to Rev 431
    Reverse comparison

Rev 430 → Rev 431

Ribbon.lua
1,3 → 1,4
 
-------------------------------------------------------------------------------
-- Addon namespace
-------------------------------------------------------------------------------
4,18 → 5,18
local Ribbon = CreateFrame("Frame")
Ribbon:RegisterEvent("PLAYER_ENTERING_WORLD")
Ribbon:RegisterEvent("UPDATE_FLOATING_CHAT_WINDOWS")
Ribbon:SetScript("OnEvent", function(self, event, ...)
if self[event] then
return self[event](self, event, ...)
end
Ribbon:SetScript("OnEvent", function(self, event, ...)
if self[event] then
return self[event](self, event, ...)
end
end)
 
local QTC = LibStub('LibQTip-1.0')
local QTip = LibStub('LibQTip-1.0')
Ribbon.DO = LibStub("LibDataBroker-1.1"):NewDataObject("Ribbon", {
icon = "Interface\\Icons\\INV_Misc_Bandage_16",
type = "data source",
label = "Ribbon",
text = "",
icon = "Interface\\Icons\\INV_Misc_Bandage_16",
type = "data source",
label = "Ribbon",
text = "",
})
 
-------------------------------------------------------------------------------
32,174 → 33,183
-------------------------------------------------------------------------------
local ChatEdit_InsertLink_OLD = ChatEdit_InsertLink
function ChatEdit_InsertLink(text)
if editbox:IsVisible() then
editbox:Insert(text)
editbox:SetFocus()
else
return ChatEdit_InsertLink_OLD(text)
end
if editbox:IsVisible() then
editbox:Insert(text)
editbox:SetFocus()
else
return ChatEdit_InsertLink_OLD(text)
end
end
 
local function LDBtext()
if RibbonDB.Important then
local text = RibbonDB.Notes[RibbonDB.Important]:gsub("|H.-|h(.-)|h", "%1")
Ribbon.DO.text = (#text > RibbonDB.limit and string.sub(text,1,RibbonDB.limit).."..." or text)
else Ribbon.DO.text = "" end
if RibbonDB.Important then
local text = RibbonDB.Notes[RibbonDB.Important]:gsub("|H.-|h(.-)|h", "%1")
Ribbon.DO.text = (#text > RibbonDB.limit and string.sub(text,1,RibbonDB.limit).."..." or text)
else Ribbon.DO.text = "" end
end
 
-- <3 Tekkub + Cork
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
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 function ToggleNote(cell, note, button)
if RibbonDB.Important == note then RibbonDB.Important = nil else RibbonDB.Important = note end
LDBtext()
if RibbonDB.Important == note then RibbonDB.Important = nil else RibbonDB.Important = note end
LDBtext()
tooltip:Hide()
if not edit then Ribbon:DrawTooltip(DockTo) end
end
 
local function EditNote(cell, data, button)
editbox:ClearAllPoints()
editbox:SetPoint(GetTipAnchor(DockTo))
editbox:Show()
editbox:SetText(data.text)
editbox:SetFocus()
edit = data.note
tooltip:SetScript("OnLeave", nil)
tooltip:Hide()
QTC:Release(tooltip)
tooltip = nil
editbox:ClearAllPoints()
editbox:SetPoint(GetTipAnchor(DockTo))
editbox:Show()
editbox:SetText(data.text)
editbox:SetFocus()
edit = data.note
 
tooltip:Hide()
if not edit then Ribbon:DrawTooltip(DockTo) end
end
 
local function RemoveNote(cell, note, button)
table.remove(RibbonDB.Notes, note)
if RibbonDB.Important == note then RibbonDB.Important = nil end
tooltip:Hide()
LDBtext()
table.remove(RibbonDB.Notes, note)
if RibbonDB.Important == note then RibbonDB.Important = nil end
tooltip:Hide()
LDBtext()
if not edit then Ribbon:DrawTooltip(DockTo) end
end
 
local function PasteNote(cell, note, button)
ChatFrameEditBox:Show()
ChatFrameEditBox:SetText(note)
ChatFrameEditBox:Show()
ChatFrameEditBox:SetText(note)
tooltip:Hide()
if not edit then Ribbon:DrawTooltip(DockTo) end
end
 
-------------------------------------------------------------------------------
-- Tooltip/LDB functions
-------------------------------------------------------------------------------
function Ribbon:OnEnter(self)
local x,y
tooltip = QTC:Acquire("RibbonTooltip", 4, "LEFT", "LEFT", "LEFT", "LEFT")
tooltip:Clear()
if next(RibbonDB.Notes) then
for k,v in pairs(RibbonDB.Notes) do
local text = v:gsub("|H.-|h(.-)|h", "%1")
y,x = tooltip:AddLine(icon2,icon3,icon4,(#text > RibbonDB.limit and string.sub(text,1,RibbonDB.limit).."..." or text)..(RibbonDB.Important == k and icon1 or ""))
tooltip:SetCellScript(y, 1, "OnMouseUp", EditNote, {note = k, text = v})
tooltip:SetCellScript(y, 2, "OnMouseUp", RemoveNote, k)
tooltip:SetCellScript(y, 3, "OnMouseUp", PasteNote, v)
tooltip:SetCellScript(y, 4, "OnMouseUp", ToggleNote, k)
end
else
tooltip:AddHeader("|cFF00FF00|TInterface\\Icons\\INV_Misc_Bandage_16:17:17:1:-1|tRibbon|r is AddOn where you can store notes.")
tooltip:AddLine("Clicking the display adds notes in the list.")
tooltip:AddLine("Clicking the lines shows the note in the display.")
tooltip:AddLine("The buttons ( |TInterface\\Icons\\INV_Misc_ScrewDriver_01:17:17:3:-2|t |TInterface\\Icons\\INV_Misc_Bomb_01:17:17:3:-2|t |TInterface\\AddOns\\Ribbon\\resting:17:17:3:-2|t ) are 'Edit', 'Delete', and 'Paste in chat'.")
end
tooltip:SmartAnchorTo(self)
tooltip:Show()
tooltip:SetScript("OnLeave", Ribbon.OnLeave)
end
function Ribbon:DrawTooltip(anchor)
local x,y
tooltip = QTip:Acquire("RibbonTooltip", 4, "LEFT", "LEFT", "LEFT", "LEFT")
tooltip:Clear()
 
function Ribbon:OnLeave()
-- if MouseIsOver(tooltip) then return end
-- tooltip:SetScript("OnLeave", nil)
-- tooltip:Hide()
QTC:Release(tooltip)
-- tooltip = nil
if next(RibbonDB.Notes) then
for k,v in pairs(RibbonDB.Notes) do
local text = v:gsub("|H.-|h(.-)|h", "%1")
y,x = tooltip:AddLine()
tooltip:SetCell(y, 1, icon2)
tooltip:SetCellScript(y, 1, "OnMouseDown", EditNote, {note = k, text = v})
 
tooltip:SetCell(y, 2, icon3)
tooltip:SetCellScript(y, 2, "OnMouseDown", RemoveNote, k)
 
tooltip:SetCell(y, 3, icon4)
tooltip:SetCellScript(y, 3, "OnMouseDown", PasteNote, v)
 
tooltip:SetCell(y, 4, (#text > RibbonDB.limit and string.sub(text,1,RibbonDB.limit).."..." or text)..(RibbonDB.Important == k and icon1 or ""))
tooltip:SetCellScript(y, 4, "OnMouseDown", ToggleNote, k)
end
else
tooltip:AddHeader("|cFF00FF00|TInterface\\Icons\\INV_Misc_Bandage_16:17:17:1:-1|tRibbon|r is AddOn where you can store notes.")
tooltip:AddLine("Clicking the display adds notes in the list.")
tooltip:AddLine("Clicking the lines shows the note in the display.")
tooltip:AddLine("The buttons ( |TInterface\\Icons\\INV_Misc_ScrewDriver_01:17:17:3:-2|t |TInterface\\Icons\\INV_Misc_Bomb_01:17:17:3:-2|t |TInterface\\AddOns\\Ribbon\\resting:17:17:3:-2|t ) are 'Edit', 'Delete', and 'Paste in chat'.")
end
tooltip:SetAutoHideDelay(0.25, anchor)
tooltip:SmartAnchorTo(anchor)
tooltip:Show()
end
 
function Ribbon.DO.OnEnter(self)
DockTo,x,y = self,self:GetCenter()
Ribbon:OnEnter(self)
function Ribbon.DO.OnEnter(display, motion)
DockTo, x,y = display, display:GetCenter()
 
if editbox:IsVisible() then return end
Ribbon:DrawTooltip(display)
end
 
function Ribbon.DO.OnLeave(self)
if MouseIsOver(tooltip) then return end
Ribbon:OnLeave()
function Ribbon.DO.OnLeave(display, motion)
end
 
function Ribbon.DO.OnClick(self)
editbox:ClearAllPoints()
editbox:SetPoint(GetTipAnchor(self))
editbox:Show()
tooltip:Hide()
function Ribbon.DO.OnClick(display, button)
if editbox:IsVisible() then
editbox:Hide()
Ribbon:DrawTooltip(display)
else
editbox:ClearAllPoints()
editbox:SetPoint(GetTipAnchor(display))
editbox:Show()
tooltip:Hide()
end
end
 
-------------------------------------------------------------------------------
-- Initialization
-------------------------------------------------------------------------------
function Ribbon:PLAYER_ENTERING_WORLD()
RibbonDB = RibbonDB or {}
RibbonDB.Notes = RibbonDB.Notes or {}
RibbonDB = RibbonDB or {}
RibbonDB.Notes = RibbonDB.Notes or {}
 
-- <3 Tekkub + tekKonfigAboutPanel.lua
editbox = CreateFrame('EditBox', "RibbonEditbox", UIParent)
editbox:Hide()
editbox:SetAutoFocus(true)
editbox:SetHeight(32)
editbox:SetFontObject('GameFontHighlightSmall')
editbox:SetWidth(350)
editbox:SetHeight(20)
editbox:SetFrameStrata("HIGH")
-- <3 Tekkub + tekKonfigAboutPanel.lua
editbox = CreateFrame('EditBox', "RibbonEditbox", UIParent)
editbox:Hide()
editbox:SetAutoFocus(true)
editbox:SetHeight(32)
editbox:SetFontObject('GameFontHighlightSmall')
editbox:SetWidth(350)
editbox:SetHeight(20)
editbox:SetFrameStrata("HIGH")
 
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 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 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)
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)
 
editbox:SetScript("OnEscapePressed", function()
editbox:ClearFocus()
edit = nil
end)
editbox:SetScript("OnEnterPressed", function(self)
if edit then
RibbonDB.Notes[edit] = self:GetText()
if RibbonDB.Important then
local text = RibbonDB.Notes[RibbonDB.Important]:gsub("|H.-|h(.-)|h", "%1")
Ribbon.DO.text = (#text > RibbonDB.limit and string.sub(text,1,RibbonDB.limit).."..." or text)
else Ribbon.DO.text = "" end
else table.insert(RibbonDB.Notes,self:GetText()) end
edit = nil
self:ClearFocus()
end)
editbox:SetScript("OnEditFocusLost", editbox.Hide)
editbox:SetScript("OnEditFocusGained", editbox.HighlightText)
editbox:SetScript("OnShow", function(self)
self:SetText("Enter to accept, Esc to cancel")
self:SetFocus()
end)
editbox:SetScript("OnEscapePressed", function()
editbox:ClearFocus()
edit = nil
end)
editbox:SetScript("OnEnterPressed", function(self)
if edit then
RibbonDB.Notes[edit] = self:GetText()
if RibbonDB.Important then
local text = RibbonDB.Notes[RibbonDB.Important]:gsub("|H.-|h(.-)|h", "%1")
Ribbon.DO.text = (#text > RibbonDB.limit and string.sub(text,1,RibbonDB.limit).."..." or text)
else Ribbon.DO.text = "" end
else table.insert(RibbonDB.Notes,self:GetText()) end
edit = nil
self:ClearFocus()
end)
editbox:SetScript("OnEditFocusLost", editbox.Hide)
editbox:SetScript("OnEditFocusGained", editbox.HighlightText)
editbox:SetScript("OnShow", function(self)
self:SetText("Enter to accept, Esc to cancel")
self:SetFocus()
end)
 
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
self.PLAYER_ENTERING_WORLD = nil
LDBtext()
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
self.PLAYER_ENTERING_WORLD = nil
LDBtext()
end
 
function Ribbon:UPDATE_FLOATING_CHAT_WINDOWS()
RibbonDB.limit = GetScreenWidth()/8.5
end
\ No newline at end of file + RibbonDB.limit = GetScreenWidth()/8.5 +end
Ribbon.toc
2,7 → 2,7
## Notes: Reminder where you can type stuff!
## Author: Mikma
## Interface: 30100
## Version: 2.2
## Version: 2.3
## SavedVariables: RibbonDB
 
LibStub.lua