Audacity 3.2.0
DragCommand.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 James Crook
8
9******************************************************************//*******************************************************************/
18
19
20#include "DragCommand.h"
21
22#include "LoadCommands.h"
23#include "Project.h"
24#include "../ProjectWindows.h"
25#include "../WaveTrack.h"
26#include "../Shuttle.h"
27#include "../ShuttleGui.h"
28#include "CommandContext.h"
29
30#include <wx/frame.h>
31
33{ XO("Drag") };
34
36
38{
39}
40
42{
48};
49
51{
52 { XO("Panel") },
53 { wxT("App"), XO("Application") },
54 { wxT("Track0"), XO("Track 0") },
55 { wxT("Track1"), XO("Track 1") },
56};
57
58
59template<bool Const>
61 S.OptionalN( bHasId ).Define( mId, wxT("Id"), 11000, -100000, 1000000);
62 S.OptionalY( bHasWinName ).Define( mWinName, wxT("Window"), wxString{"Timeline"});
63 S.OptionalY( bHasFromX ).Define( mFromX, wxT("FromX"), 200.0, 0.0, 1000000.0);
64 S.OptionalY( bHasFromY ).Define( mFromY, wxT("FromY"), 10.0, 0.0, 1000000.0);
65 S.OptionalN( bHasToX ).Define( mToX, wxT("ToX"), 400.0, 0.0, 1000000.0);
66 S.OptionalN( bHasToY ).Define( mToY, wxT("ToY"), 10.0, 0.0, 1000000.0);
67 S.OptionalN( bHasRelativeTo ).DefineEnum( mRelativeTo, wxT("RelativeTo"), kPanel, kCoordTypeStrings, nCoordTypes );
68 return true;
69};
70
72 { return VisitSettings<false>(S); }
73
75 { return VisitSettings<true>(S); }
76
78{
79 S.AddSpace(0, 5);
80
81 S.StartMultiColumn(3, wxALIGN_CENTER);
82 {
83 /* i18n-hint abbreviates "Identity" or "Identifier" */
84 S.Optional( bHasId ).TieNumericTextBox( XXO("Id:"), mId );
85 S.Optional( bHasWinName ).TieTextBox( XXO("Window Name:"), mWinName );
86 S.Optional( bHasFromX ).TieNumericTextBox( XXO("From X:"), mFromX );
87 S.Optional( bHasFromY ).TieNumericTextBox( XXO("From Y:"), mFromY );
88 S.Optional( bHasToX ).TieNumericTextBox( XXO("To X:"), mToX );
89 S.Optional( bHasToY ).TieNumericTextBox( XXO("To Y:"), mToY );
90 S.Optional( bHasRelativeTo ).TieChoice( XXO("Relative To:"), mRelativeTo,
92 }
93 S.EndMultiColumn();
94}
95
97{
98 // Defaults if no value...
99 if( !bHasFromX )
100 mFromX = 200.0;
101 if( !bHasFromY )
102 mFromY = 10;
103 if( !bHasToX )
104 mToX = 400;
105 if( !bHasToY )
106 mToY = 10;
107
108 wxWindow * pWin = &GetProjectFrame( context.project );
109 wxWindow * pWin1 = nullptr;
110 wxMouseEvent Evt( wxEVT_MOTION );
111 Evt.m_x = mFromX;
112 Evt.m_y = mFromY;
113 if( bHasId )
114 pWin1 = pWin->FindWindowById( mId );
115 if( bHasWinName )
116 pWin1 = pWin->FindWindowByName( mWinName );
117 if( pWin1 )
118 pWin = pWin1;
119 // Process twice - possible bug in Audacity being worked around
120 // where we need an event to enter AND an event to move.
121 // AdornedRuler Quick-Play bug.
122 pWin->GetEventHandler()->ProcessEvent( Evt );
123 pWin->GetEventHandler()->ProcessEvent( Evt );
124 if( bHasToX ){
125 wxMouseEvent Evt2( wxEVT_LEFT_DOWN );
126 Evt2.m_leftDown = true;
127 Evt2.m_x = mFromX;
128 Evt2.m_y = mFromY;
129 Evt2.m_aux2Down = true;
130 pWin->GetEventHandler()->ProcessEvent( Evt2 );
131 wxMouseEvent Evt3( wxEVT_MOTION );
132 Evt3.m_leftDown = true;
133 Evt2.m_aux2Down = true;
134 Evt3.m_x = mToX;
135 Evt3.m_y = mToY;
136 // AdornedRuler Quick-Play bug again.
137 pWin->GetEventHandler()->ProcessEvent( Evt3 );
138 pWin->GetEventHandler()->ProcessEvent( Evt3 );
139 wxMouseEvent Evt4( wxEVT_LEFT_UP );
140 Evt2.m_aux2Down = true;
141 Evt4.m_x = mToX;
142 Evt4.m_y = mToY;
143 pWin->GetEventHandler()->ProcessEvent( Evt4 );
144 }
145 return true;
146}
kCoordTypes
Definition: DragCommand.cpp:42
@ nCoordTypes
Definition: DragCommand.cpp:47
@ kTrack0
Definition: DragCommand.cpp:45
@ kTrack1
Definition: DragCommand.cpp:46
@ kApp
Definition: DragCommand.cpp:44
@ kPanel
Definition: DragCommand.cpp:43
static const EnumValueSymbol kCoordTypeStrings[nCoordTypes]
Definition: DragCommand.cpp:50
Declarations of DragCommand and DragCommandType classes.
#define XXO(s)
Definition: Internat.h:44
#define XO(s)
Definition: Internat.h:31
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 ...
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
#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,...
bool Apply(const CommandContext &context) override
Definition: DragCommand.cpp:96
bool bHasWinName
Definition: DragCommand.h:56
double mToY
Definition: DragCommand.h:45
double mToX
Definition: DragCommand.h:44
static const ComponentInterfaceSymbol Symbol
Definition: DragCommand.h:25
bool bHasToX
Definition: DragCommand.h:52
wxString mWinName
Definition: DragCommand.h:48
double mFromY
Definition: DragCommand.h:43
double mFromX
Definition: DragCommand.h:42
bool bHasFromX
Definition: DragCommand.h:50
void PopulateOrExchange(ShuttleGui &S) override
Definition: DragCommand.cpp:77
bool bHasToY
Definition: DragCommand.h:53
bool bHasFromY
Definition: DragCommand.h:51
bool VisitSettings(SettingsVisitorBase< Const > &S)
Definition: DragCommand.cpp:60
bool bHasRelativeTo
Definition: DragCommand.h:54
int mRelativeTo
Definition: DragCommand.h:46
Visitor of effect or command parameters. This is a base class with lots of virtual functions that do ...
Definition: Shuttle.h:115
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
BuiltinCommandsModule::Registration< DragCommand > reg
Definition: DragCommand.cpp:35