Audacity 3.2.0
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
38{ XO("Set Project") };
39
41
43{
44}
45
46template<bool Const>
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
58 { return VisitSettings<false>(S); }
59
61 { return VisitSettings<true>(S); }
62
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
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)
93
94 if( bHasSizing )
95 {
96 window.SetPosition( wxPoint( mPosX, mPosY));
97 window.SetSize( wxSize( mWidth, mHeight ));
98 }
99 return true;
100}
101
102namespace {
103using namespace MenuRegistry;
104
105// Register menu items
106
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..."),
114 wxT("Optional/Extra/Part2/Scriptables1")
115};
116}
wxT("CloseDown"))
AttachedItem sAttachment1
const ReservedCommandFlag & AudioIONotBusyFlag()
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define _(s)
Definition: Internat.h:73
an object holding per-project preferred sample rate
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 ...
Declarations of SetProjectCommand and SetProjectCommandType classes.
const auto project
#define S(N)
Definition: ToChars.cpp:64
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
AudacityProject & project
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:28
void SetRate(double rate)
Definition: ProjectRate.cpp:58
Generates classes whose instances register items at construction.
Definition: Registry.h:388
bool VisitSettings(SettingsVisitorBase< Const > &S)
void PopulateOrExchange(ShuttleGui &S) override
static const ComponentInterfaceSymbol Symbol
bool Apply(const CommandContext &context) override
Visitor of effect or command parameters. This is a base class with lots of virtual functions that do ...
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
AUDACITY_DLL_API void OnAudacityCommand(const CommandContext &ctx)
constexpr auto Command
Definition: MenuRegistry.h:456
BuiltinCommandsModule::Registration< SetProjectCommand > reg