Audacity 3.2.0
Classes | Typedefs | Enumerations | Functions | Variables
SnapUtils.h File Reference
#include "Callable.h"
#include "Prefs.h"
#include "Registry.h"
#include <functional>
#include <string_view>
Include dependency graph for SnapUtils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SnapResult
 
struct  SnapRegistryTraits
 
struct  SnapRegistryGroupData
 
struct  SnapRegistryGroup
 
struct  SnapRegistryItem
 
struct  SnapFunctionsRegistry
 
struct  SnapFunctionSuperGroup
 

Typedefs

using SnapRegistryVisitor = Registry::VisitorFunctions< SnapRegistryTraits >
 
using MultiplierFunctor = std::function< double(const AudacityProject &)>
 
using SnapRegistryItemRegistrator = Registry::RegisteredItem< SnapFunctionsRegistry >
 

Enumerations

enum class  SnapMode { SNAP_OFF , SNAP_NEAREST , SNAP_PRIOR }
 

Functions

SNAPPING_API SnapMode ReadSnapMode ()
 
SNAPPING_API Identifier ReadSnapTo ()
 
std::unique_ptr< SnapRegistryItemTimeInvariantSnapFunction (const Identifier &functionId, const TranslatableString &label, double multiplier)
 
std::unique_ptr< SnapRegistryItemTimeInvariantSnapFunction (const Identifier &functionId, const TranslatableString &label, MultiplierFunctor functor)
 

Variables

SNAPPING_API StringSetting SnapToSetting
 
SNAPPING_API EnumSetting< SnapModeSnapModeSetting
 
constexpr auto SnapFunctionGroup
 
constexpr auto SnapFunctionItems
 

Typedef Documentation

◆ MultiplierFunctor

using MultiplierFunctor = std::function<double(const AudacityProject&)>

Definition at line 92 of file SnapUtils.h.

◆ SnapRegistryItemRegistrator

Definition at line 114 of file SnapUtils.h.

◆ SnapRegistryVisitor

Definition at line 56 of file SnapUtils.h.

Enumeration Type Documentation

◆ SnapMode

enum class SnapMode
strong

Audacity: A Digital Audio Editor

SnapUtils.h

Dmitry Vedenko

Enumerator
SNAP_OFF 
SNAP_NEAREST 
SNAP_PRIOR 

Definition at line 20 of file SnapUtils.h.

21{
25};

Function Documentation

◆ ReadSnapMode()

SNAPPING_API SnapMode ReadSnapMode ( )

Definition at line 38 of file SnapUtils.cpp.

39{
41 return SnapModeSetting.ReadEnum();
42
43 return static_cast<SnapMode>(gPrefs->Read(OldSnapToKey, 0L));
44}
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
EnumSetting< SnapMode > SnapModeSetting
Definition: SnapUtils.cpp:31
SnapMode
Definition: SnapUtils.h:21
virtual bool HasEntry(const wxString &key) const =0
Checks whether specified key exists within the current group.
virtual bool Read(const wxString &key, bool *value) const =0

References gPrefs, audacity::BasicSettings::HasEntry(), anonymous_namespace{SnapUtils.cpp}::OldSnapToKey, audacity::BasicSettings::Read(), anonymous_namespace{SnapUtils.cpp}::SnapModeKey, and SnapModeSetting.

Here is the call graph for this function:

◆ ReadSnapTo()

SNAPPING_API Identifier ReadSnapTo ( )

Definition at line 90 of file SnapUtils.cpp.

91{
93 return SnapToSetting.Read();
94
95 // Try to perform the config migration once
96 const auto snapTo = DeduceSnapTo();
97 SnapToSetting.Write(snapTo);
98 gPrefs->Flush();
99
100
101 return snapTo;
102}
StringSetting SnapToSetting
Definition: SnapUtils.cpp:29
wxString DeduceSnapTo()
Definition: SnapUtils.cpp:46
bool Write(const T &value)
Write value to config and return true if successful.
Definition: Prefs.h:259
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:207
virtual bool Flush() noexcept=0

References DeduceSnapTo(), audacity::BasicSettings::Flush(), gPrefs, audacity::BasicSettings::HasEntry(), Setting< T >::Read(), anonymous_namespace{SnapUtils.cpp}::SnapToKey, SnapToSetting, and Setting< T >::Write().

Referenced by anonymous_namespace{SnappingToolBar.cpp}::SnapModePopup::GetStringValue(), anonymous_namespace{SnappingToolBar.cpp}::SnapModePopup::Init(), and anonymous_namespace{SnappingToolBar.cpp}::SnapModePopup::OnPopup().

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

◆ TimeInvariantSnapFunction() [1/2]

std::unique_ptr< SnapRegistryItem > TimeInvariantSnapFunction ( const Identifier functionId,
const TranslatableString label,
double  multiplier 
)

Definition at line 294 of file SnapUtils.cpp.

297{
298 return std::make_unique<ConstantMultiplierSnapItem>(
299 functionId, label, multiplier);
300}
TranslatableString label
Definition: TagsEditor.cpp:165

References label.

◆ TimeInvariantSnapFunction() [2/2]

std::unique_ptr< SnapRegistryItem > TimeInvariantSnapFunction ( const Identifier functionId,
const TranslatableString label,
MultiplierFunctor  functor 
)

Definition at line 286 of file SnapUtils.cpp.

289{
290 return std::make_unique<ProjectDependentMultiplierSnapItem>(
291 functionId, label, std::move(functor));
292}

References label.

Variable Documentation

◆ SnapFunctionGroup

constexpr auto SnapFunctionGroup
constexpr
Initial value:
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
constexpr auto UniqueMaker()
Generate variadic factory functions.
Definition: Callable.h:122

Definition at line 98 of file SnapUtils.h.

◆ SnapFunctionItems

constexpr auto SnapFunctionItems
constexpr
Initial value:
=
Callable::UniqueMaker<SnapFunctionSuperGroup>()

Definition at line 123 of file SnapUtils.h.

◆ SnapModeSetting

SNAPPING_API EnumSetting<SnapMode> SnapModeSetting
extern

◆ SnapToSetting

SNAPPING_API StringSetting SnapToSetting
extern