#include "waveview.h"
#include "public_editor.h"
#include "audio_region_editor.h"
+#include "audio_streamview.h"
#include "region_gain_line.h"
#include "control_point.h"
#include "ghostregion.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);
if (!Profile->get_sae()) {
gain_line.reset (new AudioRegionGainLine (line_name, *this, *group, audio_region()->envelope()));
}
-
- if (Config->get_show_region_gain()) {
- gain_line->show ();
- } else {
- gain_line->hide ();
- }
-
+
+ update_envelope_visibility ();
gain_line->reset ();
set_height (trackview.current_height());
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;
+ cerr << "AudioRegionView::region_changed() called" << endl;
RegionView::region_changed (what_changed);
region_scale_amplitude_changed ();
}
if (what_changed.contains (ARDOUR::Properties::fade_in)) {
+ cerr << region()->name() << " in changed\n";
+ stacktrace (cerr, 40);
fade_in_changed ();
}
if (what_changed.contains (ARDOUR::Properties::fade_out)) {
+ cerr << region()->name() << " out changed\n";
fade_out_changed ();
}
if (what_changed.contains (ARDOUR::Properties::fade_in_active)) {
+ cerr << region()->name() << " in active changed\n";
fade_in_active_changed ();
}
if (what_changed.contains (ARDOUR::Properties::fade_out_active)) {
+ cerr << region()->name() << " out active changed\n";
fade_out_active_changed ();
}
+ if (what_changed.contains (ARDOUR::Properties::fade_in_is_xfade)) {
+ cerr << region()->name() << " in is xfade changed\n";
+ fade_in_changed ();
+ }
+ if (what_changed.contains (ARDOUR::Properties::fade_out_is_xfade)) {
+ cerr << region()->name() << " out is xfade changed\n";
+ fade_out_changed ();
+ }
if (what_changed.contains (ARDOUR::Properties::envelope_active)) {
envelope_active_changed ();
}
{
reset_fade_out_shape ();
}
+
void
AudioRegionView::fade_in_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;
}
}
if ((height/wcnt) < NAME_HIGHLIGHT_THRESH) {
gain_line->hide ();
} else {
- if (Config->get_show_region_gain ()) {
- gain_line->show ();
- }
+ update_envelope_visibility ();
}
gain_line->set_height ((uint32_t) rint (height - NAME_HIGHLIGHT_SIZE) - 2);
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;
}
}
{
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 ();
}
}
void
AudioRegionView::unhide_envelope ()
{
- if (gain_line) {
- gain_line->show ();
- }
+ update_envelope_visibility ();
}
void
-AudioRegionView::set_envelope_visible (bool yn)
+AudioRegionView::update_envelope_visibility ()
{
- if (gain_line) {
- if (yn) {
- gain_line->show ();
- } else {
- gain_line->hide ();
- }
+ if (!gain_line) {
+ return;
+ }
+
+ if (Config->get_show_region_gain() || trackview.editor().current_mouse_mode() == Editing::MouseGain) {
+ gain_line->add_visibility (AutomationLine::Line);
+ } else {
+ gain_line->hide ();
}
}
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();
}
/* don't create points that can't be seen */
- set_envelope_visible (true);
+ update_envelope_visibility ();
x = ev->button.x;
y = ev->button.y;
}
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;
- }
+ for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
+ (*wave)->property_rectified() = Config->get_waveform_shape() == Rectified;
}
}
void
-AudioRegionView::set_waveform_shape (WaveformShape shape)
+AudioRegionView::setup_waveform_scale ()
{
- 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 ();
- }
-}
-
-void
-AudioRegionView::set_waveform_scale (WaveformScale 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;
}
}
{
trackview.editor().set_current_trimmable (_region);
trackview.editor().set_current_movable (_region);
-
- if (gain_line && Config->get_show_region_gain ()) {
- gain_line->show_all_control_points ();
+
+ if (gain_line && trackview.editor().current_mouse_mode() == Editing::MouseGain) {
+ gain_line->add_visibility (AutomationLine::ControlPoints);
}
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);
}
}
trackview.editor().set_current_trimmable (boost::shared_ptr<Trimmable>());
trackview.editor().set_current_movable (boost::shared_ptr<Movable>());
- if (gain_line) {
- gain_line->hide_all_but_selected_control_points ();
+ if (gain_line && trackview.editor().current_mouse_mode() == Editing::MouseGain) {
+ gain_line->remove_visibility (AutomationLine::ControlPoints);
}
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);
}
}
{
RegionView::thaw_after_trim ();
unhide_envelope ();
+ drag_end ();
}
void
return;
}
+ if (!ar->fade_in_is_xfade()) {
+ if (start_xfade_in) {
+ start_xfade_in->hide ();
+ start_xfade_out->hide ();
+ start_xfade_rect->hide ();
+ _start_xfade_visible = false;
+ }
+ return;
+ }
+
redraw_start_xfade_to (ar, ar->fade_in()->back()->when);
}
if (!start_xfade_out) {
start_xfade_out = new ArdourCanvas::Line (*group);
start_xfade_out->property_width_pixels() = 1;
- start_xfade_out->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
+ uint32_t col = UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 125);
+ start_xfade_out->property_fill_color_rgba() = col;
}
if (!start_xfade_rect) {
Points* points = get_canvas_points ("xfade edit redraw", npoints);
boost::scoped_ptr<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);
for (int i = 0, pci = 0; i < npoints; ++i) {
Gnome::Art::Point &p ((*points)[pci++]);
p.set_x (i);
- p.set_y (_height - (_height * vec.get()[i]));
+ p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
}
start_xfade_rect->property_x1() = ((*points)[0]).get_x();
- start_xfade_rect->property_y1() = 0;
+ start_xfade_rect->property_y1() = 1.0;
start_xfade_rect->property_x2() = ((*points)[npoints-1]).get_x();
- start_xfade_rect->property_y2() = _height;
+ start_xfade_rect->property_y2() = effective_height;
start_xfade_rect->show ();
start_xfade_rect->raise_to_top ();
for (int i = 0, pci = 0; i < npoints; ++i) {
Gnome::Art::Point &p ((*points)[pci++]);
p.set_x (i);
- p.set_y (_height - (_height * (1.0 - vec.get()[i])));
+ p.set_y (1.0 + effective_height - (effective_height * (1.0 - vec.get()[i])));
}
} else {
for (int i = 0, pci = 0; i < npoints; ++i) {
Gnome::Art::Point &p ((*points)[pci++]);
p.set_x (i);
- p.set_y (_height - (_height * vec.get()[i]));
+ p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
}
}
start_xfade_out->show ();
start_xfade_out->raise_to_top ();
+ _start_xfade_visible = true;
+
delete points;
}
return;
}
+ if (!ar->fade_out_is_xfade()) {
+ if (end_xfade_in) {
+ end_xfade_in->hide ();
+ end_xfade_out->hide ();
+ end_xfade_rect->hide ();
+ _end_xfade_visible = false;
+ }
+ return;
+ }
+
redraw_end_xfade_to (ar, ar->fade_out()->back()->when);
}
if (!end_xfade_out) {
end_xfade_out = new ArdourCanvas::Line (*group);
end_xfade_out->property_width_pixels() = 1;
- end_xfade_out->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
+ uint32_t col UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 125);
+ end_xfade_out->property_fill_color_rgba() = col;
}
if (!end_xfade_rect) {
ar->fade_out()->curve().get_vector (0, ar->fade_out()->back()->when, vec.get(), npoints);
double rend = trackview.editor().frame_to_pixel (_region->length() - len);
+ double effective_height = _height - NAME_HIGHLIGHT_SIZE - 1;
for (int i = 0, pci = 0; i < npoints; ++i) {
Gnome::Art::Point &p ((*points)[pci++]);
p.set_x (rend + i);
- p.set_y (_height - (_height * vec.get()[i]));
+ p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
}
end_xfade_rect->property_x1() = ((*points)[0]).get_x();
- end_xfade_rect->property_y1() = 0;
+ end_xfade_rect->property_y1() = 1;
end_xfade_rect->property_x2() = ((*points)[npoints-1]).get_x();
- end_xfade_rect->property_y2() = _height;
+ end_xfade_rect->property_y2() = effective_height;
end_xfade_rect->show ();
end_xfade_rect->raise_to_top ();
for (int i = 0, pci = 0; i < npoints; ++i) {
Gnome::Art::Point &p ((*points)[pci++]);
p.set_x (rend + i);
- p.set_y (_height - (_height * (1.0 - vec.get()[i])));
+ p.set_y (1.0 + effective_height - (effective_height * (1.0 - vec.get()[i])));
}
} else {
inverse->curve().get_vector (inverse->front()->when, inverse->back()->when, vec.get(), npoints);
-
+
for (int i = 0, pci = 0; i < npoints; ++i) {
Gnome::Art::Point &p ((*points)[pci++]);
p.set_x (rend + i);
- p.set_y (_height - (_height * vec.get()[i]));
+ p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
}
}
end_xfade_out->show ();
end_xfade_out->raise_to_top ();
+ _end_xfade_visible = true;
delete points;
}
void
-AudioRegionView::drag_start ()
+AudioRegionView::hide_xfades ()
+{
+ hide_start_xfade ();
+ hide_end_xfade ();
+}
+
+void
+AudioRegionView::hide_start_xfade ()
{
- TimeAxisViewItem::drag_start ();
-
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::drag_end ()
+AudioRegionView::show_start_xfade ()
{
- TimeAxisViewItem::drag_end ();
-
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
+AudioRegionView::drag_start ()
+{
+ TimeAxisViewItem::drag_start ();
+ AudioTimeAxisView* atav = dynamic_cast<AudioTimeAxisView*> (&trackview);
+
+ if (atav) {
+ AudioStreamView* av = atav->audio_view();
+ if (av) {
+ /* this will hide our xfades too */
+ _hidden_xfades = av->hide_xfades_with (audio_region());
+ }
+ }
+}
+
+void
+AudioRegionView::drag_end ()
+{
+ TimeAxisViewItem::drag_end ();
+
+ 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 ();
+ }
+}