mirror of
https://github.com/britzl/monarch.git
synced 2025-11-26 10:50:55 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
724713f9e4 | ||
|
|
39628b75af | ||
|
|
dbf1bdea9d | ||
|
|
d45005cd90 | ||
|
|
a701f6cd92 |
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user