WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   HybridScrollFrame_CreateButtons / buttonTemplate Question (https://www.wowinterface.com/forums/showthread.php?t=52623)

Spiderkeg 08-17-15 02:33 PM

HybridScrollFrame_CreateButtons / buttonTemplate Question
 
First off, thanks in advance.

I have created a working hybrid scroll frame using the HybridScrollFrame API. However, my question revolves around the HybridScrollFrame_CreateButtons function:

Code:

function HybridScrollFrame_CreateButtons (self, buttonTemplate, initialOffsetX, initialOffsetY, initialPoint, initialRelative, offsetX, offsetY, point, relativePoint)
                ...
                button = CreateFrame("BUTTON", buttonName .. 1, scrollChild, buttonTemplate);

The function requires a buttonTemplate param to be passed in, and at the moment I have a simple XML file with a few lines of code for a button, that's it.

I would prefer to keep everything as Lua, so is there any way for me to create a template using Lua that I can pass into this function and that will actually work?

I realize that, as a fallback solution, I could duplicate this function and alter it to fit my simple needs, but before doing so I figure I'd ask here.

Any thoughts?

Lombra 08-17-15 03:12 PM

No, you can only create templates using XML.

Spiderkeg 08-17-15 03:20 PM

Quote:

Originally Posted by Lombra (Post 310403)
No, you can only create templates using XML.

So if I want an all-Lua solution, creating my own function based on the given Blizzard function would be my best option, yes?

Lombra 08-18-15 03:55 AM

Yeah, or you can reuse some of the original function for some initialization logic. I've done this myself numerous times for hybrid scrolls. I don't use it any longer, but this is what I found in some old code:
Code:

local BUTTON_HEIGHT = 18
local BUTTON_OFFSET = 2

local buttons = {}
scrollFrame.buttons = buttons

for i = 1, (ceil(scrollFrame:GetHeight() / BUTTON_HEIGHT) + 1) do
        local button = createButton(scrollFrame.scrollChild)
        if i == 1 then
                button:SetPoint("TOPLEFT", 2, -1)
        else
                button:SetPoint("TOPLEFT", buttons[i - 1], "BOTTOMLEFT", 0, -BUTTON_OFFSET)
        end
        buttons[i] = button
end

HybridScrollFrame_CreateButtons(scrollFrame, nil, nil, nil, nil, nil, nil, -BUTTON_OFFSET)


Spiderkeg 08-18-15 07:58 AM

Quote:

Originally Posted by Lombra (Post 310415)
Yeah, or you can reuse some of the original function for some initialization logic. I've done this myself numerous times for hybrid scrolls. I don't use it any longer, but this is what I found in some old code:
Code:

local BUTTON_HEIGHT = 18
local BUTTON_OFFSET = 2

local buttons = {}
scrollFrame.buttons = buttons

for i = 1, (ceil(scrollFrame:GetHeight() / BUTTON_HEIGHT) + 1) do
        local button = createButton(scrollFrame.scrollChild)
        if i == 1 then
                button:SetPoint("TOPLEFT", 2, -1)
        else
                button:SetPoint("TOPLEFT", buttons[i - 1], "BOTTOMLEFT", 0, -BUTTON_OFFSET)
        end
        buttons[i] = button
end

HybridScrollFrame_CreateButtons(scrollFrame, nil, nil, nil, nil, nil, nil, -BUTTON_OFFSET)


Fascinating, thank you. I can't help but be curious, what is your approach now?

Lombra 08-18-15 08:46 AM

Well, I still do essentially the same thing, but I've made a small framework out of it, implementing more of the logic myself and making some other changes allowing me deploy and use scroll frames quickly. At the core it still uses some of the hybrid scroll functions provided by Blizzard. I found myself using these scroll frames in many projects, so it seemed worth the effort!


All times are GMT -6. The time now is 04:54 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI