From 7dcb8ec5bd883a7a4a87370b8c32d8eb79d6e157 Mon Sep 17 00:00:00 2001 From: Tekkub Stoutwrithe Date: Mon, 8 Oct 2007 04:16:10 +0000 Subject: [PATCH] TourGuide - Move scrollbar code into WidgetWarlock, various tweaks to scrollbar behavior git-svn-id: https://tekkub-wow.googlecode.com/svn/trunk/TourGuide@606 86fe6d9a-1522-0410-a387-bf9db416f0a0 --- OHFrame.lua | 34 ++++++++++++---------------------- WidgetWarlock.lua | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 22 deletions(-) diff --git a/OHFrame.lua b/OHFrame.lua index ef239c1..b314e7f 100644 --- a/OHFrame.lua +++ b/OHFrame.lua @@ -11,11 +11,11 @@ local NUMROWS = math.floor(305/(ROWHEIGHT+4)) local offset = 0 local rows = {} -local frame, scrollbar +local frame, scrollbar, upbutt, downbutt local function OnShow(self) - scrollbar:SetMinMaxValues(1, math.max(#TourGuide.actions - NUMROWS, 1)) + scrollbar:SetMinMaxValues(0, math.max(#TourGuide.actions - NUMROWS, 1)) scrollbar:SetValue(TourGuide.current - NUMROWS/2 - 1) self:SetAlpha(0) @@ -37,34 +37,21 @@ function TourGuide:CreateObjectivePanel() frame = CreateFrame("Frame", nil, UIParent) frame:SetFrameStrata("DIALOG") - scrollbar = CreateFrame("Slider", "TourGuideOHScroll", frame, "UIPanelScrollBarTemplate") - scrollbar:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, -16) + scrollbar, upbutt, downbutt = ww.ConjureScrollBar(frame, true) + scrollbar:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, -19) scrollbar:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, 16) scrollbar:SetScript("OnValueChanged", function(f, val) self:UpdateOHPanel(val) end) - TourGuideOHScrollScrollUpButton:SetScript("OnClick", function(f) - scrollbar:SetValue(offset - NUMROWS) + + upbutt:SetScript("OnClick", function(f) + scrollbar:SetValue(offset - NUMROWS + 1) PlaySound("UChatScrollButton") end) - TourGuideOHScrollScrollDownButton:SetScript("OnClick", function(f) - scrollbar:SetValue(offset + NUMROWS) + downbutt:SetScript("OnClick", function(f) + scrollbar:SetValue(offset + NUMROWS - 1) PlaySound("UChatScrollButton") end) - local uptext = scrollbar:CreateTexture(nil, "BACKGROUND") - uptext:SetWidth(31) - uptext:SetHeight(256) - uptext:SetPoint("TOPLEFT", TourGuideOHScrollScrollUpButton, "TOPLEFT", -7, 5) - uptext:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-ScrollBar") - uptext:SetTexCoord(0, 0.484375, 0, 1.0) - - local downtex = scrollbar:CreateTexture(nil, "BACKGROUND") - downtex:SetWidth(31) - downtex:SetHeight(106) - downtex:SetPoint("BOTTOMLEFT", TourGuideOHScrollScrollDownButton, "BOTTOMLEFT", -7, -3) - downtex:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-ScrollBar") - downtex:SetTexCoord(0.515625, 1.0, 0, 0.4140625) - local function LevelCorrection(f) f:SetFrameLevel(frame:GetFrameLevel()+1); f:SetScript("OnShow", nil) end for i=1,NUMROWS do local row = CreateFrame("Button", nil, frame) @@ -119,6 +106,9 @@ function TourGuide:UpdateOHPanel(value) if (offset + NUMROWS) > #self.actions then offset = #self.actions - NUMROWS end if offset < 0 then offset = 0 end + if offset == 0 then upbutt:Disable() else upbutt:Enable() end + if offset == (#self.actions - NUMROWS) then downbutt:Disable() else downbutt:Enable() end + for i in pairs(accepted) do accepted[i] = nil end for i=1,offset-1 do diff --git a/WidgetWarlock.lua b/WidgetWarlock.lua index 1cbfc54..821c771 100644 --- a/WidgetWarlock.lua +++ b/WidgetWarlock.lua @@ -69,3 +69,43 @@ function WidgetWarlock.FadeIn(frame, elap) elapsed[frame] = 0 else frame:SetAlpha(elapsed[frame]/fadetimes[frame]) end end + + +-------------------------- +-- Scroll Bar -- +-------------------------- + +function WidgetWarlock.ConjureScrollBar(parent, hasborder) + local f = CreateFrame("Slider", nil, parent) + f:SetWidth(16) + + local upbutt = CreateFrame("Button", nil, f, "UIPanelScrollUpButtonTemplate") + upbutt:SetPoint("BOTTOM", f, "TOP") + + local downbutt = CreateFrame("Button", nil, f, "UIPanelScrollDownButtonTemplate") + downbutt:SetPoint("TOP", f, "BOTTOM") + + f:SetThumbTexture("Interface\\Buttons\\UI-ScrollBar-Knob") + local thumb = f:GetThumbTexture() + thumb:SetHeight(16) + thumb:SetWidth(16) + thumb:SetTexCoord(0.25, 0.75, 0.25, 0.75) + + if hasborder then + local uptext = f:CreateTexture(nil, "BACKGROUND") + uptext:SetWidth(31) + uptext:SetHeight(256) + uptext:SetPoint("TOPLEFT", upbutt, "TOPLEFT", -7, 5) + uptext:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-ScrollBar") + uptext:SetTexCoord(0, 0.484375, 0, 1.0) + + local downtex = f:CreateTexture(nil, "BACKGROUND") + downtex:SetWidth(31) + downtex:SetHeight(106) + downtex:SetPoint("BOTTOMLEFT", downbutt, "BOTTOMLEFT", -7, -3) + downtex:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-ScrollBar") + downtex:SetTexCoord(0.515625, 1.0, 0, 0.4140625) + end + + return f, upbutt, downbutt +end -- 2.11.4.GIT