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
|
||||
icon-color: #ffffffff
|
||||
|
||||
$on:
|
||||
image-source: /images/ui/button_top_blink
|
||||
|
||||
$hover !disabled:
|
||||
image-color: #ffffff99
|
||||
image-clip: 26 0 26 26
|
||||
|
@ -46,4 +49,4 @@ TopMenuPanel < Panel
|
|||
TopMenuFrameCounterLabel < FrameCounterLabel
|
||||
color: white
|
||||
margin-top: 4
|
||||
margin-left: 5
|
||||
margin-left: 5
|
||||
|
|
|
@ -25,8 +25,8 @@ function addEvent(callback, front)
|
|||
return event
|
||||
end
|
||||
|
||||
function cycleEvent(callback, front)
|
||||
local event = g_dispatcher.cycleEvent(callback, front)
|
||||
function cycleEvent(callback, interval)
|
||||
local event = g_dispatcher.cycleEvent(callback, interval)
|
||||
-- must hold a reference to the callback, otherwise it would be collected
|
||||
event._callback = callback
|
||||
return event
|
||||
|
|
|
@ -35,3 +35,33 @@ function g_effects.cancelFade(widget)
|
|||
removeEvent(widget.fadeEvent)
|
||||
widget.fadeEvent = nil
|
||||
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