make region opacity work again; fix several other region context menu items that may have been messing with region state in unforeseen ways

git-svn-id: svn://localhost/ardour2/trunk@1691 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2007-04-09 18:07:15 +00:00
parent a3741ccac8
commit b4b891b6ab
5 changed files with 85 additions and 36 deletions

View file

@ -1631,48 +1631,65 @@ Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr<Region>
items.push_back (SeparatorElem()); items.push_back (SeparatorElem());
items.push_back (CheckMenuElem (_("Lock"), mem_fun(*this, &Editor::toggle_region_lock))); sigc::connection fooc;
items.push_back (CheckMenuElem (_("Lock")));
region_lock_item = static_cast<CheckMenuItem*>(&items.back()); region_lock_item = static_cast<CheckMenuItem*>(&items.back());
fooc = region_lock_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_lock));
if (region->locked()) { if (region->locked()) {
fooc.block (true);
region_lock_item->set_active(); region_lock_item->set_active();
fooc.block (false);
} }
items.push_back (CheckMenuElem (_("Mute"), mem_fun(*this, &Editor::toggle_region_mute))); items.push_back (CheckMenuElem (_("Mute")));
region_mute_item = static_cast<CheckMenuItem*>(&items.back()); region_mute_item = static_cast<CheckMenuItem*>(&items.back());
fooc = region_mute_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_mute));
if (region->muted()) { if (region->muted()) {
fooc.block (true);
region_mute_item->set_active(); region_mute_item->set_active();
} fooc.block (false);
items.push_back (CheckMenuElem (_("Opaque"), mem_fun(*this, &Editor::toggle_region_opaque)));
region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
if (region->opaque()) {
region_opaque_item->set_active();
} }
items.push_back (CheckMenuElem (_("Opaque")));
region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
fooc = region_opaque_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_opaque));
if (region->opaque()) {
fooc.block (true);
region_opaque_item->set_active();
fooc.block (false);
}
items.push_back (CheckMenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize))); items.push_back (CheckMenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
if (region->at_natural_position()) { if (region->at_natural_position()) {
items.back().set_sensitive (false); items.back().set_sensitive (false);
} }
items.push_back (SeparatorElem()); items.push_back (SeparatorElem());
if (ar) { if (ar) {
RegionView* rv = sv->find_view (ar); RegionView* rv = sv->find_view (ar);
AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv); AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
items.push_back (MenuElem (_("Reset Envelope"), mem_fun(*this, &Editor::reset_region_gain_envelopes))); items.push_back (MenuElem (_("Reset Envelope"), mem_fun(*this, &Editor::reset_region_gain_envelopes)));
items.push_back (CheckMenuElem (_("Envelope Visible"), mem_fun(*this, &Editor::toggle_gain_envelope_visibility))); items.push_back (CheckMenuElem (_("Envelope Visible")));
region_envelope_visible_item = static_cast<CheckMenuItem*> (&items.back()); region_envelope_visible_item = static_cast<CheckMenuItem*> (&items.back());
fooc = region_envelope_visible_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_visibility));
if (arv->envelope_visible()) { if (arv->envelope_visible()) {
fooc.block (true);
region_envelope_visible_item->set_active (true); region_envelope_visible_item->set_active (true);
fooc.block (false);
} }
items.push_back (CheckMenuElem (_("Envelope Active"), mem_fun(*this, &Editor::toggle_gain_envelope_active))); items.push_back (CheckMenuElem (_("Envelope Active")));
region_envelope_active_item = static_cast<CheckMenuItem*> (&items.back()); region_envelope_active_item = static_cast<CheckMenuItem*> (&items.back());
fooc = region_envelope_active_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_active));
if (ar->envelope_active()) { if (ar->envelope_active()) {
fooc.block (true);
region_envelope_active_item->set_active (true); region_envelope_active_item->set_active (true);
fooc.block (false);
} }
items.push_back (SeparatorElem()); items.push_back (SeparatorElem());

View file

@ -65,7 +65,7 @@ class AudioRegion : public Region
void normalize_to (float target_in_dB = 0.0f); void normalize_to (float target_in_dB = 0.0f);
uint32_t n_channels() { return sources.size(); } uint32_t n_channels() const { return sources.size(); }
vector<string> master_source_names(); vector<string> master_source_names();
bool envelope_active () const { return _flags & Region::EnvelopeActive; } bool envelope_active () const { return _flags & Region::EnvelopeActive; }
@ -95,6 +95,8 @@ class AudioRegion : public Region
int set_state (const XMLNode&); int set_state (const XMLNode&);
static void set_default_fade (float steepness, nframes_t len); static void set_default_fade (float steepness, nframes_t len);
bool fade_in_is_default () const;
bool fade_out_is_default () const;
enum FadeShape { enum FadeShape {
Linear, Linear,

View file

@ -452,12 +452,12 @@ AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buff
nframes_t buf_offset; nframes_t buf_offset;
nframes_t to_read; nframes_t to_read;
/* precondition: caller has verified that we cover the desired section */ if (muted()) {
if (chan_n >= sources.size()) {
return 0; /* read nothing */ return 0; /* read nothing */
} }
/* precondition: caller has verified that we cover the desired section */
if (position < _position) { if (position < _position) {
internal_offset = 0; internal_offset = 0;
buf_offset = _position - position; buf_offset = _position - position;
@ -482,17 +482,29 @@ AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buff
mixdown_buffer += buf_offset; mixdown_buffer += buf_offset;
} }
if (muted()) {
return 0; /* read nothing */
}
_read_data_count = 0; _read_data_count = 0;
if (srcs[chan_n]->read (mixdown_buffer, _start + internal_offset, to_read) != to_read) { if (chan_n < n_channels()) {
return 0; /* "read nothing" */
}
_read_data_count += srcs[chan_n]->read_data_count(); if (srcs[chan_n]->read (mixdown_buffer, _start + internal_offset, to_read) != to_read) {
return 0; /* "read nothing" */
}
_read_data_count += srcs[chan_n]->read_data_count();
} else {
/* track is N-channel, this region has less channels; silence the ones
we don't have.
*/
memset (mixdown_buffer, 0, sizeof (Sample) * cnt);
/* no fades required */
goto merge;
}
/* fade in */ /* fade in */
@ -503,7 +515,7 @@ AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buff
/* see if this read is within the fade in */ /* see if this read is within the fade in */
if (internal_offset < fade_in_length) { if (internal_offset < fade_in_length) {
nframes_t limit; nframes_t limit;
limit = min (to_read, fade_in_length - internal_offset); limit = min (to_read, fade_in_length - internal_offset);
@ -577,13 +589,15 @@ AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buff
Session::apply_gain_to_buffer (mixdown_buffer, to_read, _scale_amplitude); Session::apply_gain_to_buffer (mixdown_buffer, to_read, _scale_amplitude);
} }
merge:
if (!opaque()) { if (!opaque()) {
/* gack. the things we do for users. /* gack. the things we do for users.
*/ */
buf += buf_offset; buf += buf_offset;
for (nframes_t n = 0; n < to_read; ++n) { for (nframes_t n = 0; n < to_read; ++n) {
buf[n] += mixdown_buffer[n]; buf[n] += mixdown_buffer[n];
} }
@ -946,6 +960,18 @@ AudioRegion::set_fade_out_active (bool yn)
send_change (FadeOutActiveChanged); send_change (FadeOutActiveChanged);
} }
bool
AudioRegion::fade_in_is_default () const
{
return _fade_in_shape == Linear && _fade_in.back()->when == 64;
}
bool
AudioRegion::fade_out_is_default () const
{
return _fade_out_shape == Linear && _fade_out.back()->when == 64;
}
void void
AudioRegion::set_default_fade_in () AudioRegion::set_default_fade_in ()
{ {
@ -1310,14 +1336,16 @@ void
AudioRegion::suspend_fade_in () AudioRegion::suspend_fade_in ()
{ {
if (++_fade_in_disabled == 1) { if (++_fade_in_disabled == 1) {
set_fade_in_active (false); if (fade_in_is_default()) {
set_fade_in_active (false);
}
} }
} }
void void
AudioRegion::resume_fade_in () AudioRegion::resume_fade_in ()
{ {
if (_fade_in_disabled && --_fade_in_disabled == 0) { if (--_fade_in_disabled == 0 && _fade_in_disabled) {
set_fade_in_active (true); set_fade_in_active (true);
} }
} }
@ -1326,14 +1354,16 @@ void
AudioRegion::suspend_fade_out () AudioRegion::suspend_fade_out ()
{ {
if (++_fade_out_disabled == 1) { if (++_fade_out_disabled == 1) {
set_fade_out_active (false); if (fade_out_is_default()) {
set_fade_out_active (false);
}
} }
} }
void void
AudioRegion::resume_fade_out () AudioRegion::resume_fade_out ()
{ {
if (_fade_out_disabled && --_fade_out_disabled == 0) { if (--_fade_out_disabled == 0 &&_fade_out_disabled) {
set_fade_out_active (true); set_fade_out_active (true);
} }
} }

View file

@ -248,7 +248,7 @@ Session::butler_thread_work ()
gettimeofday (&begin, 0); gettimeofday (&begin, 0);
boost::shared_ptr<DiskstreamList> dsl = diskstreams.reader (); boost::shared_ptr<DiskstreamList> dsl = diskstreams.reader ();
for (i = dsl->begin(); !transport_work_requested() && butler_should_run && i != dsl->end(); ++i) { for (i = dsl->begin(); !transport_work_requested() && butler_should_run && i != dsl->end(); ++i) {
boost::shared_ptr<Diskstream> ds = *i; boost::shared_ptr<Diskstream> ds = *i;

View file

@ -1,4 +1,4 @@
#ifndef __ardour_svn_revision_h__ #ifndef __ardour_svn_revision_h__
#define __ardour_svn_revision_h__ #define __ardour_svn_revision_h__
static const char* ardour_svn_revision = "1677"; static const char* ardour_svn_revision = "1681";
#endif #endif