View Single Post
02-18-11, 12:43 AM   #8
hankthetank
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 64
Lightbulb

The "real" scroll frame template (not the faux one) is pretty self-explanatory.

Create a scroll frame derived from UIPanelScrollFrameTemplate and a content host:

lua Code:
  1. local f = CreateFrame("Frame") -- Your window
  2. ...
  3. f.scroll = CreateFrame("ScrollFrame", "myScrollFrame", f, "UIPanelScrollFrameTemplate")
  4. --[[
  5.   Position and style the scrollframe. Here you could do things like...
  6.   _G["myScrollFrameScrollBarScrollUpButton"]:SetNormalTexture(....)
  7.   See http://wowprogramming.com/utils/xmlbrowser/diff/FrameXML/UIPanelTemplates.xml
  8. ]]
  9. f.content = CreateFrame("Frame", nil, f.scroll)
  10. f.content:SetSize(f.scroll:GetWidth(), 0) -- Vert scroll only (*)
  11. f.scroll:SetScrollChild(f.content)

*: If your main window / scroll frame layout is resizable and your scroll frame unidirectional make sure to resize the content host when the scroll frame's size changed:

lua Code:
  1. f.scroll:SetScript("OnSizeChanged", function(_, w, h) f.content:SetWidth(w) end)

After you fill your scroll child with content make sure to set the points

lua Code:
  1. local myHugeFontString = f.content:CreateFontString()
  2.  
  3. myHugeFontString:SetPoint("TOPLEFT")
  4. myHugeFontString:SetPoint("TOPRIGHT") -- Vert scroll only
  5. myHugeFontString:SetFont.....
  6. myHugeFontString:SetText(alotOfText)
  7.  
  8. -- Resize content area
  9. f.content:SetPoint("BOTTOM", myHugeFontString)

That's like 10 lines of code. Idk why you would need a library for this. And since your content is so static, you don't need to recycle anything neither. All you really do is

lua Code:
  1. aButtonInTheLeftScrollFrame:SetScript("OnClick", function()
  2.     myHeaderTextFontStringInTheRightScrollFrame:SetText(....)
  3.     myBodyTextFontStringInTheRightScrollFrame:SetText(....)
  4. end)

Last edited by hankthetank : 02-18-11 at 05:52 AM.
  Reply With Quote