Changeset View
Changeset View
Standalone View
Standalone View
plugins/dockers/animation/timeline_frames_model.cpp
Show First 20 Lines • Show All 788 Lines • ▼ Show 20 Line(s) | |||||
789 | 789 | | |||
790 | bool TimelineFramesModel::copyFrame(const QModelIndex &dstIndex) | 790 | bool TimelineFramesModel::copyFrame(const QModelIndex &dstIndex) | ||
791 | { | 791 | { | ||
792 | if (!dstIndex.isValid()) return false; | 792 | if (!dstIndex.isValid()) return false; | ||
793 | 793 | | |||
794 | return m_d->addKeyframe(dstIndex.row(), dstIndex.column(), true); | 794 | return m_d->addKeyframe(dstIndex.row(), dstIndex.column(), true); | ||
795 | } | 795 | } | ||
796 | 796 | | |||
797 | bool TimelineFramesModel::insertFrames(int dstColumn, const QList<int> &dstRows, int count) | 797 | bool TimelineFramesModel::insertFrames(int dstColumn, const QList<int> &dstRows, int count, int timing) | ||
798 | { | 798 | { | ||
799 | if (dstRows.isEmpty() || count <= 0) return true; | 799 | if (dstRows.isEmpty() || count <= 0) return true; | ||
800 | timing = qMax(timing, 1); | ||||
800 | 801 | | |||
801 | KUndo2Command *parentCommand = new KUndo2Command(kundo2_i18np("Insert frame", "Insert %1 frames", count)); | 802 | KUndo2Command *parentCommand = new KUndo2Command(kundo2_i18np("Insert frame", "Insert %1 frames", count)); | ||
802 | 803 | | |||
803 | { | 804 | { | ||
804 | KisImageBarrierLockerWithFeedback locker(m_d->image); | 805 | KisImageBarrierLockerWithFeedback locker(m_d->image); | ||
805 | 806 | | |||
806 | QModelIndexList indexes; | 807 | QModelIndexList indexes; | ||
807 | 808 | | |||
808 | Q_FOREACH (int row, dstRows) { | 809 | Q_FOREACH (int row, dstRows) { | ||
809 | for (int column = dstColumn; column < columnCount(); column++) { | 810 | for (int column = dstColumn; column < columnCount(); column++) { | ||
810 | indexes << index(row, column); | 811 | indexes << index(row, column); | ||
811 | } | 812 | } | ||
812 | } | 813 | } | ||
813 | 814 | | |||
814 | setLastVisibleFrame(columnCount() + count - 1); | 815 | setLastVisibleFrame(columnCount() + (count * timing) - 1); | ||
815 | 816 | | |||
816 | 817 | createOffsetFramesCommand(indexes, QPoint((count * timing), 0), false, parentCommand); | |||
817 | createOffsetFramesCommand(indexes, QPoint(count, 0), false, parentCommand); | | |||
818 | 818 | | |||
819 | Q_FOREACH (int row, dstRows) { | 819 | Q_FOREACH (int row, dstRows) { | ||
820 | KisNodeDummy *dummy = m_d->converter->dummyFromRow(row); | 820 | KisNodeDummy *dummy = m_d->converter->dummyFromRow(row); | ||
821 | if (!dummy) continue; | 821 | if (!dummy) continue; | ||
822 | 822 | | |||
823 | KisNodeSP node = dummy->node(); | 823 | KisNodeSP node = dummy->node(); | ||
824 | if (!KisAnimationUtils::supportsContentFrames(node)) continue; | 824 | if (!KisAnimationUtils::supportsContentFrames(node)) continue; | ||
825 | 825 | | |||
826 | for (int column = dstColumn; column < dstColumn + count; column++) { | 826 | for (int column = dstColumn; column < dstColumn + (count * timing); column += timing) { | ||
827 | KisAnimationUtils::createKeyframeCommand(m_d->image, node, KisKeyframeChannel::Content.id(), column, false, parentCommand); | 827 | KisAnimationUtils::createKeyframeCommand(m_d->image, node, KisKeyframeChannel::Content.id(), column, false, parentCommand); | ||
828 | } | 828 | } | ||
829 | } | 829 | } | ||
830 | 830 | | |||
831 | const int oldTime = m_d->image->animationInterface()->currentUITime(); | 831 | const int oldTime = m_d->image->animationInterface()->currentUITime(); | ||
832 | const int newTime = dstColumn > oldTime ? dstColumn : dstColumn + count - 1; | 832 | const int newTime = dstColumn > oldTime ? dstColumn : dstColumn + (count * timing) - 1; | ||
833 | 833 | | |||
834 | new KisSwitchCurrentTimeCommand(m_d->image->animationInterface(), | 834 | new KisSwitchCurrentTimeCommand(m_d->image->animationInterface(), | ||
835 | oldTime, | 835 | oldTime, | ||
836 | newTime, parentCommand); | 836 | newTime, parentCommand); | ||
837 | } | 837 | } | ||
838 | 838 | | |||
839 | KisProcessingApplicator::runSingleCommandStroke(m_d->image, parentCommand, KisStrokeJobData::BARRIER); | 839 | KisProcessingApplicator::runSingleCommandStroke(m_d->image, parentCommand, KisStrokeJobData::BARRIER); | ||
840 | 840 | | |||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Line(s) | 927 | new KisSwitchCurrentTimeCommand(m_d->image->animationInterface(), | |||
929 | newTime, parentCommand.data()); | 929 | newTime, parentCommand.data()); | ||
930 | } | 930 | } | ||
931 | 931 | | |||
932 | 932 | | |||
933 | KisProcessingApplicator::runSingleCommandStroke(m_d->image, parentCommand.take(), KisStrokeJobData::BARRIER); | 933 | KisProcessingApplicator::runSingleCommandStroke(m_d->image, parentCommand.take(), KisStrokeJobData::BARRIER); | ||
934 | return true; | 934 | return true; | ||
935 | } | 935 | } | ||
936 | 936 | | |||
937 | | ||||
938 | QString TimelineFramesModel::audioChannelFileName() const | 937 | QString TimelineFramesModel::audioChannelFileName() const | ||
939 | { | 938 | { | ||
940 | return m_d->image ? m_d->image->animationInterface()->audioChannelFileName() : QString(); | 939 | return m_d->image ? m_d->image->animationInterface()->audioChannelFileName() : QString(); | ||
941 | } | 940 | } | ||
942 | 941 | | |||
943 | void TimelineFramesModel::setAudioChannelFileName(const QString &fileName) | 942 | void TimelineFramesModel::setAudioChannelFileName(const QString &fileName) | ||
944 | { | 943 | { | ||
945 | KIS_SAFE_ASSERT_RECOVER_RETURN(m_d->image); | 944 | KIS_SAFE_ASSERT_RECOVER_RETURN(m_d->image); | ||
Show All 34 Lines |