blob: 1a2c826ac23af0ede8ca6a30854dcd48dee3fa92 (
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
|
/*
* Copyright 2023 jacqueline <me@jacqueline.id.au>
*
* SPDX-License-Identifier: GPL-3.0-only
*/
#pragma once
#include <cstdint>
#include <string>
#include "lvgl.h"
#include "memory_resource.hpp"
namespace ui {
namespace widgets {
class TopBar {
public:
struct Configuration {
bool show_back_button;
std::pmr::string title;
};
enum class PlaybackState {
kIdle,
kPaused,
kPlaying,
};
struct State {
PlaybackState playback_state;
uint_fast8_t battery_percent;
bool is_charging;
};
explicit TopBar(lv_obj_t* parent, const Configuration& config);
auto root() -> lv_obj_t* { return container_; }
auto button() -> lv_obj_t* { return back_button_; }
auto Update(const State&) -> void;
private:
lv_obj_t* container_;
lv_obj_t* back_button_;
lv_obj_t* title_;
lv_obj_t* playback_;
lv_obj_t* battery_;
lv_obj_t* charging_;
};
} // namespace widgets
} // namespace ui
|