From 9d501f69d60493aa4a0d6341351730c833028dd5 Mon Sep 17 00:00:00 2001 From: James Crook Date: Mon, 1 May 2017 11:46:12 +0100 Subject: [PATCH] Add preference for Record being to new track. --- src/AllThemeResources.h | 6 +++-- src/Menus.cpp | 27 ++++++++++++---------- src/Menus.h | 2 +- src/Theme.cpp | 11 ++++++++- src/Theme.h | 1 + src/prefs/GUIPrefs.cpp | 4 +--- src/prefs/PrefsDialog.cpp | 6 +++++ src/prefs/TracksBehaviorsPrefs.cpp | 3 +++ src/toolbars/ControlToolBar.cpp | 37 ++++++++++++++++++++---------- 9 files changed, 66 insertions(+), 31 deletions(-) diff --git a/src/AllThemeResources.h b/src/AllThemeResources.h index 756043db8..5df022361 100644 --- a/src/AllThemeResources.h +++ b/src/AllThemeResources.h @@ -65,12 +65,14 @@ from there. Audacity will look for a file called "Pause.png". DEFINE_IMAGE( bmpRecordDisabled, wxImage( 16, 16 ), wxT("RecordDisabled")); DEFINE_IMAGE( bmpCutPreview, wxImage( 16, 16 ), wxT("CutPreview")); DEFINE_IMAGE( bmpCutPreviewDisabled, wxImage( 16, 16 ), wxT("CutPreviewDisabled")); - DEFINE_IMAGE( bmpAppendRecord, wxImage( 16, 16 ), wxT("AppendRecord")); - DEFINE_IMAGE( bmpAppendRecordDisabled, wxImage( 16, 16 ), wxT("AppendRecordDisabled")); + DEFINE_IMAGE( bmpRecordBelow, wxImage( 16, 16 ), wxT("RecordBelow")); + DEFINE_IMAGE( bmpRecordBelowDisabled, wxImage( 16, 16 ), wxT("RecordBelowDisabled")); DEFINE_IMAGE( bmpScrub, wxImage( 18, 16 ), wxT("Scrub")); DEFINE_IMAGE( bmpScrubDisabled, wxImage( 18, 16 ), wxT("ScrubDisabled")); DEFINE_IMAGE( bmpSeek, wxImage( 26, 16 ), wxT("Seek")); DEFINE_IMAGE( bmpSeekDisabled, wxImage( 26, 16 ), wxT("SeekDisabled")); + DEFINE_IMAGE( bmpRecordBeside, wxImage( 16, 16 ), wxT("RecordBeside")); + DEFINE_IMAGE( bmpRecordBesideDisabled, wxImage( 16, 16 ), wxT("RecordBesideDisabled")); SET_THEME_FLAGS( resFlagNone ); diff --git a/src/Menus.cpp b/src/Menus.cpp index 09d3aa445..7ec945e3f 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -819,18 +819,19 @@ void AudacityProject::CreateMenusAndCommands() c->SetDefaultFlags(AudioIONotBusyFlag | CanStopAudioStreamFlag, AudioIONotBusyFlag | CanStopAudioStreamFlag); /* i18n-hint: (verb)*/ - c->AddItem(wxT("RecordBeside"), _("&Record"), FN(OnRecord), wxT("R")); - // The OnRecordBelow function is actually 'record-other', i.e. if normal record records beside, + c->AddItem(wxT("Record1stChoice"), _("&Record"), FN(OnRecord), wxT("R")); + // The OnRecord2ndChoice function is: if normal record records beside, // it records below, if normal record records below, it records beside. - // TODO: fix the naming, and also check we do 'the right thing' with other options like - // TimerRecord. - // PREFER_NEW_TRACKS is defined if we want the old behaviour of by default adding a new track on - // every new recording. -#ifndef PREFER_NEW_TRACKS - c->AddItem(wxT("RecordBelow"), _("Record &New Track"), FN(OnRecordBelow), wxT("Shift+R")); -#else - c->AddItem(wxT("RecordBelow"), _("Record Beside"), FN(OnRecordBelow), wxT("Shift+R")); -#endif + // TODO: Do 'the right thing' with other options like TimerRecord. + bool bPreferAppend; + gPrefs->Read("/GUI/PreferAppendRecord",&bPreferAppend, true); + c->AddItem( wxT("Record2ndChoice"), + // Our first choice is bound to R (by default) and gets the prime position. + // We supply the name for the 'other one' here. It should be bound to Shift+R + bPreferAppend ? _("Record &New Track") : _("&Append Record"), + FN(OnRecord2ndChoice), + wxT("Shift+R") + ); c->AddItem(wxT("TimerRecord"), _("&Timer Record..."), FN(OnTimerRecord), wxT("Shift+T")); // JKC: I decided to duplicate this between play and record, rather than put it @@ -2592,7 +2593,9 @@ void AudacityProject::OnRecord() GetControlToolBar()->OnRecord(evt); } -void AudacityProject::OnRecordBelow() +// If first choice is record same track 2nd choice is record new track +// and vice versa. +void AudacityProject::OnRecord2ndChoice() { wxCommandEvent evt; evt.SetInt(1); // 0 is default, use 1 to set shift on, 2 to clear it diff --git a/src/Menus.h b/src/Menus.h index 4fb2284c2..9ef8871dd 100644 --- a/src/Menus.h +++ b/src/Menus.h @@ -70,7 +70,7 @@ public: void OnStop(); void OnPause(); void OnRecord(); -void OnRecordBelow(); +void OnRecord2ndChoice(); void OnStopSelect(); void OnSkipStart(); void OnSkipEnd(); diff --git a/src/Theme.cpp b/src/Theme.cpp index 53ca95c1a..4cfca8f77 100644 --- a/src/Theme.cpp +++ b/src/Theme.cpp @@ -231,6 +231,7 @@ void Theme::EnsureInitialised() #endif LoadPreferredTheme(); + } bool ThemeBase::LoadPreferredTheme() @@ -323,6 +324,9 @@ void ThemeBase::LoadTheme( teThemeType Theme ) #endif } + RotateImageInto( bmpRecordBeside, bmpRecordBelow, false ); + RotateImageInto( bmpRecordBesideDisabled, bmpRecordBelowDisabled, false ); + if( bRecolourOnLoad ) RecolourTheme(); @@ -1220,4 +1224,9 @@ void ThemeBase::ReplaceImage( int iIndex, wxImage * pImage ) Bitmap( iIndex ) = wxBitmap( *pImage ); } - +void ThemeBase::RotateImageInto( int iTo, int iFrom, bool bClockwise ) +{ + wxImage img(theTheme.Bitmap( iFrom ).ConvertToImage() ); + wxImage img2 = img.Rotate90( bClockwise ); + ReplaceImage( iTo, &img2 ); +} diff --git a/src/Theme.h b/src/Theme.h index 1e7bd8b8c..c9fd90372 100644 --- a/src/Theme.h +++ b/src/Theme.h @@ -132,6 +132,7 @@ public: bool bIsUsingSystemTextColour; void ReplaceImage( int iIndex, wxImage * pImage ); + void RotateImageInto( int iTo, int iFrom, bool bClockwise ); void SetBrushColour( wxBrush & Brush, int iIndex ); void SetPenColour( wxPen & Pen, int iIndex ); diff --git a/src/prefs/GUIPrefs.cpp b/src/prefs/GUIPrefs.cpp index c500c2f0c..4138a243e 100644 --- a/src/prefs/GUIPrefs.cpp +++ b/src/prefs/GUIPrefs.cpp @@ -220,9 +220,7 @@ bool GUIPrefs::Apply() gPrefs->Write(wxT("/Locale/Language"), usedLang); gPrefs->Flush(); } - // Reads preference /GUI/Theme - theTheme.LoadPreferredTheme(); - theTheme.ApplyUpdatedImages(); + return true; } diff --git a/src/prefs/PrefsDialog.cpp b/src/prefs/PrefsDialog.cpp index 89d2fe53b..fb9b65515 100644 --- a/src/prefs/PrefsDialog.cpp +++ b/src/prefs/PrefsDialog.cpp @@ -69,6 +69,8 @@ #include "MidiIOPrefs.h" #endif +#include "../Theme.h" + BEGIN_EVENT_TABLE(PrefsDialog, wxDialogWrapper) EVT_BUTTON(wxID_OK, PrefsDialog::OnOK) EVT_BUTTON(wxID_CANCEL, PrefsDialog::OnCancel) @@ -412,6 +414,10 @@ void PrefsDialog::OnOK(wxCommandEvent & WXUNUSED(event)) gPrefs->Flush(); + // Reads preference /GUI/Theme + theTheme.LoadPreferredTheme(); + theTheme.ApplyUpdatedImages(); + SavePreferredPage(); #if USE_PORTMIXER diff --git a/src/prefs/TracksBehaviorsPrefs.cpp b/src/prefs/TracksBehaviorsPrefs.cpp index f759ac12b..a90a0f664 100644 --- a/src/prefs/TracksBehaviorsPrefs.cpp +++ b/src/prefs/TracksBehaviorsPrefs.cpp @@ -63,6 +63,9 @@ void TracksBehaviorsPrefs::PopulateOrExchange(ShuttleGui & S) S.TieCheckBox(_("&Select then act on entire project, if no audio selected"), wxT("/GUI/SelectAllOnNone"), true); + S.TieCheckBox(_("Append recordings to same track, by default"), + wxT("/GUI/PreferAppendRecord"), + true); /* i18n-hint: cut-lines are a lines indicating where to cut.*/ S.TieCheckBox(_("Enable cut &lines"), wxT("/GUI/EnableCutLines"), diff --git a/src/toolbars/ControlToolBar.cpp b/src/toolbars/ControlToolBar.cpp index 7b7e39bfb..9fcfb9948 100644 --- a/src/toolbars/ControlToolBar.cpp +++ b/src/toolbars/ControlToolBar.cpp @@ -193,8 +193,16 @@ void ControlToolBar::Populate() mRecord = MakeButton(bmpRecord, bmpRecord, bmpRecordDisabled, ID_RECORD_BUTTON, true, _("Record")); - MakeAlternateImages(*mRecord, 1, bmpAppendRecord, bmpAppendRecord, - bmpAppendRecordDisabled); + + bool bPreferAppend; + gPrefs->Read("/GUI/PreferAppendRecord",&bPreferAppend, true); + if( bPreferAppend ) + MakeAlternateImages(*mRecord, 1, bmpRecordBelow, bmpRecordBelow, + bmpRecordBelowDisabled); + else + MakeAlternateImages(*mRecord, 1, bmpRecordBeside, bmpRecordBeside, + bmpRecordBesideDisabled); + mRecord->FollowModifierKeys(); #if wxUSE_TOOLTIPS @@ -228,13 +236,16 @@ void ControlToolBar::RegenerateTooltips() case ID_RECORD_BUTTON: // Without shift commands.push_back(wxT("Record")); -#ifdef PREFER_NEW_TRACKS - commands.push_back(_("Append Record")); - commands.push_back(wxT("RecordAppend")); -#else - commands.push_back(_("Record New Track")); - commands.push_back(wxT("RecordBelow")); -#endif + { bool bPreferAppend; + gPrefs->Read("/GUI/PreferAppendRecord",&bPreferAppend, true); + if( bPreferAppend ){ + commands.push_back(_("Record New Track")); + commands.push_back(wxT("RecordBelow")); + } else { + commands.push_back(_("Append Record")); + commands.push_back(wxT("RecordAppend")); + } + } break; case ID_PAUSE_BUTTON: commands.push_back(wxT("Pause")); @@ -874,9 +885,11 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt) bool success = false; bool shifted = mRecord->WasShiftDown(); -#ifndef PREFER_NEW_TRACKS - shifted = !shifted; -#endif + + bool bPreferAppend; + gPrefs->Read("/GUI/PreferAppendRecord",&bPreferAppend, true); + if( bPreferAppend ) + shifted = !shifted; TrackList *trackList = p->GetTracks(); TrackList tracksCopy{};