Module SortBox
An H/VBox alternative which can be set to either vertical or horizontal, and will autosort the windows
Functions
organize () | Calling this will cause the SortBox to reposition/resize everything |
enableTimer () | Starts the SortBox sorting and organizing itself on a timer |
disableTimer () | Stops the SortBox from sorting and organizing itself on a timer |
setSortInterval (sortInterval) | Sets the sortInterval, or amount of time in milliseconds between auto sorting on a timer if timerSort is true |
enableSort () | Enables sorting when items are added/removed, or if timerSort is true, every sortInterval milliseconds |
disableSort () | Disables sorting when items are added or removed |
setBoxType (boxType) | Set whether the SortBox acts as a VBox or HBox. |
setSortFunction (functionName) | Sets the type of sorting in use by this SortBox. |
new (options[, container]) | Creates a new SortBox |
Functions
- organize ()
- Calling this will cause the SortBox to reposition/resize everything
- enableTimer ()
- Starts the SortBox sorting and organizing itself on a timer
- disableTimer ()
- Stops the SortBox from sorting and organizing itself on a timer
- setSortInterval (sortInterval)
-
Sets the sortInterval, or amount of time in milliseconds between auto sorting on a timer if timerSort is true
Parameters:
- sortInterval number time in milliseconds between auto sorting if timerSort is true
- enableSort ()
- Enables sorting when items are added/removed, or if timerSort is true, every sortInterval milliseconds
- disableSort ()
- Disables sorting when items are added or removed
- setBoxType (boxType)
-
Set whether the SortBox acts as a VBox or HBox.
Parameters:
- boxType string If you pass 'h' or 'horizontal' it will act like an HBox. Anything else it will act like a VBox.
Usage:
mySortBox:setBoxType("v") -- behave like a VBox mySortBox:setBoxType("h") -- behave like an HBox mySortBox:setBoxType("beeblebrox") -- why?! Why would you do this? It'll behave like a VBox
- setSortFunction (functionName)
-
Sets the type of sorting in use by this SortBox.
If an item in the box does not have the appropriate property or function, then 999999999 is used for sorting except as otherwise noted.
If an invalid option is given, then existing H/VBox behaviour is maintained, just like if autoSort is false.Parameters:
- functionName
string
what type of sorting should we use? See table below for valid options and their descriptions.
sort type description gaugeValue sort gauges based on how full the gauge is, from less full to more reverseGaugeValue sort gauges based on how full the gauge is, from more full to less timeLeft sort TimerGauges based on the total time left in the gauge, from less time to more reverseTimeLeft sort TimerGauges based on the total time left in the gauge, from more time to less name sort any item (and mixed types) by name, alphabetically. reverseName sort any item (and mixed types) by name, reverse alphabetically. message sorts Labels based on their echoed message, alphabetically. If not a label, the empty string will be used reverseMessage sorts Labels based on their echoed message, reverse alphabetically. If not a label, the empty string will be used
Usage:
mySortBox:setSortFunction("gaugeValue")
- functionName
string
what type of sorting should we use? See table below for valid options and their descriptions.
- new (options[, container])
-
Creates a new SortBox
Parameters:
- options table the options to use for the SortBox. See table below for added options
- container
the container to add the SortBox into
Table of new optionsoption name description default autoSort should the SortBox perform function based sorting? If false, will behave like a normal H/VBox true timerSort should the SortBox automatically perform sorting on a timer? true sortInterval how frequently should we sort on a timer if timerSort is true, in milliseconds 500 boxType Should we stack like an HBox or VBox? use 'h' for hbox and 'v' for vbox v sortFunction how should we sort the items in the SortBox? see setSortFunction for valid options gaugeValue
Usage:
mySortBox = SortBox:new({ name = "mySortBox", x = 400, y = 100, height = 150, width = 300, sortFunction = "timeLeft" })