local RUI = LibStub("RUI-1.0")
if not RUI then return end

-- RUI.Widget.IconButton(parent, iconPath, label, width, height, onClick) → Frame
-- Button with a 16x16 icon on the left. iconPath is a texture path or FileDataID.
-- Caller must SetPoint.
function RUI.Widget.IconButton(parent, iconPath, label, width, height, onClick)
    local btn = RUI.Widget.Button(parent, "", width, height, onClick)

    local icon = btn:CreateTexture(nil, "ARTWORK")
    icon:SetSize(16, 16)
    icon:SetPoint("LEFT", btn, "LEFT", 6, 0)
    icon:SetTexture(iconPath)
    btn._icon = icon

    btn._label:ClearAllPoints()
    btn._label:SetPoint("LEFT",  icon, "RIGHT", 4, 0)
    btn._label:SetPoint("RIGHT", btn,  "RIGHT", -6, 0)
    btn._label:SetJustifyH("LEFT")
    btn._label:SetText(label or "")

    return btn
end
