Skip to content

Scroll Frames

wutname1 edited this page May 12, 2019 · 1 revision

Component stability: Beta

StdUi has 2 scroll frames:

Scroll Frame

StdUi:ScrollFrame(parent, width, height, scrollChild)

Description:

This is the simplest implementation of ScrollFrame. It's worth to note that implementation is completely different from blizzard. What does that mean?

  • ScrollBar is inside of the element.
  • Whole ScrollFrame is embedded on Panel (Frame).
  • ScrollChild will have smaller width by approximately 18 pixels (17px for ScrollBar and 3x1px for padding)
  • None of the elements have name, everything is kept private (as named children).

In practice, it means that it will keep the constraints of width/height or anchors. Nothing will be drawn outside of panel.

Arguments:

  • parent Frame - object that should be a parent of EditBox
  • width number (Optional) - Width of the EditBox
  • height number (Optional) - Height of the EditBox
  • scrollChild Frame (Optional) - Frame that should be used as ScrollChild, if you don't provide any element, new blank Frame will be created.

Returns:

Example:

local panel, scrollFrame, scrollChild, scrollBar = StdUi:ScrollFrame(window, 200, 400);

Faux Scroll Frame

StdUi:FauxScrollFrame(parent, width, height, displayCount, lineHeight, scrollChild)

Description: Works pretty much the same as ScrollFrame however it does not have smooth scroll and only display a certain amount of items.

Note: FauxScrollFrame must know how many of the items are inside and how much it can display at once.

Arguments:

  • parent Frame - object that should be a parent of EditBox
  • width number (Optional) - Width of the EditBox
  • height number (Optional) - Height of the EditBox
  • displayCount number - Amount of items to display at once
  • lineHeight number - Height of each item inside
  • scrollChild Frame (Optional) - Frame that should be used as ScrollChild, if you don't provide any element, new blank Frame will be created.

Methods:

  • scrollFrame:Update() - Forces redraw if you decide to change lineHeight or displayCount
  • scrollFrame:UpdateItemsCount(newCount) - Updates the total amount of items in ScrollChild and redraws. It is required if you dynamically change amount of items.

Named children:

  • scrollFrame.lineHeight - Line height you provided when creating widget, it is used when redraw/scroll occurs
  • scrollFrame.displayCount - Display count you provided when creating widget, it is used when redraw/scroll occurs

Returns:

Example:

local panel, scrollFrame, scrollChild, scrollBar = StdUi:FauxScrollFrame(window, 200, 400, 10, 21);