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

Classes

struct  ChannelGroup
 
struct  EmptyCell
 
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)
 
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

AudacityProject::AttachedWindows::RegisteredFactory sKey
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum : int
Enumerator
DisplaceX 
DisplaceY 
MarginX 
MarginY 
MarginsX 
MarginsY 

Definition at line 1021 of file TrackPanel.cpp.

1021  : int {
1022  // Displacement of the rectangle from upper left corner
1023  DisplaceX = 7, DisplaceY = 1,
1024  // Size of margins about the text extent that determine the rectangle size
1025  MarginX = 8, MarginY = 2,
1026  // Derived constants
1027  MarginsX = 2 * MarginX, MarginsY = 2 * MarginY,
1028  };

Function Documentation

◆ DrawTrackName()

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

Definition at line 1051 of file TrackPanel.cpp.

1054 {
1055  if( !TrackArtist::Get( context )->mbShowTrackNameInTrack )
1056  return;
1057  auto name = t->GetName();
1058  if( name.IsEmpty())
1059  return;
1060  if( !t->IsLeader())
1061  return;
1062  auto &dc = context.dc;
1063  wxBrush Brush;
1064  wxCoord textWidth, textHeight;
1065  GetTrackNameExtent( dc, t, &textWidth, &textHeight );
1066 
1067  // Logic for name background translucency (aka 'shields')
1068  // Tracks less than kOpaqueHeight high will have opaque shields.
1069  // Tracks more than kTranslucentHeight will have maximum translucency for shields.
1070  const int kOpaqueHeight = 44;
1071  const int kTranslucentHeight = 124;
1072  int h = TrackView::Get( *t ).GetHeight();
1073  // f codes the opacity as a number between 0.0 and 1.0
1074  float f = wxClip((h-kOpaqueHeight)/(float)(kTranslucentHeight-kOpaqueHeight),0.0,1.0);
1075  // kOpaque is the shield's alpha for tracks that are not tall
1076  // kTranslucent is the shield's alpha for tracks that are tall.
1077  const int kOpaque = 255;
1078  const int kTranslucent = 140;
1079  // 0.0 maps to full opacity, 1.0 maps to full translucency.
1080  int opacity = 255 - (255-140)*f;
1081 
1082  const auto nameRect =
1083  GetTrackNameRect( leftOffset, rect, textWidth, textHeight );
1084 
1085 #ifdef __WXMAC__
1086  // Mac dc is a graphics dc already.
1087  AColor::UseThemeColour( &dc, clrTrackInfoSelected, clrTrackPanelText, opacity );
1088  dc.DrawRoundedRectangle( nameRect, 8.0 );
1089 #else
1090  // This little dance with wxImage in order to draw to a graphic dc
1091  // which we can then paste as a translucent bitmap onto the real dc.
1092  enum : int {
1093  SecondMarginX = 1, SecondMarginY = 1,
1094  SecondMarginsX = 2 * SecondMarginX, SecondMarginsY = 2 * SecondMarginY,
1095  };
1096  wxImage image(
1097  textWidth + MarginsX + SecondMarginsX,
1098  textHeight + MarginsY + SecondMarginsY );
1099  image.InitAlpha();
1100  unsigned char *alpha=image.GetAlpha();
1101  memset(alpha, wxIMAGE_ALPHA_TRANSPARENT, image.GetWidth()*image.GetHeight());
1102 
1103  {
1104  std::unique_ptr< wxGraphicsContext >
1105  pGc{ wxGraphicsContext::Create(image) };
1106  auto &gc = *pGc;
1107  // This is to a gc, not a dc.
1108  AColor::UseThemeColour( &gc, clrTrackInfoSelected, clrTrackPanelText, opacity );
1109  // Draw at 1,1, not at 0,0 to avoid clipping of the antialiasing.
1110  gc.DrawRoundedRectangle(
1111  SecondMarginX, SecondMarginY,
1112  textWidth + MarginsX, textHeight + MarginsY, 8.0 );
1113  // destructor of gc updates the wxImage.
1114  }
1115  wxBitmap bitmap( image );
1116  dc.DrawBitmap( bitmap,
1117  nameRect.x - SecondMarginX, nameRect.y - SecondMarginY );
1118 #endif
1119  dc.SetTextForeground(theTheme.Colour( clrTrackPanelText ));
1120  dc.DrawText(t->GetName(),
1121  nameRect.x + MarginX,
1122  nameRect.y + MarginY);
1123 }

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:

◆ FindTrack()

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

Definition at line 525 of file TrackPanel.cpp.

526  {
527  if (pCell)
528  return static_cast<CommonTrackPanelCell*>( pCell )->FindTrack();
529  return {};
530  }

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

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

1032 {
1033  wxFont labelFont(12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
1034  dc.SetFont(labelFont);
1035  dc.GetTextExtent( t->GetName(), pW, pH );
1036 }

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

1041 {
1042  return {
1043  leftOffset + DisplaceX,
1044  trackRect.y + DisplaceY,
1045  textWidth + MarginsX,
1046  textHeight + MarginsY
1047  };
1048 }

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

AudacityProject::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.GetMainPage();
wxASSERT( mainPage );
auto &tracks = TrackList::Get( project );
auto result = safenew TrackPanel(mainPage,
window.NextWindowID(),
wxDefaultPosition,
wxDefaultSize,
tracks.shared_from_this(),
&viewInfo,
&project,
&ruler);
project.SetPanel( result );
return result;
}
}

Definition at line 198 of file TrackPanel.cpp.

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

anonymous_namespace{TrackPanel.cpp}::MarginsY
@ MarginsY
Definition: TrackPanel.cpp:1027
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:156
AColor::UseThemeColour
static void UseThemeColour(wxDC *dc, int iBrush, int iPen=-1, int alpha=255)
Definition: AColor.cpp:283
TrackView::Get
static TrackView & Get(Track &)
Definition: TrackView.cpp:63
Track::GetName
wxString GetName() const
Definition: Track.h:409
anonymous_namespace{TrackPanel.cpp}::DisplaceX
@ DisplaceX
Definition: TrackPanel.cpp:1023
TrackPanelDrawingContext::dc
wxDC & dc
Definition: TrackPanelDrawingContext.h:23
ProjectWindow::Get
static ProjectWindow & Get(AudacityProject &project)
Definition: ProjectWindow.cpp:532
anonymous_namespace{TrackPanel.cpp}::MarginX
@ MarginX
Definition: TrackPanel.cpp:1025
anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler
Ruler & ruler()
Definition: TimeTrackVRulerControls.cpp:34
TrackPanel
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
Definition: TrackPanel.h:64
AdornedRulerPanel::Get
static AdornedRulerPanel & Get(AudacityProject &project)
Definition: AdornedRulerPanel.cpp:873
TrackArtist::Get
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:75
anonymous_namespace{TrackPanel.cpp}::DisplaceY
@ DisplaceY
Definition: TrackPanel.cpp:1023
name
const TranslatableString name
Definition: Distortion.cpp:98
anonymous_namespace{TrackPanel.cpp}::FindTrack
std::shared_ptr< Track > FindTrack(TrackPanelCell *pCell)
Definition: TrackPanel.cpp:525
anonymous_namespace{TrackPanel.cpp}::MarginsX
@ MarginsX
Definition: TrackPanel.cpp:1027
anonymous_namespace{TrackPanel.cpp}::GetTrackNameExtent
void GetTrackNameExtent(wxDC &dc, const Track *t, wxCoord *pW, wxCoord *pH)
Definition: TrackPanel.cpp:1030
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:495
Track::IsLeader
bool IsLeader() const
Definition: Track.cpp:370
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:112
ThemeBase::Colour
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1193
anonymous_namespace{TrackPanel.cpp}::MarginY
@ MarginY
Definition: TrackPanel.cpp:1025
theTheme
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:202
anonymous_namespace{TrackPanel.cpp}::GetTrackNameRect
wxRect GetTrackNameRect(int leftOffset, const wxRect &trackRect, wxCoord textWidth, wxCoord textHeight)
Definition: TrackPanel.cpp:1038
CommonTrackPanelCell
Definition: CommonTrackPanelCell.h:26
safenew
#define safenew
Definition: MemoryX.h:10
TrackView::GetHeight
int GetHeight() const
Definition: TrackView.cpp:149