Audacity  3.0.3
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
TrackPanelResizerCell Class Reference

#include <TrackPanelResizerCell.h>

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

Public Member Functions

 TrackPanelResizerCell (const std::shared_ptr< Track > &pTrack)
 
std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &, const AudacityProject *) override
 
- 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 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)
 
- Public Member Functions inherited from TrackPanelNode
 TrackPanelNode ()
 
virtual ~TrackPanelNode ()=0
 
- Public Member Functions inherited from TrackPanelDrawable
virtual ~TrackPanelDrawable ()=0
 
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 TrackPanelResizerCellGet (Track &track)
 
static const TrackPanelResizerCellGet (const Track &track)
 
- 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)
 

Protected Member Functions

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

 TrackPanelResizerCell (const TrackPanelResizerCell &)=delete
 
TrackPanelResizerCelloperator= (const TrackPanelResizerCell &)=delete
 
void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
 

Private Attributes

std::weak_ptr< TrackmwTrack
 
std::weak_ptr< TrackPanelResizeHandlemResizeHandle
 

Additional Inherited Members

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

Detailed Description

Definition at line 20 of file TrackPanelResizerCell.h.

Constructor & Destructor Documentation

◆ TrackPanelResizerCell() [1/2]

TrackPanelResizerCell::TrackPanelResizerCell ( const TrackPanelResizerCell )
privatedelete

◆ TrackPanelResizerCell() [2/2]

TrackPanelResizerCell::TrackPanelResizerCell ( const std::shared_ptr< Track > &  pTrack)
explicit

Definition at line 27 of file TrackPanelResizerCell.cpp.

29  : mwTrack{ pTrack }
30 {}

Member Function Documentation

◆ DoFindTrack()

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

Implements CommonTrackPanelCell.

Definition at line 47 of file TrackPanelResizerCell.cpp.

48 {
49  return mwTrack.lock();
50 }

References mwTrack.

◆ Draw()

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

Reimplemented from TrackPanelDrawable.

Definition at line 52 of file TrackPanelResizerCell.cpp.

55 {
56  if ( iPass == TrackArtist::PassMargins ) {
57  auto pTrack = FindTrack();
58  if ( pTrack ) {
59  auto dc = &context.dc;
60  const bool last =
61  pTrack.get() == *TrackList::Channels( pTrack.get() ).rbegin();
62  if ( last ) {
63  // Fill in separator area below a track
64  AColor::TrackPanelBackground( dc, false );
65  dc->DrawRectangle( rect );
66  }
67  else {
68  // Area between channels of a group
69  // Paint the channel separator over (what would be) the lower border
70  // of this channel, down to and including the upper border of the
71  // next channel
72 
73  ADCChanger cleanup{ dc };
74 
75  // Paint the left part of the background
76  const auto artist = TrackArtist::Get( context );
77  auto labelw = artist->pZoomInfo->GetLeftOffset() - 1;
78  AColor::MediumTrackInfo( dc, pTrack->GetSelected() );
79  dc->DrawRectangle(
80  rect.GetX(), rect.GetY(), labelw, rect.GetHeight() );
81 
82  // Stroke the left border
83  dc->SetPen(*wxBLACK_PEN);
84  {
85  const auto left = rect.GetLeft();
86  AColor::Line( *dc, left, rect.GetTop(), left, rect.GetBottom() );
87  }
88 
90 
91  wxRect rec{ rect };
92  rec.width -= labelw - rec.x;
93  rec.x = labelw;
94 
95  dc->DrawRectangle( wxRect( rec ).Inflate( 0, -kBorderThickness ) );
96 
97  // These lines stroke over what is otherwise "border" of each
98  // channel
99  dc->SetBrush(*wxTRANSPARENT_BRUSH);
100  dc->SetPen(*wxBLACK_PEN);
101  const auto left = rec.GetLeft();
102  const auto right = rec.GetRight();
103  const auto top = rec.GetTop();
104  const auto bottom = rec.GetBottom();
105  AColor::Line( *dc, left, top, right, top );
106  AColor::Line( *dc, left, bottom, right, bottom );
107  }
108  }
109  }
110 }

References TrackList::Channels(), TrackPanelDrawingContext::dc, CommonTrackPanelCell::FindTrack(), TrackArtist::Get(), kBorderThickness, AColor::Line(), AColor::MediumTrackInfo(), TrackArtist::PassMargins, and AColor::TrackPanelBackground().

Here is the call graph for this function:

◆ Get() [1/2]

const TrackPanelResizerCell & TrackPanelResizerCell::Get ( const Track track)
static

Definition at line 124 of file TrackPanelResizerCell.cpp.

125 {
126  return Get( const_cast< Track & >( track ) );
127 }

References Get().

Here is the call graph for this function:

◆ Get() [2/2]

TrackPanelResizerCell & TrackPanelResizerCell::Get ( Track track)
static

Definition at line 119 of file TrackPanelResizerCell.cpp.

120 {
121  return track.AttachedObjects::Get< TrackPanelResizerCell >( key );
122 }

References key.

Referenced by anonymous_namespace{TrackPanel.cpp}::ResizingChannelGroup::Children(), anonymous_namespace{TrackPanel.cpp}::ChannelGroup::Children(), and Get().

Here is the caller graph for this function:

◆ HitTest()

std::vector< UIHandlePtr > TrackPanelResizerCell::HitTest ( const TrackPanelMouseState st,
const AudacityProject pProject 
)
overridevirtual

Implements TrackPanelCell.

Definition at line 32 of file TrackPanelResizerCell.cpp.

34 {
35  (void)pProject;// Compiler food
36  std::vector<UIHandlePtr> results;
37  auto pTrack = FindTrack();
38  if (pTrack) {
39  auto result = std::make_shared<TrackPanelResizeHandle>(
40  pTrack, st.state.m_y );
41  result = AssignUIHandlePtr(mResizeHandle, result);
42  results.push_back(result);
43  }
44  return results;
45 }

References AssignUIHandlePtr(), CommonTrackPanelCell::FindTrack(), mResizeHandle, and TrackPanelMouseState::state.

Here is the call graph for this function:

◆ operator=()

TrackPanelResizerCell& TrackPanelResizerCell::operator= ( const TrackPanelResizerCell )
privatedelete

Member Data Documentation

◆ mResizeHandle

std::weak_ptr<TrackPanelResizeHandle> TrackPanelResizerCell::mResizeHandle
private

Definition at line 50 of file TrackPanelResizerCell.h.

Referenced by HitTest().

◆ mwTrack

std::weak_ptr<Track> TrackPanelResizerCell::mwTrack
private

Definition at line 43 of file TrackPanelResizerCell.h.

Referenced by DoFindTrack().


The documentation for this class was generated from the following files:
AColor::TrackPanelBackground
static void TrackPanelBackground(wxDC *dc, bool selected)
Definition: AColor.cpp:365
key
static const AttachedTrackObjects::RegisteredFactory key
Definition: TrackPanelResizerCell.cpp:112
CommonTrackPanelCell::FindTrack
std::shared_ptr< Track > FindTrack()
Definition: CommonTrackPanelCell.h:46
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1484
AColor::Line
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:112
kBorderThickness
@ kBorderThickness
Definition: ZoomInfo.h:28
TrackPanelDrawingContext::dc
wxDC & dc
Definition: TrackPanelDrawingContext.h:23
TrackPanelResizerCell::mResizeHandle
std::weak_ptr< TrackPanelResizeHandle > mResizeHandle
Definition: TrackPanelResizerCell.h:50
TrackArtist::Get
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:79
ADCChanger
Makes temporary drawing context changes that you back out of, RAII style.
Definition: OverlayPanel.h:72
AColor::MediumTrackInfo
static void MediumTrackInfo(wxDC *dc, bool selected)
Definition: AColor.cpp:344
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
TrackPanelResizerCell
Definition: TrackPanelResizerCell.h:24
TrackArtist::PassMargins
@ PassMargins
Definition: TrackArtist.h:82
AssignUIHandlePtr
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:151
TrackPanelMouseState::state
wxMouseState & state
Definition: TrackPanelMouseEvent.h:38
TrackPanelResizerCell::Get
static TrackPanelResizerCell & Get(Track &track)
Definition: TrackPanelResizerCell.cpp:119
TrackPanelResizerCell::mwTrack
std::weak_ptr< Track > mwTrack
Definition: TrackPanelResizerCell.h:43