Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1105 Added checks on timelinecells, so scrub is tracked #1257

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion core_lib/src/interface/timelinecells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,17 @@ void TimeLineCells::paintEvent(QPaintEvent*)

if (mType == TIMELINE_CELL_TYPE::Tracks)
{
if (!isPlaying) {
if (!isPlaying)
{
paintOnionSkin(painter);
}

if (mPrevFrame != mEditor->currentFrame() || mEditor->playback()->isPlaying())
{
mPrevFrame = mEditor->currentFrame();
trackScrubber();
}

// --- draw the position of the current frame
if (mEditor->currentFrame() > mFrameOffset)
{
Expand Down Expand Up @@ -761,3 +768,24 @@ void TimeLineCells::setMouseMoveY(int x)
update();
}
}

void TimeLineCells::trackScrubber()
{
if (mEditor->currentFrame() <= mFrameOffset)
{
// Move the timeline back if the scrubber is offscreen to the left
mFrameOffset = mEditor->currentFrame() - 1;
emit offsetChanged(mFrameOffset);
mTimeLine->updateContent();
}
else if (width() < (mEditor->currentFrame() - mFrameOffset + 1) * mFrameSize)
{
// Move timeline forward if the scrubber is offscreen to the right
if (mEditor->playback()->isPlaying())
mFrameOffset = mFrameOffset + ((mEditor->currentFrame() - mFrameOffset) / 2);
else
mFrameOffset = mEditor->currentFrame() - width() / mFrameSize;
emit offsetChanged(mFrameOffset);
mTimeLine->updateContent();
}
}
2 changes: 2 additions & 0 deletions core_lib/src/interface/timelinecells.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public slots:
void setMouseMoveY(int x);

protected:
void trackScrubber();
void drawContent();
void paintOnionSkin(QPainter& painter);
void paintEvent(QPaintEvent* event);
Expand Down Expand Up @@ -113,6 +114,7 @@ private slots:
int mLastFrameNumber = -1;
int mMouseMoveY = 0;
int mMouseMoveX = 0;
int mPrevFrame = 0;
int mFrameOffset = 0;
int mLayerOffset = 0;
Qt::MouseButton primaryButton = Qt::NoButton;
Expand Down