mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-20 14:20:06 +02:00
Rewrote escape key handling, more like other Track Panel key handlers
... and removed some abandoned spectral editing code
This commit is contained in:
parent
d89944941b
commit
6ae8a656ab
@ -1879,6 +1879,9 @@ bool AudacityProject::HandleKeyDown(wxKeyEvent & event)
|
|||||||
if (wxGetTopLevelParent(wxWindow::FindFocus()) != this)
|
if (wxGetTopLevelParent(wxWindow::FindFocus()) != this)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (event.GetKeyCode() == WXK_ESCAPE)
|
||||||
|
mTrackPanel->HandleEscapeKey(true);
|
||||||
|
|
||||||
if (event.GetKeyCode() == WXK_ALT)
|
if (event.GetKeyCode() == WXK_ALT)
|
||||||
mTrackPanel->HandleAltKey(true);
|
mTrackPanel->HandleAltKey(true);
|
||||||
|
|
||||||
@ -1925,6 +1928,9 @@ bool AudacityProject::HandleKeyUp(wxKeyEvent & event)
|
|||||||
if (wxGetTopLevelParent(wxWindow::FindFocus()) != this)
|
if (wxGetTopLevelParent(wxWindow::FindFocus()) != this)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (event.GetKeyCode() == WXK_ESCAPE)
|
||||||
|
mTrackPanel->HandleEscapeKey(false);
|
||||||
|
|
||||||
if (event.GetKeyCode() == WXK_ALT)
|
if (event.GetKeyCode() == WXK_ALT)
|
||||||
mTrackPanel->HandleAltKey(false);
|
mTrackPanel->HandleAltKey(false);
|
||||||
|
|
||||||
|
@ -1565,8 +1565,11 @@ void TrackPanel::MakeParentResize()
|
|||||||
mListener->TP_HandleResize();
|
mListener->TP_HandleResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackPanel::HandleEscapeKey()
|
void TrackPanel::HandleEscapeKey(bool down)
|
||||||
{
|
{
|
||||||
|
if (!down)
|
||||||
|
return;
|
||||||
|
|
||||||
switch (mMouseCapture)
|
switch (mMouseCapture)
|
||||||
{
|
{
|
||||||
case IsSelecting:
|
case IsSelecting:
|
||||||
@ -6335,60 +6338,6 @@ void TrackPanel::OnKeyDown(wxKeyEvent & event)
|
|||||||
{
|
{
|
||||||
Track *t = GetFocusedTrack();
|
Track *t = GetFocusedTrack();
|
||||||
|
|
||||||
if (event.GetKeyCode() == WXK_ESCAPE) {
|
|
||||||
HandleEscapeKey();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
|
||||||
#ifdef SPECTRAL_EDITING_ESC_KEY
|
|
||||||
// Test for pinning and unpinning of the center frequency
|
|
||||||
bool logF;
|
|
||||||
if (mAdjustSelectionEdges &&
|
|
||||||
event.GetKeyCode() == WXK_ESCAPE) {
|
|
||||||
if (mFreqSelMode == FREQ_SEL_SNAPPING_CENTER) {
|
|
||||||
// Toggle center snapping off
|
|
||||||
// (left click can also turn it off)
|
|
||||||
mFreqSelMode = FREQ_SEL_INVALID;
|
|
||||||
}
|
|
||||||
else if (isSpectrogramTrack(t, &logF)) {
|
|
||||||
WaveTrack *wt = static_cast<WaveTrack*>(t);
|
|
||||||
if (mFreqSelMode == FREQ_SEL_INVALID) {
|
|
||||||
// Toggle center snapping on (the only way to do this)
|
|
||||||
mFreqSelMode = FREQ_SEL_SNAPPING_CENTER;
|
|
||||||
StartSnappingFreqSelection(wt);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Handle ESC during frequency drag
|
|
||||||
wxMouseState state(::wxGetMouseState());
|
|
||||||
wxCoord yy = state.GetY();
|
|
||||||
ScreenToClient(NULL, &yy);
|
|
||||||
wxRect r;
|
|
||||||
if (wt == FindTrack(state.GetX(), yy, false, false, &r)) {
|
|
||||||
eFreqSelMode saveMode = mFreqSelMode;
|
|
||||||
mFreqSelMode = FREQ_SEL_PINNED_CENTER;
|
|
||||||
|
|
||||||
StartSnappingFreqSelection(wt);
|
|
||||||
MoveSnappingFreqSelection(yy, r.y, r.height, wt);
|
|
||||||
ExtendFreqSelection(yy, r.y, r.height);
|
|
||||||
UpdateSelectionDisplay();
|
|
||||||
|
|
||||||
mFreqSelMode = saveMode;
|
|
||||||
double hint = -1.0;
|
|
||||||
if (mFreqSelMode == FREQ_SEL_FREE) {
|
|
||||||
hint = PositionToFrequency
|
|
||||||
(true, yy, r.y, r.height, wt->GetRate(), logF);
|
|
||||||
}
|
|
||||||
ResetFreqSelectionPin(hint, logF);
|
|
||||||
// MakeParentModifyState(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// And don't skip event, yet
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Only deal with LabelTracks
|
// Only deal with LabelTracks
|
||||||
if (!t || t->GetKind() != Track::Label) {
|
if (!t || t->GetKind() != Track::Label) {
|
||||||
event.Skip();
|
event.Skip();
|
||||||
|
@ -182,7 +182,7 @@ class AUDACITY_DLL_API TrackPanel:public wxPanel {
|
|||||||
//virtual void SetSelectionFormat(int iformat)
|
//virtual void SetSelectionFormat(int iformat)
|
||||||
//virtual void SetSnapTo(int snapto)
|
//virtual void SetSnapTo(int snapto)
|
||||||
|
|
||||||
void HandleEscapeKey();
|
virtual void HandleEscapeKey(bool down);
|
||||||
virtual void HandleAltKey(bool down);
|
virtual void HandleAltKey(bool down);
|
||||||
virtual void HandleShiftKey(bool down);
|
virtual void HandleShiftKey(bool down);
|
||||||
virtual void HandleControlKey(bool down);
|
virtual void HandleControlKey(bool down);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user