traverso-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Traverso-commit] traverso/src commands/MoveClip.cpp commands/Mov...


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src commands/MoveClip.cpp commands/Mov...
Date: Sat, 16 Feb 2008 20:04:43 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       08/02/16 20:04:43

Modified files:
        src/commands   : MoveClip.cpp MoveClip.h 
        src/core       : AudioClipGroup.cpp AudioClipGroup.h 

Log message:
        * complete AudioClipGroup::move_to() logic, a group of clips has one 
track index, like a normal clip. Use 
AudioClipGroup::check_valid_track_index_delta(int& delta) to properly limit a 
track index delta when calculating a new track index.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/MoveClip.cpp?cvsroot=traverso&r1=1.69&r2=1.70
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/MoveClip.h?cvsroot=traverso&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClipGroup.cpp?cvsroot=traverso&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClipGroup.h?cvsroot=traverso&r1=1.5&r2=1.6

Patches:
Index: commands/MoveClip.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/commands/MoveClip.cpp,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -b -r1.69 -r1.70
--- commands/MoveClip.cpp       14 Feb 2008 18:05:59 -0000      1.69
+++ commands/MoveClip.cpp       16 Feb 2008 20:04:42 -0000      1.70
@@ -108,14 +108,12 @@
                }
                
                TimeRef currentLocation = 
TimeRef(cpointer().on_first_input_event_scene_x() * d->sv->timeref_scalefactor);
-               m_origTrackIndex = -1;
+               
+               d->pointedTrackIndex = 
d->sv->get_trackview_under(cpointer().scene_pos())->get_track()->get_sort_index();
                
                foreach(Track* track, tracks) {
                        QList<AudioClip*> clips = track->get_cliplist();
                        foreach(AudioClip* clip, clips) {
-                               if (m_origTrackIndex == -1) {
-                                       m_origTrackIndex = m_newTrackIndex = 
track->get_sort_index();
-                               }
                                if (clip->get_track_end_location() > 
currentLocation) {
                                        movingClips.append(clip);
                                }
@@ -129,9 +127,11 @@
                Q_ASSERT(cv);
                d->sv = cv->get_sheetview();
                m_group.add_clip(cv->get_clip());
-               m_origTrackIndex = m_newTrackIndex = 
cv->get_clip()->get_track()->get_sort_index();
+               d->pointedTrackIndex = 
cv->get_clip()->get_track()->get_sort_index();
        }
        
+       m_origTrackIndex = m_newTrackIndex = m_group.get_track_index();
+       
        d->zoom = 0;
        m_sheet = d->sv->get_sheet();
 }
@@ -254,8 +254,12 @@
        }
        
        TrackView* trackView = 
d->sv->get_trackview_under(cpointer().scene_pos());
-       if (trackView && !(m_actionType == FOLD_SHEET)) {
-               m_newTrackIndex = trackView->get_track()->get_sort_index();
+       int deltaTrackIndex = 0;
+       if (trackView/* && !(m_actionType == FOLD_SHEET)*/) {
+               deltaTrackIndex = trackView->get_track()->get_sort_index() - 
d->pointedTrackIndex;
+               m_group.check_valid_track_index_delta(deltaTrackIndex);
+               m_newTrackIndex = m_newTrackIndex + deltaTrackIndex;
+               d->pointedTrackIndex = trackView->get_track()->get_sort_index();
        }
 
        // Calculate the distance moved based on the current scene x pos and 
the initial one.
@@ -349,8 +353,6 @@
                
cpointer().get_viewport()->set_holdcursor(":/cursorZoomHorizontal");
                d->sv->start_shuttle(false);
        } else {
-               delete d->zoom;
-               d->zoom = 0;
                cpointer().get_viewport()->set_holdcursor(":/cursorHoldLrud");
                d->sv->start_shuttle(true, true);
        }

Index: commands/MoveClip.h
===================================================================
RCS file: /sources/traverso/traverso/src/commands/MoveClip.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- commands/MoveClip.h 14 Feb 2008 10:32:22 -0000      1.30
+++ commands/MoveClip.h 16 Feb 2008 20:04:42 -0000      1.31
@@ -77,6 +77,7 @@
        struct Data {
                SheetView*      sv;
                int             sceneXStartPos;
+               int             pointedTrackIndex;
                bool            verticalOnly;
                Zoom*           zoom;
        };

Index: core/AudioClipGroup.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClipGroup.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- core/AudioClipGroup.cpp     14 Feb 2008 18:05:59 -0000      1.5
+++ core/AudioClipGroup.cpp     16 Feb 2008 20:04:43 -0000      1.6
@@ -30,39 +30,31 @@
 
 #include "Debugger.h"
 
-static bool smallerClip(const AudioClip* left, const AudioClip* right )
-{
-       return left->get_track_start_location() < 
right->get_track_start_location();
-}
-
-AudioClipGroup::AudioClipGroup()
-{
-}
-
 AudioClipGroup::AudioClipGroup(QList< AudioClip * > clips)
 {
        m_clips = clips;
-       update_track_start_and_end_locations();
+       update_state();
 }
 
 void AudioClipGroup::add_clip(AudioClip * clip)
 {
        m_clips.append(clip);
-       update_track_start_and_end_locations();
+       update_state();
 }
 
 void AudioClipGroup::set_clips(QList< AudioClip * > clips)
 {
        m_clips = clips;
-       update_track_start_and_end_locations();
+       update_state();
 }
 
 void AudioClipGroup::move_to(int trackIndex, TimeRef location)
 {
-       foreach(AudioClip* clip, m_clips) {
+       int trackIndexDelta = trackIndex - m_topTrackIndex;
                
-               if (clip->get_track()->get_sort_index() != trackIndex) {
-                       Track* track = 
clip->get_sheet()->get_track_for_index(trackIndex);
+       foreach(AudioClip* clip, m_clips) {
+               if (trackIndexDelta != 0) {
+                       Track* track = 
clip->get_sheet()->get_track_for_index(clip->get_track()->get_sort_index() + 
trackIndexDelta);
                        if (track) {
                                
Command::process_command(clip->get_track()->remove_clip(clip, false, true));
                                Command::process_command(track->add_clip(clip, 
false, true));
@@ -73,19 +65,35 @@
                clip->set_track_start_location(location + offset);
        }
        
-       if (m_clips.size()) {
-               m_trackStartLocation = 
m_clips.first()->get_track_start_location();
-               m_trackEndLocation = m_clips.last()->get_track_end_location();
-       }
+       update_state();
 }
 
-void AudioClipGroup::update_track_start_and_end_locations()
+void AudioClipGroup::update_state()
 {
-       qSort(m_clips.begin(), m_clips.end(), smallerClip);
+       if (m_clips.isEmpty()) {
+               return;
+       }
 
-       if (m_clips.size()) {
-               m_trackStartLocation = 
m_clips.first()->get_track_start_location();
-               m_trackEndLocation = m_clips.last()->get_track_end_location();
+       m_trackStartLocation = LONG_LONG_MAX;
+       m_trackEndLocation = TimeRef();
+       
+       m_topTrackIndex = INT_MAX;
+       m_bottomTrackIndex = 0;
+       
+       foreach(AudioClip* clip, m_clips) {
+               int index = clip->get_track()->get_sort_index();
+               if (index < m_topTrackIndex) {
+                       m_topTrackIndex = index;
+               }
+               if (index > m_bottomTrackIndex) {
+                       m_bottomTrackIndex = index;
+               }
+               if (m_trackStartLocation > clip->get_track_start_location()) {
+                       m_trackStartLocation = clip->get_track_start_location();
+               }
+               if (m_trackEndLocation < clip->get_track_end_location()) {
+                       m_trackEndLocation = clip->get_track_end_location();
+               }
        }
 }
 
@@ -132,3 +140,21 @@
        }
 }
 
+void AudioClipGroup::check_valid_track_index_delta(int & delta)
+{
+       if (m_clips.isEmpty()) {
+               return;
+       }
+       
+       int allowedDeltaPlus = (m_clips.first()->get_sheet()->get_numtracks() - 
1) - m_bottomTrackIndex;
+       int allowedDeltaMin  = -m_topTrackIndex;
+       
+       if (delta > allowedDeltaPlus) {
+               delta = allowedDeltaPlus;
+       }
+       
+       if (delta < allowedDeltaMin) {
+               delta = allowedDeltaMin;
+       }
+}
+

Index: core/AudioClipGroup.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClipGroup.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- core/AudioClipGroup.h       14 Feb 2008 10:54:09 -0000      1.5
+++ core/AudioClipGroup.h       16 Feb 2008 20:04:43 -0000      1.6
@@ -29,21 +29,23 @@
 class AudioClipGroup
 {
 public:
-       AudioClipGroup();
+       AudioClipGroup(){};
        AudioClipGroup(QList<AudioClip*> clips);
        
        void add_clip(AudioClip* clip);
        void set_clips(QList<AudioClip*> clips);
-       void move_to(int trackIndex, TimeRef location);
+       void move_to(int trackIndexDelta, TimeRef location);
        
        void set_snappable(bool snap);
        void set_as_moving(bool move);
+       void check_valid_track_index_delta(int& delta);
        
        QList<AudioClip*> copy_clips();
        void add_all_clips_to_tracks();
        void remove_all_clips_from_tracks();
        
-       int get_size() {return m_clips.size();}
+       int get_size() const {return m_clips.size();}
+       int get_track_index() const {return m_topTrackIndex;}
        
        TimeRef get_track_start_location() const {return m_trackStartLocation;}
        TimeRef get_track_end_location() const {return m_trackEndLocation;}
@@ -53,8 +55,10 @@
        QList<AudioClip*> m_clips;
        TimeRef m_trackEndLocation;
        TimeRef m_trackStartLocation;
+       int     m_topTrackIndex;
+       int     m_bottomTrackIndex;
        
-       void update_track_start_and_end_locations();
+       void update_state();
 };
 
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]