Audacity  3.0.3
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 "LoadCommands.h"
24 #include "Project.h"
25 #include "../ProjectWindows.h"
26 #include "../WaveTrack.h"
27 #include "../Shuttle.h"
28 #include "../ShuttleGui.h"
29 #include "CommandContext.h"
30 #include "../toolbars/SelectionBar.h"
31 
32 #include <wx/frame.h>
33 
35 { XO("Set Project") };
36 
38 
40 {
41 }
42 
43 
45  S.OptionalN( bHasName ).Define( mName, wxT("Name"), _("Project") );
46  S.OptionalN( bHasRate ).Define( mRate, wxT("Rate"), 44100.0, 1.0, 1000000.0);
47  S.OptionalY( bHasSizing ).Define( mPosX, wxT("X"), 10.0, 0.0, 2000.0);
48  S.OptionalY( bHasSizing ).Define( mPosY, wxT("Y"), 10.0, 0.0, 2000.0);
49  S.OptionalY( bHasSizing ).Define( mWidth, wxT("Width"), 1000.0, 200.0, 4000.0);
50  S.OptionalY( bHasSizing ).Define( mHeight, wxT("Height"), 900.0, 200.0, 4000.0);
51  return true;
52 };
53 
55 {
56  S.AddSpace(0, 5);
57  S.StartMultiColumn(3, wxALIGN_CENTER);
58  {
59  S.Optional( bHasName ).TieTextBox( XXO("Name:"), mName );
60  S.Optional( bHasRate ).TieTextBox( XXO("Rate:"), mRate );
61  S.TieCheckBox( XXO("Resize:"), bHasSizing );
62  S.AddSpace(0,0);
63  }
64  S.EndMultiColumn();
65  S.StartMultiColumn(2, wxALIGN_CENTER);
66  {
67  S.TieNumericTextBox( XXO("X:"), mPosX );
68  S.TieNumericTextBox( XXO("Y:"), mPosY );
69  S.TieNumericTextBox( XXO("Width:"), mWidth );
70  S.TieNumericTextBox( XXO("Height:"), mHeight );
71  }
72  S.EndMultiColumn();
73 }
74 
76 {
77  auto &project = context.project;
78  auto &window = GetProjectFrame( project );
79  if( bHasName )
80  window.SetLabel(mName);
81 
82  if( bHasRate && mRate >= 1 && mRate <= 1000000 )
83  {
84  auto &bar = SelectionBar::Get( project );
85  bar.SetRate( mRate );
86  }
87 
88  if( bHasSizing )
89  {
90  window.SetPosition( wxPoint( mPosX, mPosY));
91  window.SetSize( wxSize( mWidth, mHeight ));
92  }
93  return true;
94 }
SelectionBar::Get
static SelectionBar & Get(AudacityProject &project)
Definition: SelectionBar.cpp:138
SetProjectCommand::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: SetProjectCommand.cpp:54
LoadCommands.h
Project.h
SetProjectCommand::DefineParams
bool DefineParams(ShuttleParams &S) override
Definition: SetProjectCommand.cpp:44
ShuttleGuiBase::TieCheckBox
wxCheckBox * TieCheckBox(const TranslatableString &Prompt, bool &Var)
Definition: ShuttleGui.cpp:1629
SetProjectCommand::SetProjectCommand
SetProjectCommand()
Definition: SetProjectCommand.cpp:39
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2459
XO
#define XO(s)
Definition: Internat.h:31
SetProjectCommand::bHasRate
bool bHasRate
Definition: SetProjectCommand.h:52
ShuttleParams
Shuttle that deals with parameters. This is a base class with lots of virtual functions that do nothi...
Definition: Shuttle.h:62
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1238
SetProjectCommand::mPosY
int mPosY
Definition: SetProjectCommand.h:44
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterfaceSymbol.h:27
ShuttleParams::OptionalN
virtual ShuttleParams & OptionalN(bool &var)
Definition: Shuttle.h:72
ShuttleGuiBase::TieTextBox
wxTextCtrl * TieTextBox(const TranslatableString &Caption, wxString &Value, const int nChars=0)
Definition: ShuttleGui.cpp:1652
BuiltinCommandsModule::Registration
Definition: LoadCommands.h:41
anonymous_namespace{SetProjectCommand.cpp}::reg
BuiltinCommandsModule::Registration< SetProjectCommand > reg
Definition: SetProjectCommand.cpp:37
CommandContext.h
XXO
#define XXO(s)
Definition: Internat.h:44
CommandContext
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
Definition: CommandContext.h:34
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1229
SetProjectCommand::bHasName
bool bHasName
Definition: SetProjectCommand.h:50
SetProjectCommand::mPosX
int mPosX
Definition: SetProjectCommand.h:43
SetProjectCommand::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: SetProjectCommand.h:26
SetProjectCommand::mRate
double mRate
Definition: SetProjectCommand.h:47
SetProjectCommand::bHasSizing
bool bHasSizing
Definition: SetProjectCommand.h:51
ShuttleParams::OptionalY
virtual ShuttleParams & OptionalY(bool &var)
Definition: Shuttle.h:71
ShuttleGuiBase::TieNumericTextBox
wxTextCtrl * TieNumericTextBox(const TranslatableString &Prompt, int &Value, const int nChars=0)
Definition: ShuttleGui.cpp:1673
SetProjectCommand.h
Declarations of SetProjectCommand and SetProjectCommandType classes.
_
#define _(s)
Definition: Internat.h:75
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:72
SetProjectCommand::mWidth
int mWidth
Definition: SetProjectCommand.h:45
SetProjectCommand::mHeight
int mHeight
Definition: SetProjectCommand.h:46
ShuttleParams::Define
virtual void Define(bool &var, const wxChar *key, const bool vdefault, const bool vmin=false, const bool vmax=false, const bool vscl=false)
Definition: Shuttle.cpp:332
ShuttleGui::Optional
ShuttleGui & Optional(bool &bVar)
Definition: ShuttleGui.cpp:2280
CommandContext::project
AudacityProject & project
Definition: CommandContext.h:64
SetProjectCommand::mName
wxString mName
Definition: SetProjectCommand.h:42
SetProjectCommand::Apply
bool Apply(const CommandContext &context) override
Definition: SetProjectCommand.cpp:75
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631