Add blink effect
This commit is contained in:
parent
637b6ceca2
commit
d4fb6127fc
Binary file not shown.
After Width: | Height: | Size: 462 B |
|
@ -6,6 +6,9 @@ TopButton < UIButton
|
||||||
image-color: #ffffffff
|
image-color: #ffffffff
|
||||||
icon-color: #ffffffff
|
icon-color: #ffffffff
|
||||||
|
|
||||||
|
$on:
|
||||||
|
image-source: /images/ui/button_top_blink
|
||||||
|
|
||||||
$hover !disabled:
|
$hover !disabled:
|
||||||
image-color: #ffffff99
|
image-color: #ffffff99
|
||||||
image-clip: 26 0 26 26
|
image-clip: 26 0 26 26
|
||||||
|
|
|
@ -25,8 +25,8 @@ function addEvent(callback, front)
|
||||||
return event
|
return event
|
||||||
end
|
end
|
||||||
|
|
||||||
function cycleEvent(callback, front)
|
function cycleEvent(callback, interval)
|
||||||
local event = g_dispatcher.cycleEvent(callback, front)
|
local event = g_dispatcher.cycleEvent(callback, interval)
|
||||||
-- must hold a reference to the callback, otherwise it would be collected
|
-- must hold a reference to the callback, otherwise it would be collected
|
||||||
event._callback = callback
|
event._callback = callback
|
||||||
return event
|
return event
|
||||||
|
|
|
@ -35,3 +35,33 @@ function g_effects.cancelFade(widget)
|
||||||
removeEvent(widget.fadeEvent)
|
removeEvent(widget.fadeEvent)
|
||||||
widget.fadeEvent = nil
|
widget.fadeEvent = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function g_effects.startBlink(widget, duration, interval, clickCancel)
|
||||||
|
duration = duration or 0 -- until stop is called
|
||||||
|
interval = interval or 500
|
||||||
|
clickCancel = clickCancel or true
|
||||||
|
|
||||||
|
removeEvent(widget.blinkEvent)
|
||||||
|
removeEvent(widget.blinkStopEvent)
|
||||||
|
|
||||||
|
widget.blinkEvent = cycleEvent(function()
|
||||||
|
widget:setOn(not widget:isOn())
|
||||||
|
end, interval)
|
||||||
|
|
||||||
|
if duration > 0 then
|
||||||
|
widget.blinkStopEvent = scheduleEvent(function()
|
||||||
|
g_effects.stopBlink(widget)
|
||||||
|
end, duration)
|
||||||
|
end
|
||||||
|
|
||||||
|
connect(widget, { onClick = g_effects.stopBlink })
|
||||||
|
end
|
||||||
|
|
||||||
|
function g_effects.stopBlink(widget)
|
||||||
|
disconnect(widget, { onClick = g_effects.stopBlink })
|
||||||
|
removeEvent(widget.blinkEvent)
|
||||||
|
removeEvent(widget.blinkStopEvent)
|
||||||
|
widget.blinkEvent = nil
|
||||||
|
widget.blinkStopEvent = nil
|
||||||
|
widget:setOn(false)
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue