wavelength 1.0.0
Loading...
Searching...
No Matches
lyric.h
Go to the documentation of this file.
1#pragma once
2
3#include <set>
4
5#include "os/command.h"
6#include "os/ptr.h"
7#include "os/string.h"
8#include "script/dataarray.h"
9
18class Lyric {
19public:
21 class LyricData {
22 public:
23 LyricData() = default;
24
31 LyricData(int nTick, const String &text) : mTick(nTick), mText(text) {
32 }
33
40 bool operator<(const LyricData &other) const {
41 return mTick < other.mTick;
42 }
43
45 int GetTick() const {
46 return mTick;
47 }
48
50 const String &GetText() const {
51 return mText;
52 }
53
54 private:
55 int mTick;
56 String mText;
57 };
58
67 Lyric(int nTicksPerBar, int nLoopBars);
68
76
88 void AddLyric(int nTick, const char *pszText);
89
96 void Start();
97
104 void Stop();
105
115 void Advance();
116
125 static void ToggleShowing(DataArray *pCommand, void *pUserData);
126
127private:
128 int mTicksPerBar;
129 int mLoopBars;
130 std::set<LyricData> mLyrics;
131 std::set<LyricData>::iterator mCurrent;
132 Ptr<Command> mAdvanceCommand;
133 int mShowing;
134};
Reference-counted array of script data nodes.
Definition dataarray.h:20
int GetTick() const
Definition lyric.h:45
const String & GetText() const
Definition lyric.h:50
LyricData()=default
LyricData(int nTick, const String &text)
Construct a lyric.
Definition lyric.h:31
bool operator<(const LyricData &other) const
Order lyrics by tick.
Definition lyric.h:40
~Lyric()
Stop showing lyrics and unregister the lyric script command.
void AddLyric(int nTick, const char *pszText)
Add a lyric.
void Start()
Clear the lyric and schedule the first one.
void Advance()
Show the current lyric and schedule the next one.
Lyric(int nTicksPerBar, int nLoopBars)
Construct an empty lyric track and register the lyric script command.
static void ToggleShowing(DataArray *pCommand, void *pUserData)
Toggle whether lyrics show on the display, the lyric script command.
void Stop()
Withdraw the scheduled lyric.
Owner of one reference to an Attachment.
Definition ptr.h:16
Growable text buffer that is also a PrnStream.
Definition string.h:19