1 | /* |
2 | SPDX-FileCopyrightText: 2013-2018 Dominik Haumann <dhaumann@kde.org> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #ifndef KATE_TEXT_ANIMATION_H |
8 | #define KATE_TEXT_ANIMATION_H |
9 | |
10 | #include <QObject> |
11 | #include <QRectF> |
12 | #include <QString> |
13 | |
14 | #include <ktexteditor/attribute.h> |
15 | #include <ktexteditor/range.h> |
16 | |
17 | namespace KTextEditor |
18 | { |
19 | class DocumentPrivate; |
20 | } |
21 | class KateViewInternal; |
22 | class QTimeLine; |
23 | class QPainter; |
24 | |
25 | /** |
26 | * This class is used to flash text in the text view. |
27 | * The duration of the flash animation is about 250 milliseconds. |
28 | * When the animation is finished, it deletes itself. |
29 | */ |
30 | class KateTextAnimation : public QObject |
31 | { |
32 | public: |
33 | KateTextAnimation(KTextEditor::Range range, KTextEditor::Attribute::Ptr attribute, KateViewInternal *view); |
34 | ~KateTextAnimation() override; |
35 | |
36 | // draw the text to highlight, given the current animation progress |
37 | void draw(QPainter &painter); |
38 | |
39 | public: |
40 | // request repaint from view of the respective region |
41 | void nextFrame(qreal value); |
42 | |
43 | private: |
44 | // calculate rect for the text to highlight, given the current animation progress |
45 | QRectF rectForText(); |
46 | |
47 | private: |
48 | KTextEditor::Range m_range; |
49 | QString m_text; |
50 | KTextEditor::Attribute::Ptr m_attribute; |
51 | |
52 | KTextEditor::DocumentPrivate *m_doc; |
53 | KateViewInternal *m_view; |
54 | QTimeLine *m_timeLine; |
55 | qreal m_value; |
56 | }; |
57 | |
58 | #endif // KATE_TEXT_ANIMATION_H |
59 | |