TWW - Redo scrolls with WoWScrollBoxList
mbattersby opened this issue ยท 1 comments
Inherit from WoWScrollBox list also add an EventFrame scrollbar.
local view = CreateScrollBoxListLinearView()
view:SetElementInitializer("ListEntryButtonTemplate", ButtonInitFunction)
ScrollUtil.InitScrollBoxListWithScrollBar(ScrollBox, ScrollBar, view)
local dataProvider = CreateDataProvider(listOfElements)
scrollBox:SetDataProvider(dataProvider, ScrollBoxConstants.RetainScrollPosition)
This would also make it possible to support Drag re-ordering. Below is half an implementation.
local function LineFactory(elementData)
return "ScrollBoxDragLineTemplate"
end
local function AnchoringHandler(anchorFrame, candidateFrame, candidateArea)
if candidateArea == DragIntersectionArea.Above then
anchorFrame:SetPoint("BOTTOMLEFT", candidateFrame, "TOPLEFT", 0, 0)
anchorFrame:SetPoint("BOTTOMRIGHT", candidateFrame, "TOPRIGHT", 0, 0)
elseif candidateArea == DragIntersectionArea.Below then
anchorFrame:SetPoint("TOPLEFT", candidateFrame, "BOTTOMLEFT", 0, 0)
anchorFrame:SetPoint("TOPRIGHT", candidateFrame, "BOTTOMRIGHT", 0, 0)
end
end
-- This inits the object that the cursor drags around representing the source button
local function Initializer(button, sourceButton)
-- want to call the original button initializer but disable all the interactivity
end
-- This creates the object that the cursor drags around representing the source button
local function CursorFactory(elementData)
return "PandaGemEntryTemplate", Initializer
end
local dragBehavior = ScrollUtil.AddLinearDragBehavior(ScrollBox, CursorFactory, LineFactory, AnchoringHandler)
dragBehavior:SetReorderable(true)
dragBehavior:SetDragRelativeToCursor(true)
dragBehavior:SetNotifyDragSource(
function (sourceFrame, drag)
sourceFrame:SetAlpha(drag and .5 or 1)
sourceFrame:DesaturateHierarchy(drag and 1 or 0)
sourceFrame:SetMouseMotionEnabled(not drag)
end)
dragBehavior:SetNotifyDragCandidates(
function (candidateFrame, drag)
candidateFrame:SetMouseMotionEnabled(not drag)
end)
dragBehavior:SetSourceDragCondition(
function (sourceFrame, sourceElementData)
return true
end)