patch from lincoln to make MIDI track height changes no longer just grow note height...
[ardour.git] / gtk2_ardour / region_view.cc
index 5cc4df56693338564765f297a9e91e3df93e35df..aeae3acc9a1015179a6572a11cfb650e8fd48721 100644 (file)
@@ -58,7 +58,7 @@ using namespace ArdourCanvas;
 
 static const int32_t sync_mark_width = 9;
 
-boost::signals2::signal<void(RegionView*)> RegionView::RegionViewGoingAway;
+PBD::Signal1<void,RegionView*> RegionView::RegionViewGoingAway;
 
 RegionView::RegionView (ArdourCanvas::Group*              parent,
                         TimeAxisView&                     tv,
@@ -80,7 +80,7 @@ RegionView::RegionView (ArdourCanvas::Group*              parent,
        , wait_for_data(false)
        , _time_converter(r->session().tempo_map(), r->position())
 {
-       cerr << "RV " << this << " has ref on region " << _region->name() << endl;
+       GhostRegion::CatchDeletion.connect (*this, invalidator (*this), ui_bind (&RegionView::remove_ghost, this, _1), gui_context());
 }
 
 RegionView::RegionView (const RegionView& other)
@@ -94,8 +94,8 @@ RegionView::RegionView (const RegionView& other)
        current_visible_sync_position = other.current_visible_sync_position;
        valid = false;
        _pixel_width = other._pixel_width;
-       _height = other._height;
-       cerr << "RV " << this << " has ref on region " << _region->name() << endl;
+
+       GhostRegion::CatchDeletion.connect (*this, invalidator (*this), ui_bind (&RegionView::remove_ghost, this, _1), gui_context());
 }
 
 RegionView::RegionView (const RegionView& other, boost::shared_ptr<Region> other_region)
@@ -113,8 +113,8 @@ RegionView::RegionView (const RegionView& other, boost::shared_ptr<Region> other
        current_visible_sync_position = other.current_visible_sync_position;
        valid = false;
        _pixel_width = other._pixel_width;
-       _height = other._height;
-       cerr << "RV " << this << " has ref on region " << _region->name() << endl;
+
+       GhostRegion::CatchDeletion.connect (*this, invalidator (*this), ui_bind (&RegionView::remove_ghost, this, _1), gui_context());
 }
 
 RegionView::RegionView (ArdourCanvas::Group*         parent,
@@ -137,7 +137,6 @@ RegionView::RegionView (ArdourCanvas::Group*         parent,
        , wait_for_data(false)
        , _time_converter(r->session().tempo_map(), r->position())
 {
-       cerr << "RV " << this << " has ref on region " << _region->name() << endl;
 }
 
 void
@@ -146,7 +145,6 @@ RegionView::init (Gdk::Color const & basic_color, bool wfd)
        editor        = 0;
        valid         = true;
        in_destructor = false;
-       _height       = 0;
        wait_for_data = wfd;
        sync_mark     = 0;
        sync_line     = 0;
@@ -171,15 +169,17 @@ RegionView::init (Gdk::Color const & basic_color, bool wfd)
 
        if (name_pixbuf) {
                name_pixbuf->set_data ("regionview", this);
+               name_pixbuf->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_region_view_name_event), name_pixbuf, this));
        }
 
-       if (wfd)
+       if (wfd) {
                _enable_display = true;
+       }
 
        set_height (trackview.current_height());
 
-       _region->StateChanged.connect (sigc::mem_fun(*this, &RegionView::region_changed));
-
+       _region->PropertyChanged.connect (*this, invalidator (*this), ui_bind (&RegionView::region_changed, this, _1), gui_context());
+       
        group->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_region_view_event), group, this));
 
        set_colors ();
@@ -225,27 +225,27 @@ RegionView::lock_toggle ()
 }
 
 void
-RegionView::region_changed (Change what_changed)
+RegionView::region_changed (const PropertyChange& what_changed)
 {
-       ENSURE_GUI_THREAD (*this, &RegionView::region_changed, what_changed)
+       ENSURE_GUI_THREAD (*this, &RegionView::region_changed, what_changed);
 
-       if (what_changed & BoundsChanged) {
+       if (what_changed.contains (ARDOUR::bounds_change)) {
                region_resized (what_changed);
                region_sync_changed ();
        }
-       if (what_changed & Region::MuteChanged) {
+       if (what_changed.contains (ARDOUR::Properties::muted)) {
                region_muted ();
        }
-       if (what_changed & Region::OpacityChanged) {
+       if (what_changed.contains (ARDOUR::Properties::opaque)) {
                region_opacity ();
        }
-       if (what_changed & ARDOUR::NameChanged) {
+       if (what_changed.contains (ARDOUR::Properties::name)) {
                region_renamed ();
        }
-       if (what_changed & Region::SyncOffsetChanged) {
+       if (what_changed.contains (ARDOUR::Properties::sync_position)) {
                region_sync_changed ();
        }
-       if (what_changed & Region::LockChanged) {
+       if (what_changed.contains (ARDOUR::Properties::locked)) {
                region_locked ();
        }
 }
@@ -258,16 +258,20 @@ RegionView::region_locked ()
 }
 
 void
-RegionView::region_resized (Change what_changed)
+RegionView::region_resized (const PropertyChange& what_changed)
 {
        double unit_length;
 
-       if (what_changed & ARDOUR::PositionChanged) {
+       if (what_changed.contains (ARDOUR::Properties::position)) {
                set_position (_region->position(), 0);
                _time_converter.set_origin(_region->position());
        }
 
-       if (what_changed & Change (StartChanged|LengthChanged)) {
+       PropertyChange s_and_l;
+       s_and_l.add (ARDOUR::Properties::start);
+       s_and_l.add (ARDOUR::Properties::length);
+
+       if (what_changed.contains (s_and_l)) {
 
                set_duration (_region->length(), 0);
 
@@ -398,6 +402,17 @@ RegionView::fake_set_opaque (bool yn)
        set_frame_color ();
 }
 
+void
+RegionView::show_region_editor ()
+{
+       if (editor == 0) {
+               editor = new RegionEditor (trackview.session(), region());
+       }
+
+       editor->present ();
+       editor->show_all();
+}
+
 void
 RegionView::hide_region_editor()
 {