forked from HookedBehemoth/sys-tune
-
Notifications
You must be signed in to change notification settings - Fork 2
/
elm_status_bar.hpp
92 lines (81 loc) · 2.55 KB
/
elm_status_bar.hpp
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#pragma once
#include "../../ipc/tune.h"
#include "symbol.hpp"
#include <tesla.hpp>
class StatusBar final : public tsl::elm::Element {
private:
bool m_playing;
TuneRepeatMode m_repeat;
TuneShuffleMode m_shuffle;
TuneCurrentStats m_stats;
float m_percentage;
std::string_view m_current_track;
std::string m_scroll_text;
u32 m_text_width;
u32 m_scroll_offset;
bool m_truncated;
u8 m_counter;
bool m_touched = false;
public:
StatusBar();
tsl::elm::Element *requestFocus(tsl::elm::Element *oldFocus, tsl::FocusDirection direction) override;
void draw(tsl::gfx::Renderer *renderer) override;
void layout(u16 parentX, u16 parentY, u16 parentWidth, u16 parentHeight) override;
bool onClick(u64 keys) override;
bool onTouch(tsl::elm::TouchEvent event, s32 currX, s32 currY, s32 prevX, s32 prevY, s32 initialX, s32 initialY) override;
void update();
void CycleRepeat();
void CyclePlay();
void CycleShuffle();
void Prev();
void Next();
void Backward();
void Forward();
private:
ALWAYS_INLINE constexpr s32 CenterOfLine(u8 line) {
return (tsl::style::ListItemDefaultHeight * line) + (tsl::style::ListItemDefaultHeight / 2);
}
ALWAYS_INLINE s32 GetRepeatX() {
return this->getX() + (this->getWidth() / 2) - 50;
}
ALWAYS_INLINE s32 GetRepeatY() {
return this->getY() + CenterOfLine(1);
}
ALWAYS_INLINE s32 GetShuffleX() {
return this->getX() + (this->getWidth() / 2) + 50;
}
ALWAYS_INLINE s32 GetShuffleY() {
return this->getY() + CenterOfLine(1);
}
ALWAYS_INLINE s32 GetPlayStateX() {
return this->getX() + (this->getWidth() / 2);
}
ALWAYS_INLINE s32 GetPlayStateY() {
return this->getY() + CenterOfLine(2);
}
ALWAYS_INLINE s32 GetBackwardX() {
return this->getX() + 30;
}
ALWAYS_INLINE s32 GetBackwardY() {
return this->getY() + CenterOfLine(2);
}
ALWAYS_INLINE s32 GetPrevX() {
return this->getX() + ((this->getWidth() / 4) * 1);
}
ALWAYS_INLINE s32 GetPrevY() {
return this->getY() + CenterOfLine(2);
}
ALWAYS_INLINE s32 GetNextX() {
return this->getX() + ((this->getWidth() / 4) * 3);
}
ALWAYS_INLINE s32 GetNextY() {
return this->getY() + CenterOfLine(2);
}
ALWAYS_INLINE s32 GetForwardX() {
return this->getX() + this->getWidth() - 30;
}
ALWAYS_INLINE s32 GetForwardY() {
return this->getY() + CenterOfLine(2);
}
const AlphaSymbol &GetPlaybackSymbol();
};