Tidy up RegionLayeringOrderEditor a bit. Add GPL boilerplate. Make it respect edit...
authorCarl Hetherington <carl@carlh.net>
Tue, 24 Jan 2012 01:31:42 +0000 (01:31 +0000)
committerCarl Hetherington <carl@carlh.net>
Tue, 24 Jan 2012 01:31:42 +0000 (01:31 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@11324 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor.cc
gtk2_ardour/public_editor.h
gtk2_ardour/region_layering_order_editor.cc
gtk2_ardour/region_layering_order_editor.h

index 9bf99a40e29ddfe4ec389433c5c70cee3cc29c2c..c118a2ee76f7d70cc259e862655c3c9f718c519a 100644 (file)
@@ -5378,7 +5378,7 @@ Editor::change_region_layering_order (bool from_context_menu)
                layering_order_editor->set_position (WIN_POS_MOUSE);
        }
 
-       layering_order_editor->set_context (clicked_routeview->name(), _session, pl, position);
+       layering_order_editor->set_context (clicked_routeview->name(), _session, clicked_routeview, pl, position);
        layering_order_editor->maybe_present ();
 }
 
index 7a755b614f20db14124bc7fe55cc0deabcb90d8a..9e4b9884de27f6062fa91d43056c5c25f90ef797 100644 (file)
@@ -395,6 +395,8 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible {
 
        virtual void snap_to_with_modifier (framepos_t &, GdkEvent const *, int32_t direction = 0, bool for_mark = false) = 0;
 
+       virtual void get_regions_at (RegionSelection &, framepos_t where, TrackViewList const &) const = 0;
+
        /// Singleton instance, set up by Editor::Editor()
 
        static PublicEditor* _instance;
index 11882656a1c33632603a74026bb76c8bfc75d6ba..dbf3fa9dcfdd063ec7d3859d605e53b9a31e6fba 100644 (file)
@@ -1,3 +1,22 @@
+/*
+    Copyright (C) 2011-2012 Paul Davis
+
+    This program 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
 #include <gtkmm/table.h>
 #include <gtkmm/stock.h>
 #include <gtkmm/alignment.h>
@@ -7,6 +26,7 @@
 #include "keyboard.h"
 #include "public_editor.h"
 #include "region_layering_order_editor.h"
+#include "region_view.h"
 #include "utils.h"
 #include "i18n.h"
 
@@ -16,16 +36,13 @@ using namespace ARDOUR;
 
 RegionLayeringOrderEditor::RegionLayeringOrderEditor (PublicEditor& pe)
        : ArdourWindow (_("RegionLayeringOrderEditor"))
-       , playlist ()
-       , position ()
+       , position (0)
        , in_row_change (false)
         , regions_at_position (0)
-       , layering_order_columns ()
        , layering_order_model (Gtk::ListStore::create (layering_order_columns))
-       , layering_order_display ()
         , clock ("layer dialog", true, "", false, false, false)
-       , scroller ()
        , editor (pe)
+       , _time_axis_view (0)
 {
        set_name ("RegionLayeringOrderEditorWindow");
 
@@ -86,6 +103,7 @@ RegionLayeringOrderEditor::RegionLayeringOrderEditor (PublicEditor& pe)
 
 RegionLayeringOrderEditor::~RegionLayeringOrderEditor ()
 {
+       
 }
 
 void
@@ -97,40 +115,42 @@ RegionLayeringOrderEditor::row_activated (const TreeModel::Path& path, TreeViewC
 
        TreeModel::iterator iter = layering_order_model->get_iter (path);
 
-       if (iter) {
-               TreeModel::Row row = *iter;
-               boost::shared_ptr<Region> region = row[layering_order_columns.region];
-
-               region->raise_to_top ();
+       if (!iter) {
+               return;
+       }
+       
+       TreeModel::Row row = *iter;
+       RegionView* rv = row[layering_order_columns.region_view];
+       
+       vector<RegionView*> eq;
+       editor.get_equivalent_regions (rv, eq, Properties::edit.property_id);
+       
+       for (vector<RegionView*>::iterator i = eq.begin(); i != eq.end(); ++i) {
+               (*i)->region()->raise_to_top ();
        }
 }
 
-typedef boost::shared_ptr<Region> RegionPtr;
-
-struct RegionCompareByLayer {
-    bool operator() (RegionPtr a, RegionPtr b) const {
-           return a->layer() > b->layer();
-    }
+struct RegionViewCompareByLayer {
+       bool operator() (RegionView* a, RegionView* b) const {
+               return a->region()->layer() > b->region()->layer();
+       }
 };
 
 void
 RegionLayeringOrderEditor::refill ()
 {
+       assert (_time_axis_view);
+       
        regions_at_position = 0;
-
-       if (!playlist) {
-               return;
-       }
-
-       typedef Playlist::RegionList RegionList;
-
        in_row_change = true;
-
        layering_order_model->clear ();
 
-       boost::shared_ptr<RegionList> region_list(playlist->regions_at (position));
+       RegionSelection region_list;
+       TrackViewList ts;
+       ts.push_back (_time_axis_view);
+       editor.get_regions_at (region_list, position, ts);
 
-       regions_at_position = region_list->size();
+       regions_at_position = region_list.size ();
 
        if (regions_at_position < 2) {
                playlist_modified_connection.disconnect ();
@@ -139,15 +159,15 @@ RegionLayeringOrderEditor::refill ()
                return;
        }
 
-       RegionCompareByLayer cmp;
-       region_list->sort (cmp);
+       RegionViewCompareByLayer cmp;
+       region_list.sort (cmp);
 
-       for (RegionList::const_iterator i = region_list->begin(); i != region_list->end(); ++i) {
+       for (RegionSelection::const_iterator i = region_list.begin(); i != region_list.end(); ++i) {
                TreeModel::Row newrow = *(layering_order_model->append());
-               newrow[layering_order_columns.name] = (*i)->name();
-               newrow[layering_order_columns.region] = *i;
+               newrow[layering_order_columns.name] = (*i)->region()->name();
+               newrow[layering_order_columns.region_view] = *i;
 
-               if (i == region_list->begin()) {
+               if (i == region_list.begin()) {
                        layering_order_display.get_selection()->select(newrow);
                }
        }
@@ -156,7 +176,7 @@ RegionLayeringOrderEditor::refill ()
 }
 
 void
-RegionLayeringOrderEditor::set_context (const string& a_name, Session* s, const boost::shared_ptr<Playlist>  & pl, framepos_t pos)
+RegionLayeringOrderEditor::set_context (const string& a_name, Session* s, TimeAxisView* tav, boost::shared_ptr<Playlist> pl, framepos_t pos)
 {
         track_name_label.set_text (a_name);
 
@@ -164,9 +184,10 @@ RegionLayeringOrderEditor::set_context (const string& a_name, Session* s, const
        clock.set (pos, true);
 
        playlist_modified_connection.disconnect ();
-       playlist = pl;
-       playlist->ContentsChanged.connect (playlist_modified_connection, invalidator (*this), boost::bind
-                                           (&RegionLayeringOrderEditor::playlist_modified, this), gui_context());
+       pl->ContentsChanged.connect (playlist_modified_connection, invalidator (*this), boost::bind
+                                    (&RegionLayeringOrderEditor::playlist_modified, this), gui_context());
+
+       _time_axis_view = tav;
 
        position = pos;
        refill ();
index aad87297593d6a69294ddbe5324d4aa933c439a5..acdb1e59a512843298884afecc3940f5e34c380c 100644 (file)
@@ -1,3 +1,22 @@
+/*
+    Copyright (C) 2011-2012 Paul Davis
+
+    This program 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
 #ifndef __gtk2_ardour_region_layering_order_editor_h__
 #define __gtk2_ardour_region_layering_order_editor_h__
 
@@ -24,14 +43,13 @@ class RegionLayeringOrderEditor : public ArdourWindow
        RegionLayeringOrderEditor (PublicEditor&);
        virtual ~RegionLayeringOrderEditor ();
 
-       void set_context(const std::string& name, ARDOUR::Session* s, const boost::shared_ptr<ARDOUR::Playlist>  & pl, ARDOUR::framepos_t position);
+       void set_context (const std::string &, ARDOUR::Session *, TimeAxisView *, boost::shared_ptr<ARDOUR::Playlist>, ARDOUR::framepos_t);
        void maybe_present ();
 
   protected:
        virtual bool on_key_press_event (GdkEventKey* event);
 
   private:
-       boost::shared_ptr<ARDOUR::Playlist> playlist;
        framepos_t position;
        bool in_row_change;
        uint32_t regions_at_position;
@@ -41,10 +59,10 @@ class RegionLayeringOrderEditor : public ArdourWindow
        struct LayeringOrderColumns : public Gtk::TreeModel::ColumnRecord {
                LayeringOrderColumns () {
                        add (name);
-                       add (region);
+                       add (region_view);
                }
                Gtk::TreeModelColumn<std::string> name;
-               Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
+               Gtk::TreeModelColumn<RegionView *> region_view;
        };
        LayeringOrderColumns layering_order_columns;
        Glib::RefPtr<Gtk::ListStore> layering_order_model;
@@ -55,6 +73,7 @@ class RegionLayeringOrderEditor : public ArdourWindow
        Gtk::Label clock_label;
        Gtk::ScrolledWindow scroller;   // Available layers
        PublicEditor& editor;
+       TimeAxisView* _time_axis_view;
 
        void row_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column);
        void refill ();