mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-29 14:48:39 +02:00
Factor base class CellularPanel from TrackPanel...
... The base class has all the logic for managing hit test handles and context menus and changes of cursors and status messages as the mouse moves. CellularPanel has no knowledge of tracks. TrackPanel does, supplying the policy for dividing the panel area into cells. AdornedRulerPanel will be rewritten to reuse this base class with another policy. (And the notorious TrackPanel.cpp now becomes several hundred lines shorter!)
This commit is contained in:
commit
85074c3387
@ -1206,6 +1206,7 @@
|
|||||||
5E07842E1DEE6B8600CA76EA /* FileException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E07842C1DEE6B8600CA76EA /* FileException.cpp */; };
|
5E07842E1DEE6B8600CA76EA /* FileException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E07842C1DEE6B8600CA76EA /* FileException.cpp */; };
|
||||||
5E0784311DF1E4F400CA76EA /* UserException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E07842F1DF1E4F400CA76EA /* UserException.cpp */; };
|
5E0784311DF1E4F400CA76EA /* UserException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E07842F1DF1E4F400CA76EA /* UserException.cpp */; };
|
||||||
5E0A0E311D23019A00CD2567 /* MenusMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E0A0E301D23019A00CD2567 /* MenusMac.cpp */; };
|
5E0A0E311D23019A00CD2567 /* MenusMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E0A0E301D23019A00CD2567 /* MenusMac.cpp */; };
|
||||||
|
5E0A1CDD20E95FF7001AAF8D /* CellularPanel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E0A1CDB20E95FF7001AAF8D /* CellularPanel.cpp */; };
|
||||||
5E10D9061EC8F81300B3AC57 /* PlayableTrackButtonHandles.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E10D9041EC8F81300B3AC57 /* PlayableTrackButtonHandles.cpp */; };
|
5E10D9061EC8F81300B3AC57 /* PlayableTrackButtonHandles.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E10D9041EC8F81300B3AC57 /* PlayableTrackButtonHandles.cpp */; };
|
||||||
5E15123D1DB000C000702E29 /* UIHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E15123B1DB000C000702E29 /* UIHandle.cpp */; };
|
5E15123D1DB000C000702E29 /* UIHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E15123B1DB000C000702E29 /* UIHandle.cpp */; };
|
||||||
5E15125A1DB000DC00702E29 /* LabelTrackControls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E1512401DB000DC00702E29 /* LabelTrackControls.cpp */; };
|
5E15125A1DB000DC00702E29 /* LabelTrackControls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E1512401DB000DC00702E29 /* LabelTrackControls.cpp */; };
|
||||||
@ -3053,6 +3054,8 @@
|
|||||||
5E07842F1DF1E4F400CA76EA /* UserException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserException.cpp; sourceTree = "<group>"; };
|
5E07842F1DF1E4F400CA76EA /* UserException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserException.cpp; sourceTree = "<group>"; };
|
||||||
5E0784301DF1E4F400CA76EA /* UserException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserException.h; sourceTree = "<group>"; };
|
5E0784301DF1E4F400CA76EA /* UserException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserException.h; sourceTree = "<group>"; };
|
||||||
5E0A0E301D23019A00CD2567 /* MenusMac.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = MenusMac.cpp; sourceTree = "<group>"; };
|
5E0A0E301D23019A00CD2567 /* MenusMac.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = MenusMac.cpp; sourceTree = "<group>"; };
|
||||||
|
5E0A1CDB20E95FF7001AAF8D /* CellularPanel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CellularPanel.cpp; sourceTree = "<group>"; };
|
||||||
|
5E0A1CDC20E95FF7001AAF8D /* CellularPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CellularPanel.h; sourceTree = "<group>"; };
|
||||||
5E10D9041EC8F81300B3AC57 /* PlayableTrackButtonHandles.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlayableTrackButtonHandles.cpp; sourceTree = "<group>"; };
|
5E10D9041EC8F81300B3AC57 /* PlayableTrackButtonHandles.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlayableTrackButtonHandles.cpp; sourceTree = "<group>"; };
|
||||||
5E10D9051EC8F81300B3AC57 /* PlayableTrackButtonHandles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlayableTrackButtonHandles.h; sourceTree = "<group>"; };
|
5E10D9051EC8F81300B3AC57 /* PlayableTrackButtonHandles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlayableTrackButtonHandles.h; sourceTree = "<group>"; };
|
||||||
5E1512381DB000C000702E29 /* HitTestResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HitTestResult.h; sourceTree = "<group>"; };
|
5E1512381DB000C000702E29 /* HitTestResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HitTestResult.h; sourceTree = "<group>"; };
|
||||||
@ -4053,6 +4056,7 @@
|
|||||||
1790AFD809883BFD008A330A /* BatchProcessDialog.cpp */,
|
1790AFD809883BFD008A330A /* BatchProcessDialog.cpp */,
|
||||||
1790AFDA09883BFD008A330A /* Benchmark.cpp */,
|
1790AFDA09883BFD008A330A /* Benchmark.cpp */,
|
||||||
1790AFE809883BFD008A330A /* BlockFile.cpp */,
|
1790AFE809883BFD008A330A /* BlockFile.cpp */,
|
||||||
|
5E0A1CDB20E95FF7001AAF8D /* CellularPanel.cpp */,
|
||||||
1790AFF409883BFD008A330A /* CrossFade.cpp */,
|
1790AFF409883BFD008A330A /* CrossFade.cpp */,
|
||||||
2849B4600A7444BE00ECF12D /* Dependencies.cpp */,
|
2849B4600A7444BE00ECF12D /* Dependencies.cpp */,
|
||||||
28D000A31A32920C00367B21 /* DeviceChange.cpp */,
|
28D000A31A32920C00367B21 /* DeviceChange.cpp */,
|
||||||
@ -4147,6 +4151,7 @@
|
|||||||
1790AFD909883BFD008A330A /* BatchProcessDialog.h */,
|
1790AFD909883BFD008A330A /* BatchProcessDialog.h */,
|
||||||
1790AFDB09883BFD008A330A /* Benchmark.h */,
|
1790AFDB09883BFD008A330A /* Benchmark.h */,
|
||||||
1790AFE909883BFD008A330A /* BlockFile.h */,
|
1790AFE909883BFD008A330A /* BlockFile.h */,
|
||||||
|
5E0A1CDC20E95FF7001AAF8D /* CellularPanel.h */,
|
||||||
1790AFF009883BFD008A330A /* configtemplate.h */,
|
1790AFF009883BFD008A330A /* configtemplate.h */,
|
||||||
1790AFF509883BFD008A330A /* CrossFade.h */,
|
1790AFF509883BFD008A330A /* CrossFade.h */,
|
||||||
2849B4610A7444BE00ECF12D /* Dependencies.h */,
|
2849B4610A7444BE00ECF12D /* Dependencies.h */,
|
||||||
@ -7729,6 +7734,7 @@
|
|||||||
1790B11E09883BFD008A330A /* BatchCommands.cpp in Sources */,
|
1790B11E09883BFD008A330A /* BatchCommands.cpp in Sources */,
|
||||||
5ED1D0B11CDE560C00471E3C /* BackedPanel.cpp in Sources */,
|
5ED1D0B11CDE560C00471E3C /* BackedPanel.cpp in Sources */,
|
||||||
1790B11F09883BFD008A330A /* BatchProcessDialog.cpp in Sources */,
|
1790B11F09883BFD008A330A /* BatchProcessDialog.cpp in Sources */,
|
||||||
|
5E0A1CDD20E95FF7001AAF8D /* CellularPanel.cpp in Sources */,
|
||||||
1790B12009883BFD008A330A /* Benchmark.cpp in Sources */,
|
1790B12009883BFD008A330A /* Benchmark.cpp in Sources */,
|
||||||
1790B12109883BFD008A330A /* LegacyAliasBlockFile.cpp in Sources */,
|
1790B12109883BFD008A330A /* LegacyAliasBlockFile.cpp in Sources */,
|
||||||
1790B12209883BFD008A330A /* LegacyBlockFile.cpp in Sources */,
|
1790B12209883BFD008A330A /* LegacyBlockFile.cpp in Sources */,
|
||||||
|
881
src/CellularPanel.cpp
Normal file
881
src/CellularPanel.cpp
Normal file
@ -0,0 +1,881 @@
|
|||||||
|
/**********************************************************************
|
||||||
|
|
||||||
|
Audacity: A Digital Audio Editor
|
||||||
|
|
||||||
|
CellularPanel.cpp
|
||||||
|
|
||||||
|
Dominic Mazzoni
|
||||||
|
and lots of other contributors
|
||||||
|
|
||||||
|
Implements CellularPanel.
|
||||||
|
|
||||||
|
********************************************************************//*!
|
||||||
|
|
||||||
|
\class CellularPanel
|
||||||
|
\brief
|
||||||
|
|
||||||
|
Formerly part of TrackPanel, this abstract base class has no special knowledge
|
||||||
|
of Track objects and is intended for reuse with other windows.
|
||||||
|
|
||||||
|
Manages a division of a panel's area into disjoint rectangles, each with
|
||||||
|
an associated Cell object. Details of that partition and association, and
|
||||||
|
the choice of the cell with keyboard focus, are subclass responsibilities.
|
||||||
|
|
||||||
|
Handling of keyboard events is delegated to the focused cell. The cell under
|
||||||
|
the mouse position is queried for hit-test candidate objects, which handle
|
||||||
|
click-drag-release (and ESC key abort) sequences.
|
||||||
|
|
||||||
|
*//*****************************************************************/
|
||||||
|
|
||||||
|
#include "Audacity.h"
|
||||||
|
#include "CellularPanel.h"
|
||||||
|
#include "Project.h"
|
||||||
|
#include "UIHandle.h"
|
||||||
|
#include "TrackPanelMouseEvent.h"
|
||||||
|
#include "HitTestResult.h"
|
||||||
|
#include "RefreshCode.h"
|
||||||
|
|
||||||
|
struct CellularPanel::State
|
||||||
|
{
|
||||||
|
UIHandlePtr mUIHandle;
|
||||||
|
|
||||||
|
std::weak_ptr<TrackPanelCell> mLastCell;
|
||||||
|
std::vector<UIHandlePtr> mTargets;
|
||||||
|
size_t mTarget {};
|
||||||
|
unsigned mMouseOverUpdateFlags{};
|
||||||
|
|
||||||
|
int mMouseMostRecentX;
|
||||||
|
int mMouseMostRecentY;
|
||||||
|
|
||||||
|
std::weak_ptr<TrackPanelCell> mpClickedCell;
|
||||||
|
|
||||||
|
bool mEnableTab{};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(CellularPanel, OverlayPanel)
|
||||||
|
EVT_MOUSE_EVENTS(CellularPanel::OnMouseEvent)
|
||||||
|
EVT_MOUSE_CAPTURE_LOST(CellularPanel::OnCaptureLost)
|
||||||
|
EVT_COMMAND(wxID_ANY, EVT_CAPTURE_KEY, CellularPanel::OnCaptureKey)
|
||||||
|
EVT_KEY_DOWN(CellularPanel::OnKeyDown)
|
||||||
|
EVT_KEY_UP(CellularPanel::OnKeyUp)
|
||||||
|
EVT_CHAR(CellularPanel::OnChar)
|
||||||
|
EVT_SET_FOCUS(CellularPanel::OnSetFocus)
|
||||||
|
EVT_KILL_FOCUS(CellularPanel::OnKillFocus)
|
||||||
|
EVT_CONTEXT_MENU(CellularPanel::OnContextMenu)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
CellularPanel::CellularPanel(
|
||||||
|
wxWindow * parent, wxWindowID id,
|
||||||
|
const wxPoint & pos, const wxSize & size,
|
||||||
|
ViewInfo *viewInfo,
|
||||||
|
long style)
|
||||||
|
: OverlayPanel(parent, id, pos, size, style)
|
||||||
|
, mViewInfo( viewInfo )
|
||||||
|
, mState{ std::make_unique<State>() }
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CellularPanel::~CellularPanel() = default;
|
||||||
|
|
||||||
|
void CellularPanel::HandleInterruptedDrag()
|
||||||
|
{
|
||||||
|
auto &state = *mState;
|
||||||
|
if (state.mUIHandle &&
|
||||||
|
state.mUIHandle->StopsOnKeystroke() ) {
|
||||||
|
// The bogus id isn't used anywhere, but may help with debugging.
|
||||||
|
// as this is sending a bogus mouse up. The mouse button is still actually down
|
||||||
|
// and may go up again.
|
||||||
|
const int idBogusUp = 2;
|
||||||
|
wxMouseEvent evt { wxEVT_LEFT_UP };
|
||||||
|
evt.SetId( idBogusUp );
|
||||||
|
evt.SetPosition(this->ScreenToClient(::wxGetMousePosition()));
|
||||||
|
this->ProcessEvent(evt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellularPanel::Uncapture(wxMouseState *pState)
|
||||||
|
{
|
||||||
|
auto state = ::wxGetMouseState();
|
||||||
|
if (!pState) {
|
||||||
|
// Remap the position
|
||||||
|
state.SetPosition(this->ScreenToClient(state.GetPosition()));
|
||||||
|
pState = &state;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HasCapture())
|
||||||
|
ReleaseMouse();
|
||||||
|
HandleMotion( *pState );
|
||||||
|
|
||||||
|
auto lender = GetProject()->mFocusLender.get();
|
||||||
|
if (lender)
|
||||||
|
lender->SetFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CellularPanel::CancelDragging()
|
||||||
|
{
|
||||||
|
auto &state = *mState;
|
||||||
|
if (state.mUIHandle) {
|
||||||
|
// copy shared_ptr for safety, as in HandleClick
|
||||||
|
auto handle = state.mUIHandle;
|
||||||
|
// UIHANDLE CANCEL
|
||||||
|
UIHandle::Result refreshResult = handle->Cancel(GetProject());
|
||||||
|
auto pClickedCell = state.mpClickedCell.lock();
|
||||||
|
if (pClickedCell)
|
||||||
|
ProcessUIHandleResult(
|
||||||
|
pClickedCell.get(), {},
|
||||||
|
refreshResult | state.mMouseOverUpdateFlags );
|
||||||
|
state.mpClickedCell.reset();
|
||||||
|
state.mUIHandle.reset(), handle.reset(), ClearTargets();
|
||||||
|
Uncapture();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CellularPanel::HandleEscapeKey(bool down)
|
||||||
|
{
|
||||||
|
if (!down)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
{
|
||||||
|
auto target = Target();
|
||||||
|
if (target && target->HasEscape() && target->Escape()) {
|
||||||
|
HandleCursorForPresentMouseState(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto &state = *mState;
|
||||||
|
if (state.mUIHandle) {
|
||||||
|
CancelDragging();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ChangeTarget(true, false)) {
|
||||||
|
HandleCursorForPresentMouseState(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellularPanel::UpdateMouseState(const wxMouseState &state)
|
||||||
|
{
|
||||||
|
mLastMouseState = state;
|
||||||
|
|
||||||
|
// Simulate a down button if none, so hit test routines can anticipate
|
||||||
|
// which button will be clicked
|
||||||
|
if (!state.ButtonIsDown(wxMOUSE_BTN_ANY)) {
|
||||||
|
#ifdef __WXOSX__
|
||||||
|
if (state.RawControlDown())
|
||||||
|
// On Mac we can distinctly anticipate "right" click (as Control+click)
|
||||||
|
mLastMouseState.SetRightDown( true ),
|
||||||
|
mLastMouseState.SetLeftDown( false );
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
// Anticipate a left click by default
|
||||||
|
mLastMouseState.SetRightDown( false ),
|
||||||
|
mLastMouseState.SetLeftDown( true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellularPanel::HandleModifierKey()
|
||||||
|
{
|
||||||
|
HandleCursorForPresentMouseState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellularPanel::HandleCursorForPresentMouseState(bool doHit)
|
||||||
|
{
|
||||||
|
// Come here on modifier key or mouse button transitions,
|
||||||
|
// or on starting or stopping of play or record,
|
||||||
|
// or change of toolbar button,
|
||||||
|
// and change the cursor appropriately.
|
||||||
|
|
||||||
|
// Get the button and key states
|
||||||
|
auto state = ::wxGetMouseState();
|
||||||
|
// Remap the position
|
||||||
|
state.SetPosition(this->ScreenToClient(state.GetPosition()));
|
||||||
|
|
||||||
|
HandleMotion( state, doHit );
|
||||||
|
}
|
||||||
|
|
||||||
|
/// CellularPanel::HandleMotion( ) sets the cursor drawn at the mouse location,
|
||||||
|
/// and updates the status bar message.
|
||||||
|
/// We treat certain other changes of mouse button and key state as "motions"
|
||||||
|
/// too, and also starting and stopping of playback or recording, all of which
|
||||||
|
/// may cause the appropriate cursor and message to change.
|
||||||
|
/// As this procedure checks which region the mouse is over, it is
|
||||||
|
/// appropriate to establish the message in the status bar.
|
||||||
|
void CellularPanel::HandleMotion( wxMouseState &inState, bool doHit )
|
||||||
|
{
|
||||||
|
UpdateMouseState( inState );
|
||||||
|
|
||||||
|
const auto foundCell = FindCell( inState.m_x, inState.m_y );
|
||||||
|
auto &rect = foundCell.rect;
|
||||||
|
auto &pCell = foundCell.pCell;
|
||||||
|
const TrackPanelMouseState tpmState{ mLastMouseState, rect, pCell };
|
||||||
|
HandleMotion( tpmState, doHit );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellularPanel::HandleMotion
|
||||||
|
( const TrackPanelMouseState &tpmState, bool doHit )
|
||||||
|
{
|
||||||
|
auto &state = *mState;
|
||||||
|
auto handle = state.mUIHandle;
|
||||||
|
|
||||||
|
auto newCell = tpmState.pCell;
|
||||||
|
|
||||||
|
wxString status{}, tooltip{};
|
||||||
|
wxCursor *pCursor{};
|
||||||
|
unsigned refreshCode = 0;
|
||||||
|
|
||||||
|
if ( ! doHit ) {
|
||||||
|
// Dragging or not
|
||||||
|
handle = Target();
|
||||||
|
|
||||||
|
// Assume cell does not change but target does
|
||||||
|
refreshCode = state.mMouseOverUpdateFlags;
|
||||||
|
state.mMouseOverUpdateFlags = 0;
|
||||||
|
}
|
||||||
|
else if ( !state.mUIHandle ) {
|
||||||
|
// Not yet dragging.
|
||||||
|
|
||||||
|
auto oldCell = state.mLastCell.lock();
|
||||||
|
|
||||||
|
unsigned updateFlags = state.mMouseOverUpdateFlags;
|
||||||
|
|
||||||
|
// First check whether crossing cell to cell
|
||||||
|
if ( newCell == oldCell )
|
||||||
|
oldCell.reset();
|
||||||
|
else {
|
||||||
|
// Forget old targets
|
||||||
|
ClearTargets();
|
||||||
|
// Re-draw any highlighting
|
||||||
|
if (oldCell) {
|
||||||
|
ProcessUIHandleResult(
|
||||||
|
oldCell.get(), oldCell.get(), updateFlags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto oldHandle = Target();
|
||||||
|
auto oldPosition = state.mTarget;
|
||||||
|
|
||||||
|
// Now do the
|
||||||
|
// UIHANDLE HIT TEST !
|
||||||
|
state.mTargets.clear();
|
||||||
|
if (newCell)
|
||||||
|
state.mTargets = newCell->HitTest(tpmState, GetProject());
|
||||||
|
|
||||||
|
state.mTarget = 0;
|
||||||
|
|
||||||
|
// Find the old target's NEW place if we can
|
||||||
|
if (oldHandle) {
|
||||||
|
auto begin = state.mTargets.begin(), end = state.mTargets.end(),
|
||||||
|
iter = std::find(begin, end, oldHandle);
|
||||||
|
if (iter != end) {
|
||||||
|
size_t newPosition = iter - begin;
|
||||||
|
if (newPosition <= oldPosition)
|
||||||
|
state.mTarget = newPosition;
|
||||||
|
// else, some NEW hit and this position takes priority
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handle = Target();
|
||||||
|
|
||||||
|
state.mLastCell = newCell;
|
||||||
|
|
||||||
|
if (!oldCell && oldHandle != handle)
|
||||||
|
// Did not move cell to cell, but did change the target
|
||||||
|
refreshCode = updateFlags;
|
||||||
|
|
||||||
|
if (handle && handle != oldHandle)
|
||||||
|
handle->Enter(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// UIHANDLE PREVIEW
|
||||||
|
// Update status message and cursor, whether dragging or not
|
||||||
|
if (handle) {
|
||||||
|
auto preview = handle->Preview( tpmState, GetProject() );
|
||||||
|
status = preview.message;
|
||||||
|
tooltip = preview.tooltip;
|
||||||
|
pCursor = preview.cursor;
|
||||||
|
auto code = handle->GetChangeHighlight();
|
||||||
|
handle->SetChangeHighlight(RefreshCode::RefreshNone);
|
||||||
|
refreshCode |= code;
|
||||||
|
state.mMouseOverUpdateFlags |= code;
|
||||||
|
}
|
||||||
|
if (newCell &&
|
||||||
|
(!pCursor || status.empty() || tooltip.empty())) {
|
||||||
|
// Defaulting of cursor, tooltip, and status if there is no handle,
|
||||||
|
// or if the handle does not specify them
|
||||||
|
const auto preview = newCell->DefaultPreview( tpmState, GetProject() );
|
||||||
|
if (!pCursor)
|
||||||
|
pCursor = preview.cursor;
|
||||||
|
if (status.empty())
|
||||||
|
status = preview.message;
|
||||||
|
if (tooltip.empty())
|
||||||
|
tooltip = preview.tooltip;
|
||||||
|
}
|
||||||
|
if (!pCursor) {
|
||||||
|
// Ultimate default cursor
|
||||||
|
static wxCursor defaultCursor{ wxCURSOR_DEFAULT };
|
||||||
|
pCursor = &defaultCursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateStatusMessage(status);
|
||||||
|
|
||||||
|
#if wxUSE_TOOLTIPS
|
||||||
|
if (tooltip != GetToolTipText()) {
|
||||||
|
// Unset first, by analogy with AButton
|
||||||
|
UnsetToolTip();
|
||||||
|
SetToolTip(tooltip);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (pCursor)
|
||||||
|
SetCursor( *pCursor );
|
||||||
|
|
||||||
|
if (newCell)
|
||||||
|
ProcessUIHandleResult(newCell.get(), newCell.get(), refreshCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellularPanel::Leave()
|
||||||
|
{
|
||||||
|
// Make transition into an empty CellularPanel state
|
||||||
|
auto state = ::wxGetMouseState();
|
||||||
|
const wxRect rect;
|
||||||
|
std::shared_ptr<TrackPanelCell> pCell;
|
||||||
|
TrackPanelMouseState tpmState{ state, rect, pCell };
|
||||||
|
HandleMotion( tpmState );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CellularPanel::HasRotation()
|
||||||
|
{
|
||||||
|
auto &state = *mState;
|
||||||
|
// Is there a nontrivial TAB key rotation?
|
||||||
|
if ( state.mTargets.size() > 1 )
|
||||||
|
return true;
|
||||||
|
auto target = Target();
|
||||||
|
return target && target->HasRotation();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CellularPanel::HasEscape()
|
||||||
|
{
|
||||||
|
if (IsMouseCaptured())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
auto &state = *mState;
|
||||||
|
if (state.mTarget + 1 == state.mTargets.size() &&
|
||||||
|
Target() &&
|
||||||
|
!Target()->HasEscape())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return state.mTargets.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CellularPanel::ChangeTarget(bool forward, bool cycle)
|
||||||
|
{
|
||||||
|
auto &state = *mState;
|
||||||
|
auto size = state.mTargets.size();
|
||||||
|
|
||||||
|
auto target = Target();
|
||||||
|
if (target && target->HasRotation()) {
|
||||||
|
if(target->Rotate(forward))
|
||||||
|
return true;
|
||||||
|
else if (cycle && (size == 1 || IsMouseCaptured())) {
|
||||||
|
// Rotate through the states of this target only.
|
||||||
|
target->Enter(forward);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cycle &&
|
||||||
|
((forward && state.mTarget + 1 == size) ||
|
||||||
|
(!forward && state.mTarget == 0)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (size > 1) {
|
||||||
|
if (forward)
|
||||||
|
++state.mTarget;
|
||||||
|
else
|
||||||
|
state.mTarget += size - 1;
|
||||||
|
state.mTarget %= size;
|
||||||
|
if (Target())
|
||||||
|
Target()->Enter(forward);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Determines if a modal tool is active
|
||||||
|
bool CellularPanel::IsMouseCaptured()
|
||||||
|
{
|
||||||
|
auto &state = *mState;
|
||||||
|
return state.mUIHandle != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellularPanel::OnContextMenu(wxContextMenuEvent & WXUNUSED(event))
|
||||||
|
{
|
||||||
|
DoContextMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Handle mouse wheel rotation (for zoom in/out, vertical and horizontal scrolling)
|
||||||
|
void CellularPanel::HandleWheelRotation( TrackPanelMouseEvent &tpmEvent )
|
||||||
|
{
|
||||||
|
auto pCell = tpmEvent.pCell;
|
||||||
|
if (!pCell)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto &event = tpmEvent.event;
|
||||||
|
double steps {};
|
||||||
|
#if defined(__WXMAC__) && defined(EVT_MAGNIFY)
|
||||||
|
// PRL:
|
||||||
|
// Pinch and spread implemented in wxWidgets 3.1.0, or cherry-picked from
|
||||||
|
// the future in custom build of 3.0.2
|
||||||
|
if (event.Magnify()) {
|
||||||
|
event.SetControlDown(true);
|
||||||
|
steps = 2 * event.GetMagnification();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
steps = event.m_wheelRotation /
|
||||||
|
(event.m_wheelDelta > 0 ? (double)event.m_wheelDelta : 120.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(event.GetWheelAxis() == wxMOUSE_WHEEL_HORIZONTAL) {
|
||||||
|
// Two-fingered horizontal swipe on mac is treated like shift-mousewheel
|
||||||
|
event.SetShiftDown(true);
|
||||||
|
// This makes the wave move in the same direction as the fingers, and the scrollbar
|
||||||
|
// thumb moves oppositely
|
||||||
|
steps *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tpmEvent.steps = steps;
|
||||||
|
|
||||||
|
if(!event.HasAnyModifiers()) {
|
||||||
|
// We will later un-skip if we do anything, but if we don't,
|
||||||
|
// propagate the event up for the sake of the scrubber
|
||||||
|
event.Skip();
|
||||||
|
event.ResumePropagation(wxEVENT_PROPAGATE_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned result =
|
||||||
|
pCell->HandleWheelRotation( tpmEvent, GetProject() );
|
||||||
|
ProcessUIHandleResult(
|
||||||
|
pCell.get(), pCell.get(), result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellularPanel::OnCaptureKey(wxCommandEvent & event)
|
||||||
|
{
|
||||||
|
auto &state = *mState;
|
||||||
|
state.mEnableTab = false;
|
||||||
|
wxKeyEvent *kevent = static_cast<wxKeyEvent *>(event.GetEventObject());
|
||||||
|
const auto code = kevent->GetKeyCode();
|
||||||
|
if ( WXK_ESCAPE != code )
|
||||||
|
HandleInterruptedDrag();
|
||||||
|
|
||||||
|
// Give focused cell precedence
|
||||||
|
const auto t = GetFocusedCell();
|
||||||
|
if (t) {
|
||||||
|
const unsigned refreshResult =
|
||||||
|
t->CaptureKey(*kevent, *mViewInfo, this);
|
||||||
|
ProcessUIHandleResult(t, t, refreshResult);
|
||||||
|
event.Skip(kevent->GetSkipped());
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// Special TAB key handling, but only if the cell didn't capture it
|
||||||
|
if ( !(t && !kevent->GetSkipped()) &&
|
||||||
|
WXK_TAB == code && HasRotation() ) {
|
||||||
|
// Override TAB navigation in wxWidgets, by not skipping
|
||||||
|
event.Skip(false);
|
||||||
|
mEnableTab = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
if (!t)
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellularPanel::OnKeyDown(wxKeyEvent & event)
|
||||||
|
{
|
||||||
|
switch (event.GetKeyCode())
|
||||||
|
{
|
||||||
|
case WXK_ESCAPE:
|
||||||
|
if(HandleEscapeKey(true))
|
||||||
|
// Don't skip the event, eat it so that
|
||||||
|
// AudacityApp does not also stop any playback.
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WXK_ALT:
|
||||||
|
case WXK_SHIFT:
|
||||||
|
case WXK_CONTROL:
|
||||||
|
#ifdef __WXOSX__
|
||||||
|
case WXK_RAW_CONTROL:
|
||||||
|
#endif
|
||||||
|
HandleModifierKey();
|
||||||
|
break;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
case WXK_TAB:
|
||||||
|
if ( mEnableTab && HasRotation() ) {
|
||||||
|
ChangeTarget( !event.ShiftDown(), true );
|
||||||
|
HandleCursorForPresentMouseState(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto t = GetFocusedCell();
|
||||||
|
|
||||||
|
if (t) {
|
||||||
|
const unsigned refreshResult =
|
||||||
|
t->KeyDown(event, *mViewInfo, this);
|
||||||
|
ProcessUIHandleResult(t, t, refreshResult);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellularPanel::OnChar(wxKeyEvent & event)
|
||||||
|
{
|
||||||
|
switch (event.GetKeyCode())
|
||||||
|
{
|
||||||
|
case WXK_ESCAPE:
|
||||||
|
case WXK_ALT:
|
||||||
|
case WXK_SHIFT:
|
||||||
|
case WXK_CONTROL:
|
||||||
|
case WXK_PAGEUP:
|
||||||
|
case WXK_PAGEDOWN:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto t = GetFocusedCell();
|
||||||
|
if (t) {
|
||||||
|
const unsigned refreshResult =
|
||||||
|
t->Char(event, *mViewInfo, this);
|
||||||
|
ProcessUIHandleResult(t, t, refreshResult);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellularPanel::OnKeyUp(wxKeyEvent & event)
|
||||||
|
{
|
||||||
|
bool didSomething = false;
|
||||||
|
switch (event.GetKeyCode())
|
||||||
|
{
|
||||||
|
case WXK_ESCAPE:
|
||||||
|
didSomething = HandleEscapeKey(false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WXK_ALT:
|
||||||
|
case WXK_SHIFT:
|
||||||
|
case WXK_CONTROL:
|
||||||
|
#ifdef __WXOSX__
|
||||||
|
case WXK_RAW_CONTROL:
|
||||||
|
#endif
|
||||||
|
HandleModifierKey();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (didSomething)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const auto t = GetFocusedCell();
|
||||||
|
if (t) {
|
||||||
|
const unsigned refreshResult =
|
||||||
|
t->KeyUp(event, *mViewInfo, this);
|
||||||
|
ProcessUIHandleResult(t, t, refreshResult);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Should handle the case when the mouse capture is lost. (MSW only)
|
||||||
|
void CellularPanel::OnCaptureLost(wxMouseCaptureLostEvent & WXUNUSED(event))
|
||||||
|
{
|
||||||
|
auto &state = *mState;
|
||||||
|
state.mUIHandle.reset();
|
||||||
|
Leave();
|
||||||
|
|
||||||
|
// This is bad. We are lying abou the event by saying it is a mouse up.
|
||||||
|
wxMouseEvent e(wxEVT_LEFT_UP);
|
||||||
|
e.SetId( kCaptureLostEventId );
|
||||||
|
|
||||||
|
e.m_x = state.mMouseMostRecentX;
|
||||||
|
e.m_y = state.mMouseMostRecentY;
|
||||||
|
|
||||||
|
OnMouseEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This handles just generic mouse events. Then, based
|
||||||
|
/// on our current state, we forward the mouse events to
|
||||||
|
/// various interested parties.
|
||||||
|
void CellularPanel::OnMouseEvent(wxMouseEvent & event)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const auto foundCell = FindCell( event.m_x, event.m_y );
|
||||||
|
auto &rect = foundCell.rect;
|
||||||
|
auto &pCell = foundCell.pCell;
|
||||||
|
|
||||||
|
const auto size = GetSize();
|
||||||
|
TrackPanelMouseEvent tpmEvent{ event, rect, size, pCell };
|
||||||
|
|
||||||
|
#if defined(__WXMAC__) && defined(EVT_MAGNIFY)
|
||||||
|
// PRL:
|
||||||
|
// Pinch and spread implemented in wxWidgets 3.1.0, or cherry-picked from
|
||||||
|
// the future in custom build of 3.0.2
|
||||||
|
if (event.Magnify()) {
|
||||||
|
HandleWheelRotation( tpmEvent );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// If a mouse event originates from a keyboard context menu event then
|
||||||
|
// event.GetPosition() == wxDefaultPosition. wxContextMenu events are handled in
|
||||||
|
// CellularPanel::OnContextMenu(), and therefore associated mouse events are ignored here.
|
||||||
|
// Not ignoring them was causing bug 613: the mouse events were interpreted as clicking
|
||||||
|
// outside the tracks.
|
||||||
|
if (event.GetPosition() == wxDefaultPosition && (event.RightDown() || event.RightUp())) {
|
||||||
|
event.Skip();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.m_wheelRotation != 0)
|
||||||
|
HandleWheelRotation( tpmEvent );
|
||||||
|
|
||||||
|
if (event.LeftDown() || event.LeftIsDown() || event.Moving()) {
|
||||||
|
// Skip, even if we do something, so that the left click or drag
|
||||||
|
// may have an additional effect in the scrubber.
|
||||||
|
event.Skip();
|
||||||
|
event.ResumePropagation(wxEVENT_PROPAGATE_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto &state = *mState;
|
||||||
|
state.mMouseMostRecentX = event.m_x;
|
||||||
|
state.mMouseMostRecentY = event.m_y;
|
||||||
|
|
||||||
|
if (event.LeftDown()) {
|
||||||
|
// The activate event is used to make the
|
||||||
|
// parent window 'come alive' if it didn't have focus.
|
||||||
|
wxActivateEvent e;
|
||||||
|
GetParent()->GetEventHandler()->ProcessEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.Leaving())
|
||||||
|
{
|
||||||
|
Leave();
|
||||||
|
|
||||||
|
auto buttons =
|
||||||
|
// Bug 1325: button state in Leaving events is unreliable on Mac.
|
||||||
|
// Poll the global state instead.
|
||||||
|
// event.ButtonIsDown(wxMOUSE_BTN_ANY);
|
||||||
|
::wxGetMouseState().ButtonIsDown(wxMOUSE_BTN_ANY);
|
||||||
|
|
||||||
|
if(!buttons) {
|
||||||
|
CancelDragging();
|
||||||
|
|
||||||
|
#if defined(__WXMAC__)
|
||||||
|
|
||||||
|
// We must install the cursor ourselves since the window under
|
||||||
|
// the mouse is no longer this one and wx2.8.12 makes that check.
|
||||||
|
// Should re-evaluate with wx3.
|
||||||
|
wxSTANDARD_CURSOR->MacInstall();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.mUIHandle) {
|
||||||
|
auto pClickedCell = state.mpClickedCell.lock();
|
||||||
|
if (event.Dragging()) {
|
||||||
|
// UIHANDLE DRAG
|
||||||
|
// copy shared_ptr for safety, as in HandleClick
|
||||||
|
auto handle = state.mUIHandle;
|
||||||
|
const UIHandle::Result refreshResult =
|
||||||
|
handle->Drag( tpmEvent, GetProject() );
|
||||||
|
ProcessUIHandleResult
|
||||||
|
(pClickedCell.get(), pCell.get(), refreshResult);
|
||||||
|
state.mMouseOverUpdateFlags |= refreshResult;
|
||||||
|
if (refreshResult & RefreshCode::Cancelled) {
|
||||||
|
// Drag decided to abort itself
|
||||||
|
state.mUIHandle.reset(), handle.reset(), ClearTargets();
|
||||||
|
state.mpClickedCell.reset();
|
||||||
|
Uncapture( &event );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
UpdateMouseState(event);
|
||||||
|
TrackPanelMouseState tpmState{ mLastMouseState, rect, pCell };
|
||||||
|
HandleMotion( tpmState );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (event.ButtonUp()) {
|
||||||
|
// UIHANDLE RELEASE
|
||||||
|
unsigned moreFlags = state.mMouseOverUpdateFlags;
|
||||||
|
UIHandle::Result refreshResult =
|
||||||
|
state.mUIHandle->Release( tpmEvent, GetProject(), this );
|
||||||
|
ProcessUIHandleResult
|
||||||
|
(pClickedCell.get(), pCell.get(),
|
||||||
|
refreshResult | moreFlags);
|
||||||
|
state.mUIHandle.reset(), ClearTargets();
|
||||||
|
state.mpClickedCell.reset();
|
||||||
|
// will also Uncapture() below
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( event.GetEventType() == wxEVT_MOTION )
|
||||||
|
// Update status message and cursor, not during drag
|
||||||
|
// consider it not a drag, even if button is down during motion, if
|
||||||
|
// mUIHandle is null, as it becomes during interrupted drag
|
||||||
|
// (e.g. by hitting space to play while dragging an envelope point)
|
||||||
|
HandleMotion( event );
|
||||||
|
else if ( event.ButtonDown() || event.ButtonDClick() )
|
||||||
|
HandleClick( tpmEvent );
|
||||||
|
|
||||||
|
if (event.ButtonDown() && IsMouseCaptured()) {
|
||||||
|
if (!HasCapture())
|
||||||
|
CaptureMouse();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.ButtonUp())
|
||||||
|
Uncapture();
|
||||||
|
}
|
||||||
|
catch( ... )
|
||||||
|
{
|
||||||
|
// Abort any dragging, as if by hitting Esc
|
||||||
|
if ( CancelDragging() )
|
||||||
|
;
|
||||||
|
else {
|
||||||
|
Uncapture();
|
||||||
|
Refresh(false);
|
||||||
|
}
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellularPanel::HandleClick( const TrackPanelMouseEvent &tpmEvent )
|
||||||
|
{
|
||||||
|
auto pCell = tpmEvent.pCell;
|
||||||
|
|
||||||
|
// Do hit test once more, in case the button really pressed was not the
|
||||||
|
// one "anticipated."
|
||||||
|
{
|
||||||
|
TrackPanelMouseState tpmState{
|
||||||
|
tpmEvent.event,
|
||||||
|
tpmEvent.rect,
|
||||||
|
tpmEvent.pCell
|
||||||
|
};
|
||||||
|
HandleMotion( tpmState );
|
||||||
|
}
|
||||||
|
|
||||||
|
auto &state = *mState;
|
||||||
|
state.mUIHandle = Target();
|
||||||
|
|
||||||
|
if (state.mUIHandle) {
|
||||||
|
// UIHANDLE CLICK
|
||||||
|
// Make another shared pointer to the handle, in case recursive
|
||||||
|
// event dispatching otherwise tries to delete the handle.
|
||||||
|
auto handle = state.mUIHandle;
|
||||||
|
UIHandle::Result refreshResult =
|
||||||
|
handle->Click( tpmEvent, GetProject() );
|
||||||
|
if (refreshResult & RefreshCode::Cancelled)
|
||||||
|
state.mUIHandle.reset(), handle.reset(), ClearTargets();
|
||||||
|
else {
|
||||||
|
if( !HasFocus() )
|
||||||
|
SetFocus();
|
||||||
|
|
||||||
|
state.mpClickedCell = pCell;
|
||||||
|
|
||||||
|
// Perhaps the clicked handle wants to update cursor and state message
|
||||||
|
// after a click.
|
||||||
|
TrackPanelMouseState tpmState{
|
||||||
|
tpmEvent.event,
|
||||||
|
tpmEvent.rect,
|
||||||
|
tpmEvent.pCell
|
||||||
|
};
|
||||||
|
HandleMotion( tpmState );
|
||||||
|
}
|
||||||
|
ProcessUIHandleResult(
|
||||||
|
pCell.get(), pCell.get(), refreshResult);
|
||||||
|
state.mMouseOverUpdateFlags |= refreshResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellularPanel::DoContextMenu( TrackPanelCell *pCell )
|
||||||
|
{
|
||||||
|
if( !pCell ) {
|
||||||
|
pCell = GetFocusedCell();
|
||||||
|
if( !pCell )
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto delegate = pCell->ContextMenuDelegate();
|
||||||
|
if (!delegate)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto rect = FindRect( *delegate );
|
||||||
|
const UIHandle::Result refreshResult =
|
||||||
|
delegate->DoContextMenu(rect, this, NULL);
|
||||||
|
|
||||||
|
// To do: use safer shared_ptr to pCell
|
||||||
|
ProcessUIHandleResult(pCell, pCell, refreshResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellularPanel::OnSetFocus(wxFocusEvent &event)
|
||||||
|
{
|
||||||
|
auto &ptr = GetProject()->mFocusLender;
|
||||||
|
if ( !ptr )
|
||||||
|
ptr = event.GetWindow();
|
||||||
|
|
||||||
|
SetFocusedCell();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellularPanel::OnKillFocus(wxFocusEvent & WXUNUSED(event))
|
||||||
|
{
|
||||||
|
// Forget any borrowing of focus
|
||||||
|
GetProject()->mFocusLender = NULL;
|
||||||
|
|
||||||
|
if (AudacityProject::HasKeyboardCapture(this))
|
||||||
|
{
|
||||||
|
AudacityProject::ReleaseKeyboard(this);
|
||||||
|
}
|
||||||
|
Refresh( false);
|
||||||
|
}
|
||||||
|
|
||||||
|
UIHandlePtr CellularPanel::Target()
|
||||||
|
{
|
||||||
|
auto &state = *mState;
|
||||||
|
if (state.mTargets.size())
|
||||||
|
return state.mTargets[state.mTarget];
|
||||||
|
else
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
wxCoord CellularPanel::MostRecentXCoord() const
|
||||||
|
{
|
||||||
|
auto &state = *mState;
|
||||||
|
return state.mMouseMostRecentX;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellularPanel::ClearTargets()
|
||||||
|
{
|
||||||
|
auto &state = *mState;
|
||||||
|
// Forget the rotation of hit test candidates when the mouse moves from
|
||||||
|
// cell to cell or outside of the panel entirely.
|
||||||
|
state.mLastCell.reset();
|
||||||
|
state.mTargets.clear();
|
||||||
|
state.mTarget = 0;
|
||||||
|
state.mMouseOverUpdateFlags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<TrackPanelCell> CellularPanel::LastCell() const
|
||||||
|
{
|
||||||
|
auto &state = *mState;
|
||||||
|
return state.mLastCell.lock();
|
||||||
|
}
|
122
src/CellularPanel.h
Normal file
122
src/CellularPanel.h
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
/**********************************************************************
|
||||||
|
|
||||||
|
Audacity: A Digital Audio Editor
|
||||||
|
|
||||||
|
TrackPanel.h
|
||||||
|
|
||||||
|
Paul Licameli
|
||||||
|
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef __AUDACITY_CELLULAR_PANEL__
|
||||||
|
#define __AUDACITY_CELLULAR_PANEL__
|
||||||
|
|
||||||
|
#include <wx/cursor.h>
|
||||||
|
#include "widgets/OverlayPanel.h"
|
||||||
|
|
||||||
|
class ViewInfo;
|
||||||
|
class AudacityProject;
|
||||||
|
|
||||||
|
class TrackPanelCell;
|
||||||
|
struct TrackPanelMouseEvent;
|
||||||
|
struct TrackPanelMouseState;
|
||||||
|
|
||||||
|
class UIHandle;
|
||||||
|
using UIHandlePtr = std::shared_ptr<UIHandle>;
|
||||||
|
|
||||||
|
// This class manages a panel divided into a number of sub-rectangles called
|
||||||
|
// cells, that each implement hit tests returning click-drag-release handler
|
||||||
|
// objects, and other services.
|
||||||
|
// It has no dependency on the Track class.
|
||||||
|
class AUDACITY_DLL_API CellularPanel : public OverlayPanel {
|
||||||
|
public:
|
||||||
|
CellularPanel(wxWindow * parent, wxWindowID id,
|
||||||
|
const wxPoint & pos,
|
||||||
|
const wxSize & size,
|
||||||
|
ViewInfo *viewInfo,
|
||||||
|
// default as for wxPanel:
|
||||||
|
long style = wxTAB_TRAVERSAL | wxNO_BORDER);
|
||||||
|
~CellularPanel() override;
|
||||||
|
|
||||||
|
// Overridables:
|
||||||
|
|
||||||
|
virtual AudacityProject *GetProject() const = 0;
|
||||||
|
|
||||||
|
// Find track info by coordinate
|
||||||
|
struct FoundCell {
|
||||||
|
std::shared_ptr<TrackPanelCell> pCell;
|
||||||
|
wxRect rect;
|
||||||
|
};
|
||||||
|
virtual FoundCell FindCell(int mouseX, int mouseY) = 0;
|
||||||
|
virtual wxRect FindRect(const TrackPanelCell &cell) = 0;
|
||||||
|
virtual TrackPanelCell *GetFocusedCell() = 0;
|
||||||
|
virtual void SetFocusedCell() = 0;
|
||||||
|
|
||||||
|
virtual void ProcessUIHandleResult
|
||||||
|
(TrackPanelCell *pClickedCell, TrackPanelCell *pLatestCell,
|
||||||
|
unsigned refreshResult) = 0;
|
||||||
|
|
||||||
|
virtual void UpdateStatusMessage( const wxString & ) = 0;
|
||||||
|
|
||||||
|
public:
|
||||||
|
UIHandlePtr Target();
|
||||||
|
|
||||||
|
std::shared_ptr<TrackPanelCell> LastCell() const;
|
||||||
|
|
||||||
|
bool IsMouseCaptured();
|
||||||
|
|
||||||
|
wxCoord MostRecentXCoord() const;
|
||||||
|
|
||||||
|
void HandleCursorForPresentMouseState(bool doHit = true);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool HasEscape();
|
||||||
|
bool CancelDragging();
|
||||||
|
void DoContextMenu( TrackPanelCell *pCell = nullptr );
|
||||||
|
void ClearTargets();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool HasRotation();
|
||||||
|
bool ChangeTarget(bool forward, bool cycle);
|
||||||
|
|
||||||
|
void OnMouseEvent(wxMouseEvent & event);
|
||||||
|
void OnCaptureLost(wxMouseCaptureLostEvent & event);
|
||||||
|
void OnCaptureKey(wxCommandEvent & event);
|
||||||
|
void OnKeyDown(wxKeyEvent & event);
|
||||||
|
void OnChar(wxKeyEvent & event);
|
||||||
|
void OnKeyUp(wxKeyEvent & event);
|
||||||
|
|
||||||
|
void OnSetFocus(wxFocusEvent & event);
|
||||||
|
void OnKillFocus(wxFocusEvent & event);
|
||||||
|
|
||||||
|
void OnContextMenu(wxContextMenuEvent & event);
|
||||||
|
|
||||||
|
void HandleInterruptedDrag();
|
||||||
|
void Uncapture( wxMouseState *pState = nullptr );
|
||||||
|
bool HandleEscapeKey(bool down);
|
||||||
|
void UpdateMouseState(const wxMouseState &state);
|
||||||
|
void HandleModifierKey();
|
||||||
|
|
||||||
|
void HandleClick( const TrackPanelMouseEvent &tpmEvent );
|
||||||
|
void HandleWheelRotation( TrackPanelMouseEvent &tpmEvent );
|
||||||
|
|
||||||
|
void HandleMotion( wxMouseState &state, bool doHit = true );
|
||||||
|
void HandleMotion
|
||||||
|
( const TrackPanelMouseState &tpmState, bool doHit = true );
|
||||||
|
void Leave();
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
ViewInfo *mViewInfo;
|
||||||
|
|
||||||
|
// To do: make a drawing method and make this private
|
||||||
|
wxMouseState mLastMouseState;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct State;
|
||||||
|
std::unique_ptr<State> mState;
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -121,6 +121,8 @@ audacity_SOURCES = \
|
|||||||
BatchProcessDialog.h \
|
BatchProcessDialog.h \
|
||||||
Benchmark.cpp \
|
Benchmark.cpp \
|
||||||
Benchmark.h \
|
Benchmark.h \
|
||||||
|
CellularPanel.cpp \
|
||||||
|
CellularPanel.h \
|
||||||
Dependencies.cpp \
|
Dependencies.cpp \
|
||||||
Dependencies.h \
|
Dependencies.h \
|
||||||
DeviceChange.cpp \
|
DeviceChange.cpp \
|
||||||
|
113
src/Makefile.in
113
src/Makefile.in
@ -1,7 +1,7 @@
|
|||||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
|
# Makefile.in generated by automake 1.15 from Makefile.am.
|
||||||
# @configure_input@
|
# @configure_input@
|
||||||
|
|
||||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This Makefile.in is free software; the Free Software Foundation
|
# This Makefile.in is free software; the Free Software Foundation
|
||||||
# gives unlimited permission to copy and/or distribute it,
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
@ -16,7 +16,17 @@
|
|||||||
|
|
||||||
|
|
||||||
VPATH = @srcdir@
|
VPATH = @srcdir@
|
||||||
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
|
am__is_gnu_make = { \
|
||||||
|
if test -z '$(MAKELEVEL)'; then \
|
||||||
|
false; \
|
||||||
|
elif test -n '$(MAKE_HOST)'; then \
|
||||||
|
true; \
|
||||||
|
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||||
|
true; \
|
||||||
|
else \
|
||||||
|
false; \
|
||||||
|
fi; \
|
||||||
|
}
|
||||||
am__make_running_with_option = \
|
am__make_running_with_option = \
|
||||||
case $${target_option-} in \
|
case $${target_option-} in \
|
||||||
?) ;; \
|
?) ;; \
|
||||||
@ -190,9 +200,6 @@ bin_PROGRAMS = audacity$(EXEEXT)
|
|||||||
@USE_VST_TRUE@ $(NULL)
|
@USE_VST_TRUE@ $(NULL)
|
||||||
|
|
||||||
subdir = src
|
subdir = src
|
||||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
|
||||||
$(srcdir)/configtemplate.h $(srcdir)/audacity.desktop.in \
|
|
||||||
$(top_srcdir)/autotools/depcomp $(dist_mime_DATA)
|
|
||||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ac_c99_func_lrint.m4 \
|
am__aclocal_m4_deps = $(top_srcdir)/m4/ac_c99_func_lrint.m4 \
|
||||||
$(top_srcdir)/m4/ac_c99_func_lrintf.m4 \
|
$(top_srcdir)/m4/ac_c99_func_lrintf.m4 \
|
||||||
@ -235,6 +242,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_c99_func_lrint.m4 \
|
|||||||
$(top_srcdir)/configure.ac
|
$(top_srcdir)/configure.ac
|
||||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||||
$(ACLOCAL_M4)
|
$(ACLOCAL_M4)
|
||||||
|
DIST_COMMON = $(srcdir)/Makefile.am $(dist_mime_DATA) \
|
||||||
|
$(am__DIST_COMMON)
|
||||||
mkinstalldirs = $(install_sh) -d
|
mkinstalldirs = $(install_sh) -d
|
||||||
CONFIG_HEADER = configwin.h configunix.h
|
CONFIG_HEADER = configwin.h configunix.h
|
||||||
CONFIG_CLEAN_FILES = audacity.desktop
|
CONFIG_CLEAN_FILES = audacity.desktop
|
||||||
@ -287,22 +296,23 @@ am__audacity_SOURCES_DIST = BlockFile.cpp BlockFile.h DirManager.cpp \
|
|||||||
AutoRecovery.h BatchCommandDialog.cpp BatchCommandDialog.h \
|
AutoRecovery.h BatchCommandDialog.cpp BatchCommandDialog.h \
|
||||||
BatchCommands.cpp BatchCommands.h BatchProcessDialog.cpp \
|
BatchCommands.cpp BatchCommands.h BatchProcessDialog.cpp \
|
||||||
BatchProcessDialog.h Benchmark.cpp Benchmark.h \
|
BatchProcessDialog.h Benchmark.cpp Benchmark.h \
|
||||||
Dependencies.cpp Dependencies.h DeviceChange.cpp \
|
CellularPanel.cpp CellularPanel.h Dependencies.cpp \
|
||||||
DeviceChange.h DeviceManager.cpp DeviceManager.h Diags.cpp \
|
Dependencies.h DeviceChange.cpp DeviceChange.h \
|
||||||
Diags.h Envelope.cpp Envelope.h Experimental.h FFmpeg.cpp \
|
DeviceManager.cpp DeviceManager.h Diags.cpp Diags.h \
|
||||||
FFmpeg.h FFT.cpp FFT.h FileException.cpp FileException.h \
|
Envelope.cpp Envelope.h Experimental.h FFmpeg.cpp FFmpeg.h \
|
||||||
FileIO.cpp FileIO.h FileNames.cpp FileNames.h float_cast.h \
|
FFT.cpp FFT.h FileException.cpp FileException.h FileIO.cpp \
|
||||||
FreqWindow.cpp FreqWindow.h HelpText.cpp HelpText.h \
|
FileIO.h FileNames.cpp FileNames.h float_cast.h FreqWindow.cpp \
|
||||||
HistoryWindow.cpp HistoryWindow.h HitTestResult.h \
|
FreqWindow.h HelpText.cpp HelpText.h HistoryWindow.cpp \
|
||||||
ImageManipulation.cpp ImageManipulation.h \
|
HistoryWindow.h HitTestResult.h ImageManipulation.cpp \
|
||||||
InconsistencyException.cpp InconsistencyException.h \
|
ImageManipulation.h InconsistencyException.cpp \
|
||||||
InterpolateAudio.cpp InterpolateAudio.h LabelDialog.cpp \
|
InconsistencyException.h InterpolateAudio.cpp \
|
||||||
LabelDialog.h LabelTrack.cpp LabelTrack.h LangChoice.cpp \
|
InterpolateAudio.h LabelDialog.cpp LabelDialog.h \
|
||||||
LangChoice.h Languages.cpp Languages.h Legacy.cpp Legacy.h \
|
LabelTrack.cpp LabelTrack.h LangChoice.cpp LangChoice.h \
|
||||||
Lyrics.cpp Lyrics.h LyricsWindow.cpp LyricsWindow.h \
|
Languages.cpp Languages.h Legacy.cpp Legacy.h Lyrics.cpp \
|
||||||
MacroMagic.h Matrix.cpp Matrix.h MemoryX.h Menus.cpp Menus.h \
|
Lyrics.h LyricsWindow.cpp LyricsWindow.h MacroMagic.h \
|
||||||
Mix.cpp Mix.h MixerBoard.cpp MixerBoard.h ModuleManager.cpp \
|
Matrix.cpp Matrix.h MemoryX.h Menus.cpp Menus.h Mix.cpp Mix.h \
|
||||||
ModuleManager.h NumberScale.h PitchName.cpp PitchName.h \
|
MixerBoard.cpp MixerBoard.h ModuleManager.cpp ModuleManager.h \
|
||||||
|
NumberScale.h PitchName.cpp PitchName.h \
|
||||||
PlatformCompatibility.cpp PlatformCompatibility.h \
|
PlatformCompatibility.cpp PlatformCompatibility.h \
|
||||||
PluginManager.cpp PluginManager.h Printing.cpp Printing.h \
|
PluginManager.cpp PluginManager.h Printing.cpp Printing.h \
|
||||||
Profiler.cpp Profiler.h Project.cpp Project.h RealFFTf.cpp \
|
Profiler.cpp Profiler.h Project.cpp Project.h RealFFTf.cpp \
|
||||||
@ -612,7 +622,8 @@ am_audacity_OBJECTS = $(am__objects_1) audacity-AboutDialog.$(OBJEXT) \
|
|||||||
audacity-BatchCommandDialog.$(OBJEXT) \
|
audacity-BatchCommandDialog.$(OBJEXT) \
|
||||||
audacity-BatchCommands.$(OBJEXT) \
|
audacity-BatchCommands.$(OBJEXT) \
|
||||||
audacity-BatchProcessDialog.$(OBJEXT) \
|
audacity-BatchProcessDialog.$(OBJEXT) \
|
||||||
audacity-Benchmark.$(OBJEXT) audacity-Dependencies.$(OBJEXT) \
|
audacity-Benchmark.$(OBJEXT) audacity-CellularPanel.$(OBJEXT) \
|
||||||
|
audacity-Dependencies.$(OBJEXT) \
|
||||||
audacity-DeviceChange.$(OBJEXT) \
|
audacity-DeviceChange.$(OBJEXT) \
|
||||||
audacity-DeviceManager.$(OBJEXT) audacity-Diags.$(OBJEXT) \
|
audacity-DeviceManager.$(OBJEXT) audacity-Diags.$(OBJEXT) \
|
||||||
audacity-Envelope.$(OBJEXT) audacity-FFmpeg.$(OBJEXT) \
|
audacity-Envelope.$(OBJEXT) audacity-FFmpeg.$(OBJEXT) \
|
||||||
@ -1008,6 +1019,8 @@ am__define_uniq_tagged_files = \
|
|||||||
done | $(am__uniquify_input)`
|
done | $(am__uniquify_input)`
|
||||||
ETAGS = etags
|
ETAGS = etags
|
||||||
CTAGS = ctags
|
CTAGS = ctags
|
||||||
|
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/audacity.desktop.in \
|
||||||
|
$(srcdir)/configtemplate.h $(top_srcdir)/autotools/depcomp
|
||||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||||
ACLOCAL = @ACLOCAL@
|
ACLOCAL = @ACLOCAL@
|
||||||
AMTAR = @AMTAR@
|
AMTAR = @AMTAR@
|
||||||
@ -1102,6 +1115,7 @@ LN_S = @LN_S@
|
|||||||
LTLIBICONV = @LTLIBICONV@
|
LTLIBICONV = @LTLIBICONV@
|
||||||
LTLIBINTL = @LTLIBINTL@
|
LTLIBINTL = @LTLIBINTL@
|
||||||
LTLIBOBJS = @LTLIBOBJS@
|
LTLIBOBJS = @LTLIBOBJS@
|
||||||
|
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
||||||
LV2_CFLAGS = @LV2_CFLAGS@
|
LV2_CFLAGS = @LV2_CFLAGS@
|
||||||
LV2_LIBS = @LV2_LIBS@
|
LV2_LIBS = @LV2_LIBS@
|
||||||
MAINT = @MAINT@
|
MAINT = @MAINT@
|
||||||
@ -1127,6 +1141,8 @@ PACKAGE_URL = @PACKAGE_URL@
|
|||||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||||
PKG_CONFIG = @PKG_CONFIG@
|
PKG_CONFIG = @PKG_CONFIG@
|
||||||
|
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
|
||||||
|
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
|
||||||
PORTAUDIO_CFLAGS = @PORTAUDIO_CFLAGS@
|
PORTAUDIO_CFLAGS = @PORTAUDIO_CFLAGS@
|
||||||
PORTAUDIO_LIBS = @PORTAUDIO_LIBS@
|
PORTAUDIO_LIBS = @PORTAUDIO_LIBS@
|
||||||
PORTMIDI_CFLAGS = @PORTMIDI_CFLAGS@
|
PORTMIDI_CFLAGS = @PORTMIDI_CFLAGS@
|
||||||
@ -1308,22 +1324,23 @@ audacity_SOURCES = $(libaudacity_la_SOURCES) AboutDialog.cpp \
|
|||||||
AutoRecovery.h BatchCommandDialog.cpp BatchCommandDialog.h \
|
AutoRecovery.h BatchCommandDialog.cpp BatchCommandDialog.h \
|
||||||
BatchCommands.cpp BatchCommands.h BatchProcessDialog.cpp \
|
BatchCommands.cpp BatchCommands.h BatchProcessDialog.cpp \
|
||||||
BatchProcessDialog.h Benchmark.cpp Benchmark.h \
|
BatchProcessDialog.h Benchmark.cpp Benchmark.h \
|
||||||
Dependencies.cpp Dependencies.h DeviceChange.cpp \
|
CellularPanel.cpp CellularPanel.h Dependencies.cpp \
|
||||||
DeviceChange.h DeviceManager.cpp DeviceManager.h Diags.cpp \
|
Dependencies.h DeviceChange.cpp DeviceChange.h \
|
||||||
Diags.h Envelope.cpp Envelope.h Experimental.h FFmpeg.cpp \
|
DeviceManager.cpp DeviceManager.h Diags.cpp Diags.h \
|
||||||
FFmpeg.h FFT.cpp FFT.h FileException.cpp FileException.h \
|
Envelope.cpp Envelope.h Experimental.h FFmpeg.cpp FFmpeg.h \
|
||||||
FileIO.cpp FileIO.h FileNames.cpp FileNames.h float_cast.h \
|
FFT.cpp FFT.h FileException.cpp FileException.h FileIO.cpp \
|
||||||
FreqWindow.cpp FreqWindow.h HelpText.cpp HelpText.h \
|
FileIO.h FileNames.cpp FileNames.h float_cast.h FreqWindow.cpp \
|
||||||
HistoryWindow.cpp HistoryWindow.h HitTestResult.h \
|
FreqWindow.h HelpText.cpp HelpText.h HistoryWindow.cpp \
|
||||||
ImageManipulation.cpp ImageManipulation.h \
|
HistoryWindow.h HitTestResult.h ImageManipulation.cpp \
|
||||||
InconsistencyException.cpp InconsistencyException.h \
|
ImageManipulation.h InconsistencyException.cpp \
|
||||||
InterpolateAudio.cpp InterpolateAudio.h LabelDialog.cpp \
|
InconsistencyException.h InterpolateAudio.cpp \
|
||||||
LabelDialog.h LabelTrack.cpp LabelTrack.h LangChoice.cpp \
|
InterpolateAudio.h LabelDialog.cpp LabelDialog.h \
|
||||||
LangChoice.h Languages.cpp Languages.h Legacy.cpp Legacy.h \
|
LabelTrack.cpp LabelTrack.h LangChoice.cpp LangChoice.h \
|
||||||
Lyrics.cpp Lyrics.h LyricsWindow.cpp LyricsWindow.h \
|
Languages.cpp Languages.h Legacy.cpp Legacy.h Lyrics.cpp \
|
||||||
MacroMagic.h Matrix.cpp Matrix.h MemoryX.h Menus.cpp Menus.h \
|
Lyrics.h LyricsWindow.cpp LyricsWindow.h MacroMagic.h \
|
||||||
Mix.cpp Mix.h MixerBoard.cpp MixerBoard.h ModuleManager.cpp \
|
Matrix.cpp Matrix.h MemoryX.h Menus.cpp Menus.h Mix.cpp Mix.h \
|
||||||
ModuleManager.h NumberScale.h PitchName.cpp PitchName.h \
|
MixerBoard.cpp MixerBoard.h ModuleManager.cpp ModuleManager.h \
|
||||||
|
NumberScale.h PitchName.cpp PitchName.h \
|
||||||
PlatformCompatibility.cpp PlatformCompatibility.h \
|
PlatformCompatibility.cpp PlatformCompatibility.h \
|
||||||
PluginManager.cpp PluginManager.h Printing.cpp Printing.h \
|
PluginManager.cpp PluginManager.h Printing.cpp Printing.h \
|
||||||
Profiler.cpp Profiler.h Project.cpp Project.h RealFFTf.cpp \
|
Profiler.cpp Profiler.h Project.cpp Project.h RealFFTf.cpp \
|
||||||
@ -1602,7 +1619,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
|
|||||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
|
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
|
||||||
$(am__cd) $(top_srcdir) && \
|
$(am__cd) $(top_srcdir) && \
|
||||||
$(AUTOMAKE) --foreign src/Makefile
|
$(AUTOMAKE) --foreign src/Makefile
|
||||||
.PRECIOUS: Makefile
|
|
||||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||||
@case '$?' in \
|
@case '$?' in \
|
||||||
*config.status*) \
|
*config.status*) \
|
||||||
@ -2408,6 +2424,7 @@ distclean-compile:
|
|||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-BatchProcessDialog.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-BatchProcessDialog.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-Benchmark.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-Benchmark.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-BlockFile.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-BlockFile.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-CellularPanel.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-Dependencies.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-Dependencies.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-DeviceChange.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-DeviceChange.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-DeviceManager.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-DeviceManager.Po@am__quote@
|
||||||
@ -3273,6 +3290,20 @@ audacity-Benchmark.obj: Benchmark.cpp
|
|||||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o audacity-Benchmark.obj `if test -f 'Benchmark.cpp'; then $(CYGPATH_W) 'Benchmark.cpp'; else $(CYGPATH_W) '$(srcdir)/Benchmark.cpp'; fi`
|
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o audacity-Benchmark.obj `if test -f 'Benchmark.cpp'; then $(CYGPATH_W) 'Benchmark.cpp'; else $(CYGPATH_W) '$(srcdir)/Benchmark.cpp'; fi`
|
||||||
|
|
||||||
|
audacity-CellularPanel.o: CellularPanel.cpp
|
||||||
|
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT audacity-CellularPanel.o -MD -MP -MF $(DEPDIR)/audacity-CellularPanel.Tpo -c -o audacity-CellularPanel.o `test -f 'CellularPanel.cpp' || echo '$(srcdir)/'`CellularPanel.cpp
|
||||||
|
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/audacity-CellularPanel.Tpo $(DEPDIR)/audacity-CellularPanel.Po
|
||||||
|
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='CellularPanel.cpp' object='audacity-CellularPanel.o' libtool=no @AMDEPBACKSLASH@
|
||||||
|
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
|
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o audacity-CellularPanel.o `test -f 'CellularPanel.cpp' || echo '$(srcdir)/'`CellularPanel.cpp
|
||||||
|
|
||||||
|
audacity-CellularPanel.obj: CellularPanel.cpp
|
||||||
|
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT audacity-CellularPanel.obj -MD -MP -MF $(DEPDIR)/audacity-CellularPanel.Tpo -c -o audacity-CellularPanel.obj `if test -f 'CellularPanel.cpp'; then $(CYGPATH_W) 'CellularPanel.cpp'; else $(CYGPATH_W) '$(srcdir)/CellularPanel.cpp'; fi`
|
||||||
|
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/audacity-CellularPanel.Tpo $(DEPDIR)/audacity-CellularPanel.Po
|
||||||
|
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='CellularPanel.cpp' object='audacity-CellularPanel.obj' libtool=no @AMDEPBACKSLASH@
|
||||||
|
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
|
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o audacity-CellularPanel.obj `if test -f 'CellularPanel.cpp'; then $(CYGPATH_W) 'CellularPanel.cpp'; else $(CYGPATH_W) '$(srcdir)/CellularPanel.cpp'; fi`
|
||||||
|
|
||||||
audacity-Dependencies.o: Dependencies.cpp
|
audacity-Dependencies.o: Dependencies.cpp
|
||||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT audacity-Dependencies.o -MD -MP -MF $(DEPDIR)/audacity-Dependencies.Tpo -c -o audacity-Dependencies.o `test -f 'Dependencies.cpp' || echo '$(srcdir)/'`Dependencies.cpp
|
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT audacity-Dependencies.o -MD -MP -MF $(DEPDIR)/audacity-Dependencies.Tpo -c -o audacity-Dependencies.o `test -f 'Dependencies.cpp' || echo '$(srcdir)/'`Dependencies.cpp
|
||||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/audacity-Dependencies.Tpo $(DEPDIR)/audacity-Dependencies.Po
|
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/audacity-Dependencies.Tpo $(DEPDIR)/audacity-Dependencies.Po
|
||||||
@ -7722,6 +7753,8 @@ uninstall-am: uninstall-binPROGRAMS uninstall-desktopDATA \
|
|||||||
tags tags-am uninstall uninstall-am uninstall-binPROGRAMS \
|
tags tags-am uninstall uninstall-am uninstall-binPROGRAMS \
|
||||||
uninstall-desktopDATA uninstall-dist_mimeDATA
|
uninstall-desktopDATA uninstall-dist_mimeDATA
|
||||||
|
|
||||||
|
.PRECIOUS: Makefile
|
||||||
|
|
||||||
|
|
||||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||||
|
@ -6258,3 +6258,8 @@ void AudacityProject::PlaybackScroller::OnTimer(wxCommandEvent &event)
|
|||||||
trackPanel->Refresh(false);
|
trackPanel->Refresh(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AudacityProject::IsFocused( const wxWindow *window ) const
|
||||||
|
{
|
||||||
|
return window == mFocusLender || window == wxWindow::FindFocus();
|
||||||
|
}
|
||||||
|
@ -834,6 +834,12 @@ public:
|
|||||||
std::shared_ptr<BackgroundCell> GetBackgroundCell() const
|
std::shared_ptr<BackgroundCell> GetBackgroundCell() const
|
||||||
{ return mBackgroundCell; }
|
{ return mBackgroundCell; }
|
||||||
|
|
||||||
|
wxWindowRef mFocusLender;
|
||||||
|
|
||||||
|
// Return true if the window is really focused, or if focus was borrowed
|
||||||
|
// from it
|
||||||
|
bool IsFocused( const wxWindow *window ) const;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -165,6 +165,10 @@ class AUDACITY_DLL_API Track /* not final */
|
|||||||
(const TrackPanelMouseState &, const AudacityProject *pProject)
|
(const TrackPanelMouseState &, const AudacityProject *pProject)
|
||||||
final override;
|
final override;
|
||||||
|
|
||||||
|
// Delegates the handling to the related TCP cell
|
||||||
|
std::shared_ptr<TrackPanelCell> ContextMenuDelegate() override
|
||||||
|
{ return GetTrackControl(); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Rather override this for subclasses:
|
// Rather override this for subclasses:
|
||||||
|
@ -169,8 +169,6 @@ is time to refresh some aspect of the screen.
|
|||||||
#include "RefreshCode.h"
|
#include "RefreshCode.h"
|
||||||
#include "TrackArtist.h"
|
#include "TrackArtist.h"
|
||||||
#include "TrackPanelAx.h"
|
#include "TrackPanelAx.h"
|
||||||
#include "UIHandle.h"
|
|
||||||
#include "HitTestResult.h"
|
|
||||||
#include "WaveTrack.h"
|
#include "WaveTrack.h"
|
||||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||||
#include "NoteTrack.h"
|
#include "NoteTrack.h"
|
||||||
@ -254,17 +252,11 @@ template < class A, class B, class DIST > bool within(A a, B b, DIST d)
|
|||||||
return (a > b - d) && (a < b + d);
|
return (a > b - d) && (a < b + d);
|
||||||
}
|
}
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(TrackPanel, OverlayPanel)
|
BEGIN_EVENT_TABLE(TrackPanel, CellularPanel)
|
||||||
EVT_MOUSE_EVENTS(TrackPanel::OnMouseEvent)
|
EVT_MOUSE_EVENTS(TrackPanel::OnMouseEvent)
|
||||||
EVT_MOUSE_CAPTURE_LOST(TrackPanel::OnCaptureLost)
|
|
||||||
EVT_COMMAND(wxID_ANY, EVT_CAPTURE_KEY, TrackPanel::OnCaptureKey)
|
|
||||||
EVT_KEY_DOWN(TrackPanel::OnKeyDown)
|
EVT_KEY_DOWN(TrackPanel::OnKeyDown)
|
||||||
EVT_KEY_UP(TrackPanel::OnKeyUp)
|
|
||||||
EVT_CHAR(TrackPanel::OnChar)
|
|
||||||
EVT_PAINT(TrackPanel::OnPaint)
|
EVT_PAINT(TrackPanel::OnPaint)
|
||||||
EVT_SET_FOCUS(TrackPanel::OnSetFocus)
|
|
||||||
EVT_KILL_FOCUS(TrackPanel::OnKillFocus)
|
|
||||||
EVT_CONTEXT_MENU(TrackPanel::OnContextMenu)
|
|
||||||
|
|
||||||
EVT_TIMER(wxID_ANY, TrackPanel::OnTimer)
|
EVT_TIMER(wxID_ANY, TrackPanel::OnTimer)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
@ -301,11 +293,11 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
|
|||||||
ViewInfo * viewInfo,
|
ViewInfo * viewInfo,
|
||||||
TrackPanelListener * listener,
|
TrackPanelListener * listener,
|
||||||
AdornedRulerPanel * ruler)
|
AdornedRulerPanel * ruler)
|
||||||
: OverlayPanel(parent, id, pos, size, wxWANTS_CHARS | wxNO_BORDER),
|
: CellularPanel(parent, id, pos, size, viewInfo,
|
||||||
|
wxWANTS_CHARS | wxNO_BORDER),
|
||||||
mTrackInfo(this),
|
mTrackInfo(this),
|
||||||
mListener(listener),
|
mListener(listener),
|
||||||
mTracks(tracks),
|
mTracks(tracks),
|
||||||
mViewInfo(viewInfo),
|
|
||||||
mRuler(ruler),
|
mRuler(ruler),
|
||||||
mTrackArtist(nullptr),
|
mTrackArtist(nullptr),
|
||||||
mRefreshBacking(false),
|
mRefreshBacking(false),
|
||||||
@ -614,27 +606,28 @@ void TrackPanel::MakeParentRedrawScrollbars()
|
|||||||
mListener->TP_RedrawScrollbars();
|
mListener->TP_RedrawScrollbars();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackPanel::HandleInterruptedDrag()
|
namespace {
|
||||||
|
std::shared_ptr<Track> FindTrack(TrackPanelCell *pCell )
|
||||||
{
|
{
|
||||||
if (mUIHandle && mUIHandle->StopsOnKeystroke() ) {
|
if (pCell)
|
||||||
// The bogus id isn't used anywhere, but may help with debugging.
|
return static_cast<CommonTrackPanelCell*>( pCell )->FindTrack();
|
||||||
// as this is sending a bogus mouse up. The mouse button is still actually down
|
return {};
|
||||||
// and may go up again.
|
|
||||||
const int idBogusUp = 2;
|
|
||||||
wxMouseEvent evt { wxEVT_LEFT_UP };
|
|
||||||
evt.SetId( idBogusUp );
|
|
||||||
evt.SetPosition(this->ScreenToClient(::wxGetMousePosition()));
|
|
||||||
this->ProcessEvent(evt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
void TrackPanel::ProcessUIHandleResult
|
||||||
{
|
(TrackPanelCell *pClickedCell, TrackPanelCell *pLatestCell,
|
||||||
void ProcessUIHandleResult
|
|
||||||
(TrackPanel *panel, AdornedRulerPanel *ruler,
|
|
||||||
Track *pClickedTrack, Track *pLatestTrack,
|
|
||||||
UIHandle::Result refreshResult)
|
UIHandle::Result refreshResult)
|
||||||
{
|
{
|
||||||
|
const auto panel = this;
|
||||||
|
auto pLatestTrack = FindTrack( pLatestCell ).get();
|
||||||
|
|
||||||
|
// This precaution checks that the track is not only nonnull, but also
|
||||||
|
// really owned by the track list
|
||||||
|
auto pClickedTrack = GetTracks()->Lock(
|
||||||
|
std::weak_ptr<Track>{ FindTrack( pClickedCell ) }
|
||||||
|
).get();
|
||||||
|
|
||||||
// TODO: make a finer distinction between refreshing the track control area,
|
// TODO: make a finer distinction between refreshing the track control area,
|
||||||
// and the waveform area. As it is, redraw both whenever you must redraw either.
|
// and the waveform area. As it is, redraw both whenever you must redraw either.
|
||||||
|
|
||||||
@ -652,12 +645,12 @@ namespace
|
|||||||
pClickedTrack = NULL;
|
pClickedTrack = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pClickedTrack && (refreshResult & UpdateVRuler))
|
if (pClickedTrack && (refreshResult & RefreshCode::UpdateVRuler))
|
||||||
panel->UpdateVRuler(pClickedTrack);
|
panel->UpdateVRuler(pClickedTrack);
|
||||||
|
|
||||||
if (refreshResult & DrawOverlays) {
|
if (refreshResult & RefreshCode::DrawOverlays) {
|
||||||
panel->DrawOverlays(false);
|
panel->DrawOverlays(false);
|
||||||
ruler->DrawOverlays(false);
|
mRuler->DrawOverlays(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh all if told to do so, or if told to refresh a track that
|
// Refresh all if told to do so, or if told to refresh a track that
|
||||||
@ -699,95 +692,9 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((refreshResult & EnsureVisible) && pClickedTrack)
|
if ((refreshResult & RefreshCode::EnsureVisible) && pClickedTrack)
|
||||||
panel->EnsureVisible(pClickedTrack);
|
panel->EnsureVisible(pClickedTrack);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void TrackPanel::Uncapture(wxMouseState *pState)
|
|
||||||
{
|
|
||||||
auto state = ::wxGetMouseState();
|
|
||||||
if (!pState) {
|
|
||||||
// Remap the position
|
|
||||||
state.SetPosition(this->ScreenToClient(state.GetPosition()));
|
|
||||||
pState = &state;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HasCapture())
|
|
||||||
ReleaseMouse();
|
|
||||||
HandleMotion( *pState );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TrackPanel::CancelDragging()
|
|
||||||
{
|
|
||||||
if (mUIHandle) {
|
|
||||||
// copy shared_ptr for safety, as in HandleClick
|
|
||||||
auto handle = mUIHandle;
|
|
||||||
// UIHANDLE CANCEL
|
|
||||||
UIHandle::Result refreshResult = handle->Cancel(GetProject());
|
|
||||||
auto pTrack = GetTracks()->Lock(mpClickedTrack);
|
|
||||||
if (pTrack)
|
|
||||||
ProcessUIHandleResult(
|
|
||||||
this, mRuler, pTrack.get(), NULL,
|
|
||||||
refreshResult | mMouseOverUpdateFlags );
|
|
||||||
mpClickedTrack.reset();
|
|
||||||
mUIHandle.reset(), handle.reset(), ClearTargets();
|
|
||||||
Uncapture();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TrackPanel::HandleEscapeKey(bool down)
|
|
||||||
{
|
|
||||||
if (!down)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
{
|
|
||||||
auto target = Target();
|
|
||||||
if (target && target->HasEscape() && target->Escape()) {
|
|
||||||
HandleCursorForPresentMouseState(false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mUIHandle) {
|
|
||||||
CancelDragging();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ChangeTarget(true, false)) {
|
|
||||||
HandleCursorForPresentMouseState(false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackPanel::UpdateMouseState(const wxMouseState &state)
|
|
||||||
{
|
|
||||||
mLastMouseState = state;
|
|
||||||
|
|
||||||
// Simulate a down button if none, so hit test routines can anticipate
|
|
||||||
// which button will be clicked
|
|
||||||
if (!state.ButtonIsDown(wxMOUSE_BTN_ANY)) {
|
|
||||||
#ifdef __WXOSX__
|
|
||||||
if (state.RawControlDown())
|
|
||||||
// On Mac we can distinctly anticipate "right" click (as Control+click)
|
|
||||||
mLastMouseState.SetRightDown( true ),
|
|
||||||
mLastMouseState.SetLeftDown( false );
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
// Anticipate a left click by default
|
|
||||||
mLastMouseState.SetRightDown( false ),
|
|
||||||
mLastMouseState.SetLeftDown( true );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackPanel::HandleModifierKey()
|
|
||||||
{
|
|
||||||
HandleCursorForPresentMouseState();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackPanel::HandlePageUpKey()
|
void TrackPanel::HandlePageUpKey()
|
||||||
{
|
{
|
||||||
@ -799,214 +706,19 @@ void TrackPanel::HandlePageDownKey()
|
|||||||
mListener->TP_ScrollWindow(GetScreenEndTime());
|
mListener->TP_ScrollWindow(GetScreenEndTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackPanel::HandleCursorForPresentMouseState(bool doHit)
|
|
||||||
{
|
|
||||||
// Come here on modifier key or mouse button transitions,
|
|
||||||
// or on starting or stopping of play or record,
|
|
||||||
// or change of toolbar button,
|
|
||||||
// and change the cursor appropriately.
|
|
||||||
|
|
||||||
// Get the button and key states
|
|
||||||
auto state = ::wxGetMouseState();
|
|
||||||
// Remap the position
|
|
||||||
state.SetPosition(this->ScreenToClient(state.GetPosition()));
|
|
||||||
|
|
||||||
HandleMotion( state, doHit );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TrackPanel::IsAudioActive()
|
bool TrackPanel::IsAudioActive()
|
||||||
{
|
{
|
||||||
AudacityProject *p = GetProject();
|
AudacityProject *p = GetProject();
|
||||||
return p->IsAudioActive();
|
return p->IsAudioActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrackPanel::UpdateStatusMessage( const wxString &st )
|
||||||
/// TrackPanel::HandleMotion( ) sets the cursor drawn at the mouse location,
|
|
||||||
/// and updates the status bar message.
|
|
||||||
/// We treat certain other changes of mouse button and key state as "motions"
|
|
||||||
/// too, and also starting and stopping of playback or recording, all of which
|
|
||||||
/// may cause the appropriate cursor and message to change.
|
|
||||||
/// As this procedure checks which region the mouse is over, it is
|
|
||||||
/// appropriate to establish the message in the status bar.
|
|
||||||
void TrackPanel::HandleMotion( wxMouseState &inState, bool doHit )
|
|
||||||
{
|
{
|
||||||
UpdateMouseState( inState );
|
auto status = st;
|
||||||
|
|
||||||
const auto foundCell = FindCell( inState.m_x, inState.m_y );
|
|
||||||
auto &rect = foundCell.rect;
|
|
||||||
auto &pCell = foundCell.pCell;
|
|
||||||
const TrackPanelMouseState tpmState{ mLastMouseState, rect, pCell };
|
|
||||||
HandleMotion( tpmState, doHit );
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackPanel::HandleMotion
|
|
||||||
( const TrackPanelMouseState &tpmState, bool doHit )
|
|
||||||
{
|
|
||||||
auto handle = mUIHandle;
|
|
||||||
|
|
||||||
auto newCell = tpmState.pCell;
|
|
||||||
|
|
||||||
std::shared_ptr<Track> newTrack;
|
|
||||||
if ( newCell )
|
|
||||||
newTrack = static_cast<CommonTrackPanelCell*>( newCell.get() )->
|
|
||||||
FindTrack();
|
|
||||||
|
|
||||||
wxString status{}, tooltip{};
|
|
||||||
wxCursor *pCursor{};
|
|
||||||
unsigned refreshCode = 0;
|
|
||||||
|
|
||||||
if ( ! doHit ) {
|
|
||||||
// Dragging or not
|
|
||||||
handle = Target();
|
|
||||||
|
|
||||||
// Assume cell does not change but target does
|
|
||||||
refreshCode = mMouseOverUpdateFlags;
|
|
||||||
mMouseOverUpdateFlags = 0;
|
|
||||||
}
|
|
||||||
else if ( !mUIHandle ) {
|
|
||||||
// Not yet dragging.
|
|
||||||
|
|
||||||
auto oldCell = mLastCell.lock();
|
|
||||||
std::shared_ptr<Track> oldTrack;
|
|
||||||
if ( oldCell )
|
|
||||||
oldTrack = static_cast<CommonTrackPanelCell*>( oldCell.get() )->
|
|
||||||
FindTrack();
|
|
||||||
|
|
||||||
unsigned updateFlags = mMouseOverUpdateFlags;
|
|
||||||
|
|
||||||
// First check whether crossing cell to cell
|
|
||||||
if ( newCell == oldCell )
|
|
||||||
oldCell.reset();
|
|
||||||
else {
|
|
||||||
// Forget old targets
|
|
||||||
ClearTargets();
|
|
||||||
// Re-draw any highlighting
|
|
||||||
if (oldCell) {
|
|
||||||
ProcessUIHandleResult(
|
|
||||||
this, GetRuler(), oldTrack.get(), oldTrack.get(), updateFlags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto oldHandle = Target();
|
|
||||||
auto oldPosition = mTarget;
|
|
||||||
|
|
||||||
// Now do the
|
|
||||||
// UIHANDLE HIT TEST !
|
|
||||||
mTargets = newCell->HitTest(tpmState, GetProject());
|
|
||||||
|
|
||||||
mTarget = 0;
|
|
||||||
|
|
||||||
// Find the old target's NEW place if we can
|
|
||||||
if (oldHandle) {
|
|
||||||
auto begin = mTargets.begin(), end = mTargets.end(),
|
|
||||||
iter = std::find(begin, end, oldHandle);
|
|
||||||
if (iter != end) {
|
|
||||||
size_t newPosition = iter - begin;
|
|
||||||
if (newPosition <= oldPosition)
|
|
||||||
mTarget = newPosition;
|
|
||||||
// else, some NEW hit and this position takes priority
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handle = Target();
|
|
||||||
|
|
||||||
mLastCell = newCell;
|
|
||||||
|
|
||||||
if (!oldCell && oldHandle != handle)
|
|
||||||
// Did not move cell to cell, but did change the target
|
|
||||||
refreshCode = updateFlags;
|
|
||||||
|
|
||||||
if (handle && handle != oldHandle)
|
|
||||||
handle->Enter(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// UIHANDLE PREVIEW
|
|
||||||
// Update status message and cursor, whether dragging or not
|
|
||||||
if (handle) {
|
|
||||||
auto preview = handle->Preview( tpmState, GetProject() );
|
|
||||||
status = preview.message;
|
|
||||||
tooltip = preview.tooltip;
|
|
||||||
pCursor = preview.cursor;
|
|
||||||
auto code = handle->GetChangeHighlight();
|
|
||||||
handle->SetChangeHighlight(RefreshCode::RefreshNone);
|
|
||||||
refreshCode |= code;
|
|
||||||
mMouseOverUpdateFlags |= code;
|
|
||||||
}
|
|
||||||
if (!pCursor) {
|
|
||||||
static wxCursor defaultCursor{ wxCURSOR_ARROW };
|
|
||||||
pCursor = &defaultCursor;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HasEscape())
|
if (HasEscape())
|
||||||
/* i18n-hint Esc is a key on the keyboard */
|
/* i18n-hint Esc is a key on the keyboard */
|
||||||
status += wxT(" "), status += _("(Esc to cancel)");
|
status += wxT(" "), status += _("(Esc to cancel)");
|
||||||
mListener->TP_DisplayStatusMessage(status);
|
mListener->TP_DisplayStatusMessage(status);
|
||||||
if (tooltip != GetToolTipText()) {
|
|
||||||
// Unset first, by analogy with AButton
|
|
||||||
UnsetToolTip();
|
|
||||||
SetToolTip(tooltip);
|
|
||||||
}
|
|
||||||
if (pCursor)
|
|
||||||
SetCursor( *pCursor );
|
|
||||||
|
|
||||||
ProcessUIHandleResult(
|
|
||||||
this, GetRuler(), newTrack.get(), newTrack.get(), refreshCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TrackPanel::HasRotation()
|
|
||||||
{
|
|
||||||
// Is there a nontrivial TAB key rotation?
|
|
||||||
if ( mTargets.size() > 1 )
|
|
||||||
return true;
|
|
||||||
auto target = Target();
|
|
||||||
return target && target->HasRotation();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TrackPanel::HasEscape()
|
|
||||||
{
|
|
||||||
if (IsMouseCaptured())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (mTarget + 1 == mTargets.size() &&
|
|
||||||
Target() &&
|
|
||||||
!Target()->HasEscape())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return mTargets.size() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TrackPanel::ChangeTarget(bool forward, bool cycle)
|
|
||||||
{
|
|
||||||
auto size = mTargets.size();
|
|
||||||
|
|
||||||
auto target = Target();
|
|
||||||
if (target && target->HasRotation()) {
|
|
||||||
if(target->Rotate(forward))
|
|
||||||
return true;
|
|
||||||
else if (cycle && (size == 1 || IsMouseCaptured())) {
|
|
||||||
// Rotate through the states of this target only.
|
|
||||||
target->Enter(forward);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cycle &&
|
|
||||||
((forward && mTarget + 1 == size) ||
|
|
||||||
(!forward && mTarget == 0)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (size > 1) {
|
|
||||||
if (forward)
|
|
||||||
++mTarget;
|
|
||||||
else
|
|
||||||
mTarget += size - 1;
|
|
||||||
mTarget %= size;
|
|
||||||
if (Target())
|
|
||||||
Target()->Enter(forward);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackPanel::UpdateSelectionDisplay()
|
void TrackPanel::UpdateSelectionDisplay()
|
||||||
@ -1067,12 +779,6 @@ void TrackPanel::MessageForScreenReader(const wxString& message)
|
|||||||
mAx->MessageForScreenReader(message);
|
mAx->MessageForScreenReader(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determines if a modal tool is active
|
|
||||||
bool TrackPanel::IsMouseCaptured()
|
|
||||||
{
|
|
||||||
return mUIHandle != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackPanel::UpdateViewIfNoTracks()
|
void TrackPanel::UpdateViewIfNoTracks()
|
||||||
{
|
{
|
||||||
if (mTracks->empty())
|
if (mTracks->empty())
|
||||||
@ -1118,9 +824,9 @@ void TrackPanel::OnTrackListResizing(wxCommandEvent & e)
|
|||||||
// Tracks have been removed from the list.
|
// Tracks have been removed from the list.
|
||||||
void TrackPanel::OnTrackListDeletion(wxCommandEvent & e)
|
void TrackPanel::OnTrackListDeletion(wxCommandEvent & e)
|
||||||
{
|
{
|
||||||
if (mUIHandle) {
|
|
||||||
// copy shared_ptr for safety, as in HandleClick
|
// copy shared_ptr for safety, as in HandleClick
|
||||||
auto handle = mUIHandle;
|
auto handle = Target();
|
||||||
|
if (handle) {
|
||||||
handle->OnProjectChange(GetProject());
|
handle->OnProjectChange(GetProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1133,11 +839,6 @@ void TrackPanel::OnTrackListDeletion(wxCommandEvent & e)
|
|||||||
e.Skip();
|
e.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackPanel::OnContextMenu(wxContextMenuEvent & WXUNUSED(event))
|
|
||||||
{
|
|
||||||
OnTrackMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
struct TrackInfo::TCPLine {
|
struct TrackInfo::TCPLine {
|
||||||
using DrawFunction = void (*)(
|
using DrawFunction = void (*)(
|
||||||
TrackPanelDrawingContext &context,
|
TrackPanelDrawingContext &context,
|
||||||
@ -1326,109 +1027,10 @@ bool TrackInfo::HideTopItem( const wxRect &rect, const wxRect &subRect,
|
|||||||
return subRect.y + subRect.height - allowance >= rect.y + limit;
|
return subRect.y + subRect.height - allowance >= rect.y + limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle mouse wheel rotation (for zoom in/out, vertical and horizontal scrolling)
|
|
||||||
void TrackPanel::HandleWheelRotation( TrackPanelMouseEvent &tpmEvent )
|
|
||||||
{
|
|
||||||
auto pCell = tpmEvent.pCell;
|
|
||||||
if (!pCell)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto &event = tpmEvent.event;
|
|
||||||
double steps {};
|
|
||||||
#if defined(__WXMAC__) && defined(EVT_MAGNIFY)
|
|
||||||
// PRL:
|
|
||||||
// Pinch and spread implemented in wxWidgets 3.1.0, or cherry-picked from
|
|
||||||
// the future in custom build of 3.0.2
|
|
||||||
if (event.Magnify()) {
|
|
||||||
event.SetControlDown(true);
|
|
||||||
steps = 2 * event.GetMagnification();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
steps = event.m_wheelRotation /
|
|
||||||
(event.m_wheelDelta > 0 ? (double)event.m_wheelDelta : 120.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(event.GetWheelAxis() == wxMOUSE_WHEEL_HORIZONTAL) {
|
|
||||||
// Two-fingered horizontal swipe on mac is treated like shift-mousewheel
|
|
||||||
event.SetShiftDown(true);
|
|
||||||
// This makes the wave move in the same direction as the fingers, and the scrollbar
|
|
||||||
// thumb moves oppositely
|
|
||||||
steps *= -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
tpmEvent.steps = steps;
|
|
||||||
|
|
||||||
if(!event.HasAnyModifiers()) {
|
|
||||||
// We will later un-skip if we do anything, but if we don't,
|
|
||||||
// propagate the event up for the sake of the scrubber
|
|
||||||
event.Skip();
|
|
||||||
event.ResumePropagation(wxEVENT_PROPAGATE_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned result =
|
|
||||||
pCell->HandleWheelRotation( tpmEvent, GetProject() );
|
|
||||||
auto pTrack = static_cast<CommonTrackPanelCell*>(pCell.get())->FindTrack();
|
|
||||||
ProcessUIHandleResult(
|
|
||||||
this, mRuler, pTrack.get(), pTrack.get(), result);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackPanel::OnCaptureKey(wxCommandEvent & event)
|
|
||||||
{
|
|
||||||
mEnableTab = false;
|
|
||||||
wxKeyEvent *kevent = static_cast<wxKeyEvent *>(event.GetEventObject());
|
|
||||||
const auto code = kevent->GetKeyCode();
|
|
||||||
if ( WXK_ESCAPE != code )
|
|
||||||
HandleInterruptedDrag();
|
|
||||||
|
|
||||||
// TODO? Some notion of focused cell, more generally than focused tracks
|
|
||||||
|
|
||||||
// Give focused track precedence
|
|
||||||
Track * const t = GetFocusedTrack();
|
|
||||||
if (t) {
|
|
||||||
const unsigned refreshResult =
|
|
||||||
((TrackPanelCell*)t)->CaptureKey(*kevent, *mViewInfo, this);
|
|
||||||
ProcessUIHandleResult(this, mRuler, t, t, refreshResult);
|
|
||||||
event.Skip(kevent->GetSkipped());
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
// Special TAB key handling, but only if the track didn't capture it
|
|
||||||
if ( !(t && !kevent->GetSkipped()) &&
|
|
||||||
WXK_TAB == code && HasRotation() ) {
|
|
||||||
// Override TAB navigation in wxWidgets, by not skipping
|
|
||||||
event.Skip(false);
|
|
||||||
mEnableTab = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
if (!t)
|
|
||||||
event.Skip();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackPanel::OnKeyDown(wxKeyEvent & event)
|
void TrackPanel::OnKeyDown(wxKeyEvent & event)
|
||||||
{
|
{
|
||||||
switch (event.GetKeyCode())
|
switch (event.GetKeyCode())
|
||||||
{
|
{
|
||||||
case WXK_ESCAPE:
|
|
||||||
if(HandleEscapeKey(true))
|
|
||||||
// Don't skip the event, eat it so that
|
|
||||||
// AudacityApp does not also stop any playback.
|
|
||||||
return;
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WXK_ALT:
|
|
||||||
case WXK_SHIFT:
|
|
||||||
case WXK_CONTROL:
|
|
||||||
#ifdef __WXOSX__
|
|
||||||
case WXK_RAW_CONTROL:
|
|
||||||
#endif
|
|
||||||
HandleModifierKey();
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Allow PageUp and PageDown keys to
|
// Allow PageUp and PageDown keys to
|
||||||
//scroll the Track Panel left and right
|
//scroll the Track Panel left and right
|
||||||
case WXK_PAGEUP:
|
case WXK_PAGEUP:
|
||||||
@ -1439,152 +1041,15 @@ void TrackPanel::OnKeyDown(wxKeyEvent & event)
|
|||||||
HandlePageDownKey();
|
HandlePageDownKey();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if 0
|
default:
|
||||||
case WXK_TAB:
|
// fall through to base class handler
|
||||||
if ( mEnableTab && HasRotation() ) {
|
|
||||||
ChangeTarget( !event.ShiftDown(), true );
|
|
||||||
HandleCursorForPresentMouseState(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
Track *const t = GetFocusedTrack();
|
|
||||||
|
|
||||||
if (t) {
|
|
||||||
const unsigned refreshResult =
|
|
||||||
((TrackPanelCell*)t)->KeyDown(event, *mViewInfo, this);
|
|
||||||
ProcessUIHandleResult(this, mRuler, t, t, refreshResult);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackPanel::OnChar(wxKeyEvent & event)
|
|
||||||
{
|
|
||||||
switch (event.GetKeyCode())
|
|
||||||
{
|
|
||||||
case WXK_ESCAPE:
|
|
||||||
case WXK_ALT:
|
|
||||||
case WXK_SHIFT:
|
|
||||||
case WXK_CONTROL:
|
|
||||||
case WXK_PAGEUP:
|
|
||||||
case WXK_PAGEDOWN:
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Track *const t = GetFocusedTrack();
|
|
||||||
if (t) {
|
|
||||||
const unsigned refreshResult =
|
|
||||||
((TrackPanelCell*)t)->Char(event, *mViewInfo, this);
|
|
||||||
ProcessUIHandleResult(this, mRuler, t, t, refreshResult);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
event.Skip();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackPanel::OnKeyUp(wxKeyEvent & event)
|
|
||||||
{
|
|
||||||
bool didSomething = false;
|
|
||||||
switch (event.GetKeyCode())
|
|
||||||
{
|
|
||||||
case WXK_ESCAPE:
|
|
||||||
didSomething = HandleEscapeKey(false);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WXK_ALT:
|
|
||||||
case WXK_SHIFT:
|
|
||||||
case WXK_CONTROL:
|
|
||||||
#ifdef __WXOSX__
|
|
||||||
case WXK_RAW_CONTROL:
|
|
||||||
#endif
|
|
||||||
HandleModifierKey();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (didSomething)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Track * const t = GetFocusedTrack();
|
|
||||||
if (t) {
|
|
||||||
const unsigned refreshResult =
|
|
||||||
((TrackPanelCell*)t)->KeyUp(event, *mViewInfo, this);
|
|
||||||
ProcessUIHandleResult(this, mRuler, t, t, refreshResult);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
event.Skip();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Should handle the case when the mouse capture is lost.
|
|
||||||
void TrackPanel::OnCaptureLost(wxMouseCaptureLostEvent & WXUNUSED(event))
|
|
||||||
{
|
|
||||||
ClearTargets();
|
|
||||||
|
|
||||||
// This is bad. We are lying abou the event by saying it is a mouse up.
|
|
||||||
wxMouseEvent e(wxEVT_LEFT_UP);
|
|
||||||
e.SetId( kCaptureLostEventId );
|
|
||||||
|
|
||||||
e.m_x = mMouseMostRecentX;
|
|
||||||
e.m_y = mMouseMostRecentY;
|
|
||||||
|
|
||||||
OnMouseEvent(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// This handles just generic mouse events. Then, based
|
|
||||||
/// on our current state, we forward the mouse events to
|
|
||||||
/// various interested parties.
|
|
||||||
void TrackPanel::OnMouseEvent(wxMouseEvent & event)
|
void TrackPanel::OnMouseEvent(wxMouseEvent & event)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
const auto foundCell = FindCell( event.m_x, event.m_y );
|
|
||||||
auto &rect = foundCell.rect;
|
|
||||||
auto &pCell = foundCell.pCell;
|
|
||||||
auto &pTrack = foundCell.pTrack;
|
|
||||||
|
|
||||||
const auto size = GetSize();
|
|
||||||
TrackPanelMouseEvent tpmEvent{ event, rect, size, pCell };
|
|
||||||
|
|
||||||
#if defined(__WXMAC__) && defined(EVT_MAGNIFY)
|
|
||||||
// PRL:
|
|
||||||
// Pinch and spread implemented in wxWidgets 3.1.0, or cherry-picked from
|
|
||||||
// the future in custom build of 3.0.2
|
|
||||||
if (event.Magnify()) {
|
|
||||||
HandleWheelRotation( tpmEvent );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// If a mouse event originates from a keyboard context menu event then
|
|
||||||
// event.GetPosition() == wxDefaultPosition. wxContextMenu events are handled in
|
|
||||||
// TrackPanel::OnContextMenu(), and therefore associated mouse events are ignored here.
|
|
||||||
// Not ignoring them was causing bug 613: the mouse events were interpreted as clicking
|
|
||||||
// outside the tracks.
|
|
||||||
if (event.GetPosition() == wxDefaultPosition && (event.RightDown() || event.RightUp())) {
|
|
||||||
event.Skip();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.m_wheelRotation != 0)
|
|
||||||
HandleWheelRotation( tpmEvent );
|
|
||||||
|
|
||||||
if (event.LeftDown() || event.LeftIsDown() || event.Moving()) {
|
|
||||||
// Skip, even if we do something, so that the left click or drag
|
|
||||||
// may have an additional effect in the scrubber.
|
|
||||||
event.Skip();
|
|
||||||
event.ResumePropagation(wxEVENT_PROPAGATE_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
mMouseMostRecentX = event.m_x;
|
|
||||||
mMouseMostRecentY = event.m_y;
|
|
||||||
|
|
||||||
if (event.LeftDown()) {
|
if (event.LeftDown()) {
|
||||||
// The activate event is used to make the
|
|
||||||
// parent window 'come alive' if it didn't have focus.
|
|
||||||
wxActivateEvent e;
|
|
||||||
GetParent()->GetEventHandler()->ProcessEvent(e);
|
|
||||||
|
|
||||||
// wxTimers seem to be a little unreliable, so this
|
// wxTimers seem to be a little unreliable, so this
|
||||||
// "primes" it to make sure it keeps going for a while...
|
// "primes" it to make sure it keeps going for a while...
|
||||||
|
|
||||||
@ -1594,156 +1059,24 @@ try
|
|||||||
mTimer.Start(kTimerInterval, FALSE);
|
mTimer.Start(kTimerInterval, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.ButtonDown()) {
|
|
||||||
SetFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.Leaving())
|
|
||||||
{
|
|
||||||
if ( !mUIHandle )
|
|
||||||
ClearTargets();
|
|
||||||
|
|
||||||
auto buttons =
|
|
||||||
// Bug 1325: button state in Leaving events is unreliable on Mac.
|
|
||||||
// Poll the global state instead.
|
|
||||||
// event.ButtonIsDown(wxMOUSE_BTN_ANY);
|
|
||||||
::wxGetMouseState().ButtonIsDown(wxMOUSE_BTN_ANY);
|
|
||||||
|
|
||||||
if(!buttons) {
|
|
||||||
CancelDragging();
|
|
||||||
|
|
||||||
#if defined(__WXMAC__)
|
|
||||||
|
|
||||||
// We must install the cursor ourselves since the window under
|
|
||||||
// the mouse is no longer this one and wx2.8.12 makes that check.
|
|
||||||
// Should re-evaluate with wx3.
|
|
||||||
wxSTANDARD_CURSOR->MacInstall();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mUIHandle) {
|
|
||||||
auto pClickedTrack = GetTracks()->Lock(mpClickedTrack);
|
|
||||||
if (event.Dragging()) {
|
|
||||||
// UIHANDLE DRAG
|
|
||||||
// copy shared_ptr for safety, as in HandleClick
|
|
||||||
auto handle = mUIHandle;
|
|
||||||
const UIHandle::Result refreshResult =
|
|
||||||
handle->Drag( tpmEvent, GetProject() );
|
|
||||||
ProcessUIHandleResult
|
|
||||||
(this, mRuler, pClickedTrack.get(), pTrack.get(), refreshResult);
|
|
||||||
mMouseOverUpdateFlags |= refreshResult;
|
|
||||||
if (refreshResult & RefreshCode::Cancelled) {
|
|
||||||
// Drag decided to abort itself
|
|
||||||
mUIHandle.reset(), handle.reset(), ClearTargets();
|
|
||||||
mpClickedTrack.reset();
|
|
||||||
Uncapture( &event );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
UpdateMouseState(event);
|
|
||||||
TrackPanelMouseState tpmState{ mLastMouseState, rect, pCell };
|
|
||||||
HandleMotion( tpmState );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (event.ButtonUp()) {
|
|
||||||
// UIHANDLE RELEASE
|
|
||||||
unsigned moreFlags = mMouseOverUpdateFlags;
|
|
||||||
UIHandle::Result refreshResult =
|
|
||||||
mUIHandle->Release( tpmEvent, GetProject(), this );
|
|
||||||
ProcessUIHandleResult
|
|
||||||
(this, mRuler, pClickedTrack.get(), pTrack.get(),
|
|
||||||
refreshResult | moreFlags);
|
|
||||||
mUIHandle.reset(), ClearTargets();
|
|
||||||
mpClickedTrack.reset();
|
|
||||||
// will also Uncapture() below
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( event.GetEventType() == wxEVT_MOTION )
|
|
||||||
// Update status message and cursor, not during drag
|
|
||||||
// consider it not a drag, even if button is down during motion, if
|
|
||||||
// mUIHandle is null, as it becomes during interrupted drag
|
|
||||||
// (e.g. by hitting space to play while dragging an envelope point)
|
|
||||||
HandleMotion( event );
|
|
||||||
else if ( event.ButtonDown() || event.ButtonDClick() )
|
|
||||||
HandleClick( tpmEvent );
|
|
||||||
|
|
||||||
if (event.ButtonDown() && IsMouseCaptured()) {
|
|
||||||
if (!HasCapture())
|
|
||||||
CaptureMouse();
|
|
||||||
}
|
|
||||||
|
|
||||||
//EnsureVisible should be called after the up-click.
|
|
||||||
if (event.ButtonUp()) {
|
if (event.ButtonUp()) {
|
||||||
Uncapture();
|
//EnsureVisible should be called after processing the up-click.
|
||||||
|
this->CallAfter( [this, event]{
|
||||||
wxRect rect;
|
|
||||||
|
|
||||||
const auto foundCell = FindCell(event.m_x, event.m_y);
|
const auto foundCell = FindCell(event.m_x, event.m_y);
|
||||||
auto t = foundCell.pTrack;
|
const auto t = FindTrack( foundCell.pCell.get() );
|
||||||
if ( t )
|
if ( t )
|
||||||
EnsureVisible(t.get());
|
EnsureVisible(t.get());
|
||||||
}
|
} );
|
||||||
}
|
|
||||||
catch( ... )
|
|
||||||
{
|
|
||||||
// Abort any dragging, as if by hitting Esc
|
|
||||||
if ( CancelDragging() )
|
|
||||||
;
|
|
||||||
else {
|
|
||||||
Uncapture();
|
|
||||||
Refresh(false);
|
|
||||||
}
|
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackPanel::HandleClick( const TrackPanelMouseEvent &tpmEvent )
|
// Must also fall through to base class handler
|
||||||
{
|
event.Skip();
|
||||||
auto pCell = tpmEvent.pCell;
|
|
||||||
auto pTrack = static_cast<CommonTrackPanelCell *>( pCell.get() )->FindTrack();
|
|
||||||
|
|
||||||
// Do hit test once more, in case the button really pressed was not the
|
|
||||||
// one "anticipated."
|
|
||||||
{
|
|
||||||
TrackPanelMouseState tpmState{
|
|
||||||
tpmEvent.event,
|
|
||||||
tpmEvent.rect,
|
|
||||||
tpmEvent.pCell
|
|
||||||
};
|
|
||||||
HandleMotion( tpmState );
|
|
||||||
}
|
|
||||||
|
|
||||||
mUIHandle = Target();
|
|
||||||
|
|
||||||
if (mUIHandle) {
|
|
||||||
// UIHANDLE CLICK
|
|
||||||
// Make another shared pointer to the handle, in case recursive
|
|
||||||
// event dispatching otherwise tries to delete the handle.
|
|
||||||
auto handle = mUIHandle;
|
|
||||||
UIHandle::Result refreshResult =
|
|
||||||
handle->Click( tpmEvent, GetProject() );
|
|
||||||
if (refreshResult & RefreshCode::Cancelled)
|
|
||||||
mUIHandle.reset(), handle.reset(), ClearTargets();
|
|
||||||
else {
|
|
||||||
mpClickedTrack = pTrack;
|
|
||||||
|
|
||||||
// Perhaps the clicked handle wants to update cursor and state message
|
|
||||||
// after a click.
|
|
||||||
TrackPanelMouseState tpmState{
|
|
||||||
tpmEvent.event,
|
|
||||||
tpmEvent.rect,
|
|
||||||
tpmEvent.pCell
|
|
||||||
};
|
|
||||||
HandleMotion( tpmState );
|
|
||||||
}
|
|
||||||
ProcessUIHandleResult(
|
|
||||||
this, mRuler, pTrack.get(), pTrack.get(), refreshResult);
|
|
||||||
mMouseOverUpdateFlags |= refreshResult;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double TrackPanel::GetMostRecentXPos()
|
double TrackPanel::GetMostRecentXPos()
|
||||||
{
|
{
|
||||||
return mViewInfo->PositionToTime(mMouseMostRecentX, GetLabelWidth());
|
return mViewInfo->PositionToTime(MostRecentXCoord(), GetLabelWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackPanel::RefreshTrack(Track *trk, bool refreshbacking)
|
void TrackPanel::RefreshTrack(Track *trk, bool refreshbacking)
|
||||||
@ -1937,7 +1270,7 @@ void TrackPanel::DrawEverythingElse(TrackPanelDrawingContext &context,
|
|||||||
// if (GetFocusedTrack() != NULL) {
|
// if (GetFocusedTrack() != NULL) {
|
||||||
// the highlight was reportedly drawn even when something else
|
// the highlight was reportedly drawn even when something else
|
||||||
// was the focus and no highlight should be drawn. -RBD
|
// was the focus and no highlight should be drawn. -RBD
|
||||||
if (GetFocusedTrack() != NULL && wxWindow::FindFocus() == this) {
|
if (GetFocusedTrack() != NULL && GetProject()->IsFocused( this )) {
|
||||||
HighlightFocusedTrack(dc, focusRect);
|
HighlightFocusedTrack(dc, focusRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2576,17 +1909,7 @@ void TrackPanel::ScrollIntoView(int x)
|
|||||||
|
|
||||||
void TrackPanel::OnTrackMenu(Track *t)
|
void TrackPanel::OnTrackMenu(Track *t)
|
||||||
{
|
{
|
||||||
if(!t) {
|
CellularPanel::DoContextMenu( t );
|
||||||
t = GetFocusedTrack();
|
|
||||||
if(!t)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto pCell = t->GetTrackControl();
|
|
||||||
const wxRect rect(FindTrackRect(t, true));
|
|
||||||
const UIHandle::Result refreshResult =
|
|
||||||
pCell->DoContextMenu(rect, this, NULL);
|
|
||||||
ProcessUIHandleResult(this, mRuler, t, t, refreshResult);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Track * TrackPanel::GetFirstSelectedTrack()
|
Track * TrackPanel::GetFirstSelectedTrack()
|
||||||
@ -2760,7 +2083,7 @@ void TrackPanel::DrawShadow(Track * /* t */ , wxDC * dc, const wxRect & rect)
|
|||||||
/// Determines which cell is under the mouse
|
/// Determines which cell is under the mouse
|
||||||
/// @param mouseX - mouse X position.
|
/// @param mouseX - mouse X position.
|
||||||
/// @param mouseY - mouse Y position.
|
/// @param mouseY - mouse Y position.
|
||||||
TrackPanel::FoundCell TrackPanel::FindCell(int mouseX, int mouseY)
|
auto TrackPanel::FindCell(int mouseX, int mouseY) -> FoundCell
|
||||||
{
|
{
|
||||||
auto range = Cells();
|
auto range = Cells();
|
||||||
auto &iter = range.first, &end = range.second;
|
auto &iter = range.first, &end = range.second;
|
||||||
@ -2775,12 +2098,25 @@ TrackPanel::FoundCell TrackPanel::FindCell(int mouseX, int mouseY)
|
|||||||
iter = prev;
|
iter = prev;
|
||||||
auto found = *iter;
|
auto found = *iter;
|
||||||
return {
|
return {
|
||||||
static_cast<CommonTrackPanelCell*>( found.first.get() )->FindTrack(),
|
|
||||||
found.first,
|
found.first,
|
||||||
found.second
|
found.second
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxRect TrackPanel::FindRect( const TrackPanelCell &cell )
|
||||||
|
{
|
||||||
|
auto range = Cells();
|
||||||
|
auto end = range.second,
|
||||||
|
iter = std::find_if( range.first, end,
|
||||||
|
[&]( const decltype(*end) &pair )
|
||||||
|
{ return pair.first.get() == &cell; }
|
||||||
|
);
|
||||||
|
if (iter == end)
|
||||||
|
return {};
|
||||||
|
else
|
||||||
|
return (*iter).second;
|
||||||
|
}
|
||||||
|
|
||||||
// This finds the rectangle of a given track (including all channels),
|
// This finds the rectangle of a given track (including all channels),
|
||||||
// either that of the label 'adornment' or the track itself
|
// either that of the label 'adornment' or the track itself
|
||||||
// The given track is assumed to be the first channel
|
// The given track is assumed to be the first channel
|
||||||
@ -2843,42 +2179,33 @@ void TrackPanel::DisplaySelection()
|
|||||||
mListener->TP_DisplaySelection();
|
mListener->TP_DisplaySelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
Track *TrackPanel::GetFocusedTrack()
|
TrackPanelCell *TrackPanel::GetFocusedCell()
|
||||||
{
|
{
|
||||||
return mAx->GetFocus().get();
|
return mAx->GetFocus().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Track *TrackPanel::GetFocusedTrack()
|
||||||
|
{
|
||||||
|
return static_cast<Track*>( GetFocusedCell() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackPanel::SetFocusedCell()
|
||||||
|
{
|
||||||
|
SetFocusedTrack( GetFocusedTrack() );
|
||||||
|
}
|
||||||
|
|
||||||
void TrackPanel::SetFocusedTrack( Track *t )
|
void TrackPanel::SetFocusedTrack( Track *t )
|
||||||
{
|
{
|
||||||
// Make sure we always have the first linked track of a stereo track
|
// Make sure we always have the first linked track of a stereo track
|
||||||
if (t && !t->GetLinked() && t->GetLink())
|
if (t && !t->GetLinked() && t->GetLink())
|
||||||
t = (WaveTrack*)t->GetLink();
|
t = (WaveTrack*)t->GetLink();
|
||||||
|
|
||||||
if ( !mAx->SetFocus( Track::Pointer( t ) ) )
|
auto cell = mAx->SetFocus( Track::Pointer( t ) ).get();
|
||||||
return;
|
|
||||||
|
|
||||||
if (t && AudacityProject::GetKeyboardCaptureHandler())
|
if (cell) {
|
||||||
AudacityProject::ReleaseKeyboard(this);
|
|
||||||
|
|
||||||
if (t)
|
|
||||||
AudacityProject::CaptureKeyboard(this);
|
AudacityProject::CaptureKeyboard(this);
|
||||||
|
|
||||||
Refresh( false );
|
Refresh( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackPanel::OnSetFocus(wxFocusEvent & WXUNUSED(event))
|
|
||||||
{
|
|
||||||
SetFocusedTrack( GetFocusedTrack() );
|
|
||||||
Refresh( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackPanel::OnKillFocus(wxFocusEvent & WXUNUSED(event))
|
|
||||||
{
|
|
||||||
if (AudacityProject::HasKeyboardCapture(this))
|
|
||||||
{
|
|
||||||
AudacityProject::ReleaseKeyboard(this);
|
|
||||||
}
|
|
||||||
Refresh( false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
@ -3530,6 +2857,12 @@ TrackPanelCell::~TrackPanelCell()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HitTestPreview TrackPanelCell::DefaultPreview
|
||||||
|
(const TrackPanelMouseState &, const AudacityProject *)
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
unsigned TrackPanelCell::HandleWheelRotation
|
unsigned TrackPanelCell::HandleWheelRotation
|
||||||
(const TrackPanelMouseEvent &, AudacityProject *)
|
(const TrackPanelMouseEvent &, AudacityProject *)
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "SelectedRegion.h"
|
#include "SelectedRegion.h"
|
||||||
|
|
||||||
#include "widgets/OverlayPanel.h"
|
#include "CellularPanel.h"
|
||||||
|
|
||||||
#include "SelectionState.h"
|
#include "SelectionState.h"
|
||||||
|
|
||||||
@ -34,7 +34,6 @@ class SpectrumAnalyst;
|
|||||||
class Track;
|
class Track;
|
||||||
class TrackList;
|
class TrackList;
|
||||||
class TrackPanel;
|
class TrackPanel;
|
||||||
class TrackPanelCell;
|
|
||||||
class TrackArtist;
|
class TrackArtist;
|
||||||
class Ruler;
|
class Ruler;
|
||||||
class SnapManager;
|
class SnapManager;
|
||||||
@ -43,20 +42,13 @@ class LWSlider;
|
|||||||
class ControlToolBar; //Needed because state of controls can affect what gets drawn.
|
class ControlToolBar; //Needed because state of controls can affect what gets drawn.
|
||||||
class ToolsToolBar; //Needed because state of controls can affect what gets drawn.
|
class ToolsToolBar; //Needed because state of controls can affect what gets drawn.
|
||||||
class MixerBoard;
|
class MixerBoard;
|
||||||
class AudacityProject;
|
|
||||||
|
|
||||||
class TrackPanelAx;
|
class TrackPanelAx;
|
||||||
class TrackPanelCellIterator;
|
class TrackPanelCellIterator;
|
||||||
struct TrackPanelMouseEvent;
|
|
||||||
struct TrackPanelMouseState;
|
|
||||||
|
|
||||||
class ViewInfo;
|
|
||||||
|
|
||||||
class NoteTrack;
|
class NoteTrack;
|
||||||
class WaveTrack;
|
class WaveTrack;
|
||||||
class WaveClip;
|
class WaveClip;
|
||||||
class UIHandle;
|
|
||||||
using UIHandlePtr = std::shared_ptr<UIHandle>;
|
|
||||||
|
|
||||||
// Declared elsewhere, to reduce compilation dependencies
|
// Declared elsewhere, to reduce compilation dependencies
|
||||||
class TrackPanelListener;
|
class TrackPanelListener;
|
||||||
@ -242,9 +234,9 @@ private:
|
|||||||
const int DragThreshold = 3;// Anything over 3 pixels is a drag, else a click.
|
const int DragThreshold = 3;// Anything over 3 pixels is a drag, else a click.
|
||||||
|
|
||||||
|
|
||||||
class AUDACITY_DLL_API TrackPanel final : public OverlayPanel {
|
class AUDACITY_DLL_API TrackPanel final : public CellularPanel {
|
||||||
public:
|
|
||||||
|
|
||||||
|
public:
|
||||||
TrackPanel(wxWindow * parent,
|
TrackPanel(wxWindow * parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxPoint & pos,
|
const wxPoint & pos,
|
||||||
@ -263,16 +255,7 @@ class AUDACITY_DLL_API TrackPanel final : public OverlayPanel {
|
|||||||
|
|
||||||
void OnPaint(wxPaintEvent & event);
|
void OnPaint(wxPaintEvent & event);
|
||||||
void OnMouseEvent(wxMouseEvent & event);
|
void OnMouseEvent(wxMouseEvent & event);
|
||||||
void OnCaptureLost(wxMouseCaptureLostEvent & event);
|
|
||||||
void OnCaptureKey(wxCommandEvent & event);
|
|
||||||
void OnKeyDown(wxKeyEvent & event);
|
void OnKeyDown(wxKeyEvent & event);
|
||||||
void OnChar(wxKeyEvent & event);
|
|
||||||
void OnKeyUp(wxKeyEvent & event);
|
|
||||||
|
|
||||||
void OnSetFocus(wxFocusEvent & event);
|
|
||||||
void OnKillFocus(wxFocusEvent & event);
|
|
||||||
|
|
||||||
void OnContextMenu(wxContextMenuEvent & event);
|
|
||||||
|
|
||||||
void OnPlayback(wxCommandEvent &);
|
void OnPlayback(wxCommandEvent &);
|
||||||
void OnTrackListResizing(wxCommandEvent & event);
|
void OnTrackListResizing(wxCommandEvent & event);
|
||||||
@ -302,31 +285,24 @@ class AUDACITY_DLL_API TrackPanel final : public OverlayPanel {
|
|||||||
// void SetSelectionFormat(int iformat)
|
// void SetSelectionFormat(int iformat)
|
||||||
// void SetSnapTo(int snapto)
|
// void SetSnapTo(int snapto)
|
||||||
|
|
||||||
void HandleInterruptedDrag();
|
|
||||||
void Uncapture( wxMouseState *pState = nullptr );
|
|
||||||
bool CancelDragging();
|
|
||||||
bool HandleEscapeKey(bool down);
|
|
||||||
void UpdateMouseState(const wxMouseState &state);
|
|
||||||
void HandleModifierKey();
|
|
||||||
void HandlePageUpKey();
|
void HandlePageUpKey();
|
||||||
void HandlePageDownKey();
|
void HandlePageDownKey();
|
||||||
AudacityProject * GetProject() const;
|
AudacityProject * GetProject() const override;
|
||||||
|
|
||||||
void ScrollIntoView(double pos);
|
void ScrollIntoView(double pos);
|
||||||
void ScrollIntoView(int x);
|
void ScrollIntoView(int x);
|
||||||
|
|
||||||
void OnTrackMenu(Track *t = NULL);
|
void OnTrackMenu(Track *t = NULL);
|
||||||
Track * GetFirstSelectedTrack();
|
Track * GetFirstSelectedTrack();
|
||||||
bool IsMouseCaptured();
|
|
||||||
|
|
||||||
void EnsureVisible(Track * t);
|
void EnsureVisible(Track * t);
|
||||||
void VerticalScroll( float fracPosition);
|
void VerticalScroll( float fracPosition);
|
||||||
|
|
||||||
|
TrackPanelCell *GetFocusedCell() override;
|
||||||
|
void SetFocusedCell() override;
|
||||||
Track *GetFocusedTrack();
|
Track *GetFocusedTrack();
|
||||||
void SetFocusedTrack(Track *t);
|
void SetFocusedTrack(Track *t);
|
||||||
|
|
||||||
void HandleCursorForPresentMouseState(bool doHit = true);
|
|
||||||
|
|
||||||
void UpdateVRulers();
|
void UpdateVRulers();
|
||||||
void UpdateVRuler(Track *t);
|
void UpdateVRuler(Track *t);
|
||||||
void UpdateTrackVRuler(const Track *t);
|
void UpdateTrackVRuler(const Track *t);
|
||||||
@ -338,7 +314,6 @@ class AUDACITY_DLL_API TrackPanel final : public OverlayPanel {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool IsAudioActive();
|
bool IsAudioActive();
|
||||||
void HandleClick( const TrackPanelMouseEvent &tpmEvent );
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
size_t GetTrackCount() const;
|
size_t GetTrackCount() const;
|
||||||
@ -351,9 +326,6 @@ public:
|
|||||||
void UpdateAccessibility();
|
void UpdateAccessibility();
|
||||||
void MessageForScreenReader(const wxString& message);
|
void MessageForScreenReader(const wxString& message);
|
||||||
|
|
||||||
// MM: Handle mouse wheel rotation
|
|
||||||
void HandleWheelRotation( TrackPanelMouseEvent &tpmEvent );
|
|
||||||
|
|
||||||
void MakeParentRedrawScrollbars();
|
void MakeParentRedrawScrollbars();
|
||||||
|
|
||||||
// If label, rectangle includes track control panel only.
|
// If label, rectangle includes track control panel only.
|
||||||
@ -366,16 +338,10 @@ protected:
|
|||||||
// a crash, as it can take many seconds for large (eg. 10 track-hours) projects
|
// a crash, as it can take many seconds for large (eg. 10 track-hours) projects
|
||||||
|
|
||||||
// Find track info by coordinate
|
// Find track info by coordinate
|
||||||
struct FoundCell {
|
FoundCell FindCell(int mouseX, int mouseY) override;
|
||||||
std::shared_ptr<Track> pTrack;
|
|
||||||
std::shared_ptr<TrackPanelCell> pCell;
|
|
||||||
wxRect rect;
|
|
||||||
};
|
|
||||||
FoundCell FindCell(int mouseX, int mouseY);
|
|
||||||
|
|
||||||
void HandleMotion( wxMouseState &state, bool doHit = true );
|
// Find rectangle of the given cell
|
||||||
void HandleMotion
|
wxRect FindRect(const TrackPanelCell &cell) override;
|
||||||
( const TrackPanelMouseState &tpmState, bool doHit = true );
|
|
||||||
|
|
||||||
int GetVRulerWidth() const;
|
int GetVRulerWidth() const;
|
||||||
int GetVRulerOffset() const { return mTrackInfo.GetTrackInfoWidth(); }
|
int GetVRulerOffset() const { return mTrackInfo.GetTrackInfoWidth(); }
|
||||||
@ -448,7 +414,6 @@ protected:
|
|||||||
TrackPanelListener *mListener;
|
TrackPanelListener *mListener;
|
||||||
|
|
||||||
std::shared_ptr<TrackList> mTracks;
|
std::shared_ptr<TrackList> mTracks;
|
||||||
ViewInfo *mViewInfo;
|
|
||||||
|
|
||||||
AdornedRulerPanel *mRuler;
|
AdornedRulerPanel *mRuler;
|
||||||
|
|
||||||
@ -482,11 +447,6 @@ protected:
|
|||||||
|
|
||||||
bool mRedrawAfterStop;
|
bool mRedrawAfterStop;
|
||||||
|
|
||||||
wxMouseState mLastMouseState;
|
|
||||||
|
|
||||||
int mMouseMostRecentX;
|
|
||||||
int mMouseMostRecentY;
|
|
||||||
|
|
||||||
friend class TrackPanelAx;
|
friend class TrackPanelAx;
|
||||||
|
|
||||||
#if wxUSE_ACCESSIBILITY
|
#if wxUSE_ACCESSIBILITY
|
||||||
@ -511,45 +471,17 @@ protected:
|
|||||||
wxSize vrulerSize;
|
wxSize vrulerSize;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::weak_ptr<TrackPanelCell> mLastCell;
|
|
||||||
std::vector<UIHandlePtr> mTargets;
|
|
||||||
size_t mTarget {};
|
|
||||||
unsigned mMouseOverUpdateFlags{};
|
|
||||||
|
|
||||||
public:
|
|
||||||
UIHandlePtr Target()
|
|
||||||
{
|
|
||||||
if (mTargets.size())
|
|
||||||
return mTargets[mTarget];
|
|
||||||
else
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void ClearTargets()
|
|
||||||
{
|
|
||||||
// Forget the rotation of hit test candidates when the mouse moves from
|
|
||||||
// cell to cell or outside of the TrackPanel entirely.
|
|
||||||
mLastCell.reset();
|
|
||||||
mTargets.clear();
|
|
||||||
mTarget = 0;
|
|
||||||
mMouseOverUpdateFlags = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HasRotation();
|
|
||||||
bool HasEscape();
|
|
||||||
|
|
||||||
bool ChangeTarget(bool forward, bool cycle);
|
|
||||||
|
|
||||||
std::weak_ptr<Track> mpClickedTrack;
|
|
||||||
UIHandlePtr mUIHandle;
|
|
||||||
|
|
||||||
std::shared_ptr<TrackPanelCell> mpBackground;
|
std::shared_ptr<TrackPanelCell> mpBackground;
|
||||||
|
|
||||||
bool mEnableTab{};
|
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
|
void ProcessUIHandleResult
|
||||||
|
(TrackPanelCell *pClickedTrack, TrackPanelCell *pLatestCell,
|
||||||
|
unsigned refreshResult) override;
|
||||||
|
|
||||||
|
void UpdateStatusMessage( const wxString &status ) override;
|
||||||
|
|
||||||
// friending GetInfoCommand allow automation to get sizes of the
|
// friending GetInfoCommand allow automation to get sizes of the
|
||||||
// tracks, track control panel and such.
|
// tracks, track control panel and such.
|
||||||
friend class GetInfoCommand;
|
friend class GetInfoCommand;
|
||||||
|
@ -14,6 +14,7 @@ Paul Licameli
|
|||||||
#include "MemoryX.h"
|
#include "MemoryX.h"
|
||||||
|
|
||||||
class AudacityProject;
|
class AudacityProject;
|
||||||
|
struct HitTestPreview;
|
||||||
struct TrackPanelMouseEvent;
|
struct TrackPanelMouseEvent;
|
||||||
struct TrackPanelMouseState;
|
struct TrackPanelMouseState;
|
||||||
class ViewInfo;
|
class ViewInfo;
|
||||||
@ -34,6 +35,11 @@ class AUDACITY_DLL_API TrackPanelCell /* not final */
|
|||||||
public:
|
public:
|
||||||
virtual ~TrackPanelCell () = 0;
|
virtual ~TrackPanelCell () = 0;
|
||||||
|
|
||||||
|
// May supply default cursor, status message, and tooltip, when there is no
|
||||||
|
// handle to hit at the mouse position, or the handle does not supply them.
|
||||||
|
virtual HitTestPreview DefaultPreview
|
||||||
|
(const TrackPanelMouseState &state, const AudacityProject *pProject);
|
||||||
|
|
||||||
// Return pointers to objects that can be queried for a status
|
// Return pointers to objects that can be queried for a status
|
||||||
// bar message and cursor appropriate to the point, and that dispatch
|
// bar message and cursor appropriate to the point, and that dispatch
|
||||||
// mouse button events.
|
// mouse button events.
|
||||||
@ -50,6 +56,10 @@ public:
|
|||||||
(const TrackPanelMouseEvent &event,
|
(const TrackPanelMouseEvent &event,
|
||||||
AudacityProject *pProject);
|
AudacityProject *pProject);
|
||||||
|
|
||||||
|
// A cell may delegate context menu handling to another one
|
||||||
|
virtual std::shared_ptr<TrackPanelCell> ContextMenuDelegate()
|
||||||
|
{ return {}; }
|
||||||
|
|
||||||
// The pPosition parameter indicates mouse position but may be NULL
|
// The pPosition parameter indicates mouse position but may be NULL
|
||||||
// Return value is a bitwise OR of RefreshCode values
|
// Return value is a bitwise OR of RefreshCode values
|
||||||
// Default implementation does nothing
|
// Default implementation does nothing
|
||||||
|
@ -24,6 +24,13 @@ CommonTrackPanelCell::~CommonTrackPanelCell()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HitTestPreview CommonTrackPanelCell::DefaultPreview
|
||||||
|
(const TrackPanelMouseState &, const AudacityProject *)
|
||||||
|
{
|
||||||
|
static wxCursor defaultCursor{ wxCURSOR_ARROW };
|
||||||
|
return { {}, &defaultCursor, {} };
|
||||||
|
}
|
||||||
|
|
||||||
unsigned CommonTrackPanelCell::HandleWheelRotation
|
unsigned CommonTrackPanelCell::HandleWheelRotation
|
||||||
(const TrackPanelMouseEvent &evt, AudacityProject *pProject)
|
(const TrackPanelMouseEvent &evt, AudacityProject *pProject)
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,10 @@ public:
|
|||||||
|
|
||||||
virtual ~CommonTrackPanelCell() = 0;
|
virtual ~CommonTrackPanelCell() = 0;
|
||||||
|
|
||||||
|
// Default to the arrow cursor
|
||||||
|
HitTestPreview DefaultPreview
|
||||||
|
(const TrackPanelMouseState &, const AudacityProject *) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<Track> FindTrack() = 0;
|
virtual std::shared_ptr<Track> FindTrack() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -138,6 +138,7 @@
|
|||||||
<ClCompile Include="..\..\..\src\Benchmark.cpp" />
|
<ClCompile Include="..\..\..\src\Benchmark.cpp" />
|
||||||
<ClCompile Include="..\..\..\src\BlockFile.cpp" />
|
<ClCompile Include="..\..\..\src\BlockFile.cpp" />
|
||||||
<ClCompile Include="..\..\..\src\blockfile\NotYetAvailableException.cpp" />
|
<ClCompile Include="..\..\..\src\blockfile\NotYetAvailableException.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\src\CellularPanel.cpp" />
|
||||||
<ClCompile Include="..\..\..\src\commands\AudacityCommand.cpp" />
|
<ClCompile Include="..\..\..\src\commands\AudacityCommand.cpp" />
|
||||||
<ClCompile Include="..\..\..\src\commands\CommandContext.cpp" />
|
<ClCompile Include="..\..\..\src\commands\CommandContext.cpp" />
|
||||||
<ClCompile Include="..\..\..\src\commands\CommandTargets.cpp" />
|
<ClCompile Include="..\..\..\src\commands\CommandTargets.cpp" />
|
||||||
@ -481,6 +482,7 @@
|
|||||||
<ClInclude Include="..\..\..\src\Benchmark.h" />
|
<ClInclude Include="..\..\..\src\Benchmark.h" />
|
||||||
<ClInclude Include="..\..\..\src\BlockFile.h" />
|
<ClInclude Include="..\..\..\src\BlockFile.h" />
|
||||||
<ClInclude Include="..\..\..\src\blockfile\NotYetAvailableException.h" />
|
<ClInclude Include="..\..\..\src\blockfile\NotYetAvailableException.h" />
|
||||||
|
<ClInclude Include="..\..\..\src\CellularPanel.h" />
|
||||||
<ClInclude Include="..\..\..\src\commands\AudacityCommand.h" />
|
<ClInclude Include="..\..\..\src\commands\AudacityCommand.h" />
|
||||||
<ClInclude Include="..\..\..\src\commands\CommandContext.h" />
|
<ClInclude Include="..\..\..\src\commands\CommandContext.h" />
|
||||||
<ClInclude Include="..\..\..\src\commands\CommandFlag.h" />
|
<ClInclude Include="..\..\..\src\commands\CommandFlag.h" />
|
||||||
|
@ -1082,6 +1082,9 @@
|
|||||||
<ClCompile Include="..\..\..\src\widgets\WindowAccessible.cpp">
|
<ClCompile Include="..\..\..\src\widgets\WindowAccessible.cpp">
|
||||||
<Filter>src\widgets</Filter>
|
<Filter>src\widgets</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\src\CellularPanel.cpp">
|
||||||
|
<Filter>src</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\..\src\AboutDialog.h">
|
<ClInclude Include="..\..\..\src\AboutDialog.h">
|
||||||
@ -2158,6 +2161,9 @@
|
|||||||
<ClInclude Include="..\..\..\src\widgets\WindowAccessible.h">
|
<ClInclude Include="..\..\..\src\widgets\WindowAccessible.h">
|
||||||
<Filter>src\widgets</Filter>
|
<Filter>src\widgets</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\src\CellularPanel.h">
|
||||||
|
<Filter>src</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Image Include="..\..\audacity.ico">
|
<Image Include="..\..\audacity.ico">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user