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 line 29
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]) line 144
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:

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

Parameters:

  • enabled boolean if true, enable elasticity. If false, disable it.
sortbox:setMaxWidth(maxWidth) line 389
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) line 398
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() line 406
Starts the SortBox sorting and organizing itself on a timer
sortbox:disableTimer() line 417
Stops the SortBox from sorting and organizing itself on a timer
sortbox:setSortInterval(sortInterval) line 425
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() line 436
Enables sorting when items are added/removed, or if timerSort is true, every sortInterval milliseconds
sortbox:disableSort() line 442
Disables sorting when items are added or removed
sortbox:setBoxType(boxType) line 451
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) line 508
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.5.0 Last updated 2023-05-29 18:41:27