File indexing completed on 2024-05-05 16:18:17

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     Q_OBJECT
0033 public:
0034     KateTextAnimation(KTextEditor::Range range, KTextEditor::Attribute::Ptr attribute, KateViewInternal *view);
0035     ~KateTextAnimation() override;
0036 
0037     // draw the text to highlight, given the current animation progress
0038     void draw(QPainter &painter);
0039 
0040 public Q_SLOTS:
0041     // request repaint from view of the respective region
0042     void nextFrame(qreal value);
0043 
0044 private:
0045     // calculate rect for the text to highlight, given the current animation progress
0046     QRectF rectForText();
0047 
0048 private:
0049     KTextEditor::Range m_range;
0050     QString m_text;
0051     KTextEditor::Attribute::Ptr m_attribute;
0052 
0053     KTextEditor::DocumentPrivate *m_doc;
0054     KateViewInternal *m_view;
0055     QTimeLine *m_timeLine;
0056     qreal m_value;
0057 };
0058 
0059 #endif // KATE_TEXT_ANIMATION_H