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 "
CommandManager.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
#include "../toolbars/SelectionBar.h"
35
36
#include <wx/frame.h>
37
38
const
ComponentInterfaceSymbol
SetProjectCommand::Symbol
39
{
XO
(
"Set Project"
) };
40
41
namespace
{
BuiltinCommandsModule::Registration< SetProjectCommand >
reg
; }
42
43
SetProjectCommand::SetProjectCommand
()
44
{
45
}
46
47
template
<
bool
Const>
48
bool
SetProjectCommand::VisitSettings
(
SettingsVisitorBase<Const>
&
S
){
49
S
.OptionalN(
bHasName
).Define(
mName
,
wxT
(
"Name"
),
_
(
"Project"
) );
50
S
.OptionalN(
bHasRate
).Define(
mRate
,
wxT
(
"Rate"
), 44100.0, 1.0, 1000000.0);
51
S
.OptionalY(
bHasSizing
).Define(
mPosX
,
wxT
(
"X"
), 10, 0, 2000);
52
S
.OptionalY(
bHasSizing
).Define(
mPosY
,
wxT
(
"Y"
), 10, 0, 2000);
53
S
.OptionalY(
bHasSizing
).Define(
mWidth
,
wxT
(
"Width"
), 1000, 200, 4000);
54
S
.OptionalY(
bHasSizing
).Define(
mHeight
,
wxT
(
"Height"
), 900, 200, 4000);
55
return
true
;
56
};
57
58
bool
SetProjectCommand::VisitSettings
(
SettingsVisitor
&
S
)
59
{
return
VisitSettings<false>(
S
); }
60
61
bool
SetProjectCommand::VisitSettings
(
ConstSettingsVisitor
&
S
)
62
{
return
VisitSettings<true>(
S
); }
63
64
void
SetProjectCommand::PopulateOrExchange
(
ShuttleGui
&
S
)
65
{
66
S
.AddSpace(0, 5);
67
S
.StartMultiColumn(3, wxALIGN_CENTER);
68
{
69
S
.Optional(
bHasName
).TieTextBox(
XXO
(
"Name:"
),
mName
);
70
S
.Optional(
bHasRate
).TieTextBox(
XXO
(
"Rate:"
),
mRate
);
71
S
.TieCheckBox(
XXO
(
"Resize:"
),
bHasSizing
);
72
S
.AddSpace(0,0);
73
}
74
S
.EndMultiColumn();
75
S
.StartMultiColumn(2, wxALIGN_CENTER);
76
{
77
S
.TieNumericTextBox(
XXO
(
"X:"
),
mPosX
);
78
S
.TieNumericTextBox(
XXO
(
"Y:"
),
mPosY
);
79
S
.TieNumericTextBox(
XXO
(
"Width:"
),
mWidth
);
80
S
.TieNumericTextBox(
XXO
(
"Height:"
),
mHeight
);
81
}
82
S
.EndMultiColumn();
83
}
84
85
bool
SetProjectCommand::Apply
(
const
CommandContext
& context)
86
{
87
auto
&
project
= context.
project
;
88
auto
&window =
GetProjectFrame
(
project
);
89
if
(
bHasName
)
90
window.SetLabel(
mName
);
91
92
if
(
bHasRate
&&
mRate
>= 1 &&
mRate
<= 1000000)
93
ProjectRate::Get
(
project
).
SetRate
(
mRate
);
94
95
if
(
bHasSizing
)
96
{
97
window.SetPosition( wxPoint(
mPosX
,
mPosY
));
98
window.SetSize( wxSize(
mWidth
,
mHeight
));
99
}
100
return
true
;
101
}
102
103
namespace
{
104
using namespace
MenuTable
;
105
106
// Register menu items
107
108
AttachedItem
sAttachment1
{
109
wxT
(
"Optional/Extra/Part2/Scriptables1"
),
110
// Note that the PLUGIN_SYMBOL must have a space between words,
111
// whereas the short-form used here must not.
112
// (So if you did write "Compare Audio" for the PLUGIN_SYMBOL name, then
113
// you would have to use "CompareAudio" here.)
114
Command
(
wxT
(
"SetProject"
),
XXO
(
"Set Project..."
),
115
CommandDispatch::OnAudacityCommand
,
AudioIONotBusyFlag
() )
116
};
117
}
wxT
wxT("CloseDown"))
sAttachment1
AttachedItem sAttachment1
Definition:
BatchProcessDialog.cpp:1575
CommandContext.h
CommandDispatch.h
CommandManager.h
AudioIONotBusyFlag
const ReservedCommandFlag & AudioIONotBusyFlag()
Definition:
CommonCommandFlags.cpp:127
XO
XO("Cut/Copy/Paste")
XXO
XXO("&Cut/Copy/Paste Toolbar")
_
#define _(s)
Definition:
Internat.h:73
LoadCommands.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:34
CommandContext::project
AudacityProject & project
Definition:
CommandContext.h:64
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
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:43
SetProjectCommand::VisitSettings
bool VisitSettings(SettingsVisitorBase< Const > &S)
Definition:
SetProjectCommand.cpp:48
SetProjectCommand::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition:
SetProjectCommand.cpp:64
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:85
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:630
CommandDispatch::OnAudacityCommand
AUDACITY_DLL_API void OnAudacityCommand(const CommandContext &ctx)
Definition:
CommandDispatch.cpp:95
MenuTable
Definition:
CommandManager.h:423
MenuTable::Command
constexpr auto Command
Definition:
CommandManager.h:678
anonymous_namespace{SetProjectCommand.cpp}::reg
BuiltinCommandsModule::Registration< SetProjectCommand > reg
Definition:
SetProjectCommand.cpp:41
BuiltinCommandsModule::Registration
Definition:
LoadCommands.h:41
MenuTable::AttachedItem
Definition:
CommandManager.h:696
Generated by
1.9.3