2005-09-25 14:42:24 -04: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 16:23:48 -04:00
|
|
|
#include <ardour/processor.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <ardour/session.h>
|
|
|
|
#include <cstdlib>
|
2006-07-28 23:17:11 -04:00
|
|
|
#include <pbd/memento_command.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-06-27 16:23:48 -04:00
|
|
|
#include "processor_automation_time_axis.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "automation_line.h"
|
2005-11-15 21:57:22 -05:00
|
|
|
#include "canvas_impl.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace ARDOUR;
|
2006-06-22 19:40:55 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace Gtk;
|
|
|
|
|
2007-06-27 16:23:48 -04:00
|
|
|
ProcessorAutomationTimeAxisView::ProcessorAutomationTimeAxisView (Session& s, boost::shared_ptr<Route> r,
|
2006-08-03 22:18:45 -04:00
|
|
|
PublicEditor& e, TimeAxisView& parent, Canvas& canvas, std::string n,
|
2007-06-27 16:23:48 -04:00
|
|
|
ParamID param, Processor& proc, string state_name)
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
: AxisView (s),
|
2007-06-27 16:23:48 -04:00
|
|
|
AutomationTimeAxisView (s, r, e, parent, canvas, n, state_name, proc.name()),
|
|
|
|
_processor(proc),
|
|
|
|
_param (param)
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
{
|
|
|
|
char buf[32];
|
2007-06-27 16:23:48 -04:00
|
|
|
_xml_node = 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
_marked_for_display = false;
|
|
|
|
|
|
|
|
ensure_xml_node ();
|
|
|
|
|
|
|
|
XMLNodeList kids;
|
|
|
|
XMLNodeConstIterator iter;
|
|
|
|
|
2007-06-27 16:23:48 -04:00
|
|
|
kids = _xml_node->children ();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-06-27 11:51:50 -04:00
|
|
|
snprintf (buf, sizeof(buf), "Port_%" PRIu32, param.id());
|
2005-09-25 14:42:24 -04: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 16:23:48 -04:00
|
|
|
ProcessorAutomationTimeAxisView::~ProcessorAutomationTimeAxisView ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-06-27 16:23:48 -04:00
|
|
|
ProcessorAutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* item, GdkEvent* event, nframes_t when, double y)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
double x = 0;
|
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
canvas_display->w2i (x, y);
|
2005-09-25 14:42:24 -04: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-27 16:23:48 -04:00
|
|
|
AutomationList* alist (_processor.automation_list(_param, true));
|
2005-09-25 14:42:24 -04:00
|
|
|
string description = _("add automation event to ");
|
2007-06-27 16:23:48 -04:00
|
|
|
description += _processor.describe_parameter (_param);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
lines.front()->view_to_model_y (y);
|
|
|
|
|
|
|
|
_session.begin_reversible_command (description);
|
2007-06-27 11:51:50 -04: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 14:42:24 -04:00
|
|
|
_session.commit_reversible_command ();
|
|
|
|
_session.set_dirty ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-06-27 16:23:48 -04:00
|
|
|
ProcessorAutomationTimeAxisView::ensure_xml_node ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-06-27 16:23:48 -04: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 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
guint32
|
2007-06-27 16:23:48 -04:00
|
|
|
ProcessorAutomationTimeAxisView::show_at (double y, int& nth, Gtk::VBox *parent)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
ensure_xml_node ();
|
|
|
|
update_extra_xml_shown (true);
|
|
|
|
|
|
|
|
return TimeAxisView::show_at (y, nth, parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-06-27 16:23:48 -04:00
|
|
|
ProcessorAutomationTimeAxisView::hide ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
ensure_xml_node ();
|
|
|
|
update_extra_xml_shown (false);
|
|
|
|
|
|
|
|
TimeAxisView::hide ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2007-06-27 16:23:48 -04:00
|
|
|
ProcessorAutomationTimeAxisView::update_extra_xml_shown (bool editor_shown)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
char buf[32];
|
|
|
|
|
2007-06-27 16:23:48 -04:00
|
|
|
XMLNodeList nlist = _xml_node->children ();
|
2005-09-25 14:42:24 -04:00
|
|
|
XMLNodeConstIterator i;
|
|
|
|
XMLNode * port_node = 0;
|
|
|
|
|
2007-06-27 16:23:48 -04:00
|
|
|
snprintf (buf, sizeof(buf), "Port_%" PRIu32, _param.id());
|
2005-09-25 14:42:24 -04: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 16:23:48 -04:00
|
|
|
_xml_node->add_child_nocopy(*port_node);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
port_node->add_property ("shown_editor", editor_shown ? "yes": "no");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-06-27 16:23:48 -04:00
|
|
|
ProcessorAutomationTimeAxisView::set_automation_state (AutoState state)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (!ignore_state_request) {
|
2007-06-27 16:23:48 -04:00
|
|
|
_processor.automation_list (_param, true)->set_automation_state (state);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2007-06-27 16:23:48 -04:00
|
|
|
|