Class SortBox

An H/VBox alternative which can be set to either vertical or horizontal, and will autosort the windows

Info:

  • Copyright: 2020 Damian Monogue
  • License: MIT, see LICENSE.lua
  • Author: Damian Monogue

Tables

SortBox.SortFunctions Sorting functions for spairs, should you wish

Methods

SortBox:new(options[, container]) Creates a new SortBox
SortBox:organize() Calling this will cause the SortBox to reposition/resize everything
SortBox:enableElastic() Enables elasticity for the SortBox.
SortBox:disableElastic() Disables elasticity for the SortBox
SortBox:setElastic(enabled) Set elasticity specifically
SortBox:setMaxWidth(maxWidth) Set the max width of the SortBox if it's elastic
SortBox:setMaxHeight(maxHeight) Set the max height of the SortBox if it's elastic
SortBox:enableTimer() Starts the SortBox sorting and organizing itself on a timer
SortBox:disableTimer() Stops the SortBox from sorting and organizing itself on a timer
SortBox:setSortInterval(sortInterval) Sets the sortInterval, or amount of time in milliseconds between auto sorting on a timer if timerSort is true
SortBox:enableSort() Enables sorting when items are added/removed, or if timerSort is true, every sortInterval milliseconds
SortBox:disableSort() Disables sorting when items are added or removed
SortBox:setBoxType(boxType) Set whether the SortBox acts as a VBox or HBox.
SortBox:setSortFunction(functionName) Sets the type of sorting in use by this SortBox.


Tables

SortBox.SortFunctions
Sorting functions for spairs, should you wish

Fields:

  • gaugeValue sorts Geyser gauges by value, ascending
  • reverseGaugeValue sorts Geyser gauges by value, descending
  • timeLeft sorts TimerGauges by how much time is left, ascending
  • reverseTimeLeft sorts TimerGauges by how much time is left, descending.
  • name sorts Geyser objects by name, ascending
  • reverseName sorts Geyser objects by name, descending
  • message sorts Geyser labels and gauges by their echoed text, ascending
  • reverseMessage sorts Geyser labels and gauges by their echoed text, descending

Methods

SortBox: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 options
    option 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
    elastic Should this container stretch to fit its contents? boxType v stretches in height, h stretches in width. false
    maxHeight If elastic, what's the biggest a 'v' style box should grow in height? Use 0 for unlimited 0
    maxWidth If elastic, what's the biggest a 'h' style box should grow in width? Use 0 for unlimited 0
    (optional)

Usage:

    mySortBox = SortBox:new({
      name = "mySortBox",
      x = 400,
      y = 100,
      height = 150,
      width = 300,
      sortFunction = "timeLeft"
    })
SortBox:organize()
Calling this will cause the SortBox to reposition/resize everything
SortBox:enableElastic()
Enables elasticity for the SortBox.
SortBox:disableElastic()
Disables elasticity for the SortBox
SortBox:setElastic(enabled)
Set elasticity specifically

Parameters:

  • enabled boolean if true, enable elasticity. If false, disable it.
SortBox:setMaxWidth(maxWidth)
Set the max width of the SortBox if it's elastic

Parameters:

  • maxWidth number The maximum width in pixels to resize the SortBox to. Use 0 for unlimited.
SortBox:setMaxHeight(maxHeight)
Set the max height of the SortBox if it's elastic

Parameters:

  • maxHeight number The maximum height in pixels to resize the SortBox to. Use 0 for unlimited.
SortBox:enableTimer()
Starts the SortBox sorting and organizing itself on a timer
SortBox:disableTimer()
Stops the SortBox from sorting and organizing itself on a timer
SortBox: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
SortBox:enableSort()
Enables sorting when items are added/removed, or if timerSort is true, every sortInterval milliseconds
SortBox:disableSort()
Disables sorting when items are added or removed
SortBox: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
SortBox: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")
generated by LDoc 1.4.6 Last updated 2020-08-25 15:14:20