Audacity 3.2.0
Classes | Enumerations | Functions | Variables
anonymous_namespace{TrackPanel.cpp} Namespace Reference

Classes

struct  ChannelStack
 
struct  EmptyCell
 
struct  HorizontalGroup
 
struct  LabeledChannelGroup
 
struct  MainGroup
 
struct  ResizingChannelGroup
 
struct  Subgroup
 
struct  VRulerAndChannel
 
struct  VRulersAndChannels
 

Enumerations

enum  : int {
  DisplaceX = 7 , DisplaceY = 1 , MarginX = 8 , MarginY = 2 ,
  MarginsX = 2 * MarginX , MarginsY = 2 * MarginY
}
 

Functions

std::shared_ptr< TrackFindTrack (TrackPanelCell *pCell)
 
std::vector< int > FindAdjustedChannelHeights (Track &t)
 
TrackGetTrack (Channel &channel)
 
const TrackGetTrack (const Channel &channel)
 
void GetTrackNameExtent (wxDC &dc, const Channel &channel, wxCoord *pW, wxCoord *pH)
 
wxRect GetTrackNameRect (int leftOffset, const wxRect &trackRect, wxCoord textWidth, wxCoord textHeight)
 

Variables

AttachedWindows::RegisteredFactory sKey
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum : int
Enumerator
DisplaceX 
DisplaceY 
MarginX 
MarginY 
MarginsX 
MarginsY 

Definition at line 1027 of file TrackPanel.cpp.

1027 : int {
1028 // Displacement of the rectangle from upper left corner
1029 DisplaceX = 7, DisplaceY = 1,
1030 // Size of margins about the text extent that determine the rectangle size
1031 MarginX = 8, MarginY = 2,
1032 // Derived constants
1033 MarginsX = 2 * MarginX, MarginsY = 2 * MarginY,
1034 };

Function Documentation

◆ FindAdjustedChannelHeights()

std::vector< int > anonymous_namespace{TrackPanel.cpp}::FindAdjustedChannelHeights ( Track t)

Definition at line 896 of file TrackPanel.cpp.

897{
898 auto channels = t.Channels();
899 assert(!channels.empty());
900
901 // Collect heights, and count affordances
902 int nAffordances = 0;
903 int totalHeight = 0;
904 std::vector<int> oldHeights;
905 for (auto pChannel : channels) {
906 auto &view = ChannelView::Get(*pChannel);
907 const auto height = view.GetHeight();
908 totalHeight += height;
909 oldHeights.push_back(height);
910 if (view.GetAffordanceControls())
911 ++nAffordances;
912 }
913
914 // Allocate results
915 auto nChannels = static_cast<int>(oldHeights.size());
916 std::vector<int> results;
917 results.reserve(nChannels);
918
919 // Now reallocate the channel heights for the presence of affordances
920 // and separators
921 auto availableHeight = totalHeight
922 - nAffordances * kAffordancesAreaHeight
923 - (nChannels - 1) * kChannelSeparatorThickness
925 int cumulativeOldHeight = 0;
926 int cumulativeNewHeight = 0;
927 for (const auto &oldHeight : oldHeights) {
928 // Preserve the porportions among the stored heights
929 cumulativeOldHeight += oldHeight;
930 const auto newHeight =
931 cumulativeOldHeight * availableHeight / totalHeight
932 - cumulativeNewHeight;
933 cumulativeNewHeight += newHeight;
934 results.push_back(newHeight);
935 }
936
937 return results;
938}
@ kTrackSeparatorThickness
@ kChannelSeparatorThickness
@ kAffordancesAreaHeight
IteratorRange< ChannelIterator< ChannelType > > Channels()
Get range of channels with mutative access.
Definition: Channel.h:384
static ChannelView & Get(Channel &channel)

References ChannelGroup::Channels(), ChannelView::Get(), kAffordancesAreaHeight, kChannelSeparatorThickness, and kTrackSeparatorThickness.

Referenced by anonymous_namespace{TrackPanel.cpp}::ChannelStack::Children(), anonymous_namespace{TrackPanel.cpp}::ChannelStack::Draw(), and TrackPanel::UpdateTrackVRuler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindTrack()

std::shared_ptr< Track > anonymous_namespace{TrackPanel.cpp}::FindTrack ( TrackPanelCell pCell)

Definition at line 538 of file TrackPanel.cpp.

539 {
540 if (pCell)
541 // FindTrack as applied through the CommonTrackPanelCell interface
542 // will really find a track, though for now it finds a left or right
543 // channel.
544 return static_cast<CommonTrackPanelCell*>(pCell)->FindTrack();
545 return {};
546 }
std::shared_ptr< Track > FindTrack(TrackPanelCell *pCell)
Definition: TrackPanel.cpp:538

References FindTrack().

Referenced by FindTrack(), TrackPanel::OnMouseEvent(), and TrackPanel::ProcessUIHandleResult().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTrack() [1/2]

Track & anonymous_namespace{TrackPanel.cpp}::GetTrack ( Channel channel)

Definition at line 1036 of file TrackPanel.cpp.

1037{
1038 // It is assumed that all channels we ever see are in groups that are
1039 // also Tracks
1040 return static_cast<Track &>(channel.GetChannelGroup());
1041}
ChannelGroup & GetChannelGroup()
Channel object's lifetime is assumed to be nested in its Track's.
Definition: Channel.cpp:43
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110

References Channel::GetChannelGroup().

Here is the call graph for this function:

◆ GetTrack() [2/2]

const Track & anonymous_namespace{TrackPanel.cpp}::GetTrack ( const Channel channel)

Definition at line 1043 of file TrackPanel.cpp.

1044{
1045 // It is assumed that all channels we ever see are in groups that are
1046 // also Tracks
1047 return static_cast<const Track &>(channel.GetChannelGroup());
1048}

References Channel::GetChannelGroup().

Referenced by GetTrackNameExtent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTrackNameExtent()

void anonymous_namespace{TrackPanel.cpp}::GetTrackNameExtent ( wxDC &  dc,
const Channel channel,
wxCoord *  pW,
wxCoord *  pH 
)

Definition at line 1050 of file TrackPanel.cpp.

1052{
1053 wxFont labelFont(12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
1054 dc.SetFont(labelFont);
1055 dc.GetTextExtent(GetTrack(channel).GetName(), pW, pH);
1056}
const Track & GetTrack(const Channel &channel)

References GetTrack().

Here is the call graph for this function:

◆ GetTrackNameRect()

wxRect anonymous_namespace{TrackPanel.cpp}::GetTrackNameRect ( int  leftOffset,
const wxRect &  trackRect,
wxCoord  textWidth,
wxCoord  textHeight 
)

Definition at line 1058 of file TrackPanel.cpp.

1061{
1062 return {
1063 leftOffset + DisplaceX,
1064 trackRect.y + DisplaceY,
1065 textWidth + MarginsX,
1066 textHeight + MarginsY
1067 };
1068}

References DisplaceX, DisplaceY, MarginsX, and MarginsY.

Variable Documentation

◆ sKey

AttachedWindows::RegisteredFactory anonymous_namespace{TrackPanel.cpp}::sKey
Initial value:
{
[]( AudacityProject &project ) -> wxWeakRef< wxWindow > {
auto &viewInfo = ViewInfo::Get( project );
auto &window = ProjectWindow::Get( project );
auto mainPage = window.GetTrackListWindow();
wxASSERT( mainPage );
auto result = safenew TrackPanel(mainPage,
window.NextWindowID(),
wxDefaultPosition,
wxDefaultSize,
tracks.shared_from_this(),
&viewInfo,
&ruler);
SetProjectPanel( project, *result );
return result;
}
}
#define safenew
Definition: MemoryX.h:10
AUDACITY_DLL_API void SetProjectPanel(AudacityProject &project, wxWindow &panel)
const auto tracks
const auto project
static AdornedRulerPanel & Get(AudacityProject &project)
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 ProjectWindow & Get(AudacityProject &project)
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
Definition: TrackPanel.h:63
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

Definition at line 210 of file TrackPanel.cpp.

Referenced by TrackPanel::Destroy(), and TrackPanel::Get().