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

Classes

struct  BeatsGridlinePainter
 
struct  ClipTitle
 

Enumerations

enum class  HAlign { left , right }
 

Functions

wxRect GetAffordanceTitleRect (const wxRect &rect)
 
wxString GetPlaybackSpeedFullText (double clipStretchRatio)
 
std::optional< ClipTitleDoDrawAudioTitle (wxDC &dc, const wxRect &titleRect, const wxString &title)
 

Variables

constexpr double minSubdivisionWidth = 12.0
 

Enumeration Type Documentation

◆ HAlign

enum class anonymous_namespace{TrackArt.cpp}::HAlign
strong
Enumerator
left 
right 

Definition at line 292 of file TrackArt.cpp.

Function Documentation

◆ DoDrawAudioTitle()

std::optional< ClipTitle > anonymous_namespace{TrackArt.cpp}::DoDrawAudioTitle ( wxDC &  dc,
const wxRect &  titleRect,
const wxString &  title 
)

Definition at line 303 of file TrackArt.cpp.

305{
306 if(titleRect.IsEmpty())
307 return std::nullopt;
308 const auto hAlign = wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft ?
309 HAlign::right :
310 HAlign::left;
311 if(title.empty())
312 return ClipTitle { "", hAlign };
313 auto truncatedTitle = TrackArt::TruncateText(dc, title, titleRect.GetWidth());
314 if (!truncatedTitle.empty())
315 {
316 dc.DrawLabel(
317 truncatedTitle, titleRect,
318 (hAlign == HAlign::left ? wxALIGN_LEFT : wxALIGN_RIGHT) |
319 wxALIGN_CENTER_VERTICAL);
320 return ClipTitle{ truncatedTitle, hAlign };
321 }
322 return std::nullopt;
323}
static const auto title
AUDACITY_DLL_API wxString TruncateText(wxDC &dc, const wxString &text, const int maxWidth)
Definition: TrackArt.cpp:166

References title, and TrackArt::TruncateText().

Referenced by TrackArt::DrawAudioClipTitle(), and TrackArt::DrawClipTitle().

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

◆ GetAffordanceTitleRect()

wxRect anonymous_namespace{TrackArt.cpp}::GetAffordanceTitleRect ( const wxRect &  rect)

Definition at line 45 of file TrackArt.cpp.

46 {
47 constexpr int FrameThickness{ 1 };
48 return wxRect(
49 rect.GetLeft() + TrackArt::ClipFrameRadius,
50 rect.GetTop() + ClipSelectionStrokeSize + FrameThickness,
51 rect.GetWidth() - TrackArt::ClipFrameRadius * 2,
52 rect.GetHeight() - ClipSelectionStrokeSize - FrameThickness);
53 }
static constexpr int ClipSelectionStrokeSize
Definition: TrackArt.cpp:38
static constexpr int ClipFrameRadius
Definition: TrackArt.h:23

References TrackArt::ClipFrameRadius, and ClipSelectionStrokeSize.

Referenced by TrackArt::DrawClipAffordance().

Here is the caller graph for this function:

◆ GetPlaybackSpeedFullText()

wxString anonymous_namespace{TrackArt.cpp}::GetPlaybackSpeedFullText ( double  clipStretchRatio)

Definition at line 253 of file TrackArt.cpp.

254{
255 // clang-format off
256 // We reckon that most of the time, a rounded percentage value is sufficient.
257 // There are two exceptions:
258 // - The clip is only slightly stretched such that the rounded value is 100.
259 // There should be an indicator if and only if the clip is stretched, this
260 // must be reliable. Yet showing "100%" would be confusing. Hence in that
261 // case we constrain the values to [99.1, ..., 99.9, 100.1,
262 // ..., 100.9], i.e., omitting 100.0.
263 // - The clip is stretched so much that the playback speed is less than 1%.
264 // Make sure in that case that we never show 0%, but always at least 0.1%.
265 // clang-format on
266
267 const auto playbackSpeed = 100 / clipStretchRatio;
268 wxString fullText;
269
270 // We compare with .95 rather than 1, since playback speeds within [100.95,
271 // 101) get rounded to 101.0 and (99, 99.05] to 99.0 by `wxString::Format`.
272 // Let these be processed by the integer-display branch of this if statement
273 // instead.
274 if (fabs(playbackSpeed - 100.) < .95)
275 // Never show 100.0%
276 fullText = wxString::Format(
277 "%.1f%% speed", playbackSpeed > 100 ?
278 std::max(playbackSpeed, 100.1) :
279 std::min(playbackSpeed, 99.9));
280 else if (playbackSpeed < 1)
281 // Never show 0.0%
282 fullText =
283 wxString::Format("%.1f%% speed", std::max(playbackSpeed, 0.1));
284 else {
285 const auto roundedPlaybackSpeed =
286 static_cast<int>(std::round(playbackSpeed));
287 fullText = wxString::Format("%d%% speed", roundedPlaybackSpeed);
288 }
289 return fullText;
290}
int min(int a, int b)
fastfloat_really_inline void round(adjusted_mantissa &am, callback cb) noexcept
Definition: fast_float.h:2512

References min(), and fast_float::round().

Referenced by TrackArt::DrawAudioClipTitle().

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

Variable Documentation

◆ minSubdivisionWidth

constexpr double anonymous_namespace{TrackArt.cpp}::minSubdivisionWidth = 12.0
constexpr