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

Fix: tabs move animation for duplicated tabs #5426

Merged
merged 7 commits into from
Jun 1, 2024

Conversation

kornes
Copy link
Contributor

@kornes kornes commented May 26, 2024

Repro steps

  1. duplicate a tab which is not last
  2. close duplicated tab (might require 2 attempts)
  3. removed tab will leave blank gap, following tab wont start animation to blank space

Issue
positionChangedAnimation_ (QAbstractAnimation) for tabs is kept between animations,
if endValue() of previously run animation match current targetPos - animation won't fire even though it should because current starting position might be different. This results in a gap which will stay until next notebook layout happen (where all tabs are moved again without animation).
There are also a lot of unnecessary Notebook layouts (like creating new tab results in 5x layouts of whole notebook) so that's something to fix too.

Fix

  1. endValue for animation is now only checked for running animations (adf0458)
  2. returning early when move is not needed also fixes the problem alone (72f48b9)

added some minor refactors too

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/widgets/helper/NotebookTab.cpp Show resolved Hide resolved
src/widgets/helper/NotebookTab.cpp Show resolved Hide resolved
src/widgets/helper/NotebookTab.hpp Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/widgets/helper/NotebookTab.cpp Show resolved Hide resolved
src/widgets/helper/NotebookTab.cpp Show resolved Hide resolved
src/widgets/helper/NotebookTab.hpp Show resolved Hide resolved
@pajlada pajlada enabled auto-merge (squash) June 1, 2024 09:47
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

@@ -407,30 +408,32 @@ void NotebookTab::hideTabXChanged()
this->update();
}

void NotebookTab::moveAnimated(QPoint pos, bool animated)
void NotebookTab::moveAnimated(QPoint targetPos, bool animated)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "QPoint" is directly included [misc-include-cleaner]

src/widgets/helper/NotebookTab.cpp:26:

+ #include <qpoint.h>

return;
}

if (this->positionChangedAnimation_.endValue() == pos)
if (this->positionChangedAnimation_.state() ==
QAbstractAnimation::Running &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "QAbstractAnimation" is directly included [misc-include-cleaner]

src/widgets/helper/NotebookTab.cpp:26:

+ #include <qabstractanimation.h>

@@ -65,7 +65,7 @@ class NotebookTab : public Button
void setHighlightsEnabled(const bool &newVal);
bool hasHighlightsEnabled() const;

void moveAnimated(QPoint pos, bool animated = true);
void moveAnimated(QPoint targetPos, bool animated = true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "QPoint" is directly included [misc-include-cleaner]

src/widgets/helper/NotebookTab.hpp:10:

+ #include <qpoint.h>

@pajlada pajlada merged commit c3bb99e into Chatterino:master Jun 1, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants