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,6 +486,7 @@ 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"]]:
|
||||||
|
if self.find_element_with_focus() is not None:
|
||||||
self.nvda.speak(f"HARDWARE INPUT {key} {self.cache['hw_ins'][f'HARDWARE IN||{key}']}")
|
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,6 +508,7 @@ 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"]]:
|
||||||
|
if self.find_element_with_focus() is not None:
|
||||||
self.nvda.speak(f"HARDWARE OUT {key} {self.cache['hw_outs'][f'HARDWARE OUT||{key}']}")
|
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,6 +521,7 @@ 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"]]:
|
||||||
|
if self.find_element_with_focus() is not None:
|
||||||
val = values[f"ASIO CHECKBOX||{in_num} {channel}"]
|
val = values[f"ASIO CHECKBOX||{in_num} {channel}"]
|
||||||
channel = ("left", "right")[int(channel)]
|
channel = ("left", "right")[int(channel)]
|
||||||
num = int(in_num[-1])
|
num = int(in_num[-1])
|
||||||
@ -520,6 +534,7 @@ 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 self.find_element_with_focus() is not None:
|
||||||
if values[f"PATCH COMPOSITE||{key}"]:
|
if values[f"PATCH COMPOSITE||{key}"]:
|
||||||
val = values[f"PATCH COMPOSITE||{key}"]
|
val = values[f"PATCH COMPOSITE||{key}"]
|
||||||
else:
|
else:
|
||||||
@ -542,6 +557,7 @@ 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"]]:
|
||||||
|
if self.find_element_with_focus() is not None:
|
||||||
index = get_insert_checkbox_index(
|
index = get_insert_checkbox_index(
|
||||||
self.kind,
|
self.kind,
|
||||||
int(channel),
|
int(channel),
|
||||||
@ -554,7 +570,7 @@ class NVDAVMWindow(psg.Window):
|
|||||||
|
|
||||||
# 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,6 +609,7 @@ 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"]]:
|
||||||
|
if self.find_element_with_focus() is not None:
|
||||||
val = self.cache["strip"][f"STRIP {index}||{param}"]
|
val = self.cache["strip"][f"STRIP {index}||{param}"]
|
||||||
match param:
|
match param:
|
||||||
case "MONO":
|
case "MONO":
|
||||||
@ -664,6 +681,7 @@ 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"]]:
|
||||||
|
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":
|
||||||
|
Loading…
Reference in New Issue
Block a user