summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-11-09 01:58:12 +0000
committerCarl Hetherington <carl@carlh.net>2010-11-09 01:58:12 +0000
commitc246926e4148e9996060bd6865ff03a962ddab2e (patch)
tree5c83a90892aacbdce751d60674ad890e5c512bdc
parent8167262ca20d937e7e7cc828c8da47d963699b10 (diff)
Move some methods out of Editor into RegionView.
git-svn-id: svn://localhost/ardour2/branches/3.0@7981 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/audio_region_view.cc8
-rw-r--r--gtk2_ardour/audio_region_view.h2
-rw-r--r--gtk2_ardour/editor.h5
-rw-r--r--gtk2_ardour/editor_drag.cc10
-rw-r--r--gtk2_ardour/editor_mouse.cc145
-rw-r--r--gtk2_ardour/region_view.cc113
-rw-r--r--gtk2_ardour/region_view.h5
7 files changed, 133 insertions, 155 deletions
diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc
index 24a33893db..eceb9ab83d 100644
--- a/gtk2_ardour/audio_region_view.cc
+++ b/gtk2_ardour/audio_region_view.cc
@@ -1522,3 +1522,11 @@ AudioRegionView::remove_transient(float pos)
}
}
}
+
+void
+AudioRegionView::thaw_after_trim ()
+{
+ RegionView::thaw_after_trim ();
+
+ unhide_envelope ();
+}
diff --git a/gtk2_ardour/audio_region_view.h b/gtk2_ardour/audio_region_view.h
index 8673b6901d..3a35f40c7d 100644
--- a/gtk2_ardour/audio_region_view.h
+++ b/gtk2_ardour/audio_region_view.h
@@ -117,6 +117,8 @@ class AudioRegionView : public RegionView
virtual void entered (bool);
virtual void exited ();
+ void thaw_after_trim ();
+
protected:
/* this constructor allows derived types
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index d9b1d4a8fa..fb23a811e3 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -1706,11 +1706,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
/* trimming */
void point_trim (GdkEvent *, framepos_t);
- void single_contents_trim (RegionView&, framepos_t, bool, bool);
- void single_start_trim (RegionView&, framepos_t, bool);
- void single_end_trim (RegionView&, framepos_t, bool);
-
- void thaw_region_after_trim (RegionView& rv);
void trim_region_front();
void trim_region_back();
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index eb34787408..f9a9283d1b 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -1633,13 +1633,13 @@ TrimDrag::motion (GdkEvent* event, bool first_move)
switch (_operation) {
case StartTrim:
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
- _editor->single_start_trim (*i->view, pf, non_overlap_trim);
+ i->view->trim_start (pf, non_overlap_trim);
}
break;
case EndTrim:
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
- _editor->single_end_trim (*i->view, pf, non_overlap_trim);
+ i->view->trim_end (pf, non_overlap_trim);
}
break;
@@ -1665,7 +1665,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move)
}
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
- _editor->single_contents_trim (*i->view, frame_delta, left_direction, swap_direction);
+ i->view->trim_contents (frame_delta, left_direction, swap_direction);
}
}
break;
@@ -1692,11 +1692,11 @@ TrimDrag::finished (GdkEvent* event, bool movement_occurred)
motion (event, false);
if (!_editor->selection->selected (_primary)) {
- _editor->thaw_region_after_trim (*_primary);
+ _primary->thaw_after_trim ();
} else {
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
- _editor->thaw_region_after_trim (*i->view);
+ i->view->thaw_after_trim ();
i->view->enable_display (true);
i->view->fake_set_opaque (true);
if (_have_transaction) {
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc
index f2d49fa1d7..8e5db51948 100644
--- a/gtk2_ardour/editor_mouse.cc
+++ b/gtk2_ardour/editor_mouse.cc
@@ -2311,133 +2311,6 @@ Editor::cancel_selection ()
void
-Editor::single_contents_trim (RegionView& rv, framepos_t frame_delta, bool left_direction, bool swap_direction)
-{
- boost::shared_ptr<Region> region (rv.region());
-
- if (region->locked()) {
- return;
- }
-
- framepos_t new_bound;
-
- double speed = 1.0;
- TimeAxisView* tvp = clicked_axisview;
- RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*>(tvp);
-
- if (tv && tv->is_track()) {
- speed = tv->track()->speed();
- }
-
- if (left_direction) {
- if (swap_direction) {
- new_bound = (framepos_t) (region->position()/speed) + frame_delta;
- } else {
- new_bound = (framepos_t) (region->position()/speed) - frame_delta;
- }
- } else {
- if (swap_direction) {
- new_bound = (framepos_t) (region->position()/speed) - frame_delta;
- } else {
- new_bound = (framepos_t) (region->position()/speed) + frame_delta;
- }
- }
-
- region->trim_start ((framepos_t) (new_bound * speed), this);
- rv.region_changed (PropertyChange (ARDOUR::Properties::start));
-}
-
-void
-Editor::single_start_trim (RegionView& rv, framepos_t new_bound, bool no_overlap)
-{
- boost::shared_ptr<Region> region (rv.region());
-
- if (region->locked()) {
- return;
- }
-
- double speed = 1.0;
- TimeAxisView* tvp = clicked_axisview;
- RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*>(tvp);
-
- if (tv && tv->is_track()) {
- speed = tv->track()->speed();
- }
-
- framepos_t pre_trim_first_frame = region->first_frame();
-
- region->trim_front ((framepos_t) (new_bound * speed), this);
-
- if (no_overlap) {
- //Get the next region on the left of this region and shrink/expand it.
- boost::shared_ptr<Playlist> playlist (region->playlist());
- boost::shared_ptr<Region> region_left = playlist->find_next_region (pre_trim_first_frame, End, 0);
-
- bool regions_touching = false;
-
- if (region_left != 0 && (pre_trim_first_frame == region_left->last_frame() + 1)){
- regions_touching = true;
- }
-
- //Only trim region on the left if the first frame has gone beyond the left region's last frame.
- if (region_left != 0 &&
- (region_left->last_frame() > region->first_frame() || regions_touching))
- {
- region_left->trim_end(region->first_frame() - 1, this);
- }
- }
-
- rv.region_changed (ARDOUR::bounds_change);
-}
-
-void
-Editor::single_end_trim (RegionView& rv, framepos_t new_bound, bool no_overlap)
-{
- boost::shared_ptr<Region> region (rv.region());
-
- if (region->locked()) {
- return;
- }
-
- double speed = 1.0;
- TimeAxisView* tvp = clicked_axisview;
- RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*>(tvp);
-
- if (tv && tv->is_track()) {
- speed = tv->track()->speed();
- }
-
- framepos_t pre_trim_last_frame = region->last_frame();
-
- region->trim_end ((framepos_t) (new_bound * speed), this);
-
- if (no_overlap) {
- //Get the next region on the right of this region and shrink/expand it.
- boost::shared_ptr<Playlist> playlist (region->playlist());
- boost::shared_ptr<Region> region_right = playlist->find_next_region (pre_trim_last_frame, Start, 1);
-
- bool regions_touching = false;
-
- if (region_right != 0 && (pre_trim_last_frame == region_right->first_frame() - 1)) {
- regions_touching = true;
- }
-
- //Only trim region on the right if the last frame has gone beyond the right region's first frame.
- if (region_right != 0 &&
- (region_right->first_frame() < region->last_frame() || regions_touching))
- {
- region_right->trim_front(region->last_frame() + 1, this);
- }
-
- rv.region_changed (ARDOUR::bounds_change);
-
- } else {
- rv.region_changed (PropertyChange (ARDOUR::Properties::length));
- }
-}
-
-
-void
Editor::point_trim (GdkEvent* event, framepos_t new_bound)
{
RegionView* rv = clicked_regionview;
@@ -2505,24 +2378,6 @@ Editor::point_trim (GdkEvent* event, framepos_t new_bound)
}
void
-Editor::thaw_region_after_trim (RegionView& rv)
-{
- boost::shared_ptr<Region> region (rv.region());
-
- if (region->locked()) {
- return;
- }
-
- region->resume_property_changes ();
-
- AudioRegionView* arv = dynamic_cast<AudioRegionView*>(&rv);
-
- if (arv) {
- arv->unhide_envelope ();
- }
-}
-
-void
Editor::hide_marker (ArdourCanvas::Item* item, GdkEvent* /*event*/)
{
Marker* marker;
diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc
index c3518ca61a..755281a119 100644
--- a/gtk2_ardour/region_view.cc
+++ b/gtk2_ardour/region_view.cc
@@ -682,3 +682,116 @@ RegionView::update_coverage_frames (LayerDisplay d)
frame_handle_end->raise_to_top ();
}
}
+
+void
+RegionView::trim_start (framepos_t new_bound, bool no_overlap)
+{
+ if (_region->locked()) {
+ return;
+ }
+
+ RouteTimeAxisView& rtv = dynamic_cast<RouteTimeAxisView&> (trackview);
+ double const speed = rtv.track()->speed ();
+
+ framepos_t const pre_trim_first_frame = _region->first_frame();
+
+ _region->trim_front ((framepos_t) (new_bound * speed), this);
+
+ if (no_overlap) {
+ // Get the next region on the left of this region and shrink/expand it.
+ boost::shared_ptr<Playlist> playlist (_region->playlist());
+ boost::shared_ptr<Region> region_left = playlist->find_next_region (pre_trim_first_frame, End, 0);
+
+ bool regions_touching = false;
+
+ if (region_left != 0 && (pre_trim_first_frame == region_left->last_frame() + 1)) {
+ regions_touching = true;
+ }
+
+ // Only trim region on the left if the first frame has gone beyond the left region's last frame.
+ if (region_left != 0 && (region_left->last_frame() > _region->first_frame() || regions_touching)) {
+ region_left->trim_end (_region->first_frame() - 1, this);
+ }
+ }
+
+ region_changed (ARDOUR::bounds_change);
+}
+
+void
+RegionView::trim_end (framepos_t new_bound, bool no_overlap)
+{
+ if (_region->locked()) {
+ return;
+ }
+
+ RouteTimeAxisView& rtv = dynamic_cast<RouteTimeAxisView&> (trackview);
+ double const speed = rtv.track()->speed ();
+
+ framepos_t const pre_trim_last_frame = _region->last_frame();
+
+ _region->trim_end ((framepos_t) (new_bound * speed), this);
+
+ if (no_overlap) {
+ // Get the next region on the right of this region and shrink/expand it.
+ boost::shared_ptr<Playlist> playlist (_region->playlist());
+ boost::shared_ptr<Region> region_right = playlist->find_next_region (pre_trim_last_frame, Start, 1);
+
+ bool regions_touching = false;
+
+ if (region_right != 0 && (pre_trim_last_frame == region_right->first_frame() - 1)) {
+ regions_touching = true;
+ }
+
+ // Only trim region on the right if the last frame has gone beyond the right region's first frame.
+ if (region_right != 0 && (region_right->first_frame() < _region->last_frame() || regions_touching)) {
+ region_right->trim_front (_region->last_frame() + 1, this);
+ }
+
+ region_changed (ARDOUR::bounds_change);
+
+ } else {
+ region_changed (PropertyChange (ARDOUR::Properties::length));
+ }
+}
+
+
+void
+RegionView::thaw_after_trim ()
+{
+ if (_region->locked()) {
+ return;
+ }
+
+ _region->resume_property_changes ();
+}
+
+
+void
+RegionView::trim_contents (framepos_t frame_delta, bool left_direction, bool swap_direction)
+{
+ if (_region->locked()) {
+ return;
+ }
+
+ framepos_t new_bound;
+
+ RouteTimeAxisView& rtv = dynamic_cast<RouteTimeAxisView&> (trackview);
+ double const speed = rtv.track()->speed ();
+
+ if (left_direction) {
+ if (swap_direction) {
+ new_bound = (framepos_t) (_region->position() / speed) + frame_delta;
+ } else {
+ new_bound = (framepos_t) (_region->position() / speed) - frame_delta;
+ }
+ } else {
+ if (swap_direction) {
+ new_bound = (framepos_t) (_region->position() / speed) - frame_delta;
+ } else {
+ new_bound = (framepos_t) (_region->position() / speed) + frame_delta;
+ }
+ }
+
+ _region->trim_start ((framepos_t) (new_bound * speed), this);
+ region_changed (PropertyChange (ARDOUR::Properties::start));
+}
diff --git a/gtk2_ardour/region_view.h b/gtk2_ardour/region_view.h
index c65b81bc7b..1e8c09bdba 100644
--- a/gtk2_ardour/region_view.h
+++ b/gtk2_ardour/region_view.h
@@ -96,6 +96,11 @@ class RegionView : public TimeAxisViewItem
return _time_converter;
}
+ void trim_start (framepos_t, bool);
+ void trim_end (framepos_t, bool);
+ void trim_contents (framepos_t, bool, bool);
+ virtual void thaw_after_trim ();
+
protected:
/** Allows derived types to specify their visibility requirements