mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-17 16:40:07 +02:00
Allow sorting keyboard list by clicking on column headings.
This commit is contained in:
parent
b6c5d9296d
commit
48ec733ec3
@ -64,6 +64,7 @@ BEGIN_EVENT_TABLE(KeyConfigPrefs, PrefsPanel)
|
|||||||
EVT_BUTTON(ExportButtonID, KeyConfigPrefs::OnExport)
|
EVT_BUTTON(ExportButtonID, KeyConfigPrefs::OnExport)
|
||||||
EVT_BUTTON(ImportButtonID, KeyConfigPrefs::OnImport)
|
EVT_BUTTON(ImportButtonID, KeyConfigPrefs::OnImport)
|
||||||
EVT_CHOICE(CategoryID, KeyConfigPrefs::OnCategory)
|
EVT_CHOICE(CategoryID, KeyConfigPrefs::OnCategory)
|
||||||
|
EVT_LIST_COL_CLICK(CommandsListID, KeyConfigPrefs::OnSort)
|
||||||
EVT_LIST_ITEM_SELECTED(CommandsListID, KeyConfigPrefs::OnItemSelected)
|
EVT_LIST_ITEM_SELECTED(CommandsListID, KeyConfigPrefs::OnItemSelected)
|
||||||
EVT_LIST_KEY_DOWN(CommandsListID, KeyConfigPrefs::OnKeyDown)
|
EVT_LIST_KEY_DOWN(CommandsListID, KeyConfigPrefs::OnKeyDown)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
@ -191,21 +192,48 @@ void KeyConfigPrefs::CreateList()
|
|||||||
mList->SetColumnWidth(KeyComboColumn, 250);
|
mList->SetColumnWidth(KeyComboColumn, 250);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wxCALLBACK SortCallback(long item1, long item2, long sortData)
|
int KeyConfigPrefs::SortItems(long item1, long item2)
|
||||||
{
|
{
|
||||||
wxArrayString *names = (wxArrayString *) sortData;
|
if (mSortCol->Item(item1) < mSortCol->Item(item2)) {
|
||||||
|
return -1 * mSortDir;
|
||||||
if (names->Item(item1) < names->Item(item2)) {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (names->Item(item1) > names->Item(item2)) {
|
if (mSortCol->Item(item1) > mSortCol->Item(item2)) {
|
||||||
return 1;
|
return 1 * mSortDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int wxCALLBACK SortCallback(long item1, long item2, long sortData)
|
||||||
|
{
|
||||||
|
return ((KeyConfigPrefs *)sortData)->SortItems(item1, item2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeyConfigPrefs::Sort(int column)
|
||||||
|
{
|
||||||
|
wxArrayString *data = NULL;
|
||||||
|
|
||||||
|
switch(column)
|
||||||
|
{
|
||||||
|
case CommandColumn:
|
||||||
|
data = &mNames;
|
||||||
|
break;
|
||||||
|
case KeyComboColumn:
|
||||||
|
data = &mKeys;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mSortDir = -mSortDir;
|
||||||
|
if (mSortCol != data) {
|
||||||
|
mSortDir = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
mSortCol = data;
|
||||||
|
|
||||||
|
mList->SortItems(SortCallback, (long) this);
|
||||||
|
}
|
||||||
|
|
||||||
void KeyConfigPrefs::RepopulateBindingsList()
|
void KeyConfigPrefs::RepopulateBindingsList()
|
||||||
{
|
{
|
||||||
wxString cat = mCat->GetStringSelection();
|
wxString cat = mCat->GetStringSelection();
|
||||||
@ -272,7 +300,9 @@ void KeyConfigPrefs::RepopulateBindingsList()
|
|||||||
ndx++;
|
ndx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mList->SortItems(SortCallback, (long) &mNames);
|
mSortDir = 1;
|
||||||
|
mSortCol = NULL;
|
||||||
|
Sort(CommandColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyConfigPrefs::OnImport(wxCommandEvent & WXUNUSED(event))
|
void KeyConfigPrefs::OnImport(wxCommandEvent & WXUNUSED(event))
|
||||||
@ -522,6 +552,11 @@ void KeyConfigPrefs::OnCategory(wxCommandEvent & WXUNUSED(event))
|
|||||||
RepopulateBindingsList();
|
RepopulateBindingsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KeyConfigPrefs::OnSort(wxListEvent & event)
|
||||||
|
{
|
||||||
|
Sort(event.GetColumn());
|
||||||
|
}
|
||||||
|
|
||||||
void KeyConfigPrefs::OnItemSelected(wxListEvent & e)
|
void KeyConfigPrefs::OnItemSelected(wxListEvent & e)
|
||||||
{
|
{
|
||||||
mCommandSelected = e.GetIndex();
|
mCommandSelected = e.GetIndex();
|
||||||
|
@ -30,13 +30,16 @@ class KeyConfigPrefs:public PrefsPanel
|
|||||||
virtual bool Apply();
|
virtual bool Apply();
|
||||||
virtual void Cancel();
|
virtual void Cancel();
|
||||||
|
|
||||||
private:
|
int SortItems(long item1, long item2);
|
||||||
|
|
||||||
|
private:
|
||||||
void Populate();
|
void Populate();
|
||||||
void PopulateOrExchange(ShuttleGui & S);
|
void PopulateOrExchange(ShuttleGui & S);
|
||||||
void CreateList();
|
void CreateList();
|
||||||
void RepopulateBindingsList();
|
void RepopulateBindingsList();
|
||||||
wxString NameFromKey( const wxString & key );
|
wxString NameFromKey( const wxString & key );
|
||||||
void SetKeyForSelected( const wxString & key );
|
void SetKeyForSelected( const wxString & key );
|
||||||
|
void Sort(int column);
|
||||||
|
|
||||||
void OnDefaults(wxCommandEvent & e);
|
void OnDefaults(wxCommandEvent & e);
|
||||||
void OnImport(wxCommandEvent & e);
|
void OnImport(wxCommandEvent & e);
|
||||||
@ -44,6 +47,7 @@ class KeyConfigPrefs:public PrefsPanel
|
|||||||
void OnSet(wxCommandEvent & e);
|
void OnSet(wxCommandEvent & e);
|
||||||
void OnClear(wxCommandEvent & e);
|
void OnClear(wxCommandEvent & e);
|
||||||
void OnCategory(wxCommandEvent & e);
|
void OnCategory(wxCommandEvent & e);
|
||||||
|
void OnSort(wxListEvent & e);
|
||||||
void OnItemSelected(wxListEvent & e);
|
void OnItemSelected(wxListEvent & e);
|
||||||
void OnKeyDown(wxListEvent & e);
|
void OnKeyDown(wxListEvent & e);
|
||||||
|
|
||||||
@ -63,6 +67,9 @@ class KeyConfigPrefs:public PrefsPanel
|
|||||||
wxArrayString mKeys;
|
wxArrayString mKeys;
|
||||||
wxArrayString mNewKeys; // Used for work in progress.
|
wxArrayString mNewKeys; // Used for work in progress.
|
||||||
|
|
||||||
|
wxArrayString *mSortCol;
|
||||||
|
int mSortDir;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user