Skip to content

Commit

Permalink
Fix issue #98, items displayed outside of frame
Browse files Browse the repository at this point in the history
  • Loading branch information
b-morgan committed Sep 14, 2024
1 parent 1dd8171 commit 388fe13
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 56 deletions.
5 changes: 5 additions & 0 deletions SkilletNewsData.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ Skillet.NewsData = {
{ header = "Skill Levels", body = "Separate skill level data into two files" },
},
},
{ name = "Fixes",
data = {
{ header = "Shopping List", body = "Fix issue #98, items outside of frame" },
},
},
},
},
{ version = "5.32",
Expand Down
20 changes: 9 additions & 11 deletions UI/FinishingList.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_FINISHING_LIST_HEIGHT = 16

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

function Skillet:FinishingListToggleHaveItems()
self.db.profile.hide_unowned = not self.db.profile.hide_unowned
self:HideFinishingList()
end

local num_buttons = 0

-- ===========================================================================================
-- Window creation and update methods
-- ===========================================================================================
local num_buttons = 0
local function get_button(i)
local button = _G["SkilletFinishingListButton"..i]
if not button then
Expand Down Expand Up @@ -152,20 +149,21 @@ function Skillet:UpdateFinishingListWindow()
else
return
end
local height = SkilletFinishingListParent:GetHeight() - 30 -- Allow for frame border
local height = SkilletFinishingListParent:GetHeight()
local buttonH = SkilletOptionalListButton1:GetHeight()
local width = SkilletFinishingListParent:GetWidth() - 30 -- Allow for scrollbars
--DA.DEBUG(1,"UpdateFinishingListWindow: SkilletFinishingListParent height= "..tostring(height))
--DA.DEBUG(1,"UpdateFinishingListWindow: height= "..tostring(height)..", buttonH= "..tostring(buttonH))
--DA.DEBUG(1,"UpdateFinishingListWindow: SkilletFinishingListParent width= "..tostring(width))
local button_count = height / SKILLET_FINISHING_LIST_HEIGHT
local button_count = height / buttonH
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
SKILLET_FINISHING_LIST_HEIGHT) -- value step (item height)
FauxScrollFrame_Update(SkilletFinishingListList, -- frame
numItems, -- num items
button_count, -- num to display
buttonH) -- value step (item height)
--
-- Where in the list of items to start counting.
--
Expand Down
22 changes: 12 additions & 10 deletions UI/ModifiedList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@ 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_MODIFIED_LIST_HEIGHT = 24

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

-- ===========================================================================================
-- Window creation and update methods
-- ===========================================================================================
local num_buttons = 0

local function get_button(i)
local button = _G["SkilletModifiedListButton"..i]
if not button then
Expand Down Expand Up @@ -135,6 +132,7 @@ 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 @@ -148,22 +146,26 @@ function Skillet:UpdateModifiedListWindow()
end
SkilletModifiedNeeded:SetText(self.cachedModifiedNeeded)
SkilletModifiedNeeded:SetTextColor(1,1,1)
local height = SkilletModifiedListParent:GetHeight() - 30 -- Allow for frame border
local height = SkilletModifiedListParent:GetHeight()
local buttonH = SkilletModifiedListButton1:GetHeight()
buttonH = math.max(buttonH, SKILLET_MODIFIED_LIST_HEIGHT)
local width = SkilletModifiedListParent:GetWidth() - 30 -- Allow for scrollbars
local button_count = height / SKILLET_MODIFIED_LIST_HEIGHT
--DA.DEBUG(1,"UpdateModifiedListWindow: height= "..tostring(height)..", buttonH= "..tostring(buttonH))
--DA.DEBUG(1,"UpdateModifiedListWindow: width= "..tostring(width))
local button_count = height / buttonH
button_count = math.floor(button_count) - 1
--
-- Update the scroll frame
--
FauxScrollFrame_Update(SkilletModifiedListList, -- frame
numItems, -- num items
button_count, -- num to display
SKILLET_MODIFIED_LIST_HEIGHT) -- value step (item height)
FauxScrollFrame_Update(SkilletModifiedListList, -- frame
numItems, -- num items
button_count, -- num to display
buttonH) -- value step (item height)
--
-- Where in the list of items to start counting.
--
local itemOffset = FauxScrollFrame_GetOffset(SkilletModifiedListList)
--DA.DEBUG(1,"UpdateModifiedListWindow: itemOffset= "..tostring(itemOffset)..", width= "..tostring(width))
--DA.DEBUG(1,"UpdateModifiedListWindow: itemOffset= "..tostring(itemOffset))
for i=1, button_count, 1 do
num_buttons = math.max(num_buttons, i)
local itemIndex = i + itemOffset
Expand Down
24 changes: 11 additions & 13 deletions UI/OptionalList.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:OptionalListToggleHaveItems()
self.db.profile.hide_unowned = not self.db.profile.hide_unowned
self:HideOptionalList()
end

local num_buttons = 0

-- ===========================================================================================
-- Window creation and update methods
-- ===========================================================================================
local num_buttons = 0
local function get_button(i)
local button = _G["SkilletOptionalListButton"..i]
if not button then
Expand Down Expand Up @@ -152,20 +149,21 @@ function Skillet:UpdateOptionalListWindow()
else
return
end
local height = SkilletOptionalListParent:GetHeight() - 30 -- Allow for frame border
local height = SkilletOptionalListParent:GetHeight()
local buttonH = SkilletOptionalListButton1:GetHeight()
local width = SkilletOptionalListParent:GetWidth() - 30 -- Allow for scrollbars
--DA.DEBUG(1,"UpdateOptionalListWindow: SkilletOptionalListParent height= "..tostring(height))
--DA.DEBUG(1,"UpdateOptionalListWindow: SkilletOptionalListParent width= "..tostring(width))
local button_count = height / SKILLET_OPTIONAL_LIST_HEIGHT
--DA.DEBUG(1,"UpdateOptionalListWindow: height= "..tostring(height)..", buttonH= "..tostring(buttonH))
--DA.DEBUG(1,"UpdateOptionalListWindow: width= "..tostring(width))
local button_count = height / buttonH
button_count = math.floor(button_count) - 1
--DA.DEBUG(1,"UpdateOptionalListWindow: numItems= "..tostring(numItems)..", button_count= "..tostring(button_count))
--DA.DEBUG(1,"UpdateOptionalListWindow: numItems= "..tostring(numItems)..", button_count= "..tostring(button_count)..", num_buttons= "..tostring(num_buttons))
--
-- Update the scroll frame
--
FauxScrollFrame_Update(SkilletOptionalListList, -- frame
numItems, -- num items
button_count, -- num to display
SKILLET_OPTIONAL_LIST_HEIGHT) -- value step (item height)
FauxScrollFrame_Update(SkilletOptionalListList, -- frame
numItems, -- num items
button_count, -- num to display
buttonH) -- value step (item height)
--
-- Where in the list of items to start counting.
--
Expand Down
24 changes: 11 additions & 13 deletions UI/SalvageList.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_SALVAGE_LIST_HEIGHT = 16

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

function Skillet:SalvageListToggleHaveItems()
self.db.profile.hide_unowned = not self.db.profile.hide_unowned
self:HideSalvageList()
end

local num_buttons = 0

-- ===========================================================================================
-- Window creation and update methods
-- ===========================================================================================
local num_buttons = 0
local function get_button(i)
local button = _G["SkilletSalvageListButton"..i]
if not button then
Expand Down Expand Up @@ -156,25 +153,26 @@ function Skillet:UpdateSalvageListWindow()
else
return
end
local height = SkilletSalvageListParent:GetHeight() - 30 -- Allow for frame border
local height = SkilletSalvageListParent:GetHeight()
local buttonH = SkilletOptionalListButton1:GetHeight()
local width = SkilletSalvageListParent:GetWidth() - 30 -- Allow for scrollbars
--DA.DEBUG(1,"UpdateSalvageListWindow: SkilletSalvageListParent height= "..tostring(height))
--DA.DEBUG(1,"UpdateSalvageListWindow: height= "..tostring(height)..", buttonH= "..tostring(buttonH))
--DA.DEBUG(1,"UpdateSalvageListWindow: SkilletSalvageListParent width= "..tostring(width))
local button_count = height / SKILLET_SALVAGE_LIST_HEIGHT
local button_count = height / buttonH
button_count = math.floor(button_count) - 1
--DA.DEBUG(1,"UpdateSalvageListWindow: numItems= "..tostring(numItems)..", button_count= "..tostring(button_count))
--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
SKILLET_SALVAGE_LIST_HEIGHT) -- value step (item height)
FauxScrollFrame_Update(SkilletSalvageListList, -- frame
numItems, -- num items
button_count, -- num to display
buttonH) -- value step (item height)
--
-- Where in the list of items to start counting.
--
local itemOffset = FauxScrollFrame_GetOffset(SkilletSalvageListList)
--DA.DEBUG(1,"UpdateSalvageListWindow: itemOffset= "..tostring(itemOffset)..", width= "..tostring(width))
--DA.DEBUG(1,"UpdateSalvageListWindow: itemOffset= "..tostring(itemOffset))
for i=1, button_count, 1 do
num_buttons = math.max(num_buttons, i)
local itemIndex = i + itemOffset
Expand Down
27 changes: 18 additions & 9 deletions UI/ShoppingList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ local isClassic = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
local isBCC = WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC
local isWrath = WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC

SKILLET_SHOPPING_LIST_HEIGHT = 16

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

-- Stolen from the Waterfall Ace2 addon.
Expand Down Expand Up @@ -1171,6 +1169,7 @@ function Skillet:ShoppingListToggleIncludeGuild()
Skillet.db.profile.include_guild = not Skillet.db.profile.include_guild
end

local num_buttons = 0
local function get_button(i)
local button = _G["SkilletShoppingListButton"..i]
if not button then
Expand All @@ -1193,7 +1192,6 @@ end
--
function Skillet:UpdateShoppingListWindow(use_cached_recipes)
--DA.DEBUG(0,"UpdateShoppingListWindow("..tostring(use_cached_recipes)..")")
local num_buttons = 0
if not self.shoppingList or not self.shoppingList:IsVisible() then
return
end
Expand Down Expand Up @@ -1251,19 +1249,26 @@ function Skillet:UpdateShoppingListWindow(use_cached_recipes)
return (b.player > a.player)
end)
end
local button_count = SkilletShoppingListList:GetHeight() / SKILLET_SHOPPING_LIST_HEIGHT
button_count = math.floor(button_count)
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: SkilletShoppingListParent width= "..tostring(width))
local button_count = height / buttonH
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
SKILLET_SHOPPING_LIST_HEIGHT) -- value step (item height)
FauxScrollFrame_Update(SkilletShoppingListList, -- frame
numItems, -- num items
button_count, -- num to display
buttonH) -- value step (item height)
--
-- Where in the list of items to start counting.
--
local itemOffset = FauxScrollFrame_GetOffset(SkilletShoppingListList)
--DA.DEBUG(1,"UpdateShoppingListWindow: itemOffset= "..tostring(itemOffset))
local width = SkilletShoppingListList:GetWidth()
local totalPrice = 0
for i=1, button_count, 1 do
Expand All @@ -1279,6 +1284,7 @@ function Skillet:UpdateShoppingListWindow(use_cached_recipes)
local player_width = math.max(button_width * 0.3, 100)
local name_width = math.max(button_width - count_width - player_width, 125)
count:SetWidth(count_width)
name:SetWordWrap(false)
name:SetWidth(name_width)
name:SetPoint("LEFT", count:GetName(), "RIGHT", 4)
player:SetWidth(player_width)
Expand All @@ -1298,8 +1304,11 @@ function Skillet:UpdateShoppingListWindow(use_cached_recipes)
else
button.id = nil
button:Hide()
name:SetText("")
name:Hide()
count:SetText("")
count:Hide()
player:SetText("")
player:Hide()
end
end
Expand Down

0 comments on commit 388fe13

Please sign in to comment.