Add multipage frames and Playback sliders to the show builder.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Sonnet 5.5 committed 2026-10-22 11:44:19 +13:00
1 parent 82e75e69de
commit b8e6b5f24b
3 files changed
+52 -15

No files matched your search

+31 -5
View File
@@ -26,6 +26,7 @@ class Slider:
cng: str = "None"
inverted: bool = False
binding: MidiBinding | None = None
function_id: int | None = None # set for a Playback slider, which has no channels
type_name: str = "Slider"
def render(self, indent: str = " ") -> str:
@@ -42,13 +43,13 @@ class Slider:
f'Width="{self.w}" Height="{self.h}"/>\n'
f"{appearance(fg=self.fg, indent=inner)}\n"
f'{inner}<SliderMode ValueDisplayStyle="Exact" ClickAndGoType={attr(self.cng)} '
f'Monitor="true">Level</SliderMode>\n'
f'Monitor="true">{"Playback" if self.function_id is not None else "Level"}</SliderMode>\n'
f"{inner}<Reset/>\n"
f'{inner}<Level LowLimit="0" HighLimit="255" Value="{self.value}">\n'
f"{channels}\n"
f"{inner}</Level>\n"
f"{inner}<Playback>\n"
f"{inner} <Function>{INVALID_FUNCTION}</Function>\n"
f"{inner} <Function>{INVALID_FUNCTION if self.function_id is None else self.function_id}</Function>\n"
f"{inner}</Playback>{extra}\n"
f"{indent}</Slider>"
)
@@ -132,6 +133,9 @@ class Frame:
solo: bool = False
root: bool = False
show_header: bool = True
pages: int = 1
loop: bool = False
page: int = 0
children: list[Any] = field(default_factory=list)
id: int | None = None
type_name: str = "Frame"
@@ -155,7 +159,10 @@ class Frame:
cng: str = "None",
inverted: bool = False,
input: MidiBinding | None = None,
function: Any = None,
) -> Slider:
if isinstance(function, str):
function = self.show.functions_by_key[function].id
widget = Slider(
id=self.show.alloc_widget(),
caption=caption,
@@ -169,6 +176,7 @@ class Frame:
cng=cng,
inverted=inverted,
binding=input,
function_id=function,
)
self.children.append(widget)
return widget
@@ -251,8 +259,11 @@ class Frame:
h: int,
solo: bool = False,
header: bool = True,
pages: int = 1,
loop: bool = False,
page: int = 0,
) -> Frame:
child = Frame(self.show, caption, x, y, w, h, solo=solo, show_header=header)
child = Frame(self.show, caption, x, y, w, h, solo=solo, show_header=header, pages=pages, loop=loop, page=page)
self.children.append(child)
return child
@@ -281,9 +292,14 @@ class Frame:
if not self.solo:
flags.append(f"{inner}<ShowIntensityButton>False</ShowIntensityButton>")
flags.append(f"{inner}<Mixing>False</Mixing>")
nested = "\n".join(child.render(inner) for child in self.children)
if self.pages > 1:
flags.append(
f'{inner}<Multipage PagesNum="{self.pages}" CurrentPage="0" PagesLoop="{"True" if self.loop else "False"}"/>'
)
nested = "\n".join(_on_page(child, inner) for child in self.children)
page_attr = f' Page="{self.page}"' if self.page else ""
parts = [
f"{indent}<{tag} Caption={attr(self.caption)} ID=\"{self.id}\">",
f"{indent}<{tag} Caption={attr(self.caption)} ID=\"{self.id}\"{page_attr}>",
appearance(indent=inner),
f'{inner}<WindowState Visible="True" X="{self.x}" Y="{self.y}" Width="{self.w}" Height="{self.h}"/>',
*flags,
@@ -294,6 +310,16 @@ class Frame:
return "\n".join(parts)
def _on_page(child: Any, indent: str) -> str:
"""Render a child, tagging its opening element with the frame page it is on."""
text = child.render(indent)
page = getattr(child, "page", 0)
if not page or isinstance(child, Frame):
return text
head, sep, rest = text.partition(">")
return f'{head} Page="{page}"{sep}{rest}'
def _input_xml(binding: MidiBinding | None, indent: str) -> str:
if binding is None:
return ""