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: Wed, 13 Feb 2008 12:45:41 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       08/02/13 12:45:41

Modified files:
        src/commands   : MoveClip.cpp MoveClip.h 
        src/commands/plugins/TraversoCommands: TraversoCommands.cpp 
        src/core       : InputEngine.cpp InputEngine.h SnapList.cpp 
                         SnapList.h 

Log message:
        * move MoveClip::calculate_snap_diff() to SnapList, since it's more 
appropriate to be there.
        * move bypass jog logic of Moveclip to InputEngine itself, so we can 
more easily re-use it elsewhere ;)
        Afaik this the longest ever function name was created now hehe

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/MoveClip.cpp?cvsroot=traverso&r1=1.63&r2=1.64
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/MoveClip.h?cvsroot=traverso&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/plugins/TraversoCommands/TraversoCommands.cpp?cvsroot=traverso&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/InputEngine.cpp?cvsroot=traverso&r1=1.69&r2=1.70
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/InputEngine.h?cvsroot=traverso&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/SnapList.cpp?cvsroot=traverso&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/SnapList.h?cvsroot=traverso&r1=1.13&r2=1.14

Patches:
Index: commands/MoveClip.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/commands/MoveClip.cpp,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -b -r1.63 -r1.64
--- commands/MoveClip.cpp       13 Feb 2008 10:48:06 -0000      1.63
+++ commands/MoveClip.cpp       13 Feb 2008 12:45:39 -0000      1.64
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2005-2007 Remon Sijrier 
+Copyright (C) 2005-2008 Remon Sijrier 
 
 This file is part of Traverso
 
@@ -23,6 +23,7 @@
 
 #include "AudioClip.h"
 #include "ContextPointer.h"
+#include "InputEngine.h"
 #include "ProjectManager.h"
 #include "ResourcesManager.h"
 #include "SnapList.h"
@@ -51,9 +52,6 @@
 
 /**
  *     Creates  a Move Clip or Copy Clip Command object.
- *     
- * @param cv The AudioClipView that is to be dragged/copied.
- * @param arguments Can be either one of the following: move, copy, 
move_to_end, move_to_start
  */
 MoveClip::MoveClip(AudioClipView* cv, QVariantList args)
        : Command(cv->get_clip(), "")
@@ -70,6 +68,7 @@
                d->verticalOnly = false;
        }
        
+       m_clip = cv->get_clip();
        d->view = cv;
        d->sv = d->view->get_sheetview();
        d->zoom = 0;
@@ -91,8 +90,6 @@
        
        if (m_actionType == "move_to_start" || m_actionType == "move_to_end") {
                init_data();
-       } else {
-               m_clip = d->view->get_clip();
        }
 }
 
@@ -125,7 +122,6 @@
        d->origXPos = cpointer().on_first_input_event_scene_x();
        d->origPos = QPointF(d->origXPos, 
cpointer().on_first_input_event_scene_y());
        d->sv->start_shuttle(true, true);
-       d->bypassjog = false;
 }
 
 
@@ -222,14 +218,6 @@
                return 0;
        }
        
-       if (d->bypassjog) {
-               QPoint diff = d->jogBypassPos - cpointer().pos();
-               if (diff.manhattanLength() > 35) {
-                       d->bypassjog = false;
-               } else {
-                       return 0;
-               }
-       }
        
        if (d->zoom) {
                d->zoom->jog();
@@ -237,8 +225,6 @@
        }
        
        
-       d->jogBypassPos = cpointer().pos();
-       
        QPointF diffPoint(cpointer().scene_pos() - d->origPos);
        
        d->origPos = cpointer().scene_pos();
@@ -265,7 +251,7 @@
        }
 
        if (m_sheet->is_snap_on() && !d->verticalOnly) {
-               calculate_snap_diff(newTrackStartLocation, newTrackEndLocation);
+               newTrackStartLocation -= 
m_sheet->get_snap_list()->calculate_snap_diff(newTrackStartLocation, 
newTrackEndLocation);
        }
        
        m_posDiff = newTrackStartLocation - m_originalTrackStartLocation;
@@ -290,7 +276,8 @@
 void MoveClip::next_snap_pos(bool autorepeat)
 {
        Q_UNUSED(autorepeat);
-       d->bypassjog = true;
+       ie().bypass_jog_until_mouse_movements_exceeded_manhattenlength();
+       
        TimeRef trackStartLocation = 
m_sheet->get_snap_list()->next_snap_pos(m_clip->get_track_start_location());
        TimeRef trackEndLocation = 
m_sheet->get_snap_list()->next_snap_pos(m_clip->get_track_end_location());
        qint64 startdiff = (trackStartLocation - 
m_clip->get_track_start_location()).universal_frame();
@@ -304,7 +291,8 @@
 void MoveClip::prev_snap_pos(bool autorepeat)
 {
        Q_UNUSED(autorepeat);
-       d->bypassjog = true;
+       ie().bypass_jog_until_mouse_movements_exceeded_manhattenlength();
+       
        TimeRef trackStartLocation = 
m_sheet->get_snap_list()->prev_snap_pos(m_clip->get_track_start_location());
        TimeRef trackEndLocation = 
m_sheet->get_snap_list()->prev_snap_pos(m_clip->get_track_end_location());
        qint64 startdiff = (trackStartLocation - 
m_clip->get_track_start_location()).universal_frame();
@@ -325,57 +313,9 @@
 void MoveClip::move_to_end(bool autorepeat)
 {
        Q_UNUSED(autorepeat)
-       Track *track = m_clip->get_track();
-       
-       Command::process_command(track->remove_clip(m_clip, false));
        
m_clip->set_track_start_location(m_clip->get_sheet()->get_last_location());
-       Command::process_command(track->add_clip(m_clip, false));
 }
 
-void MoveClip::calculate_snap_diff(TimeRef& leftlocation, TimeRef 
rightlocation)
-{
-       // "nframe_t" domain, but must be signed ints because they can become 
negative
-       qint64 snapStartDiff = 0;
-       qint64 snapEndDiff = 0;
-       qint64 snapDiff = 0;
-       
-       SnapList* slist = m_sheet->get_snap_list();
-
-       // check if there is anything to snap
-       bool start_snapped = false;
-       bool end_snapped = false;
-       if (slist->is_snap_value(leftlocation)) {
-               start_snapped = true;
-       }
-       
-       if (slist->is_snap_value(rightlocation)) {
-               end_snapped = true;
-       }
-
-       if (start_snapped) {
-               snapStartDiff = slist->get_snap_diff(leftlocation);
-               snapDiff = snapStartDiff; // in case both ends snapped, change 
this value later, else leave it
-       }
-
-       if (end_snapped) {
-               snapEndDiff = slist->get_snap_diff(rightlocation); 
-               snapDiff = snapEndDiff; // in case both ends snapped, change 
this value later, else leave it
-       }
-
-       // If both snapped, check which one is closer. Do not apply this check 
if one of the
-       // ends hasn't snapped, because it's diff value will be 0 by default 
and will always
-       // be smaller than the actually snapped value.
-       if (start_snapped && end_snapped) {
-               if (abs(snapEndDiff) > abs(snapStartDiff))
-                       snapDiff = snapStartDiff;
-               else
-                       snapDiff = snapEndDiff;
-       }
-       
-       leftlocation -= snapDiff;
-}
-
-
 void MoveClip::start_zoom(bool autorepeat)
 {
        if (autorepeat) return;

Index: commands/MoveClip.h
===================================================================
RCS file: /sources/traverso/traverso/src/commands/MoveClip.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- commands/MoveClip.h 13 Feb 2008 10:41:00 -0000      1.27
+++ commands/MoveClip.h 13 Feb 2008 12:45:39 -0000      1.28
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2005-2006 Remon Sijrier 
+    Copyright (C) 2005-2008 Remon Sijrier 
  
     This file is part of Traverso
  
@@ -72,9 +72,7 @@
                QPointF         origPos;
                TimeRef         origTrackEndLocation;
                bool            resync;
-               bool            bypassjog;
                bool            verticalOnly;
-               QPoint          jogBypassPos;
                Zoom*           zoom;
        };
                        
@@ -82,7 +80,6 @@
        Data* d;
 
        void init_data();
-       void calculate_snap_diff(TimeRef& leftlocation, TimeRef rightlocation);
        
 public slots:
        void next_snap_pos(bool autorepeat);

Index: commands/plugins/TraversoCommands/TraversoCommands.cpp
===================================================================
RCS file: 
/sources/traverso/traverso/src/commands/plugins/TraversoCommands/TraversoCommands.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- commands/plugins/TraversoCommands/TraversoCommands.cpp      13 Feb 2008 
11:54:19 -0000      1.24
+++ commands/plugins/TraversoCommands/TraversoCommands.cpp      13 Feb 2008 
12:45:40 -0000      1.25
@@ -63,8 +63,8 @@
        
        objectname:     AudioClipView
        arguments:      First entry, either one of the following: "move", 
"copy", "move_to_end", "move_to_start"
-                       Second (optional) entry: Move vertical only: "true" for 
vertical moving only, "false" for omnidirectional moving (the default)
-       commandname:    Moveclip
+                       Second (optional) entry: Move vertical only: "true" for 
vertical moving only, "false" for omnidirectional moving (the default if none 
is given)
+       commandname:    MoveClip
        \endcode 
 
 

Index: core/InputEngine.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/InputEngine.cpp,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -b -r1.69 -r1.70
--- core/InputEngine.cpp        12 Feb 2008 20:39:08 -0000      1.69
+++ core/InputEngine.cpp        13 Feb 2008 12:45:40 -0000      1.70
@@ -528,8 +528,19 @@
 void InputEngine::jog()
 {
        PENTER3;
+
        if (isJogging) {
                if (holdingCommand) {
+                       if (m_bypassJog) {
+                               QPoint diff = m_jogBypassPos - cpointer().pos();
+                               if (diff.manhattanLength() > 
m_unbypassJogDistance) {
+                                       m_bypassJog = false;
+                               } else {
+                                       return;
+                               }
+                       }
+                       m_jogBypassPos = cpointer().pos();
+                       
                        holdingCommand->jog();
                }
        }
@@ -572,6 +583,7 @@
        fact2_k1 = 0;
        fact2_k2 = 0;
        wholeMapIndex = -1;
+       m_bypassJog = false;
        
        for (int i=0; i < STACK_SIZE; i++) {
                eventType[i] = 0;
@@ -1844,6 +1856,8 @@
        }
 }
 
-//eof
-
-
+void 
InputEngine::bypass_jog_until_mouse_movements_exceeded_manhattenlength(int 
length)
+{
+       m_unbypassJogDistance = length;
+       m_bypassJog = true;
+}

Index: core/InputEngine.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/InputEngine.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- core/InputEngine.h  12 Feb 2008 20:39:08 -0000      1.28
+++ core/InputEngine.h  13 Feb 2008 12:45:40 -0000      1.29
@@ -143,6 +143,7 @@
         int broadcast_action_from_contextmenu(const QString& name);
 
         void jog();
+       void bypass_jog_until_mouse_movements_exceeded_manhattenlength(int 
length=35);
 
         void activate();
         void suspend();
@@ -185,6 +186,8 @@
         EventCatcher           catcher;
         Command*               holdingCommand;
         QString                        sCollectedNumber;
+       QPoint                  m_jogBypassPos;
+
 
         bool                   active;
         bool                   isHolding;
@@ -194,6 +197,7 @@
         bool                   isDoubleKey;
         bool                   isJogging;
        bool                    m_cancelHold;
+       bool                    m_bypassJog;
 
         int                    fact1_k1;
         int                    fact1_k2;
@@ -214,6 +218,7 @@
         int                    doubleFactWaitTime;
         long                   eventTime[STACK_SIZE];
        int                     m_broadcastResult;
+       int                     m_unbypassJogDistance;
 
         bool                   is_fake( int keyval);
         int                    identify_first_fact();

Index: core/SnapList.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/SnapList.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- core/SnapList.cpp   21 Jan 2008 16:22:15 -0000      1.26
+++ core/SnapList.cpp   13 Feb 2008 12:45:40 -0000      1.27
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2006-2007 Nicola Doebelin, Remon Sijrier
+Copyright (C) 2006-2008 Nicola Doebelin, Remon Sijrier
 
 This file is part of Traverso
 
@@ -336,3 +336,45 @@
        return newpos;
 }
 
+
+TimeRef SnapList::calculate_snap_diff(TimeRef & leftlocation, TimeRef 
rightlocation)
+{
+       // "nframe_t" domain, but must be signed ints because they can become 
negative
+       qint64 snapStartDiff = 0;
+       qint64 snapEndDiff = 0;
+       qint64 snapDiff = 0;
+       
+       // check if there is anything to snap
+       bool start_snapped = false;
+       bool end_snapped = false;
+       if (is_snap_value(leftlocation)) {
+               start_snapped = true;
+       }
+       
+       if (is_snap_value(rightlocation)) {
+               end_snapped = true;
+       }
+
+       if (start_snapped) {
+               snapStartDiff = get_snap_diff(leftlocation);
+               snapDiff = snapStartDiff; // in case both ends snapped, change 
this value later, else leave it
+       }
+
+       if (end_snapped) {
+               snapEndDiff = get_snap_diff(rightlocation); 
+               snapDiff = snapEndDiff; // in case both ends snapped, change 
this value later, else leave it
+       }
+
+       // If both snapped, check which one is closer. Do not apply this check 
if one of the
+       // ends hasn't snapped, because it's diff value will be 0 by default 
and will always
+       // be smaller than the actually snapped value.
+       if (start_snapped && end_snapped) {
+               if (abs(snapEndDiff) > abs(snapStartDiff))
+                       snapDiff = snapStartDiff;
+               else
+                       snapDiff = snapEndDiff;
+       }
+       
+//     leftlocation -= snapDiff;
+       return TimeRef(snapDiff);
+}

Index: core/SnapList.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/SnapList.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- core/SnapList.h     21 Jan 2008 16:22:15 -0000      1.13
+++ core/SnapList.h     13 Feb 2008 12:45:40 -0000      1.14
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2006-2007 Nicola Doebelin, Remon Sijrier
+Copyright (C) 2006-2008 Nicola Doebelin, Remon Sijrier
 
 This file is part of Traverso
 
@@ -45,6 +45,8 @@
        TimeRef next_snap_pos(const TimeRef& location);
        TimeRef prev_snap_pos(const TimeRef& location);
        
+       TimeRef calculate_snap_diff(TimeRef& leftlocation, TimeRef 
rightlocation);
+
        void set_range(const TimeRef& start, const TimeRef& end, int 
scalefactor);
 
 private:




reply via email to

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