Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
anonymous_namespace{SnapUtils.cpp}::ConstantMultiplierSnapItem Class Referencefinal
Inheritance diagram for anonymous_namespace{SnapUtils.cpp}::ConstantMultiplierSnapItem:
[legend]
Collaboration diagram for anonymous_namespace{SnapUtils.cpp}::ConstantMultiplierSnapItem:
[legend]

Public Member Functions

 ConstantMultiplierSnapItem (const Identifier &internalName, const TranslatableString &label, double multiplier)
 
SnapResult Snap (const AudacityProject &, double time, bool nearest) const override
 
SnapResult SingleStep (const AudacityProject &project, double time, bool upwards) const override
 
- Public Member Functions inherited from SnapRegistryItem
 SnapRegistryItem (const Identifier &internalName, const TranslatableString &label)
 
 ~SnapRegistryItem () override
 
virtual SnapResult Snap (const AudacityProject &project, double time, bool nearest) const =0
 
virtual SnapResult SingleStep (const AudacityProject &project, double time, bool upwards) const =0
 
- Public Member Functions inherited from Registry::SingleItem
 ~SingleItem () override=0
 
- Public Member Functions inherited from Registry::detail::BaseItem
 BaseItem (const Identifier &internalName)
 
virtual ~BaseItem ()
 

Private Attributes

const double mMultiplier
 

Additional Inherited Members

- Public Attributes inherited from SnapRegistryItem
const TranslatableString label
 
- Public Attributes inherited from Registry::detail::BaseItem
const Identifier name
 
OrderingHint orderingHint
 

Detailed Description

Definition at line 198 of file SnapUtils.cpp.

Constructor & Destructor Documentation

◆ ConstantMultiplierSnapItem()

anonymous_namespace{SnapUtils.cpp}::ConstantMultiplierSnapItem::ConstantMultiplierSnapItem ( const Identifier internalName,
const TranslatableString label,
double  multiplier 
)
inline

Definition at line 201 of file SnapUtils.cpp.

204 : SnapRegistryItem { internalName, label }
205 , mMultiplier { multiplier }
206 {
207 assert(mMultiplier > 0.0);
208 }
const TranslatableString label
Definition: SnapUtils.h:82

Member Function Documentation

◆ SingleStep()

SnapResult anonymous_namespace{SnapUtils.cpp}::ConstantMultiplierSnapItem::SingleStep ( const AudacityProject project,
double  time,
bool  upwards 
) const
inlineoverridevirtual

Implements SnapRegistryItem.

Definition at line 216 of file SnapUtils.cpp.

218 {
219 const auto step = (upwards ? 1.0 : -1.0) / mMultiplier;
220 const double result = time + step;
221
222 if (result < 0.0)
223 return { 0.0, false };
224
225 return SnapWithMultiplier(result, mMultiplier, true);
226 }
SnapResult SnapWithMultiplier(double value, double multiplier, bool nearest)
Definition: SnapUtils.cpp:187

References anonymous_namespace{SnapUtils.cpp}::SnapWithMultiplier().

Here is the call graph for this function:

◆ Snap()

SnapResult anonymous_namespace{SnapUtils.cpp}::ConstantMultiplierSnapItem::Snap ( const AudacityProject ,
double  time,
bool  nearest 
) const
inlineoverridevirtual

Implements SnapRegistryItem.

Definition at line 211 of file SnapUtils.cpp.

212 {
213 return SnapWithMultiplier(time, mMultiplier, nearest);
214 }

References anonymous_namespace{SnapUtils.cpp}::SnapWithMultiplier().

Here is the call graph for this function:

Member Data Documentation

◆ mMultiplier

const double anonymous_namespace{SnapUtils.cpp}::ConstantMultiplierSnapItem::mMultiplier
private

Definition at line 229 of file SnapUtils.cpp.


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