Move some methods out of Editor into RegionView.
git-svn-id: svn://localhost/ardour2/branches/3.0@7981 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
8167262ca2
commit
c246926e41
@ -1522,3 +1522,11 @@ AudioRegionView::remove_transient(float pos)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AudioRegionView::thaw_after_trim ()
|
||||
{
|
||||
RegionView::thaw_after_trim ();
|
||||
|
||||
unhide_envelope ();
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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) {
|
||||
|
@ -2310,133 +2310,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)
|
||||
{
|
||||
@ -2504,24 +2377,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*/)
|
||||
{
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user