Merge branch 'view' into develop

This commit is contained in:
Sakamoto Shiina
2023-10-24 20:36:40 +09:00
14 changed files with 224 additions and 61 deletions

View File

@@ -225,6 +225,17 @@ class Config:
self._UI_SCALING = value self._UI_SCALING = value
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, 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 @property
@json_serializable('FONT_FAMILY') @json_serializable('FONT_FAMILY')
def FONT_FAMILY(self): def FONT_FAMILY(self):
@@ -546,6 +557,7 @@ class Config:
self._TRANSPARENCY = 100 self._TRANSPARENCY = 100
self._APPEARANCE_THEME = "System" self._APPEARANCE_THEME = "System"
self._UI_SCALING = "100%" self._UI_SCALING = "100%"
self._TEXTBOX_UI_SCALING = 100
self._FONT_FAMILY = "Yu Gothic UI" self._FONT_FAMILY = "Yu Gothic UI"
self._UI_LANGUAGE = "en" self._UI_LANGUAGE = "en"
self._CHOICE_MIC_HOST = getDefaultInputDevice()["host"]["name"] self._CHOICE_MIC_HOST = getDefaultInputDevice()["host"]["name"]

View File

@@ -352,6 +352,11 @@ def callbackSetUiScaling(value):
print("callbackSetUiScaling_new_scaling_float", new_scaling_float) print("callbackSetUiScaling_new_scaling_float", new_scaling_float)
view.showRestartButtonIfRequired() 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): def callbackSetFontFamily(value):
print("callbackSetFontFamily", value) print("callbackSetFontFamily", value)
config.FONT_FAMILY = value config.FONT_FAMILY = value
@@ -694,6 +699,7 @@ def createMainWindow():
"callback_set_transparency": callbackSetTransparency, "callback_set_transparency": callbackSetTransparency,
"callback_set_appearance": callbackSetAppearance, "callback_set_appearance": callbackSetAppearance,
"callback_set_ui_scaling": callbackSetUiScaling, "callback_set_ui_scaling": callbackSetUiScaling,
"callback_set_textbox_ui_scaling": callbackSetTextboxUiScaling,
"callback_set_font_family": callbackSetFontFamily, "callback_set_font_family": callbackSetFontFamily,
"callback_set_ui_language": callbackSetUiLanguage, "callback_set_ui_language": callbackSetUiLanguage,

View File

@@ -95,6 +95,10 @@ config_window:
ui_size: ui_size:
label: 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: font_family:
label: Font Family label: Font Family

View File

@@ -95,6 +95,10 @@ config_window:
ui_size: ui_size:
label: UIサイズ label: UIサイズ
textbox_ui_size:
label: テキストボックス フォントサイズ
desc: ログに表示されるフォントのサイズを、UIサイズを基準にして倍率を変えられます。
font_family: font_family:
label: 使用フォント label: 使用フォント

View File

@@ -5,4 +5,5 @@ customtkinter == 5.2.0
deepl == 1.15.0 deepl == 1.15.0
flashtext == 2.7 flashtext == 2.7
pyyaml == 6.0.1 pyyaml == 6.0.1
python-i18n == 0.3.9 python-i18n == 0.3.9
CTkToolTip == 0.8

View File

@@ -26,4 +26,7 @@ def generatePercentageStringsList(start=40, end=200, step=10):
strings = [] strings = []
for percent in range(start, end + 1, step): for percent in range(start, end + 1, step):
strings.append(f"{percent}%") strings.append(f"{percent}%")
return strings return strings
def intToPercentageStringsFormatter(value:int):
return f"{value}%"

20
view.py
View File

@@ -10,7 +10,7 @@ from languages import selectable_languages
from customtkinter import StringVar, IntVar, BooleanVar, END as CTK_END, get_appearance_mode 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.ui_managers import ColorThemeManager, ImageFileManager, UiScalingManager
from vrct_gui import vrct_gui from vrct_gui import vrct_gui
from utils import callFunctionIfCallable, generatePercentageStringsList from utils import callFunctionIfCallable, generatePercentageStringsList, intToPercentageStringsFormatter
from config import config 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_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")), VAR_CONFIG_WINDOW_RESTART_BUTTON_LABEL=StringVar(value=i18n.t("config_window.restart_message")),
CALLBACK_SLIDER_TOOLTIP_PERCENTAGE_FORMATTER=intToPercentageStringsFormatter,
# Side Menu Labels # Side Menu Labels
VAR_SIDE_MENU_LABEL_APPEARANCE=StringVar(value=i18n.t("config_window.side_menu_labels.appearance")), 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, CALLBACK_SET_UI_SCALING=None,
VAR_UI_SCALING=StringVar(value=config.UI_SCALING), 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_LABEL_FONT_FAMILY=StringVar(value=i18n.t("config_window.font_family.label")),
VAR_DESC_FONT_FAMILY=None, VAR_DESC_FONT_FAMILY=None,
LIST_FONT_FAMILY=self.getAvailableFonts(), 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_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_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_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) 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): def setMainWindowTransparency(transparency:float):
vrct_gui.wm_attributes("-alpha", transparency) 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 # Function
def _adjustUiSizeAndRestart(self): def _adjustUiSizeAndRestart(self):
@@ -1054,11 +1068,11 @@ class View():
@staticmethod @staticmethod
def _printToTextbox_Info(info_message): def _printToTextbox_Info(info_message, **kwargs):
vrct_gui._printToTextbox( vrct_gui._printToTextbox(
target_type="SYSTEM", target_type="SYSTEM",
original_message=info_message, original_message=info_message,
# translated_message="", **kwargs,
) )

View File

@@ -1,66 +1,120 @@
from datetime import datetime from datetime import datetime
from customtkinter import CTkFont from customtkinter import CTkFont
from .ui_utils import calculateUiSize
def _printToTextbox(vrct_gui, class _PrintToTextbox():
settings, def __init__(
target_type, self,
original_message=None, vrct_gui,
translated_message=None, settings,
tags=None, init_scaling:float,
disable_print_to_textbox_all:bool=False, ):
):
now_raw_data = datetime.now() self.vrct_gui = vrct_gui
# now = now_raw_data.strftime("%H:%M:%S") self.settings = settings
now_hm = now_raw_data.strftime("%H:%M") self.init_scaling = init_scaling
# set target textbox widget
is_only_one_message = True if original_message is None or translated_message is None or translated_message == "" else False 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
match (target_type): self._DEFAULT_TEXTBOX_FONT_SIZE__TIMESTAMP = self.settings.uism.TEXTBOX_FONT_SIZE__TIMESTAMP
case "SYSTEM": self._DEFAULT_TEXTBOX_FONT_SIZE__SYSTEM_TEXT_FONT = self.settings.uism.TEXTBOX_FONT_SIZE__SYSTEM_TEXT_FONT
target_textbox = vrct_gui.textbox_system self._DEFAULT_TEXTBOX_FONT_SIZE__SECONDARY_TEXT_FONT = self.settings.uism.TEXTBOX_FONT_SIZE__SECONDARY_TEXT_FONT
case "SENT": self._DEFAULT_TEXTBOX_FONT_SIZE__MAIN_TEXT_FONT = self.settings.uism.TEXTBOX_FONT_SIZE__MAIN_TEXT_FONT
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}")
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_CENTER", justify="center")
target_textbox.tag_config("JUSTIFY_RIGHT", justify="right") target_textbox.tag_config("JUSTIFY_RIGHT", justify="right")
target_textbox.tag_config("JUSTIFY_LEFT", justify="left") target_textbox.tag_config("JUSTIFY_LEFT", justify="left")
# common tag settings # common tag settings
# target_textbox._textbox.tag_configure("START", spacing1=16) # 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.tag_config("FIRST_INSERT_SPACING", spacing1=self.textbox_first_insert_spacing)
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("LABEL", font=CTkFont(family=self.settings.FONT_FAMILY, size=self.textbox_font_size__label, weight="normal"))
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("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("MAIN_TEXT_FONT", font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.TEXTBOX_FONT_SIZE__MAIN_TEXT_FONT, weight="normal")) 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 # System Tag Settings
target_textbox.tag_config("FIRST_INSERT_SPACING", spacing1=settings.uism.TEXTBOX_FIRST_INSERT_SPACING) target_textbox.tag_config("SYSTEM_TAG", foreground=self.settings.ctm.TEXTBOX_SYSTEM_TAG_TEXT_COLOR)
target_textbox.tag_config("SYSTEM_TAG", foreground=settings.ctm.TEXTBOX_SYSTEM_TAG_TEXT_COLOR) target_textbox.tag_config("SYSTEM_TEXT", foreground=self.settings.ctm.TEXTBOX_TEXT_SUB_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=self.settings.FONT_FAMILY, size=self.textbox_font_size__system_text_font, weight="normal"))
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"))
# Sent Tag Settings # Sent Tag Settings
target_textbox.tag_config("SENT_TAG", foreground=settings.ctm.TEXTBOX_SENT_TAG_TEXT_COLOR) target_textbox.tag_config("SENT_TAG", foreground=self.settings.ctm.TEXTBOX_SENT_TAG_TEXT_COLOR)
target_textbox.tag_config("SENT_TEXT", foreground=settings.ctm.TEXTBOX_TEXT_COLOR) target_textbox.tag_config("SENT_TEXT", foreground=self.settings.ctm.TEXTBOX_TEXT_COLOR)
target_textbox.tag_config("SENT_SUB_TEXT", foreground=settings.ctm.TEXTBOX_TEXT_SUB_COLOR) target_textbox.tag_config("SENT_SUB_TEXT", foreground=self.settings.ctm.TEXTBOX_TEXT_SUB_COLOR)
# Received Tag Settings # Received Tag Settings
target_textbox.tag_config("RECEIVED_TAG", foreground=settings.ctm.TEXTBOX_RECEIVED_TAG_TEXT_COLOR) target_textbox.tag_config("RECEIVED_TAG", foreground=self.settings.ctm.TEXTBOX_RECEIVED_TAG_TEXT_COLOR)
target_textbox.tag_config("RECEIVED_TEXT", foreground=settings.ctm.TEXTBOX_TEXT_COLOR) target_textbox.tag_config("RECEIVED_TEXT", foreground=self.settings.ctm.TEXTBOX_TEXT_COLOR)
target_textbox.tag_config("RECEIVED_SUB_TEXT", foreground=settings.ctm.TEXTBOX_TEXT_SUB_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 = " " FAKE_MARGIN = " "
# insert # insert
target_textbox.configure(state="normal") target_textbox.configure(state="normal")
target_textbox.insert("end", "\n") target_textbox.insert("end", "\n")
match (target_type): match (print_type):
case "SYSTEM": case "SYSTEM":
target_textbox.insert("end", "System", ("SYSTEM_TAG", "FIRST_INSERT_SPACING", "JUSTIFY_CENTER", "LABEL")) 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")) 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.configure(state="disabled")
target_textbox.see("end") 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)
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

View File

@@ -3,6 +3,7 @@ from types import SimpleNamespace
from typing import Union from typing import Union
from customtkinter import CTkOptionMenu, CTkFont, CTkFrame, CTkLabel, CTkRadioButton, CTkEntry, CTkSlider, CTkSwitch, CTkCheckBox, CTkProgressBar 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.ui_utils import createButtonWithImage, getLatestWidth, createOptionMenuBox
from vrct_gui import vrct_gui from vrct_gui import vrct_gui
@@ -238,11 +239,14 @@ class _SettingBoxGenerator():
slider_number_of_steps: Union[int, slider_number_of_steps: Union[int,
None] = None, None] = None,
slider_bind__ButtonPress=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) (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( slider_widget = CTkSlider(
setting_box_item_frame, setting_box_item_frame,
@@ -260,11 +264,26 @@ class _SettingBoxGenerator():
) )
setattr(self.config_window, slider_attr_name, slider_widget) 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") slider_widget.grid(row=1, column=SETTING_BOX_COLUMN, sticky="e")
if slider_bind__ButtonPress is not None: if slider_bind__ButtonPress is not None:
def adjusted_slider_bind__ButtonPress(_e): def adjusted_slider_bind__ButtonPress(_e):
command(_e) command(_e)
slider_tooltip.configure(message=getSliderValueWAfterFormatting())
slider_bind__ButtonPress() slider_bind__ButtonPress()
slider_widget.configure(command=adjusted_slider_bind__ButtonPress) slider_widget.configure(command=adjusted_slider_bind__ButtonPress)

View File

@@ -18,6 +18,9 @@ def createSettingBox_Appearance(setting_box_wrapper, config_window, settings, vi
def optionmenu_ui_scaling_callback(value): def optionmenu_ui_scaling_callback(value):
callFunctionIfCallable(view_variable.CALLBACK_SET_UI_SCALING, 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): def optionmenu_font_family_callback(value):
callFunctionIfCallable(view_variable.CALLBACK_SET_FONT_FAMILY, 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, variable=view_variable.VAR_TRANSPARENCY,
slider_bind__ButtonPress=view_variable.CALLBACK_BUTTON_PRESS_TRANSPARENCY, slider_bind__ButtonPress=view_variable.CALLBACK_BUTTON_PRESS_TRANSPARENCY,
slider_bind__ButtonRelease=view_variable.CALLBACK_BUTTON_RELEASE_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) config_window.sb__transparency.grid(row=row)
row+=1 row+=1
@@ -64,6 +68,20 @@ def createSettingBox_Appearance(setting_box_wrapper, config_window, settings, vi
config_window.sb__ui_scaling.grid(row=row) config_window.sb__ui_scaling.grid(row=row)
row+=1 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( config_window.sb__font_family = createSettingBoxDropdownMenu(
for_var_label_text=view_variable.VAR_LABEL_FONT_FAMILY, for_var_label_text=view_variable.VAR_LABEL_FONT_FAMILY,

View File

@@ -282,6 +282,8 @@ class ColorThemeManager():
self.config_window.SB__SLIDER_PROGRESS_BG_COLOR = self.DARK_500_COLOR 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_COLOR = self.DARK_700_COLOR
self.config_window.SB__SLIDER_BUTTON_HOVERED_COLOR = self.DARK_600_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_BG_COLOR = self.DARK_800_COLOR
self.config_window.SB__SWITCH_BOX_ACTIVE_BG_COLOR = self.PRIMARY_500_COLOR self.config_window.SB__SWITCH_BOX_ACTIVE_BG_COLOR = self.PRIMARY_500_COLOR

View File

@@ -1,5 +1,7 @@
from types import SimpleNamespace from types import SimpleNamespace
from ..ui_utils import calculateUiSize
class UiScalingManager(): class UiScalingManager():
def __init__(self, scaling_percentage): def __init__(self, scaling_percentage):
scaling_float = int(scaling_percentage.replace("%", "")) / 100 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_WIDTH = self._calculateUiSize(200)
self.config_window.SB__SLIDER_HEIGHT = self._calculateUiSize(16) 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_WIDTH = self.config_window.RESPONSIVE_UI_SIZE_INT_50
self.config_window.SB__PROGRESSBAR_X_SLIDER__ENTRY_HEIGHT = self.config_window.SB__ENTRY_HEIGHT 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): def _calculateUiSize(self, default_size, is_allowed_odd:bool=False, is_zero_allowed:bool=False):
size = int(default_size * self.SCALING_FLOAT) size = calculateUiSize(default_size, self.SCALING_FLOAT, is_allowed_odd, is_zero_allowed)
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 return size
@staticmethod @staticmethod

View File

@@ -42,6 +42,14 @@ def getLongestText(text_list:list):
longest_text = text longest_text = text
return longest_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): def bindEnterAndLeaveColor(target_widgets, enter_color, leave_color):
for target_widget in target_widgets: for target_widget in target_widgets:
target_widget.bind("<Enter>", lambda e, widgets=target_widgets: [w.configure(fg_color=enter_color) for w in widgets], "+") target_widget.bind("<Enter>", lambda e, widgets=target_widgets: [w.configure(fg_color=enter_color) for w in widgets], "+")

View File

@@ -8,7 +8,7 @@ from ._CreateDropdownMenuWindow import _CreateDropdownMenuWindow
from ._changeMainWindowWidgetsStatus import _changeMainWindowWidgetsStatus from ._changeMainWindowWidgetsStatus import _changeMainWindowWidgetsStatus
from ._changeConfigWindowWidgetsStatus import _changeConfigWindowWidgetsStatus from ._changeConfigWindowWidgetsStatus import _changeConfigWindowWidgetsStatus
from ._CreateConfirmationModal import _CreateConfirmationModal from ._CreateConfirmationModal import _CreateConfirmationModal
from ._printToTextbox import _printToTextbox from ._PrintToTextbox import _PrintToTextbox
from .main_window import createMainWindowWidgets from .main_window import createMainWindowWidgets
from .config_window import ConfigWindow from .config_window import ConfigWindow
@@ -133,6 +133,13 @@ class VRCT_GUI(CTk):
modal_type="information" 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): def _startMainLoop(self):
@@ -229,14 +236,10 @@ class VRCT_GUI(CTk):
target_names=target_names, target_names=target_names,
) )
def _printToTextbox(self, target_type, original_message=None, translated_message=None): def _printToTextbox(self, target_type, **kwargs):
_printToTextbox( self.print_to_textbox.printToTextbox(
vrct_gui=self,
settings=self.settings.main,
target_type=target_type, target_type=target_type,
original_message=original_message, **kwargs
translated_message=translated_message,
tags=target_type,
) )
def _setDefaultActiveLanguagePresetTab(self, tab_no:str): def _setDefaultActiveLanguagePresetTab(self, tab_no:str):