LegoBlock

LegoBlock: Embeddable library to provide block functionality. Generated LegoBlocks stick together using Tuller's FlyPaper code. Blocks do not currently stick across majors, though that is under consideration.

Description
LegoBlock lets you create a small block to display information in it like time, performance, haste or anything you can think of! Blocks can be snapped together in any position or order you can do simple things like snap them together into a long line to be positioned at the top of your UI, or you can snap them together in an "L" position and so on.

Theres two methods of snapping blocks together, one is simply to drag it to another block and it'll snap to the closet block for example if you drag block "A" to the bottom of block "B" it'll snap to the bottom, if you snap it to the left side of "B" it'll snap to that side and so on. If you have muultiple blocks and you need to specifically choose which one to snap to then drag block "A" into block "B" and you can choose which side to snap to without it trying to snap to anything else.

Blocks that are snapped togther become a group, if you have A, B and C you can drag any of those 3 and they'll all move together when you want to unsnap a block from a group hold down CTRL and drag it out.

LegoBlock is meant to display information, not as a methods of launching or viewing configuration.

:New(name[, text, icon, optionsTbl])
Creates a new LegoBlock.

Remarks
The optionsTbl is used to store block information and should be of a permanent type storage like a SavedVariables table.

OptionsTbl
Format for the optionsTbl is thus: [width] = int, [height] = int, [text] = string, [icon] = string, [x] = int, [y] = int, [anchor] = string, [showIcon] = boolean, [showText] = boolean, [hidden] = boolean, [appendString] = string, [savedFields] = integer indexed table with extra key/value pairs to fill in

Example
self:New("HelloWorld"[, "My first lego block", nil, {}])

LegoBlock:SetDB(optionsTbl)
Changes the optionsTbl attached to a lego block

Example
self:SetDB({})

LegoBlock:ShowIcon
Shows the icon

Args
None

Remarks
Will automagically position the text on show.

Example
self:ShowIcon

LegoBlock:HideIcon
Hides the icon

Args
None

Remarks
Will automagically position the text on hide.

Example
self:HideIcon

LegoBlock:SetIcon(icon)
Sets the icon

Remarks
Does not automatically show the icon

Example
self:SetIcon

LegoBlock:ShowText
Shows the text

Example
self:ShowText

LegoBlock:HideText
Hides the text

Example
self:HideText

LegoBlock:SetText(text)
Sets the text of the lego block

Remarks
You can set self.optionsTbl.noresize = true to not resize. Does not automagically show the text, you must call ShowText.

Example
self:SetText("Woohooo")