initial busmode buttonmenu implementation

bump to 0.5.1a1
Issue #16
This commit is contained in:
onyx-and-iris 2023-09-28 19:44:42 +01:00
parent 496cc35321
commit 23458debaa
4 changed files with 51 additions and 34 deletions

View File

@ -1,6 +1,6 @@
[project] [project]
name = "nvda_voicemeeter" name = "nvda_voicemeeter"
version = "0.5.0" version = "0.5.1a1"
description = "A Voicemeeter app compatible with NVDA" description = "A Voicemeeter app compatible with NVDA"
authors = [ authors = [
{ name = "onyx-and-iris", email = "code@onyxandiris.online" }, { name = "onyx-and-iris", email = "code@onyxandiris.online" },

View File

@ -478,18 +478,26 @@ class Builder:
"""tab3 row represents bus composite toggle""" """tab3 row represents bus composite toggle"""
def add_strip_outputs(layout): def add_strip_outputs(layout):
params = ["MONO", "EQ", "MUTE", "MODE"] params = ["MONO", "EQ", "MUTE"]
if self.vm.kind.name == "basic": if self.vm.kind.name == "basic":
params.remove("EQ") params.remove("EQ")
label = {"MODE": "BUSMODE"} busmodes = [util._bus_mode_map[mode] for mode in util.get_bus_modes(self.vm)]
layout.append( layout.append(
[ [
*[
psg.Button( psg.Button(
label.get(param, param.capitalize()), param.capitalize(),
size=(12 if param == "MODE" else 6, 2), size=(6, 2),
key=f"BUS {i}||{param}", key=f"BUS {i}||{param}",
) )
for param in params for param in params
],
psg.ButtonMenu(
"BUSMODE",
size=(12, 2),
menu_def=["", busmodes],
key=f"BUS {i}||MODE",
),
] ]
) )

View File

@ -111,6 +111,24 @@ def get_channel_identifier_list(vm) -> list:
return identifiers return identifiers
_bus_mode_map = {
"normal": "Normal",
"amix": "Mix Down A",
"bmix": "Mix Down B",
"repeat": "Stereo Repeat",
"composite": "Composite",
"tvmix": "Up Mix TV",
"upmix21": "Up Mix 2.1",
"upmix41": "Up Mix 4.1",
"upmix61": "Up Mix 6.1",
"centeronly": "Center Only",
"lfeonly": "Low Frequency Effect Only",
"rearonly": "Rear Only",
}
_bus_mode_map_reversed = dict((reversed(item) for item in _bus_mode_map.items()))
def get_bus_modes(vm) -> list: def get_bus_modes(vm) -> list:
if vm.kind.name == "basic": if vm.kind.name == "basic":
return [ return [

View File

@ -57,6 +57,7 @@ class NVDAVMWindow(psg.Window):
self[f"STRIP {i}||SLIDER LIMIT"].Widget.config(**slider_opts) self[f"STRIP {i}||SLIDER LIMIT"].Widget.config(**slider_opts)
for i in range(self.kind.num_bus): for i in range(self.kind.num_bus):
self[f"BUS {i}||SLIDER GAIN"].Widget.config(**slider_opts) self[f"BUS {i}||SLIDER GAIN"].Widget.config(**slider_opts)
self[f"BUS {i}||MODE"].Widget.config(**buttonmenu_opts)
if self.kind.name != "basic": if self.kind.name != "basic":
for i in range(self.kind.phys_out): for i in range(self.kind.phys_out):
self[f"ASIO CHECKBOX||IN{i + 1} 0"].Widget.config(state="readonly") self[f"ASIO CHECKBOX||IN{i + 1} 0"].Widget.config(state="readonly")
@ -260,13 +261,16 @@ class NVDAVMWindow(psg.Window):
self[f"STRIP {i}||SLIDER {param}"].bind("<Control-Shift-KeyPress-R>", "||KEY CTRL SHIFT R") self[f"STRIP {i}||SLIDER {param}"].bind("<Control-Shift-KeyPress-R>", "||KEY CTRL SHIFT R")
# Bus Params # Bus Params
params = ["MONO", "EQ", "MUTE", "MODE"] params = ["MONO", "EQ", "MUTE"]
if self.vm.kind.name == "basic": if self.vm.kind.name == "basic":
params.remove("EQ") params.remove("EQ")
for i in range(self.kind.num_bus): for i in range(self.kind.num_bus):
for param in params: for param in params:
self[f"BUS {i}||{param}"].bind("<FocusIn>", "||FOCUS IN") self[f"BUS {i}||{param}"].bind("<FocusIn>", "||FOCUS IN")
self[f"BUS {i}||{param}"].bind("<Return>", "||KEY ENTER") self[f"BUS {i}||{param}"].bind("<Return>", "||KEY ENTER")
self[f"BUS {i}||MODE"].bind("<FocusIn>", "||FOCUS IN")
self[f"BUS {i}||MODE"].bind("<space>", "||KEY SPACE", propagate=False)
self[f"BUS {i}||MODE"].bind("<Return>", "||KEY ENTER", propagate=False)
# Bus Sliders # Bus Sliders
for i in range(self.kind.num_bus): for i in range(self.kind.num_bus):
@ -300,7 +304,7 @@ class NVDAVMWindow(psg.Window):
self.logger.debug(f"values::{values}") self.logger.debug(f"values::{values}")
if event in (psg.WIN_CLOSED, "Exit"): if event in (psg.WIN_CLOSED, "Exit"):
break break
elif event.endswith("MODE"): elif not event.startswith("BUS") and event.endswith("MODE"):
mode = event mode = event
self.nvda.speak(f"{mode} enabled") self.nvda.speak(f"{mode} enabled")
continue continue
@ -1002,39 +1006,26 @@ class NVDAVMWindow(psg.Window):
"on" if val else "off", "on" if val else "off",
) )
case "MODE": case "MODE":
bus_modes = util.get_bus_modes(self.vm) chosen = util._bus_mode_map_reversed[values[event]]
next_index = bus_modes.index(val) + 1 setattr(self.vm.bus[int(index)].mode, chosen, True)
if next_index == len(bus_modes): self.cache["bus"][event] = chosen
next_index = 0
next_bus = bus_modes[next_index]
phonetic = {
"amix": "Mix Down A",
"bmix": "Mix Down B",
"repeat": "Stereo Repeat",
"tvmix": "Up Mix TV",
"upmix21": "Up Mix 2.1",
"upmix41": "Up Mix 4.1",
"upmix61": "Up Mix 6.1",
"centeronly": "Center Only",
"lfeonly": "Low Frequency Effect Only",
"rearonly": "Rear Only",
}
setattr(self.vm.bus[int(index)].mode, next_bus, True)
self.cache["bus"][event] = next_bus
self.TKroot.after( self.TKroot.after(
200, 200,
self.nvda.speak, self.nvda.speak,
phonetic.get(next_bus, next_bus), util._bus_mode_map[chosen],
) )
case [["BUS", index], [param], ["FOCUS", "IN"]]: case [["BUS", index], [param], ["FOCUS", "IN"]]:
if self.find_element_with_focus() is not None: if self.find_element_with_focus() is not None:
label = self.cache["labels"][f"BUS {index}||LABEL"] label = self.cache["labels"][f"BUS {index}||LABEL"]
val = self.cache["bus"][f"BUS {index}||{param}"] val = self.cache["bus"][f"BUS {index}||{param}"]
if param == "MODE": if param == "MODE":
self.nvda.speak(f"{label} bus {param} {val}") self.nvda.speak(f"{label} bus{param} {util._bus_mode_map[val]}")
else: else:
self.nvda.speak(f"{label} bus{param} {'on' if val else 'off'}") self.nvda.speak(f"{label} bus{param} {'on' if val else 'off'}")
case [["BUS", index], [param], ["KEY", "ENTER"]]: case [["BUS", index], [param], ["KEY", "ENTER"]]:
if param == "MODE":
util.open_context_menu_for_buttonmenu(self, f"BUS {index}||MODE")
else:
self.find_element_with_focus().click() self.find_element_with_focus().click()
# Bus Sliders # Bus Sliders