Audacity  3.0.3
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
 
- Public Member Functions inherited from TrackPanelCell
 TrackPanelCell ()=default
 
 TrackPanelCell (const TrackPanelCell &) PROHIBITED
 
TrackPanelCelloperator= (const TrackPanelCell &) PROHIBITED
 
virtual ~TrackPanelCell ()=0
 
virtual std::shared_ptr< TrackPanelCellContextMenuDelegate ()
 
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
 
- 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 CommonTrackPanelCell
static Hook InstallMouseWheelHook (const Hook &hook)
 
- 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
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
 

Additional Inherited Members

- Public Types inherited from CommonTrackPanelCell
using Hook = std::function< unsigned(const TrackPanelMouseEvent &evt, AudacityProject *pProject) >
 

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  {}

◆ ~BackgroundCell()

BackgroundCell::~BackgroundCell ( )
virtual

Definition at line 107 of file BackgroundCell.cpp.

108 {
109 }

Member Function Documentation

◆ DoFindTrack()

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

Implements CommonTrackPanelCell.

Definition at line 119 of file BackgroundCell.cpp.

120 {
121  return {};
122 }

◆ Draw()

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

Reimplemented from TrackPanelDrawable.

Definition at line 124 of file BackgroundCell.cpp.

127 {
128  if ( iPass == TrackArtist::PassBackground ) {
129  auto &dc = context.dc;
130  // Paint over the part below the tracks
131  AColor::TrackPanelBackground( &dc, false );
132  dc.DrawRectangle( rect );
133  }
134 }

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 136 of file BackgroundCell.cpp.

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

References kTopMargin, and TrackArtist::PassBackground.

◆ Get() [1/2]

BackgroundCell & BackgroundCell::Get ( AudacityProject project)
static

Definition at line 97 of file BackgroundCell.cpp.

98 {
99  return project.AttachedObjects::Get< BackgroundCell >( key );
100 }

References key.

Referenced by CommonTrackView::HitTest().

Here is the caller graph for this function:

◆ Get() [2/2]

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

Definition at line 102 of file BackgroundCell.cpp.

103 {
104  return Get( const_cast< AudacityProject & >( project ) );
105 }

References BasicUI::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 153 of file BackgroundCell.cpp.

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

References XO.

◆ HitTest()

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

Implements TrackPanelCell.

Definition at line 111 of file BackgroundCell.cpp.

114 {
115  auto result = AssignUIHandlePtr(mHandle, std::make_shared<BackgroundHandle>());
116  return { result };
117 }

References AssignUIHandlePtr().

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.

◆ 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:
BackgroundCell
Class representing the background of a Track. It provides the hit test function that tells us what wa...
Definition: BackgroundCell.h:28
AColor::TrackPanelBackground
static void TrackPanelBackground(wxDC *dc, bool selected)
Definition: AColor.cpp:362
XO
#define XO(s)
Definition: Internat.h:31
TrackPanelDrawingContext::dc
wxDC & dc
Definition: TrackPanelDrawingContext.h:23
BackgroundCell::Get
static BackgroundCell & Get(AudacityProject &project)
Definition: BackgroundCell.cpp:97
kTopMargin
@ kTopMargin
Definition: TrackPanelConstants.h:21
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
BackgroundCell::mHandle
std::weak_ptr< BackgroundHandle > mHandle
Definition: BackgroundCell.h:63
BackgroundCell::mpProject
AudacityProject * mpProject
Definition: BackgroundCell.h:61
AssignUIHandlePtr
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:151
TrackArtist::PassBackground
@ PassBackground
Definition: TrackArtist.h:86
key
static const AudacityProject::AttachedObjects::RegisteredFactory key
Definition: BackgroundCell.cpp:89