Debian Codegraph @

au4/src/playback/view/toolbars/components/timecodeformatter.h

raw
1 /*
2 * Audacity: A Digital Audio Editor
3 */
4 #pragma once
5
6 #include <QString>
7
8 #include "types.h"
9
10 namespace au::playback {
11 struct FieldConfig final
12 {
13 bool frac = false; // is it a fractional field
14 int base = 0; // divide by this (multiply, after decimal point)
15 // Code in the parser converts range to `long`
16 long range = 0; // then take modulo this
17 };
18
19 class TimecodeFormatter
20 {
21 public:
22 TimecodeFormatter(const QString& formatStr);
23 virtual ~TimecodeFormatter() = default;
24
25 struct ConversionResult
26 {
27 QString valueString;
28 std::vector<QString> fieldValueStrings;
29 };
30
31 virtual void init();
32
33 virtual ConversionResult valueToString(double value, bool nearest) const;
34 virtual std::optional<double> stringToValue(const QString& value) const;
35
36 virtual double singleStep(double value, int digitIndex, bool upwards);
37 virtual double singleStep(const QString& valueStr, int digitIndex, bool upwards);
38
39 void setSampleRate(double sampleRate);
40
41 void setTempo(double tempo);
42 void setUpperTimeSignature(int timeSig);
43 void setLowerTimeSignature(int timeSig);
44
45 protected:
46 QString m_prefix;
47
48 NumericFields m_fields;
49 std::vector<FieldConfig> m_fieldConfigs;
50 DigitInfos m_digits;
51
52 double m_sampleRate = 1.0;
53
54 double m_tempo = 0;
55 int m_upperTimeSignature = 0;
56 int m_lowerTimeSignature = 0;
57
58 QString m_format;
59 };
60 }