Always show CC region, whether empty or not (ie whether MidiModel contains any events...
authorDavid Robillard <d@drobilla.net>
Tue, 11 Sep 2007 03:14:32 +0000 (03:14 +0000)
committerDavid Robillard <d@drobilla.net>
Tue, 11 Sep 2007 03:14:32 +0000 (03:14 +0000)
git-svn-id: svn://localhost/ardour2/trunk@2451 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/automation_region_view.cc
gtk2_ardour/automation_region_view.h
gtk2_ardour/automation_streamview.cc

index 539ff233efc2081ceabcf1fdd57a6399984e248c..f0dc23e0433a6c9341ce5f09aa0a342abe67e9b1 100644 (file)
@@ -30,13 +30,14 @@ AutomationRegionView::AutomationRegionView(ArdourCanvas::Group*
                                            double                                    spu,
                                            Gdk::Color&                               basic_color)
        : RegionView(parent, time_axis, region, spu, basic_color)
-       , _line(list->parameter().to_string(), time_axis, *group, list)
 { 
-       _line.set_colors();
-       _line.show();
-       _line.show_all_control_points();
-       
-       //group->raise_to_top ();
+       if (list) {
+               _line = boost::shared_ptr<AutomationLine>(new AutomationLine(
+                                       list->parameter().to_string(), time_axis, *group, list));
+               _line->set_colors();
+               _line->show();
+               _line->show_all_control_points();
+       }
        
        group->signal_event().connect (mem_fun (this, &AutomationRegionView::canvas_event), false);
 }
@@ -77,6 +78,11 @@ AutomationRegionView::canvas_event(GdkEvent* ev)
 void
 AutomationRegionView::add_automation_event (GdkEvent* event, nframes_t when, double y)
 {
+       if (!_line) {
+               cerr << "ERROR: AutomationRegionView::add_automation_event called without line" << endl;
+               return;
+       }
+
        double x = 0;
        AutomationTimeAxisView* const view = automation_view();
 
@@ -89,16 +95,16 @@ AutomationRegionView::add_automation_event (GdkEvent* event, nframes_t when, dou
 
        /* map using line */
 
-       _line.view_to_model_y (y);
+       _line->view_to_model_y (y);
 
        view->session().begin_reversible_command (_("add automation event"));
-       XMLNode& before = _line.the_list()->get_state();
+       XMLNode& before = _line->the_list()->get_state();
 
-       _line.the_list()->add (when, y);
+       _line->the_list()->add (when, y);
 
-       XMLNode& after = _line.the_list()->get_state();
+       XMLNode& after = _line->the_list()->get_state();
        view->session().commit_reversible_command (new MementoCommand<ARDOUR::AutomationList>(
-                       *_line.the_list(), &before, &after));
+                       *_line->the_list(), &before, &after));
 
        view->session().set_dirty ();
 }
@@ -109,7 +115,8 @@ AutomationRegionView::set_y_position_and_height (double y, double h)
 {
        RegionView::set_y_position_and_height(y, h - 1);
 
-       _line.set_y_position_and_height ((uint32_t)y, (uint32_t) rint (h - NAME_HIGHLIGHT_SIZE));
+       if (_line)
+               _line->set_y_position_and_height ((uint32_t)y, (uint32_t) rint (h - NAME_HIGHLIGHT_SIZE));
 }
 
 bool
@@ -127,7 +134,8 @@ AutomationRegionView::reset_width_dependent_items (double pixel_width)
 {
        RegionView::reset_width_dependent_items(pixel_width);
        
-       _line.reset();
+       if (_line)
+               _line->reset();
 }
 
 
@@ -136,20 +144,23 @@ AutomationRegionView::region_resized (ARDOUR::Change what_changed)
 {
        RegionView::region_resized(what_changed);
 
-       _line.reset();
+       if (_line)
+               _line->reset();
 }
 
 
 void
 AutomationRegionView::entered()
 {
-       _line.track_entered();
+       if (_line)
+               _line->track_entered();
 }
 
 
 void
 AutomationRegionView::exited()
 {
-       _line.track_exited();
+       if (_line)
+               _line->track_exited();
 }
 
index 79ba84b2efc56504b0c4d9f2d3a99c4282cc5337..dc0cc8f9eea9f4b43649f685baa69a36a0deaf87 100644 (file)
@@ -52,7 +52,7 @@ public:
        inline AutomationTimeAxisView* automation_view() const
                { return dynamic_cast<AutomationTimeAxisView*>(&trackview); }
        
-       AutomationLine& line() { return _line; }
+       boost::shared_ptr<AutomationLine> line() { return _line; }
        
        // We are a ghost.  Meta ghosts?  Crazy talk.
        virtual GhostRegion* add_ghost(AutomationTimeAxisView&) { return NULL; }
@@ -69,7 +69,7 @@ protected:
        void exited();
 
 private:
-       AutomationLine _line;
+       boost::shared_ptr<AutomationLine> _line;
 };
 
 #endif /* __gtk_ardour_automation_region_view_h__ */
index 4aebcbf34ced14ec8398591760f52598af7a8085..2ede053c7b7a2062de85ae3a394957e9a9ff4bca 100644 (file)
@@ -86,13 +86,9 @@ AutomationStreamView::add_region_view_internal (boost::shared_ptr<Region> region
 
        const boost::shared_ptr<AutomationControl> control = region->control(_controller->controllable()->parameter());
 
-       if ( ! control) {
-               cerr << "No " << _controller->controllable()->parameter().to_string()
-                       << " for " << region->name() << endl;
-               return NULL;
-       }
-
-       const boost::shared_ptr<AutomationList> list = control->list();
+       boost::shared_ptr<AutomationList> list;
+       if (control)
+               list = control->list();
 
        AutomationRegionView *region_view;
        std::list<RegionView *>::iterator i;