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

Classes

struct  ChannelGroup
 
struct  EmptyCell
 
class  EmptyPanelRect
 
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)
 
void GetTrackNameExtent (wxDC &dc, const Track *t, wxCoord *pW, wxCoord *pH)
 
wxRect GetTrackNameRect (int leftOffset, const wxRect &trackRect, wxCoord textWidth, wxCoord textHeight)
 
void DrawTrackName (int leftOffset, TrackPanelDrawingContext &context, const Track *t, const wxRect &rect)
 

Variables

AttachedWindows::RegisteredFactory sKey
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum : int
Enumerator
DisplaceX 
DisplaceY 
MarginX 
MarginY 
MarginsX 
MarginsY 

Definition at line 1079 of file TrackPanel.cpp.

1079 : int {
1080 // Displacement of the rectangle from upper left corner
1081 DisplaceX = 7, DisplaceY = 1,
1082 // Size of margins about the text extent that determine the rectangle size
1083 MarginX = 8, MarginY = 2,
1084 // Derived constants
1085 MarginsX = 2 * MarginX, MarginsY = 2 * MarginY,
1086 };

Function Documentation

◆ DrawTrackName()

void anonymous_namespace{TrackPanel.cpp}::DrawTrackName ( int  leftOffset,
TrackPanelDrawingContext context,
const Track t,
const wxRect &  rect 
)

Definition at line 1109 of file TrackPanel.cpp.

1112{
1113 if( !TrackArtist::Get( context )->mbShowTrackNameInTrack )
1114 return;
1115 auto name = t->GetName();
1116 if( name.IsEmpty())
1117 return;
1118 if( !t->IsLeader())
1119 return;
1120 auto &dc = context.dc;
1121 wxBrush Brush;
1122 wxCoord textWidth, textHeight;
1123 GetTrackNameExtent( dc, t, &textWidth, &textHeight );
1124
1125 // Logic for name background translucency (aka 'shields')
1126 // Tracks less than kOpaqueHeight high will have opaque shields.
1127 // Tracks more than kTranslucentHeight will have maximum translucency for shields.
1128 const int kOpaqueHeight = 44;
1129 const int kTranslucentHeight = 124;
1130
1131 // PRL: to do: reexamine this strange use of TrackView::GetHeight,
1132 // ultimately to compute an opacity
1133 int h = TrackView::Get( *t ).GetHeight();
1134
1135 // f codes the opacity as a number between 0.0 and 1.0
1136 float f = wxClip((h-kOpaqueHeight)/(float)(kTranslucentHeight-kOpaqueHeight),0.0,1.0);
1137 // kOpaque is the shield's alpha for tracks that are not tall
1138 // kTranslucent is the shield's alpha for tracks that are tall.
1139 const int kOpaque = 255;
1140 const int kTranslucent = 140;
1141 // 0.0 maps to full opacity, 1.0 maps to full translucency.
1142 int opacity = 255 - (255-140)*f;
1143
1144 const auto nameRect =
1145 GetTrackNameRect( leftOffset, rect, textWidth, textHeight );
1146
1147#ifdef __WXMAC__
1148 // Mac dc is a graphics dc already.
1149 AColor::UseThemeColour( &dc, clrTrackInfoSelected, clrTrackPanelText, opacity );
1150 dc.DrawRoundedRectangle( nameRect, 8.0 );
1151#else
1152 // This little dance with wxImage in order to draw to a graphic dc
1153 // which we can then paste as a translucent bitmap onto the real dc.
1154 enum : int {
1155 SecondMarginX = 1, SecondMarginY = 1,
1156 SecondMarginsX = 2 * SecondMarginX, SecondMarginsY = 2 * SecondMarginY,
1157 };
1158 wxImage image(
1159 textWidth + MarginsX + SecondMarginsX,
1160 textHeight + MarginsY + SecondMarginsY );
1161 image.InitAlpha();
1162 unsigned char *alpha=image.GetAlpha();
1163 memset(alpha, wxIMAGE_ALPHA_TRANSPARENT, image.GetWidth()*image.GetHeight());
1164
1165 {
1166 std::unique_ptr< wxGraphicsContext >
1167 pGc{ wxGraphicsContext::Create(image) };
1168 auto &gc = *pGc;
1169 // This is to a gc, not a dc.
1170 AColor::UseThemeColour( &gc, clrTrackInfoSelected, clrTrackPanelText, opacity );
1171 // Draw at 1,1, not at 0,0 to avoid clipping of the antialiasing.
1172 gc.DrawRoundedRectangle(
1173 SecondMarginX, SecondMarginY,
1174 textWidth + MarginsX, textHeight + MarginsY, 8.0 );
1175 // destructor of gc updates the wxImage.
1176 }
1177 wxBitmap bitmap( image );
1178 dc.DrawBitmap( bitmap,
1179 nameRect.x - SecondMarginX, nameRect.y - SecondMarginY );
1180#endif
1181 dc.SetTextForeground(theTheme.Colour( clrTrackPanelText ));
1182 dc.DrawText(t->GetName(),
1183 nameRect.x + MarginX,
1184 nameRect.y + MarginY);
1185}
const TranslatableString name
Definition: Distortion.cpp:82
THEME_API Theme theTheme
Definition: Theme.cpp:82
static void UseThemeColour(wxDC *dc, int iBrush, int iPen=-1, int alpha=255)
Definition: AColor.cpp:349
wxColour & Colour(int iIndex)
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:69
wxString GetName() const
Definition: Track.h:466
bool IsLeader() const
Definition: Track.cpp:405
int GetHeight() const
Definition: TrackView.cpp:164
static TrackView & Get(Track &)
Definition: TrackView.cpp:69
wxRect GetTrackNameRect(int leftOffset, const wxRect &trackRect, wxCoord textWidth, wxCoord textHeight)
void GetTrackNameExtent(wxDC &dc, const Track *t, wxCoord *pW, wxCoord *pH)

References ThemeBase::Colour(), TrackPanelDrawingContext::dc, TrackView::Get(), TrackArtist::Get(), TrackView::GetHeight(), Track::GetName(), GetTrackNameExtent(), GetTrackNameRect(), Track::IsLeader(), MarginsX, MarginsY, MarginX, MarginY, name, theTheme, and AColor::UseThemeColour().

Referenced by anonymous_namespace{TrackPanel.cpp}::VRulersAndChannels::Draw().

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

◆ FindAdjustedChannelHeights()

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

Definition at line 876 of file TrackPanel.cpp.

877{
878 auto channels = TrackList::Channels(&t);
879 wxASSERT(!channels.empty());
880
881 // Collect heights, and count affordances
882 int nAffordances = 0;
883 int totalHeight = 0;
884 std::vector<int> oldHeights;
885 for (auto channel : channels) {
886 auto &view = TrackView::Get( *channel );
887 const auto height = view.GetHeight();
888 totalHeight += height;
889 oldHeights.push_back( height );
890 if (view.GetAffordanceControls())
891 ++nAffordances;
892 }
893
894 // Allocate results
895 auto nChannels = static_cast<int>(oldHeights.size());
896 std::vector<int> results;
897 results.reserve(nChannels);
898
899 // Now reallocate the channel heights for the presence of affordances
900 // and separators
901 auto availableHeight = totalHeight
902 - nAffordances * kAffordancesAreaHeight
903 - (nChannels - 1) * kChannelSeparatorThickness
905 int cumulativeOldHeight = 0;
906 int cumulativeNewHeight = 0;
907 for (const auto &oldHeight : oldHeights) {
908 // Preserve the porportions among the stored heights
909 cumulativeOldHeight += oldHeight;
910 const auto newHeight =
911 cumulativeOldHeight * availableHeight / totalHeight
912 - cumulativeNewHeight;
913 cumulativeNewHeight += newHeight;
914 results.push_back(newHeight);
915 }
916
917 return results;
918}
@ kTrackSeparatorThickness
@ kChannelSeparatorThickness
@ kAffordancesAreaHeight
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1539

References TrackList::Channels(), TrackView::Get(), kAffordancesAreaHeight, kChannelSeparatorThickness, and kTrackSeparatorThickness.

Referenced by anonymous_namespace{TrackPanel.cpp}::ChannelGroup::Children(), anonymous_namespace{TrackPanel.cpp}::ChannelGroup::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 526 of file TrackPanel.cpp.

527 {
528 if (pCell)
529 return static_cast<CommonTrackPanelCell*>( pCell )->FindTrack();
530 return {};
531 }
std::shared_ptr< Track > FindTrack(TrackPanelCell *pCell)
Definition: TrackPanel.cpp:526

References FindTrack().

Referenced by MenuButtonHandle::CommitChanges(), StretchHandle::Drag(), FindTrack(), WaveTrackSubView::GetMenuItems(), CloseButtonHandle::HitTest(), MenuButtonHandle::HitTest(), MinimizeButtonHandle::HitTest(), SelectButtonHandle::HitTest(), TrackPanel::OnMouseEvent(), and TrackPanel::ProcessUIHandleResult().

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 Track t,
wxCoord *  pW,
wxCoord *  pH 
)

Definition at line 1088 of file TrackPanel.cpp.

1090{
1091 wxFont labelFont(12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
1092 dc.SetFont(labelFont);
1093 dc.GetTextExtent( t->GetName(), pW, pH );
1094}

References Track::GetName().

Referenced by anonymous_namespace{TrackPanel.cpp}::VRulersAndChannels::DrawingArea(), and DrawTrackName().

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

◆ GetTrackNameRect()

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

Definition at line 1096 of file TrackPanel.cpp.

1099{
1100 return {
1101 leftOffset + DisplaceX,
1102 trackRect.y + DisplaceY,
1103 textWidth + MarginsX,
1104 textHeight + MarginsY
1105 };
1106}

References DisplaceX, DisplaceY, MarginsX, and MarginsY.

Referenced by anonymous_namespace{TrackPanel.cpp}::VRulersAndChannels::DrawingArea(), and DrawTrackName().

Here is the caller graph for this function:

Variable Documentation

◆ sKey

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

Definition at line 206 of file TrackPanel.cpp.

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