remove OS X specific code for key editor binding displays
[ardour.git] / gtk2_ardour / editor_ops.cc
index 2427f53962a0654a6e44dbf4b8266ab7e9ce5544..c598af2453c4fcad2e2f98ee58432a384d8ecff6 100644 (file)
 #include <gtkmm2ext/choice.h>
 #include <gtkmm2ext/popup.h>
 
-#include "ardour/audioengine.h"
-#include "ardour/session.h"
-#include "ardour/audioplaylist.h"
+#include "ardour/audio_track.h"
 #include "ardour/audioregion.h"
-#include "ardour/audio_diskstream.h"
-#include "ardour/utils.h"
+#include "ardour/dB.h"
 #include "ardour/location.h"
-#include "ardour/audio_track.h"
-#include "ardour/audioplaylist.h"
-#include "ardour/region_factory.h"
+#include "ardour/midi_region.h"
+#include "ardour/operations.h"
 #include "ardour/playlist_factory.h"
-#include "ardour/reverse.h"
-#include "ardour/transient_detector.h"
-#include "ardour/dB.h"
 #include "ardour/quantize.h"
-#include "ardour/strip_silence.h"
+#include "ardour/region_factory.h"
+#include "ardour/reverse.h"
 #include "ardour/route_group.h"
-#include "ardour/operations.h"
+#include "ardour/session.h"
+#include "ardour/session_playlists.h"
+#include "ardour/strip_silence.h"
+#include "ardour/transient_detector.h"
+#include "ardour/utils.h"
 
 #include "ardour_ui.h"
 #include "debug.h"
@@ -106,6 +104,10 @@ using Gtkmm2ext::Keyboard;
 void
 Editor::undo (uint32_t n)
 {
+       if (_drags->active ()) {
+               _drags->abort ();
+       }
+       
        if (_session) {
                _session->undo (n);
        }
@@ -114,6 +116,10 @@ Editor::undo (uint32_t n)
 void
 Editor::redo (uint32_t n)
 {
+       if (_drags->active ()) {
+               _drags->abort ();
+       }
+       
        if (_session) {
                _session->redo (n);
        }
@@ -1838,11 +1844,13 @@ Editor::clear_ranges ()
 
                Location * looploc = _session->locations()->auto_loop_location();
                Location * punchloc = _session->locations()->auto_punch_location();
+               Location * sessionloc = _session->locations()->session_range_location();
 
                _session->locations()->clear_ranges ();
                // re-add these
                if (looploc) _session->locations()->add (looploc);
                if (punchloc) _session->locations()->add (punchloc);
+               if (sessionloc) _session->locations()->add (sessionloc);
 
                XMLNode &after = _session->locations()->get_state();
                _session->add_command(new MementoCommand<Locations>(*(_session->locations()), &before, &after));
@@ -1936,7 +1944,6 @@ Editor::insert_route_list_drag (boost::shared_ptr<Route> route, int x, int y)
 {
        double wx, wy;
        double cx, cy;
-       framepos_t where;
        RouteTimeAxisView *dest_rtv = 0;
        RouteTimeAxisView *source_rtv = 0;
 
@@ -1949,7 +1956,7 @@ Editor::insert_route_list_drag (boost::shared_ptr<Route> route, int x, int y)
        event.button.x = wx;
        event.button.y = wy;
 
-       where = event_frame (&event, &cx, &cy);
+       event_frame (&event, &cx, &cy);
 
        std::pair<TimeAxisView*, int> const tv = trackview_by_y_position (cy);
        if (tv.first == 0) {
@@ -2191,7 +2198,7 @@ Editor::rename_region ()
        d.set_size_request (300, -1);
        d.set_position (Gtk::WIN_POS_MOUSE);
 
-       entry.set_text (selection->regions.front()->region()->name());
+       entry.set_text (rs.front()->region()->name());
        entry.select_region (0, -1);
 
        entry.signal_activate().connect (sigc::bind (sigc::mem_fun (d, &Dialog::response), RESPONSE_OK));
@@ -3274,6 +3281,14 @@ Editor::freeze_thread ()
 void
 Editor::freeze_route ()
 {
+       if (!_session) {
+               return;
+       }
+
+       /* stop transport before we start. this is important */
+
+       _session->request_transport_speed (0.0);
+
        if (clicked_routeview == 0 || !clicked_routeview->is_audio_track()) {
                return;
        }
@@ -3358,6 +3373,10 @@ Editor::bounce_range_selection (bool replace, bool enable_processing)
 
                boost::shared_ptr<Region> r = rtv->track()->bounce_range (start, start+cnt, itt, enable_processing);
 
+               if (!r) {
+                       continue;
+               }
+
                if (replace) {
                        list<AudioRange> ranges;
                        ranges.push_back (AudioRange (start, start+cnt, 0));
@@ -4748,6 +4767,60 @@ Editor::toggle_record_enable ()
        }
 }
 
+void
+Editor::toggle_solo ()
+{
+       bool new_state = false;
+       bool first = true;
+       boost::shared_ptr<RouteList> rl (new RouteList);
+
+       for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
+               RouteTimeAxisView *rtav = dynamic_cast<RouteTimeAxisView *>(*i);
+
+               if (!rtav) {
+                       continue;
+               }
+
+               if (first) {
+                       new_state = !rtav->route()->soloed ();
+                       first = false;
+               }
+
+               rl->push_back (rtav->route());
+       }
+
+       _session->set_solo (rl, new_state, Session::rt_cleanup, true);
+}
+
+void
+Editor::toggle_mute ()
+{
+       bool new_state = false;
+       bool first = true;
+       boost::shared_ptr<RouteList> rl (new RouteList);
+
+       for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
+               RouteTimeAxisView *rtav = dynamic_cast<RouteTimeAxisView *>(*i);
+
+               if (!rtav) {
+                       continue;
+               }
+
+               if (first) {
+                       new_state = !rtav->route()->muted();
+                       first = false;
+               }
+
+               rl->push_back (rtav->route());
+       }
+
+       _session->set_mute (rl, new_state, Session::rt_cleanup, true);
+}
+
+void
+Editor::toggle_solo_isolate ()
+{
+}
 
 void
 Editor::set_fade_length (bool in)
@@ -4942,7 +5015,7 @@ void
 Editor::toggle_region_fades (int dir)
 {
        boost::shared_ptr<AudioRegion> ar;
-       bool yn;
+       bool yn = false;
 
        RegionSelection rs = get_regions_from_selection_and_entered ();
 
@@ -6116,6 +6189,7 @@ Editor::do_insert_time ()
                get_preferred_edit_position(),
                d.distance(),
                opt,
+               d.all_playlists(),
                d.move_glued(),
                d.move_markers(),
                d.move_glued_markers(),
@@ -6125,8 +6199,10 @@ Editor::do_insert_time ()
 }
 
 void
-Editor::insert_time (framepos_t pos, framecnt_t frames, InsertTimeOption opt,
-                    bool ignore_music_glue, bool markers_too, bool glued_markers_too, bool locked_markers_too, bool tempo_too)
+Editor::insert_time (
+       framepos_t pos, framecnt_t frames, InsertTimeOption opt,
+       bool all_playlists, bool ignore_music_glue, bool markers_too, bool glued_markers_too, bool locked_markers_too, bool tempo_too
+       )
 {
        bool commit = false;
 
@@ -6137,25 +6213,37 @@ Editor::insert_time (framepos_t pos, framecnt_t frames, InsertTimeOption opt,
        begin_reversible_command (_("insert time"));
 
        for (TrackSelection::iterator x = selection->tracks.begin(); x != selection->tracks.end(); ++x) {
+
                /* regions */
-               boost::shared_ptr<Playlist> pl = (*x)->playlist();
 
-               if (pl) {
+               vector<boost::shared_ptr<Playlist> > pl;
+               if (all_playlists) {
+                       RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*> (*x);
+                       if (rtav) {
+                               pl = _session->playlists->playlists_for_track (rtav->track ());
+                       }
+               } else {
+                       if ((*x)->playlist ()) {
+                               pl.push_back ((*x)->playlist ());
+                       }
+               }
 
-                       pl->clear_changes ();
-                       pl->clear_owned_changes ();
+               for (vector<boost::shared_ptr<Playlist> >::iterator i = pl.begin(); i != pl.end(); ++i) {
+
+                       (*i)->clear_changes ();
+                       (*i)->clear_owned_changes ();
 
                        if (opt == SplitIntersected) {
-                               pl->split (pos);
+                               (*i)->split (pos);
                        }
 
-                       pl->shift (pos, frames, (opt == MoveIntersected), ignore_music_glue);
+                       (*i)->shift (pos, frames, (opt == MoveIntersected), ignore_music_glue);
 
                        vector<Command*> cmds;
-                       pl->rdiff (cmds);
+                       (*i)->rdiff (cmds);
                        _session->add_commands (cmds);
 
-                       _session->add_command (new StatefulDiffCommand (pl));
+                       _session->add_command (new StatefulDiffCommand (*i));
                        commit = true;
                }