File indexing completed on 2025-02-23 04:35:42
0001 /* 0002 SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic <max@smoothware.net> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef WAVESUBTITLE_H 0008 #define WAVESUBTITLE_H 0009 0010 #include <core/time.h> 0011 0012 #include <QImage> 0013 #include <QObject> 0014 0015 QT_FORWARD_DECLARE_CLASS(QTextLayout) 0016 0017 namespace SubtitleComposer { 0018 class RichDocument; 0019 class SubtitleLine; 0020 class WaveRenderer; 0021 0022 enum DragPosition { 0023 DRAG_NONE = 0, 0024 DRAG_FORBIDDEN, 0025 DRAG_SHOW, 0026 DRAG_LINE, 0027 DRAG_HIDE 0028 }; 0029 0030 class WaveSubtitle : public QObject 0031 { 0032 Q_OBJECT 0033 0034 public: 0035 explicit WaveSubtitle(SubtitleLine *line, WaveRenderer *parent); 0036 0037 virtual ~WaveSubtitle(); 0038 0039 inline SubtitleLine * line() const { return m_line; } 0040 0041 DragPosition draggableAt(double time, double msTolerance) const; 0042 0043 void dragStart(DragPosition dragMode, double dragTime); 0044 inline void dragUpdate(double dragTime) { m_dragTime = dragTime; } 0045 DragPosition dragEnd(double dragTime); 0046 0047 Time showTime() const; 0048 Time hideTime() const; 0049 0050 const QImage & image() const; 0051 0052 private: 0053 SubtitleLine *m_line; 0054 WaveRenderer *m_rend; 0055 0056 mutable QImage m_image; 0057 mutable bool m_imageDirty = true; 0058 0059 DragPosition m_dragMode = DRAG_NONE; 0060 double m_dragTime = 0.; 0061 double m_dragTimeOffset = 0.; 0062 }; 0063 } 0064 0065 #endif // WAVESUBTITLE_H