Skip to content

Commit 883c130

Browse files
committed
Add full timeline playback position marker
1 parent 41254ea commit 883c130

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

Source/Processors/FileReader/FileReaderEditor.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,16 @@ FullTimeline::FullTimeline(FileReader* fr)
3535
{
3636

3737
fileReader = fr;
38+
39+
startTimer(200);
3840
}
3941

4042
FullTimeline::~FullTimeline() {}
4143

44+
void FullTimeline::timerCallback() {
45+
repaint();
46+
}
47+
4248
void FullTimeline::paint(Graphics& g)
4349
{
4450

@@ -95,6 +101,12 @@ void FullTimeline::paint(Graphics& g)
95101

96102
g.fillRoundedRectangle(intervalStartPosition, 0, 2, this->getHeight(), 2);
97103
g.fillRoundedRectangle(intervalStartPosition + intervalWidth, 0, 2, this->getHeight(), 2);
104+
105+
/* Draw the current playback position */
106+
float timelinePos = (float)fileReader->getCurrentSample() / fileReader->getCurrentNumTotalSamples() * getWidth();
107+
108+
g.setOpacity(1.0f);
109+
g.fillRoundedRectangle(timelinePos, 0, 1, this->getHeight(), 0.2);
98110

99111
}
100112

Source/Processors/FileReader/FileReaderEditor.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class PlaybackButton : public Button, public Timer
5858
void paintButton(Graphics &g, bool isMouseOver, bool isButtonDown);
5959
};
6060

61-
class FullTimeline : public Component
61+
class FullTimeline : public Component, public Timer
6262
{
6363
public:
6464
FullTimeline(FileReader*);
@@ -73,6 +73,8 @@ class FullTimeline : public Component
7373

7474
FileReader* fileReader;
7575

76+
void timerCallback();
77+
7678
int intervalStartPosition;
7779
int intervalWidth;
7880
bool intervalIsSelected;
@@ -83,6 +85,7 @@ class FullTimeline : public Component
8385
void mouseUp(const MouseEvent& event);
8486

8587
bool leftSliderIsSelected;
88+
8689
};
8790

8891
class ZoomTimeline : public Component

0 commit comments

Comments
 (0)