#include "kthumb.h"
#include <KDebug>
+#include <KIcon>
#include <QPainter>
#include <QTimer>
#include <QGraphicsScene>
#include <QMimeData>
-
ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, bool generateThumbs)
- : AbstractClipItem(info, QRectF(), fps), m_clip(clip), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_hasThumbs(false), startThumbTimer(NULL), endThumbTimer(NULL), audioThumbWasDrawn(false), m_opacity(1.0), m_timeLine(0), m_startThumbRequested(false), m_endThumbRequested(false), m_startFade(0), m_endFade(0), m_hover(false), m_selectedEffect(-1), m_speed(speed), framePixelWidth(0), m_startPix(QPixmap()), m_endPix(QPixmap()) {
+ : AbstractClipItem(info, QRectF(), fps), m_clip(clip), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_hasThumbs(false), startThumbTimer(NULL), endThumbTimer(NULL), audioThumbWasDrawn(false), m_opacity(1.0), m_timeLine(0), m_startThumbRequested(false), m_endThumbRequested(false), m_startFade(0), m_endFade(0), m_hover(false), m_selectedEffect(-1), m_speed(speed), framePixelWidth(0), m_startPix(QPixmap()), m_endPix(QPixmap()), m_videoOnly(false), m_audioOnly(false) {
setZValue(1);
setRect(0, 0, (info.endPos - info.startPos).frames(fps) - 0.02, (double)(KdenliveSettings::trackheight() - 2));
setPos(info.startPos.frames(fps), (double)(info.track * KdenliveSettings::trackheight()) + 1);
+ m_videoPix = KIcon("video-x-generic").pixmap(QSize(15, 15));
+ m_audioPix = KIcon("audio-x-generic").pixmap(QSize(15, 15));
+
if (m_speed == 1.0) m_clipName = clip->name();
else {
m_clipName = clip->name() + " - " + QString::number(m_speed * 100, 'f', 0) + '%';
ClipItem::~ClipItem() {
if (startThumbTimer) delete startThumbTimer;
if (endThumbTimer) delete endThumbTimer;
- if (m_timeLine) m_timeLine;
+ if (m_timeLine) delete m_timeLine;
}
ClipItem *ClipItem::clone(ItemInfo info) const {
m_timeLine->start();
}
-void ClipItem::animate(qreal value) {
+void ClipItem::animate(qreal /*value*/) {
QRectF r = boundingRect();
r.setHeight(20);
update(r);
/*if (parentItem()) m_opacity = 0.5;
else m_opacity = 1.0;
painter->setOpacity(m_opacity);*/
- QBrush paintColor = brush();
- if (isSelected()) paintColor = QBrush(QColor(79, 93, 121));
+ QBrush paintColor;
+ if (parentItem()) paintColor = QBrush(QColor(255, 248, 149));
+ else paintColor = brush();
+ if (isSelected() || parentItem() && parentItem()->isSelected()) paintColor = QBrush(paintColor.color().darker());
QRectF br = rect();
QRectF exposed = option->exposedRect;
QRectF mapped = painter->matrix().mapRect(br);
}
// Draw clip name
+
QRectF txtBounding = painter->boundingRect(mapped, Qt::AlignHCenter | Qt::AlignVCenter, ' ' + m_clipName + ' ');
painter->fillRect(txtBounding, QBrush(QColor(0, 0, 0, 150)));
//painter->setPen(QColor(0, 0, 0, 180));
//painter->drawText(txtBounding, Qt::AlignCenter, m_clipName);
+ if (m_videoOnly) {
+ painter->drawPixmap(txtBounding.topLeft() - QPointF(17, -1), m_videoPix);
+ } else if (m_audioOnly) {
+ painter->drawPixmap(txtBounding.topLeft() - QPointF(17, -1), m_audioPix);
+ }
txtBounding.translate(QPointF(1, 1));
painter->setPen(QColor(255, 255, 255, 255));
painter->drawText(txtBounding, Qt::AlignCenter, m_clipName);
// draw frame around clip
- if (isSelected()) {
+ if (isSelected() || parentItem() && parentItem()->isSelected()) {
pen.setColor(Qt::red);
- //pen.setWidth(2);
} else {
pen.setColor(Qt::black);
- //pen.setWidth(1);
}
// draw effect or transition keyframes
painter->setMatrixEnabled(true);
// draw clip border
-
- //kDebug()<<"/// ITEM PAINTING:: exposed="<<exposed<<", RECT = "<<rect();
-
// expand clip rect to allow correct painting of clip border
exposed.setRight(exposed.right() + 1 / scale + 0.5);
exposed.setBottom(exposed.bottom() + 1);
}
//virtual
-void ClipItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
+void ClipItem::hoverEnterEvent(QGraphicsSceneHoverEvent */*e*/) {
//if (e->pos().x() < 20) m_hover = true;
if (isItemLocked()) return;
m_hover = true;
update(r.right() - width, r.y() + height, width, height);
}
-void ClipItem::resizeStart(int posx, double speed) {
+void ClipItem::resizeStart(int posx, double /*speed*/) {
const int min = (startPos() - cropStart()).frames(m_fps);
if (posx < min) posx = min;
if (posx == startPos().frames(m_fps)) return;
}
}
-void ClipItem::resizeEnd(int posx, double speed, bool updateKeyFrames) {
+void ClipItem::resizeEnd(int posx, double /*speed*/, bool updateKeyFrames) {
const int max = (startPos() - cropStart() + maxDuration()).frames(m_fps) + 1;
if (posx > max) posx = max;
if (posx == endPos().frames(m_fps)) return;
QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value) {
if (change == ItemPositionChange && scene()) {
// calculate new position.
- if (parentItem()) return pos();
+ //if (parentItem()) return pos();
QPointF newPos = value.toPointF();
//kDebug() << "/// MOVING CLIP ITEM.------------\n++++++++++";
int xpos = projectScene()->getSnapPointForPos((int) newPos.x(), KdenliveSettings::snaptopoints());
void ClipItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) {
Q_UNUSED(event);
}
+
void ClipItem::addTransition(Transition* t) {
m_transitionsList.append(t);
- CustomTrackView *view = (CustomTrackView *) scene()->views()[0];
+ //CustomTrackView *view = (CustomTrackView *) scene()->views()[0];
QDomDocument doc;
QDomElement e = doc.documentElement();
//if (view) view->slotAddTransition(this, t->toXML() , t->startPos(), track());
}
+
+void ClipItem::setVideoOnly(bool force) {
+ m_videoOnly = force;
+}
+
+void ClipItem::setAudioOnly(bool force) {
+ m_audioOnly = force;
+}
+
+bool ClipItem::isAudioOnly() const {
+ return m_audioOnly;
+}
+
+bool ClipItem::isVideoOnly() const {
+ return m_videoOnly;
+}
+
+
// virtual
/*
void CustomTrackView::mousePressEvent ( QMouseEvent * event )