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 1074 of file TrackPanel.cpp.

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

Function Documentation

◆ DrawTrackName()

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

Definition at line 1104 of file TrackPanel.cpp.

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

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 871 of file TrackPanel.cpp.

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

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 521 of file TrackPanel.cpp.

522 {
523 if (pCell)
524 return static_cast<CommonTrackPanelCell*>( pCell )->FindTrack();
525 return {};
526 }
std::shared_ptr< Track > FindTrack(TrackPanelCell *pCell)
Definition: TrackPanel.cpp:521

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 1083 of file TrackPanel.cpp.

1085{
1086 wxFont labelFont(12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
1087 dc.SetFont(labelFont);
1088 dc.GetTextExtent( t->GetName(), pW, pH );
1089}

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 1091 of file TrackPanel.cpp.

1094{
1095 return {
1096 leftOffset + DisplaceX,
1097 trackRect.y + DisplaceY,
1098 textWidth + MarginsX,
1099 textHeight + MarginsY
1100 };
1101}

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:90
static ProjectWindow & Get(AudacityProject &project)
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:385
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 207 of file TrackPanel.cpp.

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