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 if (ev->startTime >= offs && ev->startTime < twidth ||
|
|
64 ev->startTime + ev->duration >= offs)
|
|
65 {
|
|
66 int ex0 = x0 + (ev->startTime - offs) * scale,
|
|
67 ew = ex0 + ev->duration * scale,
|
|
68 ex1 = ex0 + ew <= x1 ? ex0 + ew : x1;
|
|
69
|
|
70 painter.setPen(waveColor);
|
|
71 dmFillRect(screen, ex0, y0, ex1, y1, eventColor);
|
|
72 //dmDrawTTFText(screen, font, fontcol, ex0, y0, "'%s'", ev->effect->name);
|
|
73 }
|
|
74 }
|
|
75
|
|
76 if (time >= offs * scale && time - offs <= width() * scale)
|
|
77 {
|
|
78 int xc = time - offs;
|
|
79 painter.scale(scale, 1);
|
|
80 painter.setPen(markerColor);
|
|
81 painter.drawLine(xc, 0, xc, height());
|
|
82 }
|
|
83 }
|
|
84
|
|
85
|
|
86 void TimelineTrackView::mousePressEvent(QMouseEvent *ev)
|
|
87 {
|
|
88 /*
|
|
89 if (ev->button() == Qt::LeftButton)
|
|
90 {
|
|
91 lastPoint = ev->pos();
|
|
92 scribbling = true;
|
|
93 }
|
|
94 */
|
|
95 }
|
|
96
|
|
97
|
|
98 void TimelineTrackView::mouseMoveEvent(QMouseEvent *ev)
|
|
99 {
|
|
100 /*
|
|
101 if ((ev->buttons() & Qt::LeftButton) && scribbling)
|
|
102 drawLineTo(ev->pos());
|
|
103 */
|
|
104 }
|
|
105
|
|
106
|
|
107 void TimelineTrackView::mouseReleaseEvent(QMouseEvent *ev)
|
|
108 {
|
|
109 /*
|
|
110 if (ev->button() == Qt::LeftButton && scribbling)
|
|
111 {
|
|
112 drawLineTo(ev->pos());
|
|
113 scribbling = false;
|
|
114 }
|
|
115 */
|
|
116 }
|