summaryrefslogtreecommitdiff
path: root/src/ui/include/screen_playing.hpp
blob: fff9cc351b82c33705013f822afc4a70069369c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * 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 "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::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