Skip to content

Basic Widgets

pwilkowski edited this page Oct 13, 2019 · 10 revisions

Component stability: Beta

What is widget?

Widget in StdUi is a simple table that may (but not must) inherit from blizzard UI objects. Simplest widget possible may look like this:

{
    isWidget = true
}

Basic Widgets:

Frame

StdUi:Frame(parent, width, height, inherits)

Description:

This is the simplest implementation of Frame object that that does not have any backdrop.

Arguments:

Argument Type Optional Description
parent Frame - Object that should be a parent
width number Y Width of the frame
height number Y Height of the frame
inherits string Y Template to inherit from

Returns:

Example:

local frame = StdUi:Frame(UIParent, 50, 50);

Panel

StdUi:Panel(parent, width, height, inherits)

Description:

Similar to Frame widget but has proper backdrop.

Arguments:

Argument Type Optional Description
parent Frame - Object that should be a parent
width number Y Width of the panel
height number Y Height of the panel
inherits string Y Template to inherit from

Returns:

Example:

local panel = StdUi:Panel(UIParent, 100, 100);

Panel With Label

StdUi:PanelWithLabel(parent, width, height, inherits, text)

Description:

Panel that has FontString in the center of frame. That font string is initially anchored to whole frame.

Arguments:

Argument Type Optional Description
parent Frame - Object that should be a parent
width number Y Width of the panel
height number Y Height of the panel
inherits string Y Template to inherit from
text string - Text that should be on the Panel

Returns:

Named children:

  • panel.label - FontString - font string that is used as panel text

Example:

local panel = StdUi:PanelWithLabel(UIParent, 200, 100, nil, 'Some text');

Panel With Title

StdUi:PanelWithTitle(parent, width, height, text, titleWidth, titleHeight)

Description:

Panel that has title bar on the top of it. Title bar is anchored above the actual frame in 50% of its height.

Arguments:

Argument Type Optional Description
parent Frame - Object that should be a parent
width number Y Width of the panel
height number Y Height of the panel
text string Y Text that should be on the title bar
titleWidth number Default: 100 Width of title bar
titleHeight number Default: 20 Height of title bar

Returns:

Named children:

Child Type Description
panel.titlePanel Frame Title bar frame (instance of PanelWithLabel)
panel.titlePanel.label FontString font string that is used as title bar text

Example:

local panel = StdUi:PanelWithTitle(UIParent, 200, 100, 'Title bar', 200, 32);

Texture

StdUi:Texture(parent, width, height, texture)

Description:

This is the simplest implementation of Texture object. By default, textures are drawn on 'ARTWORK' layer.

Arguments:

Argument Type Optional Description
parent Frame - Object that should be a parent
width number Y Width of the texture
height number Y Height of the texture
texture string Y Texture path

Returns:

Example:

local tex = StdUi:Texture(panel, 50, 50, [[Interface\Buttons\SquareButtonTextures]]);

Arrow Texture

StdUi:ArrowTexture(parent, direction)

Description:

Texture object with static size (16 x 8) that uses Interface\Buttons\Arrow-Up-Down:

Note: It is used in scroll bars.

Arguments:

Argument Type Optional Description
parent Frame - Object that should be a parent
direction string Default: 'UP' Direction of arrow: either 'UP' or 'DOWN'

Returns:

Example:

local tex = StdUi:ArrowTexture(panel, 'UP');

Frame/Panel Methods:

All StdUi widgets has custom functions added:

  • GetChildrenWidgets() - Returns table of children widgets.
  • SetFullWidth(flag) - Marks widget for full width when used in auto positioning/layout (true/false).

In addition, all widgets are Frame objects so they inherit all default blizzard methods. Reference can be found:
Here

Texture Methods:

Textures initially are not marked as widgets because they lack ability to have children however they can be marked as widget (if you plan to use AutoPosition). You can do it by:

texture.isWidget = true;

StdUi does not add any custom methods to Texture objects. Texture method reference can be found: Here