File indexing completed on 2024-05-05 03:58:25

0001 /*
0002     SPDX-FileCopyrightText: 2013-2018 Dominik Haumann <dhaumann@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KATE_TEXT_ANIMATION_H
0008 #define KATE_TEXT_ANIMATION_H
0009 
0010 #include <QObject>
0011 #include <QRectF>
0012 #include <QString>
0013 
0014 #include <ktexteditor/attribute.h>
0015 #include <ktexteditor/range.h>
0016 
0017 namespace KTextEditor
0018 {
0019 class DocumentPrivate;
0020 }
0021 class KateViewInternal;
0022 class QTimeLine;
0023 class QPainter;
0024 
0025 /**
0026  * This class is used to flash text in the text view.
0027  * The duration of the flash animation is about 250 milliseconds.
0028  * When the animation is finished, it deletes itself.
0029  */
0030 class KateTextAnimation : public QObject
0031 {
0032 public:
0033     KateTextAnimation(KTextEditor::Range range, KTextEditor::Attribute::Ptr attribute, KateViewInternal *view);
0034     ~KateTextAnimation() override;
0035 
0036     // draw the text to highlight, given the current animation progress
0037     void draw(QPainter &painter);
0038 
0039 public:
0040     // request repaint from view of the respective region
0041     void nextFrame(qreal value);
0042 
0043 private:
0044     // calculate rect for the text to highlight, given the current animation progress
0045     QRectF rectForText();
0046 
0047 private:
0048     KTextEditor::Range m_range;
0049     QString m_text;
0050     KTextEditor::Attribute::Ptr m_attribute;
0051 
0052     KTextEditor::DocumentPrivate *m_doc;
0053     KateViewInternal *m_view;
0054     QTimeLine *m_timeLine;
0055     qreal m_value;
0056 };
0057 
0058 #endif // KATE_TEXT_ANIMATION_H