#include <cassert>
#include <algorithm>
+#include <boost/scoped_array.hpp>
#include <boost/scoped_ptr.hpp>
#include <gtkmm.h>
using namespace ArdourCanvas;
static const int32_t sync_mark_width = 9;
+static double const handle_size = 6; /* height of fade handles */
AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
Gdk::Color const & basic_color)
, start_xfade_in (0)
, start_xfade_out (0)
, start_xfade_rect (0)
+ , _start_xfade_visible (false)
, end_xfade_in (0)
, end_xfade_out (0)
, end_xfade_rect (0)
+ , _end_xfade_visible (false)
, _amplitude_above_axis(1.0)
- , _flags(0)
, fade_color(0)
{
+ Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&AudioRegionView::parameter_changed, this, _1), gui_context());
}
AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
, start_xfade_in (0)
, start_xfade_out (0)
, start_xfade_rect (0)
+ , _start_xfade_visible (false)
, end_xfade_in (0)
, end_xfade_out (0)
, end_xfade_rect (0)
+ , _end_xfade_visible (false)
, _amplitude_above_axis(1.0)
- , _flags(0)
, fade_color(0)
{
+ Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&AudioRegionView::parameter_changed, this, _1), gui_context());
}
AudioRegionView::AudioRegionView (const AudioRegionView& other, boost::shared_ptr<AudioRegion> other_region)
, start_xfade_in (0)
, start_xfade_out (0)
, start_xfade_rect (0)
+ , _start_xfade_visible (false)
, end_xfade_in (0)
, end_xfade_out (0)
, end_xfade_rect (0)
+ , _end_xfade_visible (false)
, _amplitude_above_axis (other._amplitude_above_axis)
- , _flags (other._flags)
, fade_color(0)
{
Gdk::Color c;
c.set_rgb_p (r/255.0, g/255.0, b/255.0);
init (c, true);
+
+ Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&AudioRegionView::parameter_changed, this, _1), gui_context());
}
void
RegionView::init (basic_color, wfd);
- XMLNode *node;
-
_amplitude_above_axis = 1.0;
- _flags = 0;
-
- if ((node = _region->extra_xml ("GUI")) != 0) {
- set_flags (node);
- } else {
- _flags = WaveformVisible;
- store_flags ();
- }
compute_colors (basic_color);
if (!_recregion) {
fade_in_handle = new ArdourCanvas::SimpleRect (*group);
fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fill_color, 0);
- fade_in_handle->property_outline_pixels() = 0;
+ fade_in_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 0);
fade_in_handle->set_data ("regionview", this);
fade_out_handle = new ArdourCanvas::SimpleRect (*group);
fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fill_color, 0);
- fade_out_handle->property_outline_pixels() = 0;
+ fade_out_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 0);
fade_out_handle->set_data ("regionview", this);
set_colors ();
+ setup_waveform_visibility ();
+ setup_waveform_shape ();
+ setup_waveform_scale ();
+
/* XXX sync mark drag? */
}
AudioRegionView::region_changed (const PropertyChange& what_changed)
{
ENSURE_GUI_THREAD (*this, &AudioRegionView::region_changed, what_changed);
- // cerr << "AudioRegionView::region_changed() called" << endl;
RegionView::region_changed (what_changed);
if (what_changed.contains (ARDOUR::Properties::fade_out_active)) {
fade_out_active_changed ();
}
+ if (what_changed.contains (ARDOUR::Properties::fade_in_is_xfade)) {
+ fade_in_changed ();
+ }
+ if (what_changed.contains (ARDOUR::Properties::fade_out_is_xfade)) {
+ fade_out_changed ();
+ }
if (what_changed.contains (ARDOUR::Properties::envelope_active)) {
envelope_active_changed ();
}
{
/* position of fade handle offset from the top of the region view */
double const handle_pos = 2;
- /* height of fade handles */
- double const handle_height = 5;
if (fade_in_handle) {
fade_in_handle->property_y1() = handle_pos;
- fade_in_handle->property_y2() = handle_pos + handle_height;
+ fade_in_handle->property_y2() = handle_pos + handle_size;
}
if (fade_out_handle) {
fade_out_handle->property_y1() = handle_pos;
- fade_out_handle->property_y2() = handle_pos + handle_height;
+ fade_out_handle->property_y2() = handle_pos + handle_size;
}
}
start_xfade_in->hide ();
start_xfade_out->hide ();
start_xfade_rect->hide ();
+ _start_xfade_visible = false;
}
}
/* Put the fade in handle so that its left side is at the end-of-fade line */
fade_in_handle->property_x1() = handle_center;
- fade_in_handle->property_x2() = handle_center + 6;
+ fade_in_handle->property_x2() = handle_center + handle_size;
if (pwidth < 5) {
fade_in_shape->hide();
void
AudioRegionView::reset_fade_out_shape_width (framecnt_t width)
{
- if (dragging()) {
+ if (dragging() && audio_region()->fade_out_is_xfade()) {
+ /* we hide xfades while dragging regions */
return;
}
end_xfade_in->hide ();
end_xfade_out->hide ();
end_xfade_rect->hide ();
+ _end_xfade_visible = false;
}
}
}
}
+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;
+}
+
+
void
AudioRegionView::set_samples_per_unit (gdouble spu)
{
RegionView::set_samples_per_unit (spu);
- if (_flags & WaveformVisible) {
- for (uint32_t n=0; n < waves.size(); ++n) {
+ if (Config->get_show_waveforms ()) {
+ for (uint32_t n = 0; n < waves.size(); ++n) {
waves[n]->property_samples_per_unit() = spu;
}
}
}
void
-AudioRegionView::set_waveform_visible (bool yn)
-{
- if (((_flags & WaveformVisible) != yn)) {
- if (yn) {
- 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.
- */
- waves[n]->property_samples_per_unit() = samples_per_unit;
- waves[n]->show();
- }
- _flags |= WaveformVisible;
- } else {
- for (uint32_t n=0; n < waves.size(); ++n) {
- waves[n]->hide();
- }
- _flags &= ~WaveformVisible;
+AudioRegionView::setup_waveform_visibility ()
+{
+ if (Config->get_show_waveforms ()) {
+ 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.
+ */
+ waves[n]->property_samples_per_unit() = samples_per_unit;
+ waves[n]->show();
+ }
+ } else {
+ for (uint32_t n = 0; n < waves.size(); ++n) {
+ waves[n]->hide();
}
- store_flags ();
}
}
wave->property_zero_color() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
wave->property_zero_line() = true;
wave->property_region_start() = _region->start();
- wave->property_rectified() = (bool) (_flags & WaveformRectified);
- wave->property_logscaled() = (bool) (_flags & WaveformLogScaled);
+ wave->property_rectified() = Config->get_waveform_shape() == Rectified;
+ wave->property_logscaled() = Config->get_waveform_scale() == Logarithmic;
- if (!(_flags & WaveformVisible)) {
+ if (!Config->get_show_waveforms ()) {
wave->hide();
}
}
void
-AudioRegionView::store_flags()
-{
- XMLNode *node = new XMLNode ("GUI");
-
- node->add_property ("waveform-visible", (_flags & WaveformVisible) ? "yes" : "no");
- node->add_property ("waveform-rectified", (_flags & WaveformRectified) ? "yes" : "no");
- node->add_property ("waveform-logscaled", (_flags & WaveformLogScaled) ? "yes" : "no");
-
- _region->add_extra_xml (*node);
-}
-
-void
-AudioRegionView::set_flags (XMLNode* node)
+AudioRegionView::setup_waveform_shape ()
{
- XMLProperty *prop;
-
- if ((prop = node->property ("waveform-visible")) != 0) {
- if (string_is_affirmative (prop->value())) {
- _flags |= WaveformVisible;
- }
- }
-
- if ((prop = node->property ("waveform-rectified")) != 0) {
- if (string_is_affirmative (prop->value())) {
- _flags |= WaveformRectified;
- }
- }
-
- if ((prop = node->property ("waveform-logscaled")) != 0) {
- if (string_is_affirmative (prop->value())) {
- _flags |= WaveformLogScaled;
- }
- }
-}
-
-void
-AudioRegionView::set_waveform_shape (WaveformShape shape)
-{
- bool yn;
-
- /* this slightly odd approach is to leave the door open to
- other "shapes" such as spectral displays, etc.
- */
-
- switch (shape) {
- case Rectified:
- yn = true;
- break;
-
- default:
- yn = false;
- break;
- }
-
- if (yn != (bool) (_flags & WaveformRectified)) {
- for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
- (*wave)->property_rectified() = yn;
- }
-
- if (yn) {
- _flags |= WaveformRectified;
- } else {
- _flags &= ~WaveformRectified;
- }
- store_flags ();
+ for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
+ (*wave)->property_rectified() = Config->get_waveform_shape() == Rectified;
}
}
void
-AudioRegionView::set_waveform_scale (WaveformScale scale)
+AudioRegionView::setup_waveform_scale ()
{
- bool yn = (scale == Logarithmic);
-
- if (yn != (bool) (_flags & WaveformLogScaled)) {
- for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
- (*wave)->property_logscaled() = yn;
- }
-
- if (yn) {
- _flags |= WaveformLogScaled;
- } else {
- _flags &= ~WaveformLogScaled;
- }
- store_flags ();
+ for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
+ (*wave)->property_logscaled() = Config->get_waveform_scale() == Logarithmic;
}
}
}
if (fade_in_handle && !internal_editing) {
+ fade_in_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 255);
fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 255);
+ fade_out_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 255);
fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 255);
}
}
}
if (fade_in_handle) {
+ fade_in_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 0);
fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 0);
+ fade_out_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 0);
fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 0);
}
}
start_xfade_in->hide ();
start_xfade_out->hide ();
start_xfade_rect->hide ();
+ _start_xfade_visible = false;
}
return;
}
}
Points* points = get_canvas_points ("xfade edit redraw", npoints);
- boost::scoped_ptr<float> vec (new float[npoints]);
+ boost::scoped_array<float> vec (new float[npoints]);
double effective_height = _height - NAME_HIGHLIGHT_SIZE - 1.0;
ar->fade_in()->curve().get_vector (0, ar->fade_in()->back()->when, vec.get(), npoints);
start_xfade_out->show ();
start_xfade_out->raise_to_top ();
+ _start_xfade_visible = true;
+
delete points;
}
end_xfade_in->hide ();
end_xfade_out->hide ();
end_xfade_rect->hide ();
+ _end_xfade_visible = false;
}
return;
}
end_xfade_out->show ();
end_xfade_out->raise_to_top ();
+ _end_xfade_visible = true;
delete points;
}
void
AudioRegionView::hide_xfades ()
+{
+ hide_start_xfade ();
+ hide_end_xfade ();
+}
+
+void
+AudioRegionView::hide_start_xfade ()
{
if (start_xfade_in) {
start_xfade_in->hide();
if (start_xfade_rect) {
start_xfade_rect->hide ();
}
+
+ _start_xfade_visible = false;
+}
+
+void
+AudioRegionView::hide_end_xfade ()
+{
if (end_xfade_in) {
end_xfade_in->hide();
}
if (end_xfade_rect) {
end_xfade_rect->hide ();
}
+
+ _end_xfade_visible = false;
}
void
-AudioRegionView::show_xfades ()
+AudioRegionView::show_start_xfade ()
{
if (start_xfade_in) {
start_xfade_in->show();
if (start_xfade_rect) {
start_xfade_rect->show ();
}
+
+ _start_xfade_visible = true;
+}
+
+void
+AudioRegionView::show_end_xfade ()
+{
if (end_xfade_in) {
end_xfade_in->show();
}
if (end_xfade_rect) {
end_xfade_rect->show ();
}
+
+ _end_xfade_visible = true;
+}
+
+void
+AudioRegionView::show_xfades ()
+{
+ show_start_xfade ();
+ show_end_xfade ();
}
void
AudioStreamView* av = atav->audio_view();
if (av) {
/* this will hide our xfades too */
- av->hide_xfades_with (audio_region());
+ _hidden_xfades = av->hide_xfades_with (audio_region());
}
}
}
AudioRegionView::drag_end ()
{
TimeAxisViewItem::drag_end ();
- /* fades will be redrawn if they changed */
+
+ for (list<AudioRegionView*>::iterator i = _hidden_xfades.first.begin(); i != _hidden_xfades.first.end(); ++i) {
+ (*i)->show_start_xfade ();
+ }
+
+ for (list<AudioRegionView*>::iterator i = _hidden_xfades.second.begin(); i != _hidden_xfades.second.end(); ++i) {
+ (*i)->show_end_xfade ();
+ }
+
+ _hidden_xfades.first.clear ();
+ _hidden_xfades.second.clear ();
}
+void
+AudioRegionView::parameter_changed (string const & p)
+{
+ if (p == "show-waveforms") {
+ setup_waveform_visibility ();
+ } else if (p == "waveform-scale") {
+ setup_waveform_scale ();
+ } else if (p == "waveform-shape") {
+ setup_waveform_shape ();
+ }
+}