mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Remove progress_rich component, move it to separate repository (druid-assets)
This commit is contained in:
parent
3ae5011bde
commit
44016bc4f3
@ -1,72 +0,0 @@
|
|||||||
--- Component for rich progress component
|
|
||||||
-- @module druid.progress_rich
|
|
||||||
|
|
||||||
local component = require("druid.component")
|
|
||||||
|
|
||||||
local M = component.create("progress_rich")
|
|
||||||
|
|
||||||
|
|
||||||
function M.init(self, name, red, green, key)
|
|
||||||
self.druid = self:get_druid()
|
|
||||||
self.style = self:get_style()
|
|
||||||
self.red = self.druid:new_progress(red, key)
|
|
||||||
self.green = self.druid:new_progress(green, key)
|
|
||||||
self.fill = self.druid:new_progress(name, key)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- Instant fill progress bar to value
|
|
||||||
-- @function progress_rich:set_to
|
|
||||||
-- @tparam table self Component instance
|
|
||||||
-- @tparam number value Progress bar value, from 0 to 1
|
|
||||||
function M.set_to(self, value)
|
|
||||||
self.red:set_to(value)
|
|
||||||
self.green:set_to(value)
|
|
||||||
self.fill:set_to(value)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- Empty a progress bar
|
|
||||||
-- @function progress_rich:empty
|
|
||||||
-- @tparam table self Component instance
|
|
||||||
function M.empty(self)
|
|
||||||
self.red:empty()
|
|
||||||
self.green:empty()
|
|
||||||
self.fill:empty()
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- Start animation of a progress bar
|
|
||||||
-- @function progress_rich:to
|
|
||||||
-- @tparam table self Component instance
|
|
||||||
-- @tparam number to value between 0..1
|
|
||||||
-- @tparam[opt] function callback Callback on animation ends
|
|
||||||
function M.to(self, to, callback)
|
|
||||||
if self.timer then
|
|
||||||
timer.cancel(self.timer)
|
|
||||||
self.timer = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.fill.last_value < to then
|
|
||||||
self.red:to(self.fill.last_value)
|
|
||||||
self.green:to(to, function()
|
|
||||||
self.timer = timer.delay(self.style.DELAY, false, function()
|
|
||||||
self.red:to(to)
|
|
||||||
self.fill:to(to, callback)
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.fill.last_value > to then
|
|
||||||
self.green:to(self.red.last_value)
|
|
||||||
self.fill:to(to, function()
|
|
||||||
self.timer = timer.delay(self.style.DELAY, false, function()
|
|
||||||
self.green:to(to)
|
|
||||||
self.red:to(to, callback)
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
return M
|
|
@ -37,7 +37,6 @@ local checkbox_group = require("druid.base.checkbox_group")
|
|||||||
local radio_group = require("druid.base.radio_group")
|
local radio_group = require("druid.base.radio_group")
|
||||||
local input = require("druid.base.input")
|
local input = require("druid.base.input")
|
||||||
-- local infinity_scroll = require("druid.base.infinity_scroll")
|
-- local infinity_scroll = require("druid.base.infinity_scroll")
|
||||||
local progress_rich = require("druid.rich.progress_rich")
|
|
||||||
|
|
||||||
-- @classmod Druid
|
-- @classmod Druid
|
||||||
local Druid = class("druid.druid_instance")
|
local Druid = class("druid.druid_instance")
|
||||||
@ -359,13 +358,4 @@ function Druid.new_radio_group(self, ...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Create progress_rich basic component
|
|
||||||
-- @function druid:new_progress_rich
|
|
||||||
-- @tparam args ... progress_rich init args
|
|
||||||
-- @treturn Component progress_rich component
|
|
||||||
function Druid.new_progress_rich(self, ...)
|
|
||||||
return Druid.create(self, progress_rich, ...)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
return Druid
|
return Druid
|
||||||
|
Loading…
x
Reference in New Issue
Block a user