Lua
C++
Edit

CreateProgressBar

The progressbar widget displays a horizontal bar that indicates the progress of some task. The progress complete can be set using the Widget:SetProgress method.

Syntax

Parameter Description
x widget X position
y widget Y position
width widget width
height widget height
parent parent widget

Returns

Returns a new progress bar widget.

Example

CreateProgressBar

function UpdateProgress(e, extra)
    local widget = Widget(extra)
    widget:SetProgress((e.data / 20.0) % 1.0)
    return true
end

--Get the displays
local displays = GetDisplays()

--Create a window
local window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[1])

--Create User Interface
local ui = CreateInterface(window)

--Create widget
local sz = ui.background:GetSize()
local widget = CreateProgressBar(20, (sz.y - 30) / 2, sz.x - 40, 30, ui.background)
widget:SetProgress(0.6)

local progresstimer = CreateTimer(500)
ListenEvent(EVENT_TIMERTICK, progresstimer, UpdateProgress, widget)

while true do
    local ev = WaitEvent()
    if ev.id == EVENT_WINDOWCLOSE then
        return 0
    end
end
Copyright © 2024 Ultra Software.
All rights reserved.