ProgressBar

A UI element that shows a bar, that can be filled to different amounts in multiple orientations.

Visual example of progress bar

Different kinds of porgress bar.

Contents:

Properties

Name

Type

Default

minVal

number

nil

maxVal

number

nil

val

number

nil

x

number

nil

y

number

nil

w

number

nil

h

number

nil

vertical

boolean

false

inverted

boolean

false

style

uilib.Style

Default Style

visible

boolean

true

minVal

Smallest value the progress bar can display.

uilib.ProgressBar.minVal = nil
  • Type: number

  • Default: nil


maxVal

Biggest value the progress bar can display.

uilib.ProgressBar.maxVal = nil
  • Type: number

  • Default: nil


val

Current value the progress bar should display.

uilib.ProgressBar.val = nil
  • Type: number

  • Default: nil


x

X component of the position on the screen.

uilib.ProgressBar.x = nil
  • Type: number

  • Default: nil


y

Y component of the position on the screen.

uilib.ProgressBar.y = nil
  • Type: number

  • Default: nil


w

Width of the progress bar.

uilib.ProgressBar.w = nil
  • Type: number

  • Default: nil


h

Height of the progress bar.

uilib.ProgressBar.h = nil
  • Type: number

  • Default: nil


vertical

Enables vertical mode for the progress bar.

uilib.ProgressBar.vertical = false
  • Type: boolean

  • Default: false


inverted

Enables inverted mode for the progress bar.

uilib.ProgressBar.inverted = false
  • Type: boolean

  • Default: false


style

Style of the progress bar.

uilib.ProgressBar.style = uilib.Style:new()

visible

Contains information about the progress bar being visible or not.

uilib.ProgressBar.visible = true
  • Type: boolean

  • Default: true

Note

Please use show() to enable visibility and hide() to disable visibility of the progress bar.


Functions

new()

Function to create a new instance of ProgressBar.

function M.ProgressBar:new(minVal, maxVal, val, x, y, w, h, vertical, inverted, style)
  ...
  return prog
end

Arguments:

Name

Type

Default

Description

minVal

number

nil

Smallest value the progress bar can display.

maxVal

number

nil

Biggest value the progress bar can display.

val

number

nil

Current value the progress bar should display.

x

number

nil

X component of position of the progress bar.

y

number

nil

Y component of position of the progress bar.

w

number

nil

Width of the progress bar.

h

number

nil

Height of the progress bar.

vertical

boolean

false

Enables vertical mode for the progres bar.

inverted

boolean

false

Enables inverted mode for the progres bar.

style

uilib.Style

Default Style

Style of the progress bar.

Note

Progress bars can only use the default state for styling.

Returns:

Type

Description

uilib.ProgressBar

Instance of ProgressBar with specified properties.

Example:

local uilib = require("uilib")
local prog = uilib.ProgressBar:new(0, 100, 35, 2, 2, 10, 1, false, false, uilib.Style:new())

This would create an instance of ProgressBar with possible values between 0 and 100 and an initial value of 35. The progress bar would be displayed at the position (2, 2) and would be 10 x 1 pixels in size. It would be in horizontal mode, since vertical is set to false. The style of the progress bar will be the default style.


draw()

Function to draw the progress bar.

function M.ProgressBar:draw()
  ...
end

Arguments: nil

Returns: nil

Example:

local uilib = require("uilib")
local prog = uilib.ProgressBar:new(0, 100, 35, 2, 2, 10, 1, false, false, uilib.Style:new())
prog:draw()

This would create an instance of ProgressBar and draw it to the screen.


show()

Function to make the progress bar visible.

function uilib.ProgressBar:show()
    ...
end

Arguments: nil

Returns: nil

Example:

local uilib = require("uilib")
local prog = uilib.ProgressBar:new(0, 100, 35, 2, 2, 10, 1, false, false, uilib.Style:new())
prog:show()

This would create an instance of ProgressBar and make it visible.


hide()

Function to make the progress bar invisible.

function uilib.ProgressBar:hide()
  ...
end

Arguments: nil

Returns: nil

Example:

local uilib = require("uilib")
local prog = uilib.ProgressBar:new(0, 100, 35, 2, 2, 10, 1, false, false, uilib.Style:new())
prog:hide()

This would create an instance of ProgressBar and make it invisible.