summaryrefslogtreecommitdiffstats
path: root/src/waveform/renderers/waveformmarkrange.h
blob: deb3f09251ab558e750d87ec6ddd29e18d850252 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once

#include <QColor>
#include <QImage>
#include <QString>

#include "control/controlproxy.h"
#include "util/memory.h"
#include "waveform/waveformmarklabel.h"

class QDomNode;
class SkinContext;
class WaveformSignalColors;

class WaveformMarkRange {
  public:
    WaveformMarkRange(
            const QString& group,
            const QDomNode& node,
            const SkinContext& context,
            const WaveformSignalColors& signalColors);
    // This class is only moveable, but not copyable!
    WaveformMarkRange(WaveformMarkRange&&) = default;
    WaveformMarkRange(const WaveformMarkRange&) = delete;

    // If a mark range is active it has valid start/end points so it should be
    // drawn on waveforms.
    bool active() const;
    // If a mark range is enabled that means it should be painted with its
    // active color instead of its disabled color.
    bool enabled() const;
    // If a mark range is visible it should be drawn, otherwise it should be
    // hidden, regardless whether it is active or not.
    bool visible() const;
    // Returns start value or -1 if the start control doesn't exist.
    double start() const;
    // Returns end value or -1 if the end control doesn't exist.
    double end() const;

    bool showDuration() const;

    enum class DurationTextLocation {
        Before = 0,
        After = 1
    };

    DurationTextLocation durationTextLocation() const {
        return m_durationTextLocation;
    }

    WaveformMarkLabel m_durationLabel;

  private:
    void generateImage(int weidth, int height);

    std::unique_ptr<ControlProxy> m_markStartPointControl;
    std::unique_ptr<ControlProxy> m_markEndPointControl;
    std::unique_ptr<ControlProxy> m_markEnabledControl;
    std::unique_ptr<ControlProxy> m_markVisibleControl;

    QColor m_activeColor;
    QColor m_disabledColor;
    QColor m_durationTextColor;

    QImage m_activeImage;
    QImage m_disabledImage;

    DurationTextLocation m_durationTextLocation;

    friend class WaveformRenderMarkRange;
    friend class WOverview;
};