View Single Post
02-17-11, 11:56 AM   #7
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,953
Here's one of my more simple versions of a scroll frame I've used in one of my mock up addons to play with stuff. It's loosely based on the scroll frame code I created for my ScrollingWatchFrame addon but literally just the bare bones.
frame is whatever container frame you want to use to confine the visual part of the scrolling area.
scrollFrame is the scrolling area itself which can be bigger than the container frame.
scrollChild is the frame you do all the work with and assign it to the scrollFrame as a child so that the scrollFrame's scrolling allows you to see parts for the scrollChild's frame.
scrollBar is a pointer to the built in scroll bar component of the base template UIPanelScrollFrameTemplate which handles most of the basic functionality.
scrollSize is a variable to hold the height I want the scrollFrame to be but I assume it could be similarly used as width if you have a horizontal scrollbar rather than a vertical one.

Code:
	frame.scrollSize = missingCount * 40
	
	frame.scrollFrame = CreateFrame( "ScrollFrame", "$parent_ScrollFrame", frame, "UIPanelScrollFrameTemplate" );
	frame.scrollFrame:SetHeight(frame:GetHeight())
	frame.scrollBar = _G[frame.scrollFrame:GetName() .. "ScrollBar"];
    frame.scrollFrame:SetWidth( frame:GetWidth());
	frame.scrollFrame:SetPoint( "TOPLEFT", 10, -30 );
	frame.scrollFrame:SetPoint( "BOTTOMRIGHT", -30, 10 );
	
    frame.scrollChild = CreateFrame( "Frame", "$parent_ScrollChild", frame.scrollFrame );
	frame.scrollChild:SetHeight( frame.scrollSize );
    frame.scrollChild:SetWidth( frame.scrollFrame:GetWidth() );
    frame.scrollChild:SetAllPoints( frame.scrollFrame );
    frame.scrollFrame:SetScrollChild( frame.scrollChild );
It's not brilliant but if you want to see something minimal to help you understand how it works it might be worth looking at. But yssaril's code is very useful to know too.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote