Quantcast
HybridScrollFrame_CreateButtons / buttonTemplate Question - WoWInterface
Thread Tools Display Modes
08-17-15, 02:33 PM   #1
Spiderkeg
A Deviate Faerie Dragon
Join Date: Sep 2006
Posts: 17
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?
  Reply With Quote
08-17-15, 03:12 PM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
No, you can only create templates using XML.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
08-17-15, 03:20 PM   #3
Spiderkeg
A Deviate Faerie Dragon
Join Date: Sep 2006
Posts: 17
Originally Posted by Lombra View Post
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?
  Reply With Quote
08-18-15, 03:55 AM   #4
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
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)
__________________
Grab your sword and fight the Horde!
  Reply With Quote
08-18-15, 07:58 AM   #5
Spiderkeg
A Deviate Faerie Dragon
Join Date: Sep 2006
Posts: 17
Originally Posted by Lombra View Post
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?
  Reply With Quote
08-18-15, 08:46 AM   #6
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
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!
__________________
Grab your sword and fight the Horde!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » HybridScrollFrame_CreateButtons / buttonTemplate Question

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off