Skip to content

Commit d5bd0a1

Browse files
committed
Add zoom timeline playback marker
1 parent 883c130 commit d5bd0a1

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Source/Processors/FileReader/FileReaderEditor.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,17 @@ ZoomTimeline::ZoomTimeline(FileReader* fr)
181181
fileReader = fr;
182182
sliderWidth = 8;
183183
widthInSeconds = 30;
184+
185+
startTimer(200);
184186
}
185187

186188
ZoomTimeline::~ZoomTimeline() {}
187189

190+
void ZoomTimeline::timerCallback()
191+
{
192+
repaint();
193+
}
194+
188195
void ZoomTimeline::updatePlaybackRegion(int min, int max)
189196
{
190197
/* Default zoom slider region to first 10s */
@@ -284,6 +291,14 @@ void ZoomTimeline::paint(Graphics& g)
284291
this->getHeight() + tickHeight,
285292
juce::Justification::centred);
286293

294+
/* Draw the current playback position */
295+
float timelinePos = (float)(fileReader->getCurrentSample() - startTimestamp) / (stopTimestamp - startTimestamp) * getWidth();
296+
297+
if (timelinePos < getWidth())
298+
{
299+
g.setOpacity(1.0f);
300+
g.fillRoundedRectangle(timelinePos, 0, 1, this->getHeight(), 0.2);
301+
}
287302

288303
}
289304

Source/Processors/FileReader/FileReaderEditor.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class FullTimeline : public Component, public Timer
8888

8989
};
9090

91-
class ZoomTimeline : public Component
91+
class ZoomTimeline : public Component, public Timer
9292
{
9393
public:
9494
ZoomTimeline(FileReader*);
@@ -117,6 +117,8 @@ class ZoomTimeline : public Component
117117
bool rightSliderIsSelected;
118118
bool playbackRegionIsSelected;
119119

120+
void timerCallback();
121+
120122
};
121123

122124
class ScrubDrawerButton : public DrawerButton

0 commit comments

Comments
 (0)