Thread Tools Display Modes
07-09-09, 01:50 AM   #1
Tymesink
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 22
Scroll Frames...*Sigh*.. revisted

So I've had time recently to work on an addon and I'm getting stuck with the FauxScrollFrame stuff.

So I'm getting the data to display and it all works if when my data list count is more than or equal to my MAX_ROWS. If my data list count is less than the MAX_ROWS then the entire list doesn't show anymore.

MAX_ROWS is set to 11.
MAX_HEIGHT is set to 20.

Code:
function addon:AddFrames()
	local frameDesc = "Below is the list of Set Events" 
	frames.eventsFrame = createFrame("EventEQEvents",gmd,260,276,"TOPLEFT","BOTTOMLEFT",3,4,"EventEQ Events",frameDesc);
	
	frames.scroll = self:CreateScrollFrame(frames.eventsFrame,215,195,10,-65);
	frames.rows = self:CreateRows(frames.scroll,210);
	scrollUpdate();
end
Code:
local function scrollUpdate()
	local list = db.events;
	
	FauxScrollFrame_Update(frames.scroll,#list,MAX_ROWS,ROW_HEIGHT)
	local offset = FauxScrollFrame_GetOffset(frames.scroll)

	for i = 1, MAX_ROWS do
		local index = i + offset;	
		if index < #list then
			local b = _G[MODNAME.."ScrollButton"..i];
			b.event:SetText(list[index].event);
			b.set:SetText(list[index].set)
			b.talent:SetText(list[index].talent)
			_G[MODNAME.."ScrollButton"..i]:Show();
		else
			_G[MODNAME.."ScrollButton"..i]:Hide()
		end
	end
end
Code:
function addon:CreateScrollFrame(parentFrame, width, height,x_offset,y_offset)
	local frame = CreateFrame("ScrollFrame", MODNAME.."ScrollFrame", parentFrame, "FauxScrollFrameTemplate");
	frame:SetWidth(width)
	frame:SetHeight(height)
	frame:SetPoint("TOPLEFT", parentFrame, "TOPLEFT", x_offset, y_offset)
	frame:SetBackdrop({
		bgFile="",
		edgeFile="Interface\\Tooltips\\UI-Tooltip-Border",
		tile="true",
		tileSize= 32,
		edgeSize=10,
		insets = {left=5, right=5, top=5, bottom=5}
	})
	frame:SetBackdropBorderColor(0,.5,0,1)
	frame:SetScript("OnVerticalScroll", function(self, offset) FauxScrollFrame_OnVerticalScroll(self, offset, ROW_HEIGHT, scrollUpdate) end)
	frame:SetScript("OnShow", scrollUpdate);
	
	return frame;
end
Code:
function addon:CreateRows(frame,width)
	local rows = {};
	for i = 1,MAX_ROWS do
		local b
		if i == 1 then
			b = CreateFrame("Button", MODNAME.."ScrollButton"..i, frame)
			b:SetPoint("TOPLEFT", 2,-5)
		else
			b = CreateFrame("Button", MODNAME.."ScrollButton"..i, _G[MODNAME.."ScrollButton"..(i-1)])
			b:SetPoint("TOPLEFT", _G[MODNAME.."ScrollButton"..(i-1)], "BOTTOMLEFT", 0, 4)
		end
		
		b:SetNormalFontObject("GameFontNormalSmall")
		b:RegisterForClicks("RightButtonUp")
		b:SetWidth(width)
		b:SetHeight(ROW_HEIGHT)
		
		b.index = i;		
		b:SetScript("OnClick", 
			function()
				table.remove(db.events,b.index);
				scrollUpdate();
				addon:Print("Deleted!");
			end
		)
		
		b.event = b:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
		b.event:SetPoint("TOPLEFT", b, "TOPLEFT", 0, -6)
				
		b.set = b:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
		b.set:SetPoint("TOPLEFT", b.event, "TOPLEFT", 100, 0)
			
		b.talent = b:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
		b.talent:SetPoint("TOPLEFT", b.set, "TOPLEFT", 50, 0)
			
		rows[i] = b;
	end
	
	return rows;
end
if I'm going about this all wrong please let me know. I've been looking at and reviewing other ppl's addon trying to get a clue on how to do this. But somewhere I'm just missing it and I can't figure this out.

I've also been searching google for examples and not having any luck finding answers there either.

Any advice would be greatly appreciated.


(I would like to stay with lau script for frame creation rather using xml for a solution if that is at all possible)

Last edited by Tymesink : 07-09-09 at 01:56 AM.
  Reply With Quote
07-09-09, 08:07 PM   #2
Tymesink
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 22
Problem solved. Solution found here:

http://forums.wowace.com/showthread.php?t=16785
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Scroll Frames...*Sigh*.. revisted


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