Skip to content

Commit 7dcb8ec

Browse files
committed
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
1 parent 572a334 commit 7dcb8ec

File tree

2 files changed

+52
-22
lines changed

2 files changed

+52
-22
lines changed

OHFrame.lua

+12-22
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ local NUMROWS = math.floor(305/(ROWHEIGHT+4))
1111

1212
local offset = 0
1313
local rows = {}
14-
local frame, scrollbar
14+
local frame, scrollbar, upbutt, downbutt
1515

1616

1717
local function OnShow(self)
18-
scrollbar:SetMinMaxValues(1, math.max(#TourGuide.actions - NUMROWS, 1))
18+
scrollbar:SetMinMaxValues(0, math.max(#TourGuide.actions - NUMROWS, 1))
1919
scrollbar:SetValue(TourGuide.current - NUMROWS/2 - 1)
2020

2121
self:SetAlpha(0)
@@ -37,34 +37,21 @@ function TourGuide:CreateObjectivePanel()
3737
frame = CreateFrame("Frame", nil, UIParent)
3838
frame:SetFrameStrata("DIALOG")
3939

40-
scrollbar = CreateFrame("Slider", "TourGuideOHScroll", frame, "UIPanelScrollBarTemplate")
41-
scrollbar:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, -16)
40+
scrollbar, upbutt, downbutt = ww.ConjureScrollBar(frame, true)
41+
scrollbar:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, -19)
4242
scrollbar:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, 16)
4343
scrollbar:SetScript("OnValueChanged", function(f, val) self:UpdateOHPanel(val) end)
44-
TourGuideOHScrollScrollUpButton:SetScript("OnClick", function(f)
45-
scrollbar:SetValue(offset - NUMROWS)
44+
45+
upbutt:SetScript("OnClick", function(f)
46+
scrollbar:SetValue(offset - NUMROWS + 1)
4647
PlaySound("UChatScrollButton")
4748
end)
4849

49-
TourGuideOHScrollScrollDownButton:SetScript("OnClick", function(f)
50-
scrollbar:SetValue(offset + NUMROWS)
50+
downbutt:SetScript("OnClick", function(f)
51+
scrollbar:SetValue(offset + NUMROWS - 1)
5152
PlaySound("UChatScrollButton")
5253
end)
5354

54-
local uptext = scrollbar:CreateTexture(nil, "BACKGROUND")
55-
uptext:SetWidth(31)
56-
uptext:SetHeight(256)
57-
uptext:SetPoint("TOPLEFT", TourGuideOHScrollScrollUpButton, "TOPLEFT", -7, 5)
58-
uptext:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-ScrollBar")
59-
uptext:SetTexCoord(0, 0.484375, 0, 1.0)
60-
61-
local downtex = scrollbar:CreateTexture(nil, "BACKGROUND")
62-
downtex:SetWidth(31)
63-
downtex:SetHeight(106)
64-
downtex:SetPoint("BOTTOMLEFT", TourGuideOHScrollScrollDownButton, "BOTTOMLEFT", -7, -3)
65-
downtex:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-ScrollBar")
66-
downtex:SetTexCoord(0.515625, 1.0, 0, 0.4140625)
67-
6855
local function LevelCorrection(f) f:SetFrameLevel(frame:GetFrameLevel()+1); f:SetScript("OnShow", nil) end
6956
for i=1,NUMROWS do
7057
local row = CreateFrame("Button", nil, frame)
@@ -119,6 +106,9 @@ function TourGuide:UpdateOHPanel(value)
119106
if (offset + NUMROWS) > #self.actions then offset = #self.actions - NUMROWS end
120107
if offset < 0 then offset = 0 end
121108

109+
if offset == 0 then upbutt:Disable() else upbutt:Enable() end
110+
if offset == (#self.actions - NUMROWS) then downbutt:Disable() else downbutt:Enable() end
111+
122112
for i in pairs(accepted) do accepted[i] = nil end
123113

124114
for i=1,offset-1 do

WidgetWarlock.lua

+40
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,43 @@ function WidgetWarlock.FadeIn(frame, elap)
6969
elapsed[frame] = 0
7070
else frame:SetAlpha(elapsed[frame]/fadetimes[frame]) end
7171
end
72+
73+
74+
--------------------------
75+
-- Scroll Bar --
76+
--------------------------
77+
78+
function WidgetWarlock.ConjureScrollBar(parent, hasborder)
79+
local f = CreateFrame("Slider", nil, parent)
80+
f:SetWidth(16)
81+
82+
local upbutt = CreateFrame("Button", nil, f, "UIPanelScrollUpButtonTemplate")
83+
upbutt:SetPoint("BOTTOM", f, "TOP")
84+
85+
local downbutt = CreateFrame("Button", nil, f, "UIPanelScrollDownButtonTemplate")
86+
downbutt:SetPoint("TOP", f, "BOTTOM")
87+
88+
f:SetThumbTexture("Interface\\Buttons\\UI-ScrollBar-Knob")
89+
local thumb = f:GetThumbTexture()
90+
thumb:SetHeight(16)
91+
thumb:SetWidth(16)
92+
thumb:SetTexCoord(0.25, 0.75, 0.25, 0.75)
93+
94+
if hasborder then
95+
local uptext = f:CreateTexture(nil, "BACKGROUND")
96+
uptext:SetWidth(31)
97+
uptext:SetHeight(256)
98+
uptext:SetPoint("TOPLEFT", upbutt, "TOPLEFT", -7, 5)
99+
uptext:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-ScrollBar")
100+
uptext:SetTexCoord(0, 0.484375, 0, 1.0)
101+
102+
local downtex = f:CreateTexture(nil, "BACKGROUND")
103+
downtex:SetWidth(31)
104+
downtex:SetHeight(106)
105+
downtex:SetPoint("BOTTOMLEFT", downbutt, "BOTTOMLEFT", -7, -3)
106+
downtex:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-ScrollBar")
107+
downtex:SetTexCoord(0.515625, 1.0, 0, 0.4140625)
108+
end
109+
110+
return f, upbutt, downbutt
111+
end

0 commit comments

Comments
 (0)