mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-19 15:11:23 +01:00
Bug 406 - Label creation/other non-dialogue editing and keyboard selection hang on long projects
This is part 2... Improve performance of selection via Selection bar This provides a similar type of speed up when selecting with the keyboard via the Selection toolbar.
This commit is contained in:
@@ -1199,12 +1199,14 @@ void AudacityProject::AS_SetSnapTo(bool state)
|
||||
RedrawProject();
|
||||
}
|
||||
|
||||
void AudacityProject::AS_ModifySelection(double &start, double &end)
|
||||
void AudacityProject::AS_ModifySelection(double &start, double &end, bool done)
|
||||
{
|
||||
mViewInfo.sel0 = start;
|
||||
mViewInfo.sel1 = end;
|
||||
mTrackPanel->Refresh(false);
|
||||
ModifyState();
|
||||
if (done) {
|
||||
ModifyState();
|
||||
}
|
||||
}
|
||||
|
||||
void AudacityProject::FinishAutoScroll()
|
||||
|
||||
@@ -364,7 +364,7 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
|
||||
virtual void AS_SetRate(double rate);
|
||||
virtual bool AS_GetSnapTo();
|
||||
virtual void AS_SetSnapTo(bool state);
|
||||
virtual void AS_ModifySelection(double &start, double &end);
|
||||
virtual void AS_ModifySelection(double &start, double &end, bool done);
|
||||
|
||||
void SetStateTo(unsigned int n);
|
||||
|
||||
|
||||
@@ -314,7 +314,7 @@ void SelectionBar::OnSize(wxSizeEvent &evt)
|
||||
evt.Skip();
|
||||
}
|
||||
|
||||
void SelectionBar::ModifySelection()
|
||||
void SelectionBar::ModifySelection(bool done)
|
||||
{
|
||||
mStart = mLeftTime->GetTimeValue();
|
||||
double right = mRightTime->GetTimeValue();
|
||||
@@ -328,17 +328,17 @@ void SelectionBar::ModifySelection()
|
||||
else
|
||||
mEnd = mStart + right;
|
||||
|
||||
mListener->AS_ModifySelection(mStart, mEnd);
|
||||
mListener->AS_ModifySelection(mStart, mEnd, done);
|
||||
}
|
||||
|
||||
void SelectionBar::OnLeftTime(wxCommandEvent & WXUNUSED(event))
|
||||
void SelectionBar::OnLeftTime(wxCommandEvent & event)
|
||||
{
|
||||
ModifySelection();
|
||||
ModifySelection(event.GetInt() != 0);
|
||||
}
|
||||
|
||||
void SelectionBar::OnRightTime(wxCommandEvent & WXUNUSED(event))
|
||||
void SelectionBar::OnRightTime(wxCommandEvent & event)
|
||||
{
|
||||
ModifySelection();
|
||||
ModifySelection(event.GetInt() != 0);
|
||||
}
|
||||
|
||||
void SelectionBar::OnLengthRadio(wxCommandEvent & WXUNUSED(event))
|
||||
|
||||
@@ -36,7 +36,7 @@ class AUDACITY_DLL_API SelectionBarListener {
|
||||
virtual void AS_SetRate(double rate) = 0;
|
||||
virtual bool AS_GetSnapTo() = 0;
|
||||
virtual void AS_SetSnapTo(bool state) = 0;
|
||||
virtual void AS_ModifySelection(double &start, double &end) = 0;
|
||||
virtual void AS_ModifySelection(double &start, double &end, bool done) = 0;
|
||||
};
|
||||
|
||||
class SelectionBar:public ToolBar {
|
||||
@@ -80,7 +80,7 @@ class SelectionBar:public ToolBar {
|
||||
|
||||
void OnSize(wxSizeEvent &evt);
|
||||
|
||||
void ModifySelection();
|
||||
void ModifySelection(bool done = false);
|
||||
|
||||
void UpdateRates();
|
||||
|
||||
|
||||
@@ -198,6 +198,7 @@ BEGIN_EVENT_TABLE(TimeTextCtrl, wxControl)
|
||||
EVT_MENU_RANGE(ID_MENU, ID_MENU+100, TimeTextCtrl::OnMenu)
|
||||
EVT_MOUSE_EVENTS(TimeTextCtrl::OnMouse)
|
||||
EVT_KEY_DOWN(TimeTextCtrl::OnKeyDown)
|
||||
EVT_KEY_UP(TimeTextCtrl::OnKeyUp)
|
||||
EVT_SET_FOCUS(TimeTextCtrl::OnFocus)
|
||||
EVT_KILL_FOCUS(TimeTextCtrl::OnFocus)
|
||||
EVT_COMMAND(wxID_ANY, EVT_CAPTURE_KEY, TimeTextCtrl::OnCaptureKey)
|
||||
@@ -1081,6 +1082,23 @@ void TimeTextCtrl::OnCaptureKey(wxCommandEvent &event)
|
||||
return;
|
||||
}
|
||||
|
||||
void TimeTextCtrl::OnKeyUp(wxKeyEvent &event)
|
||||
{
|
||||
int keyCode = event.GetKeyCode();
|
||||
|
||||
event.Skip(true);
|
||||
|
||||
if ((keyCode >= WXK_NUMPAD0) && (keyCode <= WXK_NUMPAD9))
|
||||
keyCode -= WXK_NUMPAD0 - '0';
|
||||
|
||||
if ((keyCode >= '0' && keyCode <= '9') ||
|
||||
(keyCode == WXK_BACK) ||
|
||||
(keyCode == WXK_UP) ||
|
||||
(keyCode == WXK_DOWN)) {
|
||||
Updated(true);
|
||||
}
|
||||
}
|
||||
|
||||
void TimeTextCtrl::OnKeyDown(wxKeyEvent &event)
|
||||
{
|
||||
if (mDigits.GetCount() == 0)
|
||||
@@ -1089,7 +1107,8 @@ void TimeTextCtrl::OnKeyDown(wxKeyEvent &event)
|
||||
return;
|
||||
}
|
||||
|
||||
event.Skip(false);
|
||||
event.Skip();
|
||||
|
||||
int keyCode = event.GetKeyCode();
|
||||
int digit = mFocusedDigit;
|
||||
|
||||
@@ -1161,6 +1180,7 @@ void TimeTextCtrl::OnKeyDown(wxKeyEvent &event)
|
||||
nevent.SetEventObject(parent);
|
||||
nevent.SetCurrentFocus(parent);
|
||||
GetParent()->ProcessEvent(nevent);
|
||||
event.Skip(false);
|
||||
}
|
||||
|
||||
else if (keyCode == WXK_RETURN || keyCode == WXK_NUMPAD_ENTER) {
|
||||
@@ -1170,6 +1190,7 @@ void TimeTextCtrl::OnKeyDown(wxKeyEvent &event)
|
||||
wxCommandEvent cevent(wxEVT_COMMAND_BUTTON_CLICKED,
|
||||
def->GetId());
|
||||
GetParent()->ProcessEvent(cevent);
|
||||
event.Skip(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1181,8 +1202,6 @@ void TimeTextCtrl::OnKeyDown(wxKeyEvent &event)
|
||||
if (digit != mFocusedDigit) {
|
||||
SetFieldFocus(mFocusedDigit);
|
||||
}
|
||||
|
||||
event.Skip(false);
|
||||
}
|
||||
|
||||
void TimeTextCtrl::SetFieldFocus(int digit)
|
||||
@@ -1214,18 +1233,25 @@ void TimeTextCtrl::SetFieldFocus(int digit)
|
||||
#endif
|
||||
}
|
||||
|
||||
void TimeTextCtrl::Updated()
|
||||
void TimeTextCtrl::Updated(bool keyup /* = false */)
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, GetId());
|
||||
|
||||
// This will give listeners the ability to do tasks when the
|
||||
// update has been completed, like when the UP ARROW has been
|
||||
// held down and is finally released.
|
||||
event.SetInt(keyup);
|
||||
event.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
#if wxUSE_ACCESSIBILITY
|
||||
GetAccessible()->NotifyEvent(wxACC_EVENT_OBJECT_NAMECHANGE,
|
||||
this,
|
||||
wxOBJID_CLIENT,
|
||||
mFocusedDigit + 1);
|
||||
SetFieldFocus(mFocusedDigit);
|
||||
if (!keyup) {
|
||||
GetAccessible()->NotifyEvent(wxACC_EVENT_OBJECT_NAMECHANGE,
|
||||
this,
|
||||
wxOBJID_CLIENT,
|
||||
mFocusedDigit + 1);
|
||||
SetFieldFocus(mFocusedDigit);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ private:
|
||||
|
||||
void OnCaptureKey(wxCommandEvent &event);
|
||||
void OnKeyDown(wxKeyEvent &event);
|
||||
void OnKeyUp(wxKeyEvent &event);
|
||||
void OnMouse(wxMouseEvent &event);
|
||||
void OnErase(wxEraseEvent &event);
|
||||
void OnPaint(wxPaintEvent &event);
|
||||
@@ -125,7 +126,7 @@ private:
|
||||
// If autoPos was enabled, focus the first non-zero digit
|
||||
void UpdateAutoFocus();
|
||||
|
||||
void Updated();
|
||||
void Updated(bool keyup = false);
|
||||
void Increase(int steps);
|
||||
void Decrease(int steps);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user