2006-07-23 08:03:19 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2001-2006 Paul Davis
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
This program is free software; you can r>edistribute it and/or modify
|
2006-07-23 08:03:19 -04:00
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cmath>
|
2006-07-29 23:25:38 -04:00
|
|
|
#include <cassert>
|
2006-07-23 08:03:19 -04:00
|
|
|
#include <algorithm>
|
2013-10-03 04:12:02 -04:00
|
|
|
#include <vector>
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2012-10-26 20:14:08 -04:00
|
|
|
#include <boost/scoped_array.hpp>
|
2012-04-30 23:22:04 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
#include <gtkmm.h>
|
|
|
|
|
|
|
|
#include <gtkmm2ext/gtk_ui.h>
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/playlist.h"
|
|
|
|
#include "ardour/audioregion.h"
|
|
|
|
#include "ardour/audiosource.h"
|
|
|
|
#include "ardour/profile.h"
|
2009-10-30 11:30:22 -04:00
|
|
|
#include "ardour/session.h"
|
2007-10-11 18:07:47 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/memento_command.h"
|
|
|
|
#include "pbd/stacktrace.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "evoral/Curve.hpp"
|
2009-02-19 14:42:25 -05:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "canvas/rectangle.h"
|
|
|
|
#include "canvas/polygon.h"
|
2013-04-04 18:45:27 -04:00
|
|
|
#include "canvas/poly_line.h"
|
2013-04-11 22:54:12 -04:00
|
|
|
#include "canvas/line.h"
|
2013-04-15 13:50:05 -04:00
|
|
|
#include "canvas/text.h"
|
2014-05-28 21:10:22 -04:00
|
|
|
#include "canvas/xfade_curve.h"
|
2013-04-24 15:42:14 -04:00
|
|
|
#include "canvas/debug.h"
|
2013-06-20 23:11:40 -04:00
|
|
|
#include "canvas/utils.h"
|
2014-11-07 14:24:27 -05:00
|
|
|
#include "canvas/colors.h"
|
2013-04-04 00:32:52 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "streamview.h"
|
2006-08-01 13:19:38 -04:00
|
|
|
#include "audio_region_view.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "audio_time_axis.h"
|
2016-08-30 08:29:58 -04:00
|
|
|
#include "enums_convert.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "public_editor.h"
|
|
|
|
#include "audio_region_editor.h"
|
2012-05-10 09:48:23 -04:00
|
|
|
#include "audio_streamview.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "region_gain_line.h"
|
2007-07-06 23:19:04 -04:00
|
|
|
#include "control_point.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "ghostregion.h"
|
|
|
|
#include "audio_time_axis.h"
|
|
|
|
#include "rgb_macros.h"
|
|
|
|
#include "gui_thread.h"
|
2015-01-02 09:44:54 -05:00
|
|
|
#include "ui_config.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2014-01-26 16:03:04 -05:00
|
|
|
#define MUTED_ALPHA 48
|
2007-06-15 18:08:27 -04:00
|
|
|
|
2009-05-12 13:03:42 -04:00
|
|
|
using namespace std;
|
2006-07-23 08:03:19 -04:00
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
|
|
|
using namespace Editing;
|
|
|
|
using namespace ArdourCanvas;
|
|
|
|
|
2014-05-27 10:28:28 -04:00
|
|
|
static double const handle_size = 10; /* height of fade handles */
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2015-09-14 18:19:02 -04:00
|
|
|
Cairo::RefPtr<Cairo::Pattern> AudioRegionView::pending_peak_pattern;
|
|
|
|
|
2015-09-14 20:28:24 -04:00
|
|
|
static Cairo::RefPtr<Cairo::Pattern> create_pending_peak_pattern() {
|
|
|
|
cairo_surface_t * is = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 8, 8);
|
|
|
|
|
|
|
|
// create checker pattern
|
|
|
|
unsigned char *img = cairo_image_surface_get_data (is);
|
|
|
|
cairo_surface_flush (is);
|
|
|
|
const int stride = cairo_image_surface_get_stride (is);
|
|
|
|
|
|
|
|
for (int y = 0; y < 8; ++y) {
|
|
|
|
for (int x = 0; x < 8; ++x) {
|
|
|
|
const int off = (y * stride + x * 4);
|
|
|
|
uint32_t *pixel = (uint32_t*) &img[off];
|
|
|
|
if ((x < 4) ^ (y < 4)) {
|
|
|
|
*pixel = 0xa0000000;
|
|
|
|
} else {
|
|
|
|
*pixel = 0x40000000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cairo_surface_mark_dirty (is);
|
|
|
|
|
|
|
|
cairo_pattern_t* pat = cairo_pattern_create_for_surface (is);
|
|
|
|
cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT);
|
|
|
|
Cairo::RefPtr<Cairo::Pattern> p (new Cairo::Pattern (pat, false));
|
|
|
|
cairo_surface_destroy (is);
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2014-06-22 11:41:05 -04:00
|
|
|
AudioRegionView::AudioRegionView (ArdourCanvas::Container *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
|
2014-06-09 23:28:32 -04:00
|
|
|
uint32_t basic_color)
|
2006-07-23 08:03:19 -04:00
|
|
|
: RegionView (parent, tv, r, spu, basic_color)
|
2006-08-01 15:18:12 -04:00
|
|
|
, sync_mark(0)
|
|
|
|
, fade_in_handle(0)
|
|
|
|
, fade_out_handle(0)
|
2014-05-30 21:53:59 -04:00
|
|
|
, fade_in_trim_handle(0)
|
|
|
|
, fade_out_trim_handle(0)
|
2015-09-14 18:19:02 -04:00
|
|
|
, pending_peak_data(0)
|
2014-05-28 21:10:22 -04:00
|
|
|
, start_xfade_curve (0)
|
2012-04-30 23:22:04 -04:00
|
|
|
, start_xfade_rect (0)
|
2012-07-04 17:09:32 -04:00
|
|
|
, _start_xfade_visible (false)
|
2014-05-28 21:10:22 -04:00
|
|
|
, end_xfade_curve (0)
|
2012-04-30 23:22:04 -04:00
|
|
|
, end_xfade_rect (0)
|
2012-07-04 17:09:32 -04:00
|
|
|
, _end_xfade_visible (false)
|
2006-08-01 15:18:12 -04:00
|
|
|
, _amplitude_above_axis(1.0)
|
2014-05-31 09:18:43 -04:00
|
|
|
, trim_fade_in_drag_active(false)
|
|
|
|
, trim_fade_out_drag_active(false)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2015-01-02 09:44:54 -05:00
|
|
|
UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &AudioRegionView::parameter_changed));
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
2014-06-22 11:41:05 -04:00
|
|
|
AudioRegionView::AudioRegionView (ArdourCanvas::Container *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
|
2014-06-09 23:28:32 -04:00
|
|
|
uint32_t basic_color, bool recording, TimeAxisViewItem::Visibility visibility)
|
2008-09-10 11:03:30 -04:00
|
|
|
: RegionView (parent, tv, r, spu, basic_color, recording, visibility)
|
2006-08-01 15:18:12 -04:00
|
|
|
, sync_mark(0)
|
|
|
|
, fade_in_handle(0)
|
|
|
|
, fade_out_handle(0)
|
2014-05-30 21:53:59 -04:00
|
|
|
, fade_in_trim_handle(0)
|
|
|
|
, fade_out_trim_handle(0)
|
2015-09-14 18:19:02 -04:00
|
|
|
, pending_peak_data(0)
|
2014-05-28 21:10:22 -04:00
|
|
|
, start_xfade_curve (0)
|
2012-04-30 23:22:04 -04:00
|
|
|
, start_xfade_rect (0)
|
2012-07-04 17:09:32 -04:00
|
|
|
, _start_xfade_visible (false)
|
2014-05-28 21:10:22 -04:00
|
|
|
, end_xfade_curve (0)
|
2012-04-30 23:22:04 -04:00
|
|
|
, end_xfade_rect (0)
|
2012-07-04 17:09:32 -04:00
|
|
|
, _end_xfade_visible (false)
|
2006-08-01 15:18:12 -04:00
|
|
|
, _amplitude_above_axis(1.0)
|
2014-05-31 09:18:43 -04:00
|
|
|
, trim_fade_in_drag_active(false)
|
|
|
|
, trim_fade_out_drag_active(false)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2015-01-02 09:44:54 -05:00
|
|
|
UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &AudioRegionView::parameter_changed));
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
AudioRegionView::AudioRegionView (const AudioRegionView& other, boost::shared_ptr<AudioRegion> other_region)
|
|
|
|
: RegionView (other, boost::shared_ptr<Region> (other_region))
|
|
|
|
, fade_in_handle(0)
|
|
|
|
, fade_out_handle(0)
|
2014-05-30 21:53:59 -04:00
|
|
|
, fade_in_trim_handle(0)
|
|
|
|
, fade_out_trim_handle(0)
|
2015-09-14 18:19:02 -04:00
|
|
|
, pending_peak_data(0)
|
2014-05-28 21:10:22 -04:00
|
|
|
, start_xfade_curve (0)
|
2012-04-30 23:22:04 -04:00
|
|
|
, start_xfade_rect (0)
|
2012-07-04 17:09:32 -04:00
|
|
|
, _start_xfade_visible (false)
|
2014-05-28 21:10:22 -04:00
|
|
|
, end_xfade_curve (0)
|
2012-04-30 23:22:04 -04:00
|
|
|
, end_xfade_rect (0)
|
2012-07-04 17:09:32 -04:00
|
|
|
, _end_xfade_visible (false)
|
2011-05-16 19:10:58 -04:00
|
|
|
, _amplitude_above_axis (other._amplitude_above_axis)
|
2014-05-31 09:18:43 -04:00
|
|
|
, trim_fade_in_drag_active(false)
|
|
|
|
, trim_fade_out_drag_active(false)
|
2008-04-11 10:06:50 -04:00
|
|
|
{
|
2014-06-09 23:28:32 -04:00
|
|
|
init (true);
|
2012-06-17 07:48:51 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &AudioRegionView::parameter_changed));
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
void
|
2014-06-09 23:28:32 -04:00
|
|
|
AudioRegionView::init (bool wfd)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2006-07-29 23:25:38 -04:00
|
|
|
// FIXME: Some redundancy here with RegionView::init. Need to figure out
|
|
|
|
// where order is important and where it isn't...
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2015-09-14 18:19:02 -04:00
|
|
|
if (!pending_peak_pattern) {
|
2015-09-14 20:28:24 -04:00
|
|
|
pending_peak_pattern = create_pending_peak_pattern();
|
2015-09-14 18:19:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// needs to be created first, RegionView::init() calls set_height()
|
|
|
|
pending_peak_data = new ArdourCanvas::Rectangle (group);
|
|
|
|
CANVAS_DEBUG_NAME (pending_peak_data, string_compose ("pending peak rectangle for %1", region()->name()));
|
|
|
|
pending_peak_data->set_outline_color (ArdourCanvas::rgba_to_color (0, 0, 0, 0.0));
|
|
|
|
pending_peak_data->set_pattern (pending_peak_pattern);
|
|
|
|
pending_peak_data->set_data ("regionview", this);
|
|
|
|
pending_peak_data->hide ();
|
|
|
|
|
2014-06-09 23:28:32 -04:00
|
|
|
RegionView::init (wfd);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
_amplitude_above_axis = 1.0;
|
|
|
|
|
|
|
|
create_waves ();
|
|
|
|
|
2010-07-19 19:26:10 -04:00
|
|
|
if (!_recregion) {
|
2013-04-04 00:32:52 -04:00
|
|
|
fade_in_handle = new ArdourCanvas::Rectangle (group);
|
2013-04-24 15:42:14 -04:00
|
|
|
CANVAS_DEBUG_NAME (fade_in_handle, string_compose ("fade in handle for %1", region()->name()));
|
2014-06-09 23:39:07 -04:00
|
|
|
fade_in_handle->set_outline_color (ArdourCanvas::rgba_to_color (0, 0, 0, 1.0));
|
2015-01-02 09:44:54 -05:00
|
|
|
fade_in_handle->set_fill_color (UIConfiguration::instance().color ("inactive fade handle"));
|
2006-07-23 08:03:19 -04:00
|
|
|
fade_in_handle->set_data ("regionview", this);
|
2013-10-30 23:36:30 -04:00
|
|
|
fade_in_handle->hide ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
fade_out_handle = new ArdourCanvas::Rectangle (group);
|
2013-04-24 15:42:14 -04:00
|
|
|
CANVAS_DEBUG_NAME (fade_out_handle, string_compose ("fade out handle for %1", region()->name()));
|
2014-06-09 23:39:07 -04:00
|
|
|
fade_out_handle->set_outline_color (ArdourCanvas::rgba_to_color (0, 0, 0, 1.0));
|
2015-01-02 09:44:54 -05:00
|
|
|
fade_out_handle->set_fill_color (UIConfiguration::instance().color ("inactive fade handle"));
|
2006-07-23 08:03:19 -04:00
|
|
|
fade_out_handle->set_data ("regionview", this);
|
2013-10-30 23:36:30 -04:00
|
|
|
fade_out_handle->hide ();
|
2014-05-30 21:53:59 -04:00
|
|
|
|
|
|
|
fade_in_trim_handle = new ArdourCanvas::Rectangle (group);
|
|
|
|
CANVAS_DEBUG_NAME (fade_in_handle, string_compose ("fade in trim handle for %1", region()->name()));
|
2014-06-09 23:39:07 -04:00
|
|
|
fade_in_trim_handle->set_outline_color (ArdourCanvas::rgba_to_color (0, 0, 0, 1.0));
|
2015-01-02 09:44:54 -05:00
|
|
|
fade_in_trim_handle->set_fill_color (UIConfiguration::instance().color ("inactive fade handle"));
|
2014-05-30 21:53:59 -04:00
|
|
|
fade_in_trim_handle->set_data ("regionview", this);
|
|
|
|
fade_in_trim_handle->hide ();
|
|
|
|
|
|
|
|
fade_out_trim_handle = new ArdourCanvas::Rectangle (group);
|
|
|
|
CANVAS_DEBUG_NAME (fade_out_handle, string_compose ("fade out trim handle for %1", region()->name()));
|
2014-06-09 23:39:07 -04:00
|
|
|
fade_out_trim_handle->set_outline_color (ArdourCanvas::rgba_to_color (0, 0, 0, 1.0));
|
2015-01-02 09:44:54 -05:00
|
|
|
fade_out_trim_handle->set_fill_color (UIConfiguration::instance().color ("inactive fade handle"));
|
2014-05-30 21:53:59 -04:00
|
|
|
fade_out_trim_handle->set_data ("regionview", this);
|
|
|
|
fade_out_trim_handle->hide ();
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
2007-05-17 06:41:14 -04:00
|
|
|
setup_fade_handle_positions ();
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (!trackview.session()->config.get_show_region_fades()) {
|
2009-10-21 12:56:58 -04:00
|
|
|
set_fade_visibility (false);
|
|
|
|
}
|
2008-12-08 11:07:28 -05:00
|
|
|
|
2009-02-16 02:04:27 -05:00
|
|
|
const string line_name = _region->name() + ":gain";
|
2016-04-12 15:38:31 -04:00
|
|
|
|
2015-10-26 15:17:42 -04:00
|
|
|
gain_line.reset (new AudioRegionGainLine (line_name, *this, *group, audio_region()->envelope()));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-05-29 14:38:54 -04:00
|
|
|
update_envelope_visibility ();
|
2006-07-23 08:03:19 -04:00
|
|
|
gain_line->reset ();
|
|
|
|
|
2016-04-12 15:38:31 -04:00
|
|
|
/* streamview will call set_height() */
|
|
|
|
//set_height (trackview.current_height()); // XXX not correct for Layered mode, but set_height() will fix later.
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
region_muted ();
|
|
|
|
region_sync_changed ();
|
2010-02-19 13:09:08 -05:00
|
|
|
|
|
|
|
region_resized (ARDOUR::bounds_change);
|
2016-04-12 15:38:31 -04:00
|
|
|
/* region_resized sets ghost region duration */
|
2013-04-04 00:32:52 -04:00
|
|
|
|
2016-04-12 15:38:31 -04:00
|
|
|
/* region_locked is a synonym for region_renamed () which is called in region_muted() above */
|
|
|
|
//region_locked ();
|
2013-04-04 00:32:52 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
envelope_active_changed ();
|
|
|
|
fade_in_active_changed ();
|
|
|
|
fade_out_active_changed ();
|
|
|
|
|
use filechooser widget in export dialog, selected files set format combos, hide progress bar until use in export dialog, speed up 'separate regions in range' operation on larger sessions, ruler scale now calculated separately to mark generation, fix for non-stacked layering regression, try not to generate 'buried' crossfades, use playlist->freeze() to speed up copying/moving regions on large playlists (not done for undo), width dependent items now reset on regionview init, get rid of jack_port_ensure_monitor check, remove audiosourse _length (only source has a length.. i think), make overlapend differ to overlapexternal where start points coincide.
git-svn-id: svn://localhost/ardour2/trunk@2576 d708f5d6-7413-0410-9779-e7cbd77b26cf
2007-10-26 09:32:24 -04:00
|
|
|
reset_width_dependent_items (_pixel_width);
|
|
|
|
|
2010-07-19 19:26:10 -04:00
|
|
|
if (fade_in_handle) {
|
2014-05-30 21:53:59 -04:00
|
|
|
fade_in_handle->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_handle_event), fade_in_handle, this, false));
|
2010-07-19 19:26:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fade_out_handle) {
|
2014-05-30 21:53:59 -04:00
|
|
|
fade_out_handle->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_handle_event), fade_out_handle, this, false));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fade_in_trim_handle) {
|
|
|
|
fade_in_trim_handle->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_handle_event), fade_in_trim_handle, this, true));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fade_out_trim_handle) {
|
|
|
|
fade_out_trim_handle->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_handle_event), fade_out_trim_handle, this, true));
|
2010-07-19 19:26:10 -04:00
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
set_colors ();
|
|
|
|
|
2012-06-17 07:48:51 -04:00
|
|
|
setup_waveform_visibility ();
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
/* XXX sync mark drag? */
|
|
|
|
}
|
|
|
|
|
|
|
|
AudioRegionView::~AudioRegionView ()
|
|
|
|
{
|
|
|
|
in_destructor = true;
|
|
|
|
|
|
|
|
RegionViewGoingAway (this); /* EMIT_SIGNAL */
|
|
|
|
|
2010-04-21 21:40:33 -04:00
|
|
|
for (vector<ScopedConnection*>::iterator i = _data_ready_connections.begin(); i != _data_ready_connections.end(); ++i) {
|
|
|
|
delete *i;
|
|
|
|
}
|
2015-09-06 06:56:50 -04:00
|
|
|
_data_ready_connections.clear ();
|
2010-04-21 21:40:33 -04:00
|
|
|
|
2011-02-14 16:49:43 -05:00
|
|
|
for (list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator i = feature_lines.begin(); i != feature_lines.end(); ++i) {
|
2010-07-06 07:33:27 -04:00
|
|
|
delete ((*i).second);
|
|
|
|
}
|
2011-02-14 16:49:43 -05:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
/* all waveviews etc will be destroyed when the group is destroyed */
|
|
|
|
}
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<ARDOUR::AudioRegion>
|
2006-07-23 08:03:19 -04:00
|
|
|
AudioRegionView::audio_region() const
|
|
|
|
{
|
2006-07-29 23:25:38 -04:00
|
|
|
// "Guaranteed" to succeed...
|
2006-08-29 17:21:48 -04:00
|
|
|
return boost::dynamic_pointer_cast<AudioRegion>(_region);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-02-19 13:09:08 -05:00
|
|
|
AudioRegionView::region_changed (const PropertyChange& what_changed)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2010-03-02 13:05:26 -05:00
|
|
|
ENSURE_GUI_THREAD (*this, &AudioRegionView::region_changed, what_changed);
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2010-02-19 13:09:08 -05:00
|
|
|
RegionView::region_changed (what_changed);
|
2006-07-29 23:25:38 -04:00
|
|
|
|
2010-02-19 13:09:08 -05:00
|
|
|
if (what_changed.contains (ARDOUR::Properties::scale_amplitude)) {
|
2006-07-23 08:03:19 -04:00
|
|
|
region_scale_amplitude_changed ();
|
|
|
|
}
|
2010-02-19 13:09:08 -05:00
|
|
|
if (what_changed.contains (ARDOUR::Properties::fade_in)) {
|
2010-11-25 15:37:39 -05:00
|
|
|
fade_in_changed ();
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2010-02-19 13:09:08 -05:00
|
|
|
if (what_changed.contains (ARDOUR::Properties::fade_out)) {
|
2006-07-23 08:03:19 -04:00
|
|
|
fade_out_changed ();
|
|
|
|
}
|
2010-02-19 13:09:08 -05:00
|
|
|
if (what_changed.contains (ARDOUR::Properties::fade_in_active)) {
|
2006-07-23 08:03:19 -04:00
|
|
|
fade_in_active_changed ();
|
|
|
|
}
|
2010-02-19 13:09:08 -05:00
|
|
|
if (what_changed.contains (ARDOUR::Properties::fade_out_active)) {
|
2006-07-23 08:03:19 -04:00
|
|
|
fade_out_active_changed ();
|
|
|
|
}
|
2010-02-19 13:09:08 -05:00
|
|
|
if (what_changed.contains (ARDOUR::Properties::envelope_active)) {
|
2006-07-23 08:03:19 -04:00
|
|
|
envelope_active_changed ();
|
|
|
|
}
|
2010-07-06 07:33:27 -04:00
|
|
|
if (what_changed.contains (ARDOUR::Properties::valid_transients)) {
|
|
|
|
transients_changed ();
|
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::fade_in_changed ()
|
|
|
|
{
|
|
|
|
reset_fade_in_shape ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::fade_out_changed ()
|
|
|
|
{
|
|
|
|
reset_fade_out_shape ();
|
|
|
|
}
|
2012-05-10 09:48:23 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
void
|
|
|
|
AudioRegionView::fade_in_active_changed ()
|
|
|
|
{
|
2014-02-26 18:45:24 -05:00
|
|
|
if (start_xfade_rect) {
|
|
|
|
if (audio_region()->fade_in_active()) {
|
2014-05-27 10:28:28 -04:00
|
|
|
start_xfade_rect->set_fill (false);
|
2014-02-26 18:45:24 -05:00
|
|
|
} else {
|
2015-01-02 09:44:54 -05:00
|
|
|
start_xfade_rect->set_fill_color (UIConfiguration::instance().color_mod ("inactive crossfade", "inactive crossfade"));
|
2014-05-27 10:28:28 -04:00
|
|
|
start_xfade_rect->set_fill (true);
|
2014-02-26 18:45:24 -05:00
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::fade_out_active_changed ()
|
|
|
|
{
|
2014-02-26 18:45:24 -05:00
|
|
|
if (end_xfade_rect) {
|
|
|
|
if (audio_region()->fade_out_active()) {
|
2014-05-27 10:28:28 -04:00
|
|
|
end_xfade_rect->set_fill (false);
|
2015-10-05 10:17:49 -04:00
|
|
|
} else {
|
2015-01-02 09:44:54 -05:00
|
|
|
end_xfade_rect->set_fill_color (UIConfiguration::instance().color_mod ("inactive crossfade", "inactive crossfade"));
|
2014-05-27 10:28:28 -04:00
|
|
|
end_xfade_rect->set_fill (true);
|
2014-02-26 18:45:24 -05:00
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::region_scale_amplitude_changed ()
|
|
|
|
{
|
|
|
|
for (uint32_t n = 0; n < waves.size(); ++n) {
|
2013-04-17 15:22:09 -04:00
|
|
|
waves[n]->gain_changed ();
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2017-01-24 07:37:20 -05:00
|
|
|
region_renamed ();
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
2006-08-10 23:24:57 -04:00
|
|
|
void
|
|
|
|
AudioRegionView::region_renamed ()
|
|
|
|
{
|
2010-09-14 12:51:02 -04:00
|
|
|
std::string str = RegionView::make_name ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (audio_region()->speed_mismatch (trackview.session()->frame_rate())) {
|
2006-08-10 23:24:57 -04:00
|
|
|
str = string ("*") + str;
|
|
|
|
}
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
if (_region->muted()) {
|
2006-08-10 23:24:57 -04:00
|
|
|
str = string ("!") + str;
|
|
|
|
}
|
|
|
|
|
2017-01-24 07:37:20 -05:00
|
|
|
|
|
|
|
boost::shared_ptr<AudioRegion> ar (audio_region());
|
|
|
|
if (ar->scale_amplitude() != 1.0) {
|
|
|
|
char tmp[32];
|
|
|
|
snprintf (tmp, 32, " (%.1fdB)", accurate_coefficient_to_dB (ar->scale_amplitude()));
|
|
|
|
str += tmp;
|
|
|
|
}
|
|
|
|
|
2006-08-10 23:24:57 -04:00
|
|
|
set_item_name (str, this);
|
|
|
|
set_name_text (str);
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
void
|
2010-02-19 13:09:08 -05:00
|
|
|
AudioRegionView::region_resized (const PropertyChange& what_changed)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2008-02-10 13:16:25 -05:00
|
|
|
AudioGhostRegion* agr;
|
|
|
|
|
2006-07-29 23:25:38 -04:00
|
|
|
RegionView::region_resized(what_changed);
|
2010-02-19 13:09:08 -05:00
|
|
|
PropertyChange interesting_stuff;
|
|
|
|
|
|
|
|
interesting_stuff.add (ARDOUR::Properties::start);
|
|
|
|
interesting_stuff.add (ARDOUR::Properties::length);
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2010-02-19 13:09:08 -05:00
|
|
|
if (what_changed.contains (interesting_stuff)) {
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2009-10-21 12:56:58 -04:00
|
|
|
for (uint32_t n = 0; n < waves.size(); ++n) {
|
2013-04-04 00:32:52 -04:00
|
|
|
waves[n]->region_resized ();
|
2006-07-29 23:25:38 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-10-21 12:56:58 -04:00
|
|
|
for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
|
2010-07-06 07:33:27 -04:00
|
|
|
if ((agr = dynamic_cast<AudioGhostRegion*>(*i)) != 0) {
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2008-02-10 13:16:25 -05:00
|
|
|
for (vector<WaveView*>::iterator w = agr->waves.begin(); w != agr->waves.end(); ++w) {
|
2013-04-04 00:32:52 -04:00
|
|
|
(*w)->region_resized ();
|
2008-02-10 13:16:25 -05:00
|
|
|
}
|
|
|
|
}
|
2009-10-21 12:56:58 -04:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2016-04-30 20:02:25 -04:00
|
|
|
/* hide transient lines that extend beyond the region */
|
2011-02-14 16:49:43 -05:00
|
|
|
list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
|
2016-04-30 20:02:25 -04:00
|
|
|
framepos_t first = _region->first_frame();
|
|
|
|
framepos_t last = _region->last_frame();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-07-06 07:33:27 -04:00
|
|
|
for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
|
2016-04-30 20:02:25 -04:00
|
|
|
if (l->first < first || l->first >= last) {
|
2011-02-20 12:30:02 -05:00
|
|
|
l->second->hide();
|
|
|
|
} else {
|
|
|
|
l->second->show();
|
2010-07-06 07:33:27 -04:00
|
|
|
}
|
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::reset_width_dependent_items (double pixel_width)
|
|
|
|
{
|
2016-04-12 15:38:31 -04:00
|
|
|
if (pixel_width == _width) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-29 23:25:38 -04:00
|
|
|
RegionView::reset_width_dependent_items(pixel_width);
|
|
|
|
assert(_pixel_width == pixel_width);
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2015-09-14 18:19:02 -04:00
|
|
|
pending_peak_data->set_x1(pixel_width);
|
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
if (pixel_width <= 20.0 || _height < 5.0 || !trackview.session()->config.get_show_region_fades()) {
|
2014-05-30 21:53:59 -04:00
|
|
|
if (fade_in_handle) { fade_in_handle->hide(); }
|
|
|
|
if (fade_out_handle) { fade_out_handle->hide(); }
|
|
|
|
if (fade_in_trim_handle) { fade_in_trim_handle->hide(); }
|
|
|
|
if (fade_out_trim_handle) { fade_out_trim_handle->hide(); }
|
2014-05-31 08:00:04 -04:00
|
|
|
if (start_xfade_rect) { start_xfade_rect->set_outline (false); }
|
|
|
|
if (end_xfade_rect) { end_xfade_rect->set_outline (false); }
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
2016-04-30 20:02:25 -04:00
|
|
|
reset_fade_shapes ();
|
2010-07-06 07:33:27 -04:00
|
|
|
|
2016-04-30 20:02:25 -04:00
|
|
|
/* Update feature lines */
|
|
|
|
AnalysisFeatureList analysis_features;
|
|
|
|
_region->transients (analysis_features);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2016-04-30 20:02:25 -04:00
|
|
|
if (feature_lines.size () != analysis_features.size ()) {
|
|
|
|
cerr << "postponed freature line update.\n"; // XXX
|
|
|
|
// AudioRegionView::transients_changed () will pick up on this
|
|
|
|
return;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2016-04-30 20:02:25 -04:00
|
|
|
framepos_t position = _region->position();
|
2011-02-14 16:49:43 -05:00
|
|
|
|
2016-04-30 20:02:25 -04:00
|
|
|
AnalysisFeatureList::const_iterator i;
|
|
|
|
list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
|
|
|
|
double y1;
|
|
|
|
if (_height >= NAME_HIGHLIGHT_THRESH) {
|
|
|
|
y1 = _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1;
|
|
|
|
} else {
|
|
|
|
y1 = _height - 1;
|
|
|
|
}
|
|
|
|
for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) {
|
|
|
|
float x_pos = trackview.editor().sample_to_pixel ((*i) - position);
|
2011-02-14 16:49:43 -05:00
|
|
|
(*l).first = *i;
|
2013-04-04 00:32:52 -04:00
|
|
|
(*l).second->set (ArdourCanvas::Duple (x_pos, 2.0),
|
2016-04-30 20:02:25 -04:00
|
|
|
ArdourCanvas::Duple (x_pos, y1));
|
2010-07-06 07:33:27 -04:00
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::region_muted ()
|
|
|
|
{
|
2006-07-29 23:25:38 -04:00
|
|
|
RegionView::region_muted();
|
2013-04-24 15:42:14 -04:00
|
|
|
set_waveform_colors ();
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-09-10 11:03:30 -04:00
|
|
|
AudioRegionView::setup_fade_handle_positions()
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2008-09-10 11:03:30 -04:00
|
|
|
/* position of fade handle offset from the top of the region view */
|
2014-02-25 11:35:55 -05:00
|
|
|
double const handle_pos = 0.0;
|
2008-09-10 11:03:30 -04:00
|
|
|
|
|
|
|
if (fade_in_handle) {
|
2013-04-04 00:32:52 -04:00
|
|
|
fade_in_handle->set_y0 (handle_pos);
|
|
|
|
fade_in_handle->set_y1 (handle_pos + handle_size);
|
2008-09-10 11:03:30 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-10 11:03:30 -04:00
|
|
|
if (fade_out_handle) {
|
2013-04-04 00:32:52 -04:00
|
|
|
fade_out_handle->set_y0 (handle_pos);
|
|
|
|
fade_out_handle->set_y1 (handle_pos + handle_size);
|
2008-09-10 11:03:30 -04:00
|
|
|
}
|
2014-05-30 21:53:59 -04:00
|
|
|
|
|
|
|
if (fade_in_trim_handle) {
|
|
|
|
fade_in_trim_handle->set_y0 (_height - handle_size);
|
|
|
|
fade_in_trim_handle->set_y1 (_height);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fade_out_trim_handle) {
|
|
|
|
fade_out_trim_handle->set_y0 (_height - handle_size );
|
|
|
|
fade_out_trim_handle->set_y1 (_height);
|
|
|
|
}
|
2008-09-10 11:03:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-09-19 15:32:10 -04:00
|
|
|
AudioRegionView::set_height (gdouble height)
|
2008-09-10 11:03:30 -04:00
|
|
|
{
|
2016-04-12 15:38:31 -04:00
|
|
|
if (height == _height) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-09-19 15:32:10 -04:00
|
|
|
RegionView::set_height (height);
|
2015-09-14 18:19:02 -04:00
|
|
|
pending_peak_data->set_y1 (height);
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2008-09-19 15:32:10 -04:00
|
|
|
uint32_t wcnt = waves.size();
|
2007-05-17 06:41:14 -04:00
|
|
|
|
2015-06-19 08:15:25 -04:00
|
|
|
if (wcnt > 0) {
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2015-06-19 08:15:25 -04:00
|
|
|
gdouble ht;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
if (!UIConfiguration::instance().get_show_name_highlight() || (height < NAME_HIGHLIGHT_THRESH)) {
|
2015-06-19 08:15:25 -04:00
|
|
|
ht = height / (double) wcnt;
|
2006-07-23 08:03:19 -04:00
|
|
|
} else {
|
2015-06-19 08:15:25 -04:00
|
|
|
ht = (height - NAME_HIGHLIGHT_SIZE) / (double) wcnt;
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-06-19 08:15:25 -04:00
|
|
|
for (uint32_t n = 0; n < wcnt; ++n) {
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-06-19 08:15:25 -04:00
|
|
|
gdouble yoff = floor (ht * n);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-06-19 08:15:25 -04:00
|
|
|
waves[n]->set_height (ht);
|
|
|
|
waves[n]->set_y_position (yoff);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gain_line) {
|
2010-04-03 18:35:44 -04:00
|
|
|
|
2008-09-19 15:32:10 -04:00
|
|
|
if ((height/wcnt) < NAME_HIGHLIGHT_THRESH) {
|
2006-07-23 08:03:19 -04:00
|
|
|
gain_line->hide ();
|
|
|
|
} else {
|
2012-05-29 14:38:54 -04:00
|
|
|
update_envelope_visibility ();
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2010-04-03 18:35:44 -04:00
|
|
|
|
2010-04-15 16:42:05 -04:00
|
|
|
gain_line->set_height ((uint32_t) rint (height - NAME_HIGHLIGHT_SIZE) - 2);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
reset_fade_shapes ();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2016-04-30 20:02:25 -04:00
|
|
|
/* Update heights for any feature lines */
|
|
|
|
framepos_t position = _region->position();
|
2011-02-14 16:49:43 -05:00
|
|
|
list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
|
2016-04-30 20:02:25 -04:00
|
|
|
double y1;
|
|
|
|
if (_height >= NAME_HIGHLIGHT_THRESH) {
|
|
|
|
y1 = _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1;
|
|
|
|
} else {
|
|
|
|
y1 = _height - 1;
|
|
|
|
}
|
2010-07-06 07:33:27 -04:00
|
|
|
for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
|
2016-04-30 20:02:25 -04:00
|
|
|
float pos_x = trackview.editor().sample_to_pixel((*l).first - position);
|
|
|
|
(*l).second->set (ArdourCanvas::Duple (pos_x, 2.0),
|
|
|
|
ArdourCanvas::Duple (pos_x, y1));
|
2011-02-14 16:49:43 -05:00
|
|
|
}
|
2010-04-03 18:35:44 -04:00
|
|
|
|
2013-04-15 13:50:05 -04:00
|
|
|
if (name_text) {
|
|
|
|
name_text->raise_to_top();
|
2010-04-03 18:35:44 -04:00
|
|
|
}
|
2014-05-30 22:17:47 -04:00
|
|
|
|
|
|
|
setup_fade_handle_positions();
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::reset_fade_shapes ()
|
|
|
|
{
|
2014-05-30 21:53:59 -04:00
|
|
|
if (!trim_fade_in_drag_active) { reset_fade_in_shape (); }
|
|
|
|
if (!trim_fade_out_drag_active) { reset_fade_out_shape (); }
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::reset_fade_in_shape ()
|
|
|
|
{
|
2012-12-14 12:21:44 -05:00
|
|
|
reset_fade_in_shape_width (audio_region(), (framecnt_t) audio_region()->fade_in()->back()->when);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
void
|
2014-05-30 21:53:59 -04:00
|
|
|
AudioRegionView::reset_fade_in_shape_width (boost::shared_ptr<AudioRegion> ar, framecnt_t width, bool drag_active)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2014-05-30 21:53:59 -04:00
|
|
|
trim_fade_in_drag_active = drag_active;
|
2006-07-23 08:03:19 -04:00
|
|
|
if (fade_in_handle == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* smallest size for a fade is 64 frames */
|
|
|
|
|
2010-12-03 17:26:29 -05:00
|
|
|
width = std::max ((framecnt_t) 64, width);
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2010-12-18 18:53:37 -05:00
|
|
|
/* round here to prevent little visual glitches with sub-pixel placement */
|
2015-04-29 20:32:42 -04:00
|
|
|
double const pwidth = floor (width / samples_per_pixel);
|
2013-04-18 11:18:18 -04:00
|
|
|
double const handle_left = pwidth;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-12-18 16:34:32 -05:00
|
|
|
/* Put the fade in handle so that its left side is at the end-of-fade line */
|
2013-04-18 11:18:18 -04:00
|
|
|
fade_in_handle->set_x0 (handle_left);
|
|
|
|
fade_in_handle->set_x1 (handle_left + handle_size);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-05-30 21:53:59 -04:00
|
|
|
if (fade_in_trim_handle) {
|
|
|
|
fade_in_trim_handle->set_x0 (0);
|
|
|
|
fade_in_trim_handle->set_x1 (handle_size);
|
|
|
|
}
|
|
|
|
|
2014-05-31 09:15:46 -04:00
|
|
|
if (fade_in_handle->visible()) {
|
|
|
|
//see comment for drag_start
|
2014-12-08 23:00:00 -05:00
|
|
|
entered();
|
2014-05-31 09:15:46 -04:00
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (pwidth < 5) {
|
2012-12-14 14:44:09 -05:00
|
|
|
hide_start_xfade();
|
2006-07-23 08:03:19 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-26 18:45:24 -05:00
|
|
|
if (!trackview.session()->config.get_show_region_fades()) {
|
|
|
|
hide_start_xfade ();
|
|
|
|
return;
|
2008-10-09 17:55:05 -04:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-04-18 11:18:18 -04:00
|
|
|
double effective_height;
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2008-09-10 11:03:30 -04:00
|
|
|
if (_height >= NAME_HIGHLIGHT_THRESH) {
|
2014-02-13 18:16:10 -05:00
|
|
|
effective_height = _height - NAME_HIGHLIGHT_SIZE;
|
2006-07-23 08:03:19 -04:00
|
|
|
} else {
|
2014-02-13 18:16:10 -05:00
|
|
|
effective_height = _height;
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
2014-02-26 18:45:24 -05:00
|
|
|
/* points *MUST* be in anti-clockwise order */
|
2014-02-25 11:35:55 -05:00
|
|
|
|
2013-04-18 09:55:53 -04:00
|
|
|
Points points;
|
2014-02-26 18:45:24 -05:00
|
|
|
Points::size_type pi;
|
|
|
|
boost::shared_ptr<const Evoral::ControlList> list (audio_region()->fade_in());
|
|
|
|
Evoral::ControlList::const_iterator x;
|
|
|
|
double length = list->length();
|
2013-04-18 09:55:53 -04:00
|
|
|
|
2014-02-26 18:45:24 -05:00
|
|
|
points.assign (list->size(), Duple());
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2014-02-26 18:45:24 -05:00
|
|
|
for (x = list->begin(), pi = 0; x != list->end(); ++x, ++pi) {
|
2015-04-29 20:32:42 -04:00
|
|
|
points[pi].x = (pwidth * ((*x)->when/length));
|
|
|
|
points[pi].y = effective_height - ((*x)->value * (effective_height - 1.));
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-04-18 09:55:53 -04:00
|
|
|
/* draw the line */
|
|
|
|
|
2014-01-07 20:55:04 -05:00
|
|
|
redraw_start_xfade_to (ar, width, points, effective_height, handle_left);
|
2013-04-18 09:55:53 -04:00
|
|
|
|
2009-08-12 21:57:03 -04:00
|
|
|
/* ensure trim handle stays on top */
|
2010-07-19 19:26:10 -04:00
|
|
|
if (frame_handle_start) {
|
|
|
|
frame_handle_start->raise_to_top();
|
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::reset_fade_out_shape ()
|
|
|
|
{
|
2012-12-14 12:21:44 -05:00
|
|
|
reset_fade_out_shape_width (audio_region(), (framecnt_t) audio_region()->fade_out()->back()->when);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-05-30 21:53:59 -04:00
|
|
|
AudioRegionView::reset_fade_out_shape_width (boost::shared_ptr<AudioRegion> ar, framecnt_t width, bool drag_active)
|
2009-10-14 12:10:01 -04:00
|
|
|
{
|
2014-05-30 21:53:59 -04:00
|
|
|
trim_fade_out_drag_active = drag_active;
|
2006-07-23 08:03:19 -04:00
|
|
|
if (fade_out_handle == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* smallest size for a fade is 64 frames */
|
|
|
|
|
2010-12-03 17:26:29 -05:00
|
|
|
width = std::max ((framecnt_t) 64, width);
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2014-02-14 10:21:51 -05:00
|
|
|
|
2015-04-29 20:32:42 -04:00
|
|
|
double const pwidth = floor(trackview.editor().sample_to_pixel (width));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-02-14 10:21:51 -05:00
|
|
|
/* the right edge should be right on the region frame is the pixel
|
|
|
|
* width is zero. Hence the additional + 1.0 at the end.
|
|
|
|
*/
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2014-11-07 12:58:46 -05:00
|
|
|
double const handle_right = rint(trackview.editor().sample_to_pixel (_region->length()) - pwidth);
|
|
|
|
double const trim_handle_right = rint(trackview.editor().sample_to_pixel (_region->length()));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-12-18 16:34:32 -05:00
|
|
|
/* Put the fade out handle so that its right side is at the end-of-fade line;
|
|
|
|
*/
|
2014-11-01 16:05:43 -04:00
|
|
|
fade_out_handle->set_x0 (handle_right - handle_size);
|
|
|
|
fade_out_handle->set_x1 (handle_right);
|
2014-05-30 21:53:59 -04:00
|
|
|
if (fade_out_trim_handle) {
|
|
|
|
fade_out_trim_handle->set_x0 (1 + trim_handle_right - handle_size);
|
|
|
|
fade_out_trim_handle->set_x1 (1 + trim_handle_right);
|
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2014-05-31 09:15:46 -04:00
|
|
|
if (fade_out_handle->visible()) {
|
|
|
|
//see comment for drag_start
|
2014-12-08 23:00:00 -05:00
|
|
|
entered();
|
2014-05-31 09:15:46 -04:00
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
/* don't show shape if its too small */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (pwidth < 5) {
|
2012-12-14 14:44:09 -05:00
|
|
|
hide_end_xfade();
|
2006-07-23 08:03:19 -04:00
|
|
|
return;
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
|
|
|
|
2014-02-26 18:45:24 -05:00
|
|
|
if (!trackview.session()->config.get_show_region_fades()) {
|
|
|
|
hide_end_xfade();
|
|
|
|
return;
|
2008-10-09 17:55:05 -04:00
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2013-04-18 11:18:18 -04:00
|
|
|
double effective_height;
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2015-04-29 20:32:42 -04:00
|
|
|
effective_height = _height;
|
2014-11-07 12:58:46 -05:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
if (UIConfiguration::instance().get_show_name_highlight() && effective_height >= NAME_HIGHLIGHT_THRESH) {
|
2014-11-07 12:58:46 -05:00
|
|
|
effective_height -= NAME_HIGHLIGHT_SIZE;
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* points *MUST* be in anti-clockwise order */
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-04-18 09:55:53 -04:00
|
|
|
Points points;
|
2014-02-26 18:45:24 -05:00
|
|
|
Points::size_type pi;
|
|
|
|
boost::shared_ptr<const Evoral::ControlList> list (audio_region()->fade_out());
|
|
|
|
Evoral::ControlList::const_iterator x;
|
|
|
|
double length = list->length();
|
|
|
|
|
|
|
|
points.assign (list->size(), Duple());
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-02-26 18:45:24 -05:00
|
|
|
for (x = list->begin(), pi = 0; x != list->end(); ++x, ++pi) {
|
2014-11-07 12:58:46 -05:00
|
|
|
points[pi].x = _pixel_width - pwidth + (pwidth * ((*x)->when/length));
|
2015-04-29 20:32:42 -04:00
|
|
|
points[pi].y = effective_height - ((*x)->value * (effective_height - 1.));
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-04-18 09:55:53 -04:00
|
|
|
/* draw the line */
|
|
|
|
|
2014-02-26 18:45:24 -05:00
|
|
|
redraw_end_xfade_to (ar, width, points, effective_height, handle_right, pwidth);
|
2012-12-14 14:44:09 -05:00
|
|
|
|
2009-08-12 21:57:03 -04:00
|
|
|
/* ensure trim handle stays on top */
|
2010-07-19 19:26:10 -04:00
|
|
|
if (frame_handle_end) {
|
|
|
|
frame_handle_end->raise_to_top();
|
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
2012-11-20 14:43:43 -05:00
|
|
|
framepos_t
|
|
|
|
AudioRegionView::get_fade_in_shape_width ()
|
|
|
|
{
|
|
|
|
return audio_region()->fade_in()->back()->when;
|
|
|
|
}
|
|
|
|
|
|
|
|
framepos_t
|
|
|
|
AudioRegionView::get_fade_out_shape_width ()
|
|
|
|
{
|
|
|
|
return audio_region()->fade_out()->back()->when;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-18 09:55:53 -04:00
|
|
|
void
|
|
|
|
AudioRegionView::redraw_start_xfade ()
|
|
|
|
{
|
|
|
|
boost::shared_ptr<AudioRegion> ar (audio_region());
|
|
|
|
|
|
|
|
if (!ar->fade_in() || ar->fade_in()->empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
show_start_xfade();
|
|
|
|
reset_fade_in_shape_width (ar, ar->fade_in()->back()->when);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-01-07 20:55:04 -05:00
|
|
|
AudioRegionView::redraw_start_xfade_to (boost::shared_ptr<AudioRegion> ar, framecnt_t /*width*/, Points& points, double effective_height,
|
|
|
|
double rect_width)
|
2013-04-18 09:55:53 -04:00
|
|
|
{
|
2014-02-26 18:45:24 -05:00
|
|
|
if (points.size() < 2) {
|
2013-04-18 09:55:53 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-28 21:10:22 -04:00
|
|
|
if (!start_xfade_curve) {
|
|
|
|
start_xfade_curve = new ArdourCanvas::XFadeCurve (group, ArdourCanvas::XFadeCurve::Start);
|
|
|
|
CANVAS_DEBUG_NAME (start_xfade_curve, string_compose ("xfade start out line for %1", region()->name()));
|
2015-01-02 09:44:54 -05:00
|
|
|
start_xfade_curve->set_fill_color (UIConfiguration::instance().color_mod ("active crossfade", "crossfade alpha"));
|
|
|
|
start_xfade_curve->set_outline_color (UIConfiguration::instance().color ("crossfade line"));
|
2014-05-28 21:10:22 -04:00
|
|
|
start_xfade_curve->set_ignore_events (true);
|
2014-05-27 10:28:28 -04:00
|
|
|
}
|
2013-04-18 09:55:53 -04:00
|
|
|
if (!start_xfade_rect) {
|
|
|
|
start_xfade_rect = new ArdourCanvas::Rectangle (group);
|
2013-04-24 15:42:14 -04:00
|
|
|
CANVAS_DEBUG_NAME (start_xfade_rect, string_compose ("xfade start rect for %1", region()->name()));
|
2015-01-02 09:44:54 -05:00
|
|
|
start_xfade_rect->set_outline_color (UIConfiguration::instance().color ("crossfade line"));
|
2014-05-27 10:28:28 -04:00
|
|
|
start_xfade_rect->set_fill (false);
|
2014-05-31 08:00:04 -04:00
|
|
|
start_xfade_rect->set_outline (false);
|
2013-04-18 09:55:53 -04:00
|
|
|
start_xfade_rect->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_start_xfade_event), start_xfade_rect, this));
|
|
|
|
start_xfade_rect->set_data ("regionview", this);
|
|
|
|
}
|
|
|
|
|
2014-05-31 08:00:28 -04:00
|
|
|
start_xfade_rect->set (ArdourCanvas::Rect (0.0, 0.0, rect_width, effective_height));
|
2013-04-18 09:55:53 -04:00
|
|
|
|
|
|
|
/* fade out line */
|
|
|
|
|
2014-02-26 18:45:24 -05:00
|
|
|
boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_in ();
|
2013-04-18 09:55:53 -04:00
|
|
|
Points ipoints;
|
2014-02-26 18:45:24 -05:00
|
|
|
Points::size_type npoints;
|
2013-04-18 09:55:53 -04:00
|
|
|
|
|
|
|
if (!inverse) {
|
|
|
|
|
2014-02-26 18:45:24 -05:00
|
|
|
/* there is no explicit inverse fade in curve, so take the
|
|
|
|
* regular fade in curve given to use as "points" (already a
|
|
|
|
* set of coordinates), and convert to the inverse shape.
|
|
|
|
*/
|
|
|
|
|
|
|
|
npoints = points.size();
|
|
|
|
ipoints.assign (npoints, Duple());
|
2014-01-07 20:55:04 -05:00
|
|
|
|
2013-04-18 09:55:53 -04:00
|
|
|
for (Points::size_type i = 0, pci = 0; i < npoints; ++i, ++pci) {
|
|
|
|
ArdourCanvas::Duple &p (ipoints[pci]);
|
2014-02-26 18:45:24 -05:00
|
|
|
/* leave x-axis alone but invert with respect to y-axis */
|
2015-04-29 20:32:42 -04:00
|
|
|
p.y = effective_height - points[pci].y;
|
2013-04-18 09:55:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2014-02-26 18:45:24 -05:00
|
|
|
/* there is an explicit inverse fade in curve. Grab the points
|
|
|
|
and convert them into coordinates for the inverse fade in
|
|
|
|
line.
|
|
|
|
*/
|
|
|
|
|
|
|
|
npoints = inverse->size();
|
|
|
|
ipoints.assign (npoints, Duple());
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-02-26 18:45:24 -05:00
|
|
|
Evoral::ControlList::const_iterator x;
|
|
|
|
Points::size_type pi;
|
|
|
|
double length = inverse->length();
|
|
|
|
|
|
|
|
for (x = inverse->begin(), pi = 0; x != inverse->end(); ++x, ++pi) {
|
|
|
|
ArdourCanvas::Duple& p (ipoints[pi]);
|
2014-11-07 12:58:46 -05:00
|
|
|
p.x = (rect_width * ((*x)->when/length));
|
2015-04-29 20:32:42 -04:00
|
|
|
p.y = effective_height - ((*x)->value * (effective_height));
|
2013-04-18 09:55:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-28 21:10:22 -04:00
|
|
|
start_xfade_curve->set_inout (points, ipoints);
|
2013-04-18 09:55:53 -04:00
|
|
|
|
|
|
|
show_start_xfade();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::redraw_end_xfade ()
|
|
|
|
{
|
|
|
|
boost::shared_ptr<AudioRegion> ar (audio_region());
|
|
|
|
|
|
|
|
if (!ar->fade_out() || ar->fade_out()->empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
show_end_xfade();
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-04-18 09:55:53 -04:00
|
|
|
reset_fade_out_shape_width (ar, ar->fade_out()->back()->when);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-01-07 20:55:04 -05:00
|
|
|
AudioRegionView::redraw_end_xfade_to (boost::shared_ptr<AudioRegion> ar, framecnt_t width, Points& points, double effective_height,
|
2017-07-01 12:42:24 -04:00
|
|
|
double rect_edge, double rect_width)
|
2013-04-18 09:55:53 -04:00
|
|
|
{
|
2014-02-26 18:45:24 -05:00
|
|
|
if (points.size() < 2) {
|
2013-04-18 09:55:53 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-28 21:10:22 -04:00
|
|
|
if (!end_xfade_curve) {
|
|
|
|
end_xfade_curve = new ArdourCanvas::XFadeCurve (group, ArdourCanvas::XFadeCurve::End);
|
|
|
|
CANVAS_DEBUG_NAME (end_xfade_curve, string_compose ("xfade end out line for %1", region()->name()));
|
2015-01-02 09:44:54 -05:00
|
|
|
end_xfade_curve->set_fill_color (UIConfiguration::instance().color_mod ("active crossfade", "crossfade alpha"));
|
|
|
|
end_xfade_curve->set_outline_color (UIConfiguration::instance().color ("crossfade line"));
|
2014-05-28 21:10:22 -04:00
|
|
|
end_xfade_curve->set_ignore_events (true);
|
|
|
|
}
|
2014-05-27 10:28:28 -04:00
|
|
|
|
2013-04-18 09:55:53 -04:00
|
|
|
if (!end_xfade_rect) {
|
|
|
|
end_xfade_rect = new ArdourCanvas::Rectangle (group);
|
2013-04-24 15:42:14 -04:00
|
|
|
CANVAS_DEBUG_NAME (end_xfade_rect, string_compose ("xfade end rect for %1", region()->name()));
|
2015-01-02 09:44:54 -05:00
|
|
|
end_xfade_rect->set_outline_color (UIConfiguration::instance().color ("crossfade line"));
|
2014-05-27 10:28:28 -04:00
|
|
|
end_xfade_rect->set_fill (false);
|
2014-05-31 08:00:04 -04:00
|
|
|
end_xfade_rect->set_outline (false);
|
2013-04-18 09:55:53 -04:00
|
|
|
end_xfade_rect->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_end_xfade_event), end_xfade_rect, this));
|
|
|
|
end_xfade_rect->set_data ("regionview", this);
|
|
|
|
}
|
|
|
|
|
2014-11-07 12:58:46 -05:00
|
|
|
end_xfade_rect->set (ArdourCanvas::Rect (rect_edge, 0.0, rect_edge + rect_width, effective_height));
|
2013-04-18 09:55:53 -04:00
|
|
|
|
|
|
|
/* fade in line */
|
|
|
|
|
|
|
|
boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_out ();
|
|
|
|
Points ipoints;
|
2014-02-26 18:45:24 -05:00
|
|
|
Points::size_type npoints;
|
2013-04-18 09:55:53 -04:00
|
|
|
|
|
|
|
if (!inverse) {
|
|
|
|
|
2014-02-26 18:45:24 -05:00
|
|
|
/* there is no explicit inverse fade out curve, so take the
|
|
|
|
* regular fade out curve given to use as "points" (already a
|
|
|
|
* set of coordinates), and convert to the inverse shape.
|
|
|
|
*/
|
2013-04-18 09:55:53 -04:00
|
|
|
|
2014-02-26 18:45:24 -05:00
|
|
|
npoints = points.size();
|
|
|
|
ipoints.assign (npoints, Duple());
|
|
|
|
|
|
|
|
Points::size_type pci;
|
|
|
|
|
|
|
|
for (pci = 0; pci < npoints; ++pci) {
|
2013-04-18 09:55:53 -04:00
|
|
|
ArdourCanvas::Duple &p (ipoints[pci]);
|
2014-02-26 18:45:24 -05:00
|
|
|
p.y = effective_height - points[pci].y;
|
2013-04-18 09:55:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2014-02-26 18:45:24 -05:00
|
|
|
/* there is an explicit inverse fade out curve. Grab the points
|
|
|
|
and convert them into coordinates for the inverse fade out
|
|
|
|
line.
|
|
|
|
*/
|
2013-04-18 11:18:18 -04:00
|
|
|
|
2014-02-26 18:45:24 -05:00
|
|
|
npoints = inverse->size();
|
|
|
|
ipoints.assign (npoints, Duple());
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-04-18 11:18:18 -04:00
|
|
|
const double rend = trackview.editor().sample_to_pixel (_region->length() - width);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-02-26 18:45:24 -05:00
|
|
|
Evoral::ControlList::const_iterator x;
|
|
|
|
Points::size_type pi;
|
|
|
|
double length = inverse->length();
|
|
|
|
|
2015-04-29 20:32:42 -04:00
|
|
|
for (x = inverse->begin(), pi = 0; x != inverse->end(); ++x, ++pi) {
|
2014-02-26 18:45:24 -05:00
|
|
|
ArdourCanvas::Duple& p (ipoints[pi]);
|
2014-11-07 12:58:46 -05:00
|
|
|
p.x = (rect_width * ((*x)->when/length)) + rend;
|
2015-04-29 20:32:42 -04:00
|
|
|
p.y = effective_height - ((*x)->value * (effective_height));
|
2013-04-18 09:55:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-28 21:10:22 -04:00
|
|
|
end_xfade_curve->set_inout (ipoints, points);
|
2013-04-18 09:55:53 -04:00
|
|
|
|
|
|
|
show_end_xfade();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::hide_xfades ()
|
|
|
|
{
|
|
|
|
hide_start_xfade ();
|
|
|
|
hide_end_xfade ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::hide_start_xfade ()
|
|
|
|
{
|
2014-05-28 21:10:22 -04:00
|
|
|
if (start_xfade_curve) {
|
|
|
|
start_xfade_curve->hide();
|
2013-04-18 09:55:53 -04:00
|
|
|
}
|
|
|
|
if (start_xfade_rect) {
|
|
|
|
start_xfade_rect->hide ();
|
|
|
|
}
|
|
|
|
|
|
|
|
_start_xfade_visible = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::hide_end_xfade ()
|
|
|
|
{
|
2014-05-28 21:10:22 -04:00
|
|
|
if (end_xfade_curve) {
|
|
|
|
end_xfade_curve->hide();
|
2013-04-18 09:55:53 -04:00
|
|
|
}
|
|
|
|
if (end_xfade_rect) {
|
|
|
|
end_xfade_rect->hide ();
|
|
|
|
}
|
|
|
|
|
|
|
|
_end_xfade_visible = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::show_start_xfade ()
|
|
|
|
{
|
2014-05-28 21:10:22 -04:00
|
|
|
if (start_xfade_curve) {
|
|
|
|
start_xfade_curve->show();
|
2013-04-18 09:55:53 -04:00
|
|
|
}
|
|
|
|
if (start_xfade_rect) {
|
|
|
|
start_xfade_rect->show ();
|
|
|
|
}
|
|
|
|
|
|
|
|
_start_xfade_visible = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::show_end_xfade ()
|
|
|
|
{
|
2014-05-28 21:10:22 -04:00
|
|
|
if (end_xfade_curve) {
|
|
|
|
end_xfade_curve->show();
|
2013-04-18 09:55:53 -04:00
|
|
|
}
|
|
|
|
if (end_xfade_rect) {
|
|
|
|
end_xfade_rect->show ();
|
|
|
|
}
|
|
|
|
|
|
|
|
_end_xfade_visible = true;
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
void
|
2013-04-12 11:31:50 -04:00
|
|
|
AudioRegionView::set_samples_per_pixel (gdouble fpp)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2013-04-12 11:31:50 -04:00
|
|
|
RegionView::set_samples_per_pixel (fpp);
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
if (UIConfiguration::instance().get_show_waveforms ()) {
|
2012-06-17 07:48:51 -04:00
|
|
|
for (uint32_t n = 0; n < waves.size(); ++n) {
|
2013-04-12 11:31:50 -04:00
|
|
|
waves[n]->set_samples_per_pixel (fpp);
|
2007-03-18 02:07:08 -04:00
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gain_line) {
|
|
|
|
gain_line->reset ();
|
|
|
|
}
|
2007-03-18 02:07:08 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
reset_fade_shapes ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-17 15:22:09 -04:00
|
|
|
AudioRegionView::set_amplitude_above_axis (gdouble a)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
|
|
|
for (uint32_t n=0; n < waves.size(); ++n) {
|
2013-04-17 15:22:09 -04:00
|
|
|
waves[n]->set_amplitude_above_axis (a);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::set_colors ()
|
|
|
|
{
|
2006-07-29 23:25:38 -04:00
|
|
|
RegionView::set_colors();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (gain_line) {
|
2015-10-04 14:51:05 -04:00
|
|
|
gain_line->set_line_color (audio_region()->envelope_active() ?
|
|
|
|
UIConfiguration::instance().color ("gain line") :
|
2015-01-02 09:44:54 -05:00
|
|
|
UIConfiguration::instance().color_mod ("gain line inactive", "gain line inactive"));
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
2013-04-24 15:42:14 -04:00
|
|
|
set_waveform_colors ();
|
2013-04-18 14:21:53 -04:00
|
|
|
|
2014-05-28 21:10:22 -04:00
|
|
|
if (start_xfade_curve) {
|
2015-01-02 09:44:54 -05:00
|
|
|
start_xfade_curve->set_fill_color (UIConfiguration::instance().color_mod ("active crossfade", "crossfade alpha"));
|
|
|
|
start_xfade_curve->set_outline_color (UIConfiguration::instance().color ("crossfade line"));
|
2013-04-18 14:21:53 -04:00
|
|
|
}
|
2014-05-28 21:10:22 -04:00
|
|
|
if (end_xfade_curve) {
|
2015-01-02 09:44:54 -05:00
|
|
|
end_xfade_curve->set_fill_color (UIConfiguration::instance().color_mod ("active crossfade", "crossfade alpha"));
|
|
|
|
end_xfade_curve->set_outline_color (UIConfiguration::instance().color ("crossfade line"));
|
2013-04-18 14:21:53 -04:00
|
|
|
}
|
2013-04-18 21:30:12 -04:00
|
|
|
|
2013-04-18 14:21:53 -04:00
|
|
|
if (start_xfade_rect) {
|
2015-01-02 09:44:54 -05:00
|
|
|
start_xfade_rect->set_outline_color (UIConfiguration::instance().color ("crossfade line"));
|
2013-04-18 14:21:53 -04:00
|
|
|
}
|
|
|
|
if (end_xfade_rect) {
|
2015-01-02 09:44:54 -05:00
|
|
|
end_xfade_rect->set_outline_color (UIConfiguration::instance().color ("crossfade line"));
|
2013-04-18 14:21:53 -04:00
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-17 07:48:51 -04:00
|
|
|
AudioRegionView::setup_waveform_visibility ()
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2015-01-02 09:44:54 -05:00
|
|
|
if (UIConfiguration::instance().get_show_waveforms ()) {
|
2012-06-17 07:48:51 -04:00
|
|
|
for (uint32_t n = 0; n < waves.size(); ++n) {
|
|
|
|
/* make sure the zoom level is correct, since we don't update
|
|
|
|
this when waveforms are hidden.
|
|
|
|
*/
|
2013-04-04 18:45:27 -04:00
|
|
|
// CAIROCANVAS
|
2013-04-16 10:07:52 -04:00
|
|
|
// waves[n]->set_samples_per_pixel (_samples_per_pixel);
|
2012-06-17 07:48:51 -04:00
|
|
|
waves[n]->show();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (uint32_t n = 0; n < waves.size(); ++n) {
|
|
|
|
waves[n]->hide();
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::temporarily_hide_envelope ()
|
|
|
|
{
|
|
|
|
if (gain_line) {
|
|
|
|
gain_line->hide ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::unhide_envelope ()
|
|
|
|
{
|
2012-05-29 14:38:54 -04:00
|
|
|
update_envelope_visibility ();
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-05-29 14:38:54 -04:00
|
|
|
AudioRegionView::update_envelope_visibility ()
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2012-05-29 14:38:54 -04:00
|
|
|
if (!gain_line) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-06-01 14:12:39 -04:00
|
|
|
if (trackview.editor().current_mouse_mode() == Editing::MouseDraw || trackview.editor().current_mouse_mode() == Editing::MouseContent ) {
|
2014-12-08 23:00:00 -05:00
|
|
|
gain_line->set_visibility (AutomationLine::VisibleAspects(AutomationLine::ControlPoints|AutomationLine::Line));
|
2015-03-08 15:18:50 -04:00
|
|
|
gain_line->canvas_group().raise_to_top ();
|
2015-01-02 09:44:54 -05:00
|
|
|
} else if (UIConfiguration::instance().get_show_region_gain() || trackview.editor().current_mouse_mode() == Editing::MouseRange ) {
|
2015-05-26 17:41:03 -04:00
|
|
|
gain_line->set_visibility (AutomationLine::VisibleAspects(AutomationLine::Line));
|
|
|
|
gain_line->canvas_group().raise_to_top ();
|
2012-05-29 14:38:54 -04:00
|
|
|
} else {
|
2014-12-08 23:00:00 -05:00
|
|
|
gain_line->set_visibility (AutomationLine::VisibleAspects(0));
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-15 08:42:43 -04:00
|
|
|
void
|
|
|
|
AudioRegionView::delete_waves ()
|
|
|
|
{
|
|
|
|
for (vector<ScopedConnection*>::iterator i = _data_ready_connections.begin(); i != _data_ready_connections.end(); ++i) {
|
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
_data_ready_connections.clear ();
|
|
|
|
|
|
|
|
for (vector<WaveView*>::iterator w = waves.begin(); w != waves.end(); ++w) {
|
|
|
|
group->remove(*w);
|
|
|
|
}
|
|
|
|
waves.clear();
|
|
|
|
tmp_waves.clear();
|
|
|
|
pending_peak_data->show ();
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
void
|
|
|
|
AudioRegionView::create_waves ()
|
|
|
|
{
|
2008-03-17 16:54:03 -04:00
|
|
|
// cerr << "AudioRegionView::create_waves() called on " << this << endl;//DEBUG
|
2009-07-09 13:58:13 -04:00
|
|
|
RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2010-04-21 16:42:22 -04:00
|
|
|
if (!atv.track()) {
|
2006-07-23 08:03:19 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-04-21 16:42:22 -04:00
|
|
|
ChanCount nchans = atv.track()->n_channels();
|
2008-02-16 17:43:18 -05:00
|
|
|
|
2008-02-19 17:10:27 -05:00
|
|
|
// cerr << "creating waves for " << _region->name() << " with wfd = " << wait_for_data
|
|
|
|
// << " and channels = " << nchans.n_audio() << endl;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
/* in tmp_waves, set up null pointers for each channel so the vector is allocated */
|
2008-02-01 22:57:35 -05:00
|
|
|
for (uint32_t n = 0; n < nchans.n_audio(); ++n) {
|
2006-07-23 08:03:19 -04:00
|
|
|
tmp_waves.push_back (0);
|
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
|
2010-04-21 21:40:33 -04:00
|
|
|
for (vector<ScopedConnection*>::iterator i = _data_ready_connections.begin(); i != _data_ready_connections.end(); ++i) {
|
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
|
|
|
|
_data_ready_connections.clear ();
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < nchans.n_audio(); ++i) {
|
|
|
|
_data_ready_connections.push_back (0);
|
|
|
|
}
|
|
|
|
|
2008-02-01 22:57:35 -05:00
|
|
|
for (uint32_t n = 0; n < nchans.n_audio(); ++n) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
if (n >= audio_region()->n_channels()) {
|
2006-07-23 08:03:19 -04:00
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-02-19 17:10:27 -05:00
|
|
|
// cerr << "\tchannel " << n << endl;
|
2008-02-16 17:55:47 -05:00
|
|
|
|
2006-07-29 23:25:38 -04:00
|
|
|
if (wait_for_data) {
|
2010-04-21 21:40:33 -04:00
|
|
|
if (audio_region()->audio_source(n)->peaks_ready (boost::bind (&AudioRegionView::peaks_ready_handler, this, n), &_data_ready_connections[n], gui_context())) {
|
2008-09-10 11:03:30 -04:00
|
|
|
// cerr << "\tData is ready\n";
|
2008-02-16 17:43:18 -05:00
|
|
|
create_one_wave (n, true);
|
|
|
|
} else {
|
2008-02-19 17:10:27 -05:00
|
|
|
// cerr << "\tdata is not ready\n";
|
2008-02-16 17:43:18 -05:00
|
|
|
// we'll get a PeaksReady signal from the source in the future
|
|
|
|
// and will call create_one_wave(n) then.
|
2015-09-14 18:19:02 -04:00
|
|
|
pending_peak_data->show ();
|
2008-02-16 17:43:18 -05:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
} else {
|
2008-02-19 17:10:27 -05:00
|
|
|
// cerr << "\tdon't delay, display today!\n";
|
2006-07-23 08:03:19 -04:00
|
|
|
create_one_wave (n, true);
|
|
|
|
}
|
2008-02-01 22:57:35 -05:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
AudioRegionView::create_one_wave (uint32_t which, bool /*direct*/)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2008-02-01 22:57:35 -05:00
|
|
|
//cerr << "AudioRegionView::create_one_wave() called which: " << which << " this: " << this << endl;//DEBUG
|
2009-07-09 13:58:13 -04:00
|
|
|
RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
|
2015-09-06 06:39:53 -04:00
|
|
|
if (!trackview.session() || trackview.session()->deletion_in_progress () || !atv.track()) {
|
|
|
|
/* peaks_ready_handler() may be called from peak_thread_work() while
|
|
|
|
* session deletion is in progress.
|
|
|
|
* Since session-unload happens in the GUI thread, we need to test
|
|
|
|
* in this context.
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
2010-04-21 16:42:22 -04:00
|
|
|
uint32_t nchans = atv.track()->n_channels().n_audio();
|
2006-07-23 08:03:19 -04:00
|
|
|
uint32_t n;
|
2006-08-29 17:21:48 -04:00
|
|
|
uint32_t nwaves = std::min (nchans, audio_region()->n_channels());
|
2006-07-23 08:03:19 -04:00
|
|
|
gdouble ht;
|
|
|
|
|
2015-09-29 03:34:29 -04:00
|
|
|
/* compare to set_height(), use _height as set by streamview (child_height),
|
|
|
|
* not trackview.current_height() to take stacked layering into acconnt
|
|
|
|
*/
|
|
|
|
if (!UIConfiguration::instance().get_show_name_highlight() || (_height < NAME_HIGHLIGHT_THRESH)) {
|
|
|
|
ht = _height / (double) nchans;
|
2006-07-23 08:03:19 -04:00
|
|
|
} else {
|
2015-09-29 03:34:29 -04:00
|
|
|
ht = (_height - NAME_HIGHLIGHT_SIZE) / (double) nchans;
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
2015-06-19 08:15:25 -04:00
|
|
|
/* first waveview starts at 1.0, not 0.0 since that will overlap the
|
2015-10-04 14:51:05 -04:00
|
|
|
* frame
|
2015-06-19 08:15:25 -04:00
|
|
|
*/
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-09-04 10:14:01 -04:00
|
|
|
gdouble yoff = which * ht;
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
WaveView *wave = new WaveView (group, audio_region ());
|
2013-04-24 15:42:14 -04:00
|
|
|
CANVAS_DEBUG_NAME (wave, string_compose ("wave view for chn %1 of %2", which, get_item_name()));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
wave->set_channel (which);
|
|
|
|
wave->set_y_position (yoff);
|
|
|
|
wave->set_height (ht);
|
2013-04-12 11:31:50 -04:00
|
|
|
wave->set_samples_per_pixel (samples_per_pixel);
|
2014-02-14 14:03:07 -05:00
|
|
|
wave->set_show_zero_line (true);
|
2015-01-02 09:44:54 -05:00
|
|
|
wave->set_clip_level (UIConfiguration::instance().get_waveform_clip_level ());
|
2015-02-09 17:56:06 -05:00
|
|
|
wave->set_start_shift (1.0);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-06-18 10:24:59 -04:00
|
|
|
wave->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_wave_view_event), wave, this));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
switch (UIConfiguration::instance().get_waveform_shape()) {
|
2013-04-16 10:07:52 -04:00
|
|
|
case Rectified:
|
|
|
|
wave->set_shape (WaveView::Rectified);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
wave->set_shape (WaveView::Normal);
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
wave->set_logscaled (UIConfiguration::instance().get_waveform_scale() == Logarithmic);
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2014-06-19 15:06:48 -04:00
|
|
|
vector<ArdourCanvas::WaveView*> v;
|
|
|
|
v.push_back (wave);
|
|
|
|
set_some_waveform_colors (v);
|
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
if (!UIConfiguration::instance().get_show_waveforms ()) {
|
2006-07-23 08:03:19 -04:00
|
|
|
wave->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* note: calling this function is serialized by the lock
|
|
|
|
held in the peak building thread that signals that
|
|
|
|
peaks are ready for use *or* by the fact that it is
|
|
|
|
called one by one from the GUI thread.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (which < nchans) {
|
|
|
|
tmp_waves[which] = wave;
|
|
|
|
} else {
|
|
|
|
/* n-channel track, >n-channel source */
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
/* see if we're all ready */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (n = 0; n < nchans; ++n) {
|
|
|
|
if (tmp_waves[n] == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (n == nwaves && waves.empty()) {
|
|
|
|
/* all waves are ready */
|
|
|
|
tmp_waves.resize(nwaves);
|
|
|
|
|
|
|
|
waves = tmp_waves;
|
|
|
|
tmp_waves.clear ();
|
|
|
|
|
2015-09-14 18:19:02 -04:00
|
|
|
/* indicate peak-completed */
|
|
|
|
pending_peak_data->hide ();
|
2015-09-29 03:34:29 -04:00
|
|
|
|
|
|
|
/* Restore stacked coverage */
|
2016-08-30 08:29:58 -04:00
|
|
|
LayerDisplay layer_display;
|
|
|
|
if (trackview.get_gui_property ("layer-display", layer_display)) {
|
|
|
|
update_coverage_frames (layer_display);
|
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2015-09-06 06:56:50 -04:00
|
|
|
|
|
|
|
/* channel wave created, don't hook into peaks ready anymore */
|
|
|
|
delete _data_ready_connections[which];
|
|
|
|
_data_ready_connections[which] = 0;
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::peaks_ready_handler (uint32_t which)
|
|
|
|
{
|
2010-03-30 11:18:43 -04:00
|
|
|
Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&AudioRegionView::create_one_wave, this, which, false));
|
2008-02-16 17:43:18 -05:00
|
|
|
// cerr << "AudioRegionView::peaks_ready_handler() called on " << which << " this: " << this << endl;
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-02-20 14:01:40 -05:00
|
|
|
AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev, bool with_guard_points)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2012-03-09 16:22:09 -05:00
|
|
|
if (!gain_line) {
|
2006-07-23 08:03:19 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-30 06:14:16 -04:00
|
|
|
uint32_t before_p, after_p;
|
|
|
|
double mx = ev->button.x;
|
|
|
|
double my = ev->button.y;
|
|
|
|
|
|
|
|
item->canvas_to_item (mx, my);
|
|
|
|
|
|
|
|
framecnt_t const frame_within_region = (framecnt_t) floor (mx * samples_per_pixel);
|
|
|
|
|
|
|
|
if (!gain_line->control_points_adjacent (frame_within_region, before_p, after_p)) {
|
|
|
|
/* no adjacent points */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*y is in item frame */
|
|
|
|
double const bx = gain_line->nth (before_p)->get_x();
|
|
|
|
double const ax = gain_line->nth (after_p)->get_x();
|
|
|
|
double const click_ratio = (ax - mx) / (ax - bx);
|
|
|
|
|
|
|
|
double y = ((gain_line->nth (before_p)->get_y() * click_ratio) + (gain_line->nth (after_p)->get_y() * (1 - click_ratio)));
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
/* don't create points that can't be seen */
|
|
|
|
|
2012-05-29 14:38:54 -04:00
|
|
|
update_envelope_visibility ();
|
2015-10-04 11:54:18 -04:00
|
|
|
framepos_t rpos = region ()->position ();
|
2017-01-26 08:41:17 -05:00
|
|
|
MusicFrame snap_pos (trackview.editor().pixel_to_sample (mx) + rpos, 0);
|
|
|
|
trackview.editor ().snap_to_with_modifier (snap_pos, ev);
|
|
|
|
framepos_t fx = snap_pos.frame - rpos;
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
if (fx > _region->length()) {
|
2006-07-23 08:03:19 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compute vertical fractional position */
|
|
|
|
|
2015-10-30 06:14:16 -04:00
|
|
|
y = 1.0 - (y / (gain_line->height()));
|
2008-12-23 05:36:06 -05:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
/* map using gain line */
|
|
|
|
|
2015-10-30 06:14:16 -04:00
|
|
|
gain_line->view_to_model_coord (mx, y);
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
/* XXX STATEFUL: can't convert to stateful diff until we
|
2010-11-25 15:37:39 -05:00
|
|
|
can represent automation data with it.
|
|
|
|
*/
|
2010-03-02 13:05:26 -05:00
|
|
|
|
2007-06-29 00:02:58 -04:00
|
|
|
XMLNode &before = audio_region()->envelope()->get_state();
|
2015-09-13 15:24:28 -04:00
|
|
|
MementoCommand<AudioRegion>* region_memento = 0;
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
if (!audio_region()->envelope_active()) {
|
2006-11-19 11:45:16 -05:00
|
|
|
XMLNode ®ion_before = audio_region()->get_state();
|
2006-08-29 17:21:48 -04:00
|
|
|
audio_region()->set_envelope_active(true);
|
2006-11-19 11:45:16 -05:00
|
|
|
XMLNode ®ion_after = audio_region()->get_state();
|
2015-09-13 15:24:28 -04:00
|
|
|
region_memento = new MementoCommand<AudioRegion>(*(audio_region().get()), ®ion_before, ®ion_after);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
2015-09-13 15:24:28 -04:00
|
|
|
if (audio_region()->envelope()->editor_add (fx, y, with_guard_points)) {
|
|
|
|
XMLNode &after = audio_region()->envelope()->get_state();
|
|
|
|
std::list<Selectable*> results;
|
|
|
|
|
|
|
|
trackview.editor().begin_reversible_command (_("add gain control point"));
|
|
|
|
|
|
|
|
if (region_memento) {
|
|
|
|
trackview.session()->add_command (region_memento);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2015-09-13 15:24:28 -04:00
|
|
|
trackview.session()->add_command (new MementoCommand<AutomationList>(*audio_region()->envelope().get(), &before, &after));
|
|
|
|
|
2015-10-03 12:33:37 -04:00
|
|
|
gain_line->get_selectables (fx + region ()->position (), fx + region ()->position (), 0.0, 1.0, results);
|
2015-09-13 15:24:28 -04:00
|
|
|
trackview.editor ().get_selection ().set (results);
|
|
|
|
|
|
|
|
trackview.editor ().commit_reversible_command ();
|
|
|
|
trackview.session ()->set_dirty ();
|
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-10-03 04:12:02 -04:00
|
|
|
AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent* /*ev*/)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2007-07-06 23:19:04 -04:00
|
|
|
ControlPoint *cp = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
|
|
|
|
audio_region()->envelope()->erase (cp->model());
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
GhostRegion*
|
2009-07-09 13:58:13 -04:00
|
|
|
AudioRegionView::add_ghost (TimeAxisView& tv)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2009-07-09 13:58:13 -04:00
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview);
|
2016-06-02 08:42:58 -04:00
|
|
|
|
|
|
|
if (!rtv) {
|
|
|
|
return 0;
|
|
|
|
}
|
2006-08-01 22:44:23 -04:00
|
|
|
|
2013-04-12 11:31:50 -04:00
|
|
|
double unit_position = _region->position () / samples_per_pixel;
|
2015-10-22 07:56:02 -04:00
|
|
|
AudioGhostRegion* ghost = new AudioGhostRegion (*this, tv, trackview, unit_position);
|
2006-07-23 08:03:19 -04:00
|
|
|
uint32_t nchans;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-21 16:42:22 -04:00
|
|
|
nchans = rtv->track()->n_channels().n_audio();
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
for (uint32_t n = 0; n < nchans; ++n) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
if (n >= audio_region()->n_channels()) {
|
2006-07-23 08:03:19 -04:00
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
WaveView *wave = new WaveView (ghost->group, audio_region());
|
2013-04-24 15:42:14 -04:00
|
|
|
CANVAS_DEBUG_NAME (wave, string_compose ("ghost wave for %1", get_item_name()));
|
2008-02-10 13:16:25 -05:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
wave->set_channel (n);
|
2013-04-12 11:31:50 -04:00
|
|
|
wave->set_samples_per_pixel (samples_per_pixel);
|
2013-04-17 15:22:09 -04:00
|
|
|
wave->set_amplitude_above_axis (_amplitude_above_axis);
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
ghost->waves.push_back(wave);
|
|
|
|
}
|
|
|
|
|
|
|
|
ghost->set_height ();
|
2013-04-12 11:31:50 -04:00
|
|
|
ghost->set_duration (_region->length() / samples_per_pixel);
|
2008-02-10 13:16:25 -05:00
|
|
|
ghost->set_colors();
|
2006-07-23 08:03:19 -04:00
|
|
|
ghosts.push_back (ghost);
|
|
|
|
|
|
|
|
return ghost;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-12-08 23:00:00 -05:00
|
|
|
AudioRegionView::entered ()
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2010-11-25 15:37:39 -05:00
|
|
|
trackview.editor().set_current_trimmable (_region);
|
|
|
|
trackview.editor().set_current_movable (_region);
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2014-12-08 23:00:00 -05:00
|
|
|
update_envelope_visibility();
|
|
|
|
|
|
|
|
if ((trackview.editor().current_mouse_mode() == Editing::MouseObject)) {
|
2014-05-31 08:00:04 -04:00
|
|
|
if (start_xfade_rect) {
|
|
|
|
start_xfade_rect->set_outline (true);
|
|
|
|
}
|
|
|
|
if (end_xfade_rect) {
|
|
|
|
end_xfade_rect->set_outline (true);
|
|
|
|
}
|
2014-05-30 21:53:59 -04:00
|
|
|
if (fade_in_handle) {
|
|
|
|
fade_in_handle->show ();
|
|
|
|
fade_in_handle->raise_to_top ();
|
|
|
|
}
|
|
|
|
if (fade_out_handle) {
|
|
|
|
fade_out_handle->show ();
|
|
|
|
fade_out_handle->raise_to_top ();
|
|
|
|
}
|
|
|
|
if (fade_in_trim_handle) {
|
2014-05-31 09:15:46 -04:00
|
|
|
boost::shared_ptr<AudioRegion> ar (audio_region());
|
|
|
|
if (!ar->locked() && (ar->fade_in()->back()->when > 64 || (ar->can_trim() & Trimmable::FrontTrimEarlier))) {
|
|
|
|
fade_in_trim_handle->show ();
|
|
|
|
fade_in_trim_handle->raise_to_top ();
|
|
|
|
} else {
|
|
|
|
fade_in_trim_handle->hide ();
|
|
|
|
}
|
2014-05-30 21:53:59 -04:00
|
|
|
}
|
|
|
|
if (fade_out_trim_handle) {
|
2014-05-31 09:15:46 -04:00
|
|
|
boost::shared_ptr<AudioRegion> ar (audio_region());
|
|
|
|
if (!ar->locked() && (ar->fade_out()->back()->when > 64 || (ar->can_trim() & Trimmable::EndTrimLater))) {
|
|
|
|
fade_out_trim_handle->show ();
|
|
|
|
fade_out_trim_handle->raise_to_top ();
|
|
|
|
} else {
|
|
|
|
fade_out_trim_handle->hide ();
|
|
|
|
}
|
2014-05-30 21:53:59 -04:00
|
|
|
}
|
2015-06-01 14:12:39 -04:00
|
|
|
} else { //this happens when we switch tools; if we switch away from Grab mode, hide all the fade handles
|
|
|
|
if (fade_in_handle) { fade_in_handle->hide(); }
|
|
|
|
if (fade_out_handle) { fade_out_handle->hide(); }
|
|
|
|
if (fade_in_trim_handle) { fade_in_trim_handle->hide(); }
|
|
|
|
if (fade_out_trim_handle) { fade_out_trim_handle->hide(); }
|
|
|
|
if (start_xfade_rect) { start_xfade_rect->set_outline (false); }
|
|
|
|
if (end_xfade_rect) { end_xfade_rect->set_outline (false); }
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::exited ()
|
|
|
|
{
|
2010-11-25 15:37:39 -05:00
|
|
|
trackview.editor().set_current_trimmable (boost::shared_ptr<Trimmable>());
|
|
|
|
trackview.editor().set_current_movable (boost::shared_ptr<Movable>());
|
2010-09-22 11:21:06 -04:00
|
|
|
|
2015-05-26 17:41:03 -04:00
|
|
|
// if (gain_line) {
|
|
|
|
// gain_line->remove_visibility (AutomationLine::ControlPoints);
|
|
|
|
// }
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-05-30 21:53:59 -04:00
|
|
|
if (fade_in_handle) { fade_in_handle->hide(); }
|
|
|
|
if (fade_out_handle) { fade_out_handle->hide(); }
|
|
|
|
if (fade_in_trim_handle) { fade_in_trim_handle->hide(); }
|
|
|
|
if (fade_out_trim_handle) { fade_out_trim_handle->hide(); }
|
2014-05-31 08:00:04 -04:00
|
|
|
if (start_xfade_rect) { start_xfade_rect->set_outline (false); }
|
|
|
|
if (end_xfade_rect) { end_xfade_rect->set_outline (false); }
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::envelope_active_changed ()
|
|
|
|
{
|
|
|
|
if (gain_line) {
|
2015-10-04 14:51:05 -04:00
|
|
|
gain_line->set_line_color (audio_region()->envelope_active() ?
|
|
|
|
UIConfiguration::instance().color ("gain line") :
|
2015-01-02 09:44:54 -05:00
|
|
|
UIConfiguration::instance().color_mod ("gain line inactive", "gain line inactive"));
|
2014-02-25 11:35:55 -05:00
|
|
|
update_envelope_visibility ();
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-06-15 18:08:27 -04:00
|
|
|
AudioRegionView::color_handler ()
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2007-06-15 18:08:27 -04:00
|
|
|
//case cMutedWaveForm:
|
|
|
|
//case cWaveForm:
|
|
|
|
//case cWaveFormClip:
|
|
|
|
//case cZeroLine:
|
|
|
|
set_colors ();
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2007-06-15 18:08:27 -04:00
|
|
|
//case cGainLineInactive:
|
|
|
|
//case cGainLine:
|
|
|
|
envelope_active_changed();
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
}
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
void
|
2013-04-24 15:42:14 -04:00
|
|
|
AudioRegionView::set_waveform_colors ()
|
2014-06-19 15:06:48 -04:00
|
|
|
{
|
|
|
|
set_some_waveform_colors (waves);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::set_some_waveform_colors (vector<ArdourCanvas::WaveView*>& waves_to_color)
|
2013-06-28 11:31:26 -04:00
|
|
|
{
|
|
|
|
ArdourCanvas::Color fill;
|
|
|
|
ArdourCanvas::Color outline;
|
2015-01-02 09:44:54 -05:00
|
|
|
ArdourCanvas::Color clip = UIConfiguration::instance().color ("clipped waveform");
|
|
|
|
ArdourCanvas::Color zero = UIConfiguration::instance().color ("zero line");
|
2014-06-05 14:07:26 -04:00
|
|
|
|
2013-06-28 20:21:30 -04:00
|
|
|
if (_selected) {
|
|
|
|
if (_region->muted()) {
|
2014-01-26 16:03:04 -05:00
|
|
|
/* hide outline with zero alpha */
|
2015-01-02 09:44:54 -05:00
|
|
|
outline = UINT_RGBA_CHANGE_A(UIConfiguration::instance().color ("selected waveform outline"), 0);
|
|
|
|
fill = UINT_RGBA_CHANGE_A(UIConfiguration::instance().color ("selected waveform fill"), MUTED_ALPHA);
|
2013-06-28 20:21:30 -04:00
|
|
|
} else {
|
2015-01-02 09:44:54 -05:00
|
|
|
outline = UIConfiguration::instance().color ("selected waveform outline");
|
|
|
|
fill = UIConfiguration::instance().color ("selected waveform fill");
|
2013-06-28 20:21:30 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (_recregion) {
|
2015-01-02 09:44:54 -05:00
|
|
|
outline = UIConfiguration::instance().color ("recording waveform outline");
|
|
|
|
fill = UIConfiguration::instance().color ("recording waveform fill");
|
2013-06-28 20:21:30 -04:00
|
|
|
} else {
|
|
|
|
if (_region->muted()) {
|
2014-01-26 16:03:04 -05:00
|
|
|
/* hide outline with zero alpha */
|
2015-10-05 10:17:49 -04:00
|
|
|
outline = UINT_RGBA_CHANGE_A(UIConfiguration::instance().color ("waveform outline"), 0);
|
2015-01-02 09:44:54 -05:00
|
|
|
fill = UINT_RGBA_CHANGE_A(UIConfiguration::instance().color ("waveform fill"), MUTED_ALPHA);
|
2013-06-28 20:21:30 -04:00
|
|
|
} else {
|
2015-01-02 09:44:54 -05:00
|
|
|
outline = UIConfiguration::instance().color ("waveform outline");
|
|
|
|
fill = UIConfiguration::instance().color ("waveform fill");
|
2013-06-28 20:21:30 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-04-24 15:42:14 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
for (vector<ArdourCanvas::WaveView*>::iterator w = waves_to_color.begin(); w != waves_to_color.end(); ++w) {
|
2014-06-05 14:12:40 -04:00
|
|
|
(*w)->set_fill_color (fill);
|
|
|
|
(*w)->set_outline_color (outline);
|
|
|
|
(*w)->set_clip_color (clip);
|
|
|
|
(*w)->set_zero_color (zero);
|
|
|
|
}
|
2013-04-24 15:42:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::set_frame_color ()
|
|
|
|
{
|
|
|
|
if (!frame) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-05 14:07:26 -04:00
|
|
|
RegionView::set_frame_color ();
|
2013-04-24 15:42:14 -04:00
|
|
|
|
|
|
|
set_waveform_colors ();
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2008-10-09 17:55:05 -04:00
|
|
|
void
|
|
|
|
AudioRegionView::set_fade_visibility (bool yn)
|
|
|
|
{
|
|
|
|
if (yn) {
|
2014-05-31 08:16:15 -04:00
|
|
|
if (start_xfade_curve) { start_xfade_curve->show (); }
|
|
|
|
if (end_xfade_curve) { end_xfade_curve->show (); }
|
|
|
|
if (start_xfade_rect) { start_xfade_rect->show (); }
|
|
|
|
if (end_xfade_rect) { end_xfade_rect->show (); }
|
|
|
|
} else {
|
|
|
|
if (start_xfade_curve) { start_xfade_curve->hide(); }
|
|
|
|
if (end_xfade_curve) { end_xfade_curve->hide(); }
|
2014-05-30 21:53:59 -04:00
|
|
|
if (fade_in_handle) { fade_in_handle->hide(); }
|
|
|
|
if (fade_out_handle) { fade_out_handle->hide(); }
|
|
|
|
if (fade_in_trim_handle) { fade_in_trim_handle->hide(); }
|
|
|
|
if (fade_out_trim_handle) { fade_out_trim_handle->hide(); }
|
2014-05-31 08:16:15 -04:00
|
|
|
if (start_xfade_rect) { start_xfade_rect->hide (); }
|
|
|
|
if (end_xfade_rect) { end_xfade_rect->hide (); }
|
2014-05-31 08:00:04 -04:00
|
|
|
if (start_xfade_rect) { start_xfade_rect->set_outline (false); }
|
|
|
|
if (end_xfade_rect) { end_xfade_rect->set_outline (false); }
|
2008-10-09 17:55:05 -04:00
|
|
|
}
|
|
|
|
}
|
2009-08-25 17:53:21 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::update_coverage_frames (LayerDisplay d)
|
|
|
|
{
|
|
|
|
RegionView::update_coverage_frames (d);
|
|
|
|
|
2017-01-11 06:42:37 -05:00
|
|
|
if (d == Stacked) {
|
|
|
|
if (fade_in_handle) { fade_in_handle->raise_to_top (); }
|
|
|
|
if (fade_out_handle) { fade_out_handle->raise_to_top (); }
|
|
|
|
if (fade_in_trim_handle) { fade_in_trim_handle->raise_to_top (); }
|
|
|
|
if (fade_out_trim_handle) { fade_out_trim_handle->raise_to_top (); }
|
|
|
|
}
|
2009-08-25 17:53:21 -04:00
|
|
|
}
|
2010-05-21 20:26:26 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::show_region_editor ()
|
|
|
|
{
|
|
|
|
if (editor == 0) {
|
|
|
|
editor = new AudioRegionEditor (trackview.session(), audio_region());
|
|
|
|
}
|
|
|
|
|
|
|
|
editor->present ();
|
|
|
|
editor->show_all();
|
|
|
|
}
|
2010-07-06 07:33:27 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::transients_changed ()
|
|
|
|
{
|
2016-04-30 20:02:25 -04:00
|
|
|
AnalysisFeatureList analysis_features;
|
|
|
|
_region->transients (analysis_features);
|
|
|
|
framepos_t position = _region->position();
|
|
|
|
framepos_t first = _region->first_frame();
|
|
|
|
framepos_t last = _region->last_frame();
|
2010-07-06 07:33:27 -04:00
|
|
|
|
2016-04-30 20:02:25 -04:00
|
|
|
double y1;
|
|
|
|
if (_height >= NAME_HIGHLIGHT_THRESH) {
|
|
|
|
y1 = _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1;
|
|
|
|
} else {
|
|
|
|
y1 = _height - 1;
|
|
|
|
}
|
2011-02-14 16:49:43 -05:00
|
|
|
|
2016-04-30 20:02:25 -04:00
|
|
|
while (feature_lines.size() < analysis_features.size()) {
|
2013-04-04 00:32:52 -04:00
|
|
|
ArdourCanvas::Line* canvas_item = new ArdourCanvas::Line(group);
|
2013-04-24 15:42:14 -04:00
|
|
|
CANVAS_DEBUG_NAME (canvas_item, string_compose ("transient group for %1", region()->name()));
|
2016-04-30 20:02:25 -04:00
|
|
|
canvas_item->set_outline_color (UIConfiguration::instance().color ("zero line")); // also in Editor::leave_handler()
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
canvas_item->set (ArdourCanvas::Duple (-1.0, 2.0),
|
2016-04-30 20:02:25 -04:00
|
|
|
ArdourCanvas::Duple (1.0, y1));
|
2011-02-14 16:49:43 -05:00
|
|
|
|
|
|
|
canvas_item->raise_to_top ();
|
|
|
|
canvas_item->show ();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-02-14 16:49:43 -05:00
|
|
|
canvas_item->set_data ("regionview", this);
|
2013-04-04 18:45:27 -04:00
|
|
|
canvas_item->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_feature_line_event), canvas_item, this));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
|
|
|
feature_lines.push_back (make_pair(0, canvas_item));
|
2010-07-06 07:33:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
while (feature_lines.size() > analysis_features.size()) {
|
2011-02-14 16:49:43 -05:00
|
|
|
ArdourCanvas::Line* line = feature_lines.back().second;
|
2010-07-06 07:33:27 -04:00
|
|
|
feature_lines.pop_back ();
|
|
|
|
delete line;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnalysisFeatureList::const_iterator i;
|
2011-02-14 16:49:43 -05:00
|
|
|
list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-07-06 07:33:27 -04:00
|
|
|
for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) {
|
2011-02-14 16:49:43 -05:00
|
|
|
|
|
|
|
float *pos = new float;
|
2016-04-30 20:02:25 -04:00
|
|
|
*pos = trackview.editor().sample_to_pixel (*i - position);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
(*l).second->set (
|
|
|
|
ArdourCanvas::Duple (*pos, 2.0),
|
2016-04-30 20:02:25 -04:00
|
|
|
ArdourCanvas::Duple (*pos, y1)
|
2013-04-04 00:32:52 -04:00
|
|
|
);
|
2011-02-14 16:49:43 -05:00
|
|
|
|
2016-04-30 20:02:25 -04:00
|
|
|
(*l).second->set_data ("position", pos); // is this *modified* (drag?), if not use *i
|
2011-02-14 16:49:43 -05:00
|
|
|
(*l).first = *i;
|
2016-04-30 20:02:25 -04:00
|
|
|
|
|
|
|
if (l->first < first || l->first >= last) {
|
|
|
|
l->second->hide();
|
|
|
|
} else {
|
|
|
|
l->second->show();
|
|
|
|
}
|
2010-07-06 07:33:27 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-09-02 13:01:36 -04:00
|
|
|
AudioRegionView::update_transient(float /*old_pos*/, float new_pos)
|
2010-07-06 07:33:27 -04:00
|
|
|
{
|
|
|
|
/* Find frame at old pos, calulate new frame then update region transients*/
|
2011-02-14 16:49:43 -05:00
|
|
|
list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
|
2010-07-06 07:33:27 -04:00
|
|
|
|
|
|
|
for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
|
2011-02-14 16:49:43 -05:00
|
|
|
|
|
|
|
/* Line has been updated in drag so we compare to new_pos */
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-02-14 16:49:43 -05:00
|
|
|
float* pos = (float*) (*l).second->get_data ("position");
|
2011-06-01 13:00:29 -04:00
|
|
|
|
|
|
|
if (rint(new_pos) == rint(*pos)) {
|
2017-07-01 12:42:24 -04:00
|
|
|
framepos_t position = _region->position();
|
|
|
|
framepos_t old_frame = (*l).first;
|
|
|
|
framepos_t new_frame = trackview.editor().pixel_to_sample (new_pos) + position;
|
|
|
|
_region->update_transient (old_frame, new_frame);
|
|
|
|
break;
|
2010-07-06 07:33:27 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-04-30 20:02:25 -04:00
|
|
|
AudioRegionView::remove_transient (float pos)
|
2010-07-06 07:33:27 -04:00
|
|
|
{
|
2016-04-30 20:02:25 -04:00
|
|
|
/* this is called from Editor::remove_transient () with pos == get_data ("position")
|
|
|
|
* which is the item's x-coordinate inside the ARV.
|
|
|
|
*
|
|
|
|
* Find frame at old pos, calulate new frame then update region transients
|
|
|
|
*/
|
2011-02-14 16:49:43 -05:00
|
|
|
list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
|
2010-07-06 07:33:27 -04:00
|
|
|
|
|
|
|
for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
|
2011-02-14 16:49:43 -05:00
|
|
|
float *line_pos = (float*) (*l).second->get_data ("position");
|
|
|
|
if (rint(pos) == rint(*line_pos)) {
|
2017-07-01 12:42:24 -04:00
|
|
|
_region->remove_transient ((*l).first);
|
|
|
|
break;
|
2010-07-06 07:33:27 -04:00
|
|
|
}
|
|
|
|
}
|
2010-07-16 17:12:06 -04:00
|
|
|
}
|
2010-11-08 20:58:12 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::thaw_after_trim ()
|
|
|
|
{
|
|
|
|
RegionView::thaw_after_trim ();
|
|
|
|
unhide_envelope ();
|
2012-05-10 09:48:23 -04:00
|
|
|
drag_end ();
|
2010-11-08 20:58:12 -05:00
|
|
|
}
|
2012-04-30 23:22:04 -04:00
|
|
|
|
2012-07-04 17:09:32 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::show_xfades ()
|
|
|
|
{
|
|
|
|
show_start_xfade ();
|
|
|
|
show_end_xfade ();
|
2012-05-07 18:02:17 -04:00
|
|
|
}
|
2012-05-09 20:46:22 -04:00
|
|
|
|
2012-05-10 09:48:23 -04:00
|
|
|
void
|
|
|
|
AudioRegionView::drag_start ()
|
|
|
|
{
|
|
|
|
TimeAxisViewItem::drag_start ();
|
|
|
|
|
2012-12-13 11:42:05 -05:00
|
|
|
//we used to hide xfades here. I don't see the point with the new model, but we can re-implement if needed
|
2012-05-10 09:48:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionView::drag_end ()
|
|
|
|
{
|
|
|
|
TimeAxisViewItem::drag_end ();
|
2012-12-13 11:42:05 -05:00
|
|
|
//see comment for drag_start
|
2014-05-31 09:15:46 -04:00
|
|
|
|
|
|
|
if (fade_in_handle && fade_in_handle->visible()) {
|
|
|
|
// lenght of region or fade changed, re-check
|
|
|
|
// if fade_in_trim_handle or fade_out_trim_handle should
|
|
|
|
// be visible. -- If the fade_in_handle is visible
|
|
|
|
// we have focus and are not in internal edit mode.
|
2014-12-08 23:00:00 -05:00
|
|
|
entered();
|
2014-05-31 09:15:46 -04:00
|
|
|
}
|
2012-05-10 09:48:23 -04:00
|
|
|
}
|
|
|
|
|
2012-06-17 07:48:51 -04:00
|
|
|
void
|
|
|
|
AudioRegionView::parameter_changed (string const & p)
|
|
|
|
{
|
|
|
|
if (p == "show-waveforms") {
|
|
|
|
setup_waveform_visibility ();
|
|
|
|
}
|
|
|
|
}
|