events defined for sliders

resolution fix for limit slider
This commit is contained in:
onyx-and-iris 2023-09-17 11:25:11 +01:00
parent 3d7b33c8be
commit 1fdb39a041
2 changed files with 115 additions and 21 deletions

View File

@ -10,13 +10,17 @@ class LabelSlider(psg.Frame):
size = 7 size = 7
else: else:
size = 4 size = 4
if param == "LIMIT":
resolution = 1
else:
resolution = 0.1
layout = [ layout = [
[ [
psg.Text(param.capitalize(), size=size), psg.Text(param.capitalize(), size=size),
psg.Slider( psg.Slider(
range=range_, range=range_,
default_value=self.default_value(i, param), default_value=self.default_value(i, param),
resolution=0.1, resolution=resolution,
disable_number_display=True, disable_number_display=True,
size=(12, 16), size=(12, 16),
expand_x=True, expand_x=True,

View File

@ -672,52 +672,142 @@ class NVDAVMWindow(psg.Window):
self.find_element_with_focus().click() self.find_element_with_focus().click()
# Strip Sliders # Strip Sliders
case [["STRIP", index], ["SLIDER", "GAIN"]]: case [
["STRIP", index],
["SLIDER", "GAIN" | "COMP" | "GATE" | "DENOISER" | "AUDIBILITY" | "LIMIT" as param],
]:
label = self.cache["labels"][f"STRIP {index}||LABEL"] label = self.cache["labels"][f"STRIP {index}||LABEL"]
self.nvda.speak(f"{label} gain slider {val}") val = values[event]
case [["STRIP", index], ["SLIDER", "GAIN"], ["FOCUS", "IN"]]: match param:
case "GAIN":
self.vm.strip[int(index)].gain = val
case "COMP" | "GATE" | "DENOISER":
target = getattr(self.vm.strip[int(index)], param.lower())
target.knob = val
case "AUDIBILITY":
self.vm.strip[int(index)].audibility = val
case "LIMIT":
val = int(val)
self.vm.strip[int(index)].limit = val
self.nvda.speak(f"{label} {param} slider {val}")
case [
["STRIP", index],
["SLIDER", "GAIN" | "COMP" | "GATE" | "DENOISER" | "AUDIBILITY" | "LIMIT" as param],
["FOCUS", "IN"],
]:
if self.find_element_with_focus() is not None: if self.find_element_with_focus() is not None:
self.vm.event.pdirty = False self.vm.event.pdirty = False
label = self.cache["labels"][f"STRIP {index}||LABEL"] label = self.cache["labels"][f"STRIP {index}||LABEL"]
val = values[f"STRIP {index}||SLIDER GAIN"] val = values[f"STRIP {index}||SLIDER {param}"]
self.nvda.speak(f"{label} gain slider {val}") if param == "LIMIT":
case [["STRIP", index], ["SLIDER", "GAIN"], ["FOCUS", "OUT"]]: val = int(val)
self.nvda.speak(f"{label} {param} slider {val}")
case [
["STRIP", index],
["SLIDER", "GAIN" | "COMP" | "GATE" | "DENOISER" | "AUDIBILITY" | "LIMIT"],
["FOCUS", "OUT"],
]:
self.vm.event.pdirty = True self.vm.event.pdirty = True
case [["STRIP", index], ["SLIDER", "GAIN"], ["KEY", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction]]: case [
val = self.vm.strip[int(index)].gain ["STRIP", index],
["SLIDER", "GAIN" | "COMP" | "GATE" | "DENOISER" | "AUDIBILITY" | "LIMIT" as param],
["KEY", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction],
]:
match param:
case "GAIN":
val = self.vm.strip[int(index)].gain
case "LIMIT":
val = self.vm.strip[int(index)].limit
case "COMP" | "GATE" | "DENOISER":
target = getattr(self.vm.strip[int(index)], param.lower())
val = target.knob
case "AUDIBILITY":
val = self.vm.strip[int(index)].audibility
match direction: match direction:
case "RIGHT" | "UP": case "RIGHT" | "UP":
val += 1 val += 1
case "LEFT" | "DOWN": case "LEFT" | "DOWN":
val -= 1 val -= 1
self.vm.strip[int(index)].gain = util.check_bounds(val, (-60, 12))
self[f"STRIP {index}||SLIDER GAIN"].update(value=util.check_bounds(val, (-60, 12))) match param:
case "GAIN":
self.vm.strip[int(index)].gain = util.check_bounds(val, (-60, 12))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (-60, 12)))
case "LIMIT":
self.vm.strip[int(index)].limit = util.check_bounds(val, (-40, 12))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (-40, 12)))
case "COMP" | "GATE" | "DENOISER":
setattr(target, "knob", util.check_bounds(val, (0, 10)))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (0, 10)))
case "AUDIBILITY":
self.vm.strip[int(index)].audibility = util.check_bounds(val, (0, 10))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (0, 10)))
case [ case [
["STRIP", index], ["STRIP", index],
["SLIDER", "GAIN"], ["SLIDER", "GAIN" | "LIMIT" as param],
["KEY", "CTRL", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction], ["KEY", "CTRL", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction],
]: ]:
val = self.vm.strip[int(index)].gain match param:
case "GAIN":
val = self.vm.strip[int(index)].gain
case "LIMIT":
val = self.vm.strip[int(index)].limit
match direction: match direction:
case "RIGHT" | "UP": case "RIGHT" | "UP":
val += 3 val += 3
case "LEFT" | "DOWN": case "LEFT" | "DOWN":
val -= 3 val -= 3
self.vm.strip[int(index)].gain = util.check_bounds(val, (-60, 12))
self[f"STRIP {index}||SLIDER GAIN"].update(value=util.check_bounds(val, (-60, 12))) match param:
case "GAIN":
self.vm.strip[int(index)].gain = util.check_bounds(val, (-60, 12))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (-60, 12)))
case "LIMIT":
self.vm.strip[int(index)].limit = util.check_bounds(val, (-40, 12))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (-40, 12)))
case [ case [
["STRIP", index], ["STRIP", index],
["SLIDER", "GAIN"], ["SLIDER", "GAIN" | "COMP" | "GATE" | "DENOISER" | "AUDIBILITY" | "LIMIT" as param],
["KEY", "SHIFT", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction], ["KEY", "SHIFT", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction],
]: ]:
val = self.vm.strip[int(index)].gain match param:
case "GAIN":
val = self.vm.strip[int(index)].gain
case "COMP" | "GATE" | "DENOISER":
target = getattr(self.vm.strip[int(index)], param.lower())
val = target.knob
case "AUDIBILITY":
val = self.vm.strip[int(index)].audibility
case "LIMIT":
val = self.vm.strip[int(index)].limit
match direction: match direction:
case "RIGHT" | "UP": case "RIGHT" | "UP":
val += 0.1 if param == "LIMIT":
val += 1
else:
val += 0.1
case "LEFT" | "DOWN": case "LEFT" | "DOWN":
val -= 0.1 if param == "LIMIT":
self.vm.strip[int(index)].gain = util.check_bounds(val, (-60, 12)) val -= 1
self[f"STRIP {index}||SLIDER GAIN"].update(value=util.check_bounds(val, (-60, 12))) else:
val -= 0.1
match param:
case "GAIN":
self.vm.strip[int(index)].gain = util.check_bounds(val, (-60, 12))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (-60, 12)))
case "COMP" | "GATE" | "DENOISER":
setattr(target, "knob", util.check_bounds(val, (0, 10)))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (0, 10)))
case "AUDIBILITY":
self.vm.strip[int(index)].audibility = util.check_bounds(val, (0, 10))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (0, 10)))
case "LIMIT":
self.vm.strip[int(index)].limit = util.check_bounds(val, (-40, 12))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (-40, 12)))
# Bus Params # Bus Params
case [["BUS", index], [param]]: case [["BUS", index], [param]]: