Skip to content

notch

Classes:

NotchSelf module-attribute

NotchSelf = TypeVar('NotchSelf', bound=Notch)

NotchT module-attribute

NotchT = int | Frame | Scene | Time | Notch

Notch

Notch(
    data: int | Frame | Time,
    color: QColor | GlobalColor | None = None,
    label: str | None = None,
    line: QLineF = QLineF(),
)

Methods:

Attributes:

Source code
22
23
24
25
26
27
28
29
30
31
32
def __init__(
    self, data: int | Frame | Time, color: QColor | Qt.GlobalColor | None = None,
    label: str | None = None, line: QLineF = QLineF()
) -> None:
    if isinstance(data, int):
        data = Frame(data)

    self.data = data
    self.color = cast(QColor, fallback(color, Qt.GlobalColor.white))
    self.label = fallback(label, '')
    self.line = line

color instance-attribute

color = cast(QColor, fallback(color, white))

data instance-attribute

data = data

label instance-attribute

label = fallback(label, '')

line instance-attribute

line = line

from_param classmethod

from_param(
    data: NotchT,
    color: QColor | GlobalColor | None = None,
    label: str | None = None,
) -> Iterable[NotchSelf]
Source code
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
@classmethod
def from_param(
    cls: type[NotchSelf], data: NotchT, color: QColor | Qt.GlobalColor | None = None, label: str | None = None
) -> Iterable[NotchSelf]:
    if isinstance(data, Notch):
        yield cls(data.data, color if data.color is None else data.color, data.label or label, data.line)
        return

    if isinstance(data, Scene):
        if not label:
            label = data.label

        yield cls(data.start, color, label)

        if data.end != data.start:
            yield cls(data.end, color, label)

        return

    if isinstance(data, (int, Frame, Time)):
        yield cls(data, color, label)
        return

    raise TypeError

Notches

Notches(
    other: Sequence[NotchT] | Notches | None = None,
    color: QColor | GlobalColor | None = None,
    label: str | None = None,
)

Methods:

Attributes:

Source code
70
71
72
73
74
75
76
77
78
79
80
81
82
def __init__(
    self, other: Sequence[NotchT] | Notches | None = None,
    color: QColor | Qt.GlobalColor | None = None, label: str | None = None
) -> None:
    self.items = list[Notch]()

    if isinstance(other, Notches):
        self.items = list(other.items)
        return

    if isinstance(other, Sequence):
        for notch in other:
            self.add(notch, color, label)

items instance-attribute

items = list[Notch]()

add

add(
    data: NotchT,
    color: QColor | GlobalColor | None = None,
    label: str | None = None,
) -> None
Source code
84
85
86
87
def add(
    self, data: NotchT, color: QColor | Qt.GlobalColor | None = None, label: str | None = None
) -> None:
    self.items.extend(Notch.from_param(data, color, label))

norm_lines

norm_lines(timeline: Timeline, rect: QRectF) -> None
Source code
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
def norm_lines(self, timeline: Timeline, rect: QRectF) -> None:
    from ...main.timeline import Timeline

    y = rect.top()
    y_t = y + rect.height() - 1

    # fastpaths for Notches that match Timeline.Mode
    if timeline.mode == Timeline.Mode.FRAME:
        try:
            for notch in self:
                x = timeline.c_to_x(notch.data)  # type: ignore
                notch.line = QLineF(x, y, x, y_t)
            return
        except Exception:
            try:
                for notch in self:
                    x = timeline.t_to_x(notch.data)  # type: ignore
                    notch.line = QLineF(x, y, x, y_t)
                return
            except Exception:
                ...
    else:
        try:
            for notch in self:
                x = timeline.t_to_x(notch.data)  # type: ignore
                notch.line = QLineF(x, y, x, y_t)
            return
        except Exception:
            try:
                for notch in self:
                    x = timeline.c_to_x(notch.data)  # type: ignore
                    notch.line = QLineF(x, y, x, y_t)
                return
            except Exception:
                ...

    for notch in self:
        if isinstance(notch.data, Frame):
            x = timeline.c_to_x(notch.data)
        elif isinstance(notch.data, Time):
            x = timeline.t_to_x(notch.data)

        notch.line = QLineF(x, y, x, y_t)