Make layer menu items apply to the selection.
[ardour.git] / gtk2_ardour / editor_selection.cc
index ffc41f85115c35d0a635630e708f0bfa8f8efd62..3212c93bb76ecbf6ba553cb08fc5811222e9b777 100644 (file)
@@ -36,6 +36,8 @@
 #include "automation_line.h"
 #include "control_point.h"
 #include "editor_regions.h"
+#include "editor_cursors.h"
+#include "midi_region_view.h"
 
 #include "i18n.h"
 
@@ -952,6 +954,21 @@ Editor::sensitize_all_region_actions (bool s)
 void
 Editor::sensitize_the_right_region_actions ()
 {
+       if ((mouse_mode == MouseRange) || (mouse_mode != MouseObject && _join_object_range_state == JOIN_OBJECT_RANGE_RANGE)) {
+               sensitize_all_region_actions (false);
+               if (!selection->time.empty()) {
+                       _region_actions->get_action("split-region")->set_sensitive (true);
+               }
+               
+               return;
+
+       } else if (mouse_mode != MouseObject) {
+               sensitize_all_region_actions (false);
+               return;
+       }
+
+       /* We get here if we are in Object mode */
+                       
        RegionSelection rs = get_regions_from_selection_and_entered ();
        sensitize_all_region_actions (!rs.empty ());
 
@@ -1196,11 +1213,27 @@ Editor::select_all_in_track (Selection::Operation op)
        }
 }
 
+void
+Editor::select_all_internal_edit (Selection::Operation op)
+{
+        /* currently limited to MIDI only */
+
+       for (MidiRegionSelection::iterator i = selection->midi_regions.begin(); i != selection->midi_regions.end(); ++i) {
+               MidiRegionView* mrv = *i;
+               mrv->select_all_notes ();
+       }
+}
+
 void
 Editor::select_all (Selection::Operation op)
 {
        list<Selectable *> touched;
 
+        if (_internal_editing) {
+                select_all_internal_edit (op);
+                return;
+        }
+
        for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
                if ((*iter)->hidden()) {
                        continue;
@@ -1259,7 +1292,7 @@ Editor::invert_selection ()
  *  @param preserve_if_selected true to leave the current selection alone if we're adding to the selection and all of the selectables
  *  within the region are already selected.
  */
-bool
+void
 Editor::select_all_within (
        framepos_t start, framepos_t end, double top, double bot, const TrackViewList& tracklist, Selection::Operation op, bool preserve_if_selected
        )
@@ -1276,7 +1309,7 @@ Editor::select_all_within (
        }
 
        if (found.empty()) {
-               return false;
+               return;
        }
 
        if (preserve_if_selected && op != Selection::Toggle) {
@@ -1286,7 +1319,7 @@ Editor::select_all_within (
                }
 
                if (i == found.end()) {
-                       return false;
+                       return;
                }
        }
 
@@ -1307,8 +1340,6 @@ Editor::select_all_within (
        }
 
        commit_reversible_command ();
-
-       return !found.empty();
 }
 
 void
@@ -1467,7 +1498,7 @@ Editor::select_all_selectables_using_cursor (EditorCursor *cursor, bool after)
 
        if (after) {
                begin_reversible_command (_("select all after cursor"));
-               start = cursor->current_frame ;
+               start = cursor->current_frame;
                end = _session->current_end_frame();
        } else {
                if (cursor->current_frame > 0) {