summaryrefslogtreecommitdiff
path: root/lua/licenses.lua
diff options
context:
space:
mode:
authorTom Kirchner <git@halffull.org>2025-01-08 21:24:27 -0800
committerTom Kirchner <git@halffull.org>2025-01-08 21:24:27 -0800
commit6d6d7188a8f7832e7ce80dc53cf34935e40e6014 (patch)
tree8eb1f9431c259cb30f1c27e7ac0e2c39fc031378 /lua/licenses.lua
parentbff22d90737cdb9c6b3f8e49f2f5a5678c4a182e (diff)
downloadtangara-fw-6d6d7188a8f7832e7ce80dc53cf34935e40e6014.tar.gz
Allow scrolling of license text
Diffstat (limited to 'lua/licenses.lua')
-rw-r--r--lua/licenses.lua23
1 files changed, 17 insertions, 6 deletions
diff --git a/lua/licenses.lua b/lua/licenses.lua
index 0ccbcb65..59251b51 100644
--- a/lua/licenses.lua
+++ b/lua/licenses.lua
@@ -7,6 +7,7 @@ local widgets = require("widgets")
local font = require("font")
local styles = require("styles")
local screen = require("screen")
+local lvgl = require("lvgl")
local function show_license(text)
backstack.push(widgets.MenuScreen:new {
@@ -14,12 +15,22 @@ local function show_license(text)
title = "Licenses",
create_ui = function(self)
widgets.MenuScreen.create_ui(self)
- self.root:Label {
- w = lvgl.PCT(100),
- h = lvgl.SIZE_CONTENT,
- text_font = font.fusion_10,
- text = text,
- }
+ -- Licenses are all longer than one screen, so we need to be able to
+ -- scroll to read all the text. Break up the content by line, and
+ -- insert an object after each line that the user can scroll to.
+ for line in text:gmatch("[^\r\n]+") do
+ self.root:Label {
+ w = lvgl.PCT(100),
+ h = lvgl.SIZE_CONTENT,
+ text_font = font.fusion_10,
+ text = line,
+ }
+ local scroller = self.root:Object { w = 1, h = 1 }
+ scroller:onevent(lvgl.EVENT.FOCUSED, function()
+ scroller:scroll_to_view(1)
+ end)
+ lvgl.group.get_default():add_obj(scroller)
+ end
end
})
end