[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso resources/keymap.xml src/commands/CMak...
From: |
Ben Levitt |
Subject: |
[Traverso-commit] traverso resources/keymap.xml src/commands/CMak... |
Date: |
Wed, 02 Jan 2008 03:03:39 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Ben Levitt <benjie> 08/01/02 03:03:38
Modified files:
resources : keymap.xml
src/commands : CMakeLists.txt commands.h commands.pro
src/commands/plugins/TraversoCommands: TraversoCommands.cpp
TraversoCommands.h
Added files:
src/commands : MultiMove.cpp MultiMove.h
Log message:
Adds the MultiMove command, currently called "Fold" in the ui.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/resources/keymap.xml?cvsroot=traverso&r1=1.94&r2=1.95
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/CMakeLists.txt?cvsroot=traverso&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/commands.h?cvsroot=traverso&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/commands.pro?cvsroot=traverso&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/MultiMove.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/MultiMove.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/plugins/TraversoCommands/TraversoCommands.cpp?cvsroot=traverso&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/plugins/TraversoCommands/TraversoCommands.h?cvsroot=traverso&r1=1.6&r2=1.7
Patches:
Index: resources/keymap.xml
===================================================================
RCS file: /sources/traverso/traverso/resources/keymap.xml,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -b -r1.94 -r1.95
--- resources/keymap.xml 29 Dec 2007 02:03:36 -0000 1.94
+++ resources/keymap.xml 2 Jan 2008 03:03:37 -0000 1.95
@@ -469,6 +469,12 @@
<Object objectname="CurveView" mousehint="UD"
slotsignature="drag_node_vertical_only" modes="Effects" sortorder="4" />
</Objects>
</keyfact>
+ <keyfact type="HKEY2" key1="D" key2="F" >
+ <Objects>
+ <Object objectname="SongView" mousehint="RL"
modes="All" pluginname="TraversoCommands" commandname="MultiMove"
arguments="true" />
+ <Object objectname="SongView" mousehint="RL"
modes="All" pluginname="TraversoCommands" modifierkeys="CTRL"
commandname="MultiMoveSingle" arguments="false" />
+ </Objects>
+ </keyfact>
Index: src/commands/CMakeLists.txt
===================================================================
RCS file: /sources/traverso/traverso/src/commands/CMakeLists.txt,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- src/commands/CMakeLists.txt 28 Dec 2007 20:23:45 -0000 1.5
+++ src/commands/CMakeLists.txt 2 Jan 2008 03:03:37 -0000 1.6
@@ -20,6 +20,7 @@
Gain.cpp
Import.cpp
MoveClip.cpp
+MultiMove.cpp
MoveEdge.cpp
PCommand.cpp
SplitClip.cpp
Index: src/commands/commands.h
===================================================================
RCS file: /sources/traverso/traverso/src/commands/commands.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- src/commands/commands.h 30 Apr 2007 10:09:11 -0000 1.13
+++ src/commands/commands.h 2 Jan 2008 03:03:38 -0000 1.14
@@ -13,3 +13,4 @@
#include "AudioClipExternalProcessing.h"
#include "ArmTracks.h"
#include "RemoveClip.h"
+#include "MultiMove.h"
Index: src/commands/commands.pro
===================================================================
RCS file: /sources/traverso/traverso/src/commands/commands.pro,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- src/commands/commands.pro 27 Dec 2007 22:27:24 -0000 1.24
+++ src/commands/commands.pro 2 Jan 2008 03:03:38 -0000 1.25
@@ -5,6 +5,7 @@
Gain.cpp \
Import.cpp \
MoveClip.cpp \
+MultiMove.cpp \
MoveEdge.cpp \
PCommand.cpp \
SplitClip.cpp \
@@ -24,6 +25,7 @@
Gain.h \
Import.h \
MoveClip.h \
+MultiMove.h \
MoveEdge.h \
PCommand.h \
precompile.h \
Index: src/commands/plugins/TraversoCommands/TraversoCommands.cpp
===================================================================
RCS file:
/sources/traverso/traverso/src/commands/plugins/TraversoCommands/TraversoCommands.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- src/commands/plugins/TraversoCommands/TraversoCommands.cpp 2 Jan 2008
02:28:34 -0000 1.18
+++ src/commands/plugins/TraversoCommands/TraversoCommands.cpp 2 Jan 2008
03:03:38 -0000 1.19
@@ -51,6 +51,8 @@
m_dict.insert("CopyClip", MoveClipCommand);
m_dict.insert("SplitClip", SplitClipCommand);
m_dict.insert("ArmTracks", ArmTracksCommand);
+ m_dict.insert("MultiMove", MultiMoveCommand);
+ m_dict.insert("MultiMoveSingle", MultiMoveCommand);
}
Command* TraversoCommands::create(QObject* obj, const QString& command,
QVariantList arguments)
@@ -292,6 +294,23 @@
}
return new ArmTracks(view);
}
+
+ case MultiMoveCommand:
+ {
+ SongView* view = qobject_cast<SongView*>(obj);
+
+ bool allTracks = true;
+ if (arguments.size()) {
+ allTracks = arguments[0].toBool();
+ }
+
+ if (!view) {
+ PERROR("TraversoCommands: Supplied QObject was
not a SongView! "
+ "MultiMoveCommand needs a SongView as
argument");
+ return 0;
+ }
+ return new MultiMove(view, allTracks);
+ }
}
return 0;
Index: src/commands/plugins/TraversoCommands/TraversoCommands.h
===================================================================
RCS file:
/sources/traverso/traverso/src/commands/plugins/TraversoCommands/TraversoCommands.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- src/commands/plugins/TraversoCommands/TraversoCommands.h 2 May 2007
05:58:20 -0000 1.6
+++ src/commands/plugins/TraversoCommands/TraversoCommands.h 2 Jan 2008
03:03:38 -0000 1.7
@@ -47,6 +47,8 @@
Q_CLASSINFO("MoveClipOrEdge", tr("Move Or Resize Clip"))
Q_CLASSINFO("SplitClip", tr("Split"))
Q_CLASSINFO("ArmTracks", tr("Arm Tracks"))
+ Q_CLASSINFO("MultiMove", tr("Fold Sheet"))
+ Q_CLASSINFO("MultiMoveSingle", tr("Fold Track"))
public:
TraversoCommands();
@@ -67,7 +69,8 @@
DragEdgeCommand,
MoveClipOrEdgeCommand,
SplitClipCommand,
- ArmTracksCommand
+ ArmTracksCommand,
+ MultiMoveCommand
};
};
Index: src/commands/MultiMove.cpp
===================================================================
RCS file: src/commands/MultiMove.cpp
diff -N src/commands/MultiMove.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/commands/MultiMove.cpp 2 Jan 2008 03:03:38 -0000 1.1
@@ -0,0 +1,205 @@
+/*
+ Copyright (C) 2007 Ben Levitt
+
+ This file is part of Traverso
+
+ Traverso is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+*/
+
+#include <libtraversocore.h>
+
+#include "MultiMove.h"
+#include <ViewPort.h>
+#include <SongView.h>
+#include <AudioClip.h>
+#include <Marker.h>
+#include "APILinkedList.h"
+
+// Always put me below _all_ includes, this is needed
+// in case we run with memory leak detection enabled!
+#include "Debugger.h"
+
+
+MultiMove::MultiMove(SongView* sv, bool allTracks)
+ : Command(sv->get_song(), (allTracks) ? tr("Fold Sheet") : tr("Fold
Track"))
+{
+ m_sv = sv;
+ m_song = sv->get_song();
+ m_allTracks = allTracks;
+ m_track = 0;
+
+ if (!allTracks) {
+ QList<QObject* >objs = cpointer().get_context_items();
+ foreach(QObject* obj, objs) {
+ Track* t = dynamic_cast<Track*>(obj);
+ if (t) {
+ m_track = t;
+ break;
+ }
+ }
+ }
+}
+
+
+MultiMove::~MultiMove()
+{
+}
+
+
+int MultiMove::prepare_actions()
+{
+ PENTER;
+
+ if (m_newPos == m_originalPos) {
+ // Nothing happened!
+ return -1;
+ }
+
+
+ if (m_markers.size() == 0 && m_clips.size() == 0) {
+ // If no markers or clips will be moved, don't start the command
+ return -1;
+ }
+
+ return 1;
+}
+
+
+int MultiMove::begin_hold()
+{
+ PENTER;
+
+ m_newPos = m_lastPos = m_originalPos =
+ TimeRef(cpointer().on_first_input_event_scene_x() *
m_sv->timeref_scalefactor);
+
+ m_sv->stop_follow_play_head();
+ m_sv->start_shuttle(true, true);
+
+ if (!m_allTracks && m_track == 0) {
+ // No track selected
+ // Should probably return -1, but that currently throws an
error, and
+ // returning here means that no markers or clips will get
moved, which
+ // is correct.
+ return 1;
+ }
+
+ m_selectionStartPos = m_song->get_last_location();
+
+ if (!m_track) {
+ QList<Marker*>markers = m_song->get_timeline()->get_markers();
+ for (int i = 0; i < markers.size(); i++) {
+ if (markers[i]->get_when() > m_originalPos) {
+ m_markers.append(markers[i]);
+
+ if (markers[i]->get_when() <
m_selectionStartPos) {
+ m_selectionStartPos =
markers[i]->get_when();
+ }
+ }
+ }
+ }
+
+ APILinkedList tracks = m_song->get_tracks();
+
+ if (m_track) {
+ tracks.clear();
+ tracks.append(m_track);
+ }
+
+ apill_foreach(Track* track, Track, tracks) {
+ APILinkedList clips = track->get_cliplist();
+ apill_foreach(AudioClip* clip, AudioClip, clips) {
+ if (clip->get_track_end_location() > m_originalPos) {
+ m_clips.append(clip);
+
+ if (clip->get_track_start_location() <
m_selectionStartPos) {
+ m_selectionStartPos =
clip->get_track_start_location();
+ }
+ }
+ }
+ }
+
+ return 1;
+}
+
+
+int MultiMove::finish_hold()
+{
+ m_sv->start_shuttle(false);
+ undo_action();
+
+ return 1;
+}
+
+
+void MultiMove::cancel_action()
+{
+ finish_hold();
+}
+
+
+int MultiMove::do_action()
+{
+ for (int i=0; i < m_clips.size(); i++) {
+ TimeRef newTrackStartLocation =
m_clips[i]->get_track_start_location() + (m_newPos - m_originalPos);
+ m_clips[i]->set_track_start_location(newTrackStartLocation);
+ }
+ for (int i=0; i < m_markers.size(); i++) {
+ TimeRef newStartLocation = m_markers[i]->get_when() + (m_newPos
- m_originalPos);
+ m_markers[i]->set_when(newStartLocation);
+ }
+ return 1;
+}
+
+
+int MultiMove::undo_action()
+{
+ for (int i=0; i < m_clips.size(); i++) {
+ TimeRef newTrackStartLocation =
m_clips[i]->get_track_start_location() - (m_newPos - m_originalPos);
+ m_clips[i]->set_track_start_location(newTrackStartLocation);
+ }
+ for (int i=0; i < m_markers.size(); i++) {
+ TimeRef newStartLocation = m_markers[i]->get_when() - (m_newPos
- m_originalPos);
+ m_markers[i]->set_when(newStartLocation);
+ }
+ return 1;
+}
+
+
+int MultiMove::jog()
+{
+ m_newPos = TimeRef(cpointer().scene_x() * m_sv->timeref_scalefactor);
+
+ if (m_originalPos > m_selectionStartPos + m_newPos) {
+ m_newPos = m_originalPos - m_selectionStartPos;
+ }
+
+ for (int i=0; i < m_clips.size(); i++) {
+ TimeRef newTrackStartLocation =
m_clips[i]->get_track_start_location() + (m_newPos - m_lastPos);
+ m_clips[i]->set_track_start_location(newTrackStartLocation);
+ }
+ for (int i=0; i < m_markers.size(); i++) {
+ TimeRef newStartLocation = m_markers[i]->get_when() + (m_newPos
- m_lastPos);
+ m_markers[i]->set_when(newStartLocation);
+ }
+
+ m_lastPos = m_newPos;
+ m_sv->update_shuttle_factor();
+
+ return 1;
+}
+
+// eof
+
Index: src/commands/MultiMove.h
===================================================================
RCS file: src/commands/MultiMove.h
diff -N src/commands/MultiMove.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/commands/MultiMove.h 2 Jan 2008 03:03:38 -0000 1.1
@@ -0,0 +1,68 @@
+/*
+ Copyright (C) 2007 Ben Levitt
+
+ This file is part of Traverso
+
+ Traverso is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ $Id: MultiMove.h,v 1.1 2008/01/02 03:03:38 benjie Exp $
+*/
+
+#ifndef MULTIMOVE_H
+#define MULTIMOVE_H
+
+#include "Command.h"
+#include "defines.h"
+#include <QList>
+
+class AudioClip;
+class Marker;
+class Song;
+class Track;
+class SongView;
+
+
+class MultiMove : public Command
+{
+public :
+ MultiMove(SongView* sv, bool allTracks);
+ ~MultiMove();
+
+ int begin_hold();
+ int finish_hold();
+ void cancel_action();
+ int prepare_actions();
+ int do_action();
+ int undo_action();
+
+ int jog();
+
+private :
+ QList<AudioClip* > m_clips;
+ QList<Marker* > m_markers;
+ SongView* m_sv;
+ Song* m_song;
+ Track* m_track;
+ bool m_allTracks;
+ TimeRef m_originalPos;
+ TimeRef m_lastPos;
+ TimeRef m_newPos;
+ TimeRef m_selectionStartPos; // Position of
left-most "selected" item
+ // Don't move more than
this amount to the left
+ // to avoid moving
anything past the beginning of the file.
+};
+
+#endif
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Traverso-commit] traverso resources/keymap.xml src/commands/CMak...,
Ben Levitt <=