AutomationRegionView::AutomationRegionView(ArdourCanvas::Group* parent,
AutomationTimeAxisView& time_axis,
boost::shared_ptr<ARDOUR::Region> region,
+ const ARDOUR::Parameter& param,
boost::shared_ptr<ARDOUR::AutomationList> list,
double spu,
Gdk::Color& basic_color)
: RegionView(parent, time_axis, region, spu, basic_color)
+ , _parameter(param)
{
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();
+ assert(list->parameter() == param);
+ create_line(list);
}
group->signal_event().connect (mem_fun (this, &AutomationRegionView::canvas_event), false);
reset_width_dependent_items ((double) _region->length() / samples_per_unit);
- set_y_position_and_height (0, trackview.height);
+ set_height (trackview.current_height());
_region->StateChanged.connect (mem_fun(*this, &AutomationRegionView::region_changed));
_enable_display = true;
}
+void
+AutomationRegionView::create_line (boost::shared_ptr<ARDOUR::AutomationList> list)
+{
+ _line = boost::shared_ptr<AutomationLine>(new AutomationLine(
+ list->parameter().symbol(), trackview, *get_canvas_group(), list));
+ _line->set_colors();
+ _line->show();
+ _line->show_all_control_points();
+ _line->set_height ((uint32_t)rint(trackview.current_height() - NAME_HIGHLIGHT_SIZE));
+}
+
bool
AutomationRegionView::canvas_event(GdkEvent* ev)
{
AutomationRegionView::add_automation_event (GdkEvent* event, nframes_t when, double y)
{
if (!_line) {
- cerr << "ERROR: AutomationRegionView::add_automation_event called without line" << endl;
- return;
+ boost::shared_ptr<Evoral::Control> c = _region->control(_parameter, true);
+ boost::shared_ptr<ARDOUR::AutomationControl> ac
+ = boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(c);
+ assert(ac);
+ create_line(ac->alist());
}
+ assert(_line);
double x = 0;
AutomationTimeAxisView* const view = automation_view();
/* compute vertical fractional position */
- const double height = trackview.height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 2;
- y = 1.0 - (y / height);
+ const double h = trackview.current_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 2;
+ y = 1.0 - (y / h);
/* map using line */
view->session().set_dirty ();
}
-
void
-AutomationRegionView::set_y_position_and_height (double y, double h)
+AutomationRegionView::set_height (double h)
{
- RegionView::set_y_position_and_height(y, h - 1);
+ RegionView::set_height(h);
if (_line)
- _line->set_y_position_and_height ((uint32_t)y, (uint32_t) rint (h - NAME_HIGHLIGHT_SIZE));
+ _line->set_height ((uint32_t)rint(h - NAME_HIGHLIGHT_SIZE));
}
bool