1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-31 07:59:27 +02:00

easy change key bindings

This commit is contained in:
Paul Licameli 2017-08-29 10:02:22 -04:00
parent 1f7b62f056
commit aa5c3f12a3
6 changed files with 41 additions and 9 deletions

View File

@ -224,10 +224,6 @@
// scrolling past zero is enabled. Perhaps that lessens confusion.
#define EXPERIMENTAL_TWO_TONE_TIME_RULER
// Paul Licameli (PRL) 28 Dec 2017
// Easy drag-and-drop to add Nyquist, LADSPA, and VST plug-ins
// #define EXPERIMENTAL_DRAG_DROP_PLUG_INS
#ifndef IN_RC
// Define to include crash reporting
#include <wx/defs.h>
@ -248,4 +244,12 @@
// with themes
//#define EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
// Paul Licameli (PRL) 28 Dec 2017
// Easy drag-and-drop to add Nyquist, LADSPA, and VST plug-ins
// #define EXPERIMENTAL_DRAG_DROP_PLUG_INS
// PRL 5 Jan 2018
// Easy change of keystroke bindings for menu items
#define EXPERIMENTAL_EASY_CHANGE_KEY_BINDINGS
#endif

View File

@ -1479,9 +1479,25 @@ bool CommandManager::HandleCommandEntry(const CommandListEntry * entry,
///CommandManagerListener function. If you pass any flags,
///the command won't be executed unless the flags are compatible
///with the command's flags.
#include "../prefs/PrefsDialog.h"
#include "../prefs/KeyConfigPrefs.h"
bool CommandManager::HandleMenuID(int id, CommandFlag flags, CommandMask mask)
{
CommandListEntry *entry = mCommandIDHash[id];
#ifdef EXPERIMENTAL_EASY_CHANGE_KEY_BINDINGS
if (::wxGetMouseState().ShiftDown()) {
// Only want one page of the preferences
KeyConfigPrefsFactory keyConfigPrefsFactory{ entry->name };
PrefsDialog::Factories factories;
factories.push_back(&keyConfigPrefsFactory);
GlobalPrefsDialog dialog(GetActiveProject(), factories);
dialog.ShowModal();
AudacityProject::RebuildAllMenuBars();
return true;
}
#endif
return HandleCommandEntry( entry, flags, mask );
}

View File

@ -72,7 +72,7 @@ BEGIN_EVENT_TABLE(KeyConfigPrefs, PrefsPanel)
EVT_TIMER(FilterTimerID, KeyConfigPrefs::OnFilterTimer)
END_EVENT_TABLE()
KeyConfigPrefs::KeyConfigPrefs(wxWindow * parent)
KeyConfigPrefs::KeyConfigPrefs(wxWindow * parent, const wxString &name)
/* i18n-hint: as in computer keyboard (not musical!) */
: PrefsPanel(parent, _("Keyboard")),
mView(NULL),
@ -82,6 +82,10 @@ KeyConfigPrefs::KeyConfigPrefs(wxWindow * parent)
mFilterPending(false)
{
Populate();
if (!name.empty()) {
auto index = mView->GetIndexByName(name);
mView->SelectNode(index);
}
}
KeyConfigPrefs::~KeyConfigPrefs()
@ -746,5 +750,6 @@ wxString KeyConfigPrefs::HelpPageName()
PrefsPanel *KeyConfigPrefsFactory::Create(wxWindow *parent)
{
wxASSERT(parent); // to justify safenew
return safenew KeyConfigPrefs(parent);
auto result = safenew KeyConfigPrefs{ parent, mName };
return result;
}

View File

@ -35,7 +35,7 @@ class wxStaticText;
class KeyConfigPrefs final : public PrefsPanel
{
public:
KeyConfigPrefs(wxWindow * parent);
KeyConfigPrefs(wxWindow * parent, const wxString &name);
~KeyConfigPrefs();
bool Commit() override;
void Cancel() override;
@ -97,6 +97,11 @@ private:
class KeyConfigPrefsFactory final : public PrefsPanelFactory
{
public:
KeyConfigPrefsFactory(const wxString &name = wxString{})
: mName{ name } {}
PrefsPanel *Create(wxWindow *parent) override;
private:
wxString mName;
};
#endif

View File

@ -66,6 +66,8 @@ KeyView::KeyView(wxWindow *parent,
SetAccessible(mAx = safenew KeyViewAx(this));
#endif
SetMinSize({-1, 150});
// The default view
mViewType = ViewByTree;

View File

@ -107,13 +107,13 @@ public:
void ExpandAll();
void CollapseAll();
void SelectNode(int index);
private:
void RecalcExtents();
void UpdateHScroll();
void RefreshLines(bool bSort = true);
void SelectNode(int index);
int LineToIndex(int line) const;
int IndexToLine(int index) const;