Version 1.0.5 (08-09-2019)

Jarth [09-08-19 - 10:59]
Version 1.0.5 (08-09-2019)
- Fixed issue hiding labels, when they are not combined, and the settings tab is not enabled
- Fixed issue with when moving the frame, and has the lable anchor set other than a corner
-- Setting: "Bar anchor location" is removed, it now anchers to the "Display name anchor position on button".
-- Anchors can now be set to corners/sides/center.
Filename
CBs_Buttons.lua
CBs_Constants.lua
CBs_Helpers.lua
CBs_Labels.lua
CBs_Menu.lua
CBs_MoveFrame.lua
CBs_Settings_Data.lua
Changelog
CollectionBars.txt
diff --git a/CBs_Buttons.lua b/CBs_Buttons.lua
index a45009f..f324021 100644
--- a/CBs_Buttons.lua
+++ b/CBs_Buttons.lua
@@ -78,7 +78,7 @@ function base.SetupButtons(_type)
         end
     end

-    local isHidden = _type.IsEmpty and not base.Global.EnableSettings or not _type.Saved.Enabled
+    local isHidden = (_type.IsEmpty or not _type.Saved.LabelShow) and not base.Global.EnableSettings or not _type.Saved.Enabled
     if _type.Frame then
         _type.Frame:SetHidden(isHidden)
     end
diff --git a/CBs_Constants.lua b/CBs_Constants.lua
index 0a9f9a9..008316e 100644
--- a/CBs_Constants.lua
+++ b/CBs_Constants.lua
@@ -12,7 +12,7 @@ CollectionBars = {
         DisplayName = "Collection Bars",
         Abbreviation = "CBs",
         Version = 1.0,
-        MinorVersion = 0.4,
+        MinorVersion = 0.5,
         Command = "/cb_menu",
         SettingsSlash = "/cb",
         Author = "Jarth",
@@ -37,7 +37,7 @@ CollectionBars = {
         Bindings = {[1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0, [10] = 0},
         IsAudioEnabled = true,
         IsActiveActivationEnabled = true,
-        Combine = {BarDepth = 0, BarWidth = 0, X = CENTER, Y = CENTER, AnchorXY = TOPLEFT, Display = "CombineBar", Label = {OffsetX = 0, OffsetY = 0, Position = BOTTOMLEFT, PositionTarget = TOPLEFT}},
+        Combine = {BarDepth = 0, BarWidth = 0, X = CENTER, Y = CENTER, Display = "CombineBar", Label = {OffsetX = 0, OffsetY = 0, Position = BOTTOMLEFT, PositionTarget = TOPLEFT}},
         UseLAMMenu = true
     },
     Global = {
@@ -50,8 +50,6 @@ CollectionBars = {
         SettingsFilters = {["CollectionTypes"] = "Collection Types", ["Selection"] = "Collectibles", ["Collection"] = "Collection bar", ["General"] = "General", ["Combined"] = "Combined bar"},
         Combine = {Name = "Combine", EventTS = nil, MoveFrame = nil, Frame = nil, _type = nil, HideAll = nil, Fragment = nil, IsEmpty = false},
         ChoiceLocations = {"top", "topright", "right", "bottomright", "bottom", "bottomleft", "left", "topleft", "center"},
-        ChoiceCornerLocations = {"topleft", "topright", "bottomright", "bottomleft"},
-        ChoiceSideLocations = {"top", "right", "bottom", "left"},
         AvailableFonts = {"ZoFontGameSmall", "ZoFontGameLarge", "ZoFontGameLargeBold", "ZoFontGameLargeBoldShadow", "ZoFontHeader", "ZoFontHeader2", "ZoFontHeader3", "ZoFontHeader4"},
         ScenePairs = {
             ShowBarOnHud = HUD_SCENE,
@@ -133,7 +131,6 @@ function CollectionBars.GenerateCollectionTypes()
                 BarWidth = 0,
                 X = CENTER,
                 Y = CENTER,
-                AnchorXY = TOPLEFT,
                 Display = setupElement.Display,
                 LabelShow = true,
                 Label = {OffsetX = 0, OffsetY = 0, Height = 19, Width = 75, Font = "ZoFontGameSmall", Position = BOTTOMLEFT, PositionTarget = TOPLEFT},
diff --git a/CBs_Helpers.lua b/CBs_Helpers.lua
index 09d2595..6d89c5e 100644
--- a/CBs_Helpers.lua
+++ b/CBs_Helpers.lua
@@ -66,12 +66,12 @@ function base.RestorePosition(_type)
     _type.Frame:ClearAnchors()
     local combineFrame = base.Global.Combine.Frame
     if not _type.Saved.IsCombined or not combineFrame then
-        _type.Frame:SetAnchor(_type.Saved.AnchorXY, GuiRoot, TOPLEFT, _type.Saved.X, _type.Saved.Y)
+        _type.Frame:SetAnchor(_type.Saved.Label.PositionTarget, GuiRoot, TOPLEFT, _type.Saved.X, _type.Saved.Y)
     elseif _type.Saved.IsCombined then
         if not _type.Saved.HideAll then
             _type.Frame:SetAnchorFill(combineFrame)
         else
-            _type.Frame:SetAnchor(_type.Saved.AnchorXY, combineFrame, _type.Saved.AnchorXY, 0, 0)
+            _type.Frame:SetAnchor(TOPLEFT, combineFrame, TOPLEFT, 0, 0)
         end
     end
 end
diff --git a/CBs_Labels.lua b/CBs_Labels.lua
index 2b1438e..cfcbeb7 100644
--- a/CBs_Labels.lua
+++ b/CBs_Labels.lua
@@ -51,7 +51,7 @@ function base.RestoreLabel(_type)
         if not _type.Saved.IsCombined then
             frameLabel:SetAnchor(label.Position, _type.Frame, label.PositionTarget, label.OffsetX, label.OffsetY)
         end
-        frameLabel:SetHidden(not _type.Saved.IsCombined and not _type.Saved.LabelShow)
+        frameLabel:SetHidden(not _type.Saved.LabelShow and not _type.Saved.IsCombined and not base.Global.EnableSettings)
     end

     local frameLabelButton = _type.FrameLabelButton
@@ -88,8 +88,6 @@ function base.RestoreCombineLabels()
     local combineLabel = base.Saved.Combine.Label
     local width = 0
     local height = 0
-    local positionTarget = combineLabel.PositionTarget
-    local position = combineLabel.Position
     for _, _type in pairs(base.TypeOrdered) do
         if _type.Saved.Enabled and _type.Saved.IsCombined and _type.FrameLabel then
             if (not _type.IsEmpty or base.Global.EnableSettings) then
@@ -115,6 +113,6 @@ function base.RestoreCombineLabels()
         frame:ClearAnchors()
         frame:SetWidth(width)
         frame:SetHeight(height)
-        frame:SetAnchor(position, base.Global.Combine.Frame, positionTarget, combineLabel.OffsetX, combineLabel.OffsetY)
+        frame:SetAnchor(combineLabel.Position, base.Global.Combine.Frame, combineLabel.PositionTarget, combineLabel.OffsetX, combineLabel.OffsetY)
     end
 end
diff --git a/CBs_Menu.lua b/CBs_Menu.lua
index 3f5c5b0..fc83e8b 100644
--- a/CBs_Menu.lua
+++ b/CBs_Menu.lua
@@ -33,7 +33,9 @@ function base.CreateSettingsWindow()
     local disabledWhenCombined = "Disabled when Collection is included in combine bar"

     local optionsData = {
-        {type = "header", name = base.Addon.DisplayName .. " Settings"}, {type = "description", text = string.format("Here you can setup %s.\nSlash command: %s\nCollection bars settings: %s", base.Addon.DisplayName, base.Addon.Command, base.Addon.SettingsSlash)}, {
+        {type = "header", name = base.Addon.DisplayName .. " Settings"},
+        {type = "description", text = string.format("Here you can setup %s.\nSlash command: %s\nCollection bars settings: %s", base.Addon.DisplayName, base.Addon.Command, base.Addon.SettingsSlash)},
+        {
             type = "checkbox",
             name = "Use account settings",
             tooltip = "When ON the account settings will be used. When OFF character settings will be used",
@@ -303,14 +305,13 @@ function base.CreateSettingsWindow()
                     type = "dropdown",
                     name = "Display name anchor position on button",
                     tooltip = "Select display name anchor position on the button",
-                    choices = base.Global.ChoiceCornerLocations,
+                    choices = base.Global.ChoiceLocations,
                     default = base.Default.Combine.Label.PositionTarget,
                     getFunc = function()
                         return base.GetLocationText(base.Saved.Combine.Label.PositionTarget)
                     end,
                     setFunc = function(value)
                         base.Saved.Combine.Label.PositionTarget = base.GetLocationValue(value)
-                        base.Saved.Combine.AnchorXY = base.GetLocationValue(value)
                         base.RestoreCombineLabels()
                     end,
                     width = "half"
@@ -329,20 +330,10 @@ function base.CreateSettingsWindow()
                     end,
                     width = "half"
                 }, {
-                    type = "dropdown",
-                    name = "Bar anchor location",
-                    tooltip = "Select Bar anchor location, used when bar is collapsed",
-                    choices = base.Global.ChoiceCornerLocations,
-                    default = base.Default.Combine.AnchorXY,
-                    getFunc = function()
-                        return base.GetLocationText(base.Saved.Combine.AnchorXY)
-                    end,
-                    setFunc = function(value)
-                        base.Saved.Combine.AnchorXY = base.GetLocationValue(value)
-                        base.RestoreCombineLabels()
-                    end,
-                    width = "half"
-                }, {type = "divider", width = "full"}, {type = "description", text = "Here you can setup position and size"}, {
+                    type = "divider", width = "full"
+                }, {
+                    type = "description", text = "Here you can setup position and size"
+                }, {
                     type = "slider",
                     name = "Choose default bar depth (number of rows/columns)",
                     default = base.Default.BarDepth,
@@ -435,7 +426,7 @@ function base.CreateSettingsWindow()
                 type = "dropdown",
                 name = "Show tooltip anchor position",
                 tooltip = "Select tooltip anchor position\n" .. disabledWhenTooltipIsHidden,
-                choices = base.Global.ChoiceSideLocations,
+                choices = base.Global.ChoiceLocations,
                 default = base.Default[typeName].Tooltip.Position,
                 disabled = function()
                     return not _type.Saved.Tooltip.Show
@@ -616,7 +607,6 @@ function base.CreateSettingsWindow()
                 end,
                 setFunc = function(value)
                     _type.Saved.Label.PositionTarget = base.GetLocationValue(value)
-                    _type.Saved.AnchorXY = base.GetLocationValue(value)
                     base.RestoreFrame(_type)
                     base.RestoreCombineLabels()
                 end,
@@ -643,28 +633,6 @@ function base.CreateSettingsWindow()
                     base.RestoreCombineLabels()
                 end,
                 width = "half"
-            }, {
-                type = "dropdown",
-                name = "Bar anchor location",
-                tooltip = "Select Bar anchor location, used when bar is collapsed\n" .. disabledWhenCombined,
-                choices = base.Global.ChoiceCornerLocations,
-                default = base.Default[typeName].AnchorXY,
-                disabled = function()
-                    return _type.Saved.IsCombined
-                end,
-                getFunc = function()
-                    if _type.Saved.IsCombined then
-                        return base.GetLocationText(base.Saved.Combine.AnchorXY)
-                    else
-                        return base.GetLocationText(_type.Saved.AnchorXY)
-                    end
-                end,
-                setFunc = function(value)
-                    _type.Saved.AnchorXY = base.GetLocationValue(value)
-                    base.RestoreFrame(_type)
-                    base.RestoreCombineLabels()
-                end,
-                width = "half"
             }, {type = "divider", width = "full"}, {type = "description", text = "Here you can setup the position and size"}, {
                 type = "slider",
                 name = "Choose bar depth (number of rows/columns)",
diff --git a/CBs_MoveFrame.lua b/CBs_MoveFrame.lua
index 4a5867a..239929f 100644
--- a/CBs_MoveFrame.lua
+++ b/CBs_MoveFrame.lua
@@ -10,16 +10,23 @@ local base = CollectionBars
 -------------------------------------------------------------------------------------------------
 -- FUNCTIONS --
 -------------------------------------------------------------------------------------------------
-function base.GetMoveFrameSnapPosition(frame, anchorXY)
-    local snapSize = frame.Saved.SnapSize
-    local x = frame:GetLeft()
-    local y = frame:GetTop()
-
-    if anchorXY == BOTTOMRIGHT or anchorXY == TOPRIGHT then
-        x = frame:GetRight()
+function base.GetMoveFrameSnapPosition(frame, positionTargetXY, snapSize)
+    local left, top = frame:GetLeft(), frame:GetTop()
+    local width, height = frame:GetWidth(), frame:GetHeight()
+    local x, y = left, top
+
+    -- if positionTargetXY == TOPLEFT or positionTargetXY == TOP or positionTargetXY == TOPRIGHT then y = top
+    if positionTargetXY == LEFT or positionTargetXY == CENTER or positionTargetXY == RIGHT then
+        y = top + height / 2
+    elseif positionTargetXY == BOTTOMLEFT or positionTargetXY == BOTTOM or positionTargetXY == BOTTOMRIGHT then
+        y = top + height
     end
-    if anchorXY == BOTTOMRIGHT or anchorXY == BOTTOMLEFT then
-        y = frame:GetBottom()
+
+    -- if positionTargetXY == TOPLEFT or positionTargetXY == LEFT or positionTargetXY == BOTTOMLEFT then x = left
+    if positionTargetXY == TOP or positionTargetXY == CENTER or positionTargetXY == BOTTOM then
+        x = left + width / 2
+    elseif positionTargetXY == TOPRIGHT or positionTargetXY == RIGHT or positionTargetXY == BOTTOMRIGHT then
+        x = left + width
     end

     return (zo_round(x / snapSize) * snapSize), (zo_round(y / snapSize) * snapSize)
@@ -47,7 +54,7 @@ function base.UpdateMoveFrame(_type)
             frame.MoveFrameOnUpdate(frame)
             frame.MoveFrameUpdateText(frame, false)
             frame:SetHandler("OnUpdate", nil)
-            saved.X, saved.Y = base.GetMoveFrameSnapPosition(frame, saved.AnchorXY)
+            saved.X, saved.Y = base.GetMoveFrameSnapPosition(frame, _type.Saved.Label.PositionTarget, frame.Saved.SnapSize)
         end
     end

@@ -82,16 +89,16 @@ function base.GetOrCreateMoveFrame(targetFrame, _type)
             local labelTextTopLeft = ""

             if (position) then
-                labelTextTopLeft = string.format("%s,%s", frame.TargetFrame:GetLeft(), frame.TargetFrame:GetTop())
+                labelTextTopLeft = string.format("%s,%s", base.GetMoveFrameSnapPosition(frame.TargetFrame, _type.Saved.Label.PositionTarget, frame.Saved.SnapSize))
             end

             frame.labelCenter:SetText(string.format("%s,%s", frame:GetWidth(), frame:GetHeight()))
             frame.labelTopLeft:SetText(labelTextTopLeft)
         end
         newMoveFrame["MoveFrameOnUpdate"] = function(frame)
-            local x, y = base.GetMoveFrameSnapPosition(frame, TOPLEFT)
+            local x, y = base.GetMoveFrameSnapPosition(frame, _type.Saved.Label.PositionTarget, frame.Saved.SnapSize)
             frame.TargetFrame:ClearAnchors()
-            frame.TargetFrame:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, x, y)
+            frame.TargetFrame:SetAnchor(_type.Saved.Label.PositionTarget, GuiRoot, TOPLEFT, x, y)
             frame.MoveFrameUpdateText(frame, true)
         end

diff --git a/CBs_Settings_Data.lua b/CBs_Settings_Data.lua
index 5392dc7..7a35262 100644
--- a/CBs_Settings_Data.lua
+++ b/CBs_Settings_Data.lua
@@ -299,10 +299,10 @@ function base.AppendMasterListTypeCollectionTypes(self, typeSelection)
             funcSet = function(_, newValue)
                 _type.Saved.Enabled = newValue
                 if newValue then
-                    self.base.InitializeType(_type)
+                    self.base.InitializeType(self._type)
                 else
-                    self.base.RemoveLabel(_type)
-                    self.base.RemoveFrame(_type)
+                    self.base.RemoveLabel(self._type)
+                    self.base.RemoveFrame(self._type)
                     if self._type == _type then
                         self._type = nil
                         self.base.UpdateSettingsType(true, self._type)
@@ -373,10 +373,9 @@ function base.AppendMasterListTypeCombined(self, typeSelection)
         funcGet = function()
             return self.base.GetLocationText(self.base.Saved.Combine.Label.PositionTarget)
         end,
-        choices = self.base.Global.ChoiceCornerLocations,
+        choices = self.base.Global.ChoiceLocations,
         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
     })
@@ -392,18 +391,6 @@ function base.AppendMasterListTypeCombined(self, typeSelection)
             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, {
@@ -533,7 +520,7 @@ function base.AppendMasterListTypeCollection(self, typeSelection)
     self:AppendRow_Dropdown(typeSelection, {
         name = "Show tooltip anchor position",
         tooltipText = string.format("Select tooltip anchor position\n%s", disabledWhenTooltipIsHidden),
-        choices = self.base.Global.ChoiceSideLocations,
+        choices = self.base.Global.ChoiceLocations,
         disabledFunc = function()
             return not self._type.Saved.Tooltip.Show
         end,
@@ -746,7 +733,6 @@ function base.AppendMasterListTypeCollection(self, typeSelection)
         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
@@ -771,26 +757,6 @@ function base.AppendMasterListTypeCollection(self, typeSelection)
             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, {})
diff --git a/Changelog b/Changelog
index 99759d9..daa6810 100644
--- a/Changelog
+++ b/Changelog
@@ -1,6 +1,12 @@
 -------------------------------------------------------------------------------
  Collection bars
 -------------------------------------------------------------------------------
+Version 1.0.5 (08-09-2019)
+- Fixed issue hiding labels, when they are not combined, and the settings tab is not enabled
+- Fixed issue with when moving the frame, and has the lable anchor set other than a corner
+-- Setting: "Bar anchor location" is removed, it now anchers to the "Display name anchor position on button".
+-- Anchors can now be set to corners/sides/center.
+
 Version 1.0.4 (14-08-2019)
 - Updated APIVersion to 100028
 - Changed the drawlevel of buttons, so they now are displayed in front of:
diff --git a/CollectionBars.txt b/CollectionBars.txt
index ffda3f7..c8cd226 100644
--- a/CollectionBars.txt
+++ b/CollectionBars.txt
@@ -6,7 +6,7 @@

 ## APIVersion: 100028
 ## Title: Collection Bars
-## Version: 1.0.4
+## Version: 1.0.5
 ## Author: Jarth
 ## Description: Show collection bars and activate collections with key or button press. Shortcuts: Settings window: /cb LibAddonMenu: /cb_menu
 ##