summaryrefslogtreecommitdiff
path: root/src/ui/include
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-11-24 15:13:10 +1100
committerjacqueline <me@jacqueline.id.au>2023-11-24 15:13:10 +1100
commit7c6eb2997cbba350e7384151e13659271508e08f (patch)
treeb6f95a4843521e69b24cbf4c126d84442d19fc23 /src/ui/include
parent230721cd6271f3239b42e1d2471f8db15bebd712 (diff)
downloadtangara-fw-7c6eb2997cbba350e7384151e13659271508e08f.tar.gz
Migrate 'now playing' screen to lua
Diffstat (limited to 'src/ui/include')
-rw-r--r--src/ui/include/modal_add_to_queue.hpp41
-rw-r--r--src/ui/include/screen_onboarding.hpp63
-rw-r--r--src/ui/include/screen_playing.hpp73
-rw-r--r--src/ui/include/screen_track_browser.hpp74
-rw-r--r--src/ui/include/ui_fsm.hpp43
5 files changed, 10 insertions, 284 deletions
diff --git a/src/ui/include/modal_add_to_queue.hpp b/src/ui/include/modal_add_to_queue.hpp
deleted file mode 100644
index e6417cd4..00000000
--- a/src/ui/include/modal_add_to_queue.hpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2023 jacqueline <me@jacqueline.id.au>
- *
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-#pragma once
-
-#include <memory>
-#include <vector>
-
-#include "database.hpp"
-#include "index.hpp"
-#include "lvgl.h"
-
-#include "modal.hpp"
-#include "source.hpp"
-#include "track_queue.hpp"
-
-namespace ui {
-namespace modals {
-
-class AddToQueue : public Modal {
- public:
- AddToQueue(Screen*,
- audio::TrackQueue&,
- std::shared_ptr<playlist::IResetableSource>,
- bool all_tracks_only = false);
-
- private:
- audio::TrackQueue& queue_;
- std::shared_ptr<playlist::IResetableSource> item_;
- lv_obj_t* container_;
-
- lv_obj_t* selected_track_btn_;
- lv_obj_t* all_tracks_btn_;
- bool all_tracks_;
-};
-
-} // namespace modals
-} // namespace ui
diff --git a/src/ui/include/screen_onboarding.hpp b/src/ui/include/screen_onboarding.hpp
deleted file mode 100644
index 0c3c61fb..00000000
--- a/src/ui/include/screen_onboarding.hpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2023 jacqueline <me@jacqueline.id.au>
- *
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-#pragma once
-
-#include <memory>
-#include <vector>
-
-#include "lvgl.h"
-
-#include "screen.hpp"
-
-namespace ui {
-namespace screens {
-
-class Onboarding : public Screen {
- public:
- Onboarding(const std::pmr::string& title, bool show_prev, bool show_next);
-
- private:
- lv_obj_t* window_;
- lv_obj_t* title_;
- lv_obj_t* next_button_;
- lv_obj_t* prev_button_;
-
- protected:
- lv_obj_t* content_;
-};
-
-namespace onboarding {
-
-class LinkToManual : public Onboarding {
- public:
- LinkToManual();
-};
-
-class Controls : public Onboarding {
- public:
- Controls();
-};
-
-class MissingSdCard : public Onboarding {
- public:
- MissingSdCard();
-};
-
-class FormatSdCard : public Onboarding {
- public:
- FormatSdCard();
-};
-
-class InitDatabase : public Onboarding {
- public:
- InitDatabase();
-};
-
-} // namespace onboarding
-
-} // namespace screens
-} // namespace ui
diff --git a/src/ui/include/screen_playing.hpp b/src/ui/include/screen_playing.hpp
deleted file mode 100644
index 185c55cc..00000000
--- a/src/ui/include/screen_playing.hpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2023 jacqueline <me@jacqueline.id.au>
- *
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-#pragma once
-
-#include <stdint.h>
-#include <sys/_stdint.h>
-#include <memory>
-#include <vector>
-
-#include "bindey/property.h"
-#include "esp_log.h"
-#include "lvgl.h"
-
-#include "database.hpp"
-#include "future_fetcher.hpp"
-#include "model_playback.hpp"
-#include "model_top_bar.hpp"
-#include "screen.hpp"
-#include "track.hpp"
-#include "track_queue.hpp"
-
-namespace ui {
-namespace screens {
-
-/*
- * The 'Now Playing' / 'Currently Playing' screen that contains information
- * about the current track, as well as playback controls.
- */
-class Playing : public Screen {
- public:
- explicit Playing(models::TopBar&,
- models::Playback& playback_model,
- std::weak_ptr<database::Database> db,
- audio::TrackQueue& queue);
- ~Playing();
-
- auto Tick() -> void override;
-
- auto OnFocusAboveFold() -> void;
- auto OnFocusBelowFold() -> void;
-
- Playing(const Playing&) = delete;
- Playing& operator=(const Playing&) = delete;
-
- private:
- auto control_button(lv_obj_t* parent, char* icon) -> lv_obj_t*;
- auto next_up_label(lv_obj_t* parent, const std::pmr::string& text)
- -> lv_obj_t*;
-
- std::weak_ptr<database::Database> db_;
- audio::TrackQueue& queue_;
-
- bindey::property<std::shared_ptr<database::Track>> current_track_;
- bindey::property<std::vector<std::shared_ptr<database::Track>>> next_tracks_;
-
- std::unique_ptr<database::FutureFetcher<std::shared_ptr<database::Track>>>
- new_track_;
- std::unique_ptr<
- database::FutureFetcher<std::vector<std::shared_ptr<database::Track>>>>
- new_next_tracks_;
-
- lv_obj_t* next_up_header_;
- lv_obj_t* next_up_label_;
- lv_obj_t* next_up_hint_;
- lv_obj_t* next_up_container_;
-};
-
-} // namespace screens
-} // namespace ui
diff --git a/src/ui/include/screen_track_browser.hpp b/src/ui/include/screen_track_browser.hpp
deleted file mode 100644
index 0b2d6fc3..00000000
--- a/src/ui/include/screen_track_browser.hpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2023 jacqueline <me@jacqueline.id.au>
- *
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-#pragma once
-
-#include <deque>
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "lvgl.h"
-
-#include "database.hpp"
-#include "model_top_bar.hpp"
-#include "screen.hpp"
-#include "track_queue.hpp"
-
-namespace ui {
-namespace screens {
-
-class TrackBrowser : public Screen {
- public:
- TrackBrowser(
- models::TopBar& top_bar,
- audio::TrackQueue& queue,
- std::weak_ptr<database::Database> db,
- const std::pmr::vector<std::pmr::string>& breadcrumbs,
- std::future<database::Result<database::IndexRecord>*>&& initial_page);
- ~TrackBrowser() {}
-
- auto Tick() -> void override;
-
- auto OnItemSelected(lv_event_t* ev) -> void;
- auto OnItemClicked(lv_event_t* ev) -> void;
-
- private:
- enum Position {
- START = 0,
- END = 1,
- };
- auto AddLoadingIndictor(Position pos) -> void;
- auto AddResults(Position pos,
- std::shared_ptr<database::Result<database::IndexRecord>>)
- -> void;
- auto DropPage(Position pos) -> void;
- auto FetchNewPage(Position pos) -> void;
-
- auto GetNumRecords() -> std::size_t;
- auto GetItemIndex(lv_obj_t* obj) -> std::optional<std::size_t>;
-
- audio::TrackQueue& queue_;
- std::weak_ptr<database::Database> db_;
- lv_obj_t* back_button_;
- lv_obj_t* play_button_;
- lv_obj_t* enqueue_button_;
- lv_obj_t* list_;
- lv_obj_t* loading_indicator_;
-
- std::pmr::vector<std::pmr::string> breadcrumbs_;
-
- std::optional<Position> loading_pos_;
- std::optional<std::future<database::Result<database::IndexRecord>*>>
- loading_page_;
-
- std::shared_ptr<database::Result<database::IndexRecord>> initial_page_;
- std::deque<std::shared_ptr<database::Result<database::IndexRecord>>>
- current_pages_;
-};
-
-} // namespace screens
-} // namespace ui
diff --git a/src/ui/include/ui_fsm.hpp b/src/ui/include/ui_fsm.hpp
index 9e81259a..9f530d71 100644
--- a/src/ui/include/ui_fsm.hpp
+++ b/src/ui/include/ui_fsm.hpp
@@ -6,8 +6,7 @@
#pragma once
-#include <stdint.h>
-#include <sys/_stdint.h>
+#include <cstdint>
#include <memory>
#include <stack>
@@ -23,7 +22,6 @@
#include "nvs.hpp"
#include "property.hpp"
#include "relative_wheel.hpp"
-#include "screen_playing.hpp"
#include "screen_settings.hpp"
#include "service_locator.hpp"
#include "tinyfsm.hpp"
@@ -60,16 +58,14 @@ class UiState : public tinyfsm::Fsm<UiState> {
virtual void react(const system_fsm::BatteryStateChanged&);
virtual void react(const audio::PlaybackStarted&);
virtual void react(const audio::PlaybackFinished&);
- void react(const audio::PlaybackUpdate&);
- void react(const audio::QueueUpdate&);
+ virtual void react(const audio::PlaybackUpdate&);
+ virtual void react(const audio::QueueUpdate&);
virtual void react(const system_fsm::KeyLockChanged&);
virtual void react(const OnLuaError&) {}
virtual void react(const internal::RecordSelected&) {}
- virtual void react(const internal::IndexSelected&) {}
virtual void react(const internal::BackPressed&) {}
- virtual void react(const internal::ShowNowPlaying&){};
virtual void react(const internal::ShowSettingsPage&){};
virtual void react(const internal::ModalCancelPressed&) {
sCurrentModal.reset();
@@ -127,12 +123,12 @@ class Lua : public UiState {
void react(const OnLuaError&) override;
- void react(const internal::IndexSelected&) override;
- void react(const internal::ShowNowPlaying&) override;
void react(const internal::ShowSettingsPage&) override;
void react(const system_fsm::BatteryStateChanged&) override;
+ void react(const audio::QueueUpdate&) override;
void react(const audio::PlaybackStarted&) override;
+ void react(const audio::PlaybackUpdate&) override;
void react(const audio::PlaybackFinished&) override;
using UiState::react;
@@ -144,32 +140,23 @@ class Lua : public UiState {
std::shared_ptr<lua::Property> battery_pct_;
std::shared_ptr<lua::Property> battery_mv_;
std::shared_ptr<lua::Property> battery_charging_;
+
std::shared_ptr<lua::Property> bluetooth_en_;
+
std::shared_ptr<lua::Property> playback_playing_;
std::shared_ptr<lua::Property> playback_track_;
-};
-
-class Onboarding : public UiState {
- public:
- void entry() override;
-
- void react(const internal::OnboardingNavigate&) override;
+ std::shared_ptr<lua::Property> playback_position_;
- using UiState::react;
-
- private:
- uint8_t progress_;
- bool has_formatted_;
+ std::shared_ptr<lua::Property> queue_position_;
+ std::shared_ptr<lua::Property> queue_size_;
};
class Browse : public UiState {
public:
void entry() override;
- void react(const internal::RecordSelected&) override;
void react(const internal::BackPressed&) override;
- void react(const internal::ShowNowPlaying&) override;
void react(const internal::ShowSettingsPage&) override;
void react(const internal::ReindexDatabase&) override;
@@ -178,16 +165,6 @@ class Browse : public UiState {
using UiState::react;
};
-class Playing : public UiState {
- public:
- void entry() override;
- void exit() override;
-
- void react(const internal::BackPressed&) override;
-
- using UiState::react;
-};
-
class Indexing : public UiState {
public:
void entry() override;