2022-09-29 13:45:06 +01:00
|
|
|
import logging
|
2022-04-11 18:35:28 +01:00
|
|
|
import tkinter as tk
|
|
|
|
from tkinter import ttk
|
|
|
|
|
2022-05-10 20:34:29 +01:00
|
|
|
from . import builders
|
|
|
|
from .data import _configuration
|
2022-04-11 18:35:28 +01:00
|
|
|
from .gainlayer import SubMixFrame
|
|
|
|
|
2023-06-26 13:52:24 +01:00
|
|
|
logger = logging.getLogger(__name__)
|
2022-04-11 18:35:28 +01:00
|
|
|
|
2022-09-29 13:45:06 +01:00
|
|
|
|
2023-06-26 13:52:24 +01:00
|
|
|
class Navigation(ttk.Frame):
|
2022-04-11 18:35:28 +01:00
|
|
|
def __init__(self, parent):
|
|
|
|
super().__init__(parent)
|
2022-05-10 20:34:29 +01:00
|
|
|
self.parent = parent
|
2023-06-26 13:52:24 +01:00
|
|
|
self.logger = logger.getChild(self.__class__.__name__)
|
2022-06-20 00:09:27 +01:00
|
|
|
self.grid(row=0, column=3, padx=(0, 2), pady=(5, 5), sticky=(tk.W, tk.E))
|
2023-06-29 15:51:17 +01:00
|
|
|
if not _configuration.navigation_show:
|
|
|
|
self.grid_remove()
|
2022-05-10 20:34:29 +01:00
|
|
|
self.styletable = self.parent.styletable
|
2022-04-11 18:35:28 +01:00
|
|
|
|
2022-05-10 20:34:29 +01:00
|
|
|
self.builder = builders.NavigationFrameBuilder(self)
|
|
|
|
self.builder.setup()
|
|
|
|
self.builder.create_submix_button()
|
|
|
|
self.builder.create_channel_button()
|
|
|
|
self.builder.create_extend_button()
|
|
|
|
self.builder.create_info_button()
|
|
|
|
self.builder.grid_configure()
|
2022-04-11 18:35:28 +01:00
|
|
|
|
2022-05-10 20:34:29 +01:00
|
|
|
self.mainframebuilder = builders.MainFrameBuilder(self.parent)
|
2022-04-11 18:35:28 +01:00
|
|
|
|
|
|
|
def show_submix(self):
|
|
|
|
if self.submix.get():
|
2022-05-10 20:34:29 +01:00
|
|
|
self.parent.submix_frame = SubMixFrame(self.parent)
|
2022-09-29 13:45:06 +01:00
|
|
|
self.logger.info(
|
2025-01-15 20:56:37 +00:00
|
|
|
f'Finished building submixframe for submix {_configuration.submixes}'
|
2022-09-29 13:45:06 +01:00
|
|
|
)
|
2022-04-11 18:35:28 +01:00
|
|
|
else:
|
2022-05-10 20:34:29 +01:00
|
|
|
if _configuration.extends_horizontal:
|
|
|
|
self.parent.submix_frame.teardown()
|
|
|
|
if self.parent.bus_frame:
|
|
|
|
self.parent.bus_frame.grid()
|
2022-04-11 18:35:28 +01:00
|
|
|
else:
|
2022-05-10 20:34:29 +01:00
|
|
|
self.parent.columnconfigure(1, weight=0)
|
2022-04-11 18:35:28 +01:00
|
|
|
else:
|
2022-05-10 20:34:29 +01:00
|
|
|
self.parent.submix_frame.teardown()
|
|
|
|
if self.parent.bus_frame:
|
|
|
|
self.parent.bus_frame.grid()
|
2022-04-11 18:35:28 +01:00
|
|
|
else:
|
2022-05-10 20:34:29 +01:00
|
|
|
self.parent.rowconfigure(2, weight=0, minsize=0)
|
2022-09-29 13:45:06 +01:00
|
|
|
self.logger.info(
|
2025-01-15 20:56:37 +00:00
|
|
|
f'Finished tearing down submixframe for submix {_configuration.submixes}'
|
2022-09-29 13:45:06 +01:00
|
|
|
)
|
2022-04-11 18:35:28 +01:00
|
|
|
|
2022-05-10 20:34:29 +01:00
|
|
|
if not _configuration.themes_enabled:
|
|
|
|
self.styletable.configure(
|
2025-01-15 20:56:37 +00:00
|
|
|
'Submix.TButton',
|
2022-04-11 18:35:28 +01:00
|
|
|
background=f'{"purple" if self.submix.get() else "white"}',
|
|
|
|
)
|
|
|
|
|
|
|
|
def switch_channel(self):
|
2025-01-15 20:56:37 +00:00
|
|
|
if self.channel_text.get() == 'STRIP':
|
|
|
|
self.mainframebuilder.create_channelframe('bus')
|
2022-05-10 20:34:29 +01:00
|
|
|
self.parent.strip_frame.teardown()
|
2022-04-11 18:35:28 +01:00
|
|
|
else:
|
2025-01-15 20:56:37 +00:00
|
|
|
self.mainframebuilder.create_channelframe('strip')
|
2022-05-10 20:34:29 +01:00
|
|
|
self.parent.bus_frame.teardown()
|
2022-04-11 18:35:28 +01:00
|
|
|
|
2025-01-15 20:56:37 +00:00
|
|
|
self.extend_button['state'] = (
|
|
|
|
'disabled' if self.channel_text.get() == 'STRIP' else 'normal'
|
2022-04-11 18:35:28 +01:00
|
|
|
)
|
2022-05-10 20:34:29 +01:00
|
|
|
[frame.teardown() for frame in self.parent.configframes]
|
2025-01-15 20:56:37 +00:00
|
|
|
self.channel_text.set('BUS' if self.channel_text.get() == 'STRIP' else 'STRIP')
|
2022-04-11 18:35:28 +01:00
|
|
|
|
|
|
|
def extend_frame(self):
|
2022-05-10 20:34:29 +01:00
|
|
|
_configuration.extended = self.extend.get()
|
2022-04-11 18:35:28 +01:00
|
|
|
if self.extend.get():
|
2025-01-15 20:56:37 +00:00
|
|
|
self.channel_button['state'] = 'disabled'
|
|
|
|
self.mainframebuilder.create_channelframe('bus')
|
2022-04-11 18:35:28 +01:00
|
|
|
else:
|
|
|
|
[
|
2022-05-10 20:34:29 +01:00
|
|
|
frame.teardown()
|
|
|
|
for frame in self.parent.configframes
|
2025-01-15 20:56:37 +00:00
|
|
|
if '!busconfig' in str(frame)
|
2022-04-11 18:35:28 +01:00
|
|
|
]
|
2022-05-10 20:34:29 +01:00
|
|
|
self.parent.bus_frame.teardown()
|
|
|
|
self.parent.bus_frame = None
|
2025-01-15 20:56:37 +00:00
|
|
|
self.channel_button['state'] = 'normal'
|
2022-04-11 18:35:28 +01:00
|
|
|
|
2022-07-07 01:22:57 +01:00
|
|
|
if self.parent.submix_frame:
|
|
|
|
self.parent.submix_frame.teardown()
|
|
|
|
self.submix.set(False)
|
|
|
|
if not _configuration.themes_enabled:
|
|
|
|
self.styletable.configure(
|
2025-01-15 20:56:37 +00:00
|
|
|
'Submix.TButton',
|
2022-07-07 01:22:57 +01:00
|
|
|
background=f'{"purple" if self.submix.get() else "white"}',
|
|
|
|
)
|
2022-04-11 18:35:28 +01:00
|
|
|
|
2025-01-15 20:56:37 +00:00
|
|
|
self.extend_text.set('REDUCE' if self.extend.get() else 'EXTEND')
|