The layout, chase colours, mover speeds and levels as saved from QLC+: the colour frames stacked on the left with the cans and movers pads beside them. The Colour 1 and Colour 2 buttons are 75 px squares, and the Chase runs and Pads layer frames below Colour 2 move down to clear them (scripts/shows/square_colours.py). The Movers speed dial comes in from x=1820 to beside Movers position, and both speed dials are trimmed to the dial and its time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
3.2 KiB
Python
71 lines
3.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Make the Colour 1 and Colour 2 buttons in shows/test.qxw square.
|
|
|
|
They were 90 wide and 60 high on a 96 by 66 grid. Now they are 75 square on an
|
|
81 grid, which keeps the 4 by 4 layout and makes each frame 338 wide and 338
|
|
high. The collapsed Chase runs frame, which sat just under Colour 2, moves down
|
|
to stay under it, and the Pads layer frame under that moves down to clear it;
|
|
the rest of the console stays where it is.
|
|
|
|
python3 scripts/shows/square_colours.py
|
|
|
|
It stops if the buttons are already square. QLC+ has to reopen the show to
|
|
see it.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
|
|
from mover_bank import ROOT
|
|
|
|
SHOW = ROOT / "shows" / "test.qxw"
|
|
FRAMES = ('<SoloFrame Caption="Colour 1" ID="0">', '<SoloFrame Caption="Colour 2" ID="22">')
|
|
SIZE, PITCH, MARGIN = 75, 81, 10
|
|
BOTTOM = 10 # below the last row
|
|
GAP = 5
|
|
COLLAPSED = 60 # room a collapsed frame takes, as the saved layout left it
|
|
# Below Colour 2, top to bottom: (caption, ID) of each frame pushed down to clear the one above
|
|
BELOW = (("Chase runs", 83), ("Pads layer", 129))
|
|
|
|
|
|
def main() -> None:
|
|
xml = SHOW.read_text()
|
|
for head in FRAMES:
|
|
start = xml.index(head)
|
|
end = xml.index("</SoloFrame>", start)
|
|
frame = xml[start:end]
|
|
spots = re.findall(r'( <WindowState Visible="True" X="(\d+)" Y="(\d+)" Width="(\d+)" Height="(\d+)"/>)', frame)
|
|
if len(spots) != 16:
|
|
raise SystemExit(f"{head} doesn't have its 16 buttons")
|
|
if all(w == h for _, _, _, w, h in spots):
|
|
raise SystemExit(f"The buttons in {head} are already square")
|
|
cols = sorted({int(x) for _, x, _, _, _ in spots})
|
|
rows = sorted({int(y) for _, _, y, _, _ in spots})
|
|
for line, x, y, _, _ in spots:
|
|
nx, ny = MARGIN + cols.index(int(x)) * PITCH, MARGIN + rows.index(int(y)) * PITCH
|
|
frame = frame.replace(line, f' <WindowState Visible="True" X="{nx}" Y="{ny}" Width="{SIZE}" Height="{SIZE}"/>', 1)
|
|
right = MARGIN + (len(cols) - 1) * PITCH + SIZE + MARGIN
|
|
bottom = MARGIN + (len(rows) - 1) * PITCH + SIZE + BOTTOM
|
|
frame = re.sub(r'( <WindowState Visible="True" X="\d+" Y="\d+") Width="\d+" Height="\d+"/>',
|
|
rf'\1 Width="{right}" Height="{bottom}"/>', frame, count=1)
|
|
xml = xml[:start] + frame + xml[end:]
|
|
# Push the frames under Colour 2 down to clear it, each under the last.
|
|
colour_2 = re.search(r'<SoloFrame Caption="Colour 2" ID="22">.*?<WindowState Visible="True" X="\d+" Y="(\d+)" '
|
|
r'Width="\d+" Height="(\d+)"/>', xml, re.S)
|
|
top = int(colour_2.group(1)) + int(colour_2.group(2)) + GAP
|
|
for caption, wid in BELOW:
|
|
m = re.search(rf'(<Frame Caption="{caption}" ID="{wid}">.*?<WindowState Visible="True" X="\d+" Y=")(\d+)'
|
|
rf'(" Width="\d+" Height=")(\d+)(".*?<Collapsed>)(\w+)', xml, re.S)
|
|
if m is None:
|
|
raise SystemExit(f"Couldn't find the {caption} frame")
|
|
y = max(int(m.group(2)), top)
|
|
xml = xml[:m.start(2)] + str(y) + xml[m.end(2):]
|
|
top = y + (COLLAPSED if m.group(6) == "True" else int(m.group(4))) + GAP
|
|
SHOW.write_text(xml)
|
|
print(f"Made the colour buttons in {SHOW.relative_to(ROOT)} square")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|