2023-08-22 16:11:24 +01:00
|
|
|
import PySimpleGUI as psg
|
|
|
|
|
2023-08-23 02:04:18 +01:00
|
|
|
from .util import (
|
|
|
|
get_asio_checkbox_index,
|
|
|
|
get_input_device_list,
|
|
|
|
get_insert_checkbox_index,
|
2023-08-25 18:29:43 +01:00
|
|
|
get_patch_composite_list,
|
2023-08-23 02:04:18 +01:00
|
|
|
)
|
2023-08-23 00:27:37 +01:00
|
|
|
|
2023-08-22 16:11:24 +01:00
|
|
|
|
|
|
|
class Builder:
|
|
|
|
"""Responsible for building the Window layout"""
|
|
|
|
|
|
|
|
def __init__(self, window, vm):
|
|
|
|
self.window = window
|
|
|
|
self.vm = vm
|
|
|
|
self.kind = self.vm.kind
|
|
|
|
|
|
|
|
def run(self) -> list:
|
2023-08-23 02:31:15 +01:00
|
|
|
layout = []
|
|
|
|
if self.kind.name == "basic":
|
|
|
|
steps = (self.make_row0,)
|
|
|
|
else:
|
2023-08-25 18:29:43 +01:00
|
|
|
steps = (self.make_row0, self.make_row1, self.make_row2, self.make_row3)
|
2023-08-23 02:31:15 +01:00
|
|
|
for step in steps:
|
|
|
|
layout.append([step()])
|
2023-08-25 18:29:43 +01:00
|
|
|
|
|
|
|
# dummy layouts
|
|
|
|
layout2 = [
|
|
|
|
[
|
|
|
|
psg.Button(
|
|
|
|
f"1",
|
|
|
|
size=(6, 3),
|
|
|
|
key=f"ZA BUTTON||1",
|
|
|
|
)
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
layout3 = [
|
|
|
|
[
|
|
|
|
psg.Button(
|
|
|
|
f"2",
|
|
|
|
size=(6, 3),
|
|
|
|
key=f"ZA BUTTON||2",
|
|
|
|
)
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
tab1 = psg.Tab("settings", layout)
|
|
|
|
tab2 = psg.Tab("physical strips", layout2)
|
|
|
|
tab3 = psg.Tab("virtual strips", layout3)
|
|
|
|
Tg = psg.TabGroup([[tab1, tab2, tab3]])
|
|
|
|
|
|
|
|
return [[Tg]]
|
2023-08-22 16:11:24 +01:00
|
|
|
|
2023-08-23 02:31:15 +01:00
|
|
|
def make_row0(self) -> psg.Frame:
|
2023-08-25 18:29:43 +01:00
|
|
|
"""row0 represents hardware outs"""
|
|
|
|
|
2023-08-22 16:11:24 +01:00
|
|
|
def add_physical_device_opts(layout):
|
2023-08-23 02:04:18 +01:00
|
|
|
devices = get_input_device_list(self.vm)
|
2023-08-24 16:07:28 +01:00
|
|
|
devices.append("- remove device selection -")
|
2023-08-22 16:11:24 +01:00
|
|
|
layout.append(
|
|
|
|
[
|
2023-08-24 16:07:28 +01:00
|
|
|
psg.ButtonMenu(
|
|
|
|
f"A{i}",
|
|
|
|
size=(6, 3),
|
|
|
|
menu_def=["", [f"{device}" for device in devices]],
|
2023-08-22 16:11:24 +01:00
|
|
|
key=f"HARDWARE OUT||A{i}",
|
|
|
|
)
|
|
|
|
for i in range(1, self.kind.phys_out + 1)
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
hardware_out = list()
|
|
|
|
[step(hardware_out) for step in (add_physical_device_opts,)]
|
|
|
|
return psg.Frame("Hardware Out", hardware_out)
|
|
|
|
|
2023-08-23 02:31:15 +01:00
|
|
|
def make_row1(self) -> psg.Frame:
|
2023-08-25 18:29:43 +01:00
|
|
|
"""row1 represents patch asio inputs to strips"""
|
|
|
|
|
2023-08-22 16:11:24 +01:00
|
|
|
def add_asio_checkboxes(layout, i):
|
|
|
|
nums = list(range(99))
|
|
|
|
layout.append(
|
2023-08-23 00:27:37 +01:00
|
|
|
[
|
|
|
|
psg.Spin(
|
|
|
|
nums,
|
|
|
|
initial_value=self.vm.patch.asio[get_asio_checkbox_index(0, i)].get(),
|
|
|
|
size=2,
|
|
|
|
enable_events=True,
|
|
|
|
key=f"ASIO CHECKBOX||IN{i} 0",
|
|
|
|
)
|
|
|
|
],
|
2023-08-22 16:11:24 +01:00
|
|
|
)
|
|
|
|
layout.append(
|
2023-08-23 00:27:37 +01:00
|
|
|
[
|
|
|
|
psg.Spin(
|
|
|
|
nums,
|
|
|
|
initial_value=self.vm.patch.asio[get_asio_checkbox_index(1, i)].get(),
|
|
|
|
size=2,
|
|
|
|
enable_events=True,
|
|
|
|
key=f"ASIO CHECKBOX||IN{i} 1",
|
|
|
|
)
|
|
|
|
],
|
2023-08-22 16:11:24 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
inner = list()
|
2023-08-22 18:13:15 +01:00
|
|
|
asio_checkboxlists = ([] for _ in range(self.kind.phys_out))
|
|
|
|
for i, checkbox_list in enumerate(asio_checkboxlists):
|
2023-08-22 16:11:24 +01:00
|
|
|
[step(checkbox_list, i + 1) for step in (add_asio_checkboxes,)]
|
|
|
|
inner.append(psg.Frame(f"In#{i + 1}", checkbox_list))
|
|
|
|
|
|
|
|
asio_checkboxes = [inner]
|
|
|
|
return psg.Frame("PATCH ASIO Inputs to Strips", asio_checkboxes)
|
2023-08-22 18:13:15 +01:00
|
|
|
|
2023-08-23 02:31:15 +01:00
|
|
|
def make_row2(self) -> psg.Frame:
|
2023-08-25 18:29:43 +01:00
|
|
|
"""row2 represents patch composite"""
|
|
|
|
|
|
|
|
def add_physical_device_opts(layout):
|
|
|
|
outputs = get_patch_composite_list(self.vm.kind)
|
|
|
|
outputs.append("BUS Channel")
|
|
|
|
layout.append(
|
|
|
|
[
|
|
|
|
psg.ButtonMenu(
|
|
|
|
f"PC{i}",
|
|
|
|
size=(6, 2),
|
|
|
|
menu_def=["", [f"{output}" for output in outputs]],
|
|
|
|
key=f"PATCH COMPOSITE||PC{i}",
|
|
|
|
)
|
|
|
|
for i in range(1, self.kind.phys_out + 1)
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
hardware_out = list()
|
|
|
|
[step(hardware_out) for step in (add_physical_device_opts,)]
|
|
|
|
return psg.Frame("PATCH COMPOSITE", hardware_out)
|
|
|
|
|
|
|
|
def make_row3(self) -> psg.Frame:
|
|
|
|
"""row3 represents patch insert"""
|
|
|
|
|
2023-08-22 18:13:15 +01:00
|
|
|
def add_insert_checkboxes(layout, i):
|
|
|
|
if i <= self.kind.phys_in:
|
2023-08-24 17:22:37 +01:00
|
|
|
[
|
|
|
|
layout.append(
|
|
|
|
[
|
|
|
|
psg.Checkbox(
|
|
|
|
text=channel,
|
|
|
|
default=self.vm.patch.insert[get_insert_checkbox_index(self.kind, j, i)].on,
|
|
|
|
enable_events=True,
|
|
|
|
key=f"INSERT CHECKBOX||IN{i} {j}",
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
for j, channel in enumerate(("LEFT", "RIGHT"))
|
|
|
|
]
|
2023-08-22 18:13:15 +01:00
|
|
|
else:
|
|
|
|
layout.append(
|
|
|
|
[
|
2023-08-23 00:27:37 +01:00
|
|
|
psg.Checkbox(
|
2023-08-24 17:22:37 +01:00
|
|
|
text=channel,
|
|
|
|
default=self.vm.patch.insert[get_insert_checkbox_index(self.kind, j, i)].on,
|
2023-08-23 00:27:37 +01:00
|
|
|
enable_events=True,
|
2023-08-24 17:22:37 +01:00
|
|
|
key=f"INSERT CHECKBOX||IN{i} {j}",
|
|
|
|
)
|
|
|
|
for j, channel in enumerate(("LEFT", "RIGHT", "C", "LFE", "SL", "SR", "BL", "BR"))
|
2023-08-22 18:13:15 +01:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
asio_checkboxes = list()
|
|
|
|
inner = list()
|
|
|
|
checkbox_lists = ([] for _ in range(self.kind.num_strip))
|
|
|
|
for i, checkbox_list in enumerate(checkbox_lists):
|
|
|
|
if i < self.kind.phys_in:
|
|
|
|
[step(checkbox_list, i + 1) for step in (add_insert_checkboxes,)]
|
|
|
|
inner.append(psg.Frame(f"In#{i + 1}", checkbox_list))
|
|
|
|
else:
|
|
|
|
[step(checkbox_list, i + 1) for step in (add_insert_checkboxes,)]
|
|
|
|
asio_checkboxes.append([psg.Frame(f"In#{i + 1}", checkbox_list)])
|
|
|
|
asio_checkboxes.insert(0, inner)
|
|
|
|
|
|
|
|
return psg.Frame("PATCH INSERT", asio_checkboxes)
|