Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TWW - Redo scrolls with WoWScrollBoxList #233

Open
mbattersby opened this issue Jun 9, 2024 · 1 comment
Open

TWW - Redo scrolls with WoWScrollBoxList #233

mbattersby opened this issue Jun 9, 2024 · 1 comment

Comments

@mbattersby
Copy link
Collaborator

mbattersby commented Jun 9, 2024

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)
@mbattersby
Copy link
Collaborator Author

Hol up, check if this works in Classic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant