aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2015-05-24 10:25:07 +0200
committerJean-Baptiste Mardelle <[email protected]>2015-05-24 11:02:14 +0200
commit5130c7944f34ccebc4835f815a5800983ed15bf6 (patch)
tree8434a4b9dd6cb530935bccb5630a4895e611476b
parent9a97ce2a561905eba4723edf126d93203604a4fe (diff)
Fix timeline corruption when zooming with mouse wheel over selected item
Fix transitions appearing behind grouped clips
-rw-r--r--src/definitions.h27
-rw-r--r--src/statusbarmessagelabel.cpp2
-rw-r--r--src/timeline/abstractgroupitem.cpp22
-rw-r--r--src/timeline/clipitem.cpp23
-rw-r--r--src/timeline/customtrackscene.cpp3
-rw-r--r--src/timeline/customtrackscene.h1
-rw-r--r--src/timeline/customtrackview.cpp26
-rw-r--r--src/timeline/customtrackview.h2
-rw-r--r--src/timeline/transition.cpp21
9 files changed, 84 insertions, 43 deletions
diff --git a/src/definitions.h b/src/definitions.h
index 44c2451..37ed595 100644
--- a/src/definitions.h
+++ b/src/definitions.h
@@ -56,19 +56,20 @@ const QString stopmotionMonitor("stopmotionMonitor");
enum OperationType {
None = 0,
- MoveOperation = 1,
- ResizeStart = 2,
- ResizeEnd = 3,
- FadeIn = 4,
- FadeOut = 5,
- TransitionStart = 6,
- TransitionEnd = 7,
- MoveGuide = 8,
- KeyFrame = 9,
- Seek = 10,
- Spacer = 11,
- RubberSelection = 12,
- ScrollTimeline = 13
+ MoveOperation,
+ ResizeStart,
+ ResizeEnd,
+ FadeIn,
+ FadeOut,
+ TransitionStart,
+ TransitionEnd,
+ MoveGuide,
+ KeyFrame,
+ Seek,
+ Spacer,
+ RubberSelection,
+ ScrollTimeline,
+ ZoomTimeline
};
namespace PlaylistState {
diff --git a/src/statusbarmessagelabel.cpp b/src/statusbarmessagelabel.cpp
index 3056251..da89b2a 100644
--- a/src/statusbarmessagelabel.cpp
+++ b/src/statusbarmessagelabel.cpp
@@ -224,7 +224,7 @@ void StatusBarMessageLabel::paintEvent(QPaintEvent*)
backgroundColor = KStatefulBrush(KColorScheme::Window, KColorScheme::NegativeBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme())).brush(this).color();
}
if (m_state == Desaturate && m_illumination > 0) {
- backgroundColor.setAlpha(m_illumination * 2);
+ backgroundColor.setAlpha(qMax(m_illumination * 2, 255));
}
painter.fillRect(0, 0, width(), height(), backgroundColor);
diff --git a/src/timeline/abstractgroupitem.cpp b/src/timeline/abstractgroupitem.cpp
index 3cb3547..17dbca5 100644
--- a/src/timeline/abstractgroupitem.cpp
+++ b/src/timeline/abstractgroupitem.cpp
@@ -184,10 +184,20 @@ void AbstractGroupItem::paint(QPainter *p, const QStyleOptionGraphicsItem *optio
QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange) {
- if (value.toBool()) setZValue(10);
+ if (value.toBool()) setZValue(3);
else setZValue(1);
}
- if (change == ItemPositionChange && scene() && parentItem() == 0) {
+ CustomTrackScene *scene = NULL;
+ if (change == ItemPositionChange && parentItem() == 0) {
+ scene = projectScene();
+ }
+ if (scene) {
+ // calculate new position.
+ if (scene->isZooming) {
+ // For some reason, mouse wheel on selected itm sometimes triggered
+ // a position change event corrupting timeline, so discard it
+ return pos();
+ }
// calculate new position.
const int trackHeight = KdenliveSettings::trackheight();
QPointF start = sceneBoundingRect().topLeft();
@@ -277,7 +287,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
QPainterPath shape;
if (projectScene()->editMode() == NormalEdit) {
shape = clipGroupShape(newPos - pos());
- collidingItems = scene()->items(shape, Qt::IntersectsItemShape);
+ collidingItems = scene->items(shape, Qt::IntersectsItemShape);
collidingItems.removeAll(this);
for (int i = 0; i < children.count(); ++i) {
if (children.at(i)->type() == GroupWidget) {
@@ -315,7 +325,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
newPos.setX(newPos.x() + offset);
}
// If there is still a collision after our position adjust, restore original pos
- collidingItems = scene()->items(clipGroupShape(newPos - pos()), Qt::IntersectsItemShape);
+ collidingItems = scene->items(clipGroupShape(newPos - pos()), Qt::IntersectsItemShape);
collidingItems.removeAll(this);
for (int i = 0; i < children.count(); ++i) {
if (children.at(i)->type() == GroupWidget) {
@@ -333,7 +343,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
if (projectScene()->editMode() == NormalEdit) {
shape = transitionGroupShape(newPos - pos());
- collidingItems = scene()->items(shape, Qt::IntersectsItemShape);
+ collidingItems = scene->items(shape, Qt::IntersectsItemShape);
collidingItems.removeAll(this);
for (int i = 0; i < children.count(); ++i) {
if (children.at(i)->type() == GroupWidget) {
@@ -372,7 +382,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
newPos.setX(newPos.x() + offset);
}
// If there is still a collision after our position adjust, restore original pos
- collidingItems = scene()->items(transitionGroupShape(newPos - pos()), Qt::IntersectsItemShape);
+ collidingItems = scene->items(transitionGroupShape(newPos - pos()), Qt::IntersectsItemShape);
for (int i = 0; i < children.count(); ++i) {
collidingItems.removeAll(children.at(i));
}
diff --git a/src/timeline/clipitem.cpp b/src/timeline/clipitem.cpp
index e2fcd4b..f9422cc 100644
--- a/src/timeline/clipitem.cpp
+++ b/src/timeline/clipitem.cpp
@@ -1192,23 +1192,32 @@ QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange) {
if (value.toBool())
- setZValue(10);
+ setZValue(3);
else
setZValue(2);
}
- if (change == ItemPositionChange && scene()) {
+ CustomTrackScene *scene = NULL;
+ if (change == ItemPositionChange) {
+ scene = projectScene();
+ }
+ if (scene) {
// calculate new position.
//if (parentItem()) return pos();
+ if (scene->isZooming) {
+ // For some reason, mouse wheel on selected itm sometimes triggered
+ // a position change event corrupting timeline, so discard it
+ return pos();
+ }
if (property("resizingEnd").isValid()) return pos();
QPointF newPos = value.toPointF();
////qDebug() << "/// MOVING CLIP ITEM.------------\n++++++++++";
- int xpos = projectScene()->getSnapPointForPos((int) newPos.x(), KdenliveSettings::snaptopoints());
+ int xpos = scene->getSnapPointForPos((int) newPos.x(), KdenliveSettings::snaptopoints());
xpos = qMax(xpos, 0);
newPos.setX(xpos);
// Warning: newPos gives a position relative to the click event, so hack to get absolute pos
int yOffset = property("y_absolute").toInt() + newPos.y();
int newTrack = yOffset / KdenliveSettings::trackheight();
- newTrack = qMin(newTrack, projectScene()->tracksCount() - 1);
+ newTrack = qMin(newTrack, scene->tracksCount() - 1);
newTrack = qMax(newTrack, 0);
QStringList lockedTracks = property("locked_tracks").toStringList();
if (lockedTracks.contains(QString::number(newTrack))) {
@@ -1220,8 +1229,8 @@ QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value)
QRectF sceneShape = rect();
sceneShape.translate(newPos);
QList<QGraphicsItem*> items;
- if (projectScene()->editMode() == NormalEdit) {
- items = scene()->items(sceneShape, Qt::IntersectsItemShape);
+ if (scene->editMode() == NormalEdit) {
+ items = scene->items(sceneShape, Qt::IntersectsItemShape);
}
items.removeAll(this);
bool forwardMove = newPos.x() > pos().x();
@@ -1249,7 +1258,7 @@ QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value)
sceneShape.translate(QPointF(offset, 0));
newPos.setX(newPos.x() + offset);
}
- QList<QGraphicsItem*> subitems = scene()->items(sceneShape, Qt::IntersectsItemShape);
+ QList<QGraphicsItem*> subitems = scene->items(sceneShape, Qt::IntersectsItemShape);
subitems.removeAll(this);
for (int j = 0; j < subitems.count(); ++j) {
if (!subitems.at(j)->isEnabled()) continue;
diff --git a/src/timeline/customtrackscene.cpp b/src/timeline/customtrackscene.cpp
index f8c67d7..409f5f1 100644
--- a/src/timeline/customtrackscene.cpp
+++ b/src/timeline/customtrackscene.cpp
@@ -25,7 +25,8 @@ CustomTrackScene::CustomTrackScene(KdenliveDoc *doc, QObject *parent) :
QGraphicsScene(parent),
m_document(doc),
m_scale(1.0, 1.0),
- m_editMode(NormalEdit)
+ m_editMode(NormalEdit),
+ isZooming(false)
{
}
diff --git a/src/timeline/customtrackscene.h b/src/timeline/customtrackscene.h
index ca304c9..f125001 100644
--- a/src/timeline/customtrackscene.h
+++ b/src/timeline/customtrackscene.h
@@ -59,6 +59,7 @@ public:
MltVideoProfile profile() const;
void setEditMode(EditMode mode);
EditMode editMode() const;
+ bool isZooming;
private:
KdenliveDoc *m_document;
diff --git a/src/timeline/customtrackview.cpp b/src/timeline/customtrackview.cpp
index af39ebe..013b7be 100644
--- a/src/timeline/customtrackview.cpp
+++ b/src/timeline/customtrackview.cpp
@@ -321,14 +321,21 @@ bool CustomTrackView::checkTrackHeight()
void CustomTrackView::wheelEvent(QWheelEvent * e)
{
if (e->modifiers() == Qt::ControlModifier) {
- if (e->delta() > 0) emit zoomIn();
- else emit zoomOut();
+ if (m_operationMode == None || m_operationMode == ZoomTimeline) {
+ if (e->delta() > 0) emit zoomIn();
+ else emit zoomOut();
+ }
} else {
if (e->delta() <= 0) horizontalScrollBar()->setValue(horizontalScrollBar()->value() + horizontalScrollBar()->singleStep());
else horizontalScrollBar()->setValue(horizontalScrollBar()->value() - horizontalScrollBar()->singleStep());
}
}
+void CustomTrackView::setOperation(OperationType op)
+{
+ m_operationMode = op;
+}
+
int CustomTrackView::getPreviousVideoTrack(int track)
{
track = m_document->tracksCount() - track - 1;
@@ -507,7 +514,6 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
QGraphicsView::mouseMoveEvent(event);
return;
}
-
if (event->buttons() & Qt::MidButton) return;
if (dragMode() == QGraphicsView::RubberBandDrag || (event->modifiers() == Qt::ControlModifier && m_tool != SpacerTool && m_operationMode != ResizeStart && m_operationMode != ResizeEnd)) {
event->setAccepted(true);
@@ -518,7 +524,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
if (event->buttons() != Qt::NoButton) {
bool move = (event->pos() - m_clickEvent).manhattanLength() >= QApplication::startDragDistance();
- if (m_dragItem && move) m_clipDrag = true;
+ if (m_dragItem && move && m_operationMode != ZoomTimeline) m_clipDrag = true;
if (m_dragItem && m_tool == SelectTool) {
if (m_operationMode == MoveOperation && m_clipDrag) {
QGraphicsView::mouseMoveEvent(event);
@@ -613,7 +619,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
return;
}
- if (item && event->buttons() == Qt::NoButton) {
+ if (item && event->buttons() == Qt::NoButton && m_operationMode != ZoomTimeline) {
AbstractClipItem *clip = static_cast <AbstractClipItem*>(item);
if (m_tool == RazorTool) {
// razor tool over a clip, display current frame in monitor
@@ -1009,7 +1015,7 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
}
QGraphicsView::mousePressEvent(event);
event->ignore();
- return;
+ return;
}
if (m_tool == SpacerTool) {
@@ -3644,15 +3650,14 @@ void CustomTrackView::completeSpaceOperation(int track, GenTime &timeOffset)
}
clearSelection();
- m_operationMode = None;
-
+ m_operationMode = None;
return;
}
void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
{
if (m_moveOpMode == Seek) m_moveOpMode = None;
- if (m_operationMode == ScrollTimeline) {
+ if (m_operationMode == ScrollTimeline || m_operationMode == ZoomTimeline) {
m_operationMode = None;
setDragMode(QGraphicsView::NoDrag);
QGraphicsView::mouseReleaseEvent(event);
@@ -5641,8 +5646,10 @@ void CustomTrackView::setTool(ProjectTool tool)
void CustomTrackView::setScale(double scaleFactor, double verticalScale)
{
+
QMatrix newmatrix;
newmatrix = newmatrix.scale(scaleFactor, verticalScale);
+ m_scene->isZooming = true;
m_scene->setScale(scaleFactor, verticalScale);
removeTipAnimation();
bool adjust = false;
@@ -5666,6 +5673,7 @@ void CustomTrackView::setScale(double scaleFactor, double verticalScale)
}
double verticalPos = mapToScene(QPoint(0, viewport()->height() / 2)).y();
centerOn(QPointF(cursorPos(), verticalPos));
+ m_scene->isZooming = false;
}
void CustomTrackView::slotRefreshGuides()
diff --git a/src/timeline/customtrackview.h b/src/timeline/customtrackview.h
index 32c76d5..2bcb765 100644
--- a/src/timeline/customtrackview.h
+++ b/src/timeline/customtrackview.h
@@ -222,6 +222,8 @@ public:
void resetSelectionGroup(bool selectItems = true);
/** @brief Returns all infos necessary to save guides. */
QMap <double, QString> guidesData() const;
+ /** @brief We are performing a timeline operation. */
+ void setOperation(OperationType op);
public slots:
/** @brief Send seek request to MLT. */
diff --git a/src/timeline/transition.cpp b/src/timeline/transition.cpp
index 1f6e1df..8772acc 100644
--- a/src/timeline/transition.cpp
+++ b/src/timeline/transition.cpp
@@ -37,7 +37,7 @@ Transition::Transition(const ItemInfo &info, int transitiontrack, double fps, co
m_automaticTransition(automaticTransition),
m_transitionTrack(transitiontrack)
{
- setZValue(3);
+ setZValue(4);
m_info.cropDuration = info.endPos - info.startPos;
setPos(info.startPos.frames(fps), (int)(info.track * KdenliveSettings::trackheight() + itemOffset() + 1));
@@ -204,11 +204,20 @@ int Transition::type() const
QVariant Transition::itemChange(GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange) {
- if (value.toBool()) setZValue(10);
- else setZValue(3);
+ if (value.toBool()) setZValue(5);
+ else setZValue(4);
}
- if (change == ItemPositionChange && scene()) {
+ CustomTrackScene *scene = NULL;
+ if (change == ItemPositionChange) {
+ scene = projectScene();
+ }
+ if (scene) {
// calculate new position.
+ if (scene->isZooming) {
+ // For some reason, mouse wheel on selected itm sometimes triggered
+ // a position change event corrupting timeline, so discard it
+ return pos();
+ }
QPointF newPos = value.toPointF();
int xpos = projectScene()->getSnapPointForPos((int) newPos.x(), KdenliveSettings::snaptopoints());
xpos = qMax(xpos, 0);
@@ -228,7 +237,7 @@ QVariant Transition::itemChange(GraphicsItemChange change, const QVariant &value
QList<QGraphicsItem*> items;
// TODO: manage transitions in OVERWRITE MODE
//if (projectScene()->editMode() == NORMALEDIT)
- items = scene()->items(sceneShape, Qt::IntersectsItemShape);
+ items = scene->items(sceneShape, Qt::IntersectsItemShape);
items.removeAll(this);
bool forwardMove = newPos.x() > pos().x();
@@ -256,7 +265,7 @@ QVariant Transition::itemChange(GraphicsItemChange change, const QVariant &value
sceneShape.translate(QPointF(offset, 0));
newPos.setX(newPos.x() + offset);
}
- QList<QGraphicsItem*> subitems = scene()->items(sceneShape, Qt::IntersectsItemShape);
+ QList<QGraphicsItem*> subitems = scene->items(sceneShape, Qt::IntersectsItemShape);
subitems.removeAll(this);
for (int j = 0; j < subitems.count(); ++j) {
if (!subitems.at(j)->isEnabled()) continue;