Audacity 3.2.0
Namespaces | Functions | Variables
LabelTrack.cpp File Reference
#include "LabelTrack.h"
#include <algorithm>
#include <limits.h>
#include <float.h>
#include <wx/log.h>
#include <wx/tokenzr.h>
#include <wx/datetime.h>
#include "Prefs.h"
#include "Project.h"
#include "prefs/ImportExportPrefs.h"
#include "TimeWarper.h"
#include "AudacityMessageBox.h"
#include "ShuttleGui.h"
Include dependency graph for LabelTrack.cpp:

Go to the source code of this file.

Namespaces

namespace  anonymous_namespace{LabelTrack.cpp}
 

Functions

static const Track::TypeInfotypeInfo ()
 
void anonymous_namespace{LabelTrack.cpp}::AddControls (ShuttleGui &S)
 
static double SubRipTimestampToDouble (const wxString &ts)
 
static wxString SubRipTimestampFromDouble (double timestamp, bool webvtt)
 

Variables

static ProjectFileIORegistry::ObjectReaderEntry readerEntry
 
static EnumSetting< bool > anonymous_namespace{LabelTrack.cpp}::LabelStyleSetting
 
ImportExportPrefs::RegisteredControls anonymous_namespace{LabelTrack.cpp}::reg { wxT("LabelStyle"), AddControls }
 

Function Documentation

◆ SubRipTimestampFromDouble()

static wxString SubRipTimestampFromDouble ( double  timestamp,
bool  webvtt 
)
static

Definition at line 558 of file LabelTrack.cpp.

559{
560 // Note that the SubRip format always uses the comma as its separator...
561 static constexpr auto subripFormat = wxT("%H:%M:%S,%l");
562 // ... while WebVTT always used the period.
563 // WebVTT also allows skipping the hour part, but doesn't require doing so.
564 static constexpr auto webvttFormat = wxT("%H:%M:%S.%l");
565
566 // dt is the datetime that is timestamp seconds after Jan 1, 1970 UTC.
567 wxDateTime dt { (time_t) timestamp };
568 dt.SetMillisecond(wxRound(timestamp * 1000) % 1000);
569
570 // As such, we need to use UTC when formatting it, or else the time will
571 // be shifted (assuming the user is not in the UTC timezone).
572 return dt.Format(webvtt ? webvttFormat : subripFormat, wxDateTime::UTC);
573}
wxT("CloseDown"))

References wxT().

Referenced by LabelStruct::Export().

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

◆ SubRipTimestampToDouble()

static double SubRipTimestampToDouble ( const wxString &  ts)
static

Definition at line 427 of file LabelTrack.cpp.

428{
429 wxString::const_iterator end;
430 wxDateTime dt;
431
432 if (!dt.ParseFormat(ts, wxT("%H:%M:%S,%l"), &end) || end != ts.end())
434
435 return dt.GetHour() * 3600 + dt.GetMinute() * 60 + dt.GetSecond()
436 + dt.GetMillisecond() / 1000.0;
437}
const char * end(const char *str) noexcept
Definition: StringUtils.h:106

References details::end(), and wxT().

Referenced by LabelStruct::Import().

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

◆ typeInfo()

static const Track::TypeInfo & typeInfo ( )
static

Definition at line 125 of file LabelTrack.cpp.

126{
127 static Track::TypeInfo info{
128 { "label", "label", XO("Label Track") }, true, &Track::ClassTypeInfo() };
129 return info;
130}
XO("Cut/Copy/Paste")
static const TypeInfo & ClassTypeInfo()
Definition: Track.cpp:790

References Track::ClassTypeInfo(), and XO().

Referenced by LabelTrack::ClassTypeInfo(), and LabelTrack::GetTypeInfo().

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

Variable Documentation

◆ readerEntry

Initial value:
{
"labeltrack",
}
static LabelTrack * New(AudacityProject &project)
Definition: LabelTrack.cpp:87

Definition at line 77 of file LabelTrack.cpp.