#include "ardour_ui.h"
#include "automation_time_axis.h"
+#include "route_time_axis.h"
#include "automation_line.h"
#include "public_editor.h"
#include "simplerect.h"
using namespace Gtkmm2ext;
using namespace Editing;
-Pango::FontDescription AutomationTimeAxisView::name_font;
+Pango::FontDescription* AutomationTimeAxisView::name_font = 0;
bool AutomationTimeAxisView::have_name_font = false;
+const string AutomationTimeAxisView::state_node_name = "AutomationChild";
AutomationTimeAxisView::AutomationTimeAxisView (Session& s, boost::shared_ptr<Route> r,
boost::shared_ptr<Automatable> a, boost::shared_ptr<AutomationControl> c,
PublicEditor& e, TimeAxisView& rent,
- ArdourCanvas::Canvas& canvas, const string & nom,
- const string & state_name, const string & nomparent)
+ ArdourCanvas::Canvas& canvas, const string & nom, const string & nomparent)
: AxisView (s),
TimeAxisView (s, e, &rent, canvas),
_route (r),
_control (c),
_automatable (a),
- _controller(AutomationController::create(s, c->list(), c)),
+ _controller(AutomationController::create(a, c->list(), c)),
_base_rect (0),
- _xml_node (0),
_name (nom),
- _state_name (state_name),
height_button (_("h")),
clear_button (_("clear")),
auto_button (X_("")) /* force addition of a label */
auto_touch_item = 0;
auto_write_item = 0;
auto_play_item = 0;
+ mode_discrete_item = 0;
+ mode_line_item = 0;
+
ignore_state_request = false;
first_call_to_set_height = true;
bool shortened = false;
int ignore_width;
- shortpname = fit_to_pixels (_name, 60, name_font, ignore_width, true);
+ shortpname = fit_to_pixels (_name, 60, *name_font, ignore_width, true);
if (shortpname != _name ){
shortened = true;
/* limit the plug name string */
- string pname = fit_to_pixels (nomparent, 60, name_font, ignore_width, true);
+ string pname = fit_to_pixels (nomparent, 60, *name_font, ignore_width, true);
if (pname != nomparent) {
shortened = true;
}
controls_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
- XMLNode* xml_node = get_parent_with_state()->get_child_xml_node (_state_name);
+ XMLNode* xml_node = get_parent_with_state()->get_automation_child_xml_node (
+ _control->parameter());
if (xml_node) {
set_state (*xml_node);
}
boost::shared_ptr<AutomationLine> line(new AutomationLine (
- _control->list()->param_id().to_string(),
+ _control->parameter().to_string(),
*this,
*canvas_display,
_control->list()));
if (!ignore_state_request) {
if (_route == _automatable) { // FIXME: ew
_route->set_parameter_automation_state (
- _control->list()->param_id(),
+ _control->parameter(),
state);
}
}
}
+void
+AutomationTimeAxisView::interpolation_changed ()
+{
+ AutomationList::InterpolationStyle style = _control->list()->interpolation();
+
+ if (mode_line_item && mode_discrete_item) {
+ if (style == AutomationList::Discrete) {
+ mode_discrete_item->set_active(true);
+ mode_line_item->set_active(false);
+ } else {
+ mode_line_item->set_active(true);
+ mode_discrete_item->set_active(false);
+ }
+ }
+
+ _line->set_interpolation(style);
+}
+
+void
+AutomationTimeAxisView::set_interpolation (AutomationList::InterpolationStyle style)
+{
+ _control->list()->set_interpolation(style);
+ _line->set_interpolation(style);
+}
+
void
AutomationTimeAxisView::height_clicked ()
{
AutomationTimeAxisView::set_height (TrackHeight ht)
{
uint32_t h = height_to_pixels (ht);
- bool changed = (height != (uint32_t) h);
-
- //bool changed_between_small_and_normal = ( (ht == Small || ht == Smaller) ^ (height_style == Small || height_style == Smaller) );
-
- TimeAxisView* state_parent = get_parent_with_state ();
- XMLNode* xml_node = state_parent->get_child_xml_node (_state_name);
+ bool changed = (height != (uint32_t) h) || first_call_to_set_height;
+
+ if (first_call_to_set_height)
+ first_call_to_set_height = false;
TimeAxisView::set_height (ht);
_base_rect->property_y2() = h;
(*i)->set_height ();
}
+ TimeAxisView* state_parent = get_parent_with_state ();
+ assert(state_parent);
+
+ XMLNode* xml_node = state_parent->get_automation_child_xml_node(_control->parameter());
+ assert(xml_node);
switch (ht) {
case Largest:
break;
}
- //if (changed_between_small_and_normal || first_call_to_set_height) {
- first_call_to_set_height = false;
- switch (ht) {
- case Normal:
+ switch (ht) {
+ case Large:
+ case Larger:
+ case Largest:
+ _controller->show ();
+
+ case Normal:
+ if (ht == Normal)
_controller->hide();
- controls_table.remove (name_hbox);
-
- if (plugname) {
- if (plugname_packed) {
- controls_table.remove (*plugname);
- plugname_packed = false;
- }
- controls_table.attach (*plugname, 1, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
- plugname_packed = true;
- controls_table.attach (name_hbox, 1, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
- } else {
- controls_table.attach (name_hbox, 1, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
- }
- hide_name_entry ();
- show_name_label ();
- name_hbox.show_all ();
-
- auto_button.show();
- height_button.show();
- clear_button.show();
- hide_button.show_all();
- break;
-
- case Large:
- case Larger:
- case Largest:
- _controller->show ();
- break;
+ controls_table.remove (name_hbox);
- case Smaller:
- _controller->hide();
-
- case Small:
-
- controls_table.remove (name_hbox);
- if (plugname) {
- if (plugname_packed) {
- controls_table.remove (*plugname);
- plugname_packed = false;
- }
+ if (plugname) {
+ if (plugname_packed) {
+ controls_table.remove (*plugname);
+ plugname_packed = false;
}
+ controls_table.attach (*plugname, 1, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
+ plugname_packed = true;
+ controls_table.attach (name_hbox, 1, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
+ } else {
controls_table.attach (name_hbox, 1, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
- controls_table.hide_all ();
- hide_name_entry ();
- show_name_label ();
- name_hbox.show_all ();
-
- auto_button.hide();
- height_button.hide();
- clear_button.hide();
- hide_button.hide();
- break;
- }
+ }
+ hide_name_entry ();
+ show_name_label ();
+ name_hbox.show_all ();
+
+ auto_button.show();
+ height_button.show();
+ clear_button.show();
+ hide_button.show_all();
+ break;
+
+ case Smaller:
+ _controller->hide();
- //}
+ case Small:
+
+ controls_table.remove (name_hbox);
+ if (plugname) {
+ if (plugname_packed) {
+ controls_table.remove (*plugname);
+ plugname_packed = false;
+ }
+ }
+ controls_table.attach (name_hbox, 1, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
+ controls_table.hide_all ();
+ hide_name_entry ();
+ show_name_label ();
+ name_hbox.show_all ();
+
+ auto_button.hide();
+ height_button.hide();
+ clear_button.hide();
+ hide_button.hide();
+ break;
+ }
if (changed) {
/* only emit the signal if the height really changed */
items.push_back (MenuElem (_("Clear"), mem_fun(*this, &AutomationTimeAxisView::clear_clicked)));
items.push_back (SeparatorElem());
+ /* state menu */
+
Menu* auto_state_menu = manage (new Menu);
auto_state_menu->set_name ("ArdourContextMenu");
MenuList& as_items = auto_state_menu->items();
auto_touch_item = dynamic_cast<CheckMenuItem*>(&as_items.back());
items.push_back (MenuElem (_("State"), *auto_state_menu));
+
+ /* mode menu */
+
+ if (_control->parameter().type() == MidiCCAutomation) {
+ Menu* auto_mode_menu = manage (new Menu);
+ auto_mode_menu->set_name ("ArdourContextMenu");
+ MenuList& am_items = auto_mode_menu->items();
+
+ RadioMenuItem::Group group;
+
+ am_items.push_back (RadioMenuElem (group, _("Discrete"), bind (
+ mem_fun(*this, &AutomationTimeAxisView::set_interpolation),
+ AutomationList::Discrete)));
+ mode_discrete_item = dynamic_cast<CheckMenuItem*>(&am_items.back());
+ //mode_discrete_item->set_active(_control->list()->interpolation() == AutomationList::Discrete);
+
+ am_items.push_back (RadioMenuElem (group, _("Line"), bind (
+ mem_fun(*this, &AutomationTimeAxisView::set_interpolation),
+ AutomationList::Linear)));
+ mode_line_item = dynamic_cast<CheckMenuItem*>(&am_items.back());
+ //mode_line_item->set_active(_control->list()->interpolation() == AutomationList::Linear);
+
+ items.push_back (MenuElem (_("Mode"), *auto_mode_menu));
+ }
/* make sure the automation menu state is correct */
automation_state_changed ();
+ interpolation_changed ();
}
void
line->show();
}
-void
-AutomationTimeAxisView::show_all_control_points ()
-{
- _line->show_all_control_points ();
-}
-
-void
-AutomationTimeAxisView::hide_all_but_selected_control_points ()
-{
- _line->hide_all_but_selected_control_points ();
-}
-
void
AutomationTimeAxisView::entered()
{
- show_all_control_points ();
+ _line->track_entered();
}
void
AutomationTimeAxisView::exited ()
{
- hide_all_but_selected_control_points ();
+ _line->track_exited();
}
void
kids = node.children ();
- //snprintf (buf, sizeof(buf), "Port_%" PRIu32, param.id());
-
for (iter = kids.begin(); iter != kids.end(); ++iter) {
- if ((*iter)->name() == _control->list()->param_id().to_string()) {
- XMLProperty *shown = (*iter)->property("shown_editor");
-
- if (shown && shown->value() == "yes") {
- set_marked_for_display(true);
- canvas_display->show(); /* FIXME: necessary? show_at? */
+ if ((*iter)->name() == state_node_name) {
+ XMLProperty* type = (*iter)->property("automation-id");
+
+ if (type && type->value() == _control->parameter().to_string()) {
+ XMLProperty *shown = (*iter)->property("shown_editor");
+
+ if (shown && shown->value() == "yes") {
+ set_marked_for_display(true);
+ canvas_display->show(); /* FIXME: necessary? show_at? */
+ }
+ break;
}
- break;
}
}
if (!_marked_for_display)
hide();
-
- // FIXME: _xml_node = &node?
}
XMLNode*
TimeAxisView* state_parent = get_parent_with_state ();
if (state_parent) {
- return state_parent->get_child_xml_node (_state_name);
+ return state_parent->get_automation_child_xml_node (_control->parameter());
} else {
return 0;
}
}
-void
-AutomationTimeAxisView::ensure_xml_node ()
-{
- if ((_automatable != _route) && _xml_node == 0) {
- if ((_xml_node = _automatable->extra_xml ("GUI")) == 0) {
- _xml_node = new XMLNode ("GUI");
- _automatable->add_extra_xml (*_xml_node);
- }
- }
-}
-
void
AutomationTimeAxisView::update_extra_xml_shown (bool editor_shown)
{
- if (_automatable == _route)
- return;
-
- char buf[32];
-
- ensure_xml_node ();
-
- XMLNodeList nlist = _xml_node->children ();
- XMLNodeConstIterator i;
- XMLNode * port_node = 0;
-
- /* FIXME: these parsed XML node names need to go */
- //snprintf (buf, sizeof(buf), "Port_%" PRIu32, _param.id());
-
- for (i = nlist.begin(); i != nlist.end(); ++i) {
- /* FIXME: legacy session loading */
- if ((*i)->name() == _control->list()->param_id().to_string()) {
- 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");
+ XMLNode* xml_node = get_state_node();
+ xml_node->add_property ("shown", editor_shown ? "yes" : "no");
}
guint32