adam@0: local _, AskMrRobot = ... adam@0: adam@0: -- initialize the ItemIcon class (inherit from a dummy frame) adam@0: AskMrRobot.ItemIcon = AskMrRobot.inheritsFrom(AskMrRobot.ItemTooltipFrame) adam@0: adam@0: -- item icon contructor adam@0: function AskMrRobot.ItemIcon:new(name, parent) adam@0: -- create a new frame (if one isn't supplied) adam@0: local o = AskMrRobot.ItemTooltipFrame:new(name, parent) adam@0: adam@0: -- use the ItemIcon class adam@0: setmetatable(o, { __index = AskMrRobot.ItemIcon }) adam@0: adam@0: -- the item icon adam@0: o.itemIcon = o:CreateTexture(nil, "BACKGROUND") adam@0: o.itemIcon:SetPoint("TOPLEFT") adam@0: o.itemIcon:SetPoint("BOTTOMRIGHT") adam@0: adam@0: -- return the instance of the ItemIcon adam@0: return o adam@0: end adam@0: adam@0: function AskMrRobot.ItemIcon:SetRoundBorder() adam@0: self:SetBackdrop({edgeFile = "Interface\\AddOns\\AskMrRobot\\Media\\round-edge", edgeSize = 8}) adam@0: end adam@0: adam@0: function AskMrRobot.ItemIcon:SetSquareBorder() adam@0: self:SetBackdrop({edgeFile = "Interface\\AddOns\\AskMrRobot\\Media\\square-edge", edgeSize = 8}) adam@0: end adam@0: adam@0: -- set the item icon and tooltip from the specified item link adam@0: function AskMrRobot.ItemIcon:SetItemLink(link) adam@0: AskMrRobot.ItemTooltipFrame.SetItemLink(self, link) adam@0: if link then adam@0: self.itemIcon:SetTexture(GetItemIcon(AskMrRobot.getItemIdFromLink(link))) adam@0: self.itemIcon:SetTexCoord(0, 1, 0, 1) adam@0: else adam@0: self.itemIcon:SetTexture(nil) adam@0: end adam@0: end