Merge branch 'overlay_transparency' into develop

This commit is contained in:
misygauziya
2024-04-25 11:14:01 +09:00
17 changed files with 783 additions and 113 deletions

View File

@@ -11,6 +11,7 @@ from .setting_box_containers.setting_box_transcription import createSettingBox_M
from .setting_box_containers.setting_box_others import createSettingBox_Others, createSettingBox_Others_SendMessageFormats, createSettingBox_Others_ReceivedMessageFormats, createSettingBox_Others_Additional
from .setting_box_containers.setting_box_advanced_settings import createSettingBox_AdvancedSettings
from .setting_box_containers.setting_box_translation import createSettingBox_Translation
from .setting_box_containers.setting_box_vr import createSettingBox_Vr
from .setting_box_containers.setting_box_about_vrct import createSettingBox_AboutVrct
@@ -103,6 +104,21 @@ def createSideMenuAndSettingsBoxContainers(config_window, settings, view_variabl
]
},
},
{
"side_menu_tab_attr_name": "side_menu_tab_vr",
"label_attr_name": "label_vr",
"selected_mark_attr_name": "selected_mark_vr",
"textvariable": view_variable.VAR_SIDE_MENU_LABEL_VR,
"setting_box_container_settings": {
"setting_box_container_attr_name": "setting_box_container_vr",
"setting_boxes": [
{
"var_section_title": None,
"setting_box": createSettingBox_Vr
}
]
},
},
{
"side_menu_tab_attr_name": "side_menu_tab_others",
"label_attr_name": "label_others",

View File

@@ -0,0 +1 @@
from .createSettingBox_Vr import createSettingBox_Vr

View File

@@ -0,0 +1,21 @@
from utils import callFunctionIfCallable
from .._SettingBoxGenerator import _SettingBoxGenerator
def createSettingBox_Vr(setting_box_wrapper, config_window, settings, view_variable):
sbg = _SettingBoxGenerator(setting_box_wrapper, config_window, settings, view_variable)
createSettingBoxSwitch = sbg.createSettingBoxSwitch
def switchEnableOverlayUiCallback(switch_widget):
callFunctionIfCallable(view_variable.CALLBACK_SET_ENABLE_OVERLAY_SMALL_LOG, switch_widget.get())
row=0
config_window.sb__enable_overlay_small_log = createSettingBoxSwitch(
for_var_label_text=view_variable.VAR_LABEL_ENABLE_OVERLAY_SMALL_LOG,
for_var_desc_text=view_variable.VAR_DESC_ENABLE_OVERLAY_SMALL_LOG,
switch_attr_name="sb__switch_enable_overlay_small_log",
command=lambda: switchEnableOverlayUiCallback(config_window.sb__switch_enable_overlay_small_log),
variable=view_variable.VAR_ENABLE_OVERLAY_SMALL_LOG
)
config_window.sb__enable_overlay_small_log.grid(row=row)
row+=1

View File

@@ -47,6 +47,60 @@ def createMainWindowWidgets(vrct_gui, settings, view_variable):
# Main Top Bar Container - Right Side
# start from 3
main_topbar_column=3
# VR Settings Button
vrct_gui.vr_settings_container = CTkFrame(
vrct_gui.main_topbar_container,
corner_radius=settings.uism.UPDATE_AVAILABLE_BUTTON_CORNER_RADIUS,
fg_color=settings.ctm.MAIN_BG_COLOR,
cursor="hand2",
)
vrct_gui.vr_settings_container.grid(row=0, column=main_topbar_column, padx=settings.uism.UPDATE_AVAILABLE_BUTTON_PADX, pady=settings.uism.TOP_BAR_BUTTON_PADY, sticky="nsw")
# vrct_gui.vr_settings_container.grid_remove()
vrct_gui.vr_settings_container.grid_rowconfigure((0,2), weight=1)
vrct_gui.vr_settings_icon = CTkLabel(
vrct_gui.vr_settings_container,
text=None,
corner_radius=0,
height=0,
image=CTkImage(settings.image_file.CONFIGURATION_ICON, size=settings.uism.UPDATE_AVAILABLE_BUTTON_SIZE)
)
vrct_gui.vr_settings_icon.grid(row=1, column=0, padx=(settings.uism.UPDATE_AVAILABLE_BUTTON_IPADX, settings.uism.UPDATE_AVAILABLE_PADX_BETWEEN_LABEL_AND_ICON), pady=0)
vrct_gui.vr_settings_label = CTkLabel(
vrct_gui.vr_settings_container,
textvariable=view_variable.VAR_VR_SETTINGS,
height=0,
corner_radius=0,
font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.UPDATE_AVAILABLE_BUTTON_FONT_SIZE, weight="normal"),
anchor="e",
text_color="#fff",
# text_color=settings.ctm.UPDATE_AVAILABLE_BUTTON_TEXT_COLOR,
)
# This "right padx +1" is for fixing a bug that sticks out from the frame. I don't know why that happens...
vrct_gui.vr_settings_label.grid(row=1, column=1, padx=(0,settings.uism.UPDATE_AVAILABLE_BUTTON_IPADX+1), pady=0)
bindButtonFunctionAndColor(
target_widgets=[
vrct_gui.vr_settings_container,
vrct_gui.vr_settings_label,
vrct_gui.vr_settings_icon,
],
enter_color=settings.ctm.TOP_BAR_BUTTON_HOVERED_BG_COLOR,
leave_color=settings.ctm.TOP_BAR_BUTTON_BG_COLOR,
clicked_color=settings.ctm.TOP_BAR_BUTTON_CLICKED_BG_COLOR,
buttonReleasedFunction=lambda e: callFunctionIfCallable(view_variable.CALLBACK_SET_CALLBACK_OPEN_VR_SETTINGS_WINDOW),
)
main_topbar_column+=1
# Update Available Button
vrct_gui.update_available_container = CTkFrame(
vrct_gui.main_topbar_container,

View File

@@ -0,0 +1,179 @@
from utils import callFunctionIfCallable, floatToPctStr
from customtkinter import CTkImage, CTkLabel, CTkToplevel, CTkProgressBar, CTkFrame, CTkSlider
from ..ui_utils import getImagePath, setGeometryToCenterOfScreen, fadeInAnimation
from ._CreateQuickSettingBox import _CreateQuickSettingBox
class QuickSettingsWindow(CTkToplevel):
def __init__(self, vrct_gui, settings, view_variable):
super().__init__()
self.withdraw()
# self.overrideredirect(True)
self.configure(fg_color="#292a2d")
self.title("Quick Settings")
# self.wm_attributes("-toolwindow", True)
self.protocol("WM_DELETE_WINDOW", self.withdraw)
self.after(200, lambda: self.iconbitmap(getImagePath("vrct_logo_mark_black.ico")))
self.settings = settings
BG_HEIGHT= 220
BG_WIDTH= 450
BG_HEX_COLOR = "#292a2d"
self.grid_columnconfigure(0, weight=1, minsize=400)
self.grid_rowconfigure(0, weight=1)
self.qsw_background = CTkFrame(self, corner_radius=0, fg_color=BG_HEX_COLOR)
self.qsw_background.grid(sticky="nsew")
self.qsw_background.grid_columnconfigure(0, weight=1)
cqsb = _CreateQuickSettingBox(self.qsw_background, vrct_gui, settings, view_variable)
createSettingBoxSlider = cqsb.createSettingBoxSlider
# Overlay General Settings
row=0
def sliderCallback(e):
value = round(e,2)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SETTINGS, value, "opacity")
view_variable.VAR_CURRENT_VALUE_OVERLAY_OPACITY.set(floatToPctStr(value))
self.qsb__overlay_opacity = createSettingBoxSlider(
for_var_label_text=view_variable.VAR_LABEL_OVERLAY_OPACITY,
for_var_current_value=view_variable.VAR_CURRENT_VALUE_OVERLAY_OPACITY,
slider_attr_name="qsb__overlay_opacity_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_OPACITY,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_OPACITY,
command=sliderCallback,
variable=view_variable.VAR_OVERLAY_OPACITY,
)
self.qsb__overlay_opacity.grid(row=row)
row+=1
def sliderCallback(e):
value = round(e,2)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SETTINGS, value, "ui_scaling")
view_variable.VAR_CURRENT_VALUE_OVERLAY_UI_SCALING.set(floatToPctStr(value))
self.qsb__overlay_ui_scaling = createSettingBoxSlider(
for_var_label_text=view_variable.VAR_LABEL_OVERLAY_UI_SCALING,
for_var_current_value=view_variable.VAR_CURRENT_VALUE_OVERLAY_UI_SCALING,
slider_attr_name="qsb__overlay_ui_scaling_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_UI_SCALING,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_UI_SCALING,
command=sliderCallback,
variable=view_variable.VAR_OVERLAY_UI_SCALING,
)
self.qsb__overlay_ui_scaling.grid(row=row)
row+=1
# Overlay Small Log Settings
def sliderCallback(e):
value = round(e,2)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, value, "x_pos")
view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_X_POS.set(str(value))
self.qsb__overlay_small_log_settings_x_pos = createSettingBoxSlider(
for_var_label_text=view_variable.VAR_LABEL_OVERLAY_SMALL_LOG_X_POS,
for_var_current_value=view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_X_POS,
slider_attr_name="qsb__overlay_small_log_settings_x_pos_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_SMALL_LOG_X_POS,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_X_POS,
command=sliderCallback,
variable=view_variable.VAR_OVERLAY_SMALL_LOG_X_POS,
)
self.qsb__overlay_small_log_settings_x_pos.grid(row=row)
row+=1
def sliderCallback(e):
value = round(e,2)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, value, "y_pos")
view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Y_POS.set(str(value))
self.qsb__overlay_small_log_settings_y_pos = createSettingBoxSlider(
for_var_label_text=view_variable.VAR_LABEL_OVERLAY_SMALL_LOG_Y_POS,
for_var_current_value=view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Y_POS,
slider_attr_name="qsb__overlay_small_log_settings_y_pos_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_SMALL_LOG_Y_POS,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_Y_POS,
command=sliderCallback,
variable=view_variable.VAR_OVERLAY_SMALL_LOG_Y_POS,
)
self.qsb__overlay_small_log_settings_y_pos.grid(row=row)
row+=1
def sliderCallback(e):
value = round(e,2)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, value, "depth")
view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_DEPTH.set(str(value))
self.qsb__overlay_small_log_settings_depth = createSettingBoxSlider(
for_var_label_text=view_variable.VAR_LABEL_OVERLAY_SMALL_LOG_DEPTH,
for_var_current_value=view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_DEPTH,
slider_attr_name="qsb__overlay_small_log_settings_depth_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_SMALL_LOG_DEPTH,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_DEPTH,
command=sliderCallback,
variable=view_variable.VAR_OVERLAY_SMALL_LOG_DEPTH,
)
self.qsb__overlay_small_log_settings_depth.grid(row=row)
row+=1
def sliderCallback(e):
value = int(e)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, value, "display_duration")
view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_DISPLAY_DURATION.set(f"{value} second(s)")
self.qsb__overlay_small_log_settings_display_duration = createSettingBoxSlider(
for_var_label_text=view_variable.VAR_LABEL_OVERLAY_SMALL_LOG_DISPLAY_DURATION,
for_var_current_value=view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_DISPLAY_DURATION,
slider_attr_name="qsb__overlay_small_log_settings_display_duration_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_SMALL_LOG_DISPLAY_DURATION,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_DISPLAY_DURATION,
command=sliderCallback,
variable=view_variable.VAR_OVERLAY_SMALL_LOG_DISPLAY_DURATION,
)
self.qsb__overlay_small_log_settings_display_duration.grid(row=row)
row+=1
def sliderCallback(e):
value = int(e)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, value, "fadeout_duration")
view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_FADEOUT_DURATION.set(f"{value} second(s)")
self.qsb__overlay_small_log_settings_fadeout_duration = createSettingBoxSlider(
for_var_label_text=view_variable.VAR_LABEL_OVERLAY_SMALL_LOG_FADEOUT_DURATION,
for_var_current_value=view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_FADEOUT_DURATION,
slider_attr_name="qsb__overlay_small_log_settings_fadeout_duration_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_SMALL_LOG_FADEOUT_DURATION,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_FADEOUT_DURATION,
command=sliderCallback,
variable=view_variable.VAR_OVERLAY_SMALL_LOG_FADEOUT_DURATION,
)
self.qsb__overlay_small_log_settings_fadeout_duration.grid(row=row)
def show(self):
self.attributes("-alpha", 0)
self.deiconify()
setGeometryToCenterOfScreen(root_widget=self)
fadeInAnimation(self, steps=5, interval=0.02)

View File

@@ -0,0 +1,143 @@
from typing import Union
from utils import callFunctionIfCallable
from customtkinter import CTkImage, CTkLabel, CTkToplevel, CTkProgressBar, CTkFrame, CTkSlider, CTkFont
from ..ui_utils import openImageKeepAspectRatio, getImageFileFromUiUtils, setGeometryToCenterOfScreen, fadeInAnimation
class _CreateQuickSettingBox():
def __init__(self, parent_frame, vrct_gui, settings, view_variable):
self.view_variable = view_variable
self.vrct_gui = vrct_gui
self.settings = settings
self.parent_frame = parent_frame
def _createSettingBoxFrame(self, for_var_label_text=None, for_var_current_value=None):
setting_box_frame = CTkFrame(self.parent_frame, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR, width=0, height=0)
setting_box_frame.grid(row=0, column=0, sticky="ew")
setting_box_frame.grid_columnconfigure(0, weight=1)
setting_box_frame_wrapper = CTkFrame(setting_box_frame, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR, width=0, height=0)
setting_box_frame_wrapper.grid(row=0, column=0, padx=self.settings.uism.SB__IPADX, pady=self.settings.uism.SB__IPADY, sticky="nsew")
setting_box_frame_wrapper.grid_columnconfigure(0, weight=1)
# Labels
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")
setting_box_labels_frame.grid_rowconfigure((0,2), weight=1)
setting_box_labels_frame.grid_columnconfigure(1, weight=1)
setting_box_label = CTkLabel(
setting_box_labels_frame,
textvariable=for_var_label_text,
anchor="w",
height=0,
font=CTkFont(family=self.settings.FONT_FAMILY, size=self.settings.uism.SB__LABEL_FONT_SIZE, weight="normal"),
text_color=self.settings.ctm.LABELS_TEXT_COLOR
)
setting_box_label.grid(row=1, column=0, padx=0, pady=0, sticky="nse")
setting_box_label = CTkLabel(
setting_box_labels_frame,
textvariable=for_var_current_value,
anchor="w",
height=0,
font=CTkFont(family=self.settings.FONT_FAMILY, size=self.settings.uism.SB__LABEL_FONT_SIZE, weight="normal"),
text_color=self.settings.ctm.LABELS_TEXT_COLOR
)
setting_box_label.grid(row=1, column=2, padx=0, pady=0, sticky="nsw")
# Items
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=1, column=0, padx=0, sticky="nsew")
setting_box_item_frame.grid_rowconfigure((0,2), weight=1)
setting_box_item_frame.grid_columnconfigure(1, weight=1)
return (setting_box_frame, setting_box_item_frame)
def createSettingBoxSlider(
self,
for_var_label_text,
for_var_current_value,
slider_attr_name,
slider_range,
command,
variable,
slider_number_of_steps: Union[int,
None] = None,
slider_bind__ButtonPress=None,
slider_bind__ButtonRelease=None,
sliderTooltipFormatter=None,
):
(setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(for_var_label_text, for_var_current_value)
slider_widget = CTkSlider(
setting_box_item_frame,
width=self.settings.uism.SB__SLIDER_WIDTH,
height=self.settings.uism.SB__SLIDER_HEIGHT,
from_=slider_range[0],
to=slider_range[1],
number_of_steps=slider_number_of_steps,
fg_color=self.settings.ctm.SB__SLIDER_BG_COLOR,
progress_color=self.settings.ctm.SB__SLIDER_PROGRESS_BG_COLOR,
button_color=self.settings.ctm.SB__SLIDER_BUTTON_COLOR,
button_hover_color=self.settings.ctm.SB__SLIDER_BUTTON_HOVERED_COLOR,
command=command,
variable=variable,
)
setattr(self.vrct_gui, slider_attr_name, slider_widget)
slider_widget.grid(row=1, column=1, sticky="ew")
if slider_bind__ButtonPress is not None:
def adjusted_slider_bind__ButtonPress(e):
command(e)
slider_bind__ButtonPress()
slider_widget.configure(command=adjusted_slider_bind__ButtonPress)
if slider_bind__ButtonRelease is not None:
def adjusted_slider_bind__ButtonRelease(_e):
slider_bind__ButtonRelease()
slider_widget.bind("<ButtonRelease>", adjusted_slider_bind__ButtonRelease, "+")
return setting_box_frame

View File

@@ -0,0 +1 @@
from .QuickSettingsWindow import *

View File

@@ -14,6 +14,7 @@ from ._PrintToTextbox import _PrintToTextbox
from .main_window import createMainWindowWidgets
from .config_window import ConfigWindow
from .quick_settings_window import QuickSettingsWindow
from .ui_utils import setDefaultActiveTab, setGeometryToCenterOfScreen, fadeInAnimation
from utils import callFunctionIfCallable
@@ -130,6 +131,13 @@ class VRCT_GUI(CTk):
view_variable=self._view_variable
)
self.quick_settings_window = QuickSettingsWindow(
vrct_gui=self,
settings=self.settings.config_window,
view_variable=self._view_variable
)
# self.quick_settings_window.show()
self.selectable_languages_window = _CreateSelectableLanguagesWindow(
vrct_gui=self,
settings=self.settings.selectable_language_window,