ProgressBar

Package: Libraries.Interface.Controls · Inherits from: Libraries.Interface.Item, Libraries.Interface.Controls.Control, Libraries.Interface.Item2D, Libraries.Language.Object

The ProgressBar class shows how far along a task is, as a rounded bar that fills from left to right. The fill covers the share of the bar between the minimum and the maximum value, which are 0 and 100 by default. The track takes the background color and the fill takes the foreground color, from the interface options under the key "ProgressBar". Screen readers are told each time the value changes.

Example Code

use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page
use Libraries.Interface.Controls.ProgressBar

Form form
Page page = form:GetMainPage()

page:AddLabel("Loading")
ProgressBar bar = page:AddProgressBar("Loading", 0, 10)
bar:SetValue(3)

form:Display()

Actions

GetMaximum()

This action returns the largest value of the progress bar. At this value the bar is full. The default is 100.

Returns

number: The maximum value.

GetMinimum()

This action returns the smallest value of the progress bar. At this value the bar is empty. The default is 0.

Returns

number: The minimum value.

GetValue()

This action returns the current value of the progress bar.

Returns

number: The current value.

Example

use Libraries.Interface.Controls.ProgressBar
ProgressBar bar
bar:SetValue(25)
number value = bar:GetValue()

LoadGraphics(Libraries.Interface.Layouts.LayoutProperties properties)

This action loads the graphics for the progress bar. The first time, it gives the bar and its fill their views. Then it colors the fill with the foreground color, rounds both ends of the bar and the fill, places the fill inside the bar's edge, and sizes the fill to the value. The game engine calls this as needed, so most users won't need to call it directly.

Parameters

SetInterfaceOptionsKey(text key)

This action sets the key used to look up the progress bar's look in the interface options. The filled part of the bar uses the same key, so both take their colors from the same options.

Parameters

  • key text: The interface options key, such as "ProgressBar".

Example

use Libraries.Interface.Controls.ProgressBar
ProgressBar bar
bar:SetInterfaceOptionsKey("ProgressBar")

SetMaximum(number maximum)

This action sets the largest value of the progress bar. At this value the bar is full. The default is 100. The fill is resized the next time the value is set or the bar is drawn again.

Parameters

  • maximum number: The maximum value.

Example

use Libraries.Interface.Controls.ProgressBar
ProgressBar bar
bar:SetMaximum(10)
bar:SetValue(4)

SetMinimum(number minimum)

This action sets the smallest value of the progress bar. At this value the bar is empty. The default is 0. The fill is resized the next time the value is set or the bar is drawn again.

Parameters

  • minimum number: The minimum value.

Example

use Libraries.Interface.Controls.ProgressBar
ProgressBar bar
bar:SetMinimum(0)
bar:SetMaximum(10)
bar:SetValue(4)

SetValue(number value)

This action sets the current value of the progress bar and resizes the fill to show it. The fill covers the share of the bar between the minimum and the maximum; a value outside the range shows an empty or full bar. Screen readers are told of the change.

Parameters

  • value number: The new value.

Example

use Libraries.Game.Game
use Libraries.Interface.Controls.ProgressBar

class Main is Game
    ProgressBar bar
    number done = 0

    action Main
        StartGame()
    end

    action CreateGame
        bar:SetName("Download")
        bar:SetPosition(100, 100)
        Add(bar)
    end

    action Update(number seconds)
        if done < 100
            done = done + seconds * 10
            bar:SetValue(done)
        end
    end
end

Inherited Actions

262 actions from Libraries.Interface.Controls.Control
61 actions from Libraries.Interface.Item
202 actions from Libraries.Interface.Item2D
3 actions from Libraries.Language.Object