2005-09-25 18:42:24 +00:00
|
|
|
/*
|
|
|
|
|
Copyright (C) 2003 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.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
2007-06-27 20:23:48 +00:00
|
|
|
#include <ardour/processor.h>
|
2005-09-25 18:42:24 +00:00
|
|
|
#include <ardour/session.h>
|
|
|
|
|
#include <cstdlib>
|
2006-07-29 03:17:11 +00:00
|
|
|
#include <pbd/memento_command.h>
|
2005-09-25 18:42:24 +00:00
|
|
|
|
2007-06-27 20:23:48 +00:00
|
|
|
#include "processor_automation_time_axis.h"
|
2005-09-25 18:42:24 +00:00
|
|
|
#include "automation_line.h"
|
2005-11-16 02:57:22 +00:00
|
|
|
#include "canvas_impl.h"
|
2005-09-25 18:42:24 +00:00
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
|
|
using namespace ARDOUR;
|
2006-06-22 23:40:55 +00:00
|
|
|
using namespace PBD;
|
2005-09-25 18:42:24 +00:00
|
|
|
using namespace Gtk;
|
|
|
|
|
|
2007-06-27 20:23:48 +00:00
|
|
|
ProcessorAutomationTimeAxisView::ProcessorAutomationTimeAxisView (Session& s, boost::shared_ptr<Route> r,
|
2006-08-04 02:18:45 +00:00
|
|
|
PublicEditor& e, TimeAxisView& parent, Canvas& canvas, std::string n,
|
2007-06-27 20:23:48 +00:00
|
|
|
ParamID param, Processor& proc, string state_name)
|
2005-09-25 18:42:24 +00:00
|
|
|
|
|
|
|
|
: AxisView (s),
|
2007-06-27 20:23:48 +00:00
|
|
|
AutomationTimeAxisView (s, r, e, parent, canvas, n, state_name, proc.name()),
|
|
|
|
|
_processor(proc),
|
|
|
|
|
_param (param)
|
2005-09-25 18:42:24 +00:00
|
|
|
|
|
|
|
|
{
|
|
|
|
|
char buf[32];
|
2007-06-27 20:23:48 +00:00
|
|
|
_xml_node = 0;
|
2005-09-25 18:42:24 +00:00
|
|
|
_marked_for_display = false;
|
|
|
|
|
|
|
|
|
|
ensure_xml_node ();
|
|
|
|
|
|
|
|
|
|
XMLNodeList kids;
|
|
|
|
|
XMLNodeConstIterator iter;
|
|
|
|
|
|
2007-06-27 20:23:48 +00:00
|
|
|
kids = _xml_node->children ();
|
2005-09-25 18:42:24 +00:00
|
|
|
|
2007-06-27 15:51:50 +00:00
|
|
|
snprintf (buf, sizeof(buf), "Port_%" PRIu32, param.id());
|
2005-09-25 18:42:24 +00:00
|
|
|
|
|
|
|
|
for (iter = kids.begin(); iter != kids.end(); ++iter) {
|
|
|
|
|
if ((*iter)->name() == buf) {
|
|
|
|
|
|
|
|
|
|
XMLProperty *shown = (*iter)->property("shown_editor");
|
|
|
|
|
|
|
|
|
|
if (shown && shown->value() == "yes") {
|
|
|
|
|
_marked_for_display = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-27 20:23:48 +00:00
|
|
|
ProcessorAutomationTimeAxisView::~ProcessorAutomationTimeAxisView ()
|
2005-09-25 18:42:24 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2007-06-27 20:23:48 +00:00
|
|
|
ProcessorAutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* item, GdkEvent* event, nframes_t when, double y)
|
2005-09-25 18:42:24 +00:00
|
|
|
{
|
|
|
|
|
double x = 0;
|
|
|
|
|
|
2005-11-13 03:53:51 +00:00
|
|
|
canvas_display->w2i (x, y);
|
2005-09-25 18:42:24 +00:00
|
|
|
|
|
|
|
|
/* compute vertical fractional position */
|
|
|
|
|
|
|
|
|
|
if (y < 0)
|
|
|
|
|
y = 0;
|
|
|
|
|
else if (y > height)
|
|
|
|
|
y = height;
|
|
|
|
|
|
|
|
|
|
y = 1.0 - (y / height);
|
|
|
|
|
|
|
|
|
|
/* map to model space */
|
|
|
|
|
|
|
|
|
|
if (!lines.empty()) {
|
2007-06-29 04:02:58 +00:00
|
|
|
boost::shared_ptr<AutomationList> alist (_processor.control(_param, true)->list());
|
2005-09-25 18:42:24 +00:00
|
|
|
string description = _("add automation event to ");
|
2007-06-27 20:23:48 +00:00
|
|
|
description += _processor.describe_parameter (_param);
|
2005-09-25 18:42:24 +00:00
|
|
|
|
2007-06-29 04:02:58 +00:00
|
|
|
lines.front().first->view_to_model_y (y);
|
2005-09-25 18:42:24 +00:00
|
|
|
|
|
|
|
|
_session.begin_reversible_command (description);
|
2007-06-27 15:51:50 +00:00
|
|
|
XMLNode &before = alist->get_state();
|
|
|
|
|
alist->add (when, y);
|
|
|
|
|
XMLNode &after = alist->get_state();
|
|
|
|
|
_session.add_command(new MementoCommand<AutomationList>(*alist, &before, &after));
|
2005-09-25 18:42:24 +00:00
|
|
|
_session.commit_reversible_command ();
|
|
|
|
|
_session.set_dirty ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2007-06-27 20:23:48 +00:00
|
|
|
ProcessorAutomationTimeAxisView::ensure_xml_node ()
|
2005-09-25 18:42:24 +00:00
|
|
|
{
|
2007-06-27 20:23:48 +00:00
|
|
|
if (_xml_node == 0) {
|
|
|
|
|
if ((_xml_node = _processor.extra_xml ("GUI")) == 0) {
|
|
|
|
|
_xml_node = new XMLNode ("GUI");
|
|
|
|
|
_processor.add_extra_xml (*_xml_node);
|
2005-09-25 18:42:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
guint32
|
2007-06-27 20:23:48 +00:00
|
|
|
ProcessorAutomationTimeAxisView::show_at (double y, int& nth, Gtk::VBox *parent)
|
2005-09-25 18:42:24 +00:00
|
|
|
{
|
|
|
|
|
ensure_xml_node ();
|
|
|
|
|
update_extra_xml_shown (true);
|
|
|
|
|
|
|
|
|
|
return TimeAxisView::show_at (y, nth, parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2007-06-27 20:23:48 +00:00
|
|
|
ProcessorAutomationTimeAxisView::hide ()
|
2005-09-25 18:42:24 +00:00
|
|
|
{
|
|
|
|
|
ensure_xml_node ();
|
|
|
|
|
update_extra_xml_shown (false);
|
|
|
|
|
|
|
|
|
|
TimeAxisView::hide ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2007-06-27 20:23:48 +00:00
|
|
|
ProcessorAutomationTimeAxisView::update_extra_xml_shown (bool editor_shown)
|
2005-09-25 18:42:24 +00:00
|
|
|
{
|
|
|
|
|
char buf[32];
|
|
|
|
|
|
2007-06-27 20:23:48 +00:00
|
|
|
XMLNodeList nlist = _xml_node->children ();
|
2005-09-25 18:42:24 +00:00
|
|
|
XMLNodeConstIterator i;
|
|
|
|
|
XMLNode * port_node = 0;
|
|
|
|
|
|
2007-06-27 20:23:48 +00:00
|
|
|
snprintf (buf, sizeof(buf), "Port_%" PRIu32, _param.id());
|
2005-09-25 18:42:24 +00:00
|
|
|
|
|
|
|
|
for (i = nlist.begin(); i != nlist.end(); ++i) {
|
|
|
|
|
if ((*i)->name() == buf) {
|
|
|
|
|
port_node = (*i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!port_node) {
|
|
|
|
|
port_node = new XMLNode(buf);
|
2007-06-27 20:23:48 +00:00
|
|
|
_xml_node->add_child_nocopy(*port_node);
|
2005-09-25 18:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
port_node->add_property ("shown_editor", editor_shown ? "yes": "no");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2007-06-27 20:23:48 +00:00
|
|
|
ProcessorAutomationTimeAxisView::set_automation_state (AutoState state)
|
2005-09-25 18:42:24 +00:00
|
|
|
{
|
|
|
|
|
if (!ignore_state_request) {
|
2007-06-29 04:02:58 +00:00
|
|
|
_processor.control (_param, true)->list()->set_automation_state (state);
|
2005-09-25 18:42:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-06-27 20:23:48 +00:00
|
|
|
|
2007-06-29 04:02:58 +00:00
|
|
|
void
|
|
|
|
|
ProcessorAutomationTimeAxisView::add_line (AutomationLine& line)
|
|
|
|
|
{
|
|
|
|
|
bool get = false;
|
|
|
|
|
|
|
|
|
|
if (lines.empty()) {
|
|
|
|
|
/* first line is the Model for automation state */
|
|
|
|
|
automation_connection = line.the_list()->automation_state_changed.connect
|
|
|
|
|
(mem_fun(*this, &ProcessorAutomationTimeAxisView::automation_state_changed));
|
|
|
|
|
get = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lines.push_back (std::make_pair(&line,
|
|
|
|
|
AutomationController::create(_session, line.the_list(),
|
|
|
|
|
_processor.control(line.the_list()->param_id()))));
|
|
|
|
|
|
|
|
|
|
line.set_y_position_and_height (0, height);
|
|
|
|
|
|
|
|
|
|
if (get) {
|
|
|
|
|
/* pick up the current state */
|
|
|
|
|
automation_state_changed ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
line.show();
|
|
|
|
|
}
|
|
|
|
|
|