Skip to content

Commit

Permalink
Free CommonTrackInfo from dependency cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Licameli committed Nov 8, 2023
1 parent fd80933 commit f274c8b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/tracks/playabletrack/ui/PlayableTrackControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ const TCPLines& PlayableTrackControls::StaticNoteTCPLines()
static TCPLines playableTrackTCPLines;
static std::once_flag flag;
std::call_once( flag, []{
playableTrackTCPLines = CommonTrackControls::StaticTCPLines();
playableTrackTCPLines = CommonTrackInfo::StaticTCPLines();
playableTrackTCPLines.insert( playableTrackTCPLines.end(), {
{ TCPLine::kItemMute | TCPLine::kItemSolo, kTrackInfoBtnSize + 1, 0,
MuteAndSoloDrawFunction },
Expand All @@ -269,7 +269,7 @@ const TCPLines& PlayableTrackControls::StaticWaveTCPLines()
static TCPLines playableTrackTCPLines;
static std::once_flag flag;
std::call_once( flag, []{
playableTrackTCPLines = CommonTrackControls::StaticTCPLines();
playableTrackTCPLines = CommonTrackInfo::StaticTCPLines();
playableTrackTCPLines.insert( playableTrackTCPLines.end(), {
{ TCPLine::kItemMute | TCPLine::kItemSolo, kTrackInfoBtnSize + 1, 0,
MuteAndSoloDrawFunction },
Expand Down
5 changes: 5 additions & 0 deletions src/tracks/ui/CommonTrackControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,3 +425,8 @@ wxRect CommonTrackControls::DrawingArea(
else
return rect;
}

const TCPLines &CommonTrackControls::GetTCPLines() const
{
return CommonTrackInfo::StaticTCPLines();
}
7 changes: 1 addition & 6 deletions src/tracks/ui/CommonTrackControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ class AUDACITY_DLL_API CommonTrackControls /* not final */ : public TrackControl
unsigned result;
};

// This decides what details to draw in the track control panel, besides
// those at the bottom
virtual const TCPLines& GetTCPLines() const;

// To help subclasses define GetTCPLines
static const TCPLines& StaticTCPLines();
const TCPLines& GetTCPLines() const override;

protected:
// An override is supplied for derived classes to call through but it is
Expand Down
12 changes: 3 additions & 9 deletions src/tracks/ui/CommonTrackInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Paul Licameli split from TrackInfo.cpp
#include "SyncLock.h"
#include "Theme.h"
#include "Track.h"
#include "TrackControls.h"
#include "TrackPanelDrawingContext.h"
#include "UIHandle.h"
#include "ViewInfo.h"
Expand Down Expand Up @@ -59,8 +60,7 @@ static const TCPLines &commonTrackTCPLines()
return theLines;
}

#include "tracks/ui/CommonTrackControls.h"
const TCPLines &CommonTrackControls::StaticTCPLines()
const TCPLines &CommonTrackInfo::StaticTCPLines()
{
return commonTrackTCPLines();
}
Expand Down Expand Up @@ -111,11 +111,6 @@ std::pair< int, int > CalcBottomItemY

}

const TCPLines &CommonTrackControls::GetTCPLines() const
{
return commonTrackTCPLines();
}

unsigned CommonTrackInfo::MinimumTrackHeight()
{
unsigned height = 0;
Expand All @@ -141,8 +136,7 @@ void CommonTrackInfo::DrawItems
( TrackPanelDrawingContext &context,
const wxRect &rect, const Track &track )
{
auto &trackControl = static_cast<const CommonTrackControls&>(
TrackControls::Get( track ) );
auto &trackControl = TrackControls::Get(track);
const auto &topLines = trackControl.GetTCPLines();
const auto &bottomLines = commonTrackTCPBottomLines;
DrawItems
Expand Down
4 changes: 4 additions & 0 deletions src/tracks/ui/CommonTrackInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ namespace CommonTrackInfo
AUDACITY_DLL_API
bool HideTopItem( const wxRect &rect, const wxRect &subRect,
int allowance = 0 );

// To help subclasses define GetTCPLines
AUDACITY_DLL_API
const TCPLines& StaticTCPLines();
};

#endif
5 changes: 5 additions & 0 deletions src/tracks/ui/TrackControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Paul Licameli split from TrackPanel.cpp
#define __AUDACITY_TRACK_CONTROLS__

#include "CommonTrackPanelCell.h"
#include "TrackInfo.h"

class Track;

Expand All @@ -26,6 +27,10 @@ class AUDACITY_DLL_API TrackControls /* not final */ : public CommonTrackCell
TrackControls( std::shared_ptr<Track> pTrack );

virtual ~TrackControls() = 0;

// This decides what details to draw in the track control panel, besides
// those at the bottom
virtual const TrackInfo::TCPLines& GetTCPLines() const = 0;
};

#include "AttachedVirtualFunction.h"
Expand Down

0 comments on commit f274c8b

Please sign in to comment.