diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-07-06 11:33:27 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-07-06 11:33:27 +0000 |
commit | 2f9184d65395da75a43ea21ffb5f11b8d577d27a (patch) | |
tree | a50a5d5a4bd8b09ca9bd1f3bb6754b7bf86cd3c5 /gtk2_ardour/editor_drag.cc | |
parent | 2f11b367cac5fe05f5f69e2c73946312d8145260 (diff) |
beat slicing patch #1 from lincoln spiteri
git-svn-id: svn://localhost/ardour2/branches/3.0@7381 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/editor_drag.cc')
-rw-r--r-- | gtk2_ardour/editor_drag.cc | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index b01c79ad91..2aaeaa1038 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -2935,6 +2935,76 @@ LineDrag::aborted () _line->reset (); } +FeatureLineDrag::FeatureLineDrag (Editor* e, ArdourCanvas::Item* i) + : Drag (e, i), + _line (0), + _cumulative_x_drag (0) +{ + +} +void +FeatureLineDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/) +{ + + Drag::start_grab (event); + + _line = reinterpret_cast<SimpleLine*> (_item); + assert (_line); + + /* need to get x coordinate in terms of parent (AudioRegionView) origin. */ + + double cx = event->button.x; + double cy = event->button.y; + + _item->property_parent().get_value()->w2i(cx, cy); + + /* store grab start in parent frame */ + _region_view_grab_x = cx; + + _before = _line->property_x1(); + + _arv = reinterpret_cast<AudioRegionView*> (_item->get_data ("regionview")); + + _max_x = _editor->frame_to_pixel(_arv->get_duration()); +} + +void +FeatureLineDrag::motion (GdkEvent* event, bool) +{ + double dx = _drags->current_pointer_x() - last_pointer_x(); + + double cx = _region_view_grab_x + _cumulative_x_drag + dx; + + _cumulative_x_drag += dx; + + /* Clamp the min and max extent of the drag to keep it within the region view bounds */ + + if (cx > _max_x){ + cx = _max_x; + } + else if(cx < 0){ + cx = 0; + } + + _line->property_x1() = cx; + _line->property_x2() = cx; + + _before = _line->property_x1(); +} + +void +FeatureLineDrag::finished (GdkEvent* event, bool) +{ + _arv = reinterpret_cast<AudioRegionView*> (_item->get_data ("regionview")); + _arv->update_transient(_before, _line->property_x1()); +} + +void +FeatureLineDrag::aborted () +{ + //_line->reset (); +} + void RubberbandSelectDrag::start_grab (GdkEvent* event, Gdk::Cursor *) { |