From e733cee0da6981127649eb7abad349a8fd3a69d6 Mon Sep 17 00:00:00 2001 From: "James D. Callahan III" Date: Wed, 31 Mar 2010 07:23:13 -0400 Subject: [PATCH 1/5] Moved code from ListFrame:Update() to make ListFrame:ClearLines() --- Frame.lua | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/Frame.lua b/Frame.lua index a080597..1a41356 100644 --- a/Frame.lua +++ b/Frame.lua @@ -2986,6 +2986,26 @@ do end end + -- Reset the current buttons/lines + function ListFrame:ClearLines() + for i = 1, NUM_RECIPE_LINES do + local entry = self.entry_buttons[i] + local state = self.state_buttons[i] + + entry.string_index = 0 + entry:SetText("") + entry:SetScript("OnEnter", nil) + entry:SetScript("OnLeave", nil) + + state.string_index = 0 + state:Hide() + state:SetScript("OnEnter", nil) + state:SetScript("OnLeave", nil) + + state:ClearAllPoints() + end + end + function ListFrame:Update(expand_mode, refresh) -- If not refreshing an existing list and not scrolling up/down, wipe and re-initialize the entries. if not refresh and not self.scrolling then @@ -3054,25 +3074,9 @@ do self.scroll_bar:Hide() else self.scroll_bar:Show() - end - -- Reset the current buttons/lines - for i = 1, NUM_RECIPE_LINES do - local entry = self.entry_buttons[i] - local state = self.state_buttons[i] - - entry.string_index = 0 - entry:SetText("") - entry:SetScript("OnEnter", nil) - entry:SetScript("OnLeave", nil) - - state.string_index = 0 - state:Hide() - state:SetScript("OnEnter", nil) - state:SetScript("OnLeave", nil) - - state:ClearAllPoints() end + self:ClearLines() local button_index = 1 local string_index = button_index + self.scroll_bar:GetValue() -- 1.7.9.5 From cadeed8f9cda43a4c4ed5d8b60404a12648fd1ec Mon Sep 17 00:00:00 2001 From: "James D. Callahan III" Date: Wed, 31 Mar 2010 07:24:23 -0400 Subject: [PATCH 2/5] In ListFrame:Update(): If num_entries is 0, call self:ClearLines() - we may have switched to a profession where nothing shows. --- Frame.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Frame.lua b/Frame.lua index 1a41356..b0490a1 100644 --- a/Frame.lua +++ b/Frame.lua @@ -3007,14 +3007,15 @@ do end function ListFrame:Update(expand_mode, refresh) - -- If not refreshing an existing list and not scrolling up/down, wipe and re-initialize the entries. - if not refresh and not self.scrolling then + if not refresh then self:Initialize(expand_mode) end local num_entries = #self.entries if num_entries == 0 then + self:ClearLines() + -- disable expand button, it's useless here and would spam the same error again ARL_ExpandButton:SetNormalFontObject("GameFontDisableSmall") ARL_ExpandButton:Disable() -- 1.7.9.5 From b98d3712ccb00689565af6a9a2f012dd18201aad Mon Sep 17 00:00:00 2001 From: "James D. Callahan III" Date: Wed, 31 Mar 2010 07:25:53 -0400 Subject: [PATCH 3/5] In ListFrame:Update(): Only use information from self.scroll_bar if num_entries is greater than NUM_RECIPE_LINES. --- Frame.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Frame.lua b/Frame.lua index b0490a1..1139af1 100644 --- a/Frame.lua +++ b/Frame.lua @@ -3066,6 +3066,8 @@ do end return end + local offset = 0 + addon:ClosePopups() ARL_ExpandButton:SetNormalFontObject("GameFontNormalSmall") @@ -3074,15 +3076,15 @@ do if num_entries <= NUM_RECIPE_LINES then self.scroll_bar:Hide() else - self.scroll_bar:Show() + offset = self.scroll_bar:GetValue() + self.scroll_bar:SetMinMaxValues(0, math.max(0, num_entries - NUM_RECIPE_LINES)) + self.scroll_bar:Show() end self:ClearLines() local button_index = 1 - local string_index = button_index + self.scroll_bar:GetValue() - - self.scroll_bar:SetMinMaxValues(0, math.max(0, #self.entries - NUM_RECIPE_LINES)) + local string_index = button_index + offset -- Populate the buttons with new values while button_index <= NUM_RECIPE_LINES and string_index <= num_entries do @@ -3128,7 +3130,7 @@ do string_index = string_index + 1 end button_index = 1 - string_index = button_index + self.scroll_bar:GetValue() + string_index = button_index + offset -- This function could possibly have been called from a mouse click or by scrolling. -- Since, in those cases, the list entries have changed, the mouse is likely over a different entry - the highlight texture and tooltip should be generated for it. -- 1.7.9.5 From 097547cbe46300e8b26763c54b37fd23b66d47ff Mon Sep 17 00:00:00 2001 From: "James D. Callahan III" Date: Wed, 31 Mar 2010 07:34:35 -0400 Subject: [PATCH 4/5] Moved updating of the up/down button states from ScrollBar_Scroll() to the ScrollBar's OnValueChanged script handler. --- Frame.lua | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/Frame.lua b/Frame.lua index 1139af1..101fc7d 100644 --- a/Frame.lua +++ b/Frame.lua @@ -2524,13 +2524,6 @@ ScrollBar:SetThumbTexture("Interface\\Buttons\\UI-ScrollBar-Knob") ScrollBar:SetMinMaxValues(0, 1) ScrollBar:SetValueStep(1) --- This can be called either from ListFrame's OnMouseWheel script, manually --- sliding the thumb, or from clicking the up/down buttons. -ScrollBar:SetScript("OnValueChanged", - function(self, value, ...) - ListFrame:Update(nil, true) - end) - ListFrame.scroll_bar = ScrollBar ------------------------------------------------------------------------------- @@ -2578,17 +2571,6 @@ do cur_val = math.max(min_val, cur_val - SCROLL_DEPTH) ScrollBar:SetValue(cur_val) end - - if cur_val == min_val then - ScrollUpButton:Disable() - ScrollDownButton:Enable() - elseif cur_val == max_val then - ScrollUpButton:Enable() - ScrollDownButton:Disable() - else - ScrollUpButton:Enable() - ScrollDownButton:Enable() - end end ScrollUpButton:SetScript("OnClick", @@ -2611,6 +2593,25 @@ do ScrollBar_Scroll(delta) end) + -- This can be called either from ListFrame's OnMouseWheel script, manually + -- sliding the thumb, or from clicking the up/down buttons. + ScrollBar:SetScript("OnValueChanged", + function(self, value, ...) + local min_val, max_val = self:GetMinMaxValues() + + if value == min_val then + ScrollUpButton:Disable() + ScrollDownButton:Enable() + elseif value == max_val then + ScrollUpButton:Enable() + ScrollDownButton:Disable() + else + ScrollUpButton:Enable() + ScrollDownButton:Enable() + end + ListFrame:Update(nil, true) + end) + local function Button_OnEnter(self) ListItem_ShowTooltip(self, ListFrame.entries[self.string_index]) end -- 1.7.9.5 From 7319a6a321423e6dbe448e5e6a9fe43ed641044d Mon Sep 17 00:00:00 2001 From: "James D. Callahan III" Date: Wed, 31 Mar 2010 07:35:04 -0400 Subject: [PATCH 5/5] In ListItem_OnClick(): If clicked_line is nil, do nothing. --- Frame.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Frame.lua b/Frame.lua index 101fc7d..ddabcf8 100644 --- a/Frame.lua +++ b/Frame.lua @@ -2646,6 +2646,9 @@ do local clicked_line = ListFrame.entries[clickedIndex] local traverseIndex = 0 + if not clicked_line then + return + end -- First, check if this is a "modified" click, and react appropriately if clicked_line.recipe_id and _G.IsModifierKeyDown() then if _G.IsControlKeyDown() and _G.IsShiftKeyDown() then -- 1.7.9.5