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,20 +1631,32 @@ Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr<Region>
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());
fooc = region_lock_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_lock));
if (region->locked()) {
fooc.block (true);
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());
fooc = region_mute_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_mute));
if (region->muted()) {
fooc.block (true);
region_mute_item->set_active();
fooc.block (false);
}
items.push_back (CheckMenuElem (_("Opaque"), mem_fun(*this, &Editor::toggle_region_opaque)));
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)));
@ -1661,18 +1673,23 @@ Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr<Region>
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());
fooc = region_envelope_visible_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_visibility));
if (arv->envelope_visible()) {
fooc.block (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());
fooc = region_envelope_active_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_active));
if (ar->envelope_active()) {
fooc.block (true);
region_envelope_active_item->set_active (true);
fooc.block (false);
}
items.push_back (SeparatorElem());

View file

@ -65,7 +65,7 @@ class AudioRegion : public Region
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();
bool envelope_active () const { return _flags & Region::EnvelopeActive; }
@ -95,6 +95,8 @@ class AudioRegion : public Region
int set_state (const XMLNode&);
static void set_default_fade (float steepness, nframes_t len);
bool fade_in_is_default () const;
bool fade_out_is_default () const;
enum FadeShape {
Linear,

View file

@ -452,12 +452,12 @@ AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buff
nframes_t buf_offset;
nframes_t to_read;
/* precondition: caller has verified that we cover the desired section */
if (chan_n >= sources.size()) {
if (muted()) {
return 0; /* read nothing */
}
/* precondition: caller has verified that we cover the desired section */
if (position < _position) {
internal_offset = 0;
buf_offset = _position - position;
@ -482,17 +482,29 @@ AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buff
mixdown_buffer += buf_offset;
}
if (muted()) {
return 0; /* read nothing */
}
_read_data_count = 0;
if (srcs[chan_n]->read (mixdown_buffer, _start + internal_offset, to_read) != to_read) {
return 0; /* "read nothing" */
}
if (chan_n < n_channels()) {
_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 */
@ -577,6 +589,8 @@ AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buff
Session::apply_gain_to_buffer (mixdown_buffer, to_read, _scale_amplitude);
}
merge:
if (!opaque()) {
/* gack. the things we do for users.
@ -946,6 +960,18 @@ AudioRegion::set_fade_out_active (bool yn)
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
AudioRegion::set_default_fade_in ()
{
@ -1310,14 +1336,16 @@ void
AudioRegion::suspend_fade_in ()
{
if (++_fade_in_disabled == 1) {
set_fade_in_active (false);
if (fade_in_is_default()) {
set_fade_in_active (false);
}
}
}
void
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);
}
}
@ -1326,14 +1354,16 @@ void
AudioRegion::suspend_fade_out ()
{
if (++_fade_out_disabled == 1) {
set_fade_out_active (false);
if (fade_out_is_default()) {
set_fade_out_active (false);
}
}
}
void
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);
}
}

View file

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