From 36d750501e5b879520c075c39c07e4c0afb69053 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Fri, 13 Oct 2023 09:04:26 +0900 Subject: [PATCH 1/3] [bugfix] Config Window: fix 1px bug. --- vrct_gui/config_window/ConfigWindow.py | 12 +++++++++++- .../_createSettingBoxCompactModeButton.py | 2 +- .../createSettingBoxTopBar/createSettingBoxTopBar.py | 7 ++++++- .../createSideMenuAndSettingsBoxContainers.py | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/vrct_gui/config_window/ConfigWindow.py b/vrct_gui/config_window/ConfigWindow.py index 6bf10df8..d7be1492 100644 --- a/vrct_gui/config_window/ConfigWindow.py +++ b/vrct_gui/config_window/ConfigWindow.py @@ -4,6 +4,7 @@ from .widgets import createConfigWindowTitle, createSideMenuAndSettingsBoxContai from customtkinter import CTkToplevel, CTkFrame from ..ui_utils import getImagePath, getLatestWidth, getLatestHeight +from utils import isEven class ConfigWindow(CTkToplevel): def __init__(self, vrct_gui, settings, view_variable): @@ -35,8 +36,17 @@ class ConfigWindow(CTkToplevel): createSideMenuAndSettingsBoxContainers(config_window=self, settings=self.settings, view_variable=self._view_variable) # for fixing 1px bug + l_width = getLatestWidth(self.side_menu_bg_container) + if isEven(l_width) is False: + self.side_menu_bg_container.grid_columnconfigure(0, weight=0, minsize=l_width+1) + + # for fixing 1px bug + self.side_menu_bg_container.grid_rowconfigure(2, weight=1) sls__box_optionmenu_wrapper_fix_1px_bug = CTkFrame(self.side_menu_bg_container, corner_radius=0, width=0, height=0) - sls__box_optionmenu_wrapper_fix_1px_bug.grid(row=1, column=0, sticky="ew") + sls__box_optionmenu_wrapper_fix_1px_bug.grid(row=3, column=0, sticky="sew") + + # for fixing 1px bug + l_width = getLatestWidth(self.side_menu_bg_container) self.bind_all("", lambda event: event.widget.focus_set(), "+") \ No newline at end of file diff --git a/vrct_gui/config_window/widgets/createSettingBoxTopBar/_createSettingBoxCompactModeButton.py b/vrct_gui/config_window/widgets/createSettingBoxTopBar/_createSettingBoxCompactModeButton.py index 792ecc12..7f56af52 100644 --- a/vrct_gui/config_window/widgets/createSettingBoxTopBar/_createSettingBoxCompactModeButton.py +++ b/vrct_gui/config_window/widgets/createSettingBoxTopBar/_createSettingBoxCompactModeButton.py @@ -13,7 +13,7 @@ def _createSettingBoxCompactModeButton(parent_widget, config_window, settings, v config_window.setting_box_compact_mode_button_container = CTkFrame(parent_widget, corner_radius=0, fg_color=settings.ctm.TOP_BAR_BG_COLOR, width=0, height=0) - config_window.setting_box_compact_mode_button_container.grid(row=0, column=column_num, padx=settings.uism.COMPACT_MODE_PADX, sticky="nsw") + config_window.setting_box_compact_mode_button_container.grid(row=0, column=column_num, padx=settings.uism.COMPACT_MODE_PADX, sticky="nse") diff --git a/vrct_gui/config_window/widgets/createSettingBoxTopBar/createSettingBoxTopBar.py b/vrct_gui/config_window/widgets/createSettingBoxTopBar/createSettingBoxTopBar.py index 8e0581e5..cac83acb 100644 --- a/vrct_gui/config_window/widgets/createSettingBoxTopBar/createSettingBoxTopBar.py +++ b/vrct_gui/config_window/widgets/createSettingBoxTopBar/createSettingBoxTopBar.py @@ -13,10 +13,15 @@ def createSettingBoxTopBar(config_window, settings, view_variable): config_window.setting_box_top_bar.grid(row=0, column=1, sticky="nsew") + config_window.setting_box_top_bar.grid_rowconfigure(0, weight=1) + column_num=0 _createSettingBoxTitle(parent_widget=config_window.setting_box_top_bar, config_window=config_window, settings=settings, view_variable=view_variable, column_num=column_num) column_num+=1 + config_window.setting_box_top_bar.grid_columnconfigure(column_num, weight=1) + column_num+=1 + _createSettingBoxCompactModeButton(parent_widget=config_window.setting_box_top_bar, config_window=config_window, settings=settings, view_variable=view_variable, column_num=column_num) column_num+=1 @@ -27,4 +32,4 @@ def createSettingBoxTopBar(config_window, settings, view_variable): # for fixing 1px bug setting_box_top_bar_fix_1px_bug = CTkFrame(config_window.setting_box_top_bar, corner_radius=0, width=0, height=0) - setting_box_top_bar_fix_1px_bug.grid(row=0, column=column_num, sticky="ns") \ No newline at end of file + setting_box_top_bar_fix_1px_bug.grid(row=0, column=column_num, sticky="nse") \ No newline at end of file diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/createSideMenuAndSettingsBoxContainers.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/createSideMenuAndSettingsBoxContainers.py index 6cfc489e..2fac3c15 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/createSideMenuAndSettingsBoxContainers.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/createSideMenuAndSettingsBoxContainers.py @@ -29,8 +29,8 @@ def createSideMenuAndSettingsBoxContainers(config_window, settings, view_variabl config_window.grid_rowconfigure(1, weight=1) config_window.side_menu_bg_container = CTkFrame(config_window, corner_radius=0, fg_color=settings.ctm.SIDE_MENU_BG_COLOR, width=0, height=0) config_window.side_menu_bg_container.grid(row=1, column=0, sticky="nsew") + config_window.side_menu_bg_container.grid_columnconfigure(0, weight=1) - config_window.side_menu_bg_container.grid_rowconfigure(0, weight=1) config_window.side_menu_container = CTkFrame(config_window.side_menu_bg_container, corner_radius=0, fg_color=settings.ctm.SIDE_MENU_LABELS_BG_FOR_FAKE_BORDER_COLOR, width=0, height=0) config_window.side_menu_container.grid(row=0, column=0, padx=settings.uism.TOP_BAR_SIDE__TITLE_PADX, pady=(settings.uism.SIDE_MENU_TOP_PADY, 0), sticky="nsew") From 77500adb8d6231580f10ec551a13af183389cf6f Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Fri, 13 Oct 2023 12:24:53 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[bugfix]=20Main=20Window:=20=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E7=94=BB=E9=9D=A2=E3=82=92=E9=96=8B=E3=81=84=E3=81=9F?= =?UTF-8?q?=E6=99=82=E3=81=AB=E3=80=81=E3=83=A1=E3=82=A4=E3=83=B3=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E3=81=AB=E8=A2=AB=E3=81=9B=E3=82=8B=E3=83=A2=E3=83=BC?= =?UTF-8?q?=E3=83=80=E3=83=AB=E5=9E=8B=E3=82=A6=E3=82=A3=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=82=A6=E3=81=8C=E3=80=81=E3=83=A1=E3=82=A4=E3=83=B3=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E6=9C=80=E5=B0=8F=E5=8C=96=E6=99=82=E3=81=AF=E3=81=9D?= =?UTF-8?q?=E3=82=8C=E3=81=AB=E5=BE=93=E3=81=A3=E3=81=A6=E6=B6=88=E3=81=97?= =?UTF-8?q?=E3=80=81=E3=83=A1=E3=82=A4=E3=83=B3=E7=94=BB=E9=9D=A2=E3=82=92?= =?UTF-8?q?=E3=81=BE=E3=81=9F=E9=96=8B=E3=81=84=E3=81=9F=E6=99=82=E3=81=AB?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=80=82=20[Refactor]=20=E3=81=9D=E3=81=AE?= =?UTF-8?q?=E3=83=A2=E3=83=BC=E3=83=80=E3=83=AB=E5=9E=8B=E3=82=A6=E3=82=A3?= =?UTF-8?q?=E3=83=B3=E3=83=89=E3=82=A6=E3=81=AE=E8=A1=A8=E7=A4=BA=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E3=82=92=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vrct_gui/_CreateModalWindow.py | 10 +++++++++- vrct_gui/vrct_gui.py | 27 ++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/vrct_gui/_CreateModalWindow.py b/vrct_gui/_CreateModalWindow.py index 8cd837c2..f7a656b1 100644 --- a/vrct_gui/_CreateModalWindow.py +++ b/vrct_gui/_CreateModalWindow.py @@ -1,5 +1,7 @@ from customtkinter import CTkToplevel, CTkFrame, CTkLabel, CTkFont +from .ui_utils import fadeInAnimation + class _CreateModalWindow(CTkToplevel): def __init__(self, attach_window, settings, view_variable): super().__init__() @@ -46,4 +48,10 @@ class _CreateModalWindow(CTkToplevel): anchor="w", text_color=self.settings.ctm.TEXT_COLOR, ) - self.modal_container_label_wrapper.place(relx=0.5, rely=0.5, anchor="center") \ No newline at end of file + self.modal_container_label_wrapper.place(relx=0.5, rely=0.5, anchor="center") + + + def show(self): + self.attributes("-alpha", 0) + self.deiconify() + fadeInAnimation(self, steps=5, interval=0.005, max_alpha=0.5) diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index 390d076b..3b0ce31f 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -23,6 +23,23 @@ class VRCT_GUI(CTk): self.is_config_window_already_opened_once=False self.BIND_CONFIGURE_ADJUSTED_GEOMETRY_FUNC_ID=None self.BIND_FOCUS_IN_MODAL_WINDOW_LIFT_CONFIG_WINDOW_FUNC_ID=None + self.BIND_UNMAP_DETECT_MAIN_WINDOW_STATE_FUNC_ID = None + self.BIND_MAP_DETECT_MAIN_WINDOW_STATE_FUNC_ID = None + + self.window_state = None + + def detectMainWindowState(self, _e=None): + self.new_window_state = self.wm_state() + if self.window_state == self.new_window_state: + return + else: + self.window_state = self.new_window_state + + if self.window_state == "iconic": + self.modal_window.withdraw() + elif self.window_state == "normal": + self.modal_window.show() + def _showGUI(self): @@ -111,11 +128,13 @@ class VRCT_GUI(CTk): callFunctionIfCallable(self._view_variable.CALLBACK_OPEN_CONFIG_WINDOW) self._adjustToMainWindowGeometry() - self.modal_window.attributes("-alpha", 0) - self.modal_window.deiconify() - fadeInAnimation(self.modal_window, steps=5, interval=0.005, max_alpha=0.5) + self.modal_window.show() self.BIND_CONFIGURE_ADJUSTED_GEOMETRY_FUNC_ID = self.bind("", self._adjustToMainWindowGeometry, "+") + + self.BIND_UNMAP_DETECT_MAIN_WINDOW_STATE_FUNC_ID = self.bind("", self.detectMainWindowState, "+") + self.BIND_MAP_DETECT_MAIN_WINDOW_STATE_FUNC_ID = self.bind("", self.detectMainWindowState, "+") + self.BIND_FOCUS_IN_MODAL_WINDOW_LIFT_CONFIG_WINDOW_FUNC_ID = self.modal_window.bind("", lambda _e: self.config_window.lift(), "+") self.config_window.attributes("-alpha", 0) @@ -134,6 +153,8 @@ class VRCT_GUI(CTk): self.modal_window.withdraw() self.unbind("", self.BIND_CONFIGURE_ADJUSTED_GEOMETRY_FUNC_ID) + self.unbind("", self.BIND_UNMAP_DETECT_MAIN_WINDOW_STATE_FUNC_ID) + self.unbind("", self.BIND_MAP_DETECT_MAIN_WINDOW_STATE_FUNC_ID) self.modal_window.unbind("", self.BIND_FOCUS_IN_MODAL_WINDOW_LIFT_CONFIG_WINDOW_FUNC_ID) self.adjusted_event=None From 508cca8215fa7af20ef1b3b49e81ca2047be9bb0 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Fri, 13 Oct 2023 13:41:10 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[Update]=20=E8=A8=AD=E5=AE=9A=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E3=81=8B=E3=82=89=E9=80=8F=E6=98=8E=E5=BA=A6=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E6=99=82=E3=81=AB=E3=80=81=E3=83=A1=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=E3=81=AE=E3=82=AB=E3=83=90=E3=83=BC=E3=82=92?= =?UTF-8?q?=E4=B8=80=E6=99=82=E7=9A=84=E3=81=AB=E5=A4=96=E3=81=99=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=80=82=20=E3=82=B9=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=83=80=E3=83=BC=E3=82=AF=E3=83=AA=E3=83=83=E3=82=AF=E6=99=82?= =?UTF-8?q?=EF=BC=88=E3=83=89=E3=83=A9=E3=83=83=E3=82=B0=E6=99=82=EF=BC=89?= =?UTF-8?q?=E3=81=AB=E3=82=AB=E3=83=90=E3=83=BC=E3=82=92=E5=A4=96=E3=81=97?= =?UTF-8?q?=E3=80=81=E3=83=AA=E3=83=AA=E3=83=BC=E3=82=B9=E6=99=82=E3=81=AB?= =?UTF-8?q?=E6=88=BB=E3=81=99=E3=80=82=20=E3=83=AA=E3=83=AA=E3=83=BC?= =?UTF-8?q?=E3=82=B9=E3=81=AFCTkSlider=E5=81=B4=E3=81=A7=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84=E3=81=AE?= =?UTF-8?q?=E3=81=A7=E3=81=86=E3=81=BE=E3=81=8F=E3=81=84=E3=81=8F=E3=81=91?= =?UTF-8?q?=E3=81=A9=E3=80=81=20CTkSlider=E3=81=AFbind=20ButtonPress(?= =?UTF-8?q?=E3=82=AF=E3=83=AA=E3=83=83=E3=82=AF)=E3=81=AF=E3=82=AA?= =?UTF-8?q?=E3=83=BC=E3=83=90=E3=83=BC=E3=83=A9=E3=82=A4=E3=83=89=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=82=8B=E3=81=AE=E3=81=A7=E5=BC=95=E6=95=B0command(?= =?UTF-8?q?=E3=82=AF=E3=83=AA=E3=83=83=E3=82=AF=E3=82=A4=E3=83=99=E3=83=B3?= =?UTF-8?q?=E3=83=88)=E3=81=AB=E7=84=A1=E7=90=86=E3=82=84=E3=82=8A?= =?UTF-8?q?=E6=8C=9F=E3=81=BF=E8=BE=BC=E3=81=BF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view.py | 11 +++++++++++ .../_SettingBoxGenerator.py | 16 +++++++++++++--- .../createSettingBox_Appearance.py | 2 ++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/view.py b/view.py index 3a0187e4..1d74c48c 100644 --- a/view.py +++ b/view.py @@ -156,6 +156,8 @@ class View(): SLIDER_RANGE_TRANSPARENCY=(50, 100), CALLBACK_SET_TRANSPARENCY=None, VAR_TRANSPARENCY=IntVar(value=config.TRANSPARENCY), + CALLBACK_BUTTON_PRESS_TRANSPARENCY=self._closeTheCoverOfMainWindow, + CALLBACK_BUTTON_RELEASE_TRANSPARENCY=self._openTheCoverOfMainWindow, VAR_LABEL_APPEARANCE_THEME=StringVar(value=i18n.t("config_window.appearance_theme.label")), VAR_DESC_APPEARANCE_THEME=StringVar(value=i18n.t("config_window.appearance_theme.desc")), @@ -539,6 +541,15 @@ class View(): vrct_gui.attributes("-topmost", False) + @staticmethod + def _openTheCoverOfMainWindow(): + vrct_gui.modal_window.show() + vrct_gui.config_window.lift() + + @staticmethod + def _closeTheCoverOfMainWindow(): + vrct_gui.modal_window.withdraw() + def enableMainWindowSidebarCompactMode(self): self.view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE = True vrct_gui._enableMainWindowSidebarCompactMode() 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 8a5ad552..692fb046 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 @@ -204,11 +204,10 @@ class _SettingBoxGenerator(): - def createSettingBoxSlider(self, for_var_label_text, for_var_desc_text, slider_attr_name, slider_range, command, variable, slider_number_of_steps: Union[int, None] = None): + def createSettingBoxSlider(self, for_var_label_text, for_var_desc_text, slider_attr_name, slider_range, command, variable, slider_number_of_steps: Union[int, None] = None, slider_bind__ButtonPress=None, slider_bind__ButtonRelease=None): (setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(slider_attr_name, for_var_label_text, for_var_desc_text) - # print(self.settings.uism.SB__SLIDER_WIDTH) - # print(self.settings.uism.SB__SLIDER_HEIGHT) + slider_widget = CTkSlider( setting_box_item_frame, width=self.settings.uism.SB__SLIDER_WIDTH, @@ -225,6 +224,17 @@ class _SettingBoxGenerator(): 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_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("", adjusted_slider_bind__ButtonRelease, "+") + 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 e745bc3f..b2058340 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 @@ -33,6 +33,8 @@ def createSettingBox_Appearance(setting_box_wrapper, config_window, settings, vi slider_range=view_variable.SLIDER_RANGE_TRANSPARENCY, command=lambda value: slider_transparency_callback(value), variable=view_variable.VAR_TRANSPARENCY, + slider_bind__ButtonPress=view_variable.CALLBACK_BUTTON_PRESS_TRANSPARENCY, + slider_bind__ButtonRelease=view_variable.CALLBACK_BUTTON_RELEASE_TRANSPARENCY, ) config_window.sb__transparency.grid(row=row) row+=1