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 "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
39{ XO("Set Project") };
40
42
44{
45}
46
47template<bool Const>
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
59 { return VisitSettings<false>(S); }
60
62 { return VisitSettings<true>(S); }
63
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
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)
94
95 if( bHasSizing )
96 {
97 window.SetPosition( wxPoint( mPosX, mPosY));
98 window.SetSize( wxSize( mWidth, mHeight ));
99 }
100 return true;
101}
102
103namespace {
104using namespace MenuTable;
105
106// Register menu items
107
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..."),
116};
117}
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
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:630
AUDACITY_DLL_API void OnAudacityCommand(const CommandContext &ctx)
constexpr auto Command
BuiltinCommandsModule::Registration< SetProjectCommand > reg