-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtimelineeventswidget.h
More file actions
65 lines (51 loc) · 1.88 KB
/
timelineeventswidget.h
File metadata and controls
65 lines (51 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef TIMELINEEVENTSWIDGET_H
#define TIMELINEEVENTSWIDGET_H
#include "timeline.h"
#include "selection.h"
#include <QWidget>
class TimelineEventsWidget : public QWidget
{
Q_OBJECT
public:
explicit TimelineEventsWidget(QWidget *parent = 0);
// getters
inline double cursor() const { return mCursor; }
inline const Selection& selection() const { return mSelection; }
protected:
double pxPerSecond() const;
void paintEvent(QPaintEvent* ev) /* override */;
void mousePressEvent(QMouseEvent* ev) /* override */;
void mouseMoveEvent(QMouseEvent* ev) /* override */;
void mouseReleaseEvent(QMouseEvent* ev) /* override */;
bool event(QEvent* event) /* override */;
// void contextMenuEvent(QContextMenuEvent* ev) /* override */;
// hack so that clicking to gain focus doesn't affect selection
void focusInEvent(QFocusEvent* ev) /* override */;
void focusOutEvent(QFocusEvent* ev) /* override */;
signals:
void singleClicked(double time);
void selectionChanged(const Selection& selection);
void focusGained();
void focusLost();
public slots:
void setEventSource(EventList* events);
void setViewport(double startTime, double length);
void setCursor(double time);
void setSnapInterval(double interval); // in seconds
private:
float pxAtTime(double time) const;
double timeAtCursor(QMouseEvent* ev) const;
int eventPaintRow(const std::shared_ptr<TimelineEvent>& event) const;
QRectF eventPaintRect(const std::shared_ptr<TimelineEvent>& event) const;
std::shared_ptr<TimelineEvent> eventAtPos(const QPointF& pos);
EventList* mEvents;
double mCursor;
double mViewOffset;
double mViewLength;
Selection mSelection;
bool mHadSelection;
double mSnapInterval;
// hack so that clicking to gain focus doesn't affect selection
bool mIgnoreNextClick;
};
#endif // TIMELINEEVENTSWIDGET_H