1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-27 15:53:49 +01:00

Hotkeys for effects. (uses numbers for effect names)

This commit is contained in:
james.k.crook@gmail.com
2012-03-29 20:31:49 +00:00
parent b0446f3216
commit d1afc6e8c5
5 changed files with 88 additions and 14 deletions

View File

@@ -1212,7 +1212,7 @@ void AudacityProject::CreateMenusAndCommands()
mSel1save = 0; mSel1save = 0;
#if defined(__WXDEBUG__) #if defined(__WXDEBUG__)
c->CheckDups(); // c->CheckDups();
#endif #endif
} }

View File

@@ -665,7 +665,10 @@ int CommandManager::NewIdentifier(wxString name, wxString label, wxMenu *menu,
#endif #endif
tmpEntry->defaultKey = tmpEntry->key; tmpEntry->defaultKey = tmpEntry->key;
if( multi )
name= name + wxString::Format(wxT("%d"),index );
tmpEntry->name = name; tmpEntry->name = name;
tmpEntry->label = label; tmpEntry->label = label;
tmpEntry->labelPrefix = labelPrefix; tmpEntry->labelPrefix = labelPrefix;
tmpEntry->labelTop = wxMenuItem::GetLabelFromText(mCurrentMenuName); tmpEntry->labelTop = wxMenuItem::GetLabelFromText(mCurrentMenuName);
@@ -840,6 +843,13 @@ void CommandManager::SetKeyFromName(wxString name, wxString key)
} }
} }
void CommandManager::SetKeyFromIndex(int i, wxString key)
{
CommandListEntry *entry = mCommandList[i];
entry->key = KeyStringNormalize(key);
}
void CommandManager::HandleMenuOpen(wxMenuEvent &evt) void CommandManager::HandleMenuOpen(wxMenuEvent &evt)
{ {
// Ensure we have a menu and that it's a top-level menu. // Ensure we have a menu and that it's a top-level menu.
@@ -1098,11 +1108,51 @@ void CommandManager::GetAllCommandNames(wxArrayString &names,
unsigned int i; unsigned int i;
for(i=0; i<mCommandList.GetCount(); i++) { for(i=0; i<mCommandList.GetCount(); i++) {
if (includeMultis || !mCommandList[i]->multi) if (!mCommandList[i]->multi)
names.Add(mCommandList[i]->name); names.Add(mCommandList[i]->name);
else if( includeMultis )
names.Add(mCommandList[i]->name + wxT(":")/*+ mCommandList[i]->label*/);
} }
} }
void CommandManager::GetAllCommandLabels(wxArrayString &names,
bool includeMultis)
{
unsigned int i;
for(i=0; i<mCommandList.GetCount(); i++) {
if (!mCommandList[i]->multi)
names.Add(mCommandList[i]->label);
else if( includeMultis )
names.Add(mCommandList[i]->label);
}
}
void CommandManager::GetAllCommandData(
wxArrayString &names, wxArrayString &keys, wxArrayString &default_keys, wxArrayString &labels, wxArrayString & categories,
bool includeMultis)
{
unsigned int i;
for(i=0; i<mCommandList.GetCount(); i++) {
if (!mCommandList[i]->multi)
{
names.Add(mCommandList[i]->name);
keys.Add(mCommandList[i]->key);
default_keys.Add( mCommandList[i]->defaultKey);
labels.Add(mCommandList[i]->label);
categories.Add(mCommandList[i]->labelTop);
}
else if( includeMultis )
{
names.Add(mCommandList[i]->name);
keys.Add(mCommandList[i]->key);
default_keys.Add( mCommandList[i]->defaultKey);
labels.Add(mCommandList[i]->label);
categories.Add(mCommandList[i]->labelTop);
}
}
}
wxString CommandManager::GetLabelFromName(wxString name) wxString CommandManager::GetLabelFromName(wxString name)
{ {
CommandListEntry *entry = mCommandNameHash[name]; CommandListEntry *entry = mCommandNameHash[name];

View File

@@ -169,6 +169,7 @@ class AUDACITY_DLL_API CommandManager: public XMLTagHandler
// Modifying accelerators // Modifying accelerators
// //
void SetKeyFromName(wxString name, wxString key); void SetKeyFromName(wxString name, wxString key);
void SetKeyFromIndex(int i, wxString key);
// //
// Displaying menus // Displaying menus
@@ -191,6 +192,11 @@ class AUDACITY_DLL_API CommandManager: public XMLTagHandler
void GetCategories(wxArrayString &cats); void GetCategories(wxArrayString &cats);
void GetAllCommandNames(wxArrayString &names, bool includeMultis); void GetAllCommandNames(wxArrayString &names, bool includeMultis);
void GetAllCommandLabels(wxArrayString &labels, bool includeMultis);
void CommandManager::GetAllCommandData(
wxArrayString &names, wxArrayString &keys, wxArrayString &default_keys,
wxArrayString &labels, wxArrayString & categories,
bool includeMultis);
wxString GetLabelFromName(wxString name); wxString GetLabelFromName(wxString name);
wxString GetPrefixedLabelFromName(wxString name); wxString GetPrefixedLabelFromName(wxString name);

View File

@@ -212,14 +212,24 @@ void KeyConfigPrefs::RepopulateBindingsList()
mList->DeleteAllItems(); // Delete contents, but not the column headers. mList->DeleteAllItems(); // Delete contents, but not the column headers.
mNames.Clear(); mNames.Clear();
mManager->GetAllCommandNames(mNames, false); mDefaultKeys.Clear();
wxArrayString Keys,Labels,Categories;
mManager->GetAllCommandData(
mNames,
Keys,
mDefaultKeys,
Labels,
Categories,
true ); // JKC change to true to include effects (list items).
bool save = (mKeys.GetCount() == 0); bool save = (mKeys.GetCount() == 0);
size_t ndx = 0; size_t ndx = 0;
int color = 0; int color = 0;
for (size_t i = 0; i < mNames.GetCount(); i++) { for (size_t i = 0; i < mNames.GetCount(); i++) {
wxString name = mNames[i]; wxString name = mNames[i];
wxString key = KeyStringDisplay(mManager->GetKeyFromName(name)); wxString key = KeyStringDisplay(Keys[i]);
// Save the original key value to support canceling // Save the original key value to support canceling
if (save) { if (save) {
@@ -228,10 +238,10 @@ void KeyConfigPrefs::RepopulateBindingsList()
mNewKeys.Add(key); mNewKeys.Add(key);
} }
if (cat != _("All") && mManager->GetCategoryFromName(name) != cat) { // if (cat != _("All") && ! Categories[i].StartsWith(cat)) {
if (cat != _("All") && ! (Categories[i]== cat)) {
continue; continue;
} }
wxString label; wxString label;
// Labels for undo and redo change according to the last command // Labels for undo and redo change according to the last command
@@ -244,7 +254,7 @@ void KeyConfigPrefs::RepopulateBindingsList()
label = _("Redo"); label = _("Redo");
} }
else { else {
label = mManager->GetPrefixedLabelFromName(name); label = Labels[i];//mManager->GetPrefixedLabelFromName(name);
} }
label = wxMenuItem::GetLabelFromText(label.BeforeFirst(wxT('\t'))); label = wxMenuItem::GetLabelFromText(label.BeforeFirst(wxT('\t')));
@@ -334,8 +344,7 @@ void KeyConfigPrefs::OnSave(wxCommandEvent & e)
void KeyConfigPrefs::OnDefaults(wxCommandEvent & e) void KeyConfigPrefs::OnDefaults(wxCommandEvent & e)
{ {
for (size_t i = 0; i < mNames.GetCount(); i++) { for (size_t i = 0; i < mNames.GetCount(); i++) {
mManager->SetKeyFromName(mNames[i], mManager->SetKeyFromIndex(i,mDefaultKeys[i]);
mManager->GetDefaultKeyFromName(mNames[i]));
} }
RepopulateBindingsList(); RepopulateBindingsList();
} }
@@ -379,14 +388,20 @@ wxString KeyConfigPrefs::NameFromKey( const wxString & key )
// This is not yet a committed change, which will happen on a save. // This is not yet a committed change, which will happen on a save.
void KeyConfigPrefs::SetKeyForSelected( const wxString & key ) void KeyConfigPrefs::SetKeyForSelected( const wxString & key )
{ {
wxString name = mNames[mList->GetItemData(mCommandSelected)]; int i = mList->GetItemData(mCommandSelected);
wxString name = mNames[i];
mList->SetItem(mCommandSelected, KeyComboColumn, key); mList->SetItem(mCommandSelected, KeyComboColumn, key);
mManager->SetKeyFromName(name, key); mManager->SetKeyFromIndex(i, key);
#if 0
int i=mNames.Index( name ); int i=mNames.Index( name );
if( i!=wxNOT_FOUND ) if( i!=wxNOT_FOUND )
mNewKeys[i]=key; mNewKeys[i]=key;
#endif
mNewKeys[i]=key;
} }
@@ -521,9 +536,11 @@ void KeyConfigPrefs::OnItemSelected(wxListEvent & e)
bool KeyConfigPrefs::Apply() bool KeyConfigPrefs::Apply()
{ {
for (size_t i = 0; i < mNames.GetCount(); i++) { for (size_t i = 0; i < mNames.GetCount(); i++) {
wxString dkey = KeyStringNormalize(mManager->GetDefaultKeyFromName(mNames[i])); // wxString dkey = KeyStringNormalize(mManager->GetDefaultKeyFromName(mNames[i]));
wxString dkey = KeyStringNormalize(mDefaultKeys[i]);
wxString name = wxT("/NewKeys/") + mNames[i]; wxString name = wxT("/NewKeys/") + mNames[i];
wxString key = KeyStringNormalize(mManager->GetKeyFromName(mNames[i])); // wxString key = KeyStringNormalize(mManager->GetKeyFromName(mNames[i]));
wxString key = KeyStringNormalize(mNewKeys[i]);
if (gPrefs->HasEntry(name)) { if (gPrefs->HasEntry(name)) {
if (key != KeyStringNormalize(gPrefs->Read(name, key))) { if (key != KeyStringNormalize(gPrefs->Read(name, key))) {
@@ -547,7 +564,7 @@ void KeyConfigPrefs::Cancel()
{ {
// Restore original key values // Restore original key values
for (size_t i = 0; i < mNames.GetCount(); i++) { for (size_t i = 0; i < mNames.GetCount(); i++) {
mManager->SetKeyFromName(mNames[i], mKeys[i]); mManager->SetKeyFromIndex(i, mKeys[i]);
} }
return; return;

View File

@@ -59,6 +59,7 @@ class KeyConfigPrefs:public PrefsPanel
wxArrayString mCats; wxArrayString mCats;
wxArrayString mNames; wxArrayString mNames;
wxArrayString mDefaultKeys;
wxArrayString mKeys; wxArrayString mKeys;
wxArrayString mNewKeys; // Used for work in progress. wxArrayString mNewKeys; // Used for work in progress.