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 "../WaveTrack.h"
26 #include "../Shuttle.h"
27 #include "../ShuttleGui.h"
28 #include "CommandContext.h"
29 #include "../toolbars/SelectionBar.h"
30 
31 #include <wx/frame.h>
32 
34 { XO("Set Project") };
35 
37 
39 {
40 }
41 
42 
44  S.OptionalN( bHasName ).Define( mName, wxT("Name"), _("Project") );
45  S.OptionalN( bHasRate ).Define( mRate, wxT("Rate"), 44100.0, 1.0, 1000000.0);
46  S.OptionalY( bHasSizing ).Define( mPosX, wxT("X"), 10.0, 0.0, 2000.0);
47  S.OptionalY( bHasSizing ).Define( mPosY, wxT("Y"), 10.0, 0.0, 2000.0);
48  S.OptionalY( bHasSizing ).Define( mWidth, wxT("Width"), 1000.0, 200.0, 4000.0);
49  S.OptionalY( bHasSizing ).Define( mHeight, wxT("Height"), 900.0, 200.0, 4000.0);
50  return true;
51 };
52 
54 {
55  S.AddSpace(0, 5);
56  S.StartMultiColumn(3, wxALIGN_CENTER);
57  {
58  S.Optional( bHasName ).TieTextBox( XXO("Name:"), mName );
59  S.Optional( bHasRate ).TieTextBox( XXO("Rate:"), mRate );
60  S.TieCheckBox( XXO("Resize:"), bHasSizing );
61  S.AddSpace(0,0);
62  }
63  S.EndMultiColumn();
64  S.StartMultiColumn(2, wxALIGN_CENTER);
65  {
66  S.TieNumericTextBox( XXO("X:"), mPosX );
67  S.TieNumericTextBox( XXO("Y:"), mPosY );
68  S.TieNumericTextBox( XXO("Width:"), mWidth );
69  S.TieNumericTextBox( XXO("Height:"), mHeight );
70  }
71  S.EndMultiColumn();
72 }
73 
75 {
76  auto &project = context.project;
77  auto &window = GetProjectFrame( project );
78  if( bHasName )
79  window.SetLabel(mName);
80 
81  if( bHasRate && mRate >= 1 && mRate <= 1000000 )
82  {
83  auto &bar = SelectionBar::Get( project );
84  bar.SetRate( mRate );
85  }
86 
87  if( bHasSizing )
88  {
89  window.SetPosition( wxPoint( mPosX, mPosY));
90  window.SetSize( wxSize( mWidth, mHeight ));
91  }
92  return true;
93 }
SelectionBar::Get
static SelectionBar & Get(AudacityProject &project)
Definition: SelectionBar.cpp:137
SetProjectCommand::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: SetProjectCommand.cpp:53
LoadCommands.h
SetProjectCommand::DefineParams
bool DefineParams(ShuttleParams &S) override
Definition: SetProjectCommand.cpp:43
ShuttleGuiBase::TieCheckBox
wxCheckBox * TieCheckBox(const TranslatableString &Prompt, bool &Var)
Definition: ShuttleGui.cpp:1629
SetProjectCommand::SetProjectCommand
SetProjectCommand()
Definition: SetProjectCommand.cpp:38
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2447
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:36
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:22
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1229
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: Project.cpp:188
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
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:52
SetProjectCommand::mName
wxString mName
Definition: SetProjectCommand.h:42
SetProjectCommand::Apply
bool Apply(const CommandContext &context) override
Definition: SetProjectCommand.cpp:74
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631