mirror of
https://github.com/britzl/monarch.git
synced 2025-06-27 10:27:49 +02:00
Include transition id in TRANSITION.DONE message
Also send the TRANSITION.DONE message to the gui that was transitioned
This commit is contained in:
parent
39628b75af
commit
724713f9e4
@ -123,6 +123,7 @@ When a transition is completed it is up to the developer to send a ```transition
|
|||||||
Monarch comes with a system for setting up transitions easily in a gui_script using the ```monarch.transitions.gui``` module. Example:
|
Monarch comes with a system for setting up transitions easily in a gui_script using the ```monarch.transitions.gui``` module. Example:
|
||||||
|
|
||||||
local transitions = require "monarch.transitions.gui"
|
local transitions = require "monarch.transitions.gui"
|
||||||
|
local monarch = require "monarch.monarch"
|
||||||
|
|
||||||
function init(self)
|
function init(self)
|
||||||
-- create transitions for the node 'root'
|
-- create transitions for the node 'root'
|
||||||
@ -137,6 +138,10 @@ Monarch comes with a system for setting up transitions easily in a gui_script us
|
|||||||
|
|
||||||
function on_message(self, message_id, message, sender)
|
function on_message(self, message_id, message, sender)
|
||||||
self.transition.handle(message_id, message, sender)
|
self.transition.handle(message_id, message, sender)
|
||||||
|
-- you can also check when a transition has completed:
|
||||||
|
if message_id == monarch.TRANSITION.DONE and message.transition == monarch.TRANSITION.SHOW_IN then
|
||||||
|
print("Show in done!")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
### Predefined transitions
|
### Predefined transitions
|
||||||
|
@ -113,16 +113,18 @@ function M.create(node)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local function start_transition(transition, url)
|
local function start_transition(transition, transition_id, url)
|
||||||
table.insert(transition.urls, url)
|
table.insert(transition.urls, url)
|
||||||
if not transition.in_progress then
|
if not transition.in_progress then
|
||||||
|
table.insert(transition.urls, msg.url())
|
||||||
current_transition = transition
|
current_transition = transition
|
||||||
transition.in_progress = true
|
transition.in_progress = true
|
||||||
transition.fn(node, initial_data, transition.easing, transition.duration, transition.delay or 0, function()
|
transition.fn(node, initial_data, transition.easing, transition.duration, transition.delay or 0, function()
|
||||||
transition.in_progress = false
|
transition.in_progress = false
|
||||||
|
local message = { transition = transition_id }
|
||||||
while #transition.urls > 0 do
|
while #transition.urls > 0 do
|
||||||
local url = table.remove(transition.urls)
|
local url = table.remove(transition.urls)
|
||||||
msg.post(url, monarch.TRANSITION.DONE)
|
msg.post(url, monarch.TRANSITION.DONE, message)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@ -141,7 +143,7 @@ function M.create(node)
|
|||||||
else
|
else
|
||||||
local transition = transitions[message_id]
|
local transition = transitions[message_id]
|
||||||
if transition then
|
if transition then
|
||||||
start_transition(transition, sender)
|
start_transition(transition, message_id, sender)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user