1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-21 16:37:12 +01:00

Heavyweight version of SelectedRegion stored in ViewInfo emits events

This commit is contained in:
Paul Licameli
2018-02-16 18:07:59 -05:00
parent 43af7b3265
commit 33f3d4b82d
16 changed files with 240 additions and 38 deletions

View File

@@ -21,6 +21,119 @@ Paul Licameli
#include "prefs/TracksBehaviorsPrefs.h"
#include "xml/XMLWriter.h"
wxDEFINE_EVENT( EVT_SELECTED_REGION_CHANGE, SelectedRegionEvent );
SelectedRegionEvent::SelectedRegionEvent(
wxEventType commandType, NotifyingSelectedRegion *pReg )
: wxEvent{ 0, commandType }
, pRegion{ pReg }
{}
wxEvent *SelectedRegionEvent::Clone() const
{
return safenew SelectedRegionEvent{ *this };
}
NotifyingSelectedRegion& NotifyingSelectedRegion::operator =
( const SelectedRegion &other )
{
if ( mRegion != other ) {
mRegion = other;
Notify();
}
return *this;
}
bool NotifyingSelectedRegion::setTimes(double t0, double t1)
{
bool result = false;
if ( mRegion.t0() != t0 || mRegion.t1() != t1 ) {
result = mRegion.setTimes( t0, t1 );
Notify();
}
return result;
}
bool NotifyingSelectedRegion::setT0(double t, bool maySwap)
{
bool result = false;
if ( mRegion.t0() != t ) {
result = mRegion.setT0( t, maySwap );
Notify();
}
return result;
}
bool NotifyingSelectedRegion::setT1(double t, bool maySwap)
{
bool result = false;
if ( mRegion.t1() != t ) {
result = mRegion.setT1( t, maySwap );
Notify();
}
return result;
}
void NotifyingSelectedRegion::collapseToT0()
{
if ( mRegion.t0() != mRegion.t1() ) {
mRegion.collapseToT0();
Notify();
}
}
void NotifyingSelectedRegion::collapseToT1()
{
if ( mRegion.t0() != mRegion.t1() ) {
mRegion.collapseToT1();
Notify();
}
}
void NotifyingSelectedRegion::move(double delta)
{
if (delta != 0) {
mRegion.move( delta );
Notify();
}
}
bool NotifyingSelectedRegion::setFrequencies(double f0, double f1)
{
bool result = false;
if ( mRegion.f0() != f0 || mRegion.f1() != f1 ) {
result = mRegion.setFrequencies( f0, f1 );
Notify();
}
return result;
}
bool NotifyingSelectedRegion::setF0(double f, bool maySwap)
{
bool result = false;
if ( mRegion.f0() != f ) {
result = mRegion.setF0( f, maySwap );
Notify();
}
return result;
}
bool NotifyingSelectedRegion::setF1(double f, bool maySwap)
{
bool result = false;
if ( mRegion.f1() != f ) {
result = mRegion.setF1( f, maySwap );
Notify();
}
return result;
}
void NotifyingSelectedRegion::Notify()
{
SelectedRegionEvent evt{ EVT_SELECTED_REGION_CHANGE, this };
ProcessEvent( evt );
}
static const AudacityProject::AttachedObjects::RegisteredFactory key{
[]( AudacityProject &project ) {
auto result =