start laying out parameter sliders.

This commit is contained in:
onyx-and-iris 2023-09-16 10:45:56 +01:00
parent 719328c6de
commit e0f36b2411
3 changed files with 100 additions and 5 deletions

View File

@ -6,6 +6,7 @@ from .util import (
get_insert_checkbox_index,
get_output_device_list,
get_patch_composite_list,
get_slider_params,
get_tabs_labels,
)
@ -327,9 +328,52 @@ class Builder:
]
)
outputs = []
[step(outputs) for step in (add_gain_slider,)]
return psg.Frame(self.window.cache["labels"][f"STRIP {i}||LABEL"], outputs, key=f"STRIP {i}||LABEL||SLIDER")
def add_param_sliders(layout):
def default_value(i, param):
target = getattr(self.vm.strip[i], param.lower())
if param in ("COMP", "GATE", "DENOISER"):
return target.knob
return target
layout.append(
[
psg.Slider(
range=(0, 10),
default_value=default_value(i, param),
resolution=0.1,
disable_number_display=True,
size=(12, 10),
expand_x=True,
enable_events=True,
orientation="horizontal",
key=f"STRIP {i}||SLIDER {param}",
)
for param in get_slider_params(i, self.vm)
]
)
def add_limit_slider(layout):
layout.append(
[
psg.Slider(
range=(-40, 12),
default_value=self.vm.strip[i].limit,
resolution=0.1,
disable_number_display=True,
expand_x=True,
enable_events=True,
orientation="horizontal",
key=f"STRIP {i}||SLIDER LIMIT",
)
]
)
layout = []
steps = (add_gain_slider, add_param_sliders)
if self.kind.name in ("banana", "potato"):
steps += (add_limit_slider,)
[step(layout) for step in steps]
return psg.Frame(self.window.cache["labels"][f"STRIP {i}||LABEL"], layout, key=f"STRIP {i}||LABEL||SLIDER")
def make_tab1_slider_rows(self) -> psg.Frame:
layout = [[self.make_tab1_slider_row(i)] for i in range(self.kind.phys_in)]
@ -395,8 +439,45 @@ class Builder:
]
)
def add_param_sliders(layout):
def default_value(i, param):
return getattr(self.vm.strip[i], param.lower())
layout.append(
[
psg.Slider(
range=(0, 10),
default_value=default_value(i, param),
resolution=0.1,
disable_number_display=True,
size=(12, 10),
expand_x=True,
enable_events=True,
orientation="horizontal",
key=f"STRIP {i}||SLIDER {param}",
)
for param in get_slider_params(i, self.vm)
]
)
def add_limit_slider(layout):
layout.append(
[
psg.Slider(
range=(-40, 12),
default_value=self.vm.strip[i].limit,
resolution=0.1,
disable_number_display=True,
expand_x=True,
enable_events=True,
orientation="horizontal",
key=f"STRIP {i}||SLIDER LIMIT",
)
]
)
outputs = []
[step(outputs) for step in (add_gain_slider,)]
[step(outputs) for step in (add_gain_slider, add_param_sliders, add_limit_slider)]
return psg.Frame(self.window.cache["labels"][f"STRIP {i}||LABEL"], outputs, key=f"STRIP {i}||LABEL||SLIDER")
def make_tab2_slider_rows(self) -> psg.Frame:

View File

@ -130,10 +130,22 @@ def get_bus_modes(vm) -> list:
]
def check_bounds(val, bounds):
def check_bounds(val, bounds) -> int | float:
lower, upper = bounds
if val > upper:
val = upper
elif val < lower:
val = lower
return val
def get_slider_params(i, vm) -> list:
if i < vm.kind.phys_in:
if vm.kind.name == "basic":
return ("AUDIBILITY",)
elif vm.kind.name == "banana":
return ("COMP", "GATE")
elif vm.kind.name == "potato":
return ("COMP", "GATE", "DENOISER")
else:
return ("BASS", "MID", "TREBLE")

View File

@ -476,6 +476,8 @@ class NVDAVMWindow(psg.Window):
filepath = Path(filepath)
self.vm.set("command.load", str(filepath))
self.logger.debug(f"loading config file from {filepath}")
for i in (25, 50): # for the benefit of the sliders
self.TKroot.after(i, self.on_pdirty)
self.TKroot.after(
200,
self.nvda.speak,