From 8e55a5426c29497360af08a9ee336d1963ae71d7 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Thu, 19 Oct 2023 08:53:44 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[Update]=20Config=20Window:=20=E5=90=84?= =?UTF-8?q?=E9=A0=85=E7=9B=AE=E3=81=AE=E3=82=A8=E3=83=A9=E3=83=BC=E3=83=A1?= =?UTF-8?q?=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=EF=BC=88=E4=BB=AE=E7=BD=AE=E3=81=8D=E3=81=98=E3=82=83=E3=81=AA?= =?UTF-8?q?=E3=81=8F=E3=81=AA=E3=82=8A=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/en.yml | 32 +++++++++++ locales/ja.yml | 31 +++++++++++ view.py | 69 ++++++++++++++++++++---- vrct_gui/ui_managers/UiScalingManager.py | 2 +- 4 files changed, 124 insertions(+), 10 deletions(-) diff --git a/locales/en.yml b/locales/en.yml index e1616fd8..3c1dc124 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -66,6 +66,9 @@ config_window: compact_mode: Compact Mode version: version %{version} restart_message: Apply changes with a restart. + common_error_message: + invalid_value: Invalid value. + side_menu_labels: appearance: Appearance # translation: Translation @@ -75,16 +78,21 @@ config_window: others: Others advanced_settings: Advanced Settings + transparency: label: Transparency desc: Change the main window's transparency. + appearance_theme: label: Theme [Under development] desc: Change the color theme. Currently, only the Dark theme is supported. The Light theme is under development. + ui_size: label: UI Size + font_family: label: Font Family + ui_language: label: UI Language @@ -93,22 +101,32 @@ config_window: mic_host: label: Mic Host/Driver + mic_device: label: Mic Device + mic_dynamic_energy_threshold: label_for_automatic: "Mic Energy Threshold (Current Setting: Automatic)" desc_for_automatic: "Automatically determine microphone input sensitivity." label_for_manual: "Mic Energy Threshold (Current Setting: Manual)" desc_for_manual: "Manually determine the microphone input sensitivity using the slider. Press the microphone icon to input your voice and adjust the sensitivity while monitoring the volume." + error_message: You can set it with a value between 0 to %{max}. + mic_record_timeout: label: Mic Record Timeout desc: Detects silence and, when the specified number of seconds has passed, considers the mic input to have ended. (Second(s)) + error_message: It cannot be greater than '%{mic_phrase_timeout_label}' with a value of 0 or more. + mic_phrase_timeout: label: Mic Phrase Timeout desc: Transcription processing is performed at intervals of the specified number of seconds. + error_message: It cannot be set lower than '%{mic_record_timeout_label}' with a value of 0 or more. + mic_max_phrase: label: Mic Max Phrases desc: It is the lower limit for the number of transcribed words, and only when this number is exceeded will the transcription results be displayed logs and send to VRChat. + error_message: You can set a number equal to or greater than 0. + mic_word_filter: label: Mic Word Filter desc: "It will not send the sentence if the word(s) included in the set list of words.\nHow to set: e.g. AAA,BBB,CCC" @@ -119,32 +137,46 @@ config_window: desc_for_automatic: "Automatically determine speaker input sensitivity." label_for_manual: "Speaker Energy Threshold (Current Setting: Manual)" desc_for_manual: "Manually determine the speaker input sensitivity using the slider. Press the headphones icon to listen to the audio and adjust the sensitivity while monitoring the volume." + error_message: You can set it with a value between 0 to %{max}. + no_device_error_message: No speaker device detected. + speaker_record_timeout: label: Speaker Record Timeout desc: Detects silence and, when the specified number of seconds has passed, considers the speaker input to have ended. (Second(s)) + error_message: It cannot be greater than '%{speaker_phrase_timeout_label}' with a value of 0 or more. + speaker_phrase_timeout: label: Speaker Phrase Timeout desc: Transcription processing is performed at intervals of the specified number of seconds. + error_message: It cannot be set lower than '%{speaker_record_timeout_label}' with a value of 0 or more. + speaker_max_phrase: label: Speaker Max Phrases desc: It is the lower limit for the number of transcribed words, and only when this number is exceeded will the transcription results be displayed logs. + error_message: You can set a number equal to or greater than 0. + auto_clear_the_message_box: label: Auto Clear The Message Box + notice_xsoverlay: label: Notification XSOverlay (VR Only) desc: Notify received messages by using XSOverlay's notification feature. + auto_export_message_logs: label: Auto Export Message Logs desc: Automatically export the conversation messages as a text file. + message_format: label: Message Format desc: "You can change the decoration of the message you want to send.\n[message] will be replaced with the message, and [translation] will be replaced with the translated message.\nIt will be used in Notification XSOverlay too." + send_message_to_vrc: label: Send Message To VRChat desc: There is a way to use it without sending messages to VRChat, but it is not supported. Enable this feature when you intend to send a message to VRChat. osc_ip_address: label: OSC IP Address + osc_port: label: OSC Port \ No newline at end of file diff --git a/locales/ja.yml b/locales/ja.yml index 6f807f52..dac3a0b2 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -67,6 +67,9 @@ config_window: compact_mode: コンパクトモード version: バージョン %{version} restart_message: 再起動して変更を適用する。 + common_error_message: + invalid_value: 無効な値です。 + side_menu_labels: appearance: デザイン # translation: 翻訳 @@ -76,16 +79,21 @@ config_window: others: その他 advanced_settings: 高度な設定 + transparency: label: 透明度 desc: メイン画面の透明度を変更できます。 + appearance_theme: label: 外観テーマ [開発中] desc: カラーテーマを変更できます。現在はDarkテーマのみ対応。Lightテーマは制作中です。 + ui_size: label: UIサイズ + font_family: label: 使用フォント + ui_language: label: UIの言語 / UI Language @@ -94,22 +102,32 @@ config_window: mic_host: label: マイク(ホスト/ドライバー) + mic_device: label: マイク (デバイス) + mic_dynamic_energy_threshold: label_for_automatic: "マイク入力感度の調整 (現在の設定: 自動)" desc_for_automatic: マイクの入力感度を自動的に調節する。 label_for_manual: "マイク入力感度の調整 (現在の設定: 手動)" desc_for_manual: スライダーを調整して入力感度を手動で決められます。マイクのアイコンを押すと、実際に声を入力し、音量を確認しながら調節できます。 + error_message: 0 から %{max} までの数値で設定できます。 + mic_record_timeout: label: 入力が終了したとみなす無音時間 desc: 無音を検出し、設定された秒数経過すると、音声入力が終了したとみなします。 + error_message: 0 以上で 「%{mic_phrase_timeout_label}」より大きくすることはできません。 + mic_phrase_timeout: label: 一度に文字起こしする時間の長さ desc: 設定された秒数ごとに文字起こし処理が行われます。 + error_message: 0 以上で 「%{mic_record_timeout_label}」より小さくすることはできません。 + mic_max_phrase: label: 送信するまでに保持する単語数 desc: 文字起こしされた単語数の下限値で、この数値を超えた場合のみ結果をVRChatへ送信し、ログに表示します。 + error_message: 0以上の数値を設定できます。 + mic_word_filter: label: ワードフィルター desc: "設定された単語を検出すると、その文章は送信されません。\n設定の例: AAA,BBB,CCC" @@ -120,32 +138,45 @@ config_window: desc_for_automatic: スピーカーの入力感度を自動的に調節する。 label_for_manual: "スピーカー入力感度の調整 (現在の設定: 手動)" desc_for_manual: スライダーを調整して入力感度を手動で決められます。ヘッドフォンのアイコンを押すと、実際に音声を聞き取り、音量を確認しながら調節できます。 + error_message: 0 から %{max} までの数値で設定できます。 + no_device_error_message: スピーカーデバイスが検出されませんでした。 + speaker_record_timeout: label: 入力が終了したとみなす無音時間 desc: 無音を検出し、設定された秒数経過すると、音声入力が終了したとみなします。 + error_message: 0 以上で 「%{speaker_phrase_timeout_label}」より大きくすることはできません。 + speaker_phrase_timeout: label: 一度に文字起こしする時間の長さ desc: 設定された秒数ごとに文字起こし処理が行われます。 + error_message: 0 以上で 「%{speaker_record_timeout_label}」より小さくすることはできません。 + speaker_max_phrase: label: ログとして表示するまでに保持する単語数 desc: 文字起こしされた単語数の下限値で、この数値を超えた場合のみ結果をログに表示します。 + error_message: 0以上の数値を設定できます。 auto_clear_the_message_box: label: 送信後はチャットボックスを空にする + notice_xsoverlay: label: XSOverlayでの通知受け取り機能を有効 (VR限定) desc: 文字起こし(受信)されたメッセージをXSOverlayの機能を使って通知として受け取れます。 + auto_export_message_logs: label: 会話ログを自動的に保存する desc: テキストファイルとしてログがlogsフォルダ内に保存されます。 + message_format: label: 送信するメッセージのフォーマット desc: "VRChatで相手に実際に見えるフォーマットを変更できます。\n[message]がメッセージに置換され、\n[translation]が翻訳されたメッセージに置換されます。\n※XSOverlayでの通知受け取り機能でも使われます。" + send_message_to_vrc: label: VRChatにメッセージを送信する desc: "サポート対象外ですが、VRChatにメッセージを送信せずに使う方法があります。送信したい場合、この機能を有効にする事を忘れないでください。" osc_ip_address: label: OSC IP Address + osc_port: label: OSC Port \ No newline at end of file diff --git a/view.py b/view.py index e6c0ed51..f16c5ee7 100644 --- a/view.py +++ b/view.py @@ -1040,38 +1040,89 @@ class View(): def showErrorMessage_MicEnergyThreshold(self): - self._showErrorMessage(vrct_gui.config_window.sb__progressbar_x_slider__entry_mic_energy_threshold, "Mic Energy Threshold Error Message") + self._showErrorMessage( + vrct_gui.config_window.sb__progressbar_x_slider__entry_mic_energy_threshold, + self._makeInvalidValueErrorMessage(i18n.t("config_window.mic_dynamic_energy_threshold.error_message", max=config.MAX_MIC_ENERGY_THRESHOLD)) + ) def showErrorMessage_MicRecordTimeout(self): - self._showErrorMessage(vrct_gui.config_window.sb__entry_mic_record_timeout, "Mic Record Timeout Error Message") + self._showErrorMessage( + vrct_gui.config_window.sb__entry_mic_record_timeout, + self._makeInvalidValueErrorMessage( + i18n.t( + "config_window.mic_record_timeout.error_message", + mic_phrase_timeout_label=i18n.t("config_window.mic_phrase_timeout.label") + ) + ) + ) def showErrorMessage_MicPhraseTimeout(self): - self._showErrorMessage(vrct_gui.config_window.sb__entry_mic_phrase_timeout, "Mic Phrase Timeout Error Message") + self._showErrorMessage( + vrct_gui.config_window.sb__entry_mic_phrase_timeout, + self._makeInvalidValueErrorMessage( + i18n.t( + "config_window.mic_phrase_timeout.error_message", + mic_record_timeout_label=i18n.t("config_window.mic_record_timeout.label") + ) + ) + ) def showErrorMessage_MicMaxPhrases(self): - self._showErrorMessage(vrct_gui.config_window.sb__entry_mic_max_phrases, "Mic Max Phrases Error Message") + self._showErrorMessage( + vrct_gui.config_window.sb__entry_mic_max_phrases, + self._makeInvalidValueErrorMessage(i18n.t("config_window.mic_max_phrase.error_message")) + ) def showErrorMessage_SpeakerEnergyThreshold(self): - self._showErrorMessage(vrct_gui.config_window.sb__progressbar_x_slider__entry_speaker_energy_threshold, "Speaker Energy Threshold Error Message") + self._showErrorMessage( + vrct_gui.config_window.sb__progressbar_x_slider__entry_speaker_energy_threshold, + self._makeInvalidValueErrorMessage(i18n.t("config_window.speaker_dynamic_energy_threshold.error_message", max=config.MAX_SPEAKER_ENERGY_THRESHOLD)) + ) def showErrorMessage_SpeakerRecordTimeout(self): - self._showErrorMessage(vrct_gui.config_window.sb__entry_speaker_record_timeout, "Speaker Record Timeout Error Message") + self._showErrorMessage( + vrct_gui.config_window.sb__entry_speaker_record_timeout, + self._makeInvalidValueErrorMessage( + i18n.t( + "config_window.speaker_record_timeout.error_message", + speaker_phrase_timeout_label=i18n.t("config_window.speaker_phrase_timeout.label") + ) + ) + ) def showErrorMessage_SpeakerPhraseTimeout(self): - self._showErrorMessage(vrct_gui.config_window.sb__entry_speaker_phrase_timeout, "Speaker Phrase Timeout Error Message") + self._showErrorMessage( + vrct_gui.config_window.sb__entry_speaker_phrase_timeout, + self._makeInvalidValueErrorMessage( + i18n.t( + "config_window.speaker_phrase_timeout.error_message", + speaker_record_timeout_label=i18n.t("config_window.speaker_record_timeout.label") + ) + ) + ) def showErrorMessage_SpeakerMaxPhrases(self): - self._showErrorMessage(vrct_gui.config_window.sb__entry_speaker_max_phrases, "Speaker Max Phrases Error Message") + self._showErrorMessage( + vrct_gui.config_window.sb__entry_speaker_max_phrases, + self._makeInvalidValueErrorMessage(i18n.t("config_window.speaker_max_phrase.error_message")) + ) def showErrorMessage_CheckSpeakerThreshold_NoDevice(self): - self._showErrorMessage(vrct_gui.config_window.sb__progressbar_x_slider__active_button_speaker_energy_threshold, "No speaker device detected") + self._showErrorMessage( + vrct_gui.config_window.sb__progressbar_x_slider__active_button_speaker_energy_threshold, + self._makeInvalidValueErrorMessage(i18n.t("config_window.speaker_dynamic_energy_threshold.no_device_error_message")) + ) def _showErrorMessage(self, target_widget, message): self.view_variable.VAR_ERROR_MESSAGE.set(message) vrct_gui._showErrorMessage(target_widget=target_widget) + @staticmethod + def _makeInvalidValueErrorMessage(error_message): + return i18n.t("config_window.common_error_message.invalid_value") + "\n" + error_message + def clearErrorMessage(self): vrct_gui._clearErrorMessage() diff --git a/vrct_gui/ui_managers/UiScalingManager.py b/vrct_gui/ui_managers/UiScalingManager.py index 488b91ed..79961dd6 100644 --- a/vrct_gui/ui_managers/UiScalingManager.py +++ b/vrct_gui/ui_managers/UiScalingManager.py @@ -217,7 +217,7 @@ class UiScalingManager(): self.config_window.SB__ERROR_MESSAGE_IPADX = (self._calculateUiSize(10), self._calculateUiSize(10)) self.config_window.SB__ERROR_MESSAGE_IPADY = (self._calculateUiSize(6), self._calculateUiSize(6)) - self.config_window.SB__ERROR_MESSAGE_FONT_SIZE = self._calculateUiSize(12) + self.config_window.SB__ERROR_MESSAGE_FONT_SIZE = self._calculateUiSize(14) self.config_window.SB__SELECTOR_FONT_SIZE = self._calculateUiSize(14) From 7eee38f1070fafe356e70e1a60fe3fe04c9b4b7a Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Thu, 19 Oct 2023 08:58:47 +0900 Subject: [PATCH 2/5] [Chore] Remove the python print code that forgot to remove. --- vrct_gui/vrct_gui.py | 1 - 1 file changed, 1 deletion(-) diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index 2337e23c..683d4f06 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -291,7 +291,6 @@ class VRCT_GUI(CTk): self.update() screen_height = self.winfo_screenheight() window_height = self.winfo_height() - print(screen_height, window_height) if screen_height < window_height: return True else: From 2b0476c8b91e0ff3d8bc4e4d1a54dff005783d1a Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Thu, 19 Oct 2023 09:06:40 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[bugfix]=20VRCT=E3=82=A6=E3=82=A3=E3=83=B3?= =?UTF-8?q?=E3=83=89=E3=82=A6UI=20Size40%=E3=81=A7=E3=82=82OS=E3=82=A6?= =?UTF-8?q?=E3=82=A3=E3=83=B3=E3=83=89=E3=82=A6=E3=82=B5=E3=82=A4=E3=82=BA?= =?UTF-8?q?=E3=82=92=E8=B6=85=E3=81=88=E3=82=8B=E5=A0=B4=E5=90=88=E3=81=AF?= =?UTF-8?q?=E3=80=81=E7=A2=BA=E8=AA=8D=E3=83=A2=E3=83=BC=E3=83=80=E3=83=AB?= =?UTF-8?q?=E3=81=8C=E6=B0=B8=E9=81=A0=E5=87=BA=E3=81=A6=E3=81=97=E3=81=BE?= =?UTF-8?q?=E3=81=86=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82=E3=81=9D?= =?UTF-8?q?=E3=81=86=E3=81=84=E3=81=86=E7=92=B0=E5=A2=83=E3=82=92=E4=BD=9C?= =?UTF-8?q?=E3=82=8C=E3=81=9A=E3=83=86=E3=82=B9=E3=83=88=E3=81=AF=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84=E3=81=8C=E3=80=81?= =?UTF-8?q?=E3=81=BE=E3=81=81=E6=83=B3=E5=AE=9A=E5=A4=96=E3=81=99=E3=81=8E?= =?UTF-8?q?=E3=82=8B=E3=83=87=E3=82=A3=E3=82=B9=E3=83=97=E3=83=AC=E3=82=A4?= =?UTF-8?q?=E3=82=B5=E3=82=A4=E3=82=BA=E3=81=AA=E3=81=AE=E3=81=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/view.py b/view.py index f16c5ee7..21e07334 100644 --- a/view.py +++ b/view.py @@ -593,7 +593,8 @@ class View(): index = self.view_variable.LIST_UI_SCALING.index(str(target_percentage) + "%") callFunctionIfCallable(self.view_variable.CALLBACK_SET_UI_SCALING, self.view_variable.LIST_UI_SCALING[index]) callFunctionIfCallable(self.view_variable.CALLBACK_RESTART_SOFTWARE) - + else: + self._hideConfirmationModal() # ※Below 40% of the UI size is not supported, and we cannot handle it at this time. From b007fb1c5524428b1a6ed9c8a6d1426e2730415c Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Thu, 19 Oct 2023 09:32:06 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[bugfix]=20Selectable=20Language=20Window:?= =?UTF-8?q?=20Focus=E3=82=A4=E3=83=99=E3=83=B3=E3=83=88=E3=81=8C=E6=84=8F?= =?UTF-8?q?=E5=9B=B3=E3=81=97=E3=81=AA=E3=81=84=E3=81=A8=E3=81=93=E3=82=8D?= =?UTF-8?q?=E3=81=A7=E7=99=BA=E7=94=9F=E3=81=97=E3=81=A6=E3=82=A6=E3=82=A3?= =?UTF-8?q?=E3=83=B3=E3=83=89=E3=82=A6=E9=96=89=E3=81=98=E3=81=A6=E3=81=97?= =?UTF-8?q?=E3=81=BE=E3=81=86=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vrct_gui/_CreateSelectableLanguagesWindow.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vrct_gui/_CreateSelectableLanguagesWindow.py b/vrct_gui/_CreateSelectableLanguagesWindow.py index ca87c547..850c02cd 100644 --- a/vrct_gui/_CreateSelectableLanguagesWindow.py +++ b/vrct_gui/_CreateSelectableLanguagesWindow.py @@ -11,7 +11,6 @@ class _CreateSelectableLanguagesWindow(CTkToplevel): self.withdraw() - # configure window self.title("_CreateSelectableLanguagesWindow") self.overrideredirect(True) @@ -24,7 +23,8 @@ class _CreateSelectableLanguagesWindow(CTkToplevel): self.settings = settings self._view_variable = view_variable - self.bind("", lambda e: vrct_gui._closeSelectableLanguagesWindow()) + + self.bind("", self.focusOutFunction) @@ -179,4 +179,9 @@ class _CreateSelectableLanguagesWindow(CTkToplevel): row+=1 - self.is_created = True \ No newline at end of file + self.is_created = True + + + def focusOutFunction(self, e): + if str(e.widget) != ".!_createselectablelanguageswindow": return + self.vrct_gui._closeSelectableLanguagesWindow() \ No newline at end of file From 40f999f5565e8f39139e89d16ab512b3ebff4b29 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Thu, 19 Oct 2023 15:18:10 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[bugfix]=20Config=20Window:=20Dropdown=20Me?= =?UTF-8?q?nu=20Window.=20=E5=B9=85=E3=82=92=E5=86=85=E5=AE=B9=E3=81=AB?= =?UTF-8?q?=E5=90=88=E3=82=8F=E3=81=9B=E3=81=A6=E5=8F=AF=E5=A4=89=E7=9A=84?= =?UTF-8?q?=E3=81=AB=E3=80=82=E9=95=B7=E3=81=84=E3=83=86=E3=82=AD=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=81=8C=E5=85=A5=E3=81=A3=E3=81=A6=E3=82=82=E8=A6=8B?= =?UTF-8?q?=E3=81=8D=E3=82=8C=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vrct_gui/_CreateDropdownMenuWindow.py | 26 ++++++++++++------- .../_SettingBoxGenerator.py | 4 +-- .../createSettingBox_Appearance.py | 1 - .../createSettingBox_Mic.py | 1 - vrct_gui/ui_managers/UiScalingManager.py | 1 + vrct_gui/vrct_gui.py | 1 + 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/vrct_gui/_CreateDropdownMenuWindow.py b/vrct_gui/_CreateDropdownMenuWindow.py index 43ce52f8..9688ea4d 100644 --- a/vrct_gui/_CreateDropdownMenuWindow.py +++ b/vrct_gui/_CreateDropdownMenuWindow.py @@ -3,7 +3,7 @@ from types import SimpleNamespace from customtkinter import CTkToplevel, CTkFrame, CTkLabel, CTkFont, CTkScrollableFrame from time import sleep -from .ui_utils import bindButtonReleaseFunction, bindEnterAndLeaveColor, bindButtonPressColor, getLatestHeight, applyUiScalingAndFixTheBugScrollBar +from .ui_utils import bindButtonReleaseFunction, bindEnterAndLeaveColor, bindButtonPressColor, getLatestHeight, applyUiScalingAndFixTheBugScrollBar, getLatestWidth, getLongestText from functools import partial from utils import isEven, makeEven @@ -22,6 +22,7 @@ class _CreateDropdownMenuWindow(CTkToplevel): value_ipady, value_pady, value_font_size, + dropdown_menu_default_min_width, window_bg_color, window_border_color, @@ -53,6 +54,7 @@ class _CreateDropdownMenuWindow(CTkToplevel): self.value_ipady=value_ipady self.value_pady=value_pady self.value_font_size=value_font_size + self.dropdown_menu_default_min_width=dropdown_menu_default_min_width self.window_bg_color=window_bg_color self.window_border_color=window_border_color @@ -97,19 +99,19 @@ class _CreateDropdownMenuWindow(CTkToplevel): wrapper_widget=self.dropdown_menu_widgets[dropdown_menu_widget_id].wrapper_widget, attach_widget=self.dropdown_menu_widgets[dropdown_menu_widget_id].attach_widget, - dropdown_menu_width=self.dropdown_menu_widgets[dropdown_menu_widget_id].dropdown_menu_settings.dropdown_menu_width, + dropdown_menu_min_width=self.dropdown_menu_widgets[dropdown_menu_widget_id].dropdown_menu_settings.dropdown_menu_min_width, dropdown_menu_height=self.dropdown_menu_widgets[dropdown_menu_widget_id].dropdown_menu_settings.dropdown_menu_height, max_display_length=self.dropdown_menu_widgets[dropdown_menu_widget_id].dropdown_menu_settings.max_display_length, ) - def createDropdownMenuBox(self, dropdown_menu_widget_id, dropdown_menu_values, command, wrapper_widget, attach_widget, dropdown_menu_width=None, dropdown_menu_height=None, max_display_length=None): + def createDropdownMenuBox(self, dropdown_menu_widget_id, dropdown_menu_values, command, wrapper_widget, attach_widget, dropdown_menu_min_width=None, dropdown_menu_height=None, max_display_length=None): self.attach_widget = attach_widget self.wrapper_widget = wrapper_widget - self.update() - self.new_width = dropdown_menu_width if dropdown_menu_width is not None else self.attach_widget.winfo_width() + + self.new_width = dropdown_menu_min_width if dropdown_menu_min_width is not None else self.dropdown_menu_default_min_width self.new_height = dropdown_menu_height if dropdown_menu_height is not None else self.init_height self.max_display_length = max_display_length if max_display_length is not None else self.init_max_display_length @@ -151,7 +153,7 @@ class _CreateDropdownMenuWindow(CTkToplevel): wrapper_widget=wrapper_widget, attach_widget=attach_widget, dropdown_menu_settings=SimpleNamespace( - dropdown_menu_width=dropdown_menu_width, + dropdown_menu_min_width=dropdown_menu_min_width, dropdown_menu_height=dropdown_menu_height, max_display_length=max_display_length, ), @@ -166,6 +168,7 @@ class _CreateDropdownMenuWindow(CTkToplevel): def _createDropdownMenuValues(self, dropdown_menu_widget_id, dropdown_menu_values, command): + longest_text = getLongestText(dropdown_menu_values) self.dropdown_menu_values_wrapper = CTkFrame(self.scroll_frame_container, corner_radius=0, fg_color=self.window_bg_color) self.dropdown_menu_values_wrapper.grid(row=0, column=0, sticky="nsew") self.dropdown_menu_values_wrapper.grid_columnconfigure(0, weight=1) @@ -177,10 +180,10 @@ class _CreateDropdownMenuWindow(CTkToplevel): __dropdown_menu_value_wrapper.grid_rowconfigure((0,2), weight=1) - __dropdown_menu_value_wrapper.grid_columnconfigure(0, weight=1) + # __dropdown_menu_value_wrapper.grid_columnconfigure(0, weight=1) __label_widget = CTkLabel( __dropdown_menu_value_wrapper, - text="Aa", + text=longest_text, height=0, corner_radius=0, font=CTkFont(family=self.settings.FONT_FAMILY, size=self.value_font_size, weight="normal"), @@ -190,7 +193,13 @@ class _CreateDropdownMenuWindow(CTkToplevel): # setattr(self, f"l", __label_widget) __label_widget.grid(row=1, column=0, padx=self.value_ipadx, pady=self.value_ipady, sticky="w") + label_height = getLatestHeight(__dropdown_menu_value_wrapper) + label_width = getLatestWidth(__label_widget) + label_width += self.scroll_frame_container._scrollbar.winfo_width() + (self.window_border_width*2) + (self.scrollbar_ipadx[0] + self.scrollbar_ipadx[1]) + if label_width > self.new_width: + additional_width = int(label_width - self.new_width) + self.new_width += additional_width # for fixing 1px bug if isEven(label_height) is False: @@ -223,7 +232,6 @@ class _CreateDropdownMenuWindow(CTkToplevel): dropdown_menu_value_wrapper.grid_rowconfigure((0,2), weight=1) - dropdown_menu_value_wrapper.grid_columnconfigure(0, weight=1) label_widget = CTkLabel( dropdown_menu_value_wrapper, text=dropdown_menu_value, 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 e5f7ecd7..ed7d28a8 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 @@ -96,7 +96,7 @@ class _SettingBoxGenerator(): for_var_label_text, for_var_desc_text, optionmenu_attr_name, command, - dropdown_menu_width=None, + dropdown_menu_min_width=None, dropdown_menu_values=None, variable=None, ): @@ -144,7 +144,7 @@ class _SettingBoxGenerator(): command=adjustedCommand, wrapper_widget=self.config_window.main_bg_container, attach_widget=option_menu_widget, - dropdown_menu_width=dropdown_menu_width, + dropdown_menu_min_width=dropdown_menu_min_width, ) return setting_box_frame diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_appearance/createSettingBox_Appearance.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_appearance/createSettingBox_Appearance.py index b2058340..cc33684c 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_appearance/createSettingBox_Appearance.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_appearance/createSettingBox_Appearance.py @@ -70,7 +70,6 @@ def createSettingBox_Appearance(setting_box_wrapper, config_window, settings, vi for_var_desc_text=view_variable.VAR_DESC_FONT_FAMILY, optionmenu_attr_name="sb__optionmenu_font_family", dropdown_menu_values=view_variable.LIST_FONT_FAMILY, - dropdown_menu_width=settings.uism.RESPONSIVE_UI_SIZE_INT_300, command=lambda value: optionmenu_font_family_callback(value), variable=view_variable.VAR_FONT_FAMILY, ) 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 405c8df6..472e5baa 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 @@ -58,7 +58,6 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings, view_vari for_var_desc_text=view_variable.VAR_DESC_MIC_DEVICE, optionmenu_attr_name="sb__optionmenu_mic_device", dropdown_menu_values=view_variable.LIST_MIC_DEVICE, - dropdown_menu_width=settings.uism.RESPONSIVE_UI_SIZE_INT_500, command=lambda value: optionmenu_input_mic_device_callback(value), variable=view_variable.VAR_MIC_DEVICE, ) diff --git a/vrct_gui/ui_managers/UiScalingManager.py b/vrct_gui/ui_managers/UiScalingManager.py index 79961dd6..9b543704 100644 --- a/vrct_gui/ui_managers/UiScalingManager.py +++ b/vrct_gui/ui_managers/UiScalingManager.py @@ -243,6 +243,7 @@ class UiScalingManager(): self.config_window.SB__DROPDOWN_MENU_VALUE_IPADY = (self._calculateUiSize(6), self._calculateUiSize(6)) self.config_window.SB__DROPDOWN_MENU_VALUE_PADY = (0, self._calculateUiSize(1, is_allowed_odd=True)) self.config_window.SB__DROPDOWN_MENU_VALUE_FONT_SIZE = self._calculateUiSize(14) + self.config_window.SB__DROPDOWN_MENU_VALUE_DEFAULT_MIN_WIDTH = self._calculateUiSize(200) self.config_window.SB__SWITCH_WIDTH = self._calculateUiSize(50) diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index 683d4f06..f9a10fec 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -81,6 +81,7 @@ class VRCT_GUI(CTk): value_ipady=self.settings.config_window.uism.SB__DROPDOWN_MENU_VALUE_IPADY, value_pady=self.settings.config_window.uism.SB__DROPDOWN_MENU_VALUE_PADY, value_font_size=self.settings.config_window.uism.SB__DROPDOWN_MENU_VALUE_FONT_SIZE, + dropdown_menu_default_min_width=self.settings.config_window.uism.SB__DROPDOWN_MENU_VALUE_DEFAULT_MIN_WIDTH, window_bg_color=self.settings.config_window.ctm.SB__DROPDOWN_MENU_WINDOW_BG_COLOR, window_border_color=self.settings.config_window.ctm.SB__DROPDOWN_MENU_WINDOW_BORDER_COLOR,