Thread Tools Display Modes
02-17-11, 12:23 AM   #1
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Scrolling frames.

Anyone have suggestions on where to start with making scrolling frames? Working on in game help system. trying to make two, the left fame with text buttons that are the various section titles when clicked on it would load the text for that header into the frame on the right. both frames would need to be scrollable.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
02-17-11, 10:35 AM   #2
kneeki
A Flamescale Wyrmkin
 
kneeki's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 134
Pretty sure there is a WoWAce Lib which helps with the creation of exactly this. Don't recall the name off hand though.
  Reply With Quote
02-17-11, 10:41 AM   #3
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Well it looks like dewdroplib has scroll frame templates in it but i cant find any decent documentation on it. Im using the optionsassist lib by vrul and the AceGUI lib's already which also has scroll frame templates in it but im not sure how to get my help window frame to use it lol.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
02-17-11, 11:12 AM   #4
yssaril
A Warpwood Thunder Caller
 
yssaril's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 96
here is what i am currently using (pick and chose the sections you want)

Code:
local addonname, addon = ...

local backdrop = {
	bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
	edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 16,
	insets = { left = 4, right = 3, top = 4, bottom = 3 }
}

local function ScrollframeOnSizeChanged(frame, width, height)
	frame:GetScrollChild():SetWidth(width)
end

local counter = 0
local function Constructor()
	counter = counter + 1

	local box = CreateFrame("frame", nil, UIParent)
		box:SetWidth(100)
		box:SetHeight(100)
		box:SetBackdrop(backdrop)
		box:SetBackdropColor(0, 0, 0)
		box:SetBackdropBorderColor(0.4, 0.4, 0.4)
	
	local scroll = CreateFrame("ScrollFrame", addonname.."ScrollFrame"..counter, box, "UIPanelScrollFrameTemplate")
		scroll:SetPoint("TOPLEFT", box, 5, -5)
		scroll:SetPoint("BOTTOMRIGHT", box, -26, 4)
		scroll:EnableMouse(true)
	box.scroll = scroll
	box.scrollbar = _G[addonname.."ScrollFrame"..counter.."ScrollBar"]
	
	local child = CreateFrame("frame", addonname.."ScrollFramechild"..counter, scroll)
		child:SetWidth(scroll:GetWidth())
	box.child = child
	
	scroll:SetScrollChild(child)
	scroll:SetScript("OnSizeChanged", ScrollframeOnSizeChanged)

	return box
end

local function Neutralizer(box)
	box:SetParent(UIParent)
	box.scrollbar:SetValue(0)
	box:Hide()
end

addon:RegisterWidget("scrollframe", Constructor, Neutralizer)
important things to look at is the local scroll and the local child (frame is just for background and better positioning)

then all you have to do is change the height of the child and the rest gets set by the template blizzard gives us (everything you want scrolled needs to be anchored and parented to he child frame)

If you go the route of the template then you need to give the frame a name otherwise it will simply toss errors at you.

Last edited by yssaril : 02-17-11 at 11:16 AM.
  Reply With Quote
02-17-11, 11:26 AM   #5
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
ooooo an all lua no library necessary version! exactly what i was looking for. I will play with this see if i can get it to work thank you!

Just looking at it... that register widget part? does the bliz api understand that or is that a function coming from elsewhere? what exactly does registerwidget do?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 02-17-11 at 11:34 AM.
  Reply With Quote
02-17-11, 11:43 AM   #6
yssaril
A Warpwood Thunder Caller
 
yssaril's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 96
Originally Posted by Grimsin View Post
ooooo an all lua no library necessary version! exactly what i was looking for. I will play with this see if i can get it to work thank you!

Just looking at it... that register widget part? does the bliz api understand that or is that a function coming from elsewhere? what exactly does registerwidget do?
its my own API sorry i created a small widget recycler so i can make widgets use them and then toss them back and reuse them

Recycler looks like this
Code:
local addonname, addon = ...

function addon:RegisterWidget(name, constructor, neutralizer)
	self.widgetconstructors = self.widgetconstructors or {}
	self.widgetneutalizers = self.widgetneutalizers or {}
	self.widgetconstructors[name] = constructor
	self.widgetneutalizers[name] = neutralizer
end

local pool = {}
function addon:GetWidget(name, parent)
	local widget
	if self.widgetconstructors[name] then
		if pool[name] and next(pool[name]) then
			widget = table.remove(pool[name])
		else
			widget = self.widgetconstructors[name]()
			_G[addonname.."Widgets"] = _G[addonname.."Widgets"] or {} --toss all widgets into _G but in their own table so we don't polute _G
			_G[addonname.."Widgets"][name] = _G[addonname.."Widgets"][name] or {}
			_G[addonname.."Widgets"][name][#_G[addonname.."Widgets"][name]+1] = widget
			widget.__name = name
		end
	else
		error("Invalid widget name: "..name)
	end
	if parent then
		widget:SetParent(parent)
	end
	return widget
end

function addon:ReturnWidget(widget)
	local name = widget.__name
	self.widgetneutalizers[name](widget)
	pool[name] = pool[name] or {}
	table.insert(pool[name], widget)
	return nil
end
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Scrolling frames.


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