From 9291dd9fed865e95b73361b413b0e260344a8f29 Mon Sep 17 00:00:00 2001 From: Brad Morgan Date: Sat, 14 Sep 2024 13:54:37 -0600 Subject: [PATCH] More fixes for scrolling lists --- UI/FinishingList.lua | 18 +++++++++++------- UI/ModifiedList.lua | 20 +++++++++++--------- UI/OptionalList.lua | 5 +++++ UI/RequiredList.lua | 18 ++++++++++-------- UI/RequiredList.xml | 2 +- UI/SalvageList.lua | 20 ++++++++++++-------- UI/SalvageList.xml | 2 +- UI/ShoppingList.lua | 18 +++++++++++------- 8 files changed, 62 insertions(+), 41 deletions(-) diff --git a/UI/FinishingList.lua b/UI/FinishingList.lua index aacb1d5..a62b0cd 100644 --- a/UI/FinishingList.lua +++ b/UI/FinishingList.lua @@ -55,6 +55,7 @@ local FrameBackdrop = { insets = { left = 3, right = 3, top = 30, bottom = 3 } } +SKILLET_FINISHING_LIST_HEIGHT = 16 local function createFinishingListFrame(self) --DA.DEBUG(0,"createFinishingListFrame") local frame = SkilletFinishingList @@ -132,6 +133,10 @@ local function createFinishingListFrame(self) -- so hitting [ESC] will close the window -- tinsert(UISpecialFrames, frame:GetName()) +-- +-- Adjust the button height +-- + SKILLET_FINISHING_LIST_HEIGHT = math.max(SkilletFinishingButton1:GetHeight(), SKILLET_FINISHING_LIST_HEIGHT) return frame end @@ -150,20 +155,19 @@ function Skillet:UpdateFinishingListWindow() return end local height = SkilletFinishingListParent:GetHeight() - local buttonH = SkilletOptionalListButton1:GetHeight() local width = SkilletFinishingListParent:GetWidth() - 30 -- Allow for scrollbars - --DA.DEBUG(1,"UpdateFinishingListWindow: height= "..tostring(height)..", buttonH= "..tostring(buttonH)) + --DA.DEBUG(1,"UpdateFinishingListWindow: height= "..tostring(height)..", SKILLET_FINISHING_LIST_HEIGHT= "..tostring(SKILLET_FINISHING_LIST_HEIGHT)) --DA.DEBUG(1,"UpdateFinishingListWindow: SkilletFinishingListParent width= "..tostring(width)) - local button_count = height / buttonH + local button_count = height / SKILLET_FINISHING_LIST_HEIGHT button_count = math.floor(button_count) - 1 --DA.DEBUG(1,"UpdateFinishingListWindow: numItems= "..tostring(numItems)..", button_count= "..tostring(button_count)) -- -- Update the scroll frame -- - FauxScrollFrame_Update(SkilletFinishingListList, -- frame - numItems, -- num items - button_count, -- num to display - buttonH) -- value step (item height) + FauxScrollFrame_Update(SkilletFinishingListList, -- frame + numItems, -- num items + button_count, -- num to display + SKILLET_FINISHING_LIST_HEIGHT) -- value step (item height) -- -- Where in the list of items to start counting. -- diff --git a/UI/ModifiedList.lua b/UI/ModifiedList.lua index 6e3adcd..8e83522 100644 --- a/UI/ModifiedList.lua +++ b/UI/ModifiedList.lua @@ -50,6 +50,7 @@ local FrameBackdrop = { insets = { left = 3, right = 3, top = 30, bottom = 3 } } +SKILLET_MODIFIED_LIST_HEIGHT = 24 local function createModifiedListFrame(self) --DA.DEBUG(0,"createModifiedListFrame") local frame = SkilletModifiedList @@ -126,13 +127,16 @@ local function createModifiedListFrame(self) -- so hitting [ESC] will close the window -- tinsert(UISpecialFrames, frame:GetName()) +-- +-- Adjust the button height +-- + SKILLET_MODIFIED_LIST_HEIGHT = math.max(SkilletModifiedListButton1:GetHeight(), SKILLET_MODIFIED_LIST_HEIGHT) return frame end -- -- Called to update the modified list window -- -local SKILLET_MODIFIED_LIST_HEIGHT = 24 function Skillet:UpdateModifiedListWindow() --DA.DEBUG(0,"UpdateModifiedListWindow()") self.InProgress.modified = true @@ -147,20 +151,18 @@ function Skillet:UpdateModifiedListWindow() SkilletModifiedNeeded:SetText(self.cachedModifiedNeeded) SkilletModifiedNeeded:SetTextColor(1,1,1) local height = SkilletModifiedListParent:GetHeight() - local buttonH = SkilletModifiedListButton1:GetHeight() - buttonH = math.max(buttonH, SKILLET_MODIFIED_LIST_HEIGHT) local width = SkilletModifiedListParent:GetWidth() - 30 -- Allow for scrollbars - --DA.DEBUG(1,"UpdateModifiedListWindow: height= "..tostring(height)..", buttonH= "..tostring(buttonH)) + --DA.DEBUG(1,"UpdateModifiedListWindow: height= "..tostring(height)..", SKILLET_MODIFIED_LIST_HEIGHT= "..tostring(SKILLET_MODIFIED_LIST_HEIGHT)) --DA.DEBUG(1,"UpdateModifiedListWindow: width= "..tostring(width)) - local button_count = height / buttonH + local button_count = height / SKILLET_MODIFIED_LIST_HEIGHT button_count = math.floor(button_count) - 1 -- -- Update the scroll frame -- - FauxScrollFrame_Update(SkilletModifiedListList, -- frame - numItems, -- num items - button_count, -- num to display - buttonH) -- value step (item height) + FauxScrollFrame_Update(SkilletModifiedListList, -- frame + numItems, -- num items + button_count, -- num to display + SKILLET_MODIFIED_LIST_HEIGHT) -- value step (item height) -- -- Where in the list of items to start counting. -- diff --git a/UI/OptionalList.lua b/UI/OptionalList.lua index 2f88441..155804c 100644 --- a/UI/OptionalList.lua +++ b/UI/OptionalList.lua @@ -55,6 +55,7 @@ local FrameBackdrop = { insets = { left = 3, right = 3, top = 30, bottom = 3 } } +SKILLET_OPTIONAL_LIST_HEIGHT = 16 local function createOptionalListFrame(self) --DA.DEBUG(0,"createOptionalListFrame") local frame = SkilletOptionalList @@ -132,6 +133,10 @@ local function createOptionalListFrame(self) -- so hitting [ESC] will close the window -- tinsert(UISpecialFrames, frame:GetName()) +-- +-- Adjust the button height +-- + SKILLET_OPTIONAL_LIST_HEIGHT = math.max(SkilletOptionalListButton1:GetHeight(), SKILLET_OPTIONAL_LIST_HEIGHT) return frame end diff --git a/UI/RequiredList.lua b/UI/RequiredList.lua index 5fbad11..fb1bea6 100644 --- a/UI/RequiredList.lua +++ b/UI/RequiredList.lua @@ -17,8 +17,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . ]]-- -SKILLET_OPTIONAL_LIST_HEIGHT = 16 - local L = LibStub("AceLocale-3.0"):GetLocale("Skillet") function Skillet:RequiredListToggleHaveItems() @@ -26,11 +24,10 @@ function Skillet:RequiredListToggleHaveItems() self:HideRequiredList() end -local num_buttons = 0 - -- =========================================================================================== -- Window creation and update methods -- =========================================================================================== +local num_buttons = 0 local function get_button(i) local button = _G["SkilletRequiredListButton"..i] if not button then @@ -58,6 +55,7 @@ local FrameBackdrop = { insets = { left = 3, right = 3, top = 30, bottom = 3 } } +SKILLET_REQUIRED_LIST_HEIGHT = 16 local function createRequiredListFrame(self) --DA.DEBUG(0,"createRequiredListFrame") local frame = SkilletRequiredList @@ -135,6 +133,10 @@ local function createRequiredListFrame(self) -- so hitting [ESC] will close the window -- tinsert(UISpecialFrames, frame:GetName()) +-- +-- Adjust the button height +-- + SKILLET_REQUIRED_LIST_HEIGHT = math.max(SkilletRequiredListButton1:GetHeight(), SKILLET_REQUIRED_LIST_HEIGHT) return frame end @@ -147,16 +149,16 @@ function Skillet:UpdateRequiredListWindow() local numItems local recipe = self:GetRecipeDataByTradeIndex(self.currentTrade, self.selectedSkill) if self.cachedRequiredList then - --DA.DEBUG(1,"UpdateRequiredListWindow: cachedRequiredList= ",DA.DUMP1(self.cachedRequiredList)) numItems = #self.cachedRequiredList.reagents + --DA.DEBUG(1,"UpdateRequiredListWindow: cachedRequiredList= ",DA.DUMP1(self.cachedRequiredList)) else return end local height = SkilletRequiredListParent:GetHeight() - 30 -- Allow for frame border local width = SkilletRequiredListParent:GetWidth() - 30 -- Allow for scrollbars - --DA.DEBUG(1,"UpdateRequiredListWindow: SkilletRequiredListParent height= "..tostring(height)) + --DA.DEBUG(1,"UpdateRequiredListWindow: SkilletRequiredListParent height= "..tostring(height)..", SKILLET_REQUIRED_LIST_HEIGHT= "..tostring(SKILLET_REQUIRED_LIST_HEIGHT)) --DA.DEBUG(1,"UpdateRequiredListWindow: SkilletRequiredListParent width= "..tostring(width)) - local button_count = height / SKILLET_OPTIONAL_LIST_HEIGHT + local button_count = height / SKILLET_REQUIRED_LIST_HEIGHT button_count = math.floor(button_count) - 1 --DA.DEBUG(1,"UpdateRequiredListWindow: numItems= "..tostring(numItems)..", button_count= "..tostring(button_count)) -- @@ -165,7 +167,7 @@ function Skillet:UpdateRequiredListWindow() FauxScrollFrame_Update(SkilletRequiredListList, -- frame numItems, -- num items button_count, -- num to display - SKILLET_OPTIONAL_LIST_HEIGHT) -- value step (item height) + SKILLET_REQUIRED_LIST_HEIGHT) -- value step (item height) -- -- Where in the list of items to start counting. -- diff --git a/UI/RequiredList.xml b/UI/RequiredList.xml index 65ce8cc..723b073 100644 --- a/UI/RequiredList.xml +++ b/UI/RequiredList.xml @@ -224,7 +224,7 @@ - FauxScrollFrame_OnVerticalScroll(self, offset, SKILLET_OPTIONAL_LIST_HEIGHT, Skillet.RequiredList_OnScroll) + FauxScrollFrame_OnVerticalScroll(self, offset, SKILLET_REQUIRED_LIST_HEIGHT, Skillet.RequiredList_OnScroll) diff --git a/UI/SalvageList.lua b/UI/SalvageList.lua index 786fadb..8ec88b6 100644 --- a/UI/SalvageList.lua +++ b/UI/SalvageList.lua @@ -55,6 +55,7 @@ local FrameBackdrop = { insets = { left = 3, right = 3, top = 30, bottom = 3 } } +SKILLET_SALVAGE_LIST_HEIGHT = 16 local function createSalvageListFrame(self) --DA.DEBUG(0,"createSalvageListFrame") local frame = SkilletSalvageList @@ -132,6 +133,10 @@ local function createSalvageListFrame(self) -- so hitting [ESC] will close the window -- tinsert(UISpecialFrames, frame:GetName()) +-- +-- Adjust the button height +-- + SKILLET_SALVAGE_LIST_HEIGHT = math.max(SkilletModifiedListButton1:GetHeight(), SKILLET_SALVAGE_LIST_HEIGHT) return frame end @@ -153,21 +158,20 @@ function Skillet:UpdateSalvageListWindow() else return end - local height = SkilletSalvageListParent:GetHeight() - local buttonH = SkilletOptionalListButton1:GetHeight() + local height = SkilletSalvageListParent:GetHeight() local buttonH = SkilletOptionalListButton1:GetHeight() local width = SkilletSalvageListParent:GetWidth() - 30 -- Allow for scrollbars - --DA.DEBUG(1,"UpdateSalvageListWindow: height= "..tostring(height)..", buttonH= "..tostring(buttonH)) + --DA.DEBUG(1,"UpdateSalvageListWindow: height= "..tostring(height)..", SKILLET_SALVAGE_LIST_HEIGHT= "..tostring(SKILLET_SALVAGE_LIST_HEIGHT)) --DA.DEBUG(1,"UpdateSalvageListWindow: SkilletSalvageListParent width= "..tostring(width)) - local button_count = height / buttonH + local button_count = height / SKILLET_SALVAGE_LIST_HEIGHT button_count = math.floor(button_count) - 1 --DA.DEBUG(1,"UpdateSalvageListWindow: numItems= "..tostring(numItems)..", button_count= "..tostring(button_count)..", num_buttons= "..tostring(num_buttons)) -- -- Update the scroll frame -- - FauxScrollFrame_Update(SkilletSalvageListList, -- frame - numItems, -- num items - button_count, -- num to display - buttonH) -- value step (item height) + FauxScrollFrame_Update(SkilletSalvageListList, -- frame + numItems, -- num items + button_count, -- num to display + SKILLET_SALVAGE_LIST_HEIGHT) -- value step (item height) -- -- Where in the list of items to start counting. -- diff --git a/UI/SalvageList.xml b/UI/SalvageList.xml index 25f1405..34a628c 100644 --- a/UI/SalvageList.xml +++ b/UI/SalvageList.xml @@ -224,7 +224,7 @@ - FauxScrollFrame_OnVerticalScroll(self, offset, SKILLET_OPTIONAL_LIST_HEIGHT, Skillet.SalvageList_OnScroll) + FauxScrollFrame_OnVerticalScroll(self, offset, SKILLET_SALVAGE_LIST_HEIGHT, Skillet.SalvageList_OnScroll) diff --git a/UI/ShoppingList.lua b/UI/ShoppingList.lua index 0537ef6..6b454ee 100644 --- a/UI/ShoppingList.lua +++ b/UI/ShoppingList.lua @@ -67,6 +67,7 @@ Skillet.guildText = 0 -- -- Creates and sets up the shopping list window -- +SKILLET_SHOPPING_LIST_HEIGHT = 16 local function createShoppingListFrame(self) local frame = SkilletShoppingList if not frame then @@ -170,6 +171,10 @@ local function createShoppingListFrame(self) -- so hitting [ESC] will close the window -- tinsert(UISpecialFrames, frame:GetName()) +-- +-- Adjust the button height +-- + SKILLET_SHOPPING_LIST_HEIGHT = math.max(SkilletShoppingListButton1:GetHeight(), SKILLET_SHOPPING_LIST_HEIGHT) return frame end @@ -1250,20 +1255,19 @@ function Skillet:UpdateShoppingListWindow(use_cached_recipes) end) end local height = SkilletShoppingListParent:GetHeight() - local buttonH = SkilletShoppingListButton1:GetHeight() local width = SkilletShoppingListParent:GetWidth() - 30 -- Allow for scrollbars - --DA.DEBUG(1,"UpdateShoppingListWindow: height= "..tostring(height)..", buttonH= "..tostring(buttonH)) + --DA.DEBUG(1,"UpdateShoppingListWindow: height= "..tostring(height)..", SKILLET_SHOPPING_LIST_HEIGHT= "..tostring(SKILLET_SHOPPING_LIST_HEIGHT)) --DA.DEBUG(1,"UpdateShoppingListWindow: SkilletShoppingListParent width= "..tostring(width)) - local button_count = height / buttonH + local button_count = height / SKILLET_SHOPPING_LIST_HEIGHT button_count = math.floor(button_count) - 1 --DA.DEBUG(1,"UpdateShoppingListWindow: numItems= "..tostring(numItems)..", button_count= "..tostring(button_count)..", num_buttons= "..tostring(num_buttons)) -- -- Update the scroll frame -- - FauxScrollFrame_Update(SkilletShoppingListList, -- frame - numItems, -- num items - button_count, -- num to display - buttonH) -- value step (item height) + FauxScrollFrame_Update(SkilletShoppingListList, -- frame + numItems, -- num items + button_count, -- num to display + SKILLET_SHOPPING_LIST_HEIGHT) -- value step (item height) -- -- Where in the list of items to start counting. --