diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-02-12 17:10:03 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-02-12 17:10:03 +1100 |
| commit | 36f4c77fb22fd8ba433696a6fbd005d504e86186 (patch) | |
| tree | b3242f8edcd395f2b498fad40e43e1f36a9a2b00 /src/ui | |
| parent | 03c0968168090b1093bda7e05874c201ae58b57b (diff) | |
| parent | 527374c72e1ec52e1d5814dbee3587ae100631dd (diff) | |
| download | tangara-fw-36f4c77fb22fd8ba433696a6fbd005d504e86186.tar.gz | |
Merge branch 'main' of codeberg.org:cool-tech-zone/tangara-fw
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/include/themes.hpp | 1 | ||||
| -rw-r--r-- | src/ui/include/ui_fsm.hpp | 2 | ||||
| -rw-r--r-- | src/ui/themes.cpp | 10 | ||||
| -rw-r--r-- | src/ui/ui_fsm.cpp | 39 |
4 files changed, 49 insertions, 3 deletions
diff --git a/src/ui/include/themes.hpp b/src/ui/include/themes.hpp index 576ea42e..11680c0d 100644 --- a/src/ui/include/themes.hpp +++ b/src/ui/include/themes.hpp @@ -32,6 +32,7 @@ class Theme { lv_style_t button_style_; lv_style_t bar_style_; lv_style_t dropdown_style_; + lv_style_t dropdown_list_style_; lv_style_t slider_indicator_style_; lv_style_t slider_knob_style_; 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/themes.cpp b/src/ui/themes.cpp index bad73ee6..f8390570 100644 --- a/src/ui/themes.cpp +++ b/src/ui/themes.cpp @@ -89,6 +89,14 @@ Theme::Theme() { lv_style_set_border_color(&dropdown_style_, lv_palette_main(LV_PALETTE_BLUE)); lv_style_set_border_side(&dropdown_style_, LV_BORDER_SIDE_FULL); + lv_style_init(&dropdown_list_style_); + lv_style_set_radius(&dropdown_list_style_, 2); + lv_style_set_border_width(&dropdown_list_style_, 1); + lv_style_set_border_color(&dropdown_list_style_, lv_palette_main(LV_PALETTE_BLUE_GREY)); + lv_style_set_bg_opa(&dropdown_list_style_, LV_OPA_COVER); + lv_style_set_bg_color(&dropdown_list_style_, lv_color_white()); + lv_style_set_pad_all(&dropdown_list_style_, 2); + lv_theme_t* parent_theme = lv_disp_get_theme(NULL); theme_ = *parent_theme; theme_.user_data = this; @@ -124,6 +132,8 @@ void Theme::Callback(lv_obj_t* obj) { lv_obj_add_style(obj, &switch_knob_style_, LV_PART_KNOB); } else if (lv_obj_check_type(obj, &lv_dropdown_class)) { lv_obj_add_style(obj, &dropdown_style_, LV_PART_MAIN); + } else if (lv_obj_check_type(obj, &lv_dropdownlist_class)) { + lv_obj_add_style(obj, &dropdown_list_style_, LV_PART_MAIN); } } diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp index 630238e7..728c9756 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) { @@ -423,7 +446,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", @@ -567,6 +591,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); } |
