1
0
mirror of https://github.com/kepler155c/opus synced 2024-06-16 10:19:59 +00:00
opus/sys/modules/opus/ui/components/ProgressBar.lua
kepler155c 7224d441ca
Ui enhancements 2.0 (#31)
* canvas overhaul

* minor tweaks

* list mode for overview

* bugfixes + tweaks for editor 2.0

* minor tweaks

* more editor work

* refactor + new transitions

* use layout() where appropriate and cleanup

* mouse triple click + textEntry scroll ind

* cleanup

* cleanup + theme editor

* color rework + cleanup

* changes for deprecated ui methods

* can now use named colors
2020-04-21 22:40:59 -06:00

37 lines
967 B
Lua

local class = require('opus.class')
local UI = require('opus.ui')
UI.ProgressBar = class(UI.Window)
UI.ProgressBar.defaults = {
UIElement = 'ProgressBar',
backgroundColor = 'gray',
height = 1,
progressColor = 'lime',
progressChar = UI.extChars and '\153' or ' ',
fillChar = ' ',
fillColor = 'gray',
textColor = 'green',
value = 0,
}
function UI.ProgressBar:draw()
local width = math.ceil(self.value / 100 * self.width)
self:fillArea(width + 1, 1, self.width - width, self.height, self.fillChar, nil, self.fillColor)
self:fillArea(1, 1, width, self.height, self.progressChar, self.progressColor)
end
function UI.ProgressBar.example()
return UI.ProgressBar {
x = 2, ex = -2, y = 2, height = 2,
focus = function() end,
enable = function(self)
require('opus.event').onInterval(.25, function()
self.value = self.value == 100 and 0 or self.value + 5
self:draw()
self:sync()
end)
return UI.ProgressBar.enable(self)
end
}
end