diff --git a/config.py b/config.py index 65f8fa15..afd25f43 100644 --- a/config.py +++ b/config.py @@ -225,6 +225,17 @@ class Config: self._UI_SCALING = value saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) + @property + @json_serializable('TEXTBOX_UI_SCALING') + def TEXTBOX_UI_SCALING(self): + return self._TEXTBOX_UI_SCALING + + @TEXTBOX_UI_SCALING.setter + def TEXTBOX_UI_SCALING(self, value): + if type(value) is int and 50 <= value <= 200: + self._TEXTBOX_UI_SCALING = value + saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) + @property @json_serializable('FONT_FAMILY') def FONT_FAMILY(self): @@ -546,6 +557,7 @@ class Config: self._TRANSPARENCY = 100 self._APPEARANCE_THEME = "System" self._UI_SCALING = "100%" + self._TEXTBOX_UI_SCALING = 100 self._FONT_FAMILY = "Yu Gothic UI" self._UI_LANGUAGE = "en" self._CHOICE_MIC_HOST = getDefaultInputDevice()["host"]["name"] diff --git a/controller.py b/controller.py index d8dfc1fb..f3ee030d 100644 --- a/controller.py +++ b/controller.py @@ -352,6 +352,11 @@ def callbackSetUiScaling(value): print("callbackSetUiScaling_new_scaling_float", new_scaling_float) view.showRestartButtonIfRequired() +def callbackSetTextboxUiScaling(value): + print("callbackSetTextboxUiScaling", int(value)) + config.TEXTBOX_UI_SCALING = int(value) + view.setMainWindowTextboxUiSize(config.TEXTBOX_UI_SCALING/100) + def callbackSetFontFamily(value): print("callbackSetFontFamily", value) config.FONT_FAMILY = value @@ -694,6 +699,7 @@ def createMainWindow(): "callback_set_transparency": callbackSetTransparency, "callback_set_appearance": callbackSetAppearance, "callback_set_ui_scaling": callbackSetUiScaling, + "callback_set_textbox_ui_scaling": callbackSetTextboxUiScaling, "callback_set_font_family": callbackSetFontFamily, "callback_set_ui_language": callbackSetUiLanguage, diff --git a/locales/en.yml b/locales/en.yml index 3e5c4aff..3af662cf 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -95,6 +95,10 @@ config_window: ui_size: label: UI Size + textbox_ui_size: + label: Text Box Font Size + desc: You can adjust the font size used in the logs relative to the UI size. + font_family: label: Font Family diff --git a/locales/ja.yml b/locales/ja.yml index 952dbfc3..e608c2b2 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -95,6 +95,10 @@ config_window: ui_size: label: UIサイズ + textbox_ui_size: + label: テキストボックス フォントサイズ + desc: ログに表示されるフォントのサイズを、UIサイズを基準にして倍率を変えられます。 + font_family: label: 使用フォント diff --git a/requirements.txt b/requirements.txt index a399733d..42f4be2c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,5 @@ customtkinter == 5.2.0 deepl == 1.15.0 flashtext == 2.7 pyyaml == 6.0.1 -python-i18n == 0.3.9 \ No newline at end of file +python-i18n == 0.3.9 +CTkToolTip == 0.8 \ No newline at end of file diff --git a/utils.py b/utils.py index 6efe6d0a..242faf15 100644 --- a/utils.py +++ b/utils.py @@ -26,4 +26,7 @@ def generatePercentageStringsList(start=40, end=200, step=10): strings = [] for percent in range(start, end + 1, step): strings.append(f"{percent}%") - return strings \ No newline at end of file + return strings + +def intToPercentageStringsFormatter(value:int): + return f"{value}%" \ No newline at end of file diff --git a/view.py b/view.py index 6a5ff860..2a309a06 100644 --- a/view.py +++ b/view.py @@ -10,7 +10,7 @@ from languages import selectable_languages from customtkinter import StringVar, IntVar, BooleanVar, END as CTK_END, get_appearance_mode from vrct_gui.ui_managers import ColorThemeManager, ImageFileManager, UiScalingManager from vrct_gui import vrct_gui -from utils import callFunctionIfCallable, generatePercentageStringsList +from utils import callFunctionIfCallable, generatePercentageStringsList, intToPercentageStringsFormatter from config import config @@ -176,6 +176,8 @@ class View(): VAR_CONFIG_WINDOW_COMPACT_MODE_LABEL=StringVar(value=i18n.t("config_window.compact_mode")), VAR_CONFIG_WINDOW_RESTART_BUTTON_LABEL=StringVar(value=i18n.t("config_window.restart_message")), + CALLBACK_SLIDER_TOOLTIP_PERCENTAGE_FORMATTER=intToPercentageStringsFormatter, + # Side Menu Labels VAR_SIDE_MENU_LABEL_APPEARANCE=StringVar(value=i18n.t("config_window.side_menu_labels.appearance")), @@ -211,6 +213,14 @@ class View(): CALLBACK_SET_UI_SCALING=None, VAR_UI_SCALING=StringVar(value=config.UI_SCALING), + VAR_LABEL_TEXTBOX_UI_SCALING=StringVar(value=i18n.t("config_window.textbox_ui_size.label")), + VAR_DESC_TEXTBOX_UI_SCALING=StringVar(value=i18n.t("config_window.textbox_ui_size.desc")), + SLIDER_RANGE_TEXTBOX_UI_SCALING=(50, 200), + CALLBACK_SET_TEXTBOX_UI_SCALING=None, + VAR_TEXTBOX_UI_SCALING=IntVar(value=config.TEXTBOX_UI_SCALING), + CALLBACK_BUTTON_PRESS_TEXTBOX_UI_SCALING=self._closeTheCoverOfMainWindow, + CALLBACK_BUTTON_RELEASE_TEXTBOX_UI_SCALING=self._openTheCoverOfMainWindow, + VAR_LABEL_FONT_FAMILY=StringVar(value=i18n.t("config_window.font_family.label")), VAR_DESC_FONT_FAMILY=None, LIST_FONT_FAMILY=self.getAvailableFonts(), @@ -432,6 +442,7 @@ class View(): self.view_variable.CALLBACK_SET_APPEARANCE = config_window_registers.get("callback_set_appearance", None) self.view_variable.CALLBACK_SET_UI_SCALING = config_window_registers.get("callback_set_ui_scaling", None) + self.view_variable.CALLBACK_SET_TEXTBOX_UI_SCALING = config_window_registers.get("callback_set_textbox_ui_scaling", None) self.view_variable.CALLBACK_SET_FONT_FAMILY = config_window_registers.get("callback_set_font_family", None) self.view_variable.CALLBACK_SET_UI_LANGUAGE = config_window_registers.get("callback_set_ui_language", None) @@ -776,6 +787,9 @@ class View(): def setMainWindowTransparency(transparency:float): vrct_gui.wm_attributes("-alpha", transparency) + @staticmethod + def setMainWindowTextboxUiSize(custom_font_size_scale:float): + vrct_gui.print_to_textbox.setTagsSettings(custom_font_size_scale=custom_font_size_scale) # Function def _adjustUiSizeAndRestart(self): @@ -1054,11 +1068,11 @@ class View(): @staticmethod - def _printToTextbox_Info(info_message): + def _printToTextbox_Info(info_message, **kwargs): vrct_gui._printToTextbox( target_type="SYSTEM", original_message=info_message, - # translated_message="", + **kwargs, ) diff --git a/vrct_gui/_printToTextbox.py b/vrct_gui/_printToTextbox.py index 943b047d..6d68cfdc 100644 --- a/vrct_gui/_printToTextbox.py +++ b/vrct_gui/_printToTextbox.py @@ -1,66 +1,120 @@ from datetime import datetime from customtkinter import CTkFont +from .ui_utils import calculateUiSize -def _printToTextbox(vrct_gui, - settings, - target_type, - original_message=None, - translated_message=None, - tags=None, - disable_print_to_textbox_all:bool=False, - ): +class _PrintToTextbox(): + def __init__( + self, + vrct_gui, + settings, + init_scaling:float, + ): - now_raw_data = datetime.now() - # now = now_raw_data.strftime("%H:%M:%S") - now_hm = now_raw_data.strftime("%H:%M") - # set target textbox widget + self.vrct_gui = vrct_gui + self.settings = settings + self.init_scaling = init_scaling - is_only_one_message = True if original_message is None or translated_message is None or translated_message == "" else False - - match (target_type): - case "SYSTEM": - target_textbox = vrct_gui.textbox_system - case "SENT": - target_textbox = vrct_gui.textbox_sent - case "RECEIVED": - target_textbox = vrct_gui.textbox_received - case (_): - raise ValueError(f"No matching case for target_type: {target_type}") + self._DEFAULT_TEXTBOX_FIRST_INSERT_SPACING = self.settings.uism.TEXTBOX_FIRST_INSERT_SPACING + self._DEFAULT_TEXTBOX_FONT_SIZE__LABEL = self.settings.uism.TEXTBOX_FONT_SIZE__LABEL + self._DEFAULT_TEXTBOX_FONT_SIZE__TIMESTAMP = self.settings.uism.TEXTBOX_FONT_SIZE__TIMESTAMP + self._DEFAULT_TEXTBOX_FONT_SIZE__SYSTEM_TEXT_FONT = self.settings.uism.TEXTBOX_FONT_SIZE__SYSTEM_TEXT_FONT + self._DEFAULT_TEXTBOX_FONT_SIZE__SECONDARY_TEXT_FONT = self.settings.uism.TEXTBOX_FONT_SIZE__SECONDARY_TEXT_FONT + self._DEFAULT_TEXTBOX_FONT_SIZE__MAIN_TEXT_FONT = self.settings.uism.TEXTBOX_FONT_SIZE__MAIN_TEXT_FONT - def printEachTextbox(target_textbox): + + self.textbox_first_insert_spacing = None + self.textbox_font_size__label = None + self.textbox_font_size__timestamp = None + self.textbox_font_size__system_text_font = None + self.textbox_font_size__secondary_text_font = None + self.textbox_font_size__main_text_font = None + + + self.all_textbox_widgets = [self.vrct_gui.textbox_all, self.vrct_gui.textbox_system, self.vrct_gui.textbox_sent, self.vrct_gui.textbox_received] + + + self.setTagsSettings(self.init_scaling) + + + def printToTextbox(self, target_type, original_message=None, translated_message=None, to_print_to_textbox_all:bool=True): + self._printEachTextbox( + target_textbox=self._getTargetTextboxWidget(target_type), + print_type=target_type, + original_message=original_message, + translated_message=translated_message, + ) + + # To automatically print the same log to the textbox_all widget as well. + if to_print_to_textbox_all is True: + self._printEachTextbox( + target_textbox=self._getTargetTextboxWidget("ALL"), + print_type=target_type, + original_message=original_message, + translated_message=translated_message, + ) + + def setTagsSettings(self, custom_font_size_scale:float=1.0): + # Calculate Textbox's ui size by default size * textbox_ui_scale + self.textbox_first_insert_spacing = calculateUiSize(self._DEFAULT_TEXTBOX_FIRST_INSERT_SPACING, custom_font_size_scale) + self.textbox_font_size__label = calculateUiSize(self._DEFAULT_TEXTBOX_FONT_SIZE__LABEL, custom_font_size_scale) + self.textbox_font_size__timestamp = calculateUiSize(self._DEFAULT_TEXTBOX_FONT_SIZE__TIMESTAMP, custom_font_size_scale) + self.textbox_font_size__system_text_font = calculateUiSize(self._DEFAULT_TEXTBOX_FONT_SIZE__SYSTEM_TEXT_FONT, custom_font_size_scale) + self.textbox_font_size__secondary_text_font = calculateUiSize(self._DEFAULT_TEXTBOX_FONT_SIZE__SECONDARY_TEXT_FONT, custom_font_size_scale) + self.textbox_font_size__main_text_font = calculateUiSize(self._DEFAULT_TEXTBOX_FONT_SIZE__MAIN_TEXT_FONT, custom_font_size_scale) + + for each_textbox_widget in self.all_textbox_widgets: + self._setTagsSettings(target_textbox=each_textbox_widget) + each_textbox_widget.see("end") + + + + def _setTagsSettings(self, target_textbox): target_textbox.tag_config("JUSTIFY_CENTER", justify="center") target_textbox.tag_config("JUSTIFY_RIGHT", justify="right") target_textbox.tag_config("JUSTIFY_LEFT", justify="left") # common tag settings # target_textbox._textbox.tag_configure("START", spacing1=16) - target_textbox._textbox.tag_configure("LABEL", font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.TEXTBOX_FONT_SIZE__LABEL, weight="normal")) - target_textbox._textbox.tag_configure("TIMESTAMP", font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.TEXTBOX_FONT_SIZE__TIMESTAMP, weight="normal"), foreground=settings.ctm.TEXTBOX_TIMESTAMP_TEXT_COLOR) - target_textbox._textbox.tag_configure("SECONDARY_TEXT_FONT", font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.TEXTBOX_FONT_SIZE__SECONDARY_TEXT_FONT, weight="normal")) - target_textbox._textbox.tag_configure("MAIN_TEXT_FONT", font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.TEXTBOX_FONT_SIZE__MAIN_TEXT_FONT, weight="normal")) + target_textbox.tag_config("FIRST_INSERT_SPACING", spacing1=self.textbox_first_insert_spacing) + target_textbox._textbox.tag_configure("LABEL", font=CTkFont(family=self.settings.FONT_FAMILY, size=self.textbox_font_size__label, weight="normal")) + target_textbox._textbox.tag_configure("TIMESTAMP", font=CTkFont(family=self.settings.FONT_FAMILY, size=self.textbox_font_size__timestamp, weight="normal"), foreground=self.settings.ctm.TEXTBOX_TIMESTAMP_TEXT_COLOR) + target_textbox._textbox.tag_configure("SECONDARY_TEXT_FONT", font=CTkFont(family=self.settings.FONT_FAMILY, size=self.textbox_font_size__secondary_text_font, weight="normal")) + target_textbox._textbox.tag_configure("MAIN_TEXT_FONT", font=CTkFont(family=self.settings.FONT_FAMILY, size=self.textbox_font_size__main_text_font, weight="normal")) # System Tag Settings - target_textbox.tag_config("FIRST_INSERT_SPACING", spacing1=settings.uism.TEXTBOX_FIRST_INSERT_SPACING) - target_textbox.tag_config("SYSTEM_TAG", foreground=settings.ctm.TEXTBOX_SYSTEM_TAG_TEXT_COLOR) - target_textbox.tag_config("SYSTEM_TEXT", foreground=settings.ctm.TEXTBOX_TEXT_SUB_COLOR) - target_textbox._textbox.tag_configure("SYSTEM_TEXT_FONT", font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.TEXTBOX_FONT_SIZE__SYSTEM_TEXT_FONT, weight="normal")) + target_textbox.tag_config("SYSTEM_TAG", foreground=self.settings.ctm.TEXTBOX_SYSTEM_TAG_TEXT_COLOR) + target_textbox.tag_config("SYSTEM_TEXT", foreground=self.settings.ctm.TEXTBOX_TEXT_SUB_COLOR) + target_textbox._textbox.tag_configure("SYSTEM_TEXT_FONT", font=CTkFont(family=self.settings.FONT_FAMILY, size=self.textbox_font_size__system_text_font, weight="normal")) # Sent Tag Settings - target_textbox.tag_config("SENT_TAG", foreground=settings.ctm.TEXTBOX_SENT_TAG_TEXT_COLOR) - target_textbox.tag_config("SENT_TEXT", foreground=settings.ctm.TEXTBOX_TEXT_COLOR) - target_textbox.tag_config("SENT_SUB_TEXT", foreground=settings.ctm.TEXTBOX_TEXT_SUB_COLOR) + target_textbox.tag_config("SENT_TAG", foreground=self.settings.ctm.TEXTBOX_SENT_TAG_TEXT_COLOR) + target_textbox.tag_config("SENT_TEXT", foreground=self.settings.ctm.TEXTBOX_TEXT_COLOR) + target_textbox.tag_config("SENT_SUB_TEXT", foreground=self.settings.ctm.TEXTBOX_TEXT_SUB_COLOR) # Received Tag Settings - target_textbox.tag_config("RECEIVED_TAG", foreground=settings.ctm.TEXTBOX_RECEIVED_TAG_TEXT_COLOR) - target_textbox.tag_config("RECEIVED_TEXT", foreground=settings.ctm.TEXTBOX_TEXT_COLOR) - target_textbox.tag_config("RECEIVED_SUB_TEXT", foreground=settings.ctm.TEXTBOX_TEXT_SUB_COLOR) + target_textbox.tag_config("RECEIVED_TAG", foreground=self.settings.ctm.TEXTBOX_RECEIVED_TAG_TEXT_COLOR) + target_textbox.tag_config("RECEIVED_TEXT", foreground=self.settings.ctm.TEXTBOX_TEXT_COLOR) + target_textbox.tag_config("RECEIVED_SUB_TEXT", foreground=self.settings.ctm.TEXTBOX_TEXT_SUB_COLOR) + + + def _printEachTextbox( + self, + target_textbox, + print_type, + original_message, + translated_message, + ): + now_raw_data = datetime.now() + now_hm = now_raw_data.strftime("%H:%M") + + is_only_one_message = True if original_message is None or translated_message is None or translated_message == "" else False FAKE_MARGIN = " " # insert target_textbox.configure(state="normal") target_textbox.insert("end", "\n") - match (target_type): + match (print_type): case "SYSTEM": target_textbox.insert("end", "System", ("SYSTEM_TAG", "FIRST_INSERT_SPACING", "JUSTIFY_CENTER", "LABEL")) target_textbox.insert("end", FAKE_MARGIN+original_message+FAKE_MARGIN, ("SYSTEM_TEXT", "SYSTEM_TEXT_FONT", "JUSTIFY_CENTER")) @@ -92,7 +146,23 @@ def _printToTextbox(vrct_gui, target_textbox.configure(state="disabled") target_textbox.see("end") - printEachTextbox(target_textbox) - # To automatically print the same log to the textbox_all widget as well. - if disable_print_to_textbox_all is not True: printEachTextbox(vrct_gui.textbox_all) \ No newline at end of file + + + + + + def _getTargetTextboxWidget(self, target_type): + match (target_type): + case "ALL": + target_textbox = self.vrct_gui.textbox_all + case "SYSTEM": + target_textbox = self.vrct_gui.textbox_system + case "SENT": + target_textbox = self.vrct_gui.textbox_sent + case "RECEIVED": + target_textbox = self.vrct_gui.textbox_received + case (_): + raise ValueError(f"No matching case for target_type: {target_type}") + + return target_textbox \ No newline at end of file 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 f11c56b5..3c152958 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 @@ -3,6 +3,7 @@ from types import SimpleNamespace from typing import Union from customtkinter import CTkOptionMenu, CTkFont, CTkFrame, CTkLabel, CTkRadioButton, CTkEntry, CTkSlider, CTkSwitch, CTkCheckBox, CTkProgressBar +from CTkToolTip import * from vrct_gui.ui_utils import createButtonWithImage, getLatestWidth, createOptionMenuBox from vrct_gui import vrct_gui @@ -238,11 +239,14 @@ class _SettingBoxGenerator(): slider_number_of_steps: Union[int, None] = None, slider_bind__ButtonPress=None, - slider_bind__ButtonRelease=None + slider_bind__ButtonRelease=None, + sliderTooltipFormatter=None, ): (setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(slider_attr_name, for_var_label_text, for_var_desc_text) + if slider_number_of_steps is None: + slider_number_of_steps = int(slider_range[1] - slider_range[0]) slider_widget = CTkSlider( setting_box_item_frame, @@ -260,11 +264,26 @@ class _SettingBoxGenerator(): ) setattr(self.config_window, slider_attr_name, slider_widget) + def getSliderValueWAfterFormatting(): + return sliderTooltipFormatter(variable.get()) if sliderTooltipFormatter else variable.get() + + + + slider_tooltip = CTkToolTip( + slider_widget, + message=getSliderValueWAfterFormatting(), + delay=0, + bg_color=self.settings.ctm.SB__SLIDER_TOOLTIP_BG_COLOR, + text_color=self.settings.ctm.SB__SLIDER_TOOLTIP_TEXT_COLOR, + font=CTkFont(family=self.settings.FONT_FAMILY, size=self.settings.uism.SB__SLIDER_TOOLTIP_FONT_SIZE, weight="normal"), + ) + slider_widget.grid(row=1, column=SETTING_BOX_COLUMN, sticky="e") if slider_bind__ButtonPress is not None: def adjusted_slider_bind__ButtonPress(_e): command(_e) + slider_tooltip.configure(message=getSliderValueWAfterFormatting()) slider_bind__ButtonPress() slider_widget.configure(command=adjusted_slider_bind__ButtonPress) 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 cc33684c..dd5f68ab 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 @@ -18,6 +18,9 @@ def createSettingBox_Appearance(setting_box_wrapper, config_window, settings, vi def optionmenu_ui_scaling_callback(value): callFunctionIfCallable(view_variable.CALLBACK_SET_UI_SCALING, value) + def slider_text_box_ui_scaling_callback(value): + callFunctionIfCallable(view_variable.CALLBACK_SET_TEXTBOX_UI_SCALING, value) + def optionmenu_font_family_callback(value): callFunctionIfCallable(view_variable.CALLBACK_SET_FONT_FAMILY, value) @@ -35,6 +38,7 @@ def createSettingBox_Appearance(setting_box_wrapper, config_window, settings, vi variable=view_variable.VAR_TRANSPARENCY, slider_bind__ButtonPress=view_variable.CALLBACK_BUTTON_PRESS_TRANSPARENCY, slider_bind__ButtonRelease=view_variable.CALLBACK_BUTTON_RELEASE_TRANSPARENCY, + sliderTooltipFormatter=view_variable.CALLBACK_SLIDER_TOOLTIP_PERCENTAGE_FORMATTER, ) config_window.sb__transparency.grid(row=row) row+=1 @@ -64,6 +68,20 @@ def createSettingBox_Appearance(setting_box_wrapper, config_window, settings, vi config_window.sb__ui_scaling.grid(row=row) row+=1 + config_window.sb__textbox_uis_scaling = createSettingBoxSlider( + for_var_label_text=view_variable.VAR_LABEL_TEXTBOX_UI_SCALING, + for_var_desc_text=view_variable.VAR_DESC_TEXTBOX_UI_SCALING, + slider_attr_name="sb__slider_transparency", + slider_range=view_variable.SLIDER_RANGE_TEXTBOX_UI_SCALING, + command=lambda value: slider_text_box_ui_scaling_callback(value), + variable=view_variable.VAR_TEXTBOX_UI_SCALING, + slider_bind__ButtonPress=view_variable.CALLBACK_BUTTON_PRESS_TEXTBOX_UI_SCALING, + slider_bind__ButtonRelease=view_variable.CALLBACK_BUTTON_RELEASE_TEXTBOX_UI_SCALING, + sliderTooltipFormatter=view_variable.CALLBACK_SLIDER_TOOLTIP_PERCENTAGE_FORMATTER, + ) + config_window.sb__textbox_uis_scaling.grid(row=row) + row+=1 + config_window.sb__font_family = createSettingBoxDropdownMenu( for_var_label_text=view_variable.VAR_LABEL_FONT_FAMILY, diff --git a/vrct_gui/ui_managers/ColorThemeManager.py b/vrct_gui/ui_managers/ColorThemeManager.py index ab55e996..19f9f884 100644 --- a/vrct_gui/ui_managers/ColorThemeManager.py +++ b/vrct_gui/ui_managers/ColorThemeManager.py @@ -282,6 +282,8 @@ class ColorThemeManager(): self.config_window.SB__SLIDER_PROGRESS_BG_COLOR = self.DARK_500_COLOR self.config_window.SB__SLIDER_BUTTON_COLOR = self.DARK_700_COLOR self.config_window.SB__SLIDER_BUTTON_HOVERED_COLOR = self.DARK_600_COLOR + self.config_window.SB__SLIDER_TOOLTIP_BG_COLOR = self.DARK_850_COLOR + self.config_window.SB__SLIDER_TOOLTIP_TEXT_COLOR = self.DARK_200_COLOR self.config_window.SB__SWITCH_BOX_BG_COLOR = self.DARK_800_COLOR self.config_window.SB__SWITCH_BOX_ACTIVE_BG_COLOR = self.PRIMARY_500_COLOR diff --git a/vrct_gui/ui_managers/UiScalingManager.py b/vrct_gui/ui_managers/UiScalingManager.py index dc385b34..fae26c79 100644 --- a/vrct_gui/ui_managers/UiScalingManager.py +++ b/vrct_gui/ui_managers/UiScalingManager.py @@ -1,5 +1,7 @@ from types import SimpleNamespace +from ..ui_utils import calculateUiSize + class UiScalingManager(): def __init__(self, scaling_percentage): scaling_float = int(scaling_percentage.replace("%", "")) / 100 @@ -260,6 +262,7 @@ class UiScalingManager(): self.config_window.SB__SLIDER_WIDTH = self._calculateUiSize(200) self.config_window.SB__SLIDER_HEIGHT = self._calculateUiSize(16) + self.config_window.SB__SLIDER_TOOLTIP_FONT_SIZE = self._calculateUiSize(16) self.config_window.SB__PROGRESSBAR_X_SLIDER__ENTRY_WIDTH = self.config_window.RESPONSIVE_UI_SIZE_INT_50 self.config_window.SB__PROGRESSBAR_X_SLIDER__ENTRY_HEIGHT = self.config_window.SB__ENTRY_HEIGHT @@ -274,11 +277,7 @@ class UiScalingManager(): def _calculateUiSize(self, default_size, is_allowed_odd:bool=False, is_zero_allowed:bool=False): - size = int(default_size * self.SCALING_FLOAT) - size += 1 if not is_allowed_odd and size % 2 != 0 else 0 - if size <= 0: - size = 0 if is_zero_allowed else 1 - + size = calculateUiSize(default_size, self.SCALING_FLOAT, is_allowed_odd, is_zero_allowed) return size @staticmethod diff --git a/vrct_gui/ui_utils/ui_utils.py b/vrct_gui/ui_utils/ui_utils.py index bf64a985..5138fb5c 100644 --- a/vrct_gui/ui_utils/ui_utils.py +++ b/vrct_gui/ui_utils/ui_utils.py @@ -42,6 +42,14 @@ def getLongestText(text_list:list): longest_text = text return longest_text +def calculateUiSize(default_size, scaling_float, is_allowed_odd:bool=False, is_zero_allowed:bool=False): + size = int(default_size * scaling_float) + size += 1 if not is_allowed_odd and size % 2 != 0 else 0 + if size <= 0: + size = 0 if is_zero_allowed else 1 + + return size + def bindEnterAndLeaveColor(target_widgets, enter_color, leave_color): for target_widget in target_widgets: target_widget.bind("", lambda e, widgets=target_widgets: [w.configure(fg_color=enter_color) for w in widgets], "+") diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index 06f5f4f5..da9939dd 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -8,7 +8,7 @@ from ._CreateDropdownMenuWindow import _CreateDropdownMenuWindow from ._changeMainWindowWidgetsStatus import _changeMainWindowWidgetsStatus from ._changeConfigWindowWidgetsStatus import _changeConfigWindowWidgetsStatus from ._CreateConfirmationModal import _CreateConfirmationModal -from ._printToTextbox import _printToTextbox +from ._PrintToTextbox import _PrintToTextbox from .main_window import createMainWindowWidgets from .config_window import ConfigWindow @@ -133,6 +133,13 @@ class VRCT_GUI(CTk): modal_type="information" ) + self.print_to_textbox = _PrintToTextbox( + vrct_gui=self, + settings=self.settings.main, + init_scaling=(self._view_variable.VAR_TEXTBOX_UI_SCALING.get()/100) + ) + + def _startMainLoop(self): @@ -229,14 +236,10 @@ class VRCT_GUI(CTk): target_names=target_names, ) - def _printToTextbox(self, target_type, original_message=None, translated_message=None): - _printToTextbox( - vrct_gui=self, - settings=self.settings.main, + def _printToTextbox(self, target_type, **kwargs): + self.print_to_textbox.printToTextbox( target_type=target_type, - original_message=original_message, - translated_message=translated_message, - tags=target_type, + **kwargs ) def _setDefaultActiveLanguagePresetTab(self, tab_no:str):