mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-02 00:29:41 +02:00
Adds access keys
Saves view type Defaults to fully expanded upon entry Live search...may need to adjust the timer Uses black on white for the icon (should? fix assertion on Linux hopefully) (will do more a bit later)
This commit is contained in:
parent
989d9cdfa3
commit
39e7b3e08f
@ -56,6 +56,7 @@ KeyConfigPrefs and MousePrefs use.
|
||||
#define ViewByTreeID 17009
|
||||
#define ViewByNameID 17010
|
||||
#define ViewByKeyID 17011
|
||||
#define FilterTimerID 17012
|
||||
|
||||
BEGIN_EVENT_TABLE(KeyConfigPrefs, PrefsPanel)
|
||||
EVT_BUTTON(AssignDefaultsButtonID, KeyConfigPrefs::OnDefaults)
|
||||
@ -67,13 +68,16 @@ BEGIN_EVENT_TABLE(KeyConfigPrefs, PrefsPanel)
|
||||
EVT_RADIOBUTTON(ViewByTreeID, KeyConfigPrefs::OnViewBy)
|
||||
EVT_RADIOBUTTON(ViewByNameID, KeyConfigPrefs::OnViewBy)
|
||||
EVT_RADIOBUTTON(ViewByKeyID, KeyConfigPrefs::OnViewBy)
|
||||
EVT_TIMER(FilterTimerID, KeyConfigPrefs::OnFilterTimer)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
KeyConfigPrefs::KeyConfigPrefs(wxWindow * parent)
|
||||
: PrefsPanel(parent, _("Keyboard")),
|
||||
mView(NULL),
|
||||
mFilter(NULL),
|
||||
mKey(NULL)
|
||||
mKey(NULL),
|
||||
mFilterTimer(this, FilterTimerID),
|
||||
mFilterPending(false)
|
||||
{
|
||||
Populate();
|
||||
}
|
||||
@ -131,6 +135,16 @@ void KeyConfigPrefs::Populate()
|
||||
|
||||
PopulateOrExchange(S);
|
||||
|
||||
if (mViewByTree->GetValue()) {
|
||||
mView->SetView(ViewByTree);
|
||||
}
|
||||
else if (mViewByName->GetValue()) {
|
||||
mView->SetView(ViewByName);
|
||||
}
|
||||
else if (mViewByKey->GetValue()) {
|
||||
mView->SetView(ViewByKey);
|
||||
}
|
||||
|
||||
mCommandSelected = -1;
|
||||
|
||||
mManager = project->GetCommandManager();
|
||||
@ -157,9 +171,9 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
S.AddTitle(_("View by:"));
|
||||
S.StartRadioButtonGroup(wxT("/Prefs/KeyConfig/ViewBy"), wxT("tree"));
|
||||
{
|
||||
S.Id(ViewByTreeID).TieRadioButton(_("Tree"), wxT("tree"));
|
||||
S.Id(ViewByNameID).TieRadioButton(_("Name"), wxT("name"));
|
||||
S.Id(ViewByKeyID).TieRadioButton(_("Key"), wxT("key"));
|
||||
mViewByTree = S.Id(ViewByTreeID).TieRadioButton(_("&Tree"), wxT("tree"));
|
||||
mViewByName = S.Id(ViewByNameID).TieRadioButton(_("&Name"), wxT("name"));
|
||||
mViewByKey = S.Id(ViewByKeyID).TieRadioButton(_("&Key"), wxT("key"));
|
||||
}
|
||||
S.EndRadioButtonGroup();
|
||||
}
|
||||
@ -173,7 +187,7 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
|
||||
S.StartHorizontalLay(wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 0);
|
||||
{
|
||||
S.AddTitle(_("Filter:"));
|
||||
mFilterLabel = S.AddVariableText(_("Searc&h:"));
|
||||
|
||||
if (!mFilter) {
|
||||
mFilter = new wxTextCtrl(this,
|
||||
@ -226,7 +240,7 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
#else
|
||||
wxSize(210, -1));
|
||||
#endif
|
||||
mKey->SetName(_("Hotkey"));
|
||||
mKey->SetName(_("Short cut"));
|
||||
mKey->Connect(wxEVT_KEY_DOWN,
|
||||
wxKeyEventHandler(KeyConfigPrefs::OnHotkeyKeyDown),
|
||||
NULL,
|
||||
@ -243,7 +257,7 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
S.AddWindow(mKey);
|
||||
|
||||
/* i18n-hint: (verb)*/
|
||||
S.Id(SetButtonID).AddButton(_("Set"));
|
||||
S.Id(SetButtonID).AddButton(_("&Set"));
|
||||
S.Id(ClearButtonID).AddButton(_("Cl&ear"));
|
||||
}
|
||||
S.EndThreeColumn();
|
||||
@ -261,6 +275,10 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
S.EndThreeColumn();
|
||||
}
|
||||
S.EndStatic();
|
||||
|
||||
if (mViewType == ViewByKey) {
|
||||
mFilterLabel->SetLabel(_("&Hotkey:"));
|
||||
}
|
||||
}
|
||||
|
||||
void KeyConfigPrefs::RefreshBindings()
|
||||
@ -283,6 +301,7 @@ void KeyConfigPrefs::RefreshBindings()
|
||||
Prefixes,
|
||||
Labels,
|
||||
mKeys);
|
||||
mView->ExpandAll();
|
||||
|
||||
mNewKeys = mKeys;
|
||||
}
|
||||
@ -409,6 +428,16 @@ void KeyConfigPrefs::OnHotkeyKillFocus(wxFocusEvent & e)
|
||||
e.Skip();
|
||||
}
|
||||
|
||||
void KeyConfigPrefs::OnFilterTimer(wxTimerEvent & e)
|
||||
{
|
||||
// The filter timer has expired, so set the filter
|
||||
if (mFilterPending)
|
||||
{
|
||||
// Do not reset mFilterPending here...possible race
|
||||
mView->SetFilter(mFilter->GetValue());
|
||||
}
|
||||
}
|
||||
|
||||
void KeyConfigPrefs::OnFilterKeyDown(wxKeyEvent & e)
|
||||
{
|
||||
wxTextCtrl *t = (wxTextCtrl *)e.GetEventObject();
|
||||
@ -439,9 +468,13 @@ void KeyConfigPrefs::OnFilterKeyDown(wxKeyEvent & e)
|
||||
else
|
||||
{
|
||||
if (keycode == WXK_RETURN) {
|
||||
mFilterPending = false;
|
||||
mView->SetFilter(t->GetValue());
|
||||
}
|
||||
else {
|
||||
mFilterPending = true;
|
||||
mFilterTimer.Start(500, wxTIMER_ONE_SHOT);
|
||||
|
||||
e.Skip();
|
||||
}
|
||||
}
|
||||
@ -521,14 +554,17 @@ void KeyConfigPrefs::OnViewBy(wxCommandEvent & e)
|
||||
{
|
||||
case ViewByTreeID:
|
||||
mViewType = ViewByTree;
|
||||
mFilterLabel->SetLabel(_("Searc&h:"));
|
||||
break;
|
||||
|
||||
case ViewByNameID:
|
||||
mViewType = ViewByName;
|
||||
mFilterLabel->SetLabel(_("Searc&h:"));
|
||||
break;
|
||||
|
||||
case ViewByKeyID:
|
||||
mViewType = ViewByKey;
|
||||
mFilterLabel->SetLabel(_("&Hotkey:"));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -537,6 +573,9 @@ void KeyConfigPrefs::OnViewBy(wxCommandEvent & e)
|
||||
|
||||
bool KeyConfigPrefs::Apply()
|
||||
{
|
||||
ShuttleGui S(this, eIsSavingToPrefs);
|
||||
PopulateOrExchange(S);
|
||||
|
||||
for (size_t i = 0; i < mNames.GetCount(); i++) {
|
||||
wxString dkey = KeyStringNormalize(mDefaultKeys[i]);
|
||||
wxString name = wxT("/NewKeys/") + mNames[i];
|
||||
|
@ -17,9 +17,11 @@
|
||||
#include <wx/defs.h>
|
||||
#include <wx/imaglist.h>
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/radiobut.h>
|
||||
#include <wx/srchctrl.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/timer.h>
|
||||
|
||||
#include "../ShuttleGui.h"
|
||||
#include "../commands/CommandManager.h"
|
||||
@ -54,14 +56,22 @@ private:
|
||||
void OnHotkeyChar(wxKeyEvent & e);
|
||||
void OnHotkeyKillFocus(wxFocusEvent & e);
|
||||
|
||||
void OnFilterTimer(wxTimerEvent & e);
|
||||
void OnFilterKeyDown(wxKeyEvent & e);
|
||||
void OnFilterChar(wxKeyEvent & e);
|
||||
|
||||
KeyView *mView;
|
||||
wxTextCtrl *mFilter;
|
||||
wxTextCtrl *mKey;
|
||||
|
||||
wxTextCtrl *mFilter;
|
||||
wxStaticText *mFilterLabel;
|
||||
wxTimer mFilterTimer;
|
||||
bool mFilterPending;
|
||||
|
||||
ViewByType mViewType;
|
||||
wxRadioButton *mViewByTree;
|
||||
wxRadioButton *mViewByName;
|
||||
wxRadioButton *mViewByKey;
|
||||
|
||||
CommandManager *mManager;
|
||||
int mCommandSelected;
|
||||
|
@ -67,28 +67,16 @@ KeyView::KeyView(wxWindow *parent,
|
||||
|
||||
// Create the device context
|
||||
wxMemoryDC dc;
|
||||
|
||||
// LLL: I'd really like to figure out the proper colors to use so that
|
||||
// Windows high contrast themes work properly while also displaying
|
||||
// properly on the other 2 platforms...thus the #if.
|
||||
#if defined(__WXMSW__)
|
||||
wxColour back(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
|
||||
wxColour fore(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
|
||||
#else
|
||||
wxColour back(*wxWHITE);
|
||||
wxColour fore(*wxBLACK);
|
||||
#endif
|
||||
|
||||
dc.SetBrush(wxBrush(back));
|
||||
dc.SetBrush(*wxWHITE_BRUSH);
|
||||
|
||||
// Create the open/expanded bitmap
|
||||
mOpen = new wxBitmap(16, 16);
|
||||
dc.SelectObject(*mOpen);
|
||||
|
||||
dc.SetPen(wxPen(back));
|
||||
dc.SetPen(*wxWHITE_PEN);
|
||||
dc.DrawRectangle(0, 0, 16, 16);
|
||||
|
||||
dc.SetPen(wxPen(fore));
|
||||
dc.SetPen(*wxBLACK_PEN);
|
||||
dc.DrawRectangle(3, 4, 9, 9);
|
||||
dc.DrawLine(5, 8, 10, 8);
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
@ -97,10 +85,10 @@ KeyView::KeyView(wxWindow *parent,
|
||||
mClosed = new wxBitmap(16, 16);
|
||||
dc.SelectObject(*mClosed);
|
||||
|
||||
dc.SetPen(wxPen(back));
|
||||
dc.SetPen(*wxWHITE_PEN);
|
||||
dc.DrawRectangle(0, 0, 16, 16);
|
||||
|
||||
dc.SetPen(wxPen(fore));
|
||||
dc.SetPen(*wxBLACK_PEN);
|
||||
dc.DrawRectangle(3, 4, 9, 9);
|
||||
dc.DrawLine(7, 6, 7, 11);
|
||||
dc.DrawLine(5, 8, 10, 8);
|
||||
@ -298,6 +286,50 @@ KeyView::SetFilter(const wxString & filter)
|
||||
RefreshLineCount();
|
||||
}
|
||||
|
||||
//
|
||||
// Expand all branches
|
||||
//
|
||||
void
|
||||
KeyView::ExpandAll()
|
||||
{
|
||||
size_t cnt = mNodes.GetCount();
|
||||
|
||||
// Set all parent nodes to open
|
||||
for (int i = 0; i < cnt; i++)
|
||||
{
|
||||
KeyNode & node = mNodes[i];
|
||||
|
||||
if (node.isparent)
|
||||
{
|
||||
node.isopen = true;
|
||||
}
|
||||
}
|
||||
|
||||
RefreshLineCount();
|
||||
}
|
||||
|
||||
//
|
||||
// Collapse all branches
|
||||
//
|
||||
void
|
||||
KeyView::CollapseAll()
|
||||
{
|
||||
size_t cnt = mNodes.GetCount();
|
||||
|
||||
// Set all parent nodes to closed
|
||||
for (int i = 0; i < cnt; i++)
|
||||
{
|
||||
KeyNode & node = mNodes[i];
|
||||
|
||||
if (node.isparent)
|
||||
{
|
||||
node.isopen = false;
|
||||
}
|
||||
}
|
||||
|
||||
RefreshLineCount();
|
||||
}
|
||||
|
||||
//
|
||||
// Recalculate the measurements used for columns and scrolling
|
||||
//
|
||||
@ -913,10 +945,10 @@ KeyView::OnDrawItem(wxDC & dc, const wxRect & rect, size_t line) const
|
||||
}
|
||||
|
||||
// Indent text
|
||||
x += KV_LEFT_MARGIN + node->depth * KV_BITMAP_SIZE;
|
||||
x += KV_LEFT_MARGIN;
|
||||
|
||||
// Draw the command and key columns
|
||||
dc.DrawText(label, x, rect.y);
|
||||
dc.DrawText(label, x + node->depth * KV_BITMAP_SIZE, rect.y);
|
||||
dc.DrawText(node->key, x + mCommandWidth + KV_COLUMN_SPACER, rect.y);
|
||||
}
|
||||
else
|
||||
|
@ -95,6 +95,9 @@ public:
|
||||
void SetView(ViewByType type);
|
||||
void SetFilter(const wxString & filter);
|
||||
|
||||
void ExpandAll();
|
||||
void CollapseAll();
|
||||
|
||||
private:
|
||||
void OnDrawItem(wxDC & dc, const wxRect & rect, size_t line) const;
|
||||
void OnDrawBackground(wxDC & dc, const wxRect & rect, size_t line) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user