From a7644fce234e57160ca7bfee6d371c969d90bc8d Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Thu, 12 Oct 2023 09:40:01 +0900 Subject: [PATCH] =?UTF-8?q?[Update]=20Config=20Window:=20=E3=83=87?= =?UTF-8?q?=E3=83=90=E3=82=A4=E3=82=B9=E3=81=8C=E6=A4=9C=E5=87=BA=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E5=A0=B4=E5=90=88?= =?UTF-8?q?=E3=81=AEdisabled=E8=A1=A8=E7=A4=BA=E4=B8=80=E9=83=A8=E5=AE=9F?= =?UTF-8?q?=E8=A3=85(Mic=20Host,=20Mic=20Device,=20Speaker=20Device?= =?UTF-8?q?=E3=81=AE=E3=82=AA=E3=83=97=E3=82=B7=E3=83=A7=E3=83=B3=E3=83=A1?= =?UTF-8?q?=E3=83=8B=E3=83=A5=E3=83=BC=E3=81=AE=E3=81=BF)=20=E3=81=9D?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=81=9D=E3=81=AE=E9=96=A2=E6=95=B0=E3=81=AE?= =?UTF-8?q?=E6=B1=8E=E7=94=A8=E5=8C=96=E3=80=82=20[Chore]=20Appearance=20T?= =?UTF-8?q?heme=E3=82=92=E9=96=8B=E7=99=BA=E4=B8=AD=E3=81=A8=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=83=A9=E3=83=99=E3=83=AB=E7=B7=A8=E9=9B=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/en.yml | 2 +- locales/ja.yml | 2 +- view.py | 20 ++++++++++ vrct_gui/_changeConfigWindowWidgetsStatus.py | 26 +++++++++++++ vrct_gui/config_window/ConfigWindow.py | 2 + .../_SettingBoxGenerator.py | 38 +++++++++++++------ .../createSettingBox_Mic.py | 1 + .../createSettingBox_Speaker.py | 1 + .../createSidebarLanguagesSettings.py | 2 +- vrct_gui/ui_managers/ColorThemeManager.py | 2 + vrct_gui/ui_utils/ui_utils.py | 13 ++++++- 11 files changed, 94 insertions(+), 15 deletions(-) diff --git a/locales/en.yml b/locales/en.yml index 9778a3ae..ae3896d6 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -40,7 +40,7 @@ config_window: label: Transparency desc: Change the main window's transparency. appearance_theme: - label: Theme + label: Theme [Under development] desc: Change the color theme. If you selected "System", it will adjust based on your Windows theme. ui_size: label: UI Size diff --git a/locales/ja.yml b/locales/ja.yml index 6fafbeae..1a773f01 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -41,7 +41,7 @@ config_window: label: 透明度 desc: メイン画面の透明度を変更できます。 appearance_theme: - label: 外観テーマ + label: 外観テーマ [開発中] desc: カラーテーマを変更できます。「System」を選択した場合、Windowsのテーマに基づいて自動的に「Dark」か「Light」テーマを判断し、適用します。 ui_size: label: UIのサイズ diff --git a/view.py b/view.py index 73fe3910..dec8bf38 100644 --- a/view.py +++ b/view.py @@ -447,6 +447,26 @@ class View(): self.enableConfigWindowCompactMode() vrct_gui.config_window.setting_box_compact_mode_switch_box.select() + + + if config.CHOICE_MIC_HOST == "NoHost" or config.CHOICE_MIC_DEVICE == "NoDevice": + vrct_gui._changeConfigWindowWidgetsStatus( + status="disabled", + target_names=[ + "sb__optionmenu_mic_host", + "sb__optionmenu_mic_device", + ] + ) + + if config.CHOICE_SPEAKER_DEVICE == "NoDevice": + vrct_gui._changeConfigWindowWidgetsStatus( + status="disabled", + target_names=[ + "sb__optionmenu_speaker_device", + ] + ) + + # Insert sample conversation for testing. # self._insertSampleConversationToTextbox() diff --git a/vrct_gui/_changeConfigWindowWidgetsStatus.py b/vrct_gui/_changeConfigWindowWidgetsStatus.py index da2da440..0183c886 100644 --- a/vrct_gui/_changeConfigWindowWidgetsStatus.py +++ b/vrct_gui/_changeConfigWindowWidgetsStatus.py @@ -5,6 +5,16 @@ def _changeConfigWindowWidgetsStatus(config_window, settings, view_variable, sta target_names = ["mic_energy_threshold_check_button", "speaker_energy_threshold_check_button"] + def disableOptionmenuWidget(target_widget): + target_widget.label_widget.configure(text_color=settings.ctm.LABELS_TEXT_DISABLED_COLOR) + if target_widget.desc_widget is not None: + target_widget.desc_widget.configure(text_color=settings.ctm.LABELS_TEXT_DISABLED_COLOR) + target_widget.optionmenu_label_widget.configure(text_color=settings.ctm.LABELS_TEXT_DISABLED_COLOR) + target_widget.optionmenu_img_widget.configure(image=CTkImage(settings.image_file.ARROW_LEFT_DISABLED.rotate(90), size=settings.uism.SB__OPTIONMENU_IMG_SIZE)) + target_widget.optionmenu_box.unbindFunction() + target_widget.optionmenu_box.configure(cursor="") + + for target_name in target_names: match target_name: case "mic_energy_threshold_check_button": @@ -26,6 +36,22 @@ def _changeConfigWindowWidgetsStatus(config_window, settings, view_variable, sta config_window.sb__progressbar_x_slider__passive_button_speaker_energy_threshold.children["!ctklabel"].configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_COLOR) + case "sb__optionmenu_mic_host": + if status == "disabled": + target_widget = config_window.sb__widgets["sb__optionmenu_mic_host"] + disableOptionmenuWidget(target_widget) + + case "sb__optionmenu_mic_device": + if status == "disabled": + target_widget = config_window.sb__widgets["sb__optionmenu_mic_device"] + disableOptionmenuWidget(target_widget) + + case "sb__optionmenu_speaker_device": + if status == "disabled": + target_widget = config_window.sb__widgets["sb__optionmenu_speaker_device"] + disableOptionmenuWidget(target_widget) + + case _: raise ValueError(f"No matching case for target_name: {target_name}") diff --git a/vrct_gui/config_window/ConfigWindow.py b/vrct_gui/config_window/ConfigWindow.py index 918b9250..463fb78a 100644 --- a/vrct_gui/config_window/ConfigWindow.py +++ b/vrct_gui/config_window/ConfigWindow.py @@ -26,6 +26,8 @@ class ConfigWindow(CTkToplevel): # When the configuration window's compact mode is turned on, it will call `grid_remove()` on each widget appended to this array. In the opposite case, `grid()` will be called. self.additional_widgets = [] + self.sb__widgets = {} + createConfigWindowTitle(config_window=self, settings=self.settings, view_variable=self._view_variable) createSettingBoxTopBar(config_window=self, settings=self.settings, view_variable=self._view_variable) diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py index 6b509aec..6a92002a 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py @@ -1,4 +1,5 @@ from functools import partial +from types import SimpleNamespace from typing import Union from customtkinter import CTkOptionMenu, CTkFont, CTkFrame, CTkLabel, CTkRadioButton, CTkEntry, CTkSlider, CTkSwitch, CTkCheckBox, CTkProgressBar @@ -17,7 +18,9 @@ class _SettingBoxGenerator(): self.dropdown_menu_window = vrct_gui.vrct_gui.dropdown_menu_window - def _createSettingBoxFrame(self, for_var_label_text, for_var_desc_text): + def _createSettingBoxFrame(self, sb__attr_name, for_var_label_text, for_var_desc_text): + self.config_window.sb__widgets[sb__attr_name] = SimpleNamespace() + setting_box_frame = CTkFrame(self.parent_widget, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR, width=0, height=0) # "pady=(0,1)" is for bottom padding. It can be removed(override) when you do like "self.attr_name.grid(row=row, pady=0)" @@ -36,7 +39,7 @@ class _SettingBoxGenerator(): setting_box_frame_wrapper_fix_border2 = CTkFrame(setting_box_frame, corner_radius=0, width=0, height=0) setting_box_frame_wrapper_fix_border2.grid(row=0, column=1, sticky="ns") - self._setSettingBoxLabels(setting_box_frame_wrapper, for_var_label_text, for_var_desc_text) + self._setSettingBoxLabels(sb__attr_name, setting_box_frame_wrapper, for_var_label_text, for_var_desc_text) setting_box_item_frame = CTkFrame(setting_box_frame_wrapper, corner_radius=0, width=0, height=0, fg_color=self.settings.ctm.SB__BG_COLOR) setting_box_item_frame.grid(row=0, column=2, padx=0, sticky="nsew") @@ -45,7 +48,7 @@ class _SettingBoxGenerator(): return (setting_box_frame, setting_box_item_frame) - def _setSettingBoxLabels(self, setting_box_frame_wrapper, for_var_label_text, for_var_desc_text=None): + def _setSettingBoxLabels(self, sb__attr_name, setting_box_frame_wrapper, for_var_label_text, for_var_desc_text=None): setting_box_labels_frame = CTkFrame(setting_box_frame_wrapper, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR, width=0, height=0) setting_box_labels_frame.grid(row=0, column=0, padx=0, pady=0, sticky="nsew") @@ -59,6 +62,8 @@ class _SettingBoxGenerator(): text_color=self.settings.ctm.LABELS_TEXT_COLOR ) setting_box_label.grid(row=0, column=0, padx=0, pady=0, sticky="ew") + self.config_window.sb__widgets[sb__attr_name].label_widget = setting_box_label + if for_var_desc_text is not None: setting_box_desc = CTkLabel( @@ -73,17 +78,22 @@ class _SettingBoxGenerator(): ) setting_box_desc.grid(row=1, column=0, padx=0, pady=(self.settings.uism.SB__DESC_TOP_PADY,0), sticky="ew") self.config_window.additional_widgets.append(setting_box_desc) + self.config_window.sb__widgets[sb__attr_name].desc_widget=setting_box_desc + else: + self.config_window.sb__widgets[sb__attr_name].desc_widget=None + + def createSettingBoxDropdownMenu(self, for_var_label_text, for_var_desc_text, optionmenu_attr_name, command, dropdown_menu_width=None, variable=None, dropdown_menu_values=None): - (setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(for_var_label_text, for_var_desc_text) + (setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(optionmenu_attr_name, for_var_label_text, for_var_desc_text) def adjustedCommand(value): variable.set(value) command(value) - option_menu_widget = createOptionMenuBox( + (option_menu_widget, optionmenu_label_widget, optionmenu_img_widget) = createOptionMenuBox( parent_widget=setting_box_item_frame, optionmenu_bg_color=self.settings.ctm.SB__OPTIONMENU_BG_COLOR, optionmenu_hovered_bg_color=self.settings.ctm.SB__OPTIONMENU_HOVERED_BG_COLOR, @@ -104,6 +114,12 @@ class _SettingBoxGenerator(): ), ) + + self.config_window.sb__widgets[optionmenu_attr_name].optionmenu_box = option_menu_widget + self.config_window.sb__widgets[optionmenu_attr_name].optionmenu_label_widget = optionmenu_label_widget + self.config_window.sb__widgets[optionmenu_attr_name].optionmenu_img_widget = optionmenu_img_widget + + option_menu_widget.grid(row=1, column=SETTING_BOX_COLUMN, sticky="e") setattr(self.config_window, optionmenu_attr_name, option_menu_widget) @@ -122,7 +138,7 @@ class _SettingBoxGenerator(): def createSettingBoxSwitch(self, for_var_label_text, for_var_desc_text, switch_attr_name, is_checked, command): - (setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(for_var_label_text, for_var_desc_text) + (setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(switch_attr_name, for_var_label_text, for_var_desc_text) switch_widget = CTkSwitch( setting_box_item_frame, @@ -151,7 +167,7 @@ class _SettingBoxGenerator(): def createSettingBoxCheckbox(self, for_var_label_text, for_var_desc_text, checkbox_attr_name, variable, command): - (setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(for_var_label_text, for_var_desc_text) + (setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(checkbox_attr_name, for_var_label_text, for_var_desc_text) checkbox_widget = CTkCheckBox( setting_box_item_frame, @@ -185,7 +201,7 @@ class _SettingBoxGenerator(): def createSettingBoxSlider(self, for_var_label_text, for_var_desc_text, slider_attr_name, slider_range, command, variable, slider_number_of_steps: Union[int, None] = None): - (setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(for_var_label_text, for_var_desc_text) + (setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(slider_attr_name, for_var_label_text, for_var_desc_text) # print(self.settings.uism.SB__SLIDER_WIDTH) # print(self.settings.uism.SB__SLIDER_HEIGHT) @@ -212,7 +228,7 @@ class _SettingBoxGenerator(): def createSettingBoxProgressbarXSlider( self, - for_var_label_text, for_var_desc_text, command, + for_var_label_text, for_var_desc_text, command, progressbar_x_slider_attr_name, entry_attr_name, entry_bind__FocusOut, slider_attr_name, slider_range, progressbar_attr_name, @@ -227,7 +243,7 @@ class _SettingBoxGenerator(): ): - (setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(for_var_label_text, for_var_desc_text) + (setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(progressbar_x_slider_attr_name, for_var_label_text, for_var_desc_text) ENTRY_WIDTH = self.settings.uism.SB__PROGRESSBAR_X_SLIDER__ENTRY_WIDTH BAR_WIDTH = self.settings.uism.SB__PROGRESSBAR_X_SLIDER__BAR_WIDTH @@ -320,7 +336,7 @@ class _SettingBoxGenerator(): def createSettingBoxEntry(self, for_var_label_text, for_var_desc_text, entry_attr_name, entry_width, entry_bind__Any_KeyRelease, entry_textvariable, entry_bind__FocusOut=None): - (setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(for_var_label_text, for_var_desc_text) + (setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(entry_attr_name, for_var_label_text, for_var_desc_text) def adjusted_command__for_entry_bind__Any_KeyRelease(e): entry_bind__Any_KeyRelease(e.widget.get()) diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_transcription/createSettingBox_Mic.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_transcription/createSettingBox_Mic.py index 026c6539..6672cee7 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_transcription/createSettingBox_Mic.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_transcription/createSettingBox_Mic.py @@ -70,6 +70,7 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings, view_vari for_var_label_text=view_variable.VAR_LABEL_MIC_ENERGY_THRESHOLD, for_var_desc_text=view_variable.VAR_DESC_MIC_ENERGY_THRESHOLD, command=slider_input_mic_energy_threshold_callback, + progressbar_x_slider_attr_name="sb__mic_energy_threshold", entry_attr_name="sb__progressbar_x_slider__entry_mic_energy_threshold", entry_variable=view_variable.VAR_MIC_ENERGY_THRESHOLD__ENTRY, diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_transcription/createSettingBox_Speaker.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_transcription/createSettingBox_Speaker.py index 1e97eaee..01805127 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_transcription/createSettingBox_Speaker.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_transcription/createSettingBox_Speaker.py @@ -53,6 +53,7 @@ def createSettingBox_Speaker(setting_box_wrapper, config_window, settings, view_ for_var_label_text=view_variable.VAR_LABEL_SPEAKER_ENERGY_THRESHOLD, for_var_desc_text=view_variable.VAR_DESC_SPEAKER_ENERGY_THRESHOLD, command=slider_input_speaker_energy_threshold_callback, + progressbar_x_slider_attr_name="sb__speaker_energy_threshold", entry_variable=view_variable.VAR_SPEAKER_ENERGY_THRESHOLD__ENTRY, entry_attr_name="sb__progressbar_x_slider__entry_speaker_energy_threshold", diff --git a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py index 132cd86b..0363934e 100644 --- a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py +++ b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py @@ -80,7 +80,7 @@ def createSidebarLanguagesSettings(settings, main_window, view_variable): sls__box_optionmenu_wrapper.grid(row=1, column=0, sticky="ew") sls__box_optionmenu_wrapper.grid_columnconfigure(0, weight=1) - sls__selected_language_box = createOptionMenuBox( + (sls__selected_language_box, optionmenu_label_widget, optionmenu_img_widget) = createOptionMenuBox( parent_widget=sls__box_optionmenu_wrapper, optionmenu_bg_color=settings.ctm.SLS__OPTIONMENU_BG_COLOR, optionmenu_hovered_bg_color=settings.ctm.SLS__OPTIONMENU_HOVERED_BG_COLOR, diff --git a/vrct_gui/ui_managers/ColorThemeManager.py b/vrct_gui/ui_managers/ColorThemeManager.py index e297b6a7..541da271 100644 --- a/vrct_gui/ui_managers/ColorThemeManager.py +++ b/vrct_gui/ui_managers/ColorThemeManager.py @@ -220,6 +220,8 @@ class ColorThemeManager(): self.config_window.LABELS_TEXT_COLOR = self.config_window.BASIC_TEXT_COLOR self.config_window.LABELS_DESC_TEXT_COLOR = self.DARK_500_COLOR + self.config_window.LABELS_TEXT_DISABLED_COLOR = self.DARK_600_COLOR + # Top bar self.config_window.TOP_BAR_BG_COLOR = self.DARK_850_COLOR diff --git a/vrct_gui/ui_utils/ui_utils.py b/vrct_gui/ui_utils/ui_utils.py index 5dff06b9..ea957867 100644 --- a/vrct_gui/ui_utils/ui_utils.py +++ b/vrct_gui/ui_utils/ui_utils.py @@ -78,6 +78,11 @@ def bindButtonFunctionAndColor(target_widgets, enter_color, leave_color, clicked bindButtonPressColor(target_widgets, clicked_color, enter_color) bindButtonReleaseFunction(target_widgets, buttonReleasedFunction) +def unbindEnterLEaveButtonPressButtonReleaseFunction(target_widgets): + for target_widget in target_widgets: + for event_name in ["", "", "", ""]: + target_widget.unbind(event_name) + def unbindEventFromActiveTabWidget(active_tab_widget): for event_name in ["", "", "", ""]: active_tab_widget.unbind(event_name) @@ -192,7 +197,13 @@ def createOptionMenuBox(parent_widget, optionmenu_bg_color, optionmenu_hovered_b bindButtonReleaseFunction([optionmenu_label_wrapper, option_menu_box, optionmenu_label_widget, optionmenu_img_widget], optionmenu_clicked_command) - return option_menu_box + def unbindEventFromWidgets(): + unbindEnterLEaveButtonPressButtonReleaseFunction([optionmenu_label_wrapper, option_menu_box, optionmenu_label_widget, optionmenu_img_widget]) + + option_menu_box.unbindFunction = unbindEventFromWidgets + + + return (option_menu_box, optionmenu_label_widget, optionmenu_img_widget) def applyUiScalingAndFixTheBugScrollBar(scrollbar_widget, padx, width):