2022-04-11 18:35:28 +01:00
|
|
|
import tkinter as tk
|
|
|
|
from functools import partial
|
2022-06-16 23:53:28 +01:00
|
|
|
from tkinter import ttk
|
2022-04-11 18:35:28 +01:00
|
|
|
|
2022-05-10 20:34:29 +01:00
|
|
|
from . import builders
|
2022-06-16 23:53:28 +01:00
|
|
|
from .data import _base_values, _configuration
|
2022-04-11 18:35:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Config(ttk.Frame):
|
|
|
|
def __init__(self, parent, index, _id):
|
|
|
|
super().__init__(parent)
|
2022-05-10 20:34:29 +01:00
|
|
|
self.parent = parent
|
2022-04-11 18:35:28 +01:00
|
|
|
self.index = index
|
|
|
|
self.id = _id
|
2022-05-10 20:34:29 +01:00
|
|
|
self.styletable = parent.styletable
|
2022-04-11 18:35:28 +01:00
|
|
|
self.phys_in, self.virt_in = parent.kind.ins
|
|
|
|
self.phys_out, self.virt_out = parent.kind.outs
|
|
|
|
|
2022-06-20 00:09:27 +01:00
|
|
|
self.parent.subject.add(self)
|
2022-04-11 18:35:28 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def identifier(self):
|
|
|
|
return self.id
|
|
|
|
|
|
|
|
@property
|
|
|
|
def target(self):
|
|
|
|
"""returns the current interface"""
|
2022-05-10 20:34:29 +01:00
|
|
|
|
|
|
|
return self.parent.target
|
2022-04-11 18:35:28 +01:00
|
|
|
|
|
|
|
def getter(self, param):
|
2022-05-14 17:24:33 +01:00
|
|
|
if hasattr(self.target, param):
|
2022-05-14 14:05:48 +01:00
|
|
|
return getattr(self.target, param)
|
2022-04-11 18:35:28 +01:00
|
|
|
|
|
|
|
def setter(self, param, value):
|
2022-05-14 17:24:33 +01:00
|
|
|
if hasattr(self.target, param):
|
2022-05-14 14:05:48 +01:00
|
|
|
setattr(self.target, param, value)
|
2022-04-11 18:35:28 +01:00
|
|
|
|
2022-05-14 14:05:48 +01:00
|
|
|
def scale_press(self, *args):
|
2022-09-16 09:44:47 +01:00
|
|
|
self.after(1, self.remove_events)
|
|
|
|
|
|
|
|
def remove_events(self):
|
|
|
|
self.parent.target.event.remove("pdirty")
|
|
|
|
self.parent.target.event.remove("ldirty")
|
2022-04-11 18:35:28 +01:00
|
|
|
|
2022-05-14 14:05:48 +01:00
|
|
|
def scale_release(self, *args):
|
2022-09-16 09:44:47 +01:00
|
|
|
_base_values.run_update = False
|
|
|
|
self.after(1, self.add_events)
|
|
|
|
|
|
|
|
def add_events(self):
|
|
|
|
self.parent.target.event.add("pdirty")
|
|
|
|
self.parent.target.event.add("ldirty")
|
|
|
|
self.after(350, self.resume_updates)
|
|
|
|
|
|
|
|
def resume_updates(self):
|
|
|
|
_base_values.run_update = True
|
2022-05-14 14:05:48 +01:00
|
|
|
|
|
|
|
def scale_enter(self, param, *args):
|
|
|
|
val = self.slider_vars[self.slider_params.index(param)].get()
|
|
|
|
self.parent.nav_frame.info_text.set(round(val, 1))
|
|
|
|
|
|
|
|
def scale_leave(self, *args):
|
2022-05-10 20:34:29 +01:00
|
|
|
self.parent.nav_frame.info_text.set("")
|
2022-04-11 18:35:28 +01:00
|
|
|
|
|
|
|
def scale_callback(self, param, *args):
|
|
|
|
"""callback function for scale widget"""
|
2022-05-10 20:34:29 +01:00
|
|
|
|
2022-04-11 18:35:28 +01:00
|
|
|
val = self.slider_vars[self.slider_params.index(param)].get()
|
|
|
|
self.setter(param, val)
|
2022-05-10 20:34:29 +01:00
|
|
|
self.parent.nav_frame.info_text.set(round(val, 1))
|
2022-04-11 18:35:28 +01:00
|
|
|
|
|
|
|
def reset_scale(self, param, val, *args):
|
|
|
|
self.setter(param, val)
|
|
|
|
self.slider_vars[self.slider_params.index(param)].set(val)
|
|
|
|
|
2022-05-10 20:34:29 +01:00
|
|
|
def toggle_p(self, param):
|
|
|
|
val = self.param_vars[self.params.index(param)].get()
|
|
|
|
self.setter(param, val)
|
|
|
|
if not _configuration.themes_enabled:
|
|
|
|
self.styletable.configure(
|
|
|
|
f"{param}.TButton", background=f'{"green" if val else "white"}'
|
|
|
|
)
|
2022-04-11 18:35:28 +01:00
|
|
|
|
2022-06-20 00:09:27 +01:00
|
|
|
def on_update(self, subject):
|
2022-05-14 14:05:48 +01:00
|
|
|
"""update parameters"""
|
2022-06-20 00:09:27 +01:00
|
|
|
if subject == "pdirty":
|
2022-07-07 01:22:57 +01:00
|
|
|
self.sync()
|
2022-04-11 18:35:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
class StripConfig(Config):
|
|
|
|
def __init__(self, parent, index, _id):
|
|
|
|
super().__init__(parent, index, _id)
|
2022-05-14 14:05:48 +01:00
|
|
|
self.grid(column=0, row=1, columnspan=4, padx=(2,))
|
2022-05-10 20:34:29 +01:00
|
|
|
self.builder = builders.StripConfigFrameBuilder(self)
|
|
|
|
self.builder.setup()
|
|
|
|
self.make_row_0()
|
|
|
|
self.make_row_1()
|
|
|
|
self.make_row_2()
|
|
|
|
self.builder.grid_configure()
|
2022-04-11 18:35:28 +01:00
|
|
|
|
|
|
|
self.sync()
|
|
|
|
|
|
|
|
@property
|
|
|
|
def target(self):
|
2022-05-10 20:34:29 +01:00
|
|
|
"""returns the strip class for this configframe in the current interface"""
|
|
|
|
|
2022-04-11 18:35:28 +01:00
|
|
|
_target = super(StripConfig, self).target
|
|
|
|
return getattr(_target, self.identifier)[self.index]
|
|
|
|
|
2022-05-10 20:34:29 +01:00
|
|
|
def make_row_0(self):
|
2022-04-11 18:35:28 +01:00
|
|
|
if self.index < self.phys_in:
|
2022-06-16 23:53:28 +01:00
|
|
|
if self.parent.kind.name == "basic":
|
2022-05-10 20:34:29 +01:00
|
|
|
self.builder.create_audibility_slider()
|
2022-04-11 18:35:28 +01:00
|
|
|
else:
|
2022-05-10 20:34:29 +01:00
|
|
|
self.builder.create_comp_slider()
|
|
|
|
self.builder.create_gate_slider()
|
|
|
|
self.builder.create_limit_slider()
|
2022-04-11 18:35:28 +01:00
|
|
|
|
2022-05-10 20:34:29 +01:00
|
|
|
def make_row_1(self):
|
|
|
|
self.builder.create_a_buttons()
|
|
|
|
self.builder.create_b_buttons()
|
|
|
|
|
|
|
|
def make_row_2(self):
|
|
|
|
self.builder.create_param_buttons()
|
2022-04-11 18:35:28 +01:00
|
|
|
|
|
|
|
def toggle_a(self, param):
|
|
|
|
val = self.phys_out_params_vars[self.phys_out_params.index(param)].get()
|
|
|
|
self.setter(param, val)
|
2022-05-10 20:34:29 +01:00
|
|
|
if not _configuration.themes_enabled:
|
|
|
|
self.styletable.configure(
|
2022-04-11 18:35:28 +01:00
|
|
|
f"{param}.TButton", background=f'{"green" if val else "white"}'
|
|
|
|
)
|
|
|
|
|
|
|
|
def toggle_b(self, param):
|
|
|
|
val = self.virt_out_params_vars[self.virt_out_params.index(param)].get()
|
|
|
|
self.setter(param, val)
|
2022-05-10 20:34:29 +01:00
|
|
|
if not _configuration.themes_enabled:
|
|
|
|
self.styletable.configure(
|
2022-04-11 18:35:28 +01:00
|
|
|
f"{param}.TButton", background=f'{"green" if val else "white"}'
|
|
|
|
)
|
|
|
|
|
2022-05-10 20:34:29 +01:00
|
|
|
def teardown(self):
|
|
|
|
self.builder.teardown()
|
2022-04-11 18:35:28 +01:00
|
|
|
|
|
|
|
def sync(self):
|
|
|
|
[
|
2022-05-14 14:05:48 +01:00
|
|
|
self.phys_out_params_vars[i].set(self.getter(param))
|
|
|
|
for i, param in enumerate(self.phys_out_params)
|
2022-04-11 18:35:28 +01:00
|
|
|
]
|
|
|
|
[
|
2022-05-14 14:05:48 +01:00
|
|
|
self.virt_out_params_vars[i].set(self.getter(param))
|
|
|
|
for i, param in enumerate(self.virt_out_params)
|
2022-04-11 18:35:28 +01:00
|
|
|
]
|
|
|
|
[
|
2022-05-14 14:05:48 +01:00
|
|
|
self.param_vars[i].set(self.getter(param))
|
|
|
|
for i, param in enumerate(self.params)
|
2022-04-11 18:35:28 +01:00
|
|
|
]
|
2022-05-10 20:34:29 +01:00
|
|
|
|
|
|
|
if not _configuration.themes_enabled:
|
2022-04-11 18:35:28 +01:00
|
|
|
[
|
2022-05-10 20:34:29 +01:00
|
|
|
self.styletable.configure(
|
2022-04-11 18:35:28 +01:00
|
|
|
f"{param}.TButton",
|
2022-05-14 14:05:48 +01:00
|
|
|
background=f'{"green" if self.phys_out_params_vars[i].get() else "white"}',
|
2022-04-11 18:35:28 +01:00
|
|
|
)
|
2022-05-14 14:05:48 +01:00
|
|
|
for i, param in enumerate(self.phys_out_params)
|
2022-04-11 18:35:28 +01:00
|
|
|
]
|
|
|
|
[
|
2022-05-10 20:34:29 +01:00
|
|
|
self.styletable.configure(
|
2022-04-11 18:35:28 +01:00
|
|
|
f"{param}.TButton",
|
2022-05-14 14:05:48 +01:00
|
|
|
background=f'{"green" if self.virt_out_params_vars[i].get() else "white"}',
|
2022-04-11 18:35:28 +01:00
|
|
|
)
|
2022-05-14 14:05:48 +01:00
|
|
|
for i, param in enumerate(self.virt_out_params)
|
2022-04-11 18:35:28 +01:00
|
|
|
]
|
|
|
|
[
|
2022-05-10 20:34:29 +01:00
|
|
|
self.styletable.configure(
|
2022-04-11 18:35:28 +01:00
|
|
|
f"{param}.TButton",
|
2022-05-14 14:05:48 +01:00
|
|
|
background=f'{"green" if self.param_vars[i].get() else "white"}',
|
2022-04-11 18:35:28 +01:00
|
|
|
)
|
2022-05-14 14:05:48 +01:00
|
|
|
for i, param in enumerate(self.params)
|
2022-04-11 18:35:28 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
class BusConfig(Config):
|
|
|
|
def __init__(self, parent, index, _id):
|
|
|
|
super().__init__(parent, index, _id)
|
2022-05-10 20:34:29 +01:00
|
|
|
if _configuration.extends_horizontal:
|
2022-05-14 14:05:48 +01:00
|
|
|
self.grid(column=0, row=1, columnspan=4, padx=(2,))
|
2022-05-10 20:34:29 +01:00
|
|
|
else:
|
2022-05-14 14:05:48 +01:00
|
|
|
self.grid(column=0, row=3, columnspan=4, padx=(2,))
|
2022-05-10 20:34:29 +01:00
|
|
|
self.builder = builders.BusConfigFrameBuilder(self)
|
|
|
|
self.builder.setup()
|
|
|
|
self.make_row_0()
|
|
|
|
self.make_row_1()
|
|
|
|
self.builder.grid_configure()
|
2022-04-27 14:22:23 +01:00
|
|
|
|
2022-05-10 20:34:29 +01:00
|
|
|
self.sync()
|
2022-04-11 18:35:28 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def target(self):
|
2022-05-10 20:34:29 +01:00
|
|
|
"""returns the bus class for this configframe in the current interface"""
|
|
|
|
|
2022-04-11 18:35:28 +01:00
|
|
|
_target = super(BusConfig, self).target
|
|
|
|
return getattr(_target, self.identifier)[self.index]
|
|
|
|
|
2022-05-10 20:34:29 +01:00
|
|
|
def make_row_0(self):
|
|
|
|
self.builder.create_bus_mode_button()
|
|
|
|
|
|
|
|
def make_row_1(self):
|
|
|
|
self.builder.create_param_buttons()
|
|
|
|
|
|
|
|
def current_bus_mode(self):
|
|
|
|
for mode in self.bus_modes:
|
|
|
|
if getattr(self.target.mode, mode):
|
|
|
|
return mode
|
2022-04-11 18:35:28 +01:00
|
|
|
|
|
|
|
def rotate_bus_modes_right(self, *args):
|
2022-05-10 20:34:29 +01:00
|
|
|
current_mode = self.current_bus_mode()
|
|
|
|
next = self.bus_modes.index(current_mode) + 1
|
|
|
|
if next < len(self.bus_modes):
|
|
|
|
setattr(
|
|
|
|
self.target.mode,
|
|
|
|
self.bus_modes[next],
|
|
|
|
True,
|
|
|
|
)
|
|
|
|
self.bus_mode_label_text.set(self.bus_mode_map[self.bus_modes[next]])
|
2022-04-11 18:35:28 +01:00
|
|
|
else:
|
2022-05-10 20:34:29 +01:00
|
|
|
self.target.mode.normal = True
|
|
|
|
self.bus_mode_label_text.set("Normal")
|
2022-04-11 18:35:28 +01:00
|
|
|
|
|
|
|
def rotate_bus_modes_left(self, *args):
|
2022-05-10 20:34:29 +01:00
|
|
|
current_mode = self.current_bus_mode()
|
|
|
|
prev = self.bus_modes.index(current_mode) - 1
|
|
|
|
if prev < 0:
|
|
|
|
self.target.mode.rearonly = True
|
|
|
|
self.bus_mode_label_text.set("Rear Only")
|
2022-04-11 18:35:28 +01:00
|
|
|
else:
|
2022-05-10 20:34:29 +01:00
|
|
|
setattr(
|
|
|
|
self.target.mode,
|
|
|
|
self.bus_modes[prev],
|
|
|
|
True,
|
2022-04-11 18:35:28 +01:00
|
|
|
)
|
2022-05-10 20:34:29 +01:00
|
|
|
self.bus_mode_label_text.set(self.bus_mode_map[self.bus_modes[prev]])
|
2022-04-11 18:35:28 +01:00
|
|
|
|
2022-05-10 20:34:29 +01:00
|
|
|
def teardown(self):
|
|
|
|
self.builder.teardown()
|
2022-04-11 18:35:28 +01:00
|
|
|
|
|
|
|
def sync(self):
|
|
|
|
[
|
2022-05-14 14:05:48 +01:00
|
|
|
self.param_vars[i].set(self.getter(param))
|
|
|
|
for i, param in enumerate(self.params)
|
2022-04-11 18:35:28 +01:00
|
|
|
]
|
2022-05-10 20:34:29 +01:00
|
|
|
self.bus_mode_label_text.set(self.bus_mode_map[self.current_bus_mode()])
|
|
|
|
if not _configuration.themes_enabled:
|
2022-04-11 18:35:28 +01:00
|
|
|
[
|
2022-05-10 20:34:29 +01:00
|
|
|
self.styletable.configure(
|
2022-04-11 18:35:28 +01:00
|
|
|
f"{param}.TButton",
|
2022-05-14 14:05:48 +01:00
|
|
|
background=f'{"green" if self.param_vars[i].get() else "white"}',
|
2022-04-11 18:35:28 +01:00
|
|
|
)
|
2022-05-14 14:05:48 +01:00
|
|
|
for i, param in enumerate(self.params)
|
2022-04-11 18:35:28 +01:00
|
|
|
]
|