Quantcast
WoWInterface - View Single Post - LibDBIcon ... how to hide ?
View Single Post
03-29-20, 09:03 AM   #3
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,111
Code:
local addon = LibStub("AceAddon-3.0"):NewAddon("MyAddOn")
local icon = LibStub("LibDBIcon-1.0")

local defaults = {
    profile = {
        enableaddon = true,
    },
    global = { -- global setting because people hate setting the icon on every profile or character
        minimap = {
            hide = false,
            lock = true,
            -- radius = 90, -- how many pixels from 0 / top of minimap
            -- minimapPos = 200 -- how far away from minimap center in pixels
        }
    }
}

local options = {
    type = "group",
    childgroups = "tab",
    name = "MyAddOn",
    desc = L["My AddOn which does stuff"],
    args = {
        enableaddon = {
            order = 10,
            name = ENABLE,
            type = "toggle",
            -- etc
        end
        },
        hideminimapbutton = {
            order = 20,
            name = L["Hide Minimap Button"],
            desc = L["Toggle hiding the button"],
            type = "toggle",
            get = function() return db.minimap.hide end,
            set = function(info, value)
                MyAddOnDB.db.minimap.hide = value
                if value then
                    icon:Hide("MyAddOn")
                else
                    icon:Show("MyAddOn")
                end
            end
        }
    }
}

function addon:OnInitialize()
    self.db = LibStub("AceDB-3.0"):New("MyAddOnDB", defaults, true)
    
    -- other setup here including registering options table

    local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
 
    local dataobj = ldb:NewDataObject(addon, {
        type = "data source",
        icon = "Interface\\Addons\\MyAddOn\\icon.tga",
        label = "MyAddOn",
        OnClick = function(object, button)
             -- open configuration
        end,
        OnTooltipShow = function(tip)
            tip:AddLine(L["Click to open configuration."], NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b)
            tip:Show()
        end
    })
    icon:Register("MyAddOn", dataobj, self.db.global.minimap)
end
  Reply With Quote