mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-19 17:40:51 +02:00
Bug 1837 - Unable to set empty track name
Also AudacityCommand dialogs now only show help button if there is help. Also Track only shows track name over it, if there is a track name.
This commit is contained in:
parent
8ce8e7bcce
commit
ae564b2724
@ -486,7 +486,9 @@ void TrackArtist::DrawTrack(TrackPanelDrawingContext &context,
|
|||||||
|
|
||||||
if (mbShowTrackNameInWaveform &&
|
if (mbShowTrackNameInWaveform &&
|
||||||
// Exclude right channel of stereo track
|
// Exclude right channel of stereo track
|
||||||
!(!wt->GetLinked() && wt->GetLink())) {
|
!(!wt->GetLinked() && wt->GetLink()) &&
|
||||||
|
// Exclude empty name.
|
||||||
|
!wt->GetName().IsEmpty()) {
|
||||||
wxBrush Brush;
|
wxBrush Brush;
|
||||||
wxCoord x,y;
|
wxCoord x,y;
|
||||||
wxFont labelFont(12, wxSWISS, wxNORMAL, wxNORMAL);
|
wxFont labelFont(12, wxSWISS, wxNORMAL, wxNORMAL);
|
||||||
|
@ -274,7 +274,9 @@ AudacityCommandDialog::AudacityCommandDialog(wxWindow * parent,
|
|||||||
mType = type;
|
mType = type;
|
||||||
wxASSERT( pCommand );
|
wxASSERT( pCommand );
|
||||||
mpCommand = pCommand;
|
mpCommand = pCommand;
|
||||||
mAdditionalButtons = additionalButtons |eCancelButton | eHelpButton;
|
mAdditionalButtons = additionalButtons |eCancelButton;
|
||||||
|
if( !pCommand->ManualPage().IsEmpty() )
|
||||||
|
mAdditionalButtons |= eHelpButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudacityCommandDialog::Init()
|
bool AudacityCommandDialog::Init()
|
||||||
|
@ -20,6 +20,10 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#include "../../TrackPanelMouseEvent.h"
|
#include "../../TrackPanelMouseEvent.h"
|
||||||
#include "../../Track.h"
|
#include "../../Track.h"
|
||||||
#include <wx/textdlg.h>
|
#include <wx/textdlg.h>
|
||||||
|
#include "../../commands/CommandType.h"
|
||||||
|
#include "../../commands/Command.h"
|
||||||
|
#include "../../ShuttleGui.h"
|
||||||
|
|
||||||
|
|
||||||
TrackControls::TrackControls( std::shared_ptr<Track> pTrack )
|
TrackControls::TrackControls( std::shared_ptr<Track> pTrack )
|
||||||
: mwTrack{ pTrack }
|
: mwTrack{ pTrack }
|
||||||
@ -153,6 +157,42 @@ BEGIN_POPUP_MENU(TrackMenuTable)
|
|||||||
OnMoveTrack)
|
OnMoveTrack)
|
||||||
END_POPUP_MENU()
|
END_POPUP_MENU()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define SET_TRACK_NAME_PLUGIN_SYMBOL XO("Set Track Name")
|
||||||
|
|
||||||
|
// An example of using an AudacityCommand simply to create a dialog.
|
||||||
|
// We can add additional functions later, if we want to make it
|
||||||
|
// available to scripting.
|
||||||
|
// However there is no reason to, as SetTrackStatus is already provided.
|
||||||
|
class SetTrackNameCommand : public AudacityCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// CommandDefinitionInterface overrides
|
||||||
|
wxString GetSymbol() override {return SET_TRACK_NAME_PLUGIN_SYMBOL;};
|
||||||
|
//wxString GetDescription() override {return _("Sets the track name.");};
|
||||||
|
//bool DefineParams( ShuttleParams & S ) override;
|
||||||
|
void PopulateOrExchange(ShuttleGui & S) override;
|
||||||
|
//bool Apply(const CommandContext & context) override;
|
||||||
|
|
||||||
|
// Provide an override, if we want the help button.
|
||||||
|
// wxString ManualPage() override {return wxT("");};
|
||||||
|
public:
|
||||||
|
wxString mName;
|
||||||
|
};
|
||||||
|
|
||||||
|
void SetTrackNameCommand::PopulateOrExchange(ShuttleGui & S)
|
||||||
|
{
|
||||||
|
S.AddSpace(0, 5);
|
||||||
|
|
||||||
|
S.StartMultiColumn(2, wxALIGN_CENTER);
|
||||||
|
{
|
||||||
|
S.TieTextBox(_("Name:"),mName);
|
||||||
|
}
|
||||||
|
S.EndMultiColumn();
|
||||||
|
}
|
||||||
|
|
||||||
void TrackMenuTable::OnSetName(wxCommandEvent &)
|
void TrackMenuTable::OnSetName(wxCommandEvent &)
|
||||||
{
|
{
|
||||||
Track *const pTrack = mpData->pTrack;
|
Track *const pTrack = mpData->pTrack;
|
||||||
@ -160,11 +200,14 @@ void TrackMenuTable::OnSetName(wxCommandEvent &)
|
|||||||
{
|
{
|
||||||
AudacityProject *const proj = ::GetActiveProject();
|
AudacityProject *const proj = ::GetActiveProject();
|
||||||
const wxString oldName = pTrack->GetName();
|
const wxString oldName = pTrack->GetName();
|
||||||
const wxString newName =
|
|
||||||
wxGetTextFromUser(_("Change track name to:"),
|
SetTrackNameCommand Command;
|
||||||
_("Track Name"), oldName);
|
Command.mName = oldName;
|
||||||
if (newName != wxT("")) // wxGetTextFromUser returns empty string on Cancel.
|
// Bug 1837 : We need an OK/Cancel result if we are to enter a blank string.
|
||||||
|
bool bResult = Command.PromptUser( proj );
|
||||||
|
if (bResult)
|
||||||
{
|
{
|
||||||
|
wxString newName = Command.mName;
|
||||||
pTrack->SetName(newName);
|
pTrack->SetName(newName);
|
||||||
// if we have a linked channel this name should change as well
|
// if we have a linked channel this name should change as well
|
||||||
// (otherwise sort by name and time will crash).
|
// (otherwise sort by name and time will crash).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user