2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
TrackPanel.h
|
|
|
|
|
|
|
|
Dominic Mazzoni
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifndef __AUDACITY_TRACK_PANEL__
|
|
|
|
#define __AUDACITY_TRACK_PANEL__
|
|
|
|
|
2021-05-09 15:16:56 +00:00
|
|
|
|
2020-06-19 19:43:09 +00:00
|
|
|
|
2018-11-11 17:27:44 +00:00
|
|
|
|
2015-04-12 16:39:11 +00:00
|
|
|
#include <vector>
|
2014-10-18 14:19:38 +00:00
|
|
|
|
2019-03-23 18:28:37 +00:00
|
|
|
#include <wx/setup.h> // for wxUSE_* macros
|
2018-11-14 16:48:46 +00:00
|
|
|
#include <wx/timer.h> // to inherit
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2017-06-18 01:37:41 +00:00
|
|
|
#include "HitTestResult.h"
|
2018-02-17 22:42:14 +00:00
|
|
|
#include "Prefs.h"
|
2017-06-18 01:37:41 +00:00
|
|
|
|
2016-02-24 16:41:26 +00:00
|
|
|
#include "SelectedRegion.h"
|
2015-07-03 04:20:21 +00:00
|
|
|
|
2018-08-04 17:06:55 +00:00
|
|
|
#include "CellularPanel.h"
|
2015-07-09 04:38:42 +00:00
|
|
|
|
2018-12-28 16:49:35 +00:00
|
|
|
#include "commands/CommandManagerWindowClasses.h"
|
|
|
|
|
2017-06-11 11:20:01 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
class wxRect;
|
|
|
|
|
2014-10-18 14:19:38 +00:00
|
|
|
class SpectrumAnalyst;
|
2015-07-08 21:17:43 +00:00
|
|
|
class Track;
|
|
|
|
class TrackList;
|
2018-10-29 13:19:33 +00:00
|
|
|
struct TrackListEvent;
|
2010-01-23 19:44:49 +00:00
|
|
|
class TrackPanel;
|
|
|
|
class TrackArtist;
|
|
|
|
class Ruler;
|
|
|
|
class SnapManager;
|
|
|
|
class AdornedRulerPanel;
|
|
|
|
class LWSlider;
|
|
|
|
|
|
|
|
class TrackPanelAx;
|
|
|
|
|
2014-10-18 14:19:38 +00:00
|
|
|
// Declared elsewhere, to reduce compilation dependencies
|
|
|
|
class TrackPanelListener;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2017-07-07 11:56:49 +00:00
|
|
|
struct TrackPanelDrawingContext;
|
|
|
|
|
2016-02-25 01:45:49 +00:00
|
|
|
enum class UndoPush : unsigned char;
|
|
|
|
|
2015-08-27 05:13:46 +00:00
|
|
|
enum {
|
|
|
|
kTimerInterval = 50, // milliseconds
|
|
|
|
};
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
const int DragThreshold = 3;// Anything over 3 pixels is a drag, else a click.
|
|
|
|
|
2018-12-28 16:49:35 +00:00
|
|
|
class AUDACITY_DLL_API TrackPanel final
|
|
|
|
: public CellularPanel
|
|
|
|
, public NonKeystrokeInterceptingWindow
|
2018-02-17 22:42:14 +00:00
|
|
|
, private PrefsListener
|
2018-12-28 16:49:35 +00:00
|
|
|
{
|
2018-06-25 03:17:36 +00:00
|
|
|
public:
|
2019-04-21 21:01:31 +00:00
|
|
|
static TrackPanel &Get( AudacityProject &project );
|
|
|
|
static const TrackPanel &Get( const AudacityProject &project );
|
|
|
|
static void Destroy( AudacityProject &project );
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
TrackPanel(wxWindow * parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint & pos,
|
|
|
|
const wxSize & size,
|
2016-08-20 17:58:56 +00:00
|
|
|
const std::shared_ptr<TrackList> &tracks,
|
2010-01-23 19:44:49 +00:00
|
|
|
ViewInfo * viewInfo,
|
2019-04-21 21:01:31 +00:00
|
|
|
AudacityProject * project,
|
2010-01-23 19:44:49 +00:00
|
|
|
AdornedRulerPanel * ruler );
|
|
|
|
|
|
|
|
virtual ~ TrackPanel();
|
|
|
|
|
2018-02-17 22:42:14 +00:00
|
|
|
void UpdatePrefs() override;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2019-07-07 17:39:16 +00:00
|
|
|
void OnAudioIO(wxCommandEvent & evt);
|
|
|
|
|
2017-06-16 16:39:40 +00:00
|
|
|
void OnPaint(wxPaintEvent & event);
|
|
|
|
void OnMouseEvent(wxMouseEvent & event);
|
|
|
|
void OnKeyDown(wxKeyEvent & event);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2018-02-05 22:56:46 +00:00
|
|
|
void OnTrackListResizing(TrackListEvent & event);
|
|
|
|
void OnTrackListDeletion(wxEvent & event);
|
2019-06-10 15:20:07 +00:00
|
|
|
void OnEnsureVisible(TrackListEvent & event);
|
2017-06-16 16:39:40 +00:00
|
|
|
void UpdateViewIfNoTracks(); // Call this to update mViewInfo, etc, after track(s) removal, before Refresh().
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2017-06-16 16:39:40 +00:00
|
|
|
double GetMostRecentXPos();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2019-06-08 00:50:31 +00:00
|
|
|
void OnSize( wxSizeEvent & );
|
2017-06-16 16:39:40 +00:00
|
|
|
void OnIdle(wxIdleEvent & event);
|
|
|
|
void OnTimer(wxTimerEvent& event);
|
2019-05-30 17:36:41 +00:00
|
|
|
void OnProjectSettingsChange(wxCommandEvent &event);
|
2019-06-25 14:56:25 +00:00
|
|
|
void OnTrackFocusChange( wxCommandEvent &event );
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2019-06-08 16:18:04 +00:00
|
|
|
void OnUndoReset( wxCommandEvent &event );
|
|
|
|
|
2017-06-16 16:36:13 +00:00
|
|
|
void Refresh
|
|
|
|
(bool eraseBackground = true, const wxRect *rect = (const wxRect *) NULL)
|
|
|
|
override;
|
|
|
|
|
2017-06-16 16:39:40 +00:00
|
|
|
void RefreshTrack(Track *trk, bool refreshbacking = true);
|
2011-11-25 20:40:26 +00:00
|
|
|
|
2017-06-16 16:39:40 +00:00
|
|
|
void HandlePageUpKey();
|
|
|
|
void HandlePageDownKey();
|
2018-06-25 03:17:36 +00:00
|
|
|
AudacityProject * GetProject() const override;
|
2011-11-25 20:40:26 +00:00
|
|
|
|
2017-06-16 16:39:40 +00:00
|
|
|
void OnTrackMenu(Track *t = NULL);
|
2011-11-25 20:40:26 +00:00
|
|
|
|
2017-12-17 14:59:59 +00:00
|
|
|
void VerticalScroll( float fracPosition);
|
2011-11-25 20:40:26 +00:00
|
|
|
|
2018-06-25 03:17:36 +00:00
|
|
|
TrackPanelCell *GetFocusedCell() override;
|
|
|
|
void SetFocusedCell() override;
|
2011-11-25 20:40:26 +00:00
|
|
|
|
2017-06-16 16:39:40 +00:00
|
|
|
void UpdateVRulers();
|
|
|
|
void UpdateVRuler(Track *t);
|
2018-11-03 05:15:22 +00:00
|
|
|
void UpdateTrackVRuler(Track *t);
|
2017-06-16 16:39:40 +00:00
|
|
|
void UpdateVRulerSize();
|
2011-11-25 20:40:26 +00:00
|
|
|
|
|
|
|
protected:
|
2017-06-16 16:39:40 +00:00
|
|
|
bool IsAudioActive();
|
2015-08-13 14:59:42 +00:00
|
|
|
|
2015-08-09 17:48:27 +00:00
|
|
|
public:
|
|
|
|
size_t GetSelectedTrackCount() const;
|
2015-05-19 16:30:02 +00:00
|
|
|
|
2015-06-08 13:50:43 +00:00
|
|
|
protected:
|
2017-06-16 16:39:40 +00:00
|
|
|
void UpdateSelectionDisplay();
|
2014-10-18 14:19:38 +00:00
|
|
|
|
2015-08-28 14:40:19 +00:00
|
|
|
public:
|
2017-06-16 16:39:40 +00:00
|
|
|
void MakeParentRedrawScrollbars();
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2018-11-19 16:03:41 +00:00
|
|
|
// Rectangle includes track control panel, and the vertical ruler, and
|
|
|
|
// the proper track area of all channels, and the separators between them.
|
|
|
|
wxRect FindTrackRect( const Track * target );
|
2018-03-21 14:16:05 +00:00
|
|
|
|
2015-07-07 03:12:16 +00:00
|
|
|
protected:
|
2018-09-17 16:53:34 +00:00
|
|
|
// Get the root object defining a recursive subdivision of the panel's
|
|
|
|
// area into cells
|
|
|
|
std::shared_ptr<TrackPanelNode> Root() override;
|
|
|
|
|
2018-03-21 14:16:05 +00:00
|
|
|
public:
|
2020-05-20 14:59:47 +00:00
|
|
|
// JKC Nov-2011: These four functions only used from within a dll
|
2011-11-25 20:40:26 +00:00
|
|
|
// They work around some messy problems with constructors.
|
2015-08-09 17:48:27 +00:00
|
|
|
const TrackList * GetTracks() const { return mTracks.get(); }
|
|
|
|
TrackList * GetTracks() { return mTracks.get(); }
|
2015-04-19 21:12:06 +00:00
|
|
|
ViewInfo * GetViewInfo(){ return mViewInfo;}
|
|
|
|
TrackPanelListener * GetListener(){ return mListener;}
|
|
|
|
AdornedRulerPanel * GetRuler(){ return mRuler;}
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2011-11-25 20:40:26 +00:00
|
|
|
protected:
|
2017-06-16 16:39:40 +00:00
|
|
|
void DrawTracks(wxDC * dc);
|
2011-11-25 20:40:26 +00:00
|
|
|
|
2015-07-07 03:12:16 +00:00
|
|
|
public:
|
|
|
|
// Set the object that performs catch-all event handling when the pointer
|
|
|
|
// is not in any track or ruler or control panel.
|
2017-06-16 16:39:40 +00:00
|
|
|
void SetBackgroundCell
|
2015-07-07 03:12:16 +00:00
|
|
|
(const std::shared_ptr< TrackPanelCell > &pCell);
|
2017-06-17 05:26:36 +00:00
|
|
|
std::shared_ptr< TrackPanelCell > GetBackgroundCell();
|
2015-07-07 03:12:16 +00:00
|
|
|
|
2017-06-12 20:54:12 +00:00
|
|
|
public:
|
|
|
|
|
2015-08-28 19:53:11 +00:00
|
|
|
protected:
|
2010-01-23 19:44:49 +00:00
|
|
|
TrackPanelListener *mListener;
|
|
|
|
|
2016-08-20 17:58:56 +00:00
|
|
|
std::shared_ptr<TrackList> mTracks;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
AdornedRulerPanel *mRuler;
|
|
|
|
|
2016-08-03 01:25:05 +00:00
|
|
|
std::unique_ptr<TrackArtist> mTrackArtist;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-02-24 06:06:39 +00:00
|
|
|
class AUDACITY_DLL_API AudacityTimer final : public wxTimer {
|
2010-01-23 19:44:49 +00:00
|
|
|
public:
|
2016-02-24 06:06:47 +00:00
|
|
|
void Notify() override{
|
2015-08-26 03:50:23 +00:00
|
|
|
// (From Debian)
|
|
|
|
//
|
|
|
|
// Don't call parent->OnTimer(..) directly here, but instead post
|
|
|
|
// an event. This ensures that this is a pure wxWidgets event
|
|
|
|
// (no GDK event behind it) and that it therefore isn't processed
|
|
|
|
// within the YieldFor(..) of the clipboard operations (workaround
|
|
|
|
// for Debian bug #765341).
|
2016-08-08 13:54:53 +00:00
|
|
|
// QueueEvent() will take ownership of the event
|
|
|
|
parent->GetEventHandler()->QueueEvent(safenew wxTimerEvent(*this));
|
2015-08-26 03:50:23 +00:00
|
|
|
}
|
2010-01-23 19:44:49 +00:00
|
|
|
TrackPanel *parent;
|
|
|
|
} mTimer;
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
int mTimeCount;
|
|
|
|
|
|
|
|
bool mRefreshBacking;
|
|
|
|
|
|
|
|
|
2015-08-25 17:35:32 +00:00
|
|
|
protected:
|
|
|
|
|
2016-05-23 21:56:06 +00:00
|
|
|
SelectedRegion mLastDrawnSelectedRegion {};
|
|
|
|
|
2015-07-07 03:12:16 +00:00
|
|
|
protected:
|
|
|
|
|
|
|
|
std::shared_ptr<TrackPanelCell> mpBackground;
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2017-12-20 21:19:23 +00:00
|
|
|
|
2018-06-25 01:51:03 +00:00
|
|
|
void ProcessUIHandleResult
|
2018-08-04 17:06:55 +00:00
|
|
|
(TrackPanelCell *pClickedTrack, TrackPanelCell *pLatestCell,
|
2018-06-25 03:17:36 +00:00
|
|
|
unsigned refreshResult) override;
|
|
|
|
|
2019-12-08 21:24:20 +00:00
|
|
|
void UpdateStatusMessage( const TranslatableString &status ) override;
|
2010-01-23 19:44:49 +00:00
|
|
|
};
|
|
|
|
|
2018-09-11 03:00:28 +00:00
|
|
|
// A predicate class
|
2020-09-28 12:50:18 +00:00
|
|
|
struct AUDACITY_DLL_API IsVisibleTrack
|
2018-09-11 03:00:28 +00:00
|
|
|
{
|
|
|
|
IsVisibleTrack(AudacityProject *project);
|
|
|
|
|
|
|
|
bool operator () (const Track *pTrack) const;
|
|
|
|
|
|
|
|
wxRect mPanelRect;
|
|
|
|
};
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
#endif
|