diff options
author | Taybin Rutkin <taybin@taybin.com> | 2005-09-25 18:42:24 +0000 |
---|---|---|
committer | Taybin Rutkin <taybin@taybin.com> | 2005-09-25 18:42:24 +0000 |
commit | 209d967b1bb80a9735d690d8f4f0455ecb9970ca (patch) | |
tree | 9d76ddcd7c1ac9d91bb2b1a33d31b66ce4ded5de /gtk2_ardour/redirect_automation_time_axis.cc | |
parent | e4b9aed743fc765219ac775905a221c017c88fba (diff) |
Initial import of gtk2_ardour.
git-svn-id: svn://localhost/trunk/ardour2@24 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/redirect_automation_time_axis.cc')
-rw-r--r-- | gtk2_ardour/redirect_automation_time_axis.cc | 169 |
1 files changed, 169 insertions, 0 deletions
diff --git a/gtk2_ardour/redirect_automation_time_axis.cc b/gtk2_ardour/redirect_automation_time_axis.cc new file mode 100644 index 0000000000..5bbd7e290f --- /dev/null +++ b/gtk2_ardour/redirect_automation_time_axis.cc @@ -0,0 +1,169 @@ +/* + 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. + + $Id$ +*/ + +#include <ardour/redirect.h> +#include <ardour/session.h> +#include <cstdlib> + +#include "redirect_automation_time_axis.h" +#include "automation_line.h" + +#include "i18n.h" + +using namespace ARDOUR; +using namespace Gtk; + +RedirectAutomationTimeAxisView::RedirectAutomationTimeAxisView (Session& s, Route& r, PublicEditor& e, TimeAxisView& parent, Widget* p, std::string n, + uint32_t prt, Redirect& rd, string state_name) + + : AxisView (s), + AutomationTimeAxisView (s, r, e, parent, p, n, state_name, rd.name()), + redirect (rd), + port (prt) + +{ + char buf[32]; + xml_node = 0; + _marked_for_display = false; + + ensure_xml_node (); + + XMLNodeList kids; + XMLNodeConstIterator iter; + + kids = xml_node->children (); + + snprintf (buf, sizeof(buf), "Port_%" PRIu32, port); + + 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; + } + } +} + +RedirectAutomationTimeAxisView::~RedirectAutomationTimeAxisView () +{ +} + +void +RedirectAutomationTimeAxisView::add_automation_event (GtkCanvasItem* item, GdkEvent* event, jack_nframes_t when, double y) +{ + double x = 0; + + gtk_canvas_item_w2i (canvas_display, &x, &y); + + /* 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()) { + AutomationList& alist (redirect.automation_list(port)); + string description = _("add automation event to "); + description += redirect.describe_parameter (port); + + lines.front()->view_to_model_y (y); + + _session.begin_reversible_command (description); + _session.add_undo (alist.get_memento()); + alist.add (when, y); + _session.add_redo_no_execute (alist.get_memento()); + _session.commit_reversible_command (); + _session.set_dirty (); + } +} + +void +RedirectAutomationTimeAxisView::ensure_xml_node () +{ + if (xml_node == 0) { + if ((xml_node = redirect.extra_xml ("GUI")) == 0) { + xml_node = new XMLNode ("GUI"); + redirect.add_extra_xml (*xml_node); + } + } +} + +guint32 +RedirectAutomationTimeAxisView::show_at (double y, int& nth, Gtk::VBox *parent) +{ + ensure_xml_node (); + update_extra_xml_shown (true); + + return TimeAxisView::show_at (y, nth, parent); +} + +void +RedirectAutomationTimeAxisView::hide () +{ + ensure_xml_node (); + update_extra_xml_shown (false); + + TimeAxisView::hide (); +} + + +void +RedirectAutomationTimeAxisView::update_extra_xml_shown (bool editor_shown) +{ + char buf[32]; + + XMLNodeList nlist = xml_node->children (); + XMLNodeConstIterator i; + XMLNode * port_node = 0; + + snprintf (buf, sizeof(buf), "Port_%" PRIu32, port); + + for (i = nlist.begin(); i != nlist.end(); ++i) { + if ((*i)->name() == buf) { + port_node = (*i); + break; + } + } + + if (!port_node) { + port_node = new XMLNode(buf); + xml_node->add_child_nocopy(*port_node); + } + + port_node->add_property ("shown_editor", editor_shown ? "yes": "no"); + +} + +void +RedirectAutomationTimeAxisView::set_automation_state (AutoState state) +{ + if (!ignore_state_request) { + redirect.automation_list (port).set_automation_state (state); + } +} |