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] =?UTF-8?q?[bugfix]=20Config=20Window:=20Dropdown=20Menu?= =?UTF-8?q?=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,