summaryrefslogtreecommitdiff
path: root/lua/playing.lua
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-02-12 17:10:03 +1100
committerjacqueline <me@jacqueline.id.au>2024-02-12 17:10:03 +1100
commit36f4c77fb22fd8ba433696a6fbd005d504e86186 (patch)
treeb3242f8edcd395f2b498fad40e43e1f36a9a2b00 /lua/playing.lua
parent03c0968168090b1093bda7e05874c201ae58b57b (diff)
parent527374c72e1ec52e1d5814dbee3587ae100631dd (diff)
downloadtangara-fw-36f4c77fb22fd8ba433696a6fbd005d504e86186.tar.gz
Merge branch 'main' of codeberg.org:cool-tech-zone/tangara-fw
Diffstat (limited to 'lua/playing.lua')
-rw-r--r--lua/playing.lua65
1 files changed, 52 insertions, 13 deletions
diff --git a/lua/playing.lua b/lua/playing.lua
index e31e10a2..c6a3f47e 100644
--- a/lua/playing.lua
+++ b/lua/playing.lua
@@ -12,6 +12,10 @@ local img = {
next_disabled = "//lua/img/next_disabled.png",
prev = "//lua/img/prev.png",
prev_disabled = "//lua/img/prev_disabled.png",
+ shuffle = "//lua/img/shuffle.png",
+ shuffle_disabled = "//lua/img/shuffle_disabled.png",
+ repeat_enabled = "//lua/img/repeat.png",
+ repeat_disabled = "//lua/img/repeat_disabled.png",
}
return function(opts)
@@ -69,10 +73,21 @@ return function(opts)
align_items = "center",
align_content = "center",
},
+ w = lvgl.PCT(100),
+ h = lvgl.SIZE_CONTENT,
+ }
+
+ playlist:Object({ w = 3, h = 1 }) -- spacer
+
+ local cur_time = playlist:Label {
w = lvgl.SIZE_CONTENT,
h = lvgl.SIZE_CONTENT,
+ text = "",
+ text_font = font.fusion_10,
}
+ playlist:Object({ flex_grow = 1, h = 1 }) -- spacer
+
local playlist_pos = playlist:Label {
text = "",
text_font = font.fusion_10,
@@ -86,6 +101,17 @@ return function(opts)
text_font = font.fusion_10,
}
+ playlist:Object({ flex_grow = 1, h = 1 }) -- spacer
+
+ local end_time = playlist:Label {
+ w = lvgl.SIZE_CONTENT,
+ h = lvgl.SIZE_CONTENT,
+ align = lvgl.ALIGN.RIGHT_MID,
+ text = "",
+ text_font = font.fusion_10,
+ }
+ playlist:Object({ w = 3, h = 1 }) -- spacer
+
local scrubber = screen.root:Bar {
w = lvgl.PCT(100),
h = 5,
@@ -106,15 +132,15 @@ return function(opts)
pad_all = 2,
}
- local cur_time = controls:Label {
- w = lvgl.SIZE_CONTENT,
- h = lvgl.SIZE_CONTENT,
- text = "",
- text_font = font.fusion_10,
- }
controls:Object({ flex_grow = 1, h = 1 }) -- spacer
+ local repeat_btn = controls:Button {}
+ repeat_btn:onClicked(function()
+ queue.repeat_track:set(not queue.repeat_track:get())
+ end)
+ local repeat_img = repeat_btn:Image { src = img.repeat_enabled }
+
local prev_btn = controls:Button {}
prev_btn:onClicked(queue.previous)
local prev_img = prev_btn:Image { src = img.prev_disabled }
@@ -130,15 +156,14 @@ return function(opts)
next_btn:onClicked(queue.next)
local next_img = next_btn:Image { src = img.next_disabled }
+ local shuffle_btn = controls:Button {}
+ shuffle_btn:onClicked(function()
+ queue.random:set(not queue.random:get())
+ end)
+ local shuffle_img = shuffle_btn:Image { src = img.shuffle }
+
controls:Object({ flex_grow = 1, h = 1 }) -- spacer
- local end_time = controls:Label {
- w = lvgl.SIZE_CONTENT,
- h = lvgl.SIZE_CONTENT,
- align = lvgl.ALIGN.RIGHT_MID,
- text = "",
- text_font = font.fusion_10,
- }
local format_time = function(time)
return string.format("%d:%02d", time // 60, time % 60)
@@ -181,6 +206,20 @@ return function(opts)
pos > 1 and img.prev or img.prev_disabled
)
end),
+ queue.random:bind(function(shuffling)
+ if shuffling then
+ shuffle_img:set_src(img.shuffle)
+ else
+ shuffle_img:set_src(img.shuffle_disabled)
+ end
+ end),
+ queue.repeat_track:bind(function(en)
+ if en then
+ repeat_img:set_src(img.repeat_enabled)
+ else
+ repeat_img:set_src(img.repeat_disabled)
+ end
+ end),
queue.size:bind(function(num)
if not num then return end
playlist_total:set { text = tostring(num) }