Skip to content

Commit

Permalink
Add scrollbars to panels that need them
Browse files Browse the repository at this point in the history
  • Loading branch information
tekkub committed Jan 3, 2009
1 parent 67110f6 commit 9f9ea40
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Glyphs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Panda.PanelFactory("Glyphs", 45357,
39341 43122 43416 41103 42750 42974 41541 42399 42468 42905 40901 43536 43543 43546 43541
39342 43124 43428 41105 42749 42963 41527 42401 42471 42911 40903 43548 43553 43825 43826
0 0 43432 41094 42736 42955 41542 42406 42453 42906 40896 43551 43827 43554 43549
39343 43126 43419 41102 42745 42958 41539 42412 42460 42909 40920 43552 43533 0 0 0 44680
39343 43126 43419 41102 42745 42958 41539 42412 42460 42909 40920 43552 43533 0 0 44680
0 0 43431 41110 42752 42957 41517 42405 42454 42902 40908 43534
0 0 43425 41109 42748 42965 41538 42409 42463 42915 40900 43537
0 0 43429 41097 42751 42969 41518 42407 42469 42916 40906 43538
Expand All @@ -52,7 +52,7 @@ end)


Panda.PanelFactory("Minor Glyphs (by ink)", 45357,
[[39334 39774 43395 43396 43366 43390 43339 43364 43379 43342 43354 43338 43335 0 0 0 44680
[[39334 39774 43395 43396 43366 43390 43339 43364 43379 43342 43354 43338 43335 0 0 44680
0 0 43399 43397 43367 43340 43359 43361 43343 43371 43350 43356 43332
39338 43116 43398 43377 43365 43357 43725 43373 43389 43316
0 0 43376 43380 43368 43360 43344 43386 43391 43331 0 0 0 43374 43394 43126 39343
Expand Down
2 changes: 1 addition & 1 deletion Milling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local NAME, _, MILLICON = GetSpellInfo(51005)
local NAME2 = GetSpellInfo(45357)
local inks = "39469 39774 43115 43116 43117 43118 43118 43119 43120 43121 43122 43123 43124 43125 43126 43127"
Panda.PanelFactory(NAME, 45357,
[[39151 0 39469 0 0 2447 765 2449 0 0 0 0 0 0 0 0 6948
[[39151 0 39469 0 0 2447 765 2449 0 0 0 0 0 0 0 6948
39334 43103 39774 43115 0 785 2450 2452 3820 2453
39338 43104 43116 43117 0 3369 3355 3356 3357
39339 43105 43118 43119 0 3818 3821 3358 3819
Expand Down
1 change: 1 addition & 0 deletions Panda.toc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ LibDataBroker-1.1\LibDataBroker-1.1.lua
tekAucQuery.lua
tekPanelAuction.lua
tekKonfigButton.lua
tekKonfigScroll.lua
tinyGratuity.lua
tekIDmemo.lua

Expand Down
26 changes: 20 additions & 6 deletions PanelFactory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ local nocombine = [[39334 39338 39339 39340 39341 39342 39343
]]


local function noop() end

function Panda:PanelFiller()
PandaDBPC = PandaDBPC or {}
knowncombines = PandaDBPC
Expand Down Expand Up @@ -78,13 +80,25 @@ function Panda:PanelFiller()
self:SetPoint("RIGHT")
self:SetHeight(1000)

scroll:UpdateScrollChildRect()
scroll:EnableMouseWheel(true)
scroll:SetScript("OnMouseWheel", function(scroll, val)
offset = math.max(math.min(offset - val*LINEHEIGHT, 0), MAXOFFSET)
scroll:SetVerticalScroll(-offset)
self:SetPoint("TOP", 0, offset)
end)

if MAXOFFSET ~= 0 then
local scrollbar = LibStub("tekKonfig-Scroll").new(scroll, 2, LINEHIEGHT)
scrollbar:SetMinMaxValues(0, -MAXOFFSET)
scrollbar:SetValue(0)

scroll:UpdateScrollChildRect()
scroll:SetScript("OnMouseWheel", function(scroll, val) scrollbar:SetValue(scrollbar:GetValue() + val*LINEHEIGHT) end)

local orig = scrollbar:GetScript("OnValueChanged")
scrollbar:SetScript("OnValueChanged", function(scrollbar, val, ...)
scroll:SetVerticalScroll(val)
self:SetPoint("TOP", 0, -val)
return orig(scrollbar, val, ...)
end)
else
scroll:SetScript("OnMouseWheel", noop)
end
end

if canCraft then Panda.RefreshButtonFactory(scroll or self, canCraft, "TOPRIGHT", scroll or self, "BOTTOMRIGHT", 4, -3) end
Expand Down
80 changes: 80 additions & 0 deletions tekKonfigScroll.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

local lib, oldminor = LibStub:NewLibrary("tekKonfig-Scroll", 2)
if not lib then return end

lib.bg = {
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
tile = true,
tileSize = 16,
edgeSize = 12,
insets = { left = 0, right = 0, top = 5, bottom = 5 }
}

-- Creates a scrollbar
-- Parent is required, offset and step are optional
function lib.new(parent, offset, step)
local f = CreateFrame("Slider", nil, parent)
f:SetWidth(16)

f:SetPoint("TOPRIGHT", 0 - (offset or 0), -16 - (offset or 0))
f:SetPoint("BOTTOMRIGHT", 0 - (offset or 0), 16 + (offset or 0))

local up = CreateFrame("Button", nil, f)
up:SetPoint("BOTTOM", f, "TOP")
up:SetWidth(16) up:SetHeight(16)
up:SetNormalTexture("Interface\\Buttons\\UI-ScrollBar-ScrollUpButton-Up")
up:SetPushedTexture("Interface\\Buttons\\UI-ScrollBar-ScrollUpButton-Down")
up:SetDisabledTexture("Interface\\Buttons\\UI-ScrollBar-ScrollUpButton-Disabled")
up:SetHighlightTexture("Interface\\Buttons\\UI-ScrollBar-ScrollUpButton-Highlight")

up:GetNormalTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4)
up:GetPushedTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4)
up:GetDisabledTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4)
up:GetHighlightTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4)
up:GetHighlightTexture():SetBlendMode("ADD")

up:SetScript("OnClick", function(self)
local parent = self:GetParent()
parent:SetValue(parent:GetValue() - (step or parent:GetHeight()/2))
PlaySound("UChatScrollButton")
end)

local down = CreateFrame("Button", nil, f)
down:SetPoint("TOP", f, "BOTTOM")
down:SetWidth(16) down:SetHeight(16)
down:SetNormalTexture("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Up")
down:SetPushedTexture("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Down")
down:SetDisabledTexture("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Disabled")
down:SetHighlightTexture("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Highlight")

down:GetNormalTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4)
down:GetPushedTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4)
down:GetDisabledTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4)
down:GetHighlightTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4)
down:GetHighlightTexture():SetBlendMode("ADD")

down:SetScript("OnClick", function(self)
local parent = self:GetParent()
parent:SetValue(parent:GetValue() + (step or parent:GetHeight()/2))
PlaySound("UChatScrollButton")
end)

f:SetThumbTexture("Interface\\Buttons\\UI-ScrollBar-Knob")
local thumb = f:GetThumbTexture()
thumb:SetWidth(16) thumb:SetHeight(24)
thumb:SetTexCoord(1/4, 3/4, 1/8, 7/8)

f:SetScript("OnValueChanged", function(self, value)
local min, max = self:GetMinMaxValues()
if value == min then up:Disable() else up:Enable() end
if value == max then down:Disable() else down:Enable() end
end)

local border = CreateFrame("Frame", nil, f)
border:SetPoint("TOPLEFT", up, -5, 5)
border:SetPoint("BOTTOMRIGHT", down, 5, -3)
border:SetBackdrop(lib.bg)
border:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b, 0.5)

return f, up, down, border
end

0 comments on commit 9f9ea40

Please sign in to comment.