[Update] Overlay Settings:

有効無効スイッチ追加。
VR Settingsではなく、Overlay Settingsに。
Lightテーマに一部対応。
This commit is contained in:
Sakamoto Shiina
2024-04-26 22:34:19 +09:00
parent 2feb1a6fba
commit 0026102f45
6 changed files with 104 additions and 35 deletions

View File

@@ -139,8 +139,8 @@ class View():
# VR Settings
VAR_VR_SETTINGS=StringVar(value="VR Settings"),
# Overlay Settings
VAR_VR_SETTINGS=StringVar(value="Overlay Settings"),
CALLBACK_SET_CALLBACK_OPEN_VR_SETTINGS_WINDOW=self._openVrSettingsWindow,

View File

@@ -48,48 +48,48 @@ def createMainWindowWidgets(vrct_gui, settings, view_variable):
# start from 3
main_topbar_column=3
# VR Settings Button
vrct_gui.vr_settings_container = CTkFrame(
# Overlay Settings Button
vrct_gui.overlay_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.overlay_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.overlay_settings_container.grid_remove()
vrct_gui.vr_settings_container.grid_rowconfigure((0,2), weight=1)
vrct_gui.overlay_settings_container.grid_rowconfigure((0,2), weight=1)
vrct_gui.vr_settings_icon = CTkLabel(
vrct_gui.vr_settings_container,
vrct_gui.overlay_settings_icon = CTkLabel(
vrct_gui.overlay_settings_container,
text=None,
corner_radius=0,
height=0,
image=CTkImage(settings.image_file.CONFIGURATION_ICON, size=settings.uism.UPDATE_AVAILABLE_BUTTON_SIZE)
image=CTkImage(settings.image_file.CONFIGURATION_ICON_DISABLED, 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.overlay_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,
vrct_gui.overlay_settings_label = CTkLabel(
vrct_gui.overlay_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.TOP_BAR_BUTTON_TEXT_COLOR,
# 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)
vrct_gui.overlay_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,
vrct_gui.overlay_settings_container,
vrct_gui.overlay_settings_label,
vrct_gui.overlay_settings_icon,
],
enter_color=settings.ctm.TOP_BAR_BUTTON_HOVERED_BG_COLOR,
leave_color=settings.ctm.TOP_BAR_BUTTON_BG_COLOR,

View File

@@ -9,18 +9,15 @@ 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.title("Overlay Settings")
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)
@@ -32,6 +29,7 @@ class QuickSettingsWindow(CTkToplevel):
cqsb = _CreateQuickSettingBox(self.qsw_background, vrct_gui, settings, view_variable)
createSettingBoxSlider = cqsb.createSettingBoxSlider
createSettingBoxSwitch = cqsb.createSettingBoxSwitch
@@ -39,6 +37,19 @@ class QuickSettingsWindow(CTkToplevel):
# Overlay General Settings
row=0
def switchCallback(switch_widget):
callFunctionIfCallable(view_variable.CALLBACK_SET_ENABLE_OVERLAY_SMALL_LOG, switch_widget.get())
self.qsb__enable_overlay_small_log = createSettingBoxSwitch(
for_var_label_text=view_variable.VAR_LABEL_ENABLE_OVERLAY_SMALL_LOG,
switch_attr_name="qsb__enable_overlay_small_log_switch",
command=lambda: switchCallback(vrct_gui.qsb__enable_overlay_small_log_switch),
variable=view_variable.VAR_ENABLE_OVERLAY_SMALL_LOG,
)
self.qsb__enable_overlay_small_log.grid(row=row)
row+=1
def sliderCallback(e):
value = round(e,2)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SETTINGS, value, "opacity")
@@ -75,9 +86,23 @@ class QuickSettingsWindow(CTkToplevel):
# Overlay Small Log Settings
# row+=1
# def switchCallback(switch_widget):
# callFunctionIfCallable(view_variable.CALLBACK_SET_ENABLE_OVERLAY_SMALL_LOG, switch_widget.get())
# self.qsb__enable_overlay_small_log = createSettingBoxSwitch(
# for_var_label_text=view_variable.VAR_LABEL_ENABLE_OVERLAY_SMALL_LOG,
# switch_attr_name="qsb__enable_overlay_small_log_switch",
# command=lambda: switchCallback(vrct_gui.qsb__enable_overlay_small_log_switch),
# variable=view_variable.VAR_ENABLE_OVERLAY_SMALL_LOG,
# )
# self.qsb__enable_overlay_small_log.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 File

@@ -2,7 +2,7 @@ from typing import Union
from utils import callFunctionIfCallable
from customtkinter import CTkImage, CTkLabel, CTkToplevel, CTkProgressBar, CTkFrame, CTkSlider, CTkFont
from customtkinter import CTkImage, CTkLabel, CTkToplevel, CTkProgressBar, CTkFrame, CTkSlider, CTkFont, CTkSwitch
from ..ui_utils import openImageKeepAspectRatio, getImageFileFromUiUtils, setGeometryToCenterOfScreen, fadeInAnimation
class _CreateQuickSettingBox():
@@ -49,16 +49,16 @@ class _CreateQuickSettingBox():
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")
if for_var_current_value is not None:
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")
@@ -140,4 +140,46 @@ class _CreateQuickSettingBox():
slider_bind__ButtonRelease()
slider_widget.bind("<ButtonRelease>", adjusted_slider_bind__ButtonRelease, "+")
return setting_box_frame
def createSettingBoxSwitch(
self,
for_var_label_text,
switch_attr_name,
variable,
command,
for_var_current_value=None,
):
(setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(for_var_label_text, for_var_current_value)
switch_widget = CTkSwitch(
setting_box_item_frame,
text=None,
height=0,
width=0,
corner_radius=int(self.settings.uism.SB__SWITCH_BOX_HEIGHT/2),
border_width=0,
switch_height=self.settings.uism.SB__SWITCH_BOX_HEIGHT,
switch_width=self.settings.uism.SB__SWITCH_BOX_WIDTH,
onvalue=True,
offvalue=False,
variable=variable,
command=command,
fg_color=self.settings.ctm.SB__SWITCH_BOX_BG_COLOR,
progress_color=self.settings.ctm.SB__SWITCH_BOX_ACTIVE_BG_COLOR,
button_color=self.settings.ctm.SB__SWITCH_BOX_BUTTON_COLOR,
button_hover_color=self.settings.ctm.SB__SWITCH_BOX_BUTTON_HOVERED_COLOR,
)
setattr(self.vrct_gui, switch_attr_name, switch_widget)
switch_widget.grid(row=1, column=1, sticky="w")
return setting_box_frame

View File

@@ -110,6 +110,7 @@ def _darkTheme(base_color):
TOP_BAR_BUTTON_BG_COLOR = base_color.DARK_888_COLOR,
TOP_BAR_BUTTON_HOVERED_BG_COLOR = base_color.DARK_850_COLOR,
TOP_BAR_BUTTON_CLICKED_BG_COLOR = base_color.DARK_900_COLOR,
TOP_BAR_BUTTON_TEXT_COLOR = base_color.DARK_BASIC_TEXT_COLOR,
UPDATE_AVAILABLE_BUTTON_BG_COLOR = base_color.DARK_888_COLOR,
UPDATE_AVAILABLE_BUTTON_HOVERED_BG_COLOR = base_color.DARK_850_COLOR,

View File

@@ -110,6 +110,7 @@ def _lightTheme(base_color):
TOP_BAR_BUTTON_BG_COLOR = base_color.LIGHT_175_COLOR,
TOP_BAR_BUTTON_HOVERED_BG_COLOR = base_color.LIGHT_300_COLOR,
TOP_BAR_BUTTON_CLICKED_BG_COLOR = base_color.LIGHT_350_COLOR,
TOP_BAR_BUTTON_TEXT_COLOR = base_color.LIGHT_BASIC_TEXT_COLOR,
UPDATE_AVAILABLE_BUTTON_TEXT_COLOR = base_color.PRIMARY_400_COLOR,
),