summaryrefslogtreecommitdiff
path: root/gtk2_ardour/editor_ops.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-01-09 23:24:54 +0000
committerDavid Robillard <d@drobilla.net>2007-01-09 23:24:54 +0000
commit532f6aad4ac79ca15d69deccd18fca90e444c437 (patch)
tree0d4ca5449af8eb48ad56e163efcab42c4656e8de /gtk2_ardour/editor_ops.cc
parentef6b25432d9c46d71b08c0f7d5f2686df428c4e8 (diff)
Merged with trunk R1283.
NOTE: Compiles, but broken (crash on adding MIDI track). git-svn-id: svn://localhost/ardour2/branches/midi@1292 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/editor_ops.cc')
-rw-r--r--gtk2_ardour/editor_ops.cc124
1 files changed, 81 insertions, 43 deletions
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index 93e90f4c2c..ea4848b882 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -44,6 +44,7 @@
#include <ardour/audio_track.h>
#include <ardour/audioplaylist.h>
#include <ardour/region_factory.h>
+#include <ardour/playlist_factory.h>
#include <ardour/reverse.h>
#include "ardour_ui.h"
@@ -56,7 +57,6 @@
#include "rgb_macros.h"
#include "selection_templates.h"
#include "selection.h"
-#include "sfdb_ui.h"
#include "editing.h"
#include "gtk-custom-hruler.h"
#include "gui_thread.h"
@@ -122,7 +122,7 @@ Editor::split_regions_at (nframes_t where, RegionSelection& regions)
tmp = a;
++tmp;
- Playlist* pl = (*a)->region()->playlist();
+ boost::shared_ptr<Playlist> pl = (*a)->region()->playlist();
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*a);
if (arv)
@@ -149,7 +149,7 @@ Editor::remove_clicked_region ()
return;
}
- Playlist* playlist = clicked_routeview->playlist();
+ boost::shared_ptr<Playlist> playlist = clicked_routeview->playlist();
begin_reversible_command (_("remove region"));
XMLNode &before = playlist->get_state();
@@ -232,7 +232,7 @@ Editor::select_region_for_operation (int dir, TimeAxisView **tv)
RouteTimeAxisView* rtv;
if ((rtv = dynamic_cast<RouteTimeAxisView*> (*tv)) != 0) {
- Playlist *pl;
+ boost::shared_ptr<Playlist> pl;
if ((pl = rtv->playlist()) == 0) {
return region;
@@ -1197,6 +1197,8 @@ Editor::temporal_zoom_to_frame (bool coarser, nframes_t frame)
void
Editor::add_location_from_selection ()
{
+ string rangename;
+
if (selection->time.empty()) {
return;
}
@@ -1208,7 +1210,8 @@ Editor::add_location_from_selection ()
nframes_t start = selection->time[clicked_selection].start;
nframes_t end = selection->time[clicked_selection].end;
- Location *location = new Location (start, end, "selection");
+ session->locations()->next_available_name(rangename,"selection");
+ Location *location = new Location (start, end, rangename, Location::IsRangeMarker);
session->begin_reversible_command (_("add marker"));
XMLNode &before = session->locations()->get_state();
@@ -1221,9 +1224,12 @@ Editor::add_location_from_selection ()
void
Editor::add_location_from_playhead_cursor ()
{
+ string markername;
+
nframes_t where = session->audible_frame();
- Location *location = new Location (where, where, "mark", Location::IsMark);
+ session->locations()->next_available_name(markername,"mark");
+ Location *location = new Location (where, where, markername, Location::IsMark);
session->begin_reversible_command (_("add marker"));
XMLNode &before = session->locations()->get_state();
session->locations()->add (location, true);
@@ -1242,7 +1248,7 @@ Editor::add_location_from_audio_region ()
RegionView* rv = *(selection->regions.begin());
boost::shared_ptr<Region> region = rv->region();
- Location *location = new Location (region->position(), region->last_frame(), region->name());
+ Location *location = new Location (region->position(), region->last_frame(), region->name(), Location::IsRangeMarker);
session->begin_reversible_command (_("add marker"));
XMLNode &before = session->locations()->get_state();
session->locations()->add (location, true);
@@ -1649,6 +1655,7 @@ Editor::set_mark ()
nframes_t pos;
float prefix;
bool was_floating;
+ string markername;
if (get_prefix (prefix, was_floating)) {
pos = session->audible_frame ();
@@ -1660,7 +1667,8 @@ Editor::set_mark ()
}
}
- session->locations()->add (new Location (pos, 0, "mark", Location::IsMark), true);
+ session->locations()->next_available_name(markername,"mark");
+ session->locations()->add (new Location (pos, 0, markername, Location::IsMark), true);
}
void
@@ -1709,6 +1717,28 @@ Editor::clear_locations ()
session->locations()->clear ();
}
+void
+Editor::unhide_markers ()
+{
+ for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
+ Location *l = (*i).first;
+ if (l->is_hidden() && l->is_mark()) {
+ l->set_hidden(false, this);
+ }
+ }
+}
+
+void
+Editor::unhide_ranges ()
+{
+ for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
+ Location *l = (*i).first;
+ if (l->is_hidden() && l->is_range_marker()) {
+ l->set_hidden(false, this);
+ }
+ }
+}
+
/* INSERT/REPLACE */
void
@@ -1719,7 +1749,7 @@ Editor::insert_region_list_drag (boost::shared_ptr<Region> region, int x, int y)
TimeAxisView *tv;
nframes_t where;
AudioTimeAxisView *atv = 0;
- Playlist *playlist;
+ boost::shared_ptr<Playlist> playlist;
track_canvas.window_to_world (x, y, wx, wy);
wx += horizontal_adjustment.get_value();
@@ -1749,20 +1779,26 @@ Editor::insert_region_list_drag (boost::shared_ptr<Region> region, int x, int y)
return;
}
+ cerr << "drop target playlist, UC = " << playlist.use_count() << endl;
+
snap_to (where);
begin_reversible_command (_("insert dragged region"));
XMLNode &before = playlist->get_state();
+ cerr << "pre add target playlist, UC = " << playlist.use_count() << endl;
playlist->add_region (RegionFactory::create (region), where, 1.0);
+ cerr << "post add target playlist, UC = " << playlist.use_count() << endl;
session->add_command(new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
commit_reversible_command ();
+
+ cerr << "post drop target playlist, UC = " << playlist.use_count() << endl;
}
void
Editor::insert_region_list_selection (float times)
{
RouteTimeAxisView *tv = 0;
- Playlist *playlist;
+ boost::shared_ptr<Playlist> playlist;
if (clicked_routeview != 0) {
tv = clicked_routeview;
@@ -2097,7 +2133,7 @@ Editor::region_from_selection ()
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
boost::shared_ptr<AudioRegion> current;
boost::shared_ptr<Region> current_r;
- Playlist *pl;
+ boost::shared_ptr<Playlist> pl;
nframes_t internal_start;
string new_name;
@@ -2134,7 +2170,7 @@ Editor::create_region_from_selection (vector<boost::shared_ptr<AudioRegion> >& n
boost::shared_ptr<AudioRegion> current;
boost::shared_ptr<Region> current_r;
- Playlist* playlist;
+ boost::shared_ptr<Playlist> playlist;
nframes_t internal_start;
string new_name;
@@ -2191,7 +2227,7 @@ Editor::separate_region_from_selection ()
return;
}
- Playlist *playlist;
+ boost::shared_ptr<Playlist> playlist;
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
@@ -2239,7 +2275,7 @@ Editor::separate_regions_using_location (Location& loc)
return;
}
- Playlist *playlist;
+ boost::shared_ptr<Playlist> playlist;
/* XXX i'm unsure as to whether this should operate on selected tracks only
or the entire enchillada. uncomment the below line to correct the behaviour
@@ -2288,8 +2324,8 @@ Editor::crop_region_to_selection ()
return;
}
- vector<Playlist*> playlists;
- Playlist *playlist;
+ vector<boost::shared_ptr<Playlist> > playlists;
+ boost::shared_ptr<Playlist> playlist;
if (clicked_axisview != 0) {
@@ -2322,7 +2358,7 @@ Editor::crop_region_to_selection ()
begin_reversible_command (_("trim to selection"));
- for (vector<Playlist*>::iterator i = playlists.begin(); i != playlists.end(); ++i) {
+ for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
boost::shared_ptr<Region> region;
@@ -2371,7 +2407,7 @@ Editor::region_fill_track ()
boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>(region);
assert(ar);
- Playlist* pl = region->playlist();
+ boost::shared_ptr<Playlist> pl = region->playlist();
if (end <= region->last_frame()) {
return;
@@ -2415,7 +2451,7 @@ Editor::region_fill_selection ()
nframes_t start = selection->time[clicked_selection].start;
nframes_t end = selection->time[clicked_selection].end;
- Playlist *playlist;
+ boost::shared_ptr<Playlist> playlist;
if (selection->tracks.empty()) {
return;
@@ -2781,7 +2817,7 @@ Editor::bounce_range_selection ()
continue;
}
- Playlist* playlist;
+ boost::shared_ptr<Playlist> playlist;
if ((playlist = atv->playlist()) == 0) {
return;
@@ -2897,7 +2933,7 @@ Editor::cut_copy_points (CutCopyOp op)
}
struct PlaylistState {
- Playlist* playlist;
+ boost::shared_ptr<Playlist> playlist;
XMLNode* before;
};
@@ -2910,7 +2946,7 @@ struct lt_playlist {
void
Editor::cut_copy_regions (CutCopyOp op)
{
- typedef std::map<AudioPlaylist*,AudioPlaylist*> PlaylistMapping;
+ typedef std::map<boost::shared_ptr<AudioPlaylist>,boost::shared_ptr<AudioPlaylist> > PlaylistMapping;
PlaylistMapping pmap;
nframes_t first_position = max_frames;
@@ -2921,7 +2957,8 @@ Editor::cut_copy_regions (CutCopyOp op)
first_position = min ((*x)->region()->position(), first_position);
if (op == Cut || op == Clear) {
- AudioPlaylist *pl = dynamic_cast<AudioPlaylist*>((*x)->region()->playlist());
+ boost::shared_ptr<AudioPlaylist> pl = boost::dynamic_pointer_cast<AudioPlaylist>((*x)->region()->playlist());
+
if (pl) {
PlaylistState before;
@@ -2939,8 +2976,8 @@ Editor::cut_copy_regions (CutCopyOp op)
for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ) {
- AudioPlaylist *pl = dynamic_cast<AudioPlaylist*>((*x)->region()->playlist());
- AudioPlaylist* npl;
+ boost::shared_ptr<AudioPlaylist> pl = boost::dynamic_pointer_cast<AudioPlaylist>((*x)->region()->playlist());
+ boost::shared_ptr<AudioPlaylist> npl;
RegionSelection::iterator tmp;
tmp = x;
@@ -2951,7 +2988,8 @@ Editor::cut_copy_regions (CutCopyOp op)
PlaylistMapping::iterator pi = pmap.find (pl);
if (pi == pmap.end()) {
- npl = new AudioPlaylist (*session, "cutlist", true);
+ // FIXME
+ npl = boost::dynamic_pointer_cast<AudioPlaylist> (PlaylistFactory::create (DataType::AUDIO, *session, "cutlist", true));
npl->freeze();
pmap[pl] = npl;
} else {
@@ -2983,7 +3021,7 @@ Editor::cut_copy_regions (CutCopyOp op)
x = tmp;
}
- list<Playlist*> foo;
+ list<boost::shared_ptr<Playlist> > foo;
for (PlaylistMapping::iterator i = pmap.begin(); i != pmap.end(); ++i) {
foo.push_back (i->second);
@@ -3080,8 +3118,8 @@ Editor::paste_named_selection (float times)
TreeModel::iterator i = selected->get_selected();
NamedSelection* ns = (*i)[named_selection_columns.selection];
- list<Playlist*>::iterator chunk;
- list<Playlist*>::iterator tmp;
+ list<boost::shared_ptr<Playlist> >::iterator chunk;
+ list<boost::shared_ptr<Playlist> >::iterator tmp;
chunk = ns->playlists.begin();
@@ -3090,8 +3128,8 @@ Editor::paste_named_selection (float times)
for (t = selection->tracks.begin(); t != selection->tracks.end(); ++t) {
AudioTimeAxisView* atv;
- Playlist* pl;
- AudioPlaylist* apl;
+ boost::shared_ptr<Playlist> pl;
+ boost::shared_ptr<AudioPlaylist> apl;
if ((atv = dynamic_cast<AudioTimeAxisView*> (*t)) == 0) {
continue;
@@ -3100,8 +3138,8 @@ Editor::paste_named_selection (float times)
if ((pl = atv->playlist()) == 0) {
continue;
}
-
- if ((apl = dynamic_cast<AudioPlaylist*> (pl)) == 0) {
+
+ if ((apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl)) == 0) {
continue;
}
@@ -3109,7 +3147,7 @@ Editor::paste_named_selection (float times)
++tmp;
XMLNode &before = apl->get_state();
- apl->paste (**chunk, edit_cursor->current_frame, times);
+ apl->paste (*chunk, edit_cursor->current_frame, times);
session->add_command(new MementoCommand<AudioPlaylist>(*apl, &before, &apl->get_state()));
if (tmp != ns->playlists.end()) {
@@ -3123,7 +3161,7 @@ Editor::paste_named_selection (float times)
void
Editor::duplicate_some_regions (RegionSelection& regions, float times)
{
- Playlist *playlist;
+ boost::shared_ptr<Playlist> playlist;
RegionSelection sel = regions; // clear (below) will clear the argument list
begin_reversible_command (_("duplicate region"));
@@ -3161,7 +3199,7 @@ Editor::duplicate_selection (float times)
return;
}
- Playlist *playlist;
+ boost::shared_ptr<Playlist> playlist;
vector<boost::shared_ptr<AudioRegion> > new_regions;
vector<boost::shared_ptr<AudioRegion> >::iterator ri;
@@ -3227,20 +3265,20 @@ Editor::center_edit_cursor ()
}
void
-Editor::clear_playlist (Playlist& playlist)
+Editor::clear_playlist (boost::shared_ptr<Playlist> playlist)
{
begin_reversible_command (_("clear playlist"));
- XMLNode &before = playlist.get_state();
- playlist.clear ();
- XMLNode &after = playlist.get_state();
- session->add_command (new MementoCommand<Playlist>(playlist, &before, &after));
+ XMLNode &before = playlist->get_state();
+ playlist->clear ();
+ XMLNode &after = playlist->get_state();
+ session->add_command (new MementoCommand<Playlist>(*playlist.get(), &before, &after));
commit_reversible_command ();
}
void
Editor::nudge_track (bool use_edit_cursor, bool forwards)
{
- Playlist *playlist;
+ boost::shared_ptr<Playlist> playlist;
nframes_t distance;
nframes_t next_distance;
nframes_t start;
@@ -3388,7 +3426,7 @@ Editor::apply_filter (AudioFilter& filter, string command)
if (!arv)
continue;
- Playlist* playlist = arv->region()->playlist();
+ boost::shared_ptr<Playlist> playlist = arv->region()->playlist();
RegionSelection::iterator tmp;