led-controller-version-3-effect-creation 3.0.3__tar.gz → 3.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/PKG-INFO +3 -3
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/pyproject.toml +2 -2
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/studio/app.py +18 -2
- led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/studio/lab/__init__.py +12 -0
- led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/studio/lab/clock.py +83 -0
- led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/studio/lab/examples.py +88 -0
- led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/studio/lab/inspector.py +416 -0
- led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/studio/lab/output.py +224 -0
- led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/studio/lab/page.py +961 -0
- led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/studio/lab/timeline.py +261 -0
- led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/studio/lab/tree.py +358 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/studio/ring.py +25 -9
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/studio/session.py +77 -20
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/studio/window.py +22 -0
- led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/visual/__init__.py +7 -0
- led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/visual/blocks.py +92 -0
- led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/visual/compiler.py +178 -0
- led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/visual/editor.py +237 -0
- led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/visual/kernel.py +149 -0
- led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/visual/model.py +173 -0
- led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/visual/persistence.py +107 -0
- led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/visual/preview.py +126 -0
- led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/visual/steps.py +150 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/.gitignore +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/README.md +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/__init__.py +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/build.py +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/cli.py +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/imports.py +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/scaffold.py +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/source.py +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/studio/__init__.py +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/studio/authoring.py +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/studio/blueprint.py +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/studio/calibrate.py +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/studio/calibration_page.py +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/studio/catalogue.py +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/studio/parameters.py +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/studio/preset_dialog.py +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/studio/project.py +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/studio/source_editor.py +0 -0
- {led_controller_version_3_effect_creation-3.0.3 → led_controller_version_3_effect_creation-3.0.4}/src/lefx/effect_creation/validate.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: led-controller-version-3-effect-creation
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.4
|
|
4
4
|
Summary: LEFX V3 effect creation: scaffolding, source validation, package building and the desktop studio
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Keywords: build,editor,effects,gui,led,lefx,packaging
|
|
@@ -10,7 +10,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.12
|
|
11
11
|
Classifier: Topic :: Multimedia :: Graphics
|
|
12
12
|
Requires-Python: <3.13,>=3.12
|
|
13
|
-
Requires-Dist: led-controller-version-3==3.0.
|
|
13
|
+
Requires-Dist: led-controller-version-3==3.0.4
|
|
14
14
|
Requires-Dist: pyside6>=6.0.0
|
|
15
15
|
Requires-Dist: pyyaml<7,>=6.0.2
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "led-controller-version-3-effect-creation"
|
|
7
|
-
version = "3.0.
|
|
7
|
+
version = "3.0.4"
|
|
8
8
|
description = "LEFX V3 effect creation: scaffolding, source validation, package building and the desktop studio"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -40,7 +40,7 @@ dependencies = [
|
|
|
40
40
|
# The runtime, which carries the schema to write against, the loader to
|
|
41
41
|
# verify what was just built, and the control surface the studio drives a
|
|
42
42
|
# device through. One name now, because those four layers ship together.
|
|
43
|
-
"led-controller-version-3==3.0.
|
|
43
|
+
"led-controller-version-3==3.0.4",
|
|
44
44
|
"PySide6>=6.0.0",
|
|
45
45
|
# Imported directly to read and write a source tree. It arrives with the
|
|
46
46
|
# runtime anyway, but a package that imports a thing declares it.
|
|
@@ -58,6 +58,11 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
58
58
|
"The way to find out whether a standalone build is complete."
|
|
59
59
|
),
|
|
60
60
|
)
|
|
61
|
+
parser.add_argument(
|
|
62
|
+
"--gui-self-check",
|
|
63
|
+
action="store_true",
|
|
64
|
+
help="Open the Studio with null output, run the Qt event loop briefly and exit.",
|
|
65
|
+
)
|
|
61
66
|
parser.add_argument("--verbose", action="store_true")
|
|
62
67
|
return parser
|
|
63
68
|
|
|
@@ -84,8 +89,14 @@ def self_check(project: Project) -> int:
|
|
|
84
89
|
if outputs == [NULL_OUTPUT]:
|
|
85
90
|
print(" ! no device package reachable — entry point metadata is missing")
|
|
86
91
|
|
|
92
|
+
from lefx.interfaces.discovery import installed_effect_sets
|
|
93
|
+
|
|
94
|
+
sets = installed_effect_sets()
|
|
95
|
+
print(f"effect sets : {', '.join(sorted(sets))}")
|
|
87
96
|
session = StudioSession(project=project)
|
|
88
97
|
failures: list[str] = []
|
|
98
|
+
if under_a_frozen_build() and not {"core-set", "smartspeaker-set"} <= sets.keys():
|
|
99
|
+
failures.append("Frozen build is missing installed effect-set archives")
|
|
89
100
|
try:
|
|
90
101
|
session.open(NULL_OUTPUT)
|
|
91
102
|
effects = session.registry.list_effects()
|
|
@@ -150,13 +161,18 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
150
161
|
search_paths=args.sources,
|
|
151
162
|
project=project,
|
|
152
163
|
)
|
|
153
|
-
|
|
164
|
+
if not args.gui_self_check:
|
|
165
|
+
remember(project)
|
|
154
166
|
|
|
155
167
|
application = QApplication(sys.argv[:1])
|
|
156
168
|
application.setApplicationName("LEFX Studio")
|
|
157
|
-
window = StudioWindow(session, initial_output=args.output)
|
|
169
|
+
window = StudioWindow(session, initial_output=NULL_OUTPUT if args.gui_self_check else args.output)
|
|
158
170
|
window.setWindowTitle(f"LEFX Studio — {project.label}")
|
|
159
171
|
window.show()
|
|
172
|
+
if args.gui_self_check:
|
|
173
|
+
from PySide6.QtCore import QTimer
|
|
174
|
+
|
|
175
|
+
QTimer.singleShot(1000, window.close)
|
|
160
176
|
try:
|
|
161
177
|
return int(application.exec())
|
|
162
178
|
finally:
|
led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/studio/lab/__init__.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Studio Lab: the experimental visual editor, as one tab of the studio.
|
|
2
|
+
|
|
3
|
+
Experimental on purpose. It is a place to try out how designing effects should
|
|
4
|
+
feel — layers, blocks, a timeline, stepping through states — on top of the
|
|
5
|
+
headless core in :mod:`lefx.effect_creation.visual`, which stays the only
|
|
6
|
+
owner of the document and the only thing that computes frames.
|
|
7
|
+
|
|
8
|
+
Split like the studio itself: ``clock`` and ``output`` carry no Qt and are
|
|
9
|
+
tested without a display; ``page``, ``tree``, ``inspector``, ``timeline`` and
|
|
10
|
+
``ring`` draw. Each panel talks to the page through a few signals, so one can be
|
|
11
|
+
swapped for another experiment without touching the rest.
|
|
12
|
+
"""
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""Preview time that does not depend on how often anyone looks at it.
|
|
2
|
+
|
|
3
|
+
The timeline asks for "now" whenever it repaints, which is as often as the GUI
|
|
4
|
+
manages. The answer is computed from a monotonic clock and an anchor, never by
|
|
5
|
+
adding a frame interval, so a slow repaint shows a later moment rather than a
|
|
6
|
+
slower effect, and pausing, seeking or changing the speed costs no drift.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import time
|
|
12
|
+
from typing import Callable
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class PreviewClock:
|
|
16
|
+
"""Play, pause, stop and seek over ``[start, end]`` at a chosen speed."""
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self, *, start: float = 0.0, end: float = 10.0, now: Callable[[], float] = time.monotonic
|
|
20
|
+
) -> None:
|
|
21
|
+
self._now = now
|
|
22
|
+
self.start = float(start)
|
|
23
|
+
self.end = max(self.start + 0.001, float(end))
|
|
24
|
+
self.speed = 1.0
|
|
25
|
+
self.loop = True
|
|
26
|
+
self._position = self.start
|
|
27
|
+
self._anchor: float | None = None
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def playing(self) -> bool:
|
|
31
|
+
return self._anchor is not None
|
|
32
|
+
|
|
33
|
+
def elapsed(self) -> float:
|
|
34
|
+
"""The preview time right now. Reaching the end loops or pauses there."""
|
|
35
|
+
if self._anchor is None:
|
|
36
|
+
return self._position
|
|
37
|
+
moment = self._now()
|
|
38
|
+
position = self._position + (moment - self._anchor) * self.speed
|
|
39
|
+
if position >= self.end:
|
|
40
|
+
if self.loop:
|
|
41
|
+
position = self.start + (position - self.start) % (self.end - self.start)
|
|
42
|
+
else:
|
|
43
|
+
position, moment = self.end, None
|
|
44
|
+
self._position, self._anchor = position, moment
|
|
45
|
+
return position
|
|
46
|
+
|
|
47
|
+
def play(self) -> None:
|
|
48
|
+
if self.playing:
|
|
49
|
+
return
|
|
50
|
+
if self._position >= self.end:
|
|
51
|
+
self._position = self.start
|
|
52
|
+
self._anchor = self._now()
|
|
53
|
+
|
|
54
|
+
def pause(self) -> None:
|
|
55
|
+
self._position = self.elapsed()
|
|
56
|
+
self._anchor = None
|
|
57
|
+
|
|
58
|
+
def toggle(self) -> None:
|
|
59
|
+
self.pause() if self.playing else self.play()
|
|
60
|
+
|
|
61
|
+
def stop(self) -> None:
|
|
62
|
+
self._anchor = None
|
|
63
|
+
self._position = self.start
|
|
64
|
+
|
|
65
|
+
def seek(self, position: float) -> None:
|
|
66
|
+
self._position = min(self.end, max(self.start, float(position)))
|
|
67
|
+
if self._anchor is not None:
|
|
68
|
+
self._anchor = self._now()
|
|
69
|
+
|
|
70
|
+
def set_speed(self, speed: float) -> None:
|
|
71
|
+
self._position = self.elapsed()
|
|
72
|
+
if self._anchor is not None:
|
|
73
|
+
self._anchor = self._now()
|
|
74
|
+
self.speed = max(0.01, float(speed))
|
|
75
|
+
|
|
76
|
+
def set_range(self, start: float, end: float) -> None:
|
|
77
|
+
position = self.elapsed()
|
|
78
|
+
self.start = max(0.0, float(start))
|
|
79
|
+
self.end = max(self.start + 0.001, float(end))
|
|
80
|
+
self.seek(position)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
__all__ = ["PreviewClock"]
|
led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/studio/lab/examples.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""Starting points for experiments, built with the editor's own operations.
|
|
2
|
+
|
|
3
|
+
Each one is one of the concept cases the Lab is meant to explore. They are
|
|
4
|
+
documents like any other: built through :class:`Editor` calls, validated by it,
|
|
5
|
+
and editable, savable and exportable once loaded. No Qt here.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Callable
|
|
11
|
+
|
|
12
|
+
from lefx.effect_creation.visual import Editor
|
|
13
|
+
|
|
14
|
+
TWELFTH = 1 / 12
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def two_points_rotating() -> dict:
|
|
18
|
+
editor = Editor()
|
|
19
|
+
editor.metadata(id="zwei_punkte", title="Zwei Punkte, gemeinsame Rotation")
|
|
20
|
+
layer = editor.add_layer("Punkte")
|
|
21
|
+
editor.add_element(layer, "point", position=0.0, color="#FF5533")
|
|
22
|
+
editor.add_element(layer, "point", position=0.5, color="#3399FF")
|
|
23
|
+
editor.add_animation(layer, "rotation", rate=0.25)
|
|
24
|
+
return editor.document
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def counter_rotating_segments() -> dict:
|
|
28
|
+
editor = Editor()
|
|
29
|
+
editor.metadata(id="gegenlaeufige_segmente", title="Gegenläufige Segmente")
|
|
30
|
+
first = editor.add_layer("Segment A")
|
|
31
|
+
editor.add_element(first, "segment", position=0.0, length=5 * TWELFTH, color="#FF3311")
|
|
32
|
+
editor.add_animation(first, "rotation", rate=0.25)
|
|
33
|
+
second = editor.add_layer("Segment B")
|
|
34
|
+
editor.configure_layer(second, blend="add")
|
|
35
|
+
editor.add_element(second, "segment", position=0.5, length=3 * TWELFTH, color="#1155FF")
|
|
36
|
+
editor.add_animation(second, "rotation", rate=0.25, reverse=True)
|
|
37
|
+
return editor.document
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def alternating_pattern() -> dict:
|
|
41
|
+
"""A/B over the whole ring, from six points — no pattern block exists yet."""
|
|
42
|
+
editor = Editor()
|
|
43
|
+
editor.metadata(id="ab_muster", title="A/B-Muster (aus Punkten)")
|
|
44
|
+
background = editor.add_layer("B-Farbe")
|
|
45
|
+
editor.add_element(background, "fill", color="#202060")
|
|
46
|
+
layer = editor.add_layer("A-Punkte")
|
|
47
|
+
for index in range(0, 12, 2):
|
|
48
|
+
editor.add_element(layer, "point", position=index * TWELFTH, color="#FFAA00")
|
|
49
|
+
editor.add_animation(layer, "rotation", rate=1 / 12)
|
|
50
|
+
return editor.document
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def segment_with_colour_cycle() -> dict:
|
|
54
|
+
editor = Editor()
|
|
55
|
+
editor.metadata(id="segment_farbwechsel", title="Rotierendes Segment mit Farbwechsel")
|
|
56
|
+
layer = editor.add_layer("Segment")
|
|
57
|
+
editor.add_element(layer, "segment", length=5 * TWELFTH, color="#FF0000")
|
|
58
|
+
editor.add_animation(layer, "rotation", rate=0.2)
|
|
59
|
+
editor.add_animation(layer, "color_cycle", rate=0.5)
|
|
60
|
+
return editor.document
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def overlapping_layers() -> dict:
|
|
64
|
+
editor = Editor()
|
|
65
|
+
editor.metadata(id="ueberlagerung", title="Überlagerung über einem Verlauf")
|
|
66
|
+
ground = editor.add_layer("Hintergrund")
|
|
67
|
+
editor.add_element(ground, "gradient", color="#001133", end_color="#003311", brightness=0.6)
|
|
68
|
+
sparks = editor.add_layer("Funkeln")
|
|
69
|
+
editor.configure_layer(sparks, blend="max")
|
|
70
|
+
editor.add_element(sparks, "fill", color="#FFFFFF", brightness=0.8)
|
|
71
|
+
editor.add_animation(sparks, "sparkle", frequency=4.0, density=0.2, seed=7)
|
|
72
|
+
pulse = editor.add_layer("Puls")
|
|
73
|
+
editor.configure_layer(pulse, blend="add")
|
|
74
|
+
editor.add_element(pulse, "segment", length=4 * TWELFTH, color="#AA00FF")
|
|
75
|
+
editor.add_animation(pulse, "pulse", frequency=0.5, minimum=-80.0, maximum=0.0)
|
|
76
|
+
editor.add_animation(pulse, "rotation", rate=0.1, reverse=True)
|
|
77
|
+
return editor.document
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
EXAMPLES: dict[str, tuple[str, Callable[[], dict]]] = {
|
|
81
|
+
"two_points": ("Zwei Punkte rotieren gemeinsam", two_points_rotating),
|
|
82
|
+
"counter_rotation": ("Zwei Segmente, gegenläufig auf zwei Ebenen", counter_rotating_segments),
|
|
83
|
+
"alternating": ("A/B-Muster über den ganzen Ring", alternating_pattern),
|
|
84
|
+
"colour_cycle": ("Rotierendes Segment mit Farbwechsel", segment_with_colour_cycle),
|
|
85
|
+
"overlap": ("Ebenen überlagern sich (Verlauf, Funkeln, Puls)", overlapping_layers),
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
__all__ = ["EXAMPLES"]
|
led_controller_version_3_effect_creation-3.0.4/src/lefx/effect_creation/studio/lab/inspector.py
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
"""The property inspector: one field per declared property, nothing hand-made.
|
|
2
|
+
|
|
3
|
+
Every block and every layer already describes its properties in
|
|
4
|
+
:mod:`lefx.effect_creation.visual.blocks` — label, kind, range, default. The
|
|
5
|
+
fields here are built from those descriptors, so a block added there is
|
|
6
|
+
editable here without touching this file.
|
|
7
|
+
|
|
8
|
+
The inspector never changes the document. It reports what the user did —
|
|
9
|
+
``committed`` for a value meant to stay, ``previewed`` for a value while a
|
|
10
|
+
slider is still being dragged — and the page hands that to the editor, which
|
|
11
|
+
validates it. What the inspector then shows is what the editor accepted: the
|
|
12
|
+
next document arrives and every field is set from it again, so a rejected value
|
|
13
|
+
simply springs back, with the reason next to it rather than in a dialog.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from typing import Any
|
|
19
|
+
|
|
20
|
+
from PySide6.QtCore import Qt, Signal
|
|
21
|
+
from PySide6.QtGui import QColor
|
|
22
|
+
from PySide6.QtWidgets import (
|
|
23
|
+
QCheckBox,
|
|
24
|
+
QColorDialog,
|
|
25
|
+
QComboBox,
|
|
26
|
+
QDoubleSpinBox,
|
|
27
|
+
QFormLayout,
|
|
28
|
+
QHBoxLayout,
|
|
29
|
+
QLabel,
|
|
30
|
+
QLineEdit,
|
|
31
|
+
QPushButton,
|
|
32
|
+
QSlider,
|
|
33
|
+
QSpinBox,
|
|
34
|
+
QVBoxLayout,
|
|
35
|
+
QWidget,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
from lefx.effect_creation.visual.blocks import BLOCKS, LAYER_PROPERTIES, Property
|
|
39
|
+
from lefx.sdk import DefinitionKind
|
|
40
|
+
|
|
41
|
+
RING_FRACTIONS = frozenset({"position", "length", "mask_start", "mask_length"})
|
|
42
|
+
"""Properties measured as a share of the ring, which get an LED helper."""
|
|
43
|
+
|
|
44
|
+
BLENDS = [("over", "Überdecken"), ("add", "Addieren"), ("max", "Maximum")]
|
|
45
|
+
COMPOSITIONS = [("opaque", "Deckend (unbedeckt = schwarz)"),
|
|
46
|
+
("transparent", "Transparent (unbedeckt = durchlässig)")]
|
|
47
|
+
KINDS = [(kind.value, kind.value) for kind in DefinitionKind]
|
|
48
|
+
SLIDER_STEPS = 1000
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class Field(QWidget):
|
|
52
|
+
"""One property's editor. Subclasses emit ``committed`` and ``previewed``."""
|
|
53
|
+
|
|
54
|
+
committed = Signal(object)
|
|
55
|
+
previewed = Signal(object)
|
|
56
|
+
|
|
57
|
+
def set_value(self, value: Any) -> None: # pragma: no cover — abstract
|
|
58
|
+
raise NotImplementedError
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class BoolField(Field):
|
|
62
|
+
def __init__(self, spec: Property) -> None:
|
|
63
|
+
super().__init__()
|
|
64
|
+
layout = QHBoxLayout(self)
|
|
65
|
+
layout.setContentsMargins(0, 0, 0, 0)
|
|
66
|
+
self.box = QCheckBox()
|
|
67
|
+
self.box.toggled.connect(lambda checked: self.committed.emit(bool(checked)))
|
|
68
|
+
layout.addWidget(self.box)
|
|
69
|
+
layout.addStretch(1)
|
|
70
|
+
|
|
71
|
+
def set_value(self, value: Any) -> None:
|
|
72
|
+
self.box.blockSignals(True)
|
|
73
|
+
self.box.setChecked(bool(value))
|
|
74
|
+
self.box.blockSignals(False)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class IntField(Field):
|
|
78
|
+
def __init__(self, spec: Property) -> None:
|
|
79
|
+
super().__init__()
|
|
80
|
+
layout = QHBoxLayout(self)
|
|
81
|
+
layout.setContentsMargins(0, 0, 0, 0)
|
|
82
|
+
self.spin = QSpinBox()
|
|
83
|
+
self.spin.setRange(int(spec.minimum if spec.minimum is not None else -2**31),
|
|
84
|
+
int(min(spec.maximum if spec.maximum is not None else 2**31 - 1, 2**31 - 1)))
|
|
85
|
+
self.spin.setKeyboardTracking(False)
|
|
86
|
+
self.spin.valueChanged.connect(lambda value: self.committed.emit(int(value)))
|
|
87
|
+
layout.addWidget(self.spin, stretch=1)
|
|
88
|
+
|
|
89
|
+
def set_value(self, value: Any) -> None:
|
|
90
|
+
self.spin.blockSignals(True)
|
|
91
|
+
self.spin.setValue(int(value))
|
|
92
|
+
self.spin.blockSignals(False)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class FloatField(Field):
|
|
96
|
+
"""Slider for reach, spin box for precision; ring shares also in LEDs.
|
|
97
|
+
|
|
98
|
+
Dragging the slider previews without committing, so a single drag is one
|
|
99
|
+
undo step rather than a hundred. Releasing it commits.
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
def __init__(self, spec: Property, name: str, led_count: int) -> None:
|
|
103
|
+
super().__init__()
|
|
104
|
+
self.minimum = float(spec.minimum if spec.minimum is not None else -1000.0)
|
|
105
|
+
self.maximum = float(spec.maximum if spec.maximum is not None else 1000.0)
|
|
106
|
+
span = self.maximum - self.minimum
|
|
107
|
+
# Wide ranges (rates up to 100/s) are mostly used near the bottom;
|
|
108
|
+
# a squared slider keeps the useful part from being three pixels wide.
|
|
109
|
+
self.exponent = 2.0 if span > 10 else 1.0
|
|
110
|
+
self.led_count = max(1, int(led_count))
|
|
111
|
+
self._value = float(spec.default)
|
|
112
|
+
|
|
113
|
+
layout = QHBoxLayout(self)
|
|
114
|
+
layout.setContentsMargins(0, 0, 0, 0)
|
|
115
|
+
self.slider = QSlider(Qt.Orientation.Horizontal)
|
|
116
|
+
self.slider.setRange(0, SLIDER_STEPS)
|
|
117
|
+
self.slider.sliderMoved.connect(self._on_slider_moved)
|
|
118
|
+
self.slider.sliderReleased.connect(lambda: self.committed.emit(self._from_slider(self.slider.value())))
|
|
119
|
+
self.slider.actionTriggered.connect(self._on_slider_action)
|
|
120
|
+
self.spin = QDoubleSpinBox()
|
|
121
|
+
self.spin.setRange(self.minimum, self.maximum)
|
|
122
|
+
self.spin.setDecimals(4 if span <= 1 else 3)
|
|
123
|
+
self.spin.setSingleStep(0.01 if span <= 2 else 0.1)
|
|
124
|
+
self.spin.setKeyboardTracking(False)
|
|
125
|
+
self.spin.valueChanged.connect(lambda value: self.committed.emit(float(value)))
|
|
126
|
+
layout.addWidget(self.slider, stretch=3)
|
|
127
|
+
layout.addWidget(self.spin, stretch=2)
|
|
128
|
+
|
|
129
|
+
self.leds: QSpinBox | None = None
|
|
130
|
+
if name in RING_FRACTIONS:
|
|
131
|
+
self.leds = QSpinBox()
|
|
132
|
+
self.leds.setRange(0, self.led_count)
|
|
133
|
+
self.leds.setSuffix(" LED")
|
|
134
|
+
self.leds.setToolTip(f"Als Anzahl LEDs eines {self.led_count}er-Rings eingeben")
|
|
135
|
+
self.leds.setKeyboardTracking(False)
|
|
136
|
+
self.leds.valueChanged.connect(
|
|
137
|
+
lambda count: self.committed.emit(min(self.maximum, count / self.led_count)))
|
|
138
|
+
layout.addWidget(self.leds, stretch=1)
|
|
139
|
+
|
|
140
|
+
def _from_slider(self, position: int) -> float:
|
|
141
|
+
ratio = (position / SLIDER_STEPS) ** self.exponent
|
|
142
|
+
return round(self.minimum + (self.maximum - self.minimum) * ratio, 6)
|
|
143
|
+
|
|
144
|
+
def _to_slider(self, value: float) -> int:
|
|
145
|
+
span = self.maximum - self.minimum
|
|
146
|
+
ratio = 0.0 if span <= 0 else max(0.0, min(1.0, (value - self.minimum) / span))
|
|
147
|
+
return int(round(ratio ** (1 / self.exponent) * SLIDER_STEPS))
|
|
148
|
+
|
|
149
|
+
def _on_slider_moved(self, position: int) -> None:
|
|
150
|
+
self.previewed.emit(self._from_slider(position))
|
|
151
|
+
|
|
152
|
+
def _on_slider_action(self, action: int) -> None:
|
|
153
|
+
# Clicks on the groove and arrow keys move without a drag: commit those.
|
|
154
|
+
if action != QSlider.SliderAction.SliderMove:
|
|
155
|
+
self.committed.emit(self._from_slider(self.slider.sliderPosition()))
|
|
156
|
+
|
|
157
|
+
def set_value(self, value: Any) -> None:
|
|
158
|
+
self._value = float(value)
|
|
159
|
+
for widget in (self.slider, self.spin, self.leds):
|
|
160
|
+
if widget is not None:
|
|
161
|
+
widget.blockSignals(True)
|
|
162
|
+
if not self.slider.isSliderDown():
|
|
163
|
+
self.slider.setValue(self._to_slider(self._value))
|
|
164
|
+
self.spin.setValue(self._value)
|
|
165
|
+
if self.leds is not None:
|
|
166
|
+
# The kernel's own rounding, so the count shown is the count lit.
|
|
167
|
+
self.leds.setValue(min(self.led_count, int(self._value * self.led_count + 0.5)))
|
|
168
|
+
for widget in (self.slider, self.spin, self.leds):
|
|
169
|
+
if widget is not None:
|
|
170
|
+
widget.blockSignals(False)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
class ColorField(Field):
|
|
174
|
+
"""A swatch that opens a colour dialog, and the hex value to type into."""
|
|
175
|
+
|
|
176
|
+
def __init__(self, spec: Property) -> None:
|
|
177
|
+
super().__init__()
|
|
178
|
+
self._value = str(spec.default)
|
|
179
|
+
layout = QHBoxLayout(self)
|
|
180
|
+
layout.setContentsMargins(0, 0, 0, 0)
|
|
181
|
+
self.swatch = QPushButton()
|
|
182
|
+
self.swatch.setFixedWidth(46)
|
|
183
|
+
self.swatch.setToolTip("Farbe wählen")
|
|
184
|
+
self.swatch.clicked.connect(self._choose)
|
|
185
|
+
self.text = QLineEdit()
|
|
186
|
+
self.text.setMaxLength(7)
|
|
187
|
+
self.text.setPlaceholderText("#RRGGBB")
|
|
188
|
+
self.text.editingFinished.connect(self._typed)
|
|
189
|
+
layout.addWidget(self.swatch)
|
|
190
|
+
layout.addWidget(self.text, stretch=1)
|
|
191
|
+
|
|
192
|
+
def _typed(self) -> None:
|
|
193
|
+
value = self.text.text().strip()
|
|
194
|
+
if not value.startswith("#"):
|
|
195
|
+
value = "#" + value
|
|
196
|
+
if value.upper() != self._value.upper():
|
|
197
|
+
self.committed.emit(value.upper())
|
|
198
|
+
|
|
199
|
+
def _choose(self) -> None:
|
|
200
|
+
dialog = QColorDialog(QColor(self._value), self)
|
|
201
|
+
dialog.setWindowTitle("Farbe wählen")
|
|
202
|
+
dialog.currentColorChanged.connect(lambda color: self.previewed.emit(color.name().upper()))
|
|
203
|
+
if dialog.exec() == QColorDialog.DialogCode.Accepted:
|
|
204
|
+
self.committed.emit(dialog.currentColor().name().upper())
|
|
205
|
+
else:
|
|
206
|
+
self.committed.emit(self._value) # restores the preview of the stored value
|
|
207
|
+
|
|
208
|
+
def set_value(self, value: Any) -> None:
|
|
209
|
+
self._value = str(value).upper()
|
|
210
|
+
self.text.blockSignals(True)
|
|
211
|
+
self.text.setText(self._value)
|
|
212
|
+
self.text.blockSignals(False)
|
|
213
|
+
self.swatch.setStyleSheet(
|
|
214
|
+
f"background: {self._value}; border: 1px solid #555; border-radius: 3px; min-height: 18px;")
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def field_for(spec: Property, name: str, led_count: int) -> Field:
|
|
218
|
+
if spec.kind == "color":
|
|
219
|
+
return ColorField(spec)
|
|
220
|
+
if spec.kind == "bool":
|
|
221
|
+
return BoolField(spec)
|
|
222
|
+
if spec.kind == "int":
|
|
223
|
+
return IntField(spec)
|
|
224
|
+
return FloatField(spec, name, led_count)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
class ChoiceField(Field):
|
|
228
|
+
def __init__(self, choices: list[tuple[str, str]]) -> None:
|
|
229
|
+
super().__init__()
|
|
230
|
+
layout = QHBoxLayout(self)
|
|
231
|
+
layout.setContentsMargins(0, 0, 0, 0)
|
|
232
|
+
self.box = QComboBox()
|
|
233
|
+
for value, label in choices:
|
|
234
|
+
self.box.addItem(label, value)
|
|
235
|
+
self.box.currentIndexChanged.connect(lambda _: self.committed.emit(self.box.currentData()))
|
|
236
|
+
layout.addWidget(self.box, stretch=1)
|
|
237
|
+
|
|
238
|
+
def set_value(self, value: Any) -> None:
|
|
239
|
+
self.box.blockSignals(True)
|
|
240
|
+
self.box.setCurrentIndex(max(0, self.box.findData(value)))
|
|
241
|
+
self.box.blockSignals(False)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
class TextField(Field):
|
|
245
|
+
def __init__(self) -> None:
|
|
246
|
+
super().__init__()
|
|
247
|
+
layout = QHBoxLayout(self)
|
|
248
|
+
layout.setContentsMargins(0, 0, 0, 0)
|
|
249
|
+
self.edit = QLineEdit()
|
|
250
|
+
self.edit.editingFinished.connect(lambda: self.committed.emit(self.edit.text()))
|
|
251
|
+
layout.addWidget(self.edit, stretch=1)
|
|
252
|
+
|
|
253
|
+
def set_value(self, value: Any) -> None:
|
|
254
|
+
if self.edit.hasFocus() and self.edit.isModified():
|
|
255
|
+
return
|
|
256
|
+
self.edit.blockSignals(True)
|
|
257
|
+
self.edit.setText(str(value))
|
|
258
|
+
self.edit.setModified(False)
|
|
259
|
+
self.edit.blockSignals(False)
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
class Inspector(QWidget):
|
|
263
|
+
"""Shows the selected object; reports edits as (target, field, value).
|
|
264
|
+
|
|
265
|
+
``target`` is an object id, or ``None`` for the whole effect. ``field`` is a
|
|
266
|
+
property name, or one of ``@name``, ``@enabled``, ``@blend`` for a layer's
|
|
267
|
+
own settings, or ``effect.<key>`` for the effect metadata.
|
|
268
|
+
"""
|
|
269
|
+
|
|
270
|
+
committed = Signal(object, str, object)
|
|
271
|
+
previewed = Signal(object, str, object)
|
|
272
|
+
|
|
273
|
+
def __init__(self, parent: QWidget | None = None) -> None:
|
|
274
|
+
super().__init__(parent)
|
|
275
|
+
self._shape: tuple | None = None
|
|
276
|
+
self._fields: dict[str, Field] = {}
|
|
277
|
+
layout = QVBoxLayout(self)
|
|
278
|
+
layout.setAlignment(Qt.AlignmentFlag.AlignTop)
|
|
279
|
+
self.heading = QLabel()
|
|
280
|
+
self.heading.setStyleSheet("font-size: 15px; font-weight: 600;")
|
|
281
|
+
self.subheading = QLabel()
|
|
282
|
+
self.subheading.setWordWrap(True)
|
|
283
|
+
self.subheading.setStyleSheet("color: #888;")
|
|
284
|
+
self.form_host = QWidget()
|
|
285
|
+
self.form = QFormLayout(self.form_host)
|
|
286
|
+
self.form.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow)
|
|
287
|
+
self.problem = QLabel()
|
|
288
|
+
self.problem.setWordWrap(True)
|
|
289
|
+
self.problem.setStyleSheet("color: #e07a5f; padding-top: 6px;")
|
|
290
|
+
self.problem.hide()
|
|
291
|
+
layout.addWidget(self.heading)
|
|
292
|
+
layout.addWidget(self.subheading)
|
|
293
|
+
layout.addWidget(self.form_host)
|
|
294
|
+
layout.addWidget(self.problem)
|
|
295
|
+
|
|
296
|
+
# -- what is shown ------------------------------------------------------
|
|
297
|
+
|
|
298
|
+
def show_object(self, document: dict, target: str | None, led_count: int) -> None:
|
|
299
|
+
item, kind = locate(document, target)
|
|
300
|
+
if item is None:
|
|
301
|
+
target, item, kind = None, document["effect"], "effect"
|
|
302
|
+
shape = (target, kind, item.get("type"), led_count)
|
|
303
|
+
if shape != self._shape:
|
|
304
|
+
self._rebuild(document, target, item, kind, led_count)
|
|
305
|
+
self._shape = shape
|
|
306
|
+
self._fill(document, item, kind)
|
|
307
|
+
|
|
308
|
+
def show_problem(self, text: str | None) -> None:
|
|
309
|
+
self.problem.setText(text or "")
|
|
310
|
+
self.problem.setVisible(bool(text))
|
|
311
|
+
|
|
312
|
+
def field(self, name: str) -> Field:
|
|
313
|
+
return self._fields[name]
|
|
314
|
+
|
|
315
|
+
# -- building -----------------------------------------------------------
|
|
316
|
+
|
|
317
|
+
def _rebuild(self, document: dict, target: str | None, item: dict, kind: str, led_count: int) -> None:
|
|
318
|
+
while self.form.rowCount():
|
|
319
|
+
self.form.removeRow(0)
|
|
320
|
+
self._fields = {}
|
|
321
|
+
self.show_problem(None)
|
|
322
|
+
|
|
323
|
+
if kind == "effect":
|
|
324
|
+
self.heading.setText("Gesamteffekt")
|
|
325
|
+
self.subheading.setText(
|
|
326
|
+
"Kein Runtime-Layer: das ganze Projekt und seine zusammengesetzte Vorschau. "
|
|
327
|
+
"Diese Angaben gehen in den exportierten LEFX-Effekt ein.")
|
|
328
|
+
self._add(target, "effect.title", "Titel", TextField())
|
|
329
|
+
self._add(target, "effect.id", "Effekt-ID", TextField())
|
|
330
|
+
self._add(target, "effect.description", "Beschreibung", TextField())
|
|
331
|
+
self._add(target, "effect.kind", "Lebenszyklus", ChoiceField(KINDS))
|
|
332
|
+
self._add(target, "effect.composition", "Runtime-Komposition", ChoiceField(COMPOSITIONS))
|
|
333
|
+
spin = IntField(Property("Dauer", "int", 2000, 1, 600000))
|
|
334
|
+
spin.spin.setSuffix(" ms")
|
|
335
|
+
spin.setToolTip("Nur für Events und Timed Overlays von Bedeutung")
|
|
336
|
+
self._add(target, "effect.duration_ms", "Dauer", spin)
|
|
337
|
+
return
|
|
338
|
+
|
|
339
|
+
if kind == "layer":
|
|
340
|
+
self.heading.setText(f"Ebene · {item['name']}")
|
|
341
|
+
self.subheading.setText("Eine Studio-Ebene: eigene Elemente, eigene Animationen, "
|
|
342
|
+
"eigene Mischung mit den Ebenen darunter.")
|
|
343
|
+
self._add(target, "@name", "Name", TextField())
|
|
344
|
+
visible = BoolField(Property("Sichtbar", "bool", True))
|
|
345
|
+
self._add(target, "@enabled", "Sichtbar", visible)
|
|
346
|
+
self._add(target, "@blend", "Mischmodus", ChoiceField(BLENDS))
|
|
347
|
+
specs = LAYER_PROPERTIES
|
|
348
|
+
elif kind == "group":
|
|
349
|
+
self.heading.setText(f"Gruppe · {item['name']}")
|
|
350
|
+
self.subheading.setText("Gruppen sind im Lab nur sichtbar; ihre künftige Rolle ist offen.")
|
|
351
|
+
self._add(target, "@name", "Name", TextField())
|
|
352
|
+
return
|
|
353
|
+
else:
|
|
354
|
+
block = BLOCKS[item["type"]]
|
|
355
|
+
role = "Animation der Ebene" if kind == "animation" else "Visuelles Element"
|
|
356
|
+
self.heading.setText(block.label)
|
|
357
|
+
layer = _layer_name(document, item, kind)
|
|
358
|
+
self.subheading.setText(f"{role} · {layer}" if layer else role)
|
|
359
|
+
specs = block.properties
|
|
360
|
+
for name, spec in specs.items():
|
|
361
|
+
self._add(target, name, spec.label, field_for(spec, name, led_count))
|
|
362
|
+
|
|
363
|
+
def _add(self, target: str | None, name: str, label: str, field: Field) -> None:
|
|
364
|
+
field.committed.connect(lambda value, n=name: self.committed.emit(target, n, value))
|
|
365
|
+
field.previewed.connect(lambda value, n=name: self.previewed.emit(target, n, value))
|
|
366
|
+
self._fields[name] = field
|
|
367
|
+
self.form.addRow(label, field)
|
|
368
|
+
|
|
369
|
+
def _fill(self, document: dict, item: dict, kind: str) -> None:
|
|
370
|
+
for name, field in self._fields.items():
|
|
371
|
+
if name.startswith("effect."):
|
|
372
|
+
field.set_value(document["effect"][name.split(".", 1)[1]])
|
|
373
|
+
elif name.startswith("@"):
|
|
374
|
+
field.set_value(item[name[1:]])
|
|
375
|
+
else:
|
|
376
|
+
field.set_value(item["properties"][name])
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
def locate(document: dict, target: str | None) -> tuple[dict | None, str]:
|
|
380
|
+
if target is None:
|
|
381
|
+
return None, "effect"
|
|
382
|
+
|
|
383
|
+
def visit(children):
|
|
384
|
+
for child in children:
|
|
385
|
+
if child["id"] == target:
|
|
386
|
+
return child
|
|
387
|
+
if child.get("type") == "group":
|
|
388
|
+
found = visit(child["children"])
|
|
389
|
+
if found is not None:
|
|
390
|
+
return found
|
|
391
|
+
return None
|
|
392
|
+
|
|
393
|
+
for layer in document["layers"]:
|
|
394
|
+
if layer["id"] == target:
|
|
395
|
+
return layer, "layer"
|
|
396
|
+
found = visit(layer["children"])
|
|
397
|
+
if found is not None:
|
|
398
|
+
return found, "group" if found.get("type") == "group" else "element"
|
|
399
|
+
for animation in document["animations"]:
|
|
400
|
+
if animation["id"] == target:
|
|
401
|
+
return animation, "animation"
|
|
402
|
+
return None, "effect"
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
def _layer_name(document: dict, item: dict, kind: str) -> str | None:
|
|
406
|
+
if kind == "animation":
|
|
407
|
+
return next((layer["name"] for layer in document["layers"] if layer["id"] == item["target"]), None)
|
|
408
|
+
|
|
409
|
+
def contains(children):
|
|
410
|
+
return any(child["id"] == item["id"] or (child.get("type") == "group" and contains(child["children"]))
|
|
411
|
+
for child in children)
|
|
412
|
+
|
|
413
|
+
return next((layer["name"] for layer in document["layers"] if contains(layer["children"])), None)
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
__all__ = ["Inspector", "field_for", "locate"]
|