} else QGraphicsItem::mousePressEvent(event);
}
+void AbstractGroupItem::resizeStart(int diff)
+{
+ bool info = false;
+ if (m_resizeInfos.isEmpty())
+ info = true;
+ int maximum = diff;
+ QList <QGraphicsItem *> children = childItems();
+ QList <AbstractClipItem *> items;
+ int itemcount = 0;
+ for (int i = 0; i < children.count(); ++i) {
+ AbstractClipItem *item = static_cast <AbstractClipItem *>(children.at(i));
+ if (item && item->type() == AVWIDGET) {
+ items << item;
+ if (info)
+ m_resizeInfos << item->info();
+ item->resizeStart((int)(m_resizeInfos.at(itemcount).startPos.frames(item->fps())) + diff);
+ int itemdiff = (int)(item->startPos() - m_resizeInfos.at(itemcount).startPos).frames(item->fps());
+ if (qAbs(itemdiff) < qAbs(maximum))
+ maximum = itemdiff;
+ ++itemcount;
+ }
+ }
+
+ for (int i = 0; i < items.count(); ++i)
+ items.at(i)->resizeStart((int)(m_resizeInfos.at(i).startPos.frames(items.at(i)->fps())) + maximum);
+}
+
void AbstractGroupItem::resizeEnd(int diff)
{
bool info = false;
void setItemLocked(bool locked);
bool isItemLocked() const;
// ItemInfo info() const;
- /** @brief Resizes all clips in this group from the end.
+
+ /** @brief Resizes all clips in this group from start.
+ *@param diff Difference to startPos stored in m_resizeInfos */
+ void resizeStart(int diff);
+ /** @brief Resizes all clips in this group from end.
* @param diff Difference to endPos stored in m_resizeInfos */
void resizeEnd(int diff);
- void resizeStart(int diff);
/** @brief Gets m_resizeInfos */
QList <ItemInfo> resizeInfos();
/** @brief Clears m_resizeInfos */
void clearResizeInfos();
+
/** @brief Gets the duration (length) of the group. */
GenTime duration();
} else if (viewport()->width() - pos < 10) {
m_scrollOffset = 30;
m_scrollTimer.start();
- } else if (m_scrollTimer.isActive()) m_scrollTimer.stop();
-
+ } else if (m_scrollTimer.isActive()) {
+ m_scrollTimer.stop();
+ }
} else if (m_operationMode == RESIZESTART && move) {
m_document->renderer()->pause();
- m_dragItem->resizeStart((int)(snappedPos));
+ if (m_dragItem->type() == AVWIDGET && m_dragItem->parentItem() && m_dragItem->parentItem() != m_selectionGroup) {
+ AbstractGroupItem *parent = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());
+ if (parent)
+ parent->resizeStart((int)(snappedPos) - m_dragItemInfo.startPos.frames(m_document->fps()));
+ } else {
+ m_dragItem->resizeStart((int)(snappedPos));
+ }
} else if (m_operationMode == RESIZEEND && move) {
m_document->renderer()->pause();
if (m_dragItem->type() == AVWIDGET && m_dragItem->parentItem() && m_dragItem->parentItem() != m_selectionGroup) {
m_document->renderer()->doRefresh();
} else if (m_operationMode == RESIZESTART && m_dragItem->startPos() != m_dragItemInfo.startPos) {
// resize start
- prepareResizeClipStart(m_dragItem, m_dragItemInfo, m_dragItem->startPos().frames(m_document->fps()));
+ if (m_dragItem->type() == AVWIDGET && m_dragItem->parentItem() && m_dragItem->parentItem() != m_selectionGroup) {
+ AbstractGroupItem *parent = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());
+ if (parent) {
+ QUndoCommand *resizeCommand = new QUndoCommand();
+ resizeCommand->setText(i18n("Resize group"));
+ QList <QGraphicsItem *> items = parent->childItems();
+ QList <ItemInfo> infos = parent->resizeInfos();
+ parent->clearResizeInfos();
+ int itemcount = 0;
+ for (int i = 0; i < items.count(); ++i) {
+ AbstractClipItem *item = static_cast<AbstractClipItem *>(items.at(i));
+ if (item && item->type() == AVWIDGET) {
+ ItemInfo info = infos.at(itemcount);
+ prepareResizeClipStart(item, info, item->startPos().frames(m_document->fps()), false, resizeCommand);
+ ++itemcount;
+ }
+ }
+ m_commandStack->push(resizeCommand);
+ }
+ } else {
+ prepareResizeClipStart(m_dragItem, m_dragItemInfo, m_dragItem->startPos().frames(m_document->fps()));
+ }
} else if (m_operationMode == RESIZEEND && m_dragItem->endPos() != m_dragItemInfo.endPos) {
// resize end
if (m_dragItem->type() == AVWIDGET && m_dragItem->parentItem() && m_dragItem->parentItem() != m_selectionGroup) {
// do this here, too, because otherwise undo won't update the group
if (item->parentItem() && item->parentItem() != m_selectionGroup)
- new RebuildGroupCommand(this, item->info().track, item->info().startPos, command);
+ new RebuildGroupCommand(this, item->info().track, item->endPos() - GenTime(1, m_document->fps()), command);
ItemInfo info = item->info();
if (item->type() == AVWIDGET) {
}
if (item->parentItem() && item->parentItem() != m_selectionGroup)
- new RebuildGroupCommand(this, item->info().track, item->info().startPos, command);
+ new RebuildGroupCommand(this, item->info().track, item->endPos() - GenTime(1, m_document->fps()), command);
}
void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldInfo, int pos, bool check, QUndoCommand *command)
// do this here, too, because otherwise undo won't update the group
if (item->parentItem() && item->parentItem() != m_selectionGroup)
- new RebuildGroupCommand(this, item->info().track, item->info().startPos, command);
+ new RebuildGroupCommand(this, item->info().track, item->startPos(), command);
ItemInfo info = item->info();
if (item->type() == AVWIDGET) {
}
}
if (item->parentItem() && item->parentItem() != m_selectionGroup)
- new RebuildGroupCommand(this, item->info().track, item->info().startPos, command);
+ new RebuildGroupCommand(this, item->info().track, item->startPos(), command);
}
void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)