mirror of
https://github.com/britzl/monarch.git
synced 2025-11-27 03:10:54 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5879a5f63 | ||
|
|
97c97e738d | ||
|
|
e4ca53630e | ||
|
|
9afd77e2b0 | ||
|
|
9808c09aa1 |
@@ -20,8 +20,8 @@ jdk:
|
|||||||
#DEFOLD_AUTH=auth token
|
#DEFOLD_AUTH=auth token
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- secure: "1rVLsDcb7dFdgyB9D1JQDr4JhWSosoMvgYgrqZNPxJ/Du3qtY3bk6dgQim+g2fDMQpDOPCQ/EhmhtrLJrIgBhhvOcsrVKT8gl9ZnATw5tHGI6XTw3eod8WgsU8owlc7CaT3XaUgwVshmW3oB/257SDf6kHwsCv/gAJuCEL5RZp76BhTWsfyeDCgz5XXgWx4a21tcIWz96jxEsrYQKLLV2ne55CxU5Hw9IMU7Ig7pkGoYCf1g+iUEA39NC8nIrQibUoJj3yNB2u3ZFwGf2LuDjjkSIsyYWn1LzA2fQYw5uAcjiQ/aDkj6sAEvwrWsIsJhOon5cQBFIU6cIIN2oK3A7BA0zJj0EsTFPUMIeryyoqiuLUDoIvHD/eEqouNduP6Kml02Ql0pDZnjDy/+nzp2e7VA5Sd9Xg1XKd1mmHKx4nc2U+IcIDZWAerFKcqQqeZSwzz5igv07w5zYZ99KCSBMH2K/2H/CNekHa6SQQ29mC8D3lDXOfwEq3fAhsabgUGe2uAgUY1nKwJBKEi7r+KEROBr5ydkWenzbCXv3GNNsuCHKpNFuoZv3QMyjUjlPBxZVndNLSv85juhkBx6wXAh8CxTt78Y8GV0xI8oazSM065gpDmENGVqyO1bUn2CZF8YRC4MLfHK+245QN82ui+YOqVudTX8RGWnX0GFUncjaRQ="
|
- DEFOLD_AUTH=foobar
|
||||||
- DEFOLD_USER=bjorn.ritzl@king.com
|
- DEFOLD_USER=bjorn.ritzl@gmail.com
|
||||||
- DEFOLD_BOOSTRAP_COLLECTION=/test/test.collectionc
|
- DEFOLD_BOOSTRAP_COLLECTION=/test/test.collectionc
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ local function cowait(delay)
|
|||||||
local co = coroutine.running()
|
local co = coroutine.running()
|
||||||
assert(co, "You must run this form within a coroutine")
|
assert(co, "You must run this form within a coroutine")
|
||||||
timer.delay(delay, false, function()
|
timer.delay(delay, false, function()
|
||||||
coroutine.resume(co)
|
assert(coroutine.resume(co))
|
||||||
end)
|
end)
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
end
|
end
|
||||||
@@ -466,6 +466,11 @@ local function show_in(screen, previous_screen, reload, add_to_stack, cb)
|
|||||||
if reload and screen.loaded then
|
if reload and screen.loaded then
|
||||||
log("show_in() reloading", screen.id)
|
log("show_in() reloading", screen.id)
|
||||||
unload(screen, reload)
|
unload(screen, reload)
|
||||||
|
-- we need to wait here in case the unloaded screen contained any screens
|
||||||
|
-- if this is the case we need to let these sub-screens have their final()
|
||||||
|
-- functions called so that they have time to call unregister()
|
||||||
|
cowait(0)
|
||||||
|
cowait(0)
|
||||||
end
|
end
|
||||||
load(screen)
|
load(screen)
|
||||||
if add_to_stack then
|
if add_to_stack then
|
||||||
@@ -573,13 +578,13 @@ function M.show(id, options, data, cb)
|
|||||||
|
|
||||||
local co
|
local co
|
||||||
co = coroutine.create(function()
|
co = coroutine.create(function()
|
||||||
|
local top = stack[#stack]
|
||||||
-- a screen can ignore the stack by setting the no_stack to true
|
-- a screen can ignore the stack by setting the no_stack to true
|
||||||
local add_to_stack = not options or not options.no_stack
|
local add_to_stack = not options or not options.no_stack
|
||||||
if add_to_stack then
|
if add_to_stack then
|
||||||
-- manipulate the current top
|
-- manipulate the current top
|
||||||
-- close popup(s) if needed
|
-- close popup(s) if needed
|
||||||
-- transition out
|
-- transition out
|
||||||
local top = stack[#stack]
|
|
||||||
if top then
|
if top then
|
||||||
-- keep top popup visible if new screen can be shown on top of a popup
|
-- keep top popup visible if new screen can be shown on top of a popup
|
||||||
if top.popup and screen.popup_on_popup then
|
if top.popup and screen.popup_on_popup then
|
||||||
@@ -589,7 +594,7 @@ function M.show(id, options, data, cb)
|
|||||||
while top.popup do
|
while top.popup do
|
||||||
stack[#stack] = nil
|
stack[#stack] = nil
|
||||||
show_out(top, screen, function()
|
show_out(top, screen, function()
|
||||||
coroutine.resume(co)
|
assert(coroutine.resume(co))
|
||||||
end)
|
end)
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
top = stack[#stack]
|
top = stack[#stack]
|
||||||
@@ -619,7 +624,7 @@ function M.show(id, options, data, cb)
|
|||||||
-- screen that has Preload set to true
|
-- screen that has Preload set to true
|
||||||
if M.is_preloading(id) then
|
if M.is_preloading(id) then
|
||||||
M.when_preloaded(id, function()
|
M.when_preloaded(id, function()
|
||||||
coroutine.resume(co)
|
assert(coroutine.resume(co))
|
||||||
end)
|
end)
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
end
|
end
|
||||||
@@ -627,7 +632,7 @@ function M.show(id, options, data, cb)
|
|||||||
|
|
||||||
if cb then callbacks.when_done(cb) end
|
if cb then callbacks.when_done(cb) end
|
||||||
end)
|
end)
|
||||||
coroutine.resume(co)
|
assert(coroutine.resume(co))
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -104,114 +104,163 @@ function M.fade_in(node, from, easing, duration, delay, cb)
|
|||||||
gui.animate(node, gui.PROP_COLOR, to, easing, duration, delay, cb)
|
gui.animate(node, gui.PROP_COLOR, to, easing, duration, delay, cb)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create a transition for a node
|
|
||||||
-- @return Transition instance
|
|
||||||
function M.create(node)
|
|
||||||
assert(node, "You must provide a node")
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Create a transition
|
||||||
|
-- @return Transition instance
|
||||||
|
local function create()
|
||||||
local instance = {}
|
local instance = {}
|
||||||
|
|
||||||
local transitions = {}
|
local transitions = {
|
||||||
|
[monarch.TRANSITION.SHOW_IN] = { urls = {}, transitions = {}, in_progress_count = 0, },
|
||||||
|
[monarch.TRANSITION.SHOW_OUT] = { urls = {}, transitions = {}, in_progress_count = 0, },
|
||||||
|
[monarch.TRANSITION.BACK_IN] = { urls = {}, transitions = {}, in_progress_count = 0, },
|
||||||
|
[monarch.TRANSITION.BACK_OUT] = { urls = {}, transitions = {}, in_progress_count = 0, },
|
||||||
|
}
|
||||||
|
|
||||||
local current_transition = nil
|
local current_transition = nil
|
||||||
|
|
||||||
local initial_data = {}
|
|
||||||
initial_data.pos = gui.get_position(node)
|
|
||||||
initial_data.scale = gui.get_scale(node)
|
|
||||||
|
|
||||||
local function create_transition(fn, easing, duration, delay)
|
local function create_transition(transition_id, node, fn, easing, duration, delay)
|
||||||
return {
|
local t = transitions[transition_id]
|
||||||
|
t.transitions[#t.transitions + 1] = {
|
||||||
|
node = node,
|
||||||
|
node_data = {
|
||||||
|
pos = gui.get_position(node),
|
||||||
|
scale = gui.get_scale(node),
|
||||||
|
},
|
||||||
fn = fn,
|
fn = fn,
|
||||||
easing = easing,
|
easing = easing,
|
||||||
duration = duration,
|
duration = duration,
|
||||||
delay = delay,
|
delay = delay,
|
||||||
in_progress = false,
|
id = transition_id
|
||||||
urls = {},
|
|
||||||
id = nil
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local function finish_transition(transition)
|
local function finish_transition(transition_id)
|
||||||
transition.in_progress = false
|
local t = transitions[transition_id]
|
||||||
local message = { transition = transition.id }
|
if #t.urls > 0 then
|
||||||
while #transition.urls > 0 do
|
local message = { transition = transition_id }
|
||||||
local url = table.remove(transition.urls)
|
while #t.urls > 0 do
|
||||||
msg.post(url, monarch.TRANSITION.DONE, message)
|
local url = table.remove(t.urls)
|
||||||
|
msg.post(url, monarch.TRANSITION.DONE, message)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
current_transition = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local function check_and_finish_transition(transition_id)
|
||||||
|
local t = transitions[transition_id]
|
||||||
|
if t.in_progress_count == 0 then
|
||||||
|
finish_transition(transition_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function start_transition(transition, transition_id, url)
|
local function start_transition(transition_id, url)
|
||||||
table.insert(transition.urls, url)
|
local t = transitions[transition_id]
|
||||||
if not transition.in_progress then
|
table.insert(t.urls, url)
|
||||||
table.insert(transition.urls, msg.url())
|
if t.in_progress_count == 0 then
|
||||||
transition.in_progress = true
|
table.insert(t.urls, msg.url())
|
||||||
transition.id = transition_id
|
current_transition = t
|
||||||
current_transition = transition
|
if #t.transitions > 0 then
|
||||||
transition.fn(node, initial_data, transition.easing, transition.duration, transition.delay or 0, function()
|
for i=1,#t.transitions do
|
||||||
finish_transition(transition)
|
local transition = t.transitions[i]
|
||||||
end)
|
t.in_progress_count = t.in_progress_count + 1
|
||||||
|
transition.fn(transition.node, transition.node_data, transition.easing, transition.duration, transition.delay or 0, function()
|
||||||
|
t.in_progress_count = t.in_progress_count - 1
|
||||||
|
check_and_finish_transition(transition_id)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
check_and_finish_transition(transition_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Forward on_message calls here
|
-- Forward on_message calls here
|
||||||
function instance.handle(message_id, message, sender)
|
function instance.handle(message_id, message, sender)
|
||||||
if message_id == LAYOUT_CHANGED then
|
if message_id == LAYOUT_CHANGED then
|
||||||
initial_data.pos = gui.get_position(node)
|
for _,t in pairs(transitions) do
|
||||||
|
for _,transitions in pairs(t.transitions) do
|
||||||
|
transitions.node_data.pos = gui.get_position(transitions.node)
|
||||||
|
end
|
||||||
|
end
|
||||||
-- replay the current transition if the layout changes
|
-- replay the current transition if the layout changes
|
||||||
-- this will ensure that things are still hidden if they
|
-- this will ensure that things are still hidden if they
|
||||||
-- were transitioned out
|
-- were transitioned out
|
||||||
if current_transition then
|
if current_transition then
|
||||||
current_transition.fn(node, initial_data, current_transition.easing, 0, 0)
|
for _,transition in pairs(current_transition.transitions) do
|
||||||
if current_transition.in_progress then
|
local node = transition.node
|
||||||
finish_transition(current_transition)
|
transition.fn(transition.node, transition.node_data, transition.easing, 0, 0)
|
||||||
|
end
|
||||||
|
if current_transition.in_progress_count > 0 then
|
||||||
|
finish_transition(message_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
elseif message_id == monarch.TRANSITION.SHOW_IN
|
||||||
local transition = transitions[message_id]
|
or message_id == monarch.TRANSITION.SHOW_OUT
|
||||||
if transition then
|
or message_id == monarch.TRANSITION.BACK_IN
|
||||||
start_transition(transition, message_id, sender)
|
or message_id == monarch.TRANSITION.BACK_OUT then
|
||||||
end
|
start_transition(message_id, sender)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Specify the transition function when this node is transitioned
|
-- Specify the transition function when this node is transitioned
|
||||||
-- to
|
-- to
|
||||||
-- @param fn Transition function (see slide_in_left and other above)
|
-- @param fn Transition function (see slide_in_left and other above)
|
||||||
-- @param easing Easing function to use
|
-- @param easing Easing function to use
|
||||||
-- @param duration Transition duration
|
-- @param duration Transition duration
|
||||||
-- @param delay Transition delay
|
-- @param delay Transition delay
|
||||||
function instance.show_in(fn, easing, duration, delay)
|
function instance.show_in(node, fn, easing, duration, delay)
|
||||||
transitions[monarch.TRANSITION.SHOW_IN] = create_transition(fn, easing, duration, delay)
|
create_transition(monarch.TRANSITION.SHOW_IN, node, fn, easing, duration, delay)
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Specify the transition function when this node is transitioned
|
-- Specify the transition function when this node is transitioned
|
||||||
-- from when showing another screen
|
-- from when showing another screen
|
||||||
function instance.show_out(fn, easing, duration, delay)
|
function instance.show_out(node, fn, easing, duration, delay)
|
||||||
transitions[monarch.TRANSITION.SHOW_OUT] = create_transition(fn, easing, duration, delay)
|
create_transition(monarch.TRANSITION.SHOW_OUT, node, fn, easing, duration, delay)
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Specify the transition function when this node is transitioned
|
--- Specify the transition function when this node is transitioned
|
||||||
-- to when navigating back in the screen stack
|
-- to when navigating back in the screen stack
|
||||||
function instance.back_in(fn, easing, duration, delay)
|
function instance.back_in(node, fn, easing, duration, delay)
|
||||||
transitions[monarch.TRANSITION.BACK_IN] = create_transition(fn, easing, duration, delay)
|
create_transition(monarch.TRANSITION.BACK_IN, node, fn, easing, duration, delay)
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Specify the transition function when this node is transitioned
|
--- Specify the transition function when this node is transitioned
|
||||||
-- from when navigating back in the screen stack
|
-- from when navigating back in the screen stack
|
||||||
function instance.back_out(fn, easing, duration, delay)
|
function instance.back_out(node, fn, easing, duration, delay)
|
||||||
transitions[monarch.TRANSITION.BACK_OUT] = create_transition(fn, easing, duration, delay)
|
create_transition(monarch.TRANSITION.BACK_OUT, node, fn, easing, duration, delay)
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set default transitions (instant)
|
return instance
|
||||||
instance.show_in(M.instant)
|
end
|
||||||
instance.show_out(M.instant)
|
|
||||||
instance.back_in(M.instant)
|
function M.create(node)
|
||||||
instance.back_out(M.instant)
|
local instance = create()
|
||||||
|
-- backward compatibility with the old version of create
|
||||||
|
-- where a single node was used
|
||||||
|
if node then
|
||||||
|
local show_in = instance.show_in
|
||||||
|
local show_out = instance.show_out
|
||||||
|
local back_in = instance.back_in
|
||||||
|
local back_out = instance.back_out
|
||||||
|
instance.show_in = function(fn, easing, duration, delay)
|
||||||
|
return show_in(node, fn, easing, duration, delay)
|
||||||
|
end
|
||||||
|
instance.show_out = function(fn, easing, duration, delay)
|
||||||
|
return show_out(node, fn, easing, duration, delay)
|
||||||
|
end
|
||||||
|
instance.back_in = function(fn, easing, duration, delay)
|
||||||
|
return back_in(node, fn, easing, duration, delay)
|
||||||
|
end
|
||||||
|
instance.back_out = function(fn, easing, duration, delay)
|
||||||
|
return back_out(node, fn, easing, duration, delay)
|
||||||
|
end
|
||||||
|
end
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user