summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorailurux <ailuruxx@gmail.com>2024-02-12 15:36:56 +1100
committerailurux <ailuruxx@gmail.com>2024-02-12 15:36:56 +1100
commit9512bd97bbac48fa33339cc248c76070063bbc61 (patch)
tree00ecbfecf5961954a7f7e349a73ab0ba52e90d88 /src/ui
parent679521d8e37171e8698d618fca9a7908348c429f (diff)
downloadtangara-fw-9512bd97bbac48fa33339cc248c76070063bbc61.tar.gz
Add buttons for shuffle + repeat track
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/include/ui_fsm.hpp2
-rw-r--r--src/ui/ui_fsm.cpp39
2 files changed, 38 insertions, 3 deletions
diff --git a/src/ui/include/ui_fsm.hpp b/src/ui/include/ui_fsm.hpp
index c097e764..52ab77a5 100644
--- a/src/ui/include/ui_fsm.hpp
+++ b/src/ui/include/ui_fsm.hpp
@@ -116,6 +116,7 @@ class UiState : public tinyfsm::Fsm<UiState> {
static lua::Property sQueuePosition;
static lua::Property sQueueSize;
+ static lua::Property sQueueReplay;
static lua::Property sQueueRepeat;
static lua::Property sQueueRandom;
@@ -165,6 +166,7 @@ class Lua : public UiState {
auto SetPlaying(const lua::LuaValue&) -> bool;
auto SetRandom(const lua::LuaValue&) -> bool;
auto SetRepeat(const lua::LuaValue&) -> bool;
+ auto SetReplay(const lua::LuaValue&) -> bool;
auto QueueNext(lua_State*) -> int;
auto QueuePrevious(lua_State*) -> int;
diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp
index 12584ec7..6e4bbe6f 100644
--- a/src/ui/ui_fsm.cpp
+++ b/src/ui/ui_fsm.cpp
@@ -127,8 +127,30 @@ lua::Property UiState::sPlaybackPosition{0};
lua::Property UiState::sQueuePosition{0};
lua::Property UiState::sQueueSize{0};
-lua::Property UiState::sQueueRepeat{false};
-lua::Property UiState::sQueueRandom{false};
+lua::Property UiState::sQueueRepeat{false, [](const lua::LuaValue& val) {
+ if (!std::holds_alternative<bool>(val)) {
+ return false;
+ }
+ bool new_val = std::get<bool>(val);
+ sServices->track_queue().repeat(new_val);
+ return true;
+}};
+lua::Property UiState::sQueueReplay{false, [](const lua::LuaValue& val) {
+ if (!std::holds_alternative<bool>(val)) {
+ return false;
+ }
+ bool new_val = std::get<bool>(val);
+ sServices->track_queue().replay(new_val);
+ return true;
+}};
+lua::Property UiState::sQueueRandom{false, [](const lua::LuaValue& val) {
+ if (!std::holds_alternative<bool>(val)) {
+ return false;
+ }
+ bool new_val = std::get<bool>(val);
+ sServices->track_queue().random(new_val);
+ return true;
+}};
lua::Property UiState::sVolumeCurrentPct{
0, [](const lua::LuaValue& val) {
@@ -296,6 +318,7 @@ void UiState::react(const audio::QueueUpdate&) {
sQueuePosition.Update(current_pos);
sQueueRandom.Update(queue.random());
sQueueRepeat.Update(queue.repeat());
+ sQueueReplay.Update(queue.replay());
}
void UiState::react(const audio::PlaybackStarted& ev) {
@@ -417,7 +440,8 @@ void Lua::entry() {
{"previous", [&](lua_State* s) { return QueuePrevious(s); }},
{"position", &sQueuePosition},
{"size", &sQueueSize},
- {"replay", &sQueueRepeat},
+ {"replay", &sQueueReplay},
+ {"repeat_track", &sQueueRepeat},
{"random", &sQueueRandom},
});
sLua->bridge().AddPropertyModule("volume",
@@ -564,6 +588,15 @@ auto Lua::SetRepeat(const lua::LuaValue& val) -> bool {
return true;
}
+auto Lua::SetReplay(const lua::LuaValue& val) -> bool {
+ if (!std::holds_alternative<bool>(val)) {
+ return false;
+ }
+ bool b = std::get<bool>(val);
+ sServices->track_queue().replay(b);
+ return true;
+}
+
void Lua::exit() {
lv_group_set_default(NULL);
}