357
|
1 #include <QtGui>
|
|
2 #include "edtimeline.h"
|
|
3
|
|
4
|
|
5 TimelineTrackView::TimelineTrackView(QWidget *parent) : QWidget(parent)
|
|
6 {
|
|
7 track = NULL;
|
|
8 time = offs = 0;
|
|
9 scale = 1.0f;
|
|
10 }
|
|
11
|
|
12
|
|
13 void TimelineTrackView::setTrack(DMTimelineTrack *mtrack)
|
|
14 {
|
|
15 track = mtrack;
|
|
16 update();
|
|
17 }
|
|
18
|
|
19
|
|
20 DMTimelineTrack * TimelineTrackView::getTrack()
|
|
21 {
|
|
22 return track;
|
|
23 }
|
|
24
|
|
25
|
|
26 void TimelineTrackView::setTime(const int mtime)
|
|
27 {
|
|
28 time = mtime;
|
|
29 update();
|
|
30 }
|
|
31
|
|
32
|
|
33 void TimelineTrackView::setOffset(const int moffs)
|
|
34 {
|
|
35 offs = moffs;
|
|
36 update();
|
|
37 }
|
|
38
|
|
39
|
|
40 void TimelineTrackView::setScale(const float mscale)
|
|
41 {
|
|
42 if (mscale > 0.05)
|
|
43 scale = mscale;
|
|
44 update();
|
|
45 }
|
|
46
|
|
47
|
|
48 void TimelineTrackView::paintEvent(QPaintEvent *)
|
|
49 {
|
|
50 QColor eventColor(150, 150, 150);
|
|
51 QColor markerColor(255,255,255);
|
|
52
|
|
53 QPainter painter(this);
|
|
54 painter.setRenderHint(QPainter::Antialiasing);
|
|
55
|
|
56 painter.save();
|
|
57 painter.scale(scale, 1);
|
|
58
|
|
59 for (int event = 0; event < track->nevents; event++)
|
|
60 {
|
|
61 DMTimelineEvent *ev = track->events[event];
|
|
62 }
|
|
63
|
|
64 if (time >= offs * scale && time - offs <= width() * scale)
|
|
65 {
|
|
66 int xc = time - offs;
|
|
67 painter.scale(scale, 1);
|
|
68 painter.setPen(markerColor);
|
|
69 painter.drawLine(xc, 0, xc, height());
|
|
70 }
|
|
71 }
|
|
72
|
|
73
|
|
74 void TimelineTrackView::mousePressEvent(QMouseEvent *ev)
|
|
75 {
|
|
76 /*
|
|
77 if (ev->button() == Qt::LeftButton)
|
|
78 {
|
|
79 lastPoint = ev->pos();
|
|
80 scribbling = true;
|
|
81 }
|
|
82 */
|
|
83 }
|
|
84
|
|
85
|
|
86 void TimelineTrackView::mouseMoveEvent(QMouseEvent *ev)
|
|
87 {
|
|
88 /*
|
|
89 if ((ev->buttons() & Qt::LeftButton) && scribbling)
|
|
90 drawLineTo(ev->pos());
|
|
91 */
|
|
92 }
|
|
93
|
|
94
|
|
95 void TimelineTrackView::mouseReleaseEvent(QMouseEvent *ev)
|
|
96 {
|
|
97 /*
|
|
98 if (ev->button() == Qt::LeftButton && scribbling)
|
|
99 {
|
|
100 drawLineTo(ev->pos());
|
|
101 scribbling = false;
|
|
102 }
|
|
103 */
|
|
104 }
|