Skip to content

Commit

Permalink
More fixes for scrolling lists
Browse files Browse the repository at this point in the history
  • Loading branch information
b-morgan committed Sep 14, 2024
1 parent 388fe13 commit 9291dd9
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 41 deletions.
18 changes: 11 additions & 7 deletions UI/FinishingList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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.
--
Expand Down
20 changes: 11 additions & 9 deletions UI/ModifiedList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
--
Expand Down
5 changes: 5 additions & 0 deletions UI/OptionalList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
18 changes: 10 additions & 8 deletions UI/RequiredList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]--

SKILLET_OPTIONAL_LIST_HEIGHT = 16

local L = LibStub("AceLocale-3.0"):GetLocale("Skillet")

function Skillet:RequiredListToggleHaveItems()
self.db.profile.hide_unowned = not self.db.profile.hide_unowned
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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))
--
Expand All @@ -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.
--
Expand Down
2 changes: 1 addition & 1 deletion UI/RequiredList.xml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
</Anchors>
<Scripts>
<OnVerticalScroll>
FauxScrollFrame_OnVerticalScroll(self, offset, SKILLET_OPTIONAL_LIST_HEIGHT, Skillet.RequiredList_OnScroll)
FauxScrollFrame_OnVerticalScroll(self, offset, SKILLET_REQUIRED_LIST_HEIGHT, Skillet.RequiredList_OnScroll)
</OnVerticalScroll>
</Scripts>
</ScrollFrame>
Expand Down
20 changes: 12 additions & 8 deletions UI/SalvageList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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.
--
Expand Down
2 changes: 1 addition & 1 deletion UI/SalvageList.xml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
</Anchors>
<Scripts>
<OnVerticalScroll>
FauxScrollFrame_OnVerticalScroll(self, offset, SKILLET_OPTIONAL_LIST_HEIGHT, Skillet.SalvageList_OnScroll)
FauxScrollFrame_OnVerticalScroll(self, offset, SKILLET_SALVAGE_LIST_HEIGHT, Skillet.SalvageList_OnScroll)
</OnVerticalScroll>
</Scripts>
</ScrollFrame>
Expand Down
18 changes: 11 additions & 7 deletions UI/ShoppingList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.
--
Expand Down

0 comments on commit 9291dd9

Please sign in to comment.