// virtual void KeyframeHelper::mousePressEvent(QMouseEvent * event) { m_hoverKeyframe = -1; if (event->button() != Qt::LeftButton) { QWidget::mousePressEvent(event); return; } int xPos = event->x() - margin; int headOffset = m_lineHeight / 1.5; if (m_geom != NULL && (event->y() <= headOffset)) { // check if we want to move a keyframe int mousePos = qMax((int)(xPos / m_scale), 0) + m_offset; Mlt::GeometryItem item; if (m_geom->next_key(&item, mousePos) == 0) { if (qAbs((item.frame() - m_offset)* m_scale - xPos) < headOffset) { m_movingItem.x(item.x()); m_movingItem.y(item.y()); m_movingItem.w(item.w()); m_movingItem.h(item.h()); m_movingItem.mix(item.mix()); m_movingItem.frame(item.frame()); while (!m_extraMovingItems.isEmpty()) { Mlt::GeometryItem *gitem = m_extraMovingItems.takeFirst(); if (gitem) delete gitem; } for (int i = 0; i < m_extraGeometries.count(); ++i) { if (m_extraGeometries.at(i)->next_key(item, mousePos) == 0) { Mlt::GeometryItem *item2 = new Mlt::GeometryItem(); item2->x(item.x()); item2->frame(item.frame()); m_extraMovingItems.append(item2); } else { m_extraMovingItems.append(NULL); } } m_dragStart = event->pos(); return; } } } int seekRequest = xPos / m_scale; if (seekRequest != m_position) { m_seekPosition = seekRequest; emit requestSeek(m_seekPosition); update(); } }
void Geometryval::slotDeleteFrame(int pos) { // check there is more than one keyframe Mlt::GeometryItem item; int frame = m_timePos.getValue(); if (pos == -1) pos = frame; int error = m_geom->next_key(&item, pos + 1); if (error) { error = m_geom->prev_key(&item, pos - 1); if (error || item.frame() == pos) return; } m_geom->remove(frame); buttonAdd->setEnabled(true); buttonDelete->setEnabled(false); widget->setEnabled(false); spinTransp->setEnabled(false); frameOptions->setEnabled(false); m_reset->setEnabled(false); m_helper->update(); slotPositionChanged(pos, false); updateTransitionPath(); emit parameterChanged(); }
void Geometryval::slotPreviousFrame() { Mlt::GeometryItem item; int error = m_geom->prev_key(&item, m_helper->value() - 1); kDebug() << "// SEEK TO NEXT KFR: " << error; if (error) return; int pos = item.frame(); m_ui.spinPos->setValue(pos); }
void Geometryval::slotPreviousFrame() { Mlt::GeometryItem item; int error = m_geom->prev_key(&item, m_helper->value() - 1); //qDebug() << "// SEEK TO NEXT KFR: " << error; if (error) return; int pos = item.frame(); m_timePos.setValue(pos); slotPositionChanged(); }
void Geometryval::slotNextFrame() { Mlt::GeometryItem item; int error = m_geom->next_key(&item, m_helper->value() + 1); kDebug() << "// SEEK TO NEXT KFR: " << error; if (error) { // Go to end m_ui.spinPos->setValue(m_ui.spinPos->maximum()); return; } int pos = item.frame(); m_ui.spinPos->setValue(pos); }
QString GeometryWidget::offsetAnimation(int offset, bool useOffset) { Mlt::Geometry *geometry = new Mlt::Geometry((char*)NULL, m_outPoint, m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight()); Mlt::GeometryItem item; int pos = 0; int ix = 0; while (!m_geometry->next_key(&item, pos)) { pos = item.frame() + 1; item.frame(item.frame() + offset); geometry->insert(item); ix++; } m_useOffset = useOffset; QString result = geometry->serialise(); if (!m_fixedGeom && result.contains(QStringLiteral(";")) && !result.section(QStringLiteral(";"),0,0).contains(QStringLiteral("="))) { result.prepend("0="); } m_geometry->parse(result.toUtf8().data(), m_outPoint, m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight()); m_timeline->setKeyGeometry(m_geometry, m_inPoint, m_outPoint, m_useOffset); delete geometry; return result; }
void Geometryval::slotNextFrame() { Mlt::GeometryItem item; int error = m_geom->next_key(&item, m_helper->value() + 1); int pos; //qDebug() << "// SEEK TO NEXT KFR: " << error; if (error) { // Go to end pos = m_helper->frameLength; } else pos = item.frame(); m_timePos.setValue(pos); slotPositionChanged(); }
void Geometryval::slotUpdateTransitionProperties() { int pos = m_timePos.getValue(); Mlt::GeometryItem item; int error = m_geom->next_key(&item, pos); if (error || item.frame() != pos) { // no keyframe under cursor return; } QRectF r = m_paramRect->rect().normalized(); QPointF rectpos = m_paramRect->pos(); item.x(rectpos.x() / m_dar); item.y(rectpos.y()); item.w(r.width() / m_dar); item.h(r.height()); m_geom->insert(item); updateTransitionPath(); emit parameterChanged(); }
void Geometryval::slotAddFrame() { int pos = m_ui.spinPos->value(); Mlt::GeometryItem item; item.frame(pos); item.x(m_paramRect->pos().x()); item.y(m_paramRect->pos().y()); item.w(m_paramRect->rect().width()); item.h(m_paramRect->rect().height()); item.mix(m_ui.spinTransp->value()); m_geom->insert(item); m_ui.buttonAdd->setEnabled(false); m_ui.buttonDelete->setEnabled(true); m_ui.widget->setEnabled(true); m_ui.spinTransp->setEnabled(true); m_scaleMenu->setEnabled(true); m_alignMenu->setEnabled(true); m_helper->update(); emit parameterChanged(); }
void Geometryval::updateTransitionPath() { if (m_fixedMode) return; Mlt::GeometryItem item; int pos = 0; int counter = 0; QPainterPath path; while (true) { if (m_geom->next_key(&item, pos) == 1) break; pos = item.frame(); if (counter == 0) { path.moveTo(item.x() * m_dar + item.w() * m_dar / 2, item.y() + item.h() / 2); } else { path.lineTo(item.x() * m_dar + item.w() * m_dar / 2, item.y() + item.h() / 2); } counter++; pos++; } m_path->setPath(path); }
void Geometryval::slotDeleteFrame() { // check there is more than one keyframe Mlt::GeometryItem item; const int pos = m_ui.spinPos->value(); int error = m_geom->next_key(&item, pos + 1); if (error) { error = m_geom->prev_key(&item, pos - 1); if (error || item.frame() == pos) return; } m_geom->remove(m_ui.spinPos->value()); m_ui.buttonAdd->setEnabled(true); m_ui.buttonDelete->setEnabled(false); m_ui.widget->setEnabled(false); m_ui.spinTransp->setEnabled(false); m_scaleMenu->setEnabled(false); m_alignMenu->setEnabled(false); m_helper->update(); slotPositionChanged(pos, false); updateTransitionPath(); emit parameterChanged(); }
void Geometryval::slotAddFrame(int pos) { int frame = m_timePos.getValue(); if (pos == -1) pos = frame; Mlt::GeometryItem item; item.frame(pos); QRectF r = m_paramRect->rect().normalized(); QPointF rectpos = m_paramRect->pos(); item.x(rectpos.x() / m_dar); item.y(rectpos.y()); item.w(r.width() / m_dar); item.h(r.height()); item.mix(spinTransp->value()); m_geom->insert(item); buttonAdd->setEnabled(false); buttonDelete->setEnabled(true); widget->setEnabled(true); spinTransp->setEnabled(true); frameOptions->setEnabled(true); m_reset->setEnabled(true); m_helper->update(); emit parameterChanged(); }