3
0
mirror of https://github.com/britzl/monarch.git synced 2025-11-26 19:00:53 +01:00

Compare commits

...

5 Commits
2.3.0 ... 2.5.0

Author SHA1 Message Date
Björn Ritzl
724713f9e4 Include transition id in TRANSITION.DONE message
Also send the TRANSITION.DONE message to the gui that was transitioned
2018-06-01 08:43:08 +02:00
Björn Ritzl
39628b75af Merge pull request #17 from britzl/resizefix
Replay transitions when the layout changes
2018-05-26 19:43:42 +02:00
Björn Ritzl
dbf1bdea9d Replay transitions when the layout changes 2018-05-25 15:33:51 +02:00
Björn Ritzl
d45005cd90 Added documentation about monarch.debug()
Fixes #16
2018-05-24 16:34:33 +02:00
Björn Ritzl
a701f6cd92 Fixed broken tests 2018-03-26 06:33:11 +02:00
3 changed files with 24 additions and 3 deletions

View File

@@ -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:
local transitions = require "monarch.transitions.gui"
local monarch = require "monarch.monarch"
function init(self)
-- 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)
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
### Predefined transitions
@@ -240,3 +245,7 @@ Check if a Monarch screen exists.
**RETURN**
* ```exists``` (boolean) - True if the screen exists.
### monarch.debug()
Enable verbose logging of the internals of Monarch.

View File

@@ -96,6 +96,8 @@ function M.create(node)
local transitions = {}
local current_transition = nil
local initial_data = {}
initial_data.pos = gui.get_position(node)
initial_data.scale = gui.get_scale(node)
@@ -111,15 +113,18 @@ function M.create(node)
}
end
local function start_transition(transition, url)
local function start_transition(transition, transition_id, url)
table.insert(transition.urls, url)
if not transition.in_progress then
table.insert(transition.urls, msg.url())
current_transition = transition
transition.in_progress = true
transition.fn(node, initial_data, transition.easing, transition.duration, transition.delay or 0, function()
transition.in_progress = false
local message = { transition = transition_id }
while #transition.urls > 0 do
local url = table.remove(transition.urls)
msg.post(url, monarch.TRANSITION.DONE)
msg.post(url, monarch.TRANSITION.DONE, message)
end
end)
end
@@ -129,10 +134,16 @@ function M.create(node)
function instance.handle(message_id, message, sender)
if message_id == LAYOUT_CHANGED then
initial_data.pos = gui.get_position(node)
-- replay the current transition if the layout changes
-- this will ensure that things are still hidden if they
-- were transitioned out
if current_transition then
current_transition.fn(node, initial_data, current_transition.easing, 0, 0)
end
else
local transition = transitions[message_id]
if transition then
start_transition(transition, sender)
start_transition(transition, message_id, sender)
end
end
end

View File

@@ -1,6 +1,7 @@
local cowait = require "test.cowait"
local monarch = require "monarch.monarch"
local SCREEN1_STR = hash("screen1")
local SCREEN1 = hash(SCREEN1_STR)
local SCREEN2 = hash("screen2")
local POPUP1 = hash("popup1")