diff options
| author | ailurux <ailuruxx@gmail.com> | 2024-02-12 15:36:56 +1100 |
|---|---|---|
| committer | ailurux <ailuruxx@gmail.com> | 2024-02-12 15:36:56 +1100 |
| commit | 9512bd97bbac48fa33339cc248c76070063bbc61 (patch) | |
| tree | 00ecbfecf5961954a7f7e349a73ab0ba52e90d88 /lua | |
| parent | 679521d8e37171e8698d618fca9a7908348c429f (diff) | |
| download | tangara-fw-9512bd97bbac48fa33339cc248c76070063bbc61.tar.gz | |
Add buttons for shuffle + repeat track
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/img/repeat.png | bin | 0 -> 4786 bytes | |||
| -rw-r--r-- | lua/img/repeat_disabled.png | bin | 0 -> 7287 bytes | |||
| -rw-r--r-- | lua/img/shuffle.png | bin | 0 -> 4809 bytes | |||
| -rw-r--r-- | lua/img/shuffle_disabled.png | bin | 0 -> 8706 bytes | |||
| -rw-r--r-- | lua/playing.lua | 65 |
5 files changed, 52 insertions, 13 deletions
diff --git a/lua/img/repeat.png b/lua/img/repeat.png Binary files differnew file mode 100644 index 00000000..9a4da7fd --- /dev/null +++ b/lua/img/repeat.png diff --git a/lua/img/repeat_disabled.png b/lua/img/repeat_disabled.png Binary files differnew file mode 100644 index 00000000..20b6ab59 --- /dev/null +++ b/lua/img/repeat_disabled.png diff --git a/lua/img/shuffle.png b/lua/img/shuffle.png Binary files differnew file mode 100644 index 00000000..b54e359d --- /dev/null +++ b/lua/img/shuffle.png diff --git a/lua/img/shuffle_disabled.png b/lua/img/shuffle_disabled.png Binary files differnew file mode 100644 index 00000000..912d0e95 --- /dev/null +++ b/lua/img/shuffle_disabled.png 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) } |
