diff options
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/browser.lua | 21 | ||||
| -rw-r--r-- | lua/img/bat/chg.png | bin | 666 -> 667 bytes | |||
| -rw-r--r-- | lua/img/play_small.png | bin | 593 -> 593 bytes | |||
| -rw-r--r-- | lua/main_menu.lua | 13 | ||||
| -rw-r--r-- | lua/widgets.lua | 1 |
5 files changed, 22 insertions, 13 deletions
diff --git a/lua/browser.lua b/lua/browser.lua index ccb2dae8..f07d80bc 100644 --- a/lua/browser.lua +++ b/lua/browser.lua @@ -4,7 +4,7 @@ local legacy_ui = require("legacy_ui") local database = require("database") local backstack = require("backstack") local font = require("font") -local playing = require("playing") +local queue = require("queue") local browser = {} @@ -40,7 +40,6 @@ function browser.create(opts) h = lvgl.SIZE_CONTENT, pad_left = 4, pad_right = 4, - pad_top = 2, pad_bottom = 2, bg_opa = lvgl.OPA(100), bg_color = "#fafafa", @@ -64,9 +63,18 @@ function browser.create(opts) h = lvgl.SIZE_CONTENT, pad_column = 4, }) + local original_iterator = opts.iterator:clone() local enqueue = widgets.IconBtn(buttons, "//lua/img/enqueue.png", "Enqueue") + enqueue:onClicked(function() + queue.add(original_iterator) + end) -- enqueue:add_flag(lvgl.FLAG.HIDDEN) local play = widgets.IconBtn(buttons, "//lua/img/play_small.png", "Play") + play:onClicked(function() + queue.clear() + queue.add(original_iterator) + end + ) end screen.list = lvgl.List(screen.root, { @@ -88,7 +96,7 @@ function browser.create(opts) local btn = screen.list:add_btn(nil, tostring(item)) btn:onClicked(function() local contents = item:contents() - if type(contents) == "function" then + if type(contents) == "userdata" then backstack.push(function() return browser.create({ title = opts.title, @@ -97,7 +105,8 @@ function browser.create(opts) }) end) else - print("add", contents) + queue.clear() + queue.add(contents) legacy_ui.open_now_playing() -- backstack.push(playing) end @@ -105,13 +114,13 @@ function browser.create(opts) btn:onevent(lvgl.EVENT.FOCUSED, function() screen.focused_item = this_item if screen.last_item - 5 < this_item then - opts.iterator(screen.add_item) + opts.iterator:next(screen.add_item) end end) end for _ = 1, 8 do - opts.iterator(screen.add_item) + opts.iterator:next(screen.add_item) end return screen diff --git a/lua/img/bat/chg.png b/lua/img/bat/chg.png Binary files differindex af90f02b..d604bb76 100644 --- a/lua/img/bat/chg.png +++ b/lua/img/bat/chg.png diff --git a/lua/img/play_small.png b/lua/img/play_small.png Binary files differindex a7361be4..3fc7032e 100644 --- a/lua/img/play_small.png +++ b/lua/img/play_small.png diff --git a/lua/main_menu.lua b/lua/main_menu.lua index 50e930fb..c0b9b1d1 100644 --- a/lua/main_menu.lua +++ b/lua/main_menu.lua @@ -36,13 +36,12 @@ return function() for id, idx in ipairs(indexes) do local btn = menu.list:add_btn(nil, tostring(idx)) btn:onClicked(function() - legacy_ui.open_browse(id); - -- backstack.push(function() - -- return browser { - -- title = tostring(idx), - -- iterator = idx:iter() - -- } - -- end) + backstack.push(function() + return browser { + title = tostring(idx), + iterator = idx:iter() + } + end) end) end diff --git a/lua/widgets.lua b/lua/widgets.lua index 95615a8c..b601326b 100644 --- a/lua/widgets.lua +++ b/lua/widgets.lua @@ -151,6 +151,7 @@ function widgets.IconBtn(parent, icon, text) } btn:Image { src = icon } btn:Label { text = text, text_font = font.fusion_10 } + return btn end return widgets |
