From 5d8314b2d4ebca939183e0aef02c3e029ecf8cd2 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Fri, 30 Oct 2026 00:51:16 -0500 Subject: [PATCH] Scroll the config panels with ClassicAPI's scroll bar pfUIScrollFrameTemplate (api/ui-widgets.xml) is a ScrollFrame with pfUIScrollBarTemplate inside its right edge and a Content scroll child, driven by ScrollUtil.InitScrollFrameWithScrollBar. The panels keep a ScrollFrame because the engine measures its range from the shown frames inside the content, which the hand-placed config rows rely on. The bar follows OnScrollRangeChanged instead of an OnUpdate poll per panel. A panel measures its range once its rows are built, and the search results measure theirs with UpdateScrollChildRect instead of hiding, re-attaching and scrolling a frame later. Clearing the search measures again too. CreateScrollFrame and CreateScrollChild have no users left, and nothing called CreateTabFrame or CreateTabChild; all four are gone. pfQuest's compat layer brings its own copies of the scroll helpers. --- api/ui-widgets.lua | 182 --------------------------------------------- api/ui-widgets.xml | 30 ++++++++ modules/gui.lua | 23 +++--- 3 files changed, 40 insertions(+), 195 deletions(-) diff --git a/api/ui-widgets.lua b/api/ui-widgets.lua index 4fba4205..ad2b7a18 100644 --- a/api/ui-widgets.lua +++ b/api/ui-widgets.lua @@ -316,117 +316,6 @@ do -- dropdown end end -function pfUI.api.CreateTabChild(self, title, bwidth, bheight, bottom, static) - -- create tab button - local b = CreateFrame("Button", "pfConfig" .. title .. "Button", self, "UIPanelButtonTemplate") - b:SetText(title) - - -- setup env - local childcount = table.getn(self.childs) + 1 - local button_width = bwidth - local button_height = bheight or 20 - local border = 4 - - if not button_width then - button_width = 150 - elseif button_width == true then - button_width = _G["pfConfig" .. title .. "ButtonText"]:GetStringWidth() + 4 * border - end - - -- set dimensions - b:SetSize(button_width, button_height) - b:SetID(childcount) - - if not self.align or self.align == "LEFT" then - local outside = self.outside and -2 * border - button_width or 0 - if bottom then - b:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", border + outside, (self.bottomcount-1) * (button_height) + (self.bottomcount * border) ) - else - b:SetPoint("TOPLEFT", self, "TOPLEFT", border + outside, -(childcount-1) * (button_height) - (childcount * border) ) - end - elseif self.align == "TOP" then - local outside = self.outside and 2 * border + button_height or 0 - local prev_button = self.buttons[getn(self.buttons)] - if prev_button then - b:SetPoint("TOPLEFT", prev_button, "TOPRIGHT", border, 0) - else - b:SetPoint("TOPLEFT", self, "TOPLEFT", border + (self.outside and -border), -border + outside ) - end - end - - SkinButton(b,.2,1,.8) - - if childcount ~= 1 then - b:SetTextColor(.5,.5,.5) - else - b:SetTextColor(.2,1,.8) - end - - b:SetScript("OnClick", function() - for k,v in pairs(self.childs) do - v:Hide() - end - self.childs[this:GetID()]:Show() - - for k,v in pairs(self.buttons) do - v.active = false - v:SetTextColor(.5,.5,.5) - end - self.buttons[this:GetID()]:SetTextColor(.2,1,.8) - end) - - self.buttons[childcount] = b - self.bottomcount = bottom and self.bottomcount + 1 or self.bottomcount - - -- create child frame - local child, scrollchild = nil, nil - if not static then - child = CreateScrollFrame("pfConfig" .. title .. "Frame", self) - scrollchild = CreateScrollChild("pfConfig" .. title .. "ScrollChild", child) - else - child = CreateFrame("Frame", "pfConfig" .. title .. "Frame", self) - end - - if childcount ~= 1 then child:Hide() end - - if not self.align or self.align == "LEFT" then - child:SetPoint("TOPLEFT", self, "TOPLEFT", button_width + 2*border + 5, -border -5) - child:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -border -5 , border + 5) - elseif self.align == "TOP" then - if self.outside then - child:SetPoint("TOPLEFT", self, "TOPLEFT", 5, -5) - child:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -5, 5) - end - end - - CreateBackdrop(child) - SetAllPointsOffset(child.backdrop, child, -5,5) - - local ret = scrollchild or child - ret.button = b - table.insert(self.childs, child) - return ret -end - -function pfUI.api.CreateTabFrame(parent, align, outside) - local f = CreateFrame("Frame", nil, parent) - - f:SetPoint("TOPLEFT", parent, "TOPLEFT", -5, 5) - f:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT", 5, -5) - - -- setup env - f.childs = { } - f.buttons = { } - f.align = align - f.outside = outside - f.bottomcount = 1 - - -- Create Child Frame - f.CreateTabChild = pfUI.api.CreateTabChild - - return f -end - -- [ pfUIScrollingEditBoxTemplate ] -- Mixin of the template in ui-widgets.xml: ClassicAPI's scrolling edit box -- with pfUI's scroll bar beside it. @@ -451,77 +340,6 @@ function pfUIScrollingEditBoxMixin:SetFont(font, size, flags) self:SetFontObject(self.font) end -function pfUI.api.CreateScrollFrame(name, parent) - local f = CreateFrame("ScrollFrame", name, parent) - - -- create slider - f.slider = CreateFrame("Slider", nil, f) - f.slider:SetOrientation('VERTICAL') - f.slider:SetPoint("TOPLEFT", f, "TOPRIGHT", -7, 0) - f.slider:SetPoint("BOTTOMRIGHT", 0, 0) - f.slider:SetThumbTexture(pfUI.media["img:col"]) - f.slider.thumb = f.slider:GetThumbTexture() - f.slider.thumb:SetHeight(50) - f.slider.thumb:SetTexture(.3,1,.8,.5) - - f.slider:SetScript("OnValueChanged", function() - f:SetVerticalScroll(this:GetValue()) - f.UpdateScrollState() - end) - - f.UpdateScrollState = function() - f.slider:SetMinMaxValues(0, f:GetVerticalScrollRange()) - f.slider:SetValue(f:GetVerticalScroll()) - - local m = f:GetHeight()+f:GetVerticalScrollRange() - local v = f:GetHeight() - local ratio = v / m - - if ratio < 1 then - local size = math.floor(v * ratio) - f.slider.thumb:SetHeight(size) - f.slider:Show() - else - f.slider:Hide() - end - end - - f.Scroll = function(self, step) - local step = step or 0 - - local current = f:GetVerticalScroll() - local max = f:GetVerticalScrollRange() - local new = current - step - - f:SetVerticalScroll(Clamp(new, 0, max)) - - f:UpdateScrollState() - end - - f:EnableMouseWheel(1) - f:SetScript("OnMouseWheel", function() - this:Scroll(arg1*10) - end) - - return f -end - -function pfUI.api.CreateScrollChild(name, parent) - local f = CreateFrame("Frame", name, parent) - - -- dummy values required - f:SetSize(1, 1) - f:SetAllPoints(parent) - - parent:SetScrollChild(f) - - f:SetScript("OnUpdate", function() - this:GetParent():UpdateScrollState() - end) - - return f -end - -- [ CreateTextBox ] -- Creates and returns a default pfUI skinned EditBox function pfUI.api.CreateTextBox(name, parent) diff --git a/api/ui-widgets.xml b/api/ui-widgets.xml index 981347de..9fd6dc72 100644 --- a/api/ui-widgets.xml +++ b/api/ui-widgets.xml @@ -29,6 +29,36 @@ + + + + + + + + + + + + + + + + + + self.Content:SetAllPoints() + self:EnableMouseWheel(true) + ScrollUtil.InitScrollFrameWithScrollBar(self, self.ScrollBar) + + + +