Audacity 3.2.0
Static Public Member Functions | List of all members
SnapFunctionsRegistry Struct Referencefinal

#include <SnapUtils.h>

Static Public Member Functions

static Registry::GroupItem< SnapRegistryTraits > & Registry ()
 
static void Visit (const SnapRegistryVisitor &visitor)
 
static const SnapRegistryItemFind (const Identifier &id)
 
static SnapResult Snap (const Identifier &id, const AudacityProject &project, double time, bool nearest)
 
static SnapResult SingleStep (const Identifier &id, const AudacityProject &project, double time, bool upwards)
 

Detailed Description

Definition at line 101 of file SnapUtils.h.

Member Function Documentation

◆ Find()

const SnapRegistryItem * SnapFunctionsRegistry::Find ( const Identifier id)
static

Definition at line 121 of file SnapUtils.cpp.

122{
123 using Cache = std::unordered_map<Identifier, const SnapRegistryItem*>;
124 static Cache cache;
125
126 auto it = cache.find(id);
127 if (it != cache.end())
128 return it->second;
129
130 auto visitor = [&](const SnapRegistryItem &item, auto&) {
131 auto it = cache.find(item.name);
132
133 if (it == cache.end())
134 {
135 cache.insert({ item.name, &item });
136 }
137 };
138
139 Registry::Visit(visitor, &Registry());
140
141 it = cache.find(id);
142
143 return it != cache.end() ? it->second : nullptr;
144}
void Visit(const Visitors &visitors, const GroupItem< RegistryTraits > *pTopItem, const GroupItem< RegistryTraits > *pRegistry={}, typename RegistryTraits::ComputedItemContextType &computedItemContext=RegistryTraits::ComputedItemContextType::Instance)
Definition: Registry.h:609
const Identifier name
Definition: Registry.h:86
static Registry::GroupItem< SnapRegistryTraits > & Registry()
Definition: SnapUtils.cpp:104

References Registry::detail::BaseItem::name, Registry(), and Registry::Visit().

Referenced by anonymous_namespace{SnappingToolBar.cpp}::GetSnapToLabel(), SingleStep(), and Snap().

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

◆ Registry()

Registry::GroupItem< SnapRegistryTraits > & SnapFunctionsRegistry::Registry ( )
static

Definition at line 104 of file SnapUtils.cpp.

References anonymous_namespace{SnapUtils.cpp}::PathStart.

Referenced by Find(), and Visit().

Here is the caller graph for this function:

◆ SingleStep()

SnapResult SnapFunctionsRegistry::SingleStep ( const Identifier id,
const AudacityProject project,
double  time,
bool  upwards 
)
static

Definition at line 158 of file SnapUtils.cpp.

161{
162 auto item = Find(id);
163
164 if (item == nullptr)
165 return SnapResult { time, false };
166
167 return item->SingleStep(project, time, upwards);
168}
const auto project
static const SnapRegistryItem * Find(const Identifier &id)
Definition: SnapUtils.cpp:121

References Find(), and project.

Referenced by BarStepCase(), ProjectSnap::SingleStep(), and TimeStepCase().

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

◆ Snap()

SnapResult SnapFunctionsRegistry::Snap ( const Identifier id,
const AudacityProject project,
double  time,
bool  nearest 
)
static

Definition at line 146 of file SnapUtils.cpp.

149{
150 auto item = Find(id);
151
152 if (item == nullptr)
153 return SnapResult { time, false };
154
155 return item->Snap(project, time, nearest);
156}

References Find(), and project.

Referenced by BeatsCase(), ProjectSnap::SnapTime(), TEST_CASE(), and TimeCase().

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

◆ Visit()

void SnapFunctionsRegistry::Visit ( const SnapRegistryVisitor visitor)
static

Definition at line 110 of file SnapUtils.cpp.

111{
113 PathStart,
114 { { L"", L"beats,triplets,time,video,cd" } },
115 };
116
118 Registry::VisitWithFunctions(visitor, &top, &Registry());
119}
void VisitWithFunctions(const VisitorFunctions< RegistryTraits > &visitors, const GroupItem< RegistryTraits > *pTopItem, const GroupItem< RegistryTraits > *pRegistry={}, typename RegistryTraits::ComputedItemContextType &computedItemContext=RegistryTraits::ComputedItemContextType::Instance)
Definition: Registry.h:623

References anonymous_namespace{SnapUtils.cpp}::PathStart, Registry(), and Registry::VisitWithFunctions().

Referenced by 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:

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