mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 16:19:43 +02:00
Add DragCommand. Default Y/N on optional fields. Open/Save project items.
This commit is contained in:
parent
1ffccbd748
commit
a36490a0b6
@ -1609,6 +1609,12 @@ void AudacityProject::CreateMenusAndCommands()
|
||||
AudioIONotBusyFlag, AudioIONotBusyFlag);
|
||||
c->AddItem(wxT("Export2"), _("Export..."), FN(OnAudacityCommand),
|
||||
AudioIONotBusyFlag, AudioIONotBusyFlag);
|
||||
c->AddItem(wxT("OpenProject"), _("Open Project..."), FN(OnAudacityCommand),
|
||||
AudioIONotBusyFlag, AudioIONotBusyFlag);
|
||||
c->AddItem(wxT("SaveProject"), _("Save Project..."), FN(OnAudacityCommand),
|
||||
AudioIONotBusyFlag, AudioIONotBusyFlag);
|
||||
c->AddItem(wxT("Drag"), _("Mousing About..."), FN(OnAudacityCommand),
|
||||
AudioIONotBusyFlag, AudioIONotBusyFlag);
|
||||
c->AddItem(wxT("CompareAudio"), _("Compare Audio..."), FN(OnAudacityCommand),
|
||||
AudioIONotBusyFlag, AudioIONotBusyFlag);
|
||||
c->AddItem(wxT("GetPreference"), _("Get Preference..."), FN(OnAudacityCommand),
|
||||
|
@ -74,6 +74,8 @@ public:
|
||||
bool ExchangeWithMaster(const wxString & Name) override;
|
||||
bool ShouldSet();
|
||||
virtual ShuttleParams & Optional( bool & var ){ pOptionalFlag = NULL;return *this;};
|
||||
virtual ShuttleParams & OptionalY( bool & var ){ return Optional( var );};
|
||||
virtual ShuttleParams & OptionalN( bool & var ){ return Optional( var );};
|
||||
virtual void Define( bool & var, const wxChar * key, const bool vdefault, const bool vmin=false, const bool vmax=false, const bool vscl=false );
|
||||
virtual void Define( size_t & var, const wxChar * key, const int vdefault, const int vmin=0, const int vmax=100000, const int vscl=1 );
|
||||
virtual void Define( int & var, const wxChar * key, const int vdefault, const int vmin=0, const int vmax=100000, const int vscl=1 );
|
||||
@ -156,6 +158,10 @@ class ShuttleDefaults : public ShuttleParams
|
||||
{
|
||||
public:
|
||||
wxString Result;
|
||||
virtual ShuttleParams & Optional( bool & var )override{ var = true; pOptionalFlag = NULL;return *this;};
|
||||
virtual ShuttleParams & OptionalY( bool & var )override{ var = true; pOptionalFlag = NULL;return *this;};
|
||||
virtual ShuttleParams & OptionalN( bool & var )override{ var = false;pOptionalFlag = NULL;return *this;};
|
||||
|
||||
void Define( bool & var, const wxChar * WXUNUSED(key), const bool vdefault,
|
||||
const bool WXUNUSED(vmin), const bool WXUNUSED(vmax), const bool WXUNUSED(vscl) )
|
||||
override { var = vdefault;};
|
||||
|
@ -2197,6 +2197,8 @@ void TrackInfo::GainSliderDrawFunction
|
||||
auto target = dynamic_cast<GainSliderHandle*>( context.target.get() );
|
||||
auto dc = &context.dc;
|
||||
bool hit = target && target->GetTrack().get() == pTrack;
|
||||
if( hit )
|
||||
hit=hit;
|
||||
bool captured = hit && target->IsClicked();
|
||||
SliderDrawFunction<WaveTrack>
|
||||
( &TrackInfo::GainSlider, dc, rect, pTrack, captured, hit);
|
||||
|
@ -294,5 +294,6 @@ bool CommandImplementation::Apply(const CommandContext & WXUNUSED(context))
|
||||
#include "SetLabelCommand.cpp"
|
||||
#include "SetProjectCommand.cpp"
|
||||
#include "SetEnvelopeCommand.cpp"
|
||||
#include "DragCommand.cpp"
|
||||
#endif
|
||||
|
||||
|
@ -313,6 +313,7 @@ LongMessageDialog::LongMessageDialog(wxWindow * parent,
|
||||
{
|
||||
mType = type;
|
||||
mAdditionalButtons = additionalButtons;
|
||||
SetName( "Long Message" );
|
||||
}
|
||||
|
||||
LongMessageDialog::~LongMessageDialog(){
|
||||
|
119
src/commands/DragCommand.cpp
Normal file
119
src/commands/DragCommand.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity - A Digital Audio Editor
|
||||
Copyright 1999-2018 Audacity Team
|
||||
License: wxwidgets
|
||||
|
||||
James Crook
|
||||
|
||||
******************************************************************//**
|
||||
|
||||
\file DragCommand.cpp
|
||||
\brief Definitions for DragCommand
|
||||
|
||||
\class DragCommand
|
||||
\brief Command that sets clip information
|
||||
|
||||
*//*******************************************************************/
|
||||
|
||||
#include "DragCommand.h"
|
||||
#include "../Project.h"
|
||||
#include "../Track.h"
|
||||
#include "../TrackPanel.h"
|
||||
#include "../WaveTrack.h"
|
||||
#include "../ShuttleGui.h"
|
||||
#include "CommandContext.h"
|
||||
|
||||
DragCommand::DragCommand()
|
||||
{
|
||||
}
|
||||
|
||||
enum kCoordTypes
|
||||
{
|
||||
kPanel,
|
||||
kApp,
|
||||
kTrack0,
|
||||
kTrack1,
|
||||
nCoordTypes
|
||||
};
|
||||
|
||||
static const wxString kCoordTypeStrings[nCoordTypes] =
|
||||
{
|
||||
XO("Panel"),
|
||||
XO("App"),
|
||||
XO("Track0"),
|
||||
XO("Track1"),
|
||||
};
|
||||
|
||||
|
||||
bool DragCommand::DefineParams( ShuttleParams & S ){
|
||||
wxArrayString coords( nCoordTypes, kCoordTypeStrings );
|
||||
S.OptionalN( bHasId ).Define( mId, wxT("Id"), 0.0, 11000.0, 1000000.0);
|
||||
S.OptionalY( bHasWinName ).Define( mWinName, wxT("Window"), "Timeline");
|
||||
S.OptionalY( bHasFromX ).Define( mFromX, wxT("FromX"), 200.0, 0.0, 1000000.0);
|
||||
S.OptionalY( bHasFromY ).Define( mFromY, wxT("FromY"), 10.0, 0.0, 1000000.0);
|
||||
S.OptionalN( bHasToX ).Define( mToX, wxT("ToX"), 400.0, 0.0, 1000000.0);
|
||||
S.OptionalN( bHasToY ).Define( mToY, wxT("ToY"), 10.0, 0.0, 1000000.0);
|
||||
S.OptionalN( bHasRelativeTo ).DefineEnum( mRelativeTo, wxT("RelativeTo"), kPanel, coords );
|
||||
return true;
|
||||
};
|
||||
|
||||
void DragCommand::PopulateOrExchange(ShuttleGui & S)
|
||||
{
|
||||
wxArrayString coords( nCoordTypes, kCoordTypeStrings );
|
||||
|
||||
S.AddSpace(0, 5);
|
||||
|
||||
S.StartMultiColumn(3, wxALIGN_CENTER);
|
||||
{
|
||||
S.Optional( bHasId ).TieNumericTextBox( _("Id:"), mId );
|
||||
S.Optional( bHasWinName ).TieTextBox( _("Window Name:"), mWinName );
|
||||
S.Optional( bHasFromX ).TieNumericTextBox( _("From X:"), mFromX );
|
||||
S.Optional( bHasFromY ).TieNumericTextBox( _("From Y:"), mFromY );
|
||||
S.Optional( bHasToX ).TieNumericTextBox( _("To X:"), mToX );
|
||||
S.Optional( bHasToY ).TieNumericTextBox( _("To Y:"), mToY );
|
||||
S.Optional( bHasRelativeTo ).TieChoice( _("Relative To:"), mRelativeTo, &coords );
|
||||
}
|
||||
S.EndMultiColumn();
|
||||
}
|
||||
|
||||
bool DragCommand::Apply(const CommandContext & context)
|
||||
{
|
||||
wxWindow * pWin = context.GetProject();
|
||||
wxWindow * pWin1 = nullptr;
|
||||
wxMouseEvent Evt( wxEVT_MOTION );
|
||||
Evt.m_x = mFromX;
|
||||
Evt.m_y = mFromY;
|
||||
if( bHasId )
|
||||
pWin1 = pWin->FindWindowById( mId );
|
||||
if( bHasWinName )
|
||||
pWin1 = pWin->FindWindowByName( mWinName );
|
||||
if( pWin1 )
|
||||
pWin = pWin1;
|
||||
// Process twice - possible bug in Audacity being worked around
|
||||
// where we need an event to enter AND an event to move.
|
||||
// AdornedRuler Quick-Play bug.
|
||||
pWin->GetEventHandler()->ProcessEvent( Evt );
|
||||
pWin->GetEventHandler()->ProcessEvent( Evt );
|
||||
if( bHasToX ){
|
||||
wxMouseEvent Evt2( wxEVT_LEFT_DOWN );
|
||||
Evt2.m_x = mFromX;
|
||||
Evt2.m_y = mFromY;
|
||||
Evt2.m_aux2Down = true;
|
||||
pWin->GetEventHandler()->ProcessEvent( Evt2 );
|
||||
wxMouseEvent Evt3( wxEVT_MOTION );
|
||||
Evt3.m_leftDown = true;
|
||||
Evt2.m_aux2Down = true;
|
||||
Evt3.m_x = mToX;
|
||||
Evt3.m_y = mToY;
|
||||
// AdornedRuler Quick-Play bug again.
|
||||
pWin->GetEventHandler()->ProcessEvent( Evt3 );
|
||||
pWin->GetEventHandler()->ProcessEvent( Evt3 );
|
||||
wxMouseEvent Evt4( wxEVT_LEFT_UP );
|
||||
Evt2.m_aux2Down = true;
|
||||
Evt4.m_x = mToX;
|
||||
Evt4.m_y = mToY;
|
||||
pWin->GetEventHandler()->ProcessEvent( Evt4 );
|
||||
}
|
||||
return true;
|
||||
}
|
59
src/commands/DragCommand.h
Normal file
59
src/commands/DragCommand.h
Normal file
@ -0,0 +1,59 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity - A Digital Audio Editor
|
||||
Copyright 1999-2009 Audacity Team
|
||||
License: wxwidgets
|
||||
|
||||
James Crook
|
||||
|
||||
******************************************************************//**
|
||||
|
||||
\file DragCommand.h
|
||||
\brief Declarations of DragCommand and DragCommandType classes
|
||||
|
||||
*//*******************************************************************/
|
||||
|
||||
#ifndef __DRAG_COMMAND__
|
||||
#define __DRAG_COMMAND__
|
||||
|
||||
#include "Command.h"
|
||||
#include "CommandType.h"
|
||||
|
||||
#define DRAG_PLUGIN_SYMBOL XO("Drag")
|
||||
|
||||
class DragCommand : public AudacityCommand
|
||||
{
|
||||
public:
|
||||
DragCommand();
|
||||
// CommandDefinitionInterface overrides
|
||||
wxString GetSymbol() override {return DRAG_PLUGIN_SYMBOL;};
|
||||
wxString GetDescription() override {return _("Drags mouse from one place to another.");};
|
||||
bool DefineParams( ShuttleParams & S ) override;
|
||||
void PopulateOrExchange(ShuttleGui & S) override;
|
||||
|
||||
// AudacityCommand overrides
|
||||
wxString ManualPage() override {return wxT("Extra_Menu:_Automation#drag");};
|
||||
|
||||
bool Apply(const CommandContext & context) override;
|
||||
|
||||
public:
|
||||
double mFromX;
|
||||
double mFromY;
|
||||
double mToX;
|
||||
double mToY;
|
||||
int mRelativeTo;
|
||||
int mId;
|
||||
wxString mWinName;
|
||||
|
||||
bool bHasFromX;
|
||||
bool bHasFromY;
|
||||
bool bHasToX;
|
||||
bool bHasToY;
|
||||
bool bHasRelativeTo;
|
||||
bool bHasId;
|
||||
bool bHasWinName;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* End of include guard: __DRAG_COMMAND__ */
|
@ -585,7 +585,8 @@ void GetInfoCommand::ExploreWindows( const CommandContext &context,
|
||||
context.AddItem( R.GetTop() );
|
||||
context.AddItem( R.GetRight() );
|
||||
context.AddItem( R.GetBottom() );
|
||||
context.AddItem( Name );
|
||||
context.AddItem( Name );
|
||||
context.AddItem( item->GetId() );
|
||||
context.EndArray();
|
||||
|
||||
ExploreWindows( context, P, item, item->GetId(), depth+1 );
|
||||
|
@ -37,7 +37,7 @@ modelled on BuiltinEffectsModule
|
||||
#include "../commands/SetEnvelopeCommand.h"
|
||||
#include "../commands/SetClipCommand.h"
|
||||
#include "../commands/SetProjectCommand.h"
|
||||
|
||||
#include "../commands/DragCommand.h"
|
||||
|
||||
//
|
||||
// Define the list of COMMANDs that will be autoregistered and how to instantiate each
|
||||
@ -46,6 +46,7 @@ modelled on BuiltinEffectsModule
|
||||
COMMAND( DEMO, DemoCommand, () ) \
|
||||
COMMAND( MESSAGE, MessageCommand, () ) \
|
||||
COMMAND( SCREENSHOT, ScreenshotCommand, () ) \
|
||||
COMMAND( DRAG, DragCommand, () ) \
|
||||
COMMAND( COMPARE_AUDIO, CompareAudioCommand, () ) \
|
||||
COMMAND( SET_TRACK, SetTrackCommand, () ) \
|
||||
COMMAND( SET_ENVELOPE, SetEnvelopeCommand, () ) \
|
||||
|
@ -48,13 +48,13 @@ static const wxString kColourStrings[nColours] =
|
||||
|
||||
bool SetClipCommand::DefineParams( ShuttleParams & S ){
|
||||
wxArrayString colours( nColours, kColourStrings );
|
||||
S.Optional( bHasTrackIndex ).Define( mTrackIndex, wxT("Track"), 0, 0, 100 );
|
||||
S.Optional( bHasChannelIndex ).Define( mChannelIndex, wxT("Channel"), 0, 0, 100 );
|
||||
S.Optional( bHasContainsTime ).Define( mContainsTime, wxT("At"), 0.0, 0.0, 100000.0 );
|
||||
S.Optional( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours );
|
||||
S.OptionalY( bHasTrackIndex ).Define( mTrackIndex, wxT("Track"), 0, 0, 100 );
|
||||
S.OptionalN( bHasChannelIndex ).Define( mChannelIndex, wxT("Channel"), 0, 0, 100 );
|
||||
S.OptionalY( bHasContainsTime ).Define( mContainsTime, wxT("At"), 0.0, 0.0, 100000.0 );
|
||||
S.OptionalN( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours );
|
||||
// Allowing a negative start time is not a mistake.
|
||||
// It will be used in demonstrating time before zero.
|
||||
S.Optional( bHasT0 ).Define( mT0, wxT("Start"), 0.0, -5.0, 1000000.0);
|
||||
S.OptionalN( bHasT0 ).Define( mT0, wxT("Start"), 0.0, -5.0, 1000000.0);
|
||||
return true;
|
||||
};
|
||||
|
||||
|
@ -31,11 +31,11 @@ SetLabelCommand::SetLabelCommand()
|
||||
|
||||
|
||||
bool SetLabelCommand::DefineParams( ShuttleParams & S ){
|
||||
S.Define( mLabelIndex, wxT("Label"), 0, 0, 100 );
|
||||
S.Optional( bHasText ).Define( mText, wxT("Text"), wxT("empty") );
|
||||
S.Optional( bHasT0 ).Define( mT0, wxT("Start"), 0.0, 0.0, 100000.0);
|
||||
S.Optional( bHasT1 ).Define( mT1, wxT("End"), 0.0, 0.0, 100000.0);
|
||||
S.Optional( bHasSelected ).Define( mbSelected, wxT("Selected"), false );
|
||||
S.Define( mLabelIndex, wxT("Label"), 0, 0, 100 );
|
||||
S.OptionalY( bHasText ).Define( mText, wxT("Text"), wxT("empty") );
|
||||
S.OptionalY( bHasT0 ).Define( mT0, wxT("Start"), 0.0, 0.0, 100000.0);
|
||||
S.OptionalY( bHasT1 ).Define( mT1, wxT("End"), 0.0, 0.0, 100000.0);
|
||||
S.OptionalN( bHasSelected ).Define( mbSelected, wxT("Selected"), false );
|
||||
return true;
|
||||
};
|
||||
|
||||
|
@ -82,22 +82,22 @@ bool SetTrackCommand::DefineParams( ShuttleParams & S ){
|
||||
wxArrayString displays( nDisplayTypes, kDisplayTypeStrings );
|
||||
wxArrayString scales( nScaleTypes, kScaleTypeStrings );
|
||||
|
||||
S.Optional( bHasTrackIndex ).Define( mTrackIndex, wxT("Track"), 0, 0, 100 );
|
||||
S.Optional( bHasChannelIndex ).Define( mChannelIndex, wxT("Channel"), 0, 0, 100 );
|
||||
S.Optional( bHasTrackName ).Define( mTrackName, wxT("Name"), wxT("Unnamed") );
|
||||
S.Optional( bHasPan ).Define( mPan, wxT("Pan"), 0.0, -1.0, 1.0);
|
||||
S.Optional( bHasGain ).Define( mGain, wxT("Gain"), 1.0, 0.0, 10.0);
|
||||
S.Optional( bHasHeight ).Define( mHeight, wxT("Height"), 120, 44, 700 );
|
||||
S.Optional( bHasDisplayType ).DefineEnum( mDisplayType, wxT("Display"), kWaveform, displays );
|
||||
S.Optional( bHasScaleType ).DefineEnum( mScaleType, wxT("Scale"), kLinear, scales );
|
||||
S.Optional( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours );
|
||||
S.Optional( bHasSpectralSelect ).Define( bSpectralSelect, wxT("SpectralSel"),true );
|
||||
S.Optional( bHasGrayScale ).Define( bGrayScale, wxT("GrayScale"), false );
|
||||
S.OptionalY( bHasTrackIndex ).Define( mTrackIndex, wxT("Track"), 0, 0, 100 );
|
||||
S.OptionalN( bHasChannelIndex ).Define( mChannelIndex, wxT("Channel"), 0, 0, 100 );
|
||||
S.OptionalN( bHasTrackName ).Define( mTrackName, wxT("Name"), wxT("Unnamed") );
|
||||
S.OptionalN( bHasPan ).Define( mPan, wxT("Pan"), 0.0, -1.0, 1.0);
|
||||
S.OptionalN( bHasGain ).Define( mGain, wxT("Gain"), 1.0, 0.0, 10.0);
|
||||
S.OptionalN( bHasHeight ).Define( mHeight, wxT("Height"), 120, 44, 700 );
|
||||
S.OptionalN( bHasDisplayType ).DefineEnum( mDisplayType, wxT("Display"), kWaveform, displays );
|
||||
S.OptionalN( bHasScaleType ).DefineEnum( mScaleType, wxT("Scale"), kLinear, scales );
|
||||
S.OptionalN( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours );
|
||||
S.OptionalN( bHasSpectralSelect ).Define( bSpectralSelect, wxT("SpectralSel"),true );
|
||||
S.OptionalN( bHasGrayScale ).Define( bGrayScale, wxT("GrayScale"), false );
|
||||
// There is also a select command. This is an alternative.
|
||||
S.Optional( bHasSelected ).Define( bSelected, wxT("Selected"), false );
|
||||
S.Optional( bHasFocused ).Define( bFocused, wxT("Focused"), false );
|
||||
S.Optional( bHasSolo ).Define( bSolo, wxT("Solo"), false );
|
||||
S.Optional( bHasMute ).Define( bMute, wxT("Mute"), false );
|
||||
S.OptionalN( bHasSelected ).Define( bSelected, wxT("Selected"), false );
|
||||
S.OptionalN( bHasFocused ).Define( bFocused, wxT("Focused"), false );
|
||||
S.OptionalN( bHasSolo ).Define( bSolo, wxT("Solo"), false );
|
||||
S.OptionalN( bHasMute ).Define( bMute, wxT("Mute"), false );
|
||||
return true;
|
||||
};
|
||||
|
||||
|
@ -2636,7 +2636,7 @@ void AdornedRulerPanel::HandleQPDrag(wxMouseEvent &/*event*/, wxCoord mousePosX)
|
||||
case mesDraggingPlayRegionStart:
|
||||
HideQuickPlayIndicator();
|
||||
|
||||
// Don't start dragging until beyond tollerance initial playback start
|
||||
// Don't start dragging until beyond tolerance initial playback start
|
||||
if (!mIsDragging && isWithinStart)
|
||||
mQuickPlayPos = mOldPlayRegionStart;
|
||||
else
|
||||
|
@ -141,6 +141,7 @@
|
||||
<ClCompile Include="..\..\..\src\commands\CommandContext.cpp" />
|
||||
<ClCompile Include="..\..\..\src\commands\CommandTargets.cpp" />
|
||||
<ClCompile Include="..\..\..\src\commands\Demo.cpp" />
|
||||
<ClCompile Include="..\..\..\src\commands\DragCommand.cpp" />
|
||||
<ClCompile Include="..\..\..\src\commands\LoadCommands.cpp" />
|
||||
<ClCompile Include="..\..\..\src\commands\OpenSaveCommands.cpp" />
|
||||
<ClCompile Include="..\..\..\src\commands\SetClipCommand.cpp" />
|
||||
@ -483,6 +484,7 @@
|
||||
<ClInclude Include="..\..\..\src\commands\CommandFlag.h" />
|
||||
<ClInclude Include="..\..\..\src\commands\CommandFunctors.h" />
|
||||
<ClInclude Include="..\..\..\src\commands\Demo.h" />
|
||||
<ClInclude Include="..\..\..\src\commands\DragCommand.h" />
|
||||
<ClInclude Include="..\..\..\src\commands\LoadCommands.h" />
|
||||
<ClInclude Include="..\..\..\src\commands\OpenSaveCommands.h" />
|
||||
<ClInclude Include="..\..\..\src\commands\SetClipCommand.h" />
|
||||
|
@ -1076,6 +1076,9 @@
|
||||
<ClCompile Include="..\..\..\src\commands\SetEnvelopeCommand.cpp">
|
||||
<Filter>src\commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\commands\DragCommand.cpp">
|
||||
<Filter>src\commands</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\src\AboutDialog.h">
|
||||
@ -2146,6 +2149,9 @@
|
||||
<ClInclude Include="..\..\..\src\commands\SetEnvelopeCommand.h">
|
||||
<Filter>src\commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\commands\DragCommand.h">
|
||||
<Filter>src\commands</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\..\audacity.ico">
|
||||
|
Loading…
x
Reference in New Issue
Block a user