CuteLogger
Fast and simple logging solution for Qt based applications
scrubbar.h
1 /*
2  * Copyright (c) 2011-2024 Meltytech, LLC
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef SCRUBBAR_H
19 #define SCRUBBAR_H
20 
21 #include <QWidget>
22 
23 class ScrubBar : public QWidget
24 {
25  Q_OBJECT
26 
27  enum controls {
28  CONTROL_NONE,
29  CONTROL_HEAD,
30  CONTROL_IN,
31  CONTROL_OUT
32  };
33 
34 public:
35  explicit ScrubBar(QWidget *parent = 0);
36 
37  virtual void mousePressEvent(QMouseEvent *event);
38  virtual void mouseReleaseEvent(QMouseEvent *event);
39  virtual void mouseMoveEvent(QMouseEvent *event);
40  void setScale(int maximum);
41  void setFramerate(double fps);
42  int position() const;
43  void setInPoint(int in);
44  void setOutPoint(int out);
45  void setMarkers(const QList<int> &);
46  QList<int> markers() const
47  {
48  return m_markers;
49  }
50  void setMargin(int margin)
51  {
52  m_margin = margin;
53  }
54  void setLoopRange(int start, int end);
55 
56 signals:
57  void paused(int);
58  void seeked(int);
59  void inChanged(int);
60  void outChanged(int);
61 
62 public slots:
63  bool onSeek(int value);
64 
65 protected:
66  virtual void paintEvent(QPaintEvent *e);
67  virtual void resizeEvent(QResizeEvent *);
68  virtual bool event(QEvent *event);
69 
70 private:
71  int m_cursorPosition;
72  int m_head;
73  double m_scale;
74  double m_fps;
75  int m_interval;
76  int m_max;
77  int m_in;
78  int m_out;
79  int m_margin;
80  enum controls m_activeControl;
81  QPixmap m_pixmap;
82  int m_timecodeWidth;
83  int m_secondsPerTick;
84  QList<int> m_markers;
85  int m_loopStart;
86  int m_loopEnd;
87 
88  void updatePixmap();
89 };
90 
91 #endif // SCRUBBAR_H