Audacity 3.2.0
ProjectSnap.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 ProjectSnap.h
7
8 Dmitry Vedenko
9
10**********************************************************************/
11#pragma once
12
13#include "ClientData.h"
14#include "Observer.h"
15#include "SnapUtils.h"
16
17class AudacityProject;
18
20{
22 Identifier newSnapTo { "seconds" };
23};
24
26class SNAPPING_API ProjectSnap final :
27 public ClientData::Base,
28 public Observer::Publisher<SnapChangedMessage>
29{
30public:
32 static const ProjectSnap& Get(const AudacityProject& project);
33
34 explicit ProjectSnap(const AudacityProject& project);
35 ProjectSnap(const ProjectSnap&) = delete;
37
38 void SetSnapMode(SnapMode mode);
39 SnapMode GetSnapMode() const;
40
41 void SetSnapTo(Identifier snap);
42 Identifier GetSnapTo() const;
43
44 SnapResult SnapTime(double time) const;
45 SnapResult SingleStep(double time, bool upwards) const;
46
47private:
49
50 SnapMode mSnapMode { ReadSnapMode() };
51 Identifier mSnapTo { ReadSnapTo() };
52};
Utility ClientData::Site to register hooks into a host class that attach client data.
Identifier ReadSnapTo()
Definition: SnapUtils.cpp:90
SnapMode ReadSnapMode()
Definition: SnapUtils.cpp:38
SnapMode
Definition: SnapUtils.h:21
const auto project
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
An object that sends messages to an open-ended list of subscribed callbacks.
Definition: Observer.h:108
Project snapping settings.
Definition: ProjectSnap.h:29
const AudacityProject & mProject
Definition: ProjectSnap.h:48
ProjectSnap(const ProjectSnap &)=delete
ProjectSnap & operator=(const ProjectSnap &)=delete
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:202
A convenient default parameter for class template Site.
Definition: ClientData.h:29
SnapMode newSnapMode
Definition: ProjectSnap.h:21
Identifier newSnapTo
Definition: ProjectSnap.h:22