Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
BackgroundCell Class Referencefinal

Class representing the background of a Track. It provides the hit test function that tells us what was hit. More...

#include <BackgroundCell.h>

Inheritance diagram for BackgroundCell:
[legend]
Collaboration diagram for BackgroundCell:
[legend]

Public Member Functions

 BackgroundCell (AudacityProject *pProject)
 
virtual ~BackgroundCell ()
 
- Public Member Functions inherited from CommonTrackPanelCell
 CommonTrackPanelCell ()
 
virtual ~CommonTrackPanelCell ()=0
 
HitTestPreview DefaultPreview (const TrackPanelMouseState &, const AudacityProject *) override
 
std::shared_ptr< TrackFindTrack ()
 
std::shared_ptr< const TrackFindTrack () const
 
virtual std::vector< MenuItemGetMenuItems (const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject)
 Return a list of items for DoContextMenu() (empties for separators) More...
 
- Public Member Functions inherited from TrackPanelCell
 TrackPanelCell ()=default
 
 TrackPanelCell (const TrackPanelCell &) PROHIBITED
 
TrackPanelCelloperator= (const TrackPanelCell &) PROHIBITED
 
virtual ~TrackPanelCell ()=0
 
virtual HitTestPreview DefaultPreview (const TrackPanelMouseState &state, const AudacityProject *pProject)
 
virtual std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject)=0
 
virtual unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject)
 
virtual std::shared_ptr< TrackPanelCellContextMenuDelegate ()
 
virtual unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject)
 
virtual unsigned CaptureKey (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned KeyDown (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned KeyUp (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned Char (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned LoseFocus (AudacityProject *project)
 
- Public Member Functions inherited from TrackPanelNode
 TrackPanelNode ()
 
virtual ~TrackPanelNode ()=0
 
- Public Member Functions inherited from TrackPanelDrawable
virtual ~TrackPanelDrawable ()=0
 
virtual void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
 
virtual wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Static Public Member Functions

static BackgroundCellGet (AudacityProject &project)
 
static const BackgroundCellGet (const AudacityProject &project)
 
- Static Public Member Functions inherited from TrackPanelDrawable
static wxRect MaximizeWidth (const wxRect &rect, const wxRect &panelRect)
 
static wxRect MaximizeHeight (const wxRect &rect, const wxRect &panelRect)
 

Public Attributes

std::weak_ptr< ZoomHandlemZoomHandle
 

Protected Member Functions

std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &state, const AudacityProject *) override
 
std::shared_ptr< TrackDoFindTrack () override
 
- Protected Member Functions inherited from CommonTrackPanelCell
virtual std::shared_ptr< TrackDoFindTrack ()=0
 
unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject) override
 
unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 

Private Member Functions

void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
 
wxRect DrawingArea (TrackPanelDrawingContext &, const wxRect &rect, const wxRect &panelRect, unsigned iPass) override
 
std::vector< MenuItemGetMenuItems (const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject) override
 Return a list of items for DoContextMenu() (empties for separators) More...
 

Private Attributes

AudacityProjectmpProject
 
std::weak_ptr< BackgroundHandlemHandle
 

Detailed Description

Class representing the background of a Track. It provides the hit test function that tells us what was hit.

Definition at line 25 of file BackgroundCell.h.

Constructor & Destructor Documentation

◆ BackgroundCell()

BackgroundCell::BackgroundCell ( AudacityProject pProject)
inlineexplicit

Definition at line 34 of file BackgroundCell.h.

35 : mpProject(pProject)
36 {}
AudacityProject * mpProject

◆ ~BackgroundCell()

BackgroundCell::~BackgroundCell ( )
virtual

Definition at line 106 of file BackgroundCell.cpp.

107{
108}

Member Function Documentation

◆ DoFindTrack()

std::shared_ptr< Track > BackgroundCell::DoFindTrack ( )
overrideprotectedvirtual

Implements CommonTrackPanelCell.

Definition at line 118 of file BackgroundCell.cpp.

119{
120 return {};
121}

◆ Draw()

void BackgroundCell::Draw ( TrackPanelDrawingContext context,
const wxRect &  rect,
unsigned  iPass 
)
overrideprivatevirtual

Reimplemented from TrackPanelDrawable.

Definition at line 123 of file BackgroundCell.cpp.

126{
127 if ( iPass == TrackArtist::PassBackground ) {
128 auto &dc = context.dc;
129 // Paint over the part below the tracks
130 AColor::TrackPanelBackground( &dc, false );
131 dc.DrawRectangle( rect );
132 }
133}
static void TrackPanelBackground(wxDC *dc, bool selected)
Definition: AColor.cpp:454

References TrackPanelDrawingContext::dc, TrackArtist::PassBackground, and AColor::TrackPanelBackground().

Here is the call graph for this function:

◆ DrawingArea()

wxRect BackgroundCell::DrawingArea ( TrackPanelDrawingContext ,
const wxRect &  rect,
const wxRect &  panelRect,
unsigned  iPass 
)
overrideprivatevirtual

Reimplemented from TrackPanelDrawable.

Definition at line 135 of file BackgroundCell.cpp.

138{
139 if ( iPass == TrackArtist::PassBackground )
140 // If there are any tracks, extend the drawing area up, to cover the
141 // bottom ends of any zooming guide lines.
142 return {
143 rect.x,
144 rect.y - kTopMargin,
145 rect.width,
146 rect.height + kTopMargin
147 };
148 else
149 return rect;
150}
@ kTopMargin

References kTopMargin, and TrackArtist::PassBackground.

◆ Get() [1/2]

BackgroundCell & BackgroundCell::Get ( AudacityProject project)
static

Definition at line 96 of file BackgroundCell.cpp.

97{
98 return project.AttachedObjects::Get< BackgroundCell >( key );
99}
static const AudacityProject::AttachedObjects::RegisteredFactory key
Class representing the background of a Track. It provides the hit test function that tells us what wa...

References key.

Referenced by Get(), and CommonTrackView::HitTest().

Here is the caller graph for this function:

◆ Get() [2/2]

const BackgroundCell & BackgroundCell::Get ( const AudacityProject project)
static

Definition at line 101 of file BackgroundCell.cpp.

102{
103 return Get( const_cast< AudacityProject & >( project ) );
104}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static BackgroundCell & Get(AudacityProject &project)

References Get().

Here is the call graph for this function:

◆ GetMenuItems()

auto BackgroundCell::GetMenuItems ( const wxRect &  rect,
const wxPoint *  pPosition,
AudacityProject pProject 
)
overrideprivatevirtual

Return a list of items for DoContextMenu() (empties for separators)

If the vector is empty (as in the default), there is no context menu.

Commands are invoked with temporary selection fields of CommandContext set to a point selected region at the mouse pick, and the cell's track.

A function may be given, but if it is null, then the command can be found by name in the CommandManager.

An item in the list with no command name marks a menu separator.

The menu item is enabled only if it contains a true flag, but if looked up in the command manager, it must also satisfy the command manager's conditions.

Reimplemented from CommonTrackPanelCell.

Definition at line 152 of file BackgroundCell.cpp.

155{
156 // These commands exist in toolbar menus too, but maybe with other labels
157 // TODO: devise a system of registration so that BackgroundCell has no
158 // special knowledge about track sub-types
159 return {
160 { L"NewMonoTrack", XO("Add Mono Track")},
161 { L"NewStereoTrack", XO("Add Stereo Track") },
162 { L"NewLabelTrack", XO("Add Label Track"), },
163 {},
164 { L"Export", XO("Export Audio..."), },
165 {},
166 { L"SelectAll", XO("Select All") },
167 };
168}
XO("Cut/Copy/Paste")

References XO().

Here is the call graph for this function:

◆ HitTest()

std::vector< UIHandlePtr > BackgroundCell::HitTest ( const TrackPanelMouseState state,
const AudacityProject  
)
overrideprotectedvirtual

Implements TrackPanelCell.

Definition at line 110 of file BackgroundCell.cpp.

113{
114 auto result = AssignUIHandlePtr(mHandle, std::make_shared<BackgroundHandle>());
115 return { result };
116}
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:151
std::weak_ptr< BackgroundHandle > mHandle

References AssignUIHandlePtr(), and mHandle.

Here is the call graph for this function:

Member Data Documentation

◆ mHandle

std::weak_ptr<BackgroundHandle> BackgroundCell::mHandle
private

Definition at line 63 of file BackgroundCell.h.

Referenced by HitTest().

◆ mpProject

AudacityProject* BackgroundCell::mpProject
private

Definition at line 61 of file BackgroundCell.h.

◆ mZoomHandle

std::weak_ptr<ZoomHandle> BackgroundCell::mZoomHandle
mutable

Definition at line 67 of file BackgroundCell.h.

Referenced by CommonTrackView::HitTest().


The documentation for this class was generated from the following files: