X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fcustomtrackscene.cpp;h=35d12061730a6662a261164e2f3d821869bcfc5d;hb=56aee6aedeeed3efd10ada8fe3c229eddc01ef05;hp=e2cc7345c61cdd5a52e4466665547079e769b9c3;hpb=40d8c63ec12c38560be338806ca1ccd9a01ddc0d;p=kdenlive diff --git a/src/customtrackscene.cpp b/src/customtrackscene.cpp index e2cc7345..35d12061 100644 --- a/src/customtrackscene.cpp +++ b/src/customtrackscene.cpp @@ -17,49 +17,58 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include - -#include "kdenlivedoc.h" #include "customtrackscene.h" +#include "kdenlivedoc.h" + +#include -CustomTrackScene::CustomTrackScene(KdenliveDoc *doc, QObject *parent) - : QGraphicsScene(parent), m_document(doc), m_scale(1.0) { - m_transitionPixmap = QPixmap(KStandardDirs::locate("appdata", "transition.png")); +CustomTrackScene::CustomTrackScene(KdenliveDoc *doc, QObject *parent) : + QGraphicsScene(parent), + m_document(doc), + m_scale(1.0, 1.0), + m_editMode(NormalEdit) +{ } -CustomTrackScene::~CustomTrackScene() { +CustomTrackScene::~CustomTrackScene() +{ } -double CustomTrackScene::getSnapPointForPos(double pos, bool doSnap) { +double CustomTrackScene::getSnapPointForPos(double pos, bool doSnap) +{ double maximumOffset; if (doSnap) { - if (m_scale > 3) maximumOffset = 10 / m_scale; - else maximumOffset = 6 / m_scale; + if (m_scale.x() > 3) maximumOffset = 10 / m_scale.x(); + else maximumOffset = 6 / m_scale.x(); for (int i = 0; i < m_snapPoints.size(); ++i) { if (qAbs((int)(pos - m_snapPoints.at(i).frames(m_document->fps()))) < maximumOffset) { return m_snapPoints.at(i).frames(m_document->fps()); } - if (m_snapPoints.at(i).frames(m_document->fps()) > pos) break; + if (m_snapPoints.at(i).frames(m_document->fps()) > pos) + break; } } return GenTime(pos, m_document->fps()).frames(m_document->fps()); } -void CustomTrackScene::setSnapList(QList snaps) { +void CustomTrackScene::setSnapList(const QList & snaps) +{ m_snapPoints = snaps; } -GenTime CustomTrackScene::previousSnapPoint(GenTime pos) { +GenTime CustomTrackScene::previousSnapPoint(const GenTime &pos) const +{ for (int i = 0; i < m_snapPoints.size(); ++i) { if (m_snapPoints.at(i) >= pos) { - if (i == 0) i = 1; + if (i == 0) return GenTime(); return m_snapPoints.at(i - 1); } } return GenTime(); } -GenTime CustomTrackScene::nextSnapPoint(GenTime pos) { +GenTime CustomTrackScene::nextSnapPoint(const GenTime &pos) const +{ for (int i = 0; i < m_snapPoints.size(); ++i) { if (m_snapPoints.at(i) > pos) { return m_snapPoints.at(i); @@ -68,16 +77,35 @@ GenTime CustomTrackScene::nextSnapPoint(GenTime pos) { return pos; } -void CustomTrackScene::setScale(double scale) { - m_scale = scale; +void CustomTrackScene::setScale(double scale, double vscale) +{ + m_scale.setX(scale); + m_scale.setY(vscale); } -double CustomTrackScene::scale() const { +QPointF CustomTrackScene::scale() const +{ return m_scale; } -int CustomTrackScene::tracksCount() const { +int CustomTrackScene::tracksCount() const +{ return m_document->tracksCount(); } +MltVideoProfile CustomTrackScene::profile() const +{ + return m_document->mltProfile(); +} + +void CustomTrackScene::setEditMode(EditMode mode) +{ + m_editMode = mode; +} + +EditMode CustomTrackScene::editMode() const +{ + return m_editMode; +} + #include "customtrackscene.moc"