mirror of
https://github.com/britzl/monarch.git
synced 2025-11-26 19:00:53 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b01f5d28c3 | ||
|
|
43e847dacc | ||
|
|
ce5ca26b6c | ||
|
|
742779d749 | ||
|
|
84944f3f22 |
@@ -114,7 +114,7 @@ end
|
|||||||
|
|
||||||
function on_message(self, message_id, message, sender)
|
function on_message(self, message_id, message, sender)
|
||||||
if message_id == hash("my_resize_message") then
|
if message_id == hash("my_resize_message") then
|
||||||
self.transition.window_resized(message.width, message.height)
|
transition.window_resized(message.width, message.height)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -228,6 +228,17 @@ function M.is_visible(id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Check if a screen is loaded
|
||||||
|
-- @param id (string|hash)
|
||||||
|
-- @return true if the screen is loaded
|
||||||
|
function M.is_loaded(id)
|
||||||
|
assert(id, "You must provide a screen id")
|
||||||
|
id = tohash(id)
|
||||||
|
assert(screens[id], ("There is no screen registered with id %s"):format(tostring(id)))
|
||||||
|
return screens[id].loaded
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Check if a screen is a popup
|
--- Check if a screen is a popup
|
||||||
-- @param id Screen id
|
-- @param id Screen id
|
||||||
-- @return true if the screen is a popup
|
-- @return true if the screen is a popup
|
||||||
@@ -509,8 +520,12 @@ local function load(screen)
|
|||||||
msg.post(screen.proxy, MSG_ENABLE)
|
msg.post(screen.proxy, MSG_ENABLE)
|
||||||
elseif screen.factory then
|
elseif screen.factory then
|
||||||
screen.factory_ids = collectionfactory.create(screen.factory)
|
screen.factory_ids = collectionfactory.create(screen.factory)
|
||||||
screen.transition_url = screen.factory_ids[screen.transition_id]
|
if screen.transition_id then
|
||||||
screen.focus_url = screen.factory_ids[screen.focus_id]
|
screen.transition_url = screen.factory_ids[screen.transition_id]
|
||||||
|
end
|
||||||
|
if screen.focus_id then
|
||||||
|
screen.focus_url = screen.factory_ids[screen.focus_id]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
screen.loaded = true
|
screen.loaded = true
|
||||||
screen.preloaded = false
|
screen.preloaded = false
|
||||||
@@ -1178,8 +1193,8 @@ end
|
|||||||
-- @return error (string|nil) Error message if unable to send message
|
-- @return error (string|nil) Error message if unable to send message
|
||||||
function M.post(id, message_id, message)
|
function M.post(id, message_id, message)
|
||||||
assert(id, "You must provide a screen id")
|
assert(id, "You must provide a screen id")
|
||||||
if not M.is_visible(id) then
|
if not M.is_loaded(id) then
|
||||||
return false, "Unable to post message to screen if it isn't visible"
|
return false, "Unable to post message to screen if it isn't loaded"
|
||||||
end
|
end
|
||||||
|
|
||||||
assert(message_id, "You must provide a message_id")
|
assert(message_id, "You must provide a message_id")
|
||||||
|
|||||||
@@ -142,12 +142,12 @@ return function()
|
|||||||
monarch.show(SCREEN1)
|
monarch.show(SCREEN1)
|
||||||
assert(wait_until_stack({ SCREEN1 }))
|
assert(wait_until_stack({ SCREEN1 }))
|
||||||
assert(wait_until_visible(SCREEN1))
|
assert(wait_until_visible(SCREEN1))
|
||||||
|
|
||||||
monarch.show(SCREEN2)
|
monarch.show(SCREEN2)
|
||||||
assert(wait_until_stack({ SCREEN1, SCREEN2 }))
|
assert(wait_until_stack({ SCREEN1, SCREEN2 }))
|
||||||
assert(wait_until_hidden(SCREEN1))
|
assert(wait_until_hidden(SCREEN1))
|
||||||
assert(wait_until_visible(SCREEN2))
|
assert(wait_until_visible(SCREEN2))
|
||||||
|
|
||||||
monarch.show(POPUP1)
|
monarch.show(POPUP1)
|
||||||
assert(wait_until_stack({ SCREEN1, SCREEN2, POPUP1 }))
|
assert(wait_until_stack({ SCREEN1, SCREEN2, POPUP1 }))
|
||||||
assert(wait_until_hidden(SCREEN1))
|
assert(wait_until_hidden(SCREEN1))
|
||||||
@@ -155,6 +155,17 @@ return function()
|
|||||||
assert(wait_until_visible(POPUP1))
|
assert(wait_until_visible(POPUP1))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("should be able to tell if a screen is loaded or not", function()
|
||||||
|
assert(not monarch.is_loaded(SCREEN1))
|
||||||
|
monarch.show(SCREEN1)
|
||||||
|
assert(wait_until_visible(SCREEN1))
|
||||||
|
assert(monarch.is_loaded(SCREEN1))
|
||||||
|
|
||||||
|
monarch.hide(SCREEN1)
|
||||||
|
assert(wait_until_hidden(SCREEN1))
|
||||||
|
assert(not monarch.is_loaded(SCREEN1))
|
||||||
|
end)
|
||||||
|
|
||||||
it("should be able to show a screen without adding it to the stack", function()
|
it("should be able to show a screen without adding it to the stack", function()
|
||||||
monarch.show(BACKGROUND, { no_stack = true })
|
monarch.show(BACKGROUND, { no_stack = true })
|
||||||
assert(wait_until_visible(BACKGROUND), "Background was never shown")
|
assert(wait_until_visible(BACKGROUND), "Background was never shown")
|
||||||
|
|||||||
Reference in New Issue
Block a user