]> git.sesse.net Git - kdenlive/blobdiff - src/abstractgroupitem.cpp
Correctly update markers in monitor:
[kdenlive] / src / abstractgroupitem.cpp
index d9ce8b79061a391eb80926bc4a4690b7b212d6ab..817db9739b1ccf54edfdc5c15a14d0112cdc15a4 100644 (file)
@@ -37,7 +37,7 @@ AbstractGroupItem::AbstractGroupItem(double /* fps */) :
         QGraphicsItemGroup()
 {
     setZValue(1);
-    setFlags(QGraphicsItem::ItemClipsToShape | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
+    setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
     setAcceptDrops(true);
 }
 
@@ -97,13 +97,15 @@ void AbstractGroupItem::fixItemRect()
 void AbstractGroupItem::paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *)
 {
     const double scale = option->matrix.m11();
-    p->fillRect(option->exposedRect, QColor(100, 100, 200, 100));
-    p->setClipping(false);
+    QColor bgcolor(100, 100, 200, 100);
+    QRectF bound = option->exposedRect.adjusted(0, 0, 1, 1);
+    p->setClipRect(bound);
+    p->fillRect(option->exposedRect, bgcolor);
     QPen pen = p->pen();
     pen.setColor(QColor(200, 90, 90));
     pen.setStyle(Qt::DashLine);
-    pen.setWidthF(1.0);
-    pen.setCosmetic(true);
+    pen.setWidthF(0.0);
+    //pen.setCosmetic(true);
     p->setPen(pen);
     p->drawRect(boundingRect().adjusted(0, 0, - 1 / scale, 0));
 }
@@ -111,7 +113,7 @@ void AbstractGroupItem::paint(QPainter *p, const QStyleOptionGraphicsItem *optio
 //virtual
 QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant &value)
 {
-    if (change == ItemPositionChange && scene()) {
+    if (change == ItemPositionChange && scene() && parentItem() == 0) {
         // calculate new position.
         const int trackHeight = KdenliveSettings::trackheight();
         QPointF start = sceneBoundingRect().topLeft();
@@ -149,6 +151,26 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
                     offset = (int)(trackHeight / 3 * 2 - 1);
                     topTrack = currentTrack;
                 }
+            } else if (children.at(i)->type() == GROUPWIDGET) {
+                QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
+                bool clipGroup = false;
+                for (int j = 0; j < subchildren.count(); j++) {
+                    if (subchildren.at(j)->type() == AVWIDGET) {
+                        clipGroup = true;
+                        break;
+                    }
+                }
+                if (clipGroup) {
+                    if (topTrack == -1 || currentTrack <= topTrack) {
+                        offset = 0;
+                        topTrack = currentTrack;
+                    }
+                } else {
+                    if (topTrack == -1 || currentTrack < topTrack) {
+                        offset = (int)(trackHeight / 3 * 2 - 1);
+                        topTrack = currentTrack;
+                    }
+                }
             }
         }
         newPos.setY((int)((proposedTrack) * trackHeight) + offset);
@@ -158,6 +180,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
             // If group goes below 0, adjust position to 0
             return QPointF(pos().x() - start.x(), pos().y());
         }*/
+
         QPainterPath shape = groupShape(newPos - pos());
         QList<QGraphicsItem*> collindingItems = scene()->items(shape, Qt::IntersectsItemShape);
         for (int i = 0; i < children.count(); i++) {
@@ -172,7 +195,6 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
                 QGraphicsItem *collision = collindingItems.at(i);
                 if (collision->type() == AVWIDGET) {
                     // Collision
-                    //kDebug()<<"// COLLISION WIT:"<<collision->sceneBoundingRect();
                     if (newPos.y() != pos().y()) {
                         // Track change results in collision, restore original position
                         return pos();