From 387a1805ebad2eceac98b8f812d72bc0f8ed195e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Ritzl?= Date: Sun, 19 Sep 2021 23:08:31 +0200 Subject: [PATCH] Added option to change timestep for screen when below popup Fixes #73 --- README_API.md | 8 ++++++++ monarch/monarch.lua | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/README_API.md b/README_API.md index 6040beb..d0b2bdd 100644 --- a/README_API.md +++ b/README_API.md @@ -149,6 +149,14 @@ Check if a Monarch screen is visible. * `exists` (boolean) - True if the screen is visible. +## monarch.set_timestep_below_popup(screen_id, timestep) +Set the timestep to apply for a screen when below a popup. + +**PARAMETERS** +* `screen_id` (string|hash) - Id of the screen to change timestep setting for +* `timestep` (number) - Timestep to apply + + ## monarch.add_listener([url]) Add a URL that will be notified of navigation events. diff --git a/monarch/monarch.lua b/monarch/monarch.lua index 0b88888..c50a177 100644 --- a/monarch/monarch.lua +++ b/monarch/monarch.lua @@ -1155,6 +1155,19 @@ function M.bottom(offset) return screen and screen.id end + +--- Set the timestep to apply for a screen when below a popup +-- @param id (string|hash) Id of the screen to change timestep setting for +-- @param timestep (number) Timestep to apply +function M.set_timestep_below_popup(id, timestep) + assert(id, "You must provide a screen id") + assert(timestep, "You must provide a timestep") + id = tohash(id) + assert(screens[id], ("There is no screen registered with id %s"):format(tostring(id))) + screens[id].timestep_below_popup = timestep +end + + local function url_to_key(url) return (url.socket or hash("")) .. (url.path or hash("")) .. (url.fragment or hash("")) end