mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
* improve example gui. Add simple pages * return old progress bar with example * base progress with steps, there is bug with step? 1 ~= 1, small delta? * polish progress, check float error case * add callback on end of "to" function, value check * start of green/red in progress * add first version of rich progress bar * make green bar darker * rich bar fixes * add delay, before filling in rich progress * PR fixes * remove dublicate of 'progress_rich'
55 lines
1.2 KiB
Lua
55 lines
1.2 KiB
Lua
local settings = require("druid.settings")
|
|
local pr_settings = settings.progress_rich
|
|
|
|
local M = {}
|
|
|
|
function M.init(instance, name, red, green, key)
|
|
instance.red = instance.parent:new_progress(red, key)
|
|
instance.green = instance.parent:new_progress(green, key)
|
|
instance.fill = instance.parent:new_progress(name, key)
|
|
end
|
|
|
|
|
|
function M.set_to(instance, value)
|
|
instance.red:set_to(value)
|
|
instance.green:set_to(value)
|
|
instance.fill:set_to(value)
|
|
end
|
|
|
|
|
|
function M.empty(instance)
|
|
instance.red:empty()
|
|
instance.green:empty()
|
|
instance.fill:empty()
|
|
end
|
|
|
|
|
|
function M.to(instance, to, callback)
|
|
if instance.timer then
|
|
timer.cancel(instance.timer)
|
|
instance.timer = nil
|
|
end
|
|
|
|
if instance.fill.last_value < to then
|
|
instance.red:to(instance.fill.last_value)
|
|
instance.green:to(to, function()
|
|
instance.timer = timer.delay(pr_settings.DELAY, false, function()
|
|
instance.red:to(to)
|
|
instance.fill:to(to, callback)
|
|
end)
|
|
end)
|
|
end
|
|
|
|
if instance.fill.last_value > to then
|
|
instance.green:to(instance.red.last_value)
|
|
instance.fill:to(to, function()
|
|
instance.timer = timer.delay(pr_settings.DELAY, false, function()
|
|
instance.green:to(to)
|
|
instance.red:to(to, callback)
|
|
end)
|
|
end)
|
|
end
|
|
end
|
|
|
|
|
|
return M |