audacia/src/TrackPanel.h

226 lines
5.6 KiB
C
Raw Normal View History

/**********************************************************************
Audacity: A Digital Audio Editor
TrackPanel.h
Dominic Mazzoni
**********************************************************************/
#ifndef __AUDACITY_TRACK_PANEL__
#define __AUDACITY_TRACK_PANEL__
#include <vector>
#include <wx/setup.h> // for wxUSE_* macros
#include <wx/timer.h> // to inherit
#include "HitTestResult.h"
#include "Prefs.h"
#include "SelectedRegion.h"
2015-07-03 04:20:21 +00:00
#include "CellularPanel.h"
#include "commands/CommandManagerWindowClasses.h"
class wxRect;
class SpectrumAnalyst;
class Track;
class TrackList;
2018-10-29 13:19:33 +00:00
struct TrackListEvent;
class TrackPanel;
class TrackArtist;
class Ruler;
class SnapManager;
class AdornedRulerPanel;
class LWSlider;
class TrackPanelAx;
// Declared elsewhere, to reduce compilation dependencies
class TrackPanelListener;
struct TrackPanelDrawingContext;
2016-02-25 01:45:49 +00:00
enum class UndoPush : unsigned char;
enum {
kTimerInterval = 50, // milliseconds
};
const int DragThreshold = 3;// Anything over 3 pixels is a drag, else a click.
class AUDACITY_DLL_API TrackPanel final
: public CellularPanel
, public NonKeystrokeInterceptingWindow
, private PrefsListener
{
public:
static TrackPanel &Get( AudacityProject &project );
static const TrackPanel &Get( const AudacityProject &project );
static void Destroy( AudacityProject &project );
TrackPanel(wxWindow * parent,
wxWindowID id,
const wxPoint & pos,
const wxSize & size,
const std::shared_ptr<TrackList> &tracks,
ViewInfo * viewInfo,
AudacityProject * project,
AdornedRulerPanel * ruler );
virtual ~ TrackPanel();
void UpdatePrefs() override;
void OnAudioIO(wxCommandEvent & evt);
2017-06-16 16:39:40 +00:00
void OnPaint(wxPaintEvent & event);
void OnMouseEvent(wxMouseEvent & event);
void OnKeyDown(wxKeyEvent & event);
void OnTrackListResizing(TrackListEvent & event);
void OnTrackListDeletion(wxEvent & event);
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().
2017-06-16 16:39:40 +00:00
double GetMostRecentXPos();
void OnSize( wxSizeEvent & );
2017-06-16 16:39:40 +00:00
void OnIdle(wxIdleEvent & event);
void OnTimer(wxTimerEvent& event);
void OnProjectSettingsChange(wxCommandEvent &event);
void OnTrackFocusChange( wxCommandEvent &event );
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();
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
void VerticalScroll( float fracPosition);
2011-11-25 20:40:26 +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);
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();
public:
size_t GetSelectedTrackCount() const;
protected:
2017-06-16 16:39:40 +00:00
void UpdateSelectionDisplay();
public:
2017-06-16 16:39:40 +00:00
void MakeParentRedrawScrollbars();
2014-06-03 20:30:19 +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 );
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;
public:
// 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.
const TrackList * GetTracks() const { return mTracks.get(); }
TrackList * GetTracks() { return mTracks.get(); }
ViewInfo * GetViewInfo(){ return mViewInfo;}
TrackPanelListener * GetListener(){ return mListener;}
AdornedRulerPanel * GetRuler(){ return mRuler;}
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
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
(const std::shared_ptr< TrackPanelCell > &pCell);
std::shared_ptr< TrackPanelCell > GetBackgroundCell();
public:
protected:
TrackPanelListener *mListener;
std::shared_ptr<TrackList> mTracks;
AdornedRulerPanel *mRuler;
std::unique_ptr<TrackArtist> mTrackArtist;
class AUDACITY_DLL_API AudacityTimer final : public wxTimer {
public:
void Notify() override{
// (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));
}
TrackPanel *parent;
} mTimer;
2014-06-03 20:30:19 +00:00
int mTimeCount;
bool mRefreshBacking;
protected:
SelectedRegion mLastDrawnSelectedRegion {};
protected:
std::shared_ptr<TrackPanelCell> mpBackground;
DECLARE_EVENT_TABLE()
void ProcessUIHandleResult
(TrackPanelCell *pClickedTrack, TrackPanelCell *pLatestCell,
unsigned refreshResult) override;
void UpdateStatusMessage( const TranslatableString &status ) override;
};
2018-09-11 03:00:28 +00:00
// A predicate class
struct AUDACITY_DLL_API IsVisibleTrack
2018-09-11 03:00:28 +00:00
{
IsVisibleTrack(AudacityProject *project);
bool operator () (const Track *pTrack) const;
wxRect mPanelRect;
};
#endif