summaryrefslogtreecommitdiff
path: root/gtk2_ardour/automation_region_view.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-09-06 02:30:39 +0000
committerDavid Robillard <d@drobilla.net>2007-09-06 02:30:39 +0000
commitc190aca4a0debe1220558d14afb8f1ab4adb959f (patch)
tree1c2749473afe96f41cd99d1036533342db98a1ba /gtk2_ardour/automation_region_view.cc
parent7423ad46a742fbfd03ee4e54e78167c9006a2e8d (diff)
Deep "automation regions" support.
Fix zoom/height/etc changing for automation region views. Broke smooth automation region dragging (make omelette, break eggs, etc). git-svn-id: svn://localhost/ardour2/trunk@2424 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/automation_region_view.cc')
-rw-r--r--gtk2_ardour/automation_region_view.cc84
1 files changed, 81 insertions, 3 deletions
diff --git a/gtk2_ardour/automation_region_view.cc b/gtk2_ardour/automation_region_view.cc
index 51650e94ae..539ff233ef 100644
--- a/gtk2_ardour/automation_region_view.cc
+++ b/gtk2_ardour/automation_region_view.cc
@@ -17,7 +17,11 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <pbd/memento_command.h>
#include "automation_region_view.h"
+#include "public_editor.h"
+
+#include "i18n.h"
AutomationRegionView::AutomationRegionView(ArdourCanvas::Group* parent,
AutomationTimeAxisView& time_axis,
@@ -32,20 +36,73 @@ AutomationRegionView::AutomationRegionView(ArdourCanvas::Group*
_line.show();
_line.show_all_control_points();
- group->raise_to_top ();
+ //group->raise_to_top ();
group->signal_event().connect (mem_fun (this, &AutomationRegionView::canvas_event), false);
}
+void
+AutomationRegionView::init (Gdk::Color& basic_color, bool wfd)
+{
+ _enable_display = false;
+
+ RegionView::init(basic_color, false);
+
+ compute_colors (basic_color);
+
+ reset_width_dependent_items ((double) _region->length() / samples_per_unit);
+
+ set_y_position_and_height (0, trackview.height);
+
+ _region->StateChanged.connect (mem_fun(*this, &AutomationRegionView::region_changed));
+
+ set_colors ();
+
+ _enable_display = true;
+}
bool
AutomationRegionView::canvas_event(GdkEvent* ev)
{
- cerr << "AUTOMATION EVENT" << endl;
+ if (ev->type == GDK_BUTTON_RELEASE) {
+
+ const nframes_t when = trackview.editor.pixel_to_frame((nframes_t)ev->button.x)
+ - _region->position();
+ add_automation_event(ev, when, ev->button.y);
+ }
return false;
}
+void
+AutomationRegionView::add_automation_event (GdkEvent* event, nframes_t when, double y)
+{
+ double x = 0;
+ AutomationTimeAxisView* const view = automation_view();
+
+ view->canvas_display->w2i (x, y);
+
+ /* compute vertical fractional position */
+
+ const double height = trackview.height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 2;
+ y = 1.0 - (y / height);
+
+ /* map using line */
+
+ _line.view_to_model_y (y);
+
+ view->session().begin_reversible_command (_("add automation event"));
+ XMLNode& before = _line.the_list()->get_state();
+
+ _line.the_list()->add (when, y);
+
+ XMLNode& after = _line.the_list()->get_state();
+ view->session().commit_reversible_command (new MementoCommand<ARDOUR::AutomationList>(
+ *_line.the_list(), &before, &after));
+
+ view->session().set_dirty ();
+}
+
void
AutomationRegionView::set_y_position_and_height (double y, double h)
@@ -55,10 +112,31 @@ AutomationRegionView::set_y_position_and_height (double y, double h)
_line.set_y_position_and_height ((uint32_t)y, (uint32_t) rint (h - NAME_HIGHLIGHT_SIZE));
}
+bool
+AutomationRegionView::set_position (nframes_t pos, void* src, double* ignored)
+{
+ // Do nothing, region parent will move us
+ //return false;
+
+ return RegionView::set_position(pos, src, ignored); // FIXME: eventually...
+}
+
+
+void
+AutomationRegionView::reset_width_dependent_items (double pixel_width)
+{
+ RegionView::reset_width_dependent_items(pixel_width);
+
+ _line.reset();
+}
+
+
void
AutomationRegionView::region_resized (ARDOUR::Change what_changed)
{
- // Do nothing, parent will move us
+ RegionView::region_resized(what_changed);
+
+ _line.reset();
}