summaryrefslogtreecommitdiff
path: root/src/ui/include
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-01-05 10:38:35 +1100
committerjacqueline <me@jacqueline.id.au>2024-01-05 10:38:35 +1100
commit34cae4e6e4bb00b3453bcdab084368a949c908a4 (patch)
tree024caadd70ea35ab2c73cc782f3a37c93a90702f /src/ui/include
parent938ba62f57ed2c002bae4aec236eeaeb200e4cba (diff)
downloadtangara-fw-34cae4e6e4bb00b3453bcdab084368a949c908a4.tar.gz
add an alerts module for lua, and implement a volume indicator with it
Diffstat (limited to 'src/ui/include')
-rw-r--r--src/ui/include/screen.hpp2
-rw-r--r--src/ui/include/ui_events.hpp8
-rw-r--r--src/ui/include/ui_fsm.hpp11
3 files changed, 18 insertions, 3 deletions
diff --git a/src/ui/include/screen.hpp b/src/ui/include/screen.hpp
index e9eaeeb0..4fe0a3b7 100644
--- a/src/ui/include/screen.hpp
+++ b/src/ui/include/screen.hpp
@@ -40,6 +40,7 @@ class Screen {
auto root() -> lv_obj_t* { return root_; }
auto content() -> lv_obj_t* { return content_; }
+ auto alert() -> lv_obj_t* { return alert_; }
auto modal_content() -> lv_obj_t* { return modal_content_; }
auto modal_group(lv_group_t* g) -> void { modal_group_ = g; }
@@ -68,6 +69,7 @@ class Screen {
lv_obj_t* const root_;
lv_obj_t* content_;
lv_obj_t* modal_content_;
+ lv_obj_t* alert_;
lv_group_t* const group_;
lv_group_t* modal_group_;
diff --git a/src/ui/include/ui_events.hpp b/src/ui/include/ui_events.hpp
index 111f37a8..59be7606 100644
--- a/src/ui/include/ui_events.hpp
+++ b/src/ui/include/ui_events.hpp
@@ -24,9 +24,9 @@ struct OnStorageChange : tinyfsm::Event {
struct OnSystemError : tinyfsm::Event {};
- struct OnLuaError : tinyfsm::Event {
- std::string message;
- };
+struct OnLuaError : tinyfsm::Event {
+ std::string message;
+};
namespace internal {
@@ -54,6 +54,8 @@ struct OnboardingNavigate : tinyfsm::Event {
struct ModalConfirmPressed : tinyfsm::Event {};
struct ModalCancelPressed : tinyfsm::Event {};
+struct DismissAlerts : tinyfsm::Event {};
+
} // namespace internal
} // namespace ui
diff --git a/src/ui/include/ui_fsm.hpp b/src/ui/include/ui_fsm.hpp
index ba3f5e3f..33f9eac4 100644
--- a/src/ui/include/ui_fsm.hpp
+++ b/src/ui/include/ui_fsm.hpp
@@ -60,6 +60,7 @@ class UiState : public tinyfsm::Fsm<UiState> {
virtual void react(const audio::PlaybackFinished&);
virtual void react(const audio::PlaybackUpdate&);
virtual void react(const audio::QueueUpdate&);
+ virtual void react(const audio::VolumeChanged&){};
virtual void react(const system_fsm::KeyLockChanged&);
virtual void react(const OnLuaError&) {}
@@ -76,6 +77,8 @@ class UiState : public tinyfsm::Fsm<UiState> {
void react(const internal::ControlSchemeChanged&);
virtual void react(const internal::ReindexDatabase&){};
+ void react(const internal::DismissAlerts&);
+
virtual void react(const database::event::UpdateStarted&){};
virtual void react(const database::event::UpdateProgress&){};
virtual void react(const database::event::UpdateFinished&){};
@@ -129,6 +132,7 @@ class Lua : public UiState {
void react(const audio::PlaybackStarted&) override;
void react(const audio::PlaybackUpdate&) override;
void react(const audio::PlaybackFinished&) override;
+ void react(const audio::VolumeChanged&) override;
void react(const internal::BackPressed&) override;
using UiState::react;
@@ -136,6 +140,10 @@ class Lua : public UiState {
private:
auto PushLuaScreen(lua_State*) -> int;
auto PopLuaScreen(lua_State*) -> int;
+
+ auto ShowAlert(lua_State*) -> int;
+ auto HideAlert(lua_State*) -> int;
+
auto SetPlaying(const lua::LuaValue&) -> bool;
auto SetRandom(const lua::LuaValue&) -> bool;
auto SetRepeat(const lua::LuaValue&) -> bool;
@@ -154,6 +162,9 @@ class Lua : public UiState {
std::shared_ptr<lua::Property> queue_size_;
std::shared_ptr<lua::Property> queue_repeat_;
std::shared_ptr<lua::Property> queue_random_;
+
+ std::shared_ptr<lua::Property> volume_current_pct_;
+ std::shared_ptr<lua::Property> volume_current_db_;
};
class Browse : public UiState {