Audacity
3.2.0
src
commands
SetProjectCommand.cpp
Go to the documentation of this file.
1
/**********************************************************************
2
3
Audacity - A Digital Audio Editor
4
Copyright 1999-2018 Audacity Team
5
License: wxwidgets
6
7
Dan Horgan
8
James Crook
9
10
******************************************************************/
/*******************************************************************/
19
20
21
#include "
SetProjectCommand.h
"
22
23
#include "
CommandDispatch.h
"
24
#include "
MenuRegistry.h
"
25
#include "../CommonCommandFlags.h"
26
#include "
LoadCommands.h
"
27
#include "
Project.h
"
28
#include "
ProjectRate.h
"
29
#include "../ProjectWindows.h"
30
#include "
WaveTrack.h
"
31
#include "
SettingsVisitor.h
"
32
#include "
ShuttleGui.h
"
33
#include "
CommandContext.h
"
34
35
#include <wx/frame.h>
36
37
const
ComponentInterfaceSymbol
SetProjectCommand::Symbol
38
{
XO
(
"Set Project"
) };
39
40
namespace
{
BuiltinCommandsModule::Registration< SetProjectCommand >
reg
; }
41
42
SetProjectCommand::SetProjectCommand
()
43
{
44
}
45
46
template
<
bool
Const>
47
bool
SetProjectCommand::VisitSettings
(
SettingsVisitorBase<Const>
&
S
){
48
S
.OptionalN(
bHasName
).Define(
mName
,
wxT
(
"Name"
),
_
(
"Project"
) );
49
S
.OptionalN(
bHasRate
).Define(
mRate
,
wxT
(
"Rate"
), 44100.0, 1.0, 1000000.0);
50
S
.OptionalY(
bHasSizing
).Define(
mPosX
,
wxT
(
"X"
), 10, 0, 2000);
51
S
.OptionalY(
bHasSizing
).Define(
mPosY
,
wxT
(
"Y"
), 10, 0, 2000);
52
S
.OptionalY(
bHasSizing
).Define(
mWidth
,
wxT
(
"Width"
), 1000, 200, 4000);
53
S
.OptionalY(
bHasSizing
).Define(
mHeight
,
wxT
(
"Height"
), 900, 200, 4000);
54
return
true
;
55
};
56
57
bool
SetProjectCommand::VisitSettings
(
SettingsVisitor
&
S
)
58
{
return
VisitSettings<false>(
S
); }
59
60
bool
SetProjectCommand::VisitSettings
(
ConstSettingsVisitor
&
S
)
61
{
return
VisitSettings<true>(
S
); }
62
63
void
SetProjectCommand::PopulateOrExchange
(
ShuttleGui
&
S
)
64
{
65
S
.AddSpace(0, 5);
66
S
.StartMultiColumn(3, wxALIGN_CENTER);
67
{
68
S
.Optional(
bHasName
).TieTextBox(
XXO
(
"Name:"
),
mName
);
69
S
.Optional(
bHasRate
).TieTextBox(
XXO
(
"Rate:"
),
mRate
);
70
S
.TieCheckBox(
XXO
(
"Resize:"
),
bHasSizing
);
71
S
.AddSpace(0,0);
72
}
73
S
.EndMultiColumn();
74
S
.StartMultiColumn(2, wxALIGN_CENTER);
75
{
76
S
.TieNumericTextBox(
XXO
(
"X:"
),
mPosX
);
77
S
.TieNumericTextBox(
XXO
(
"Y:"
),
mPosY
);
78
S
.TieNumericTextBox(
XXO
(
"Width:"
),
mWidth
);
79
S
.TieNumericTextBox(
XXO
(
"Height:"
),
mHeight
);
80
}
81
S
.EndMultiColumn();
82
}
83
84
bool
SetProjectCommand::Apply
(
const
CommandContext
& context)
85
{
86
auto
&
project
= context.
project
;
87
auto
&window =
GetProjectFrame
(
project
);
88
if
(
bHasName
)
89
window.SetLabel(
mName
);
90
91
if
(
bHasRate
&&
mRate
>= 1 &&
mRate
<= 1000000)
92
ProjectRate::Get
(
project
).
SetRate
(
mRate
);
93
94
if
(
bHasSizing
)
95
{
96
window.SetPosition( wxPoint(
mPosX
,
mPosY
));
97
window.SetSize( wxSize(
mWidth
,
mHeight
));
98
}
99
return
true
;
100
}
101
102
namespace
{
103
using namespace
MenuRegistry
;
104
105
// Register menu items
106
107
AttachedItem
sAttachment1
{
108
// Note that the PLUGIN_SYMBOL must have a space between words,
109
// whereas the short-form used here must not.
110
// (So if you did write "Compare Audio" for the PLUGIN_SYMBOL name, then
111
// you would have to use "CompareAudio" here.)
112
Command
(
wxT
(
"SetProject"
),
XXO
(
"Set Project..."
),
113
CommandDispatch::OnAudacityCommand
,
AudioIONotBusyFlag
() ),
114
wxT
(
"Optional/Extra/Part2/Scriptables1"
)
115
};
116
}
wxT
wxT("CloseDown"))
sAttachment1
AttachedItem sAttachment1
Definition:
BatchProcessDialog.cpp:1590
CommandContext.h
CommandDispatch.h
AudioIONotBusyFlag
const ReservedCommandFlag & AudioIONotBusyFlag()
Definition:
CommonCommandFlags.cpp:118
XO
XO("Cut/Copy/Paste")
XXO
XXO("&Cut/Copy/Paste Toolbar")
_
#define _(s)
Definition:
Internat.h:73
LoadCommands.h
MenuRegistry.h
Project.h
ProjectRate.h
an object holding per-project preferred sample rate
GetProjectFrame
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
Definition:
ProjectWindows.cpp:71
SetProjectCommand.h
Declarations of SetProjectCommand and SetProjectCommandType classes.
SettingsVisitor.h
ShuttleGui.h
project
const auto project
Definition:
TestWaveTrackMaker.cpp:18
S
#define S(N)
Definition:
ToChars.cpp:64
WaveTrack.h
CommandContext
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
Definition:
CommandContext.h:37
CommandContext::project
AudacityProject & project
Definition:
CommandContext.h:71
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition:
ComponentInterfaceSymbol.h:27
ProjectRate::Get
static ProjectRate & Get(AudacityProject &project)
Definition:
ProjectRate.cpp:28
ProjectRate::SetRate
void SetRate(double rate)
Definition:
ProjectRate.cpp:58
Registry::RegisteredItem
Generates classes whose instances register items at construction.
Definition:
Registry.h:388
SetProjectCommand::mWidth
int mWidth
Definition:
SetProjectCommand.h:47
SetProjectCommand::mPosY
int mPosY
Definition:
SetProjectCommand.h:46
SetProjectCommand::mHeight
int mHeight
Definition:
SetProjectCommand.h:48
SetProjectCommand::bHasSizing
bool bHasSizing
Definition:
SetProjectCommand.h:53
SetProjectCommand::bHasName
bool bHasName
Definition:
SetProjectCommand.h:52
SetProjectCommand::SetProjectCommand
SetProjectCommand()
Definition:
SetProjectCommand.cpp:42
SetProjectCommand::VisitSettings
bool VisitSettings(SettingsVisitorBase< Const > &S)
Definition:
SetProjectCommand.cpp:47
SetProjectCommand::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition:
SetProjectCommand.cpp:63
SetProjectCommand::bHasRate
bool bHasRate
Definition:
SetProjectCommand.h:54
SetProjectCommand::mName
wxString mName
Definition:
SetProjectCommand.h:44
SetProjectCommand::Symbol
static const ComponentInterfaceSymbol Symbol
Definition:
SetProjectCommand.h:26
SetProjectCommand::Apply
bool Apply(const CommandContext &context) override
Definition:
SetProjectCommand.cpp:84
SetProjectCommand::mRate
double mRate
Definition:
SetProjectCommand.h:49
SetProjectCommand::mPosX
int mPosX
Definition:
SetProjectCommand.h:45
SettingsVisitorBase
Visitor of effect or command parameters. This is a base class with lots of virtual functions that do ...
Definition:
SettingsVisitor.h:79
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition:
ShuttleGui.h:640
CommandDispatch::OnAudacityCommand
AUDACITY_DLL_API void OnAudacityCommand(const CommandContext &ctx)
Definition:
CommandDispatch.cpp:96
MenuRegistry
Definition:
MenuRegistry.cpp:19
MenuRegistry::Command
constexpr auto Command
Definition:
MenuRegistry.h:456
anonymous_namespace{SetProjectCommand.cpp}::reg
BuiltinCommandsModule::Registration< SetProjectCommand > reg
Definition:
SetProjectCommand.cpp:40
BuiltinCommandsModule::Registration
Definition:
LoadCommands.h:41
Generated by
1.9.3