--[[
Author: Jarth
Filename: CBs_Settings_Data.lua
]] --
-------------------------------------------------------------------------------------------------
-- VARIABLES --
-------------------------------------------------------------------------------------------------
local base = CollectionBars

-------------------------------------------------------------------------------------------------
-- FUNCTIONS --
-------------------------------------------------------------------------------------------------
function base.AppendMasterListTypeGeneral(self, typeSelection)
    self:AppendRow_Checkbox(typeSelection, {
        name = "Use account settings",
        tooltip = "When ON the account settings will be used. When OFF character settings will be used",
        funcGet = function()
            return self.base.Saved.UseAccountSettings
        end,
        funcSet = function(_, newValue)
            self.base.SetAndUpdateAccountSettings(newValue)
            self.base.InitializeWithSavedData()
            self.base.RestoreFrames()
            self.base.RestoreCombineLabels()
            self.base.Global.SettingsList:RefreshData()
        end
    })
    self:AppendRow_Checkbox(typeSelection, {
        name = "Load LibAddonMenu",
        tooltip = 'When ON the "Settings > Addons > Collection Bars" menu will be loaded\nRequires: LibAddonMenu-2.0\nReload after change with "/reloadui"\nDisclamer: Settings changed outside "LibAddonMenu" does not show as updated in the "LibAddonMenu"',
        funcGet = function()
            return LibAddonMenu2 and self.base.Saved.UseLAMMenu
        end,
        disabledFunc = function()
            return not LibAddonMenu2
        end,
        funcSet = function(_, newValue)
            self.base.Saved.UseLAMMenu = LibAddonMenu2 and newValue
            self.base.Global.SettingsList:RefreshData()
        end
    })
    self:AppendRow_Button(typeSelection, {
        name = "Reset settings",
        buttonName = "Reset",
        funcSet = function()
            self.base.ResetAccountSettings()
            self.base.SetAndUpdateAccountSettings()
            self.base.InitializeWithSavedData()
            self.base.RestoreFrames()
            self.base.RestoreCombineLabels()
            self.base.Global.SettingsList:RefreshData()
        end
    })
    self:AppendRow_Title(typeSelection, {name = "Position and size"})
    self:AppendRow_Divider(typeSelection, {})
    self:AppendRow_Checkbox(typeSelection, {
        name = "Unlock movement of bar",
        tooltipText = "When ON the bar will show the X,Y position of the top left corner, and is draggable",
        funcGet = function()
            return self.base.Global.IsMoveEnabled
        end,
        funcSet = function(_, newValue)
            self.base.Global.IsMoveEnabled = newValue
            self.base.RestoreFrames()
        end
    })
    self:AppendRow_Slider(typeSelection, {
        name = "Choose snap size when moving",
        tooltipText = "Choose snap size when moving",
        funcGet = function()
            return self.base.Saved.SnapSize
        end,
        funcSet = function(sliderControl, newValue)
            local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel")
            if valueLabel then
                valueLabel:SetText(newValue)
            end
            self.base.Saved.SnapSize = newValue
            self.base.RestoreFrames()
        end,
        minValue = 1,
        maxValue = 10,
        valueStep = 1,
        default = self.base.Default.SnapSize,
        valueFormat = "%.2f",
        showValue = true
    })
    self:AppendRow_Slider(typeSelection, {
        name = "Choose max bar depth",
        tooltipText = "Choose max bar depth\n(number of inverse rows/columns)",
        funcGet = function()
            return self.base.Saved.BarDepth
        end,
        funcSet = function(sliderControl, newValue)
            local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel")
            if valueLabel then
                valueLabel:SetText(newValue)
            end
            self.base.Saved.BarDepth = newValue
            self.base.RestoreFrames()
        end,
        minValue = 0,
        maxValue = base.Global.HighestUnlocked,
        valueStep = 1,
        default = self.base.Default.BarDepth,
        valueFormat = "%.2f",
        showValue = true
    })
    self:AppendRow_Slider(typeSelection, {
        name = "Choose max bar height",
        tooltipText = "Choose max bar height\n(number of inverse rows/columns)",
        funcGet = function()
            return self.base.Saved.BarWidth
        end,
        funcSet = function(sliderControl, newValue)
            local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel")
            if valueLabel then
                valueLabel:SetText(newValue)
            end
            self.base.Saved.BarWidth = newValue
            self.base.RestoreFrames()
        end,
        minValue = 0,
        maxValue = base.Global.HighestUnlocked,
        valueStep = 1,
        default = self.base.Default.BarWidth,
        valueFormat = "%.2f",
        showValue = true
    })
    self:AppendRow_Checkbox(typeSelection, {
        name = "Show binding's on bar",
        tooltipText = "When ON the binding's will be shown on the bar",
        funcGet = function()
            return self.base.Saved.ShowBinding
        end,
        funcSet = function(_, newValue)
            self.base.Saved.ShowBinding = newValue
            self.base.RestoreFrames()
        end
    })
    self:AppendRow_Slider(typeSelection, {
        name = "Choose button size",
        tooltipText = "Choose button size",
        funcGet = function()
            return self.base.Saved.ButtonXY
        end,
        funcSet = function(sliderControl, newValue)
            local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel")
            if valueLabel then
                valueLabel:SetText(newValue)
            end
            self.base.Saved.ButtonXY = newValue
            self.base.RestoreFrames()
        end,
        minValue = 1,
        maxValue = 100,
        valueStep = 1,
        default = ZO_GAMEPAD_ACTION_BUTTON_SIZE,
        valueFormat = "%.2f",
        showValue = true
    })

    local whenOnTheBar = "When ON the bar will show the bar "
    self:AppendRow_Title(typeSelection, {name = "Visibility"})
    self:AppendRow_Divider(typeSelection, {})
    self:AppendRow_Checkbox(typeSelection, {
        name = "Show bar on main view/hud",
        tooltipText = string.format("%s on main view/hud", whenOnTheBar),
        funcGet = function()
            return self.base.Saved.ShowBarOnHud
        end,
        funcSet = function(_, newValue)
            self.base.Saved.ShowBarOnHud = newValue
            self.base.UpdateFragments("ShowBarOnHud")
        end
    })
    self:AppendRow_Checkbox(typeSelection, {
        name = "Show bar on the main view when an overlay is activated/hudui",
        tooltipText = string.format("%s on the main view when an overlay is activated/hudui", whenOnTheBar),
        funcGet = function()
            return self.base.Saved.ShowBarOnHudUI
        end,
        funcSet = function(_, newValue)
            self.base.Saved.ShowBarOnHudUI = newValue
            self.base.UpdateFragments("ShowBarOnHudUI")
        end
    })
    self:AppendRow_Checkbox(typeSelection, {
        name = "Show bar in menu",
        tooltipText = string.format("%s in menu", whenOnTheBar),
        funcGet = function()
            return self.base.Saved.ShowBarInMenu
        end,
        funcSet = function(_, newValue)
            self.base.Saved.ShowBarInMenu = newValue
            self.base.UpdateFragments("ShowBarInMenu")
        end
    })
    self:AppendRow_Checkbox(typeSelection, {
        name = "Show bar in the inventory",
        tooltipText = string.format("%s in the inventory", whenOnTheBar),
        funcGet = function()
            return self.base.Saved.ShowBarInInventory
        end,
        funcSet = function(_, newValue)
            self.base.Saved.ShowBarInInventory = newValue
            self.base.UpdateFragments("ShowBarInInventory")
        end
    })
    self:AppendRow_Checkbox(typeSelection, {
        name = "Show bar in interactions",
        tooltipText = string.format("%s in interactions", whenOnTheBar),
        funcGet = function()
            return self.base.Saved.ShowBarInInteract
        end,
        funcSet = function(_, newValue)
            self.base.Saved.ShowBarInInteract = newValue
            self.base.UpdateFragments("ShowBarInInteract")
        end
    })
    self:AppendRow_Checkbox(typeSelection, {
        name = "Show bar at a bank",
        tooltipText = string.format("%s at a bank", whenOnTheBar),
        funcGet = function()
            return self.base.Saved.ShowBarInBank
        end,
        funcSet = function(_, newValue)
            self.base.Saved.ShowBarInBank = newValue
            self.base.UpdateFragments("ShowBarInBank")
        end
    })
    self:AppendRow_Checkbox(typeSelection, {
        name = "Show bar at a fence",
        tooltipText = string.format("%s at a fence", whenOnTheBar),
        funcGet = function()
            return self.base.Saved.ShowBarInFence
        end,
        funcSet = function(_, newValue)
            self.base.Saved.ShowBarInFence = newValue
            self.base.UpdateFragments("ShowBarInFence")
        end
    })
    self:AppendRow_Checkbox(typeSelection, {
        name = "Show bar at a store",
        tooltipText = string.format("%s at a store", whenOnTheBar),
        funcGet = function()
            return self.base.Saved.ShowBarInStore
        end,
        funcSet = function(_, newValue)
            self.base.Saved.ShowBarInStore = newValue
            self.base.UpdateFragments("ShowBarInStore")
        end
    })

    self:AppendRow_Title(typeSelection, {name = "Active and activation"})
    self:AppendRow_Divider(typeSelection, {})
    self:AppendRow_Checkbox(typeSelection, {
        name = "Show active and activation",
        tooltipText = "When ON the active collectibles will be highlighted, and activation animation will display",
        funcGet = function()
            return self.base.Saved.IsActiveActivationEnabled
        end,
        funcSet = function(_, newValue)
            self.base.Saved.IsActiveActivationEnabled = newValue
            self.base.RestoreFrames()
        end
    })

    self:AppendRow_Title(typeSelection, {name = "Audio"})
    self:AppendRow_Divider(typeSelection, {})
    self:AppendRow_Checkbox(typeSelection, {
        name = "Play hover audio",
        tooltipText = "When ON hover events on the bar, will play audio",
        funcGet = function()
            return self.base.Saved.IsAudioEnabled
        end,
        funcSet = function(_, newValue)
            self.base.Saved.IsAudioEnabled = newValue
            self.base.RestoreFrames()
        end
    })
end

function base.AppendMasterListTypeCollectionTypes(self, typeSelection)
    self:AppendRow_Title(typeSelection, {name = "Collection types"})
    self:AppendRow_Divider(typeSelection, {})

    for _, _type in ipairs(self.base.TypeOrdered or {}) do
        self:AppendRow_Checkbox_CogButton(typeSelection, {
            cId = _type.Id,
            name = string.format("Show %s", _type.Name),
            tooltipText = string.format("When ON the collection type: %s will enabled\nSelect by pressing settings-symbol/cog", _type.Name),
            funcGet = function()
                return _type.Saved.Enabled
            end,
            disabledFunc = function()
                return _type.Disabled
            end,
            funcSet = function(_, newValue)
                _type.Saved.Enabled = newValue
                if newValue then
                    self.base.InitializeType(_type)
                else
                    self.base.RemoveLabel(_type)
                    self.base.RemoveFrame(_type)
                    if self._type == _type then
                        self._type = nil
                        self.base.UpdateSettingsType(true, self._type)
                    end
                end
                if _type.Saved.IsCombined then
                    self.base.RestoreCombineLabels()
                end
                self.base.Global.SettingsList:RefreshData()
            end,
            funcCog = function(_)
                self._type = _type
                self.base.UpdateSettingsType(true, self._type)
                self.base.Global.SettingsList:RefreshData()
            end
        })
    end
end

function base.AppendMasterListTypeCombined(self, typeSelection)
    self:AppendRow_Title(typeSelection, {name = "Display names and labels"})
    self:AppendRow_Divider(typeSelection, {})
    self:AppendRow_Slider(typeSelection, {
        name = "Display name offset horizontal",
        tooltipText = "Display name offset horizontal\n(X)",
        funcGet = function()
            return self.base.Saved.Combine.Label.OffsetX
        end,
        funcSet = function(sliderControl, newValue)
            local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel")
            if valueLabel then
                valueLabel:SetText(newValue)
            end
            self.base.Saved.Combine.Label.OffsetX = newValue
            self.base.RestoreCombineLabels()
        end,
        minValue = -500,
        maxValue = 500,
        valueStep = 1,
        default = self.base.Default.Combine.Label.OffsetX,
        valueFormat = "%.2f",
        showValue = true
    })
    self:AppendRow_Slider(typeSelection, {
        name = "Display name offset vertical",
        tooltipText = "Display name offset vertical\n(Y)",
        funcGet = function()
            return self.base.Saved.Combine.Label.OffsetY
        end,
        funcSet = function(sliderControl, newValue)
            local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel")
            if valueLabel then
                valueLabel:SetText(newValue)
            end
            self.base.Saved.Combine.Label.OffsetY = newValue
            self.base.RestoreCombineLabels()
        end,
        minValue = -500,
        maxValue = 500,
        valueStep = 1,
        default = self.base.Default.Combine.Label.OffsetY,
        valueFormat = "%.2f",
        showValue = true
    })
    self:AppendRow_Dropdown(typeSelection, {
        name = "Display name anchor position on button",
        tooltipText = "Select display name anchor position on the button",
        funcGet = function()
            return self.base.GetLocationText(self.base.Saved.Combine.Label.PositionTarget)
        end,
        choices = self.base.Global.ChoiceCornerLocations,
        funcSet = function(_, newValue)
            self.base.Saved.Combine.Label.PositionTarget = self.base.GetLocationValue(newValue)
            self.base.Saved.Combine.AnchorXY = self.base.GetLocationValue(newValue)
            self.base.RestoreCombineLabels()
        end
    })
    self:AppendRow_Dropdown(typeSelection, {
        name = "Display name anchor position on label",
        tooltipText = "Select display name anchor position on the label",
        funcGet = function()
            return self.base.GetLocationText(self.base.Saved.Combine.Label.Position)
        end,
        choices = self.base.Global.ChoiceLocations,
        funcSet = function(_, newValue)
            self.base.Saved.Combine.Label.Position = self.base.GetLocationValue(newValue)
            self.base.RestoreCombineLabels()
        end
    })
    self:AppendRow_Dropdown(typeSelection, {
        name = "Bar anchor location",
        tooltipText = "Select Bar anchor location, used when bar is collapsed",
        funcGet = function()
            return self.base.GetLocationText(self.base.Saved.Combine.AnchorXY)
        end,
        choices = self.base.Global.ChoiceCornerLocations,
        funcSet = function(_, newValue)
            self.base.Saved.Combine.AnchorXY = self.base.GetLocationValue(newValue)
            self.base.RestoreCombineLabels()
        end
    })
    self:AppendRow_Title(typeSelection, {name = "Position and size"})
    self:AppendRow_Divider(typeSelection, {})
    self:AppendRow_Slider(typeSelection, {
        name = "Choose default bar depth",
        tooltipText = "Choose default bar depth\n(number of rows/columns)",
        funcGet = function()
            return self.base.Saved.Combine.BarDepth
        end,
        funcSet = function(sliderControl, newValue)
            local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel")
            if valueLabel then
                valueLabel:SetText(newValue)
            end
            self.base.Saved.Combine.BarDepth = newValue
            self.base.RestoreFrames()
        end,
        minValue = 0,
        maxValue = self.base.Global.HighestUnlocked,
        valueStep = 1,
        default = self.base.Default.BarDepth,
        valueFormat = "%.2f",
        showValue = true
    })
    self:AppendRow_Slider(typeSelection, {
        name = "Choose max bar height",
        tooltipText = "Choose max bar height\n(number of inverse rows/columns)",
        funcGet = function()
            return self.base.Saved.Combine.BarWidth
        end,
        funcSet = function(sliderControl, newValue)
            local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel")
            if valueLabel then
                valueLabel:SetText(newValue)
            end
            self.base.Saved.Combine.BarWidth = newValue
            self.base.RestoreFrames()
        end,
        minValue = 0,
        maxValue = self.base.Global.HighestUnlocked,
        valueStep = 1,
        default = self.base.Default.BarWidth,
        valueFormat = "%.2f",
        showValue = true
    })
end

function base.AppendMasterListTypeSelection(self, typeSelection)
    self:AppendRow_Title(typeSelection, {name = "Selection"})
    self:AppendRow_Divider(typeSelection, {})
    self:AppendRow_Checkbox(typeSelection, {
        name = string.format("Show disabled %s", self._type.Name),
        tooltipText = string.format("When ON disabled elements will be shown for %s", self._type.Name),
        funcGet = function()
            return self._type.Saved.MenuShowDisabled
        end,
        funcSet = function(_, newValue)
            self._type.Saved.MenuShowDisabled = newValue
            self.base.CreateCollection(self._type)
            self.base.Global.SettingsList:RefreshData()
        end
    })
    self:AppendRow_Divider(typeSelection, {})
    self:AppendRow_Checkbox(typeSelection, {
        name = string.format("Select all %s", self._type.Name),
        tooltipText = string.format("When pressed all %s will either be selected or deselected", self._type.Name),
        funcGet = function()
            return self.base.IsAllSelected(self._type)
        end,
        funcSet = function(_, newValue)
            self.base.SelectAll(self._type, newValue)
            self.base.RestoreFrame(self._type)
            self.base.RestoreCombineLabels()
            self.base.Global.SettingsList:RefreshData()
        end
    })
    self:AppendRow_Divider(typeSelection, {})
    for _, collection in ipairs(self._type.OrderedCollection or {}) do
        if self._type.Saved.MenuShowDisabled and collection.Disabled or not collection.Disabled then
            self:AppendRow_Checkbox(typeSelection, {
                cId = collection.Id,
                name = string.format("Show %s", collection.Name),
                tooltipText = collection.Tooltip,
                funcGet = function()
                    return self._type.Saved.Selected[collection.Id]
                end,
                disabledFunc = function()
                    return collection.Disabled
                end,
                funcSet = function(checkBoxControl, newValue)
                    local control = checkBoxControl:GetParent()
                    if not (control.data.disabledFunc and control.data.disabledFunc()) then
                        if newValue == true then
                            self._type.Saved.Selected[control.data.cId] = newValue
                        else
                            self._type.Saved.Selected[control.data.cId] = nil
                        end
                        self.base.RestoreFrame(self._type)
                        self.base.RestoreCombineLabels()
                        self.base.Global.SettingsList:RefreshData()
                    end
                end

            })
        end
    end
end

function base.AppendMasterListTypeCollection(self, typeSelection)
    local disabledWhenTooltipIsHidden = "Disabled when tooltip is not shown"
    local disabledWhenLabelIsHidden = "Disabled when label is not shown"
    local disabledWhenCombined = "Disabled when Collection is included in combine bar"

    self:AppendRow_Title(typeSelection, {name = "Tooltip"})
    self:AppendRow_Divider(typeSelection, {})
    self:AppendRow_Checkbox(typeSelection, {
        name = "Show tooltip",
        tooltipText = "When ON tooltips will be shown, when hovering buttons on the bar",
        funcGet = function()
            return self._type.Saved.Tooltip.Show
        end,
        funcSet = function(_, newValue)
            self._type.Saved.Tooltip.Show = newValue
            self.base.SetupButtons(self._type)
            self.base.Global.SettingsList:RefreshData()
        end
    })
    self:AppendRow_Dropdown(typeSelection, {
        name = "Show tooltip anchor position",
        tooltipText = string.format("Select tooltip anchor position\n%s", disabledWhenTooltipIsHidden),
        choices = self.base.Global.ChoiceSideLocations,
        disabledFunc = function()
            return not self._type.Saved.Tooltip.Show
        end,
        funcGet = function()
            return self.base.GetLocationText(self._type.Saved.Tooltip.Position)
        end,
        funcSet = function(_, newValue)
            self._type.Saved.Tooltip.Position = self.base.GetLocationValue(newValue)
            self.base.SetupButtons(self._type)
        end
    })

    self:AppendRow_Title(typeSelection, {name = "Display name and label"})
    self:AppendRow_Divider(typeSelection, {})
    self:AppendRow_Checkbox(typeSelection, {
        name = "Include in combine bar",
        tooltipText = "When ON will be attached to a combined bar",
        funcGet = function()
            return self._type.Saved.IsCombined
        end,
        funcSet = function(_, newValue)
            self._type.Saved.IsCombined = newValue
            self.base.RestoreFrame(self._type)
            self.base.RestoreCombineLabels()
            self.base.Global.SettingsList:RefreshData()
        end
    })
    self:AppendRow_Divider(typeSelection, {})
    self:AppendRow_Checkbox(typeSelection, {
        name = "Enable hide/toggle visibility of the label",
        tooltipText = string.format("When enabled a +/- at the end of the label indicates if the label is hidden or shown\n%s", disabledWhenCombined),
        disabledFunc = function()
            return self._type.Saved.IsCombined
        end,
        funcGet = function()
            return self._type.Saved.IsCombined or self._type.Saved.HideAllEnabled
        end,
        funcSet = function(_, newValue)
            if (not newValue) then
                self._type.Saved.HideAll = newValue
                self.base.RestoreFrame(self._type)
            end
            self._type.Saved.HideAllEnabled = newValue
            self._type.Saved.LabelShow = true
            self.base.SetupLabel(self._type)
            self.base.RestoreLabel(self._type)
            self.base.Global.SettingsList:RefreshData()
        end
    })
    self:AppendRow_Checkbox(typeSelection, {
        name = "Show label",
        tooltipText = string.format("%s or hide/toggle visibility is enabled", disabledWhenCombined),
        disabledFunc = function()
            return self._type.Saved.HideAllEnabled or self._type.Saved.IsCombined
        end,
        funcGet = function()
            return self._type.Saved.LabelShow or self._type.Saved.IsCombined
        end,
        funcSet = function(_, newValue)
            self._type.Saved.LabelShow = newValue
            self.base.SetupLabel(self._type)
            self.base.RestoreLabel(self._type)
            self.base.Global.SettingsList:RefreshData()
        end
    })
    self:AppendRow_EditBox(typeSelection, {
        name = "Display name",
        tooltipText = string.format("Change displayname used on the label\n%s", disabledWhenLabelIsHidden),
        disabledFunc = function()
            return not self._type.Saved.LabelShow
        end,
        funcGet = function()
            return tostring(self._type.Saved.Display)
        end,
        funcSet = function(control)
            self._type.Saved.Display = control:GetText() or ""
            self.base.RestoreFrame(self._type)
            self.base.RestoreCombineLabels()
        end
    })
    self:AppendRow_Dropdown(typeSelection, {
        name = "Display name font",
        tooltipText = string.format("Change display name font\n%s", disabledWhenLabelIsHidden),
        disabledFunc = function()
            return not self._type.Saved.LabelShow
        end,
        choices = self.base.Global.AvailableFonts,
        funcGet = function()
            return self._type.Saved.Label.Font
        end,
        funcSet = function(_, newValue)
            self._type.Saved.Label.Font = newValue
            self.base.RestoreFrame(self._type)
            self.base.RestoreCombineLabels()
        end
    })
    self:AppendRow_Slider(typeSelection, {
        name = "Display name height",
        tooltipText = string.format("Change display name height\n%s", disabledWhenLabelIsHidden),
        disabledFunc = function()
            return not self._type.Saved.LabelShow
        end,
        funcGet = function()
            return self._type.Saved.Label.Height
        end,
        funcSet = function(sliderControl, newValue)
            local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel")
            if valueLabel then
                valueLabel:SetText(newValue)
            end
            self._type.Saved.Label.Height = newValue
            self.base.RestoreFrame(self._type)
            self.base.RestoreCombineLabels()
        end,
        minValue = 0,
        maxValue = 100,
        valueStep = 1,
        default = self.base.Default[self._type.Name].Label.Height,
        valueFormat = "%.2f",
        showValue = true
    })
    self:AppendRow_Slider(typeSelection, {
        name = "Display name width",
        tooltipText = string.format("Change display name width\n%s", disabledWhenLabelIsHidden),
        disabledFunc = function()
            return not self._type.Saved.LabelShow
        end,
        funcGet = function()
            return self._type.Saved.Label.Width
        end,
        funcSet = function(sliderControl, newValue)
            local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel")
            if valueLabel then
                valueLabel:SetText(newValue)
            end
            self._type.Saved.Label.Width = newValue
            self.base.RestoreFrame(self._type)
            self.base.RestoreCombineLabels()
        end,
        minValue = 0,
        maxValue = 500,
        valueStep = 1,
        default = self.base.Default[self._type.Name].Label.Width,
        valueFormat = "%.2f",
        showValue = true
    })
    self:AppendRow_Slider(typeSelection, {
        name = "Display name offset horizontal",
        tooltipText = string.format("Display name offset horizontal\n(X)\n%s", disabledWhenLabelIsHidden),
        disabledFunc = function()
            return not self._type.Saved.LabelShow
        end,
        funcGet = function()
            return self._type.Saved.Label.OffsetX
        end,
        funcSet = function(sliderControl, newValue)
            local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel")
            if valueLabel then
                valueLabel:SetText(newValue)
            end
            self._type.Saved.Label.OffsetX = newValue
            self.base.RestoreFrame(self._type)
            self.base.RestoreCombineLabels()
        end,
        minValue = -500,
        maxValue = 500,
        valueStep = 1,
        default = self.base.Default[self._type.Name].Label.OffsetX,
        valueFormat = "%.2f",
        showValue = true
    })
    self:AppendRow_Slider(typeSelection, {
        name = "Display name offset vertical",
        tooltipText = string.format("Display name offset vertical\n(y)\n%s", disabledWhenLabelIsHidden),
        disabledFunc = function()
            return not self._type.Saved.LabelShow
        end,
        funcGet = function()
            return self._type.Saved.Label.OffsetY
        end,
        funcSet = function(sliderControl, newValue)
            local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel")
            if valueLabel then
                valueLabel:SetText(newValue)
            end
            self._type.Saved.Label.OffsetY = newValue
            self.base.RestoreFrame(self._type)
            self.base.RestoreCombineLabels()
        end,
        minValue = -500,
        maxValue = 500,
        valueStep = 1,
        default = self.base.Default[self._type.Name].Label.OffsetY,
        valueFormat = "%.2f",
        showValue = true
    })
    self:AppendRow_Dropdown(typeSelection, {
        name = "Display name anchor position on button",
        tooltipText = string.format("Select display name anchor position on the button\n%s\n or Collection is included in combine bar", disabledWhenLabelIsHidden),
        disabledFunc = function()
            return not self._type.Saved.LabelShow or self._type.Saved.IsCombined
        end,
        funcGet = function()
            if self._type.Saved.IsCombined then
                return self.base.GetLocationText(self.base.Saved.Combine.Label.PositionTarget)
            else
                return self.base.GetLocationText(self._type.Saved.Label.PositionTarget)
            end
        end,
        choices = self.base.Global.ChoiceLocations,
        funcSet = function(_, newValue)
            self._type.Saved.Label.PositionTarget = self.base.GetLocationValue(newValue)
            self._type.Saved.AnchorXY = self.base.GetLocationValue(newValue)
            self.base.RestoreFrame(self._type)
            self.base.RestoreCombineLabels()
        end
    })
    self:AppendRow_Dropdown(typeSelection, {
        name = "Display name anchor position on label",
        tooltipText = string.format("Select display name anchor position on the label\n%s\n or Collection is included in combine bar", disabledWhenLabelIsHidden),
        disabledFunc = function()
            return not self._type.Saved.LabelShow or self._type.Saved.IsCombined
        end,
        funcGet = function()
            if self._type.Saved.IsCombined then
                return self.base.GetLocationText(self.base.Saved.Combine.Label.Position)
            else
                return self.base.GetLocationText(self._type.Saved.Label.Position)
            end
        end,
        choices = self.base.Global.ChoiceLocations,
        funcSet = function(_, newValue)
            self._type.Saved.Label.Position = self.base.GetLocationValue(newValue)
            self.base.RestoreFrame(self._type)
            self.base.RestoreCombineLabels()
        end
    })
    self:AppendRow_Dropdown(typeSelection, {
        name = "Bar anchor location",
        tooltipText = string.format("Select Bar anchor location, used when bar is collapsed\n%s", disabledWhenCombined),
        disabledFunc = function()
            return self._type.Saved.IsCombined
        end,
        funcGet = function()
            if self._type.Saved.IsCombined then
                return self.base.GetLocationText(self.base.Saved.Combine.AnchorXY)
            else
                return self.base.GetLocationText(self._type.Saved.AnchorXY)
            end
        end,
        choices = self.base.Global.ChoiceCornerLocations,
        funcSet = function(_, newValue)
            self._type.Saved.AnchorXY = self.base.GetLocationValue(newValue)
            self.base.RestoreFrame(self._type)
            self.base.RestoreCombineLabels()
        end
    })

    self:AppendRow_Title(typeSelection, {name = "Position and size"})
    self:AppendRow_Divider(typeSelection, {})
    self:AppendRow_Slider(typeSelection, {
        name = "Choose bar depth",
        tooltipText = string.format("Choose bar depth\n(number of rows/columns)\n%s", disabledWhenCombined),
        disabledFunc = function()
            return self._type.Saved.IsCombined
        end,
        funcGet = function()
            return self._type.Saved.BarDepth
        end,
        funcSet = function(sliderControl, newValue)
            local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel")
            if valueLabel then
                valueLabel:SetText(newValue)
            end
            self._type.Saved.BarDepth = newValue
            self.base.RestoreFrame(self._type)
            self.base.RestoreCombineLabels()
        end,
        minValue = 0,
        maxValue = self._type.Unlocked,
        valueStep = 1,
        default = self.base.Default[self._type.Name].BarDepth,
        valueFormat = "%.2f",
        showValue = true
    })
    self:AppendRow_Slider(typeSelection, {
        name = "Choose max bar height",
        tooltipText = string.format("Choose bar height\n(number of inverse rows/columns)\n%s", disabledWhenCombined),
        disabledFunc = function()
            return self._type.Saved.IsCombined
        end,
        funcGet = function()
            return self._type.Saved.BarWidth
        end,
        funcSet = function(sliderControl, newValue)
            local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel")
            if valueLabel then
                valueLabel:SetText(newValue)
            end
            self._type.Saved.BarWidth = newValue
            self.base.RestoreFrame(self._type)
            self.base.RestoreCombineLabels()
        end,
        minValue = 0,
        maxValue = self._type.Unlocked,
        valueStep = 1,
        default = self.base.Default[self._type.Name].BarWidth,
        showValue = true
    })
    self:AppendRow_Checkbox(typeSelection, {
        name = "Bar orientation horizontal",
        tooltipText = string.format("Bar orientation horizontal\n%s", disabledWhenCombined),
        disabledFunc = function()
            return self._type.Saved.IsCombined
        end,
        funcGet = function()
            return self._type.Saved.Horizontal
        end,
        funcSet = function(_, newValue)
            self._type.Saved.Horizontal = newValue
            self.base.RestoreFrame(self._type)
            self.base.RestoreCombineLabels()
        end
    })
end

function base.AppendMasterListTypeNoCollectionType(self, typeSelection)
    self:AppendRow_Title(typeSelection, {name = "Select a collection type"})
    self:AppendRow_Divider(typeSelection, {})
end