Audacity  2.2.2
Classes | Macros | Enumerations | Functions | Variables
TrackPanel.cpp File Reference

Implements TrackPanel and TrackInfo. More...

#include "Audacity.h"
#include "Experimental.h"
#include "TrackPanel.h"
#include "Project.h"
#include "TrackPanelCellIterator.h"
#include "TrackPanelMouseEvent.h"
#include "TrackPanelResizeHandle.h"
#include "AColor.h"
#include "AllThemeResources.h"
#include "AudioIO.h"
#include "float_cast.h"
#include "Prefs.h"
#include "RefreshCode.h"
#include "TrackArtist.h"
#include "TrackPanelAx.h"
#include "UIHandle.h"
#include "HitTestResult.h"
#include "WaveTrack.h"
#include "toolbars/ControlToolBar.h"
#include "toolbars/ToolsToolBar.h"
#include "../images/Cursors.h"
#include "widgets/ASlider.h"
#include "widgets/Ruler.h"
#include <algorithm>
#include "TrackPanelDrawingContext.h"
#include "tracks/ui/TrackControls.h"
#include "tracks/ui/TrackButtonHandles.h"
#include "tracks/playabletrack/notetrack/ui/NoteTrackButtonHandle.h"
#include "tracks/playabletrack/wavetrack/ui/WaveTrackSliderHandles.h"
#include "tracks/playabletrack/ui/PlayableTrackButtonHandles.h"

Go to the source code of this file.

Classes

struct  TrackInfo::TCPLine
 

Macros

#define RANGE(array)   (array), (array) + sizeof(array)/sizeof(*(array))
 
#define TITLE_ITEMS
 
#define MUTE_SOLO_ITEMS(extra)
 
#define STATUS_ITEMS
 
#define COMMON_ITEMS   TITLE_ITEMS
 

Enumerations

enum  : unsigned
 

Functions

 wxDEFINE_EVENT (EVT_TRACK_PANEL_TIMER, wxCommandEvent)
 
template<class A , class B , class DIST >
bool within (A a, B b, DIST d)
 
std::unique_ptr< wxCursor > MakeCursor (int WXUNUSED(CursorId), const char *const pXpm[36], int HotX, int HotY)
 
static TrackPanelTrackPanelFactory (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const std::shared_ptr< TrackList > &tracks, ViewInfo *viewInfo, TrackPanelListener *listener, AdornedRulerPanel *ruler)
 

Variables

static const int TitleSoloBorderOverlap = 1
 

Detailed Description

Implements TrackPanel and TrackInfo.

Todo:
Refactoring of the TrackPanel, possibly as described in Track Panel Refactor

TrackPanel.cpp is currently some of the worst code in Audacity. It's not really unreadable, there's just way too much stuff in this one file. Rather than apply a quick fix, the long-term plan is to create a GUITrack class that knows how to draw itself and handle events. Then this class just helps coordinate between tracks.

Plans under discussion are described in Track Panel Refactor

Definition in file TrackPanel.cpp.

Macro Definition Documentation

#define COMMON_ITEMS   TITLE_ITEMS

Definition at line 1207 of file TrackPanel.cpp.

#define MUTE_SOLO_ITEMS (   extra)
Value:
{ kItemMute | kItemSolo, kTrackInfoBtnSize + 1, extra, \
static void MuteAndSoloDrawFunction(TrackPanelDrawingContext &context, const wxRect &rect, const Track *pTrack)

Definition at line 1196 of file TrackPanel.cpp.

#define RANGE (   array)    (array), (array) + sizeof(array)/sizeof(*(array))

Definition at line 1156 of file TrackPanel.cpp.

#define STATUS_ITEMS
Value:
{ kItemStatusInfo1, 12, 0, \
{ kItemStatusInfo2, 12, 0, \
static void Status1DrawFunction(TrackPanelDrawingContext &context, const wxRect &rect, const Track *pTrack)
static void Status2DrawFunction(TrackPanelDrawingContext &context, const wxRect &rect, const Track *pTrack)

Definition at line 1199 of file TrackPanel.cpp.

#define TITLE_ITEMS
Value:
{ kItemBarButtons, kTrackInfoBtnSize, 0, \
static void CloseTitleDrawFunction(TrackPanelDrawingContext &context, const wxRect &rect, const Track *pTrack)

Definition at line 1193 of file TrackPanel.cpp.

Enumeration Type Documentation

anonymous enum : unsigned

Definition at line 1159 of file TrackPanel.cpp.

1159  : unsigned {
1160  // The sequence is not significant, just keep bits distinct
1161  kItemBarButtons = 1 << 0,
1162  kItemStatusInfo1 = 1 << 1,
1163  kItemMute = 1 << 2,
1164  kItemSolo = 1 << 3,
1165  kItemGain = 1 << 4,
1166  kItemPan = 1 << 5,
1167  kItemVelocity = 1 << 6,
1168  kItemMidiControlsRect = 1 << 7,
1169  kItemMinimize = 1 << 8,
1170  kItemSyncLock = 1 << 9,
1171  kItemStatusInfo2 = 1 << 10,
1172 
1173  kHighestBottomItem = kItemMinimize,
1174 };

Function Documentation

std::unique_ptr<wxCursor> MakeCursor ( int   WXUNUSEDCursorId,
const char *const  pXpm[36],
int  HotX,
int  HotY 
)

Makes a cursor from an XPM, uses CursorId as a fallback. TODO: Move this function to some other source file for reuse elsewhere.

Definition at line 274 of file TrackPanel.cpp.

Referenced by ZoomHandle::HitPreview(), LabelTextHandle::HitPreview(), CutlineHandle::HitPreview(), SampleHandle::HitPreview(), WaveTrackVZoomHandle::HitPreview(), TimeShiftHandle::HitPreview(), TrackSelectHandle::Preview(), and EnvelopeHandle::Preview().

275 {
276 #ifdef CURSORS_SIZE32
277  const int HotAdjust =0;
278 #else
279  const int HotAdjust =8;
280 #endif
281 
282  wxImage Image = wxImage(wxBitmap(pXpm).ConvertToImage());
283  Image.SetMaskColour(255,0,0);
284  Image.SetMask();// Enable mask.
285 
286  Image.SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_X, HotX-HotAdjust );
287  Image.SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_Y, HotY-HotAdjust );
288  return std::make_unique<wxCursor>( Image );
289 }
static TrackPanel* TrackPanelFactory ( wxWindow *  parent,
wxWindowID  id,
const wxPoint &  pos,
const wxSize &  size,
const std::shared_ptr< TrackList > &  tracks,
ViewInfo viewInfo,
TrackPanelListener listener,
AdornedRulerPanel ruler 
)
static

Definition at line 3495 of file TrackPanel.cpp.

References safenew.

3503 {
3504  wxASSERT(parent); // to justify safenew
3505  return safenew TrackPanel(
3506  parent,
3507  id,
3508  pos,
3509  size,
3510  tracks,
3511  viewInfo,
3512  listener,
3513  ruler);
3514 }
#define safenew
Definition: Audacity.h:230
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
Definition: TrackPanel.h:245
template<class A , class B , class DIST >
bool within ( a,
b,
DIST  d 
)

Definition at line 252 of file TrackPanel.cpp.

Referenced by TrackArtist::DrawBackgroundWithSelection().

253 {
254  return (a > b - d) && (a < b + d);
255 }
wxDEFINE_EVENT ( EVT_TRACK_PANEL_TIMER  ,
wxCommandEvent   
)

Variable Documentation

const int TitleSoloBorderOverlap = 1
static