Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
ProjectSnap Class Referencefinal

Project snapping settings. More...

#include <ProjectSnap.h>

Inheritance diagram for ProjectSnap:
[legend]
Collaboration diagram for ProjectSnap:
[legend]

Public Member Functions

 ProjectSnap (const AudacityProject &project)
 
 ProjectSnap (const ProjectSnap &)=delete
 
ProjectSnapoperator= (const ProjectSnap &)=delete
 
void SetSnapMode (SnapMode mode)
 
SnapMode GetSnapMode () const
 
void SetSnapTo (Identifier snap)
 
Identifier GetSnapTo () const
 
SnapResult SnapTime (double time) const
 
SnapResult SingleStep (double time, bool upwards) const
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 
- Public Member Functions inherited from Observer::Publisher< SnapChangedMessage >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 

Static Public Member Functions

static ProjectSnapGet (AudacityProject &project)
 
static const ProjectSnapGet (const AudacityProject &project)
 

Private Attributes

const AudacityProjectmProject
 
SnapMode mSnapMode { ReadSnapMode() }
 
Identifier mSnapTo { ReadSnapTo() }
 

Additional Inherited Members

- Public Types inherited from Observer::Publisher< SnapChangedMessage >
using message_type = SnapChangedMessage
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const SnapChangedMessage &) >
 Type of functions that can be connected to the Publisher. More...
 
- Static Public Attributes inherited from Observer::Publisher< SnapChangedMessage >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from Observer::Publisher< SnapChangedMessage >
CallbackReturn Publish (const SnapChangedMessage &message)
 Send a message to connected callbacks. More...
 

Detailed Description

Project snapping settings.

Definition at line 26 of file ProjectSnap.h.

Constructor & Destructor Documentation

◆ ProjectSnap() [1/2]

ProjectSnap::ProjectSnap ( const AudacityProject project)
explicit

Definition at line 37 of file ProjectSnap.cpp.

39{}
const auto project
const AudacityProject & mProject
Definition: ProjectSnap.h:48

◆ ProjectSnap() [2/2]

ProjectSnap::ProjectSnap ( const ProjectSnap )
delete

Member Function Documentation

◆ Get() [1/2]

ProjectSnap & ProjectSnap::Get ( AudacityProject project)
static

◆ Get() [2/2]

const ProjectSnap & ProjectSnap::Get ( const AudacityProject project)
static

Definition at line 32 of file ProjectSnap.cpp.

33{
34 return Get(const_cast<AudacityProject&>(project));
35}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static ProjectSnap & Get(AudacityProject &project)
Definition: ProjectSnap.cpp:27

References Get(), and project.

Here is the call graph for this function:

◆ GetSnapMode()

SnapMode ProjectSnap::GetSnapMode ( ) const

Definition at line 54 of file ProjectSnap.cpp.

55{
56 return mSnapMode;
57}
SnapMode mSnapMode
Definition: ProjectSnap.h:50

References mSnapMode.

Referenced by SnappingToolBar::Populate().

Here is the caller graph for this function:

◆ GetSnapTo()

Identifier ProjectSnap::GetSnapTo ( ) const

Definition at line 72 of file ProjectSnap.cpp.

73{
74 return mSnapTo;
75}
Identifier mSnapTo
Definition: ProjectSnap.h:51

References mSnapTo.

◆ operator=()

ProjectSnap & ProjectSnap::operator= ( const ProjectSnap )
delete

◆ SetSnapMode()

void ProjectSnap::SetSnapMode ( SnapMode  mode)

Definition at line 41 of file ProjectSnap.cpp.

42{
43 if (mSnapMode != mode)
44 {
45 mSnapMode = mode;
46
47 SnapModeSetting.WriteEnum(mSnapMode);
48 gPrefs->Flush();
49
51 }
52}
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
EnumSetting< SnapMode > SnapModeSetting
Definition: SnapUtils.cpp:31
CallbackReturn Publish(const SnapChangedMessage &message)
Send a message to connected callbacks.
Definition: Observer.h:207
virtual bool Flush() noexcept=0

References audacity::BasicSettings::Flush(), gPrefs, mSnapMode, mSnapTo, Observer::Publisher< SnapChangedMessage >::Publish(), and SnapModeSetting.

Referenced by AUPImportFileHandle::Import(), anonymous_namespace{PluginMenus.cpp}::OnResetConfig(), SnappingToolBar::OnSnapModeChanged(), SelectActions::Handler::OnSnapToNearest(), SelectActions::Handler::OnSnapToOff(), SelectActions::Handler::OnSnapToPrior(), and anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::PopulateOrExchange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetSnapTo()

void ProjectSnap::SetSnapTo ( Identifier  snap)

Definition at line 59 of file ProjectSnap.cpp.

60{
61 if (mSnapTo != snap)
62 {
63 mSnapTo = snap;
64
66 gPrefs->Flush();
67
69 }
70}
StringSetting SnapToSetting
Definition: SnapUtils.cpp:29
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
Definition: Identifier.h:66
bool Write(const T &value)
Write value to config and return true if successful.
Definition: Prefs.h:259

References audacity::BasicSettings::Flush(), Identifier::GET(), gPrefs, mSnapMode, mSnapTo, Observer::Publisher< SnapChangedMessage >::Publish(), SnapToSetting, and Setting< T >::Write().

Referenced by anonymous_namespace{SnappingToolBar.cpp}::SnapModePopup::OnComboKeyEvent(), anonymous_namespace{SnappingToolBar.cpp}::SnapModePopup::OnPopup(), and anonymous_namespace{PluginMenus.cpp}::OnResetConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SingleStep()

SnapResult ProjectSnap::SingleStep ( double  time,
bool  upwards 
) const

Definition at line 85 of file ProjectSnap.cpp.

86{
88 return { time, false };
89
91}
static SnapResult SingleStep(const Identifier &id, const AudacityProject &project, double time, bool upwards)
Definition: SnapUtils.cpp:158

References mProject, mSnapMode, mSnapTo, SnapFunctionsRegistry::SingleStep(), and SNAP_OFF.

Here is the call graph for this function:

◆ SnapTime()

SnapResult ProjectSnap::SnapTime ( double  time) const

Definition at line 77 of file ProjectSnap.cpp.

78{
80 return { time, false };
81
83}
static SnapResult Snap(const Identifier &id, const AudacityProject &project, double time, bool nearest)
Definition: SnapUtils.cpp:146

References mProject, mSnapMode, mSnapTo, SnapFunctionsRegistry::Snap(), SNAP_NEAREST, and SNAP_OFF.

Referenced by SnapManager::CondListAdd(), and SnapManager::Snap().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mProject

const AudacityProject& ProjectSnap::mProject
private

Definition at line 48 of file ProjectSnap.h.

Referenced by SingleStep(), and SnapTime().

◆ mSnapMode

SnapMode ProjectSnap::mSnapMode { ReadSnapMode() }
private

Definition at line 50 of file ProjectSnap.h.

Referenced by GetSnapMode(), SetSnapMode(), SetSnapTo(), SingleStep(), and SnapTime().

◆ mSnapTo

Identifier ProjectSnap::mSnapTo { ReadSnapTo() }
private

Definition at line 51 of file ProjectSnap.h.

Referenced by GetSnapTo(), SetSnapMode(), SetSnapTo(), SingleStep(), and SnapTime().


The documentation for this class was generated from the following files: