mirror of
https://github.com/onyx-and-iris/nvda-voicemeeter.git
synced 2024-11-22 18:00:50 +00:00
start laying out nested tab structure
focus in events added for tabgroups focus the settings tab on startup
This commit is contained in:
parent
047577265c
commit
086fbc1b8c
@ -2,7 +2,6 @@ import PySimpleGUI as psg
|
|||||||
|
|
||||||
from .util import (
|
from .util import (
|
||||||
get_asio_checkbox_index,
|
get_asio_checkbox_index,
|
||||||
get_asio_samples_list,
|
|
||||||
get_input_device_list,
|
get_input_device_list,
|
||||||
get_insert_checkbox_index,
|
get_insert_checkbox_index,
|
||||||
get_output_device_list,
|
get_output_device_list,
|
||||||
@ -41,25 +40,49 @@ class Builder:
|
|||||||
for step in steps:
|
for step in steps:
|
||||||
layout0.append([step()])
|
layout0.append([step()])
|
||||||
|
|
||||||
layout1 = []
|
layout1_1 = []
|
||||||
steps = (self.make_tab1_rows,)
|
steps = (self.make_tab1_rows,)
|
||||||
for step in steps:
|
for step in steps:
|
||||||
layout1.append([step()])
|
layout1_1.append([step()])
|
||||||
|
|
||||||
layout2 = []
|
layout2_1 = []
|
||||||
steps = (self.make_tab2_rows,)
|
steps = (self.make_tab2_rows,)
|
||||||
for step in steps:
|
for step in steps:
|
||||||
layout2.append([step()])
|
layout2_1.append([step()])
|
||||||
|
|
||||||
layout3 = []
|
layout3_1 = []
|
||||||
steps = (self.make_tab3_rows,)
|
steps = (self.make_tab3_rows,)
|
||||||
for step in steps:
|
for step in steps:
|
||||||
layout3.append([step()])
|
layout3_1.append([step()])
|
||||||
|
|
||||||
layouts = [layout0, layout1, layout2, layout3]
|
def _make_inner_tabgroup(layouts, identifier) -> psg.TabGroup:
|
||||||
|
inner_layout = []
|
||||||
|
for i, tabname in enumerate(("buttons", "sliders")):
|
||||||
|
inner_layout.append([psg.Tab(tabname.capitalize(), layouts[i], key=f"tab||{identifier}||{tabname}")])
|
||||||
|
return psg.TabGroup(
|
||||||
|
inner_layout,
|
||||||
|
change_submits=True,
|
||||||
|
enable_events=True,
|
||||||
|
key=f"tabgroup||{identifier}",
|
||||||
|
)
|
||||||
|
|
||||||
tabs = [psg.Tab(identifier, layouts[i], key=identifier) for i, identifier in enumerate(get_tabs_labels())]
|
def _make_tabs(identifier) -> psg.Tab:
|
||||||
tab_group = psg.TabGroup([tabs], change_submits=True, key="tabs")
|
match identifier:
|
||||||
|
case "Settings":
|
||||||
|
return psg.Tab("Settings", layout0, key="tab||Settings")
|
||||||
|
case "Physical Strip":
|
||||||
|
tabgroup = _make_inner_tabgroup((layout1_1, []), identifier)
|
||||||
|
case "Virtual Strip":
|
||||||
|
tabgroup = _make_inner_tabgroup((layout2_1, []), identifier)
|
||||||
|
case "Buses":
|
||||||
|
tabgroup = _make_inner_tabgroup((layout3_1, []), identifier)
|
||||||
|
return psg.Tab(identifier, [[tabgroup]], key=f"tab||{identifier}")
|
||||||
|
|
||||||
|
tabs = []
|
||||||
|
for tab in get_tabs_labels():
|
||||||
|
tabs.append(_make_tabs(tab))
|
||||||
|
|
||||||
|
tab_group = psg.TabGroup([tabs], change_submits=True, enable_events=True, key="tabgroup")
|
||||||
|
|
||||||
return [[menu], [tab_group]]
|
return [[menu], [tab_group]]
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ from .util import (
|
|||||||
get_channel_identifier_list,
|
get_channel_identifier_list,
|
||||||
get_insert_checkbox_index,
|
get_insert_checkbox_index,
|
||||||
get_patch_composite_list,
|
get_patch_composite_list,
|
||||||
|
get_tabs_labels,
|
||||||
open_context_menu_for_buttonmenu,
|
open_context_menu_for_buttonmenu,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -65,6 +66,7 @@ class NVDAVMWindow(psg.Window):
|
|||||||
[self[f"PATCH COMPOSITE||PC{i + 1}"].Widget.config(**buttonmenu_opts) for i in range(self.kind.phys_out)]
|
[self[f"PATCH COMPOSITE||PC{i + 1}"].Widget.config(**buttonmenu_opts) for i in range(self.kind.phys_out)]
|
||||||
|
|
||||||
self.register_events()
|
self.register_events()
|
||||||
|
self["tabgroup"].set_focus()
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
settings_path = Path.cwd() / self.SETTINGS
|
settings_path = Path.cwd() / self.SETTINGS
|
||||||
@ -123,7 +125,10 @@ class NVDAVMWindow(psg.Window):
|
|||||||
"""Registers events for widgets"""
|
"""Registers events for widgets"""
|
||||||
|
|
||||||
# TABS
|
# TABS
|
||||||
self["tabs"].bind("<FocusIn>", "||FOCUS IN")
|
self["tabgroup"].bind("<FocusIn>", "||FOCUS IN")
|
||||||
|
for tabname in get_tabs_labels()[1:]:
|
||||||
|
self[f"tabgroup||{tabname}"].bind("<FocusIn>", "||FOCUS IN")
|
||||||
|
self[f"tabgroup||{tabname}"].bind("<Shift-KeyPress-Tab>", "||KEY SHIFT TAB")
|
||||||
self.bind("<Control-KeyPress-Tab>", "CTRL-TAB")
|
self.bind("<Control-KeyPress-Tab>", "CTRL-TAB")
|
||||||
self.bind("<Control-Shift-KeyPress-Tab>", "CTRL-SHIFT-TAB")
|
self.bind("<Control-Shift-KeyPress-Tab>", "CTRL-SHIFT-TAB")
|
||||||
self.bind("<Control-a>", "CTRL-A")
|
self.bind("<Control-a>", "CTRL-A")
|
||||||
@ -357,17 +362,16 @@ 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 == "tabs":
|
|
||||||
self.nvda.speak(f"tab {values['tabs']}")
|
|
||||||
|
|
||||||
match parsed_cmd := self.parser.match.parseString(event):
|
match parsed_cmd := self.parser.match.parseString(event):
|
||||||
# Focus tabgroup
|
# Focus tabgroup
|
||||||
case ["CTRL-TAB"] | ["CTRL-SHIFT-TAB"]:
|
case ["CTRL-TAB"] | ["CTRL-SHIFT-TAB"]:
|
||||||
self["tabs"].set_focus()
|
self["tabgroup"].set_focus()
|
||||||
|
self.nvda.speak(f"{values['tabgroup']}")
|
||||||
|
|
||||||
# Rename popups
|
# Rename popups
|
||||||
case ["F2:113"]:
|
case ["F2:113"]:
|
||||||
tab = values["tabs"]
|
tab = values["tabgroup"]
|
||||||
if tab in ("Physical Strip", "Virtual Strip", "Buses"):
|
if tab in ("Physical Strip", "Virtual Strip", "Buses"):
|
||||||
data = self.popup_rename("Label", title=f"Rename {tab}", tab=tab)
|
data = self.popup_rename("Label", title=f"Rename {tab}", tab=tab)
|
||||||
if not data: # cancel was pressed
|
if not data: # cancel was pressed
|
||||||
@ -452,11 +456,18 @@ class NVDAVMWindow(psg.Window):
|
|||||||
else:
|
else:
|
||||||
with open(self.SETTINGS, "wb") as f:
|
with open(self.SETTINGS, "wb") as f:
|
||||||
f.truncate()
|
f.truncate()
|
||||||
self.logger.debug("default bin was truncated")
|
self.logger.debug("settings.json was truncated")
|
||||||
|
|
||||||
# Tabs
|
# Tabs
|
||||||
case [["tabs"], ["FOCUS", "IN"]]:
|
case ["tabgroup"] | [["tabgroup"], ["FOCUS", "IN"]]:
|
||||||
self.nvda.speak(f"tab {values['tabs']}")
|
if self.find_element_with_focus() is None:
|
||||||
|
self.nvda.speak(f"{values['tabgroup']}")
|
||||||
|
case [["tabgroup"], tabname] | [["tabgroup"], tabname, ["FOCUS", "IN"]]:
|
||||||
|
if self.find_element_with_focus() is None:
|
||||||
|
name = " ".join(tabname)
|
||||||
|
self.nvda.speak(f"{values[f'tabgroup||{name}']}")
|
||||||
|
case [["tabgroup"], _, ["KEY", "SHIFT", "TAB"]]:
|
||||||
|
self.nvda.speak(values["tabgroup"])
|
||||||
|
|
||||||
# Hardware In
|
# Hardware In
|
||||||
case [["HARDWARE", "IN"], [key]]:
|
case [["HARDWARE", "IN"], [key]]:
|
||||||
@ -475,7 +486,8 @@ class NVDAVMWindow(psg.Window):
|
|||||||
f"HARDWARE IN {key} set {phonetic.get(driver, driver)} {device_name}",
|
f"HARDWARE IN {key} set {phonetic.get(driver, driver)} {device_name}",
|
||||||
)
|
)
|
||||||
case [["HARDWARE", "IN"], [key], ["FOCUS", "IN"]]:
|
case [["HARDWARE", "IN"], [key], ["FOCUS", "IN"]]:
|
||||||
self.nvda.speak(f"HARDWARE INPUT {key} {self.cache['hw_ins'][f'HARDWARE IN||{key}']}")
|
if self.find_element_with_focus() is not None:
|
||||||
|
self.nvda.speak(f"HARDWARE INPUT {key} {self.cache['hw_ins'][f'HARDWARE IN||{key}']}")
|
||||||
case [["HARDWARE", "IN"], [key], ["KEY", "SPACE" | "ENTER"]]:
|
case [["HARDWARE", "IN"], [key], ["KEY", "SPACE" | "ENTER"]]:
|
||||||
open_context_menu_for_buttonmenu(self, f"HARDWARE IN||{key}")
|
open_context_menu_for_buttonmenu(self, f"HARDWARE IN||{key}")
|
||||||
|
|
||||||
@ -496,7 +508,8 @@ class NVDAVMWindow(psg.Window):
|
|||||||
f"HARDWARE OUT {key} set {phonetic.get(driver, driver)} {device_name}",
|
f"HARDWARE OUT {key} set {phonetic.get(driver, driver)} {device_name}",
|
||||||
)
|
)
|
||||||
case [["HARDWARE", "OUT"], [key], ["FOCUS", "IN"]]:
|
case [["HARDWARE", "OUT"], [key], ["FOCUS", "IN"]]:
|
||||||
self.nvda.speak(f"HARDWARE OUT {key} {self.cache['hw_outs'][f'HARDWARE OUT||{key}']}")
|
if self.find_element_with_focus() is not None:
|
||||||
|
self.nvda.speak(f"HARDWARE OUT {key} {self.cache['hw_outs'][f'HARDWARE OUT||{key}']}")
|
||||||
case [["HARDWARE", "OUT"], [key], ["KEY", "SPACE" | "ENTER"]]:
|
case [["HARDWARE", "OUT"], [key], ["KEY", "SPACE" | "ENTER"]]:
|
||||||
open_context_menu_for_buttonmenu(self, f"HARDWARE OUT||{key}")
|
open_context_menu_for_buttonmenu(self, f"HARDWARE OUT||{key}")
|
||||||
|
|
||||||
@ -508,10 +521,11 @@ class NVDAVMWindow(psg.Window):
|
|||||||
channel = ("left", "right")[int(channel)]
|
channel = ("left", "right")[int(channel)]
|
||||||
self.nvda.speak(f"Patch ASIO {in_num} {channel} set to {val}")
|
self.nvda.speak(f"Patch ASIO {in_num} {channel} set to {val}")
|
||||||
case [["ASIO", "CHECKBOX"], [in_num, channel], ["FOCUS", "IN"]]:
|
case [["ASIO", "CHECKBOX"], [in_num, channel], ["FOCUS", "IN"]]:
|
||||||
val = values[f"ASIO CHECKBOX||{in_num} {channel}"]
|
if self.find_element_with_focus() is not None:
|
||||||
channel = ("left", "right")[int(channel)]
|
val = values[f"ASIO CHECKBOX||{in_num} {channel}"]
|
||||||
num = int(in_num[-1])
|
channel = ("left", "right")[int(channel)]
|
||||||
self.nvda.speak(f"Patch ASIO inputs to strips IN#{num} {channel} {val}")
|
num = int(in_num[-1])
|
||||||
|
self.nvda.speak(f"Patch ASIO inputs to strips IN#{num} {channel} {val}")
|
||||||
|
|
||||||
# Patch COMPOSITE
|
# Patch COMPOSITE
|
||||||
case [["PATCH", "COMPOSITE"], [key]]:
|
case [["PATCH", "COMPOSITE"], [key]]:
|
||||||
@ -520,12 +534,13 @@ class NVDAVMWindow(psg.Window):
|
|||||||
self.vm.patch.composite[index].set(get_patch_composite_list(self.kind).index(val) + 1)
|
self.vm.patch.composite[index].set(get_patch_composite_list(self.kind).index(val) + 1)
|
||||||
self.TKroot.after(200, self.nvda.speak, f"PATCH COMPOSITE {key[-1]} set {val}")
|
self.TKroot.after(200, self.nvda.speak, f"PATCH COMPOSITE {key[-1]} set {val}")
|
||||||
case [["PATCH", "COMPOSITE"], [key], ["FOCUS", "IN"]]:
|
case [["PATCH", "COMPOSITE"], [key], ["FOCUS", "IN"]]:
|
||||||
if values[f"PATCH COMPOSITE||{key}"]:
|
if self.find_element_with_focus() is not None:
|
||||||
val = values[f"PATCH COMPOSITE||{key}"]
|
if values[f"PATCH COMPOSITE||{key}"]:
|
||||||
else:
|
val = values[f"PATCH COMPOSITE||{key}"]
|
||||||
index = int(key[-1]) - 1
|
else:
|
||||||
val = get_patch_composite_list(self.kind)[self.vm.patch.composite[index].get() - 1]
|
index = int(key[-1]) - 1
|
||||||
self.nvda.speak(f"Patch COMPOSITE {key[-1]} {val}")
|
val = get_patch_composite_list(self.kind)[self.vm.patch.composite[index].get() - 1]
|
||||||
|
self.nvda.speak(f"Patch COMPOSITE {key[-1]} {val}")
|
||||||
case [["PATCH", "COMPOSITE"], [key], ["KEY", "SPACE" | "ENTER"]]:
|
case [["PATCH", "COMPOSITE"], [key], ["KEY", "SPACE" | "ENTER"]]:
|
||||||
open_context_menu_for_buttonmenu(self, f"PATCH COMPOSITE||{key}")
|
open_context_menu_for_buttonmenu(self, f"PATCH COMPOSITE||{key}")
|
||||||
|
|
||||||
@ -542,19 +557,20 @@ class NVDAVMWindow(psg.Window):
|
|||||||
f"PATCH INSERT {in_num} {_patch_insert_channels[int(channel)]} set to {'on' if val else 'off'}"
|
f"PATCH INSERT {in_num} {_patch_insert_channels[int(channel)]} set to {'on' if val else 'off'}"
|
||||||
)
|
)
|
||||||
case [["INSERT", "CHECKBOX"], [in_num, channel], ["FOCUS", "IN"]]:
|
case [["INSERT", "CHECKBOX"], [in_num, channel], ["FOCUS", "IN"]]:
|
||||||
index = get_insert_checkbox_index(
|
if self.find_element_with_focus() is not None:
|
||||||
self.kind,
|
index = get_insert_checkbox_index(
|
||||||
int(channel),
|
self.kind,
|
||||||
int(in_num[-1]),
|
int(channel),
|
||||||
)
|
int(in_num[-1]),
|
||||||
val = values[f"INSERT CHECKBOX||{in_num} {channel}"]
|
)
|
||||||
channel = _patch_insert_channels[int(channel)]
|
val = values[f"INSERT CHECKBOX||{in_num} {channel}"]
|
||||||
num = int(in_num[-1])
|
channel = _patch_insert_channels[int(channel)]
|
||||||
self.nvda.speak(f"Patch INSERT IN#{num} {channel} {'on' if val else 'off'}")
|
num = int(in_num[-1])
|
||||||
|
self.nvda.speak(f"Patch INSERT IN#{num} {channel} {'on' if val else 'off'}")
|
||||||
|
|
||||||
# Advanced Settings
|
# Advanced Settings
|
||||||
case ["ADVANCED SETTINGS"] | ["CTRL-A"]:
|
case ["ADVANCED SETTINGS"] | ["CTRL-A"]:
|
||||||
if values["tabs"] == "Settings":
|
if values["tabgroup"] == "tab||Settings":
|
||||||
self.popup_advanced_settings(title="Advanced Settings")
|
self.popup_advanced_settings(title="Advanced Settings")
|
||||||
case [["ADVANCED", "SETTINGS"], ["FOCUS", "IN"]]:
|
case [["ADVANCED", "SETTINGS"], ["FOCUS", "IN"]]:
|
||||||
self.nvda.speak("ADVANCED SETTINGS")
|
self.nvda.speak("ADVANCED SETTINGS")
|
||||||
@ -593,25 +609,26 @@ class NVDAVMWindow(psg.Window):
|
|||||||
self.cache["strip"][f"STRIP {index}||{param}"] = val
|
self.cache["strip"][f"STRIP {index}||{param}"] = val
|
||||||
self.nvda.speak(f"{label} {param} {'on' if val else 'off'}")
|
self.nvda.speak(f"{label} {param} {'on' if val else 'off'}")
|
||||||
case [["STRIP", index], [param], ["FOCUS", "IN"]]:
|
case [["STRIP", index], [param], ["FOCUS", "IN"]]:
|
||||||
val = self.cache["strip"][f"STRIP {index}||{param}"]
|
if self.find_element_with_focus() is not None:
|
||||||
match param:
|
val = self.cache["strip"][f"STRIP {index}||{param}"]
|
||||||
case "MONO":
|
match param:
|
||||||
if int(index) < self.kind.phys_in:
|
case "MONO":
|
||||||
actual = param.lower()
|
if int(index) < self.kind.phys_in:
|
||||||
elif int(index) == self.kind.phys_in + 1:
|
actual = param.lower()
|
||||||
actual = "k"
|
elif int(index) == self.kind.phys_in + 1:
|
||||||
else:
|
actual = "k"
|
||||||
actual = "mc"
|
else:
|
||||||
case _:
|
actual = "mc"
|
||||||
actual = param
|
case _:
|
||||||
phonetic = {"k": "karaoke"}
|
actual = param
|
||||||
label = self.cache["labels"][f"STRIP {index}||LABEL"]
|
phonetic = {"k": "karaoke"}
|
||||||
if actual == "k":
|
label = self.cache["labels"][f"STRIP {index}||LABEL"]
|
||||||
self.nvda.speak(
|
if actual == "k":
|
||||||
f"{label} {phonetic.get(actual, actual)} {['off', 'k m', 'k 1', 'k 2'][self.cache['strip'][f'STRIP {int(index)}||{param}']]}"
|
self.nvda.speak(
|
||||||
)
|
f"{label} {phonetic.get(actual, actual)} {['off', 'k m', 'k 1', 'k 2'][self.cache['strip'][f'STRIP {int(index)}||{param}']]}"
|
||||||
else:
|
)
|
||||||
self.nvda.speak(f"{label} {phonetic.get(actual, actual)} {'on' if val else 'off'}")
|
else:
|
||||||
|
self.nvda.speak(f"{label} {phonetic.get(actual, actual)} {'on' if val else 'off'}")
|
||||||
case [["STRIP", index], [param], ["KEY", "ENTER"]]:
|
case [["STRIP", index], [param], ["KEY", "ENTER"]]:
|
||||||
self.find_element_with_focus().click()
|
self.find_element_with_focus().click()
|
||||||
|
|
||||||
@ -664,12 +681,13 @@ class NVDAVMWindow(psg.Window):
|
|||||||
f"{label} bus mode {phonetic.get(next_bus, next_bus)}",
|
f"{label} bus mode {phonetic.get(next_bus, next_bus)}",
|
||||||
)
|
)
|
||||||
case [["BUS", index], [param], ["FOCUS", "IN"]]:
|
case [["BUS", index], [param], ["FOCUS", "IN"]]:
|
||||||
label = self.cache["labels"][f"BUS {index}||LABEL"]
|
if self.find_element_with_focus() is not None:
|
||||||
val = self.cache["bus"][f"BUS {index}||{param}"]
|
label = self.cache["labels"][f"BUS {index}||LABEL"]
|
||||||
if param == "MODE":
|
val = self.cache["bus"][f"BUS {index}||{param}"]
|
||||||
self.nvda.speak(f"{label} bus {param} {val}")
|
if param == "MODE":
|
||||||
else:
|
self.nvda.speak(f"{label} bus {param} {val}")
|
||||||
self.nvda.speak(f"{label} bus {param} {'on' if val else 'off'}")
|
else:
|
||||||
|
self.nvda.speak(f"{label} bus {param} {'on' if val else 'off'}")
|
||||||
case [["BUS", index], [param], ["KEY", "ENTER"]]:
|
case [["BUS", index], [param], ["KEY", "ENTER"]]:
|
||||||
self.find_element_with_focus().click()
|
self.find_element_with_focus().click()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user