Merge branch 'bugfix_ui_corruption_by_windowz_scaling' into UI_2.0

This commit is contained in:
Sakamoto Shiina
2023-10-16 10:20:28 +09:00
9 changed files with 35 additions and 42 deletions

View File

@@ -1,3 +1,6 @@
import ctypes
ctypes.windll.shcore.SetProcessDpiAwareness(0)
from vrct_gui.splash_window import SplashWindow
splash = SplashWindow()
splash.showSplash()

View File

@@ -6,3 +6,4 @@ deepl == 1.15.0
flashtext == 2.7
pyyaml == 6.0.1
python-i18n == 0.3.9
ctypes

View File

@@ -38,7 +38,6 @@ class View():
self.settings.main = SimpleNamespace(
ctm=all_ctm.main,
uism=all_uism.main,
COMPACT_MODE_ICON_SIZE=0,
**common_args
)

View File

@@ -1,8 +1,6 @@
from customtkinter import CTkImage
def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, target_names):
COMPACT_MODE_ICON_SIZE_TUPLES = (settings.COMPACT_MODE_ICON_SIZE, settings.COMPACT_MODE_ICON_SIZE)
if target_names == "All":
target_names = ["translation_switch", "transcription_send_switch", "transcription_receive_switch", "foreground_switch", "quick_language_settings", "config_button", "minimize_sidebar_button", "entry_message_box"]
@@ -32,7 +30,7 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, ta
widget_selected_mark.configure(fg_color=settings.ctm.SF__SELECTED_MARK_ACTIVE_BG_COLOR)
icon_file = icon_name
image = CTkImage(icon_file, size=COMPACT_MODE_ICON_SIZE_TUPLES)
image = CTkImage(icon_file, size=settings.uism.SF__COMPACT_MODE_IMAGE_SIZE)
widget_compact_mode_icon.configure(image=image)
@@ -109,12 +107,12 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, ta
if status == "disabled":
vrct_gui.sidebar_config_button_wrapper.configure(cursor="")
vrct_gui.sidebar_config_button.configure(
image=CTkImage(settings.image_file.CONFIGURATION_ICON_DISABLED, size=COMPACT_MODE_ICON_SIZE_TUPLES),
image=CTkImage(settings.image_file.CONFIGURATION_ICON_DISABLED, size=settings.uism.SF__COMPACT_MODE_IMAGE_SIZE),
)
elif status == "normal":
vrct_gui.sidebar_config_button_wrapper.configure(cursor="hand2")
vrct_gui.sidebar_config_button.configure(
image=CTkImage(settings.image_file.CONFIGURATION_ICON, size=COMPACT_MODE_ICON_SIZE_TUPLES),
image=CTkImage(settings.image_file.CONFIGURATION_ICON, size=settings.uism.SF__COMPACT_MODE_IMAGE_SIZE),
)

View File

@@ -11,17 +11,23 @@ def createMainWindowWidgets(vrct_gui, settings, view_variable):
vrct_gui.iconbitmap(getImagePath("vrct_logo_mark_black.ico"))
vrct_gui.title("VRCT")
vrct_gui.minsize(200, 200)
# vrct_gui.minsize(200, 200)
# Main Container
vrct_gui.grid_columnconfigure(1, weight=1, minsize=settings.uism.MAIN_AREA_MIN_WIDTH)
vrct_gui.grid_columnconfigure(0, weight=1)
vrct_gui.grid_rowconfigure(0, weight=1)
# vrct_gui.grid_columnconfigure(0, weight=1, minsize=settings.uism.MAIN_AREA_MIN_WIDTH)
vrct_gui.configure(fg_color="#ff7f50")
vrct_gui.toplevel_wrapper = CTkFrame(vrct_gui, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0)
vrct_gui.toplevel_wrapper.grid(row=0, column=0, sticky="nsew")
vrct_gui.toplevel_wrapper.grid_columnconfigure(1, weight=1)
# Main Container
vrct_gui.main_bg_container = CTkFrame(vrct_gui, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0)
vrct_gui.main_bg_container = CTkFrame(vrct_gui.toplevel_wrapper, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0)
vrct_gui.main_bg_container.grid(row=0, column=1, sticky="nsew")

View File

@@ -217,11 +217,6 @@ def createSidebarFeatures(settings, main_window, view_variable):
setattr(main_window, switch_box_attr_name, switch_box_widget)
if settings.COMPACT_MODE_ICON_SIZE == 0:
label_widget.grid(row=row, column=0, pady=settings.uism.SF__LABELS_IPADY, padx=(settings.uism.SF__LABEL_LEFT_PAD,0), sticky="ew")
settings.COMPACT_MODE_ICON_SIZE = int(getLatestHeight(frame_widget) - settings.uism.SF__COMPACT_MODE_ICON_PADY*2)
label_widget.grid_remove()
# for compact mode
compact_mode_icon_widget = CTkLabel(
@@ -229,7 +224,7 @@ def createSidebarFeatures(settings, main_window, view_variable):
text=None,
height=0,
corner_radius=0,
image=CTkImage((icon_file),size=(settings.COMPACT_MODE_ICON_SIZE,settings.COMPACT_MODE_ICON_SIZE)),
image=CTkImage(icon_file, size=settings.uism.SF__COMPACT_MODE_IMAGE_SIZE),
)
setattr(main_window, compact_mode_icon_attr_name, compact_mode_icon_widget)
@@ -244,11 +239,11 @@ def createSidebarFeatures(settings, main_window, view_variable):
# Arrange
compact_mode_icon_widget.grid(row=row, column=0, pady=settings.uism.SF__COMPACT_MODE_ICON_PADY)
compact_mode_icon_widget.grid(row=row, column=0, padx=settings.uism.SF__COMPACT_MODE_ICON_PADX, pady=settings.uism.SF__COMPACT_MODE_ICON_PADY)
selected_mark_widget.place(relx=-1, rely=0.5, relheight=0.75, anchor="center")
label_widget.grid(row=row, column=0, pady=settings.uism.SF__LABELS_IPADY, padx=(settings.uism.SF__LABEL_LEFT_PAD,0), sticky="ew")
switch_box_widget.grid(row=row, column=0, padx=(0,settings.uism.SF__SWITCH_BOX_RIGHT_PAD), sticky="e")
switch_box_widget.grid(row=row, column=1, padx=settings.uism.SF__SWITCH_BOX_PADX, sticky="e")
# Unbind the event "<Button-1>" originally set up by the widget to manually control it.

View File

@@ -6,9 +6,9 @@ from ._create_sidebar import createSidebarFeatures, createSidebarLanguagesSettin
def createSidebar(settings, main_window, view_variable):
# Side Bar Container
main_window.grid_rowconfigure(0, weight=1)
main_window.toplevel_wrapper.grid_rowconfigure(0, weight=1)
main_window.sidebar_bg_container_wrapper = CTkFrame(main_window, corner_radius=0, fg_color=settings.ctm.SIDEBAR_BG_COLOR, width=0, height=0)
main_window.sidebar_bg_container_wrapper = CTkFrame(main_window.toplevel_wrapper, corner_radius=0, fg_color=settings.ctm.SIDEBAR_BG_COLOR, width=0, height=0)
main_window.sidebar_bg_container_wrapper.grid(row=0, column=0, sticky="nsew")
@@ -16,8 +16,8 @@ def createSidebar(settings, main_window, view_variable):
main_window.sidebar_compact_mode_bg_container = CTkFrame(main_window.sidebar_bg_container_wrapper, corner_radius=0, fg_color=settings.ctm.SIDEBAR_BG_COLOR, width=0, height=0)
main_window.sidebar_bg_container.grid_columnconfigure(0, weight=0, minsize=settings.uism.SIDEBAR_MIN_WIDTH)
main_window.sidebar_compact_mode_bg_container.grid_columnconfigure(0, weight=0, minsize=settings.uism.COMPACT_MODE_SIDEBAR_MIN_WIDTH)
main_window.sidebar_bg_container.grid_columnconfigure(0, weight=1, minsize=settings.uism.SIDEBAR_MIN_WIDTH)
main_window.sidebar_compact_mode_bg_container.grid_columnconfigure(0, weight=1)
createSidebarFeatures(settings, main_window, view_variable)
@@ -45,12 +45,11 @@ def createSidebar(settings, main_window, view_variable):
main_window.sidebar_config_button_wrapper.grid_columnconfigure(0, weight=1)
settings.uism.CONFIG_BUTTON_PADX = 0
main_window.sidebar_config_button = CTkLabel(
main_window.sidebar_config_button_wrapper,
text=None,
height=0,
image=CTkImage((settings.image_file.CONFIGURATION_ICON),size=(settings.COMPACT_MODE_ICON_SIZE,settings.COMPACT_MODE_ICON_SIZE))
image=CTkImage(settings.image_file.CONFIGURATION_ICON, size=settings.uism.SIDEBAR_CONFIG_BUTTON_IMAGE_SIZE)
)
main_window.sidebar_config_button.grid(row=0, column=0, padx=0, pady=settings.uism.SIDEBAR_CONFIG_BUTTON_IPADY)

View File

@@ -29,6 +29,7 @@ class UiScalingManager():
# Main
self.main.MAIN_AREA_MIN_WIDTH = self._calculateUiSize(640)
self.main.SIDEBAR_MIN_WIDTH = self._calculateUiSize(230)
self.main.TEXTBOX_PADX = self._calculateUiSize(16)
self.main.TEXTBOX_CORNER_RADIUS = self._calculateUiSize(6)
@@ -54,9 +55,6 @@ class UiScalingManager():
# Sidebar
self.main.SIDEBAR_MIN_WIDTH = self._calculateUiSize(230)
self.main.COMPACT_MODE_SIDEBAR_MIN_WIDTH = self._calculateUiSize(60)
# Sidebar Features
self.main.SF__LOGO_MAX_SIZE = self._calculateUiSize(120)
self.main.SF__LOGO_PADY = (self._calculateUiSize(12),self._calculateUiSize(8))
@@ -64,10 +62,12 @@ class UiScalingManager():
self.main.SF__LABELS_IPADY = self._calculateUiSize(16)
self.main.SF__COMPACT_MODE_ICON_PADY = self.main.SF__LABELS_IPADY
self.main.SF__COMPACT_MODE_ICON_PADX = self.main.SF__COMPACT_MODE_ICON_PADY
self.main.SF__LABEL_LEFT_PAD = self._calculateUiSize(20)
self.main.SF__LABEL_FONT_SIZE = self._calculateUiSize(16)
self.main.SF__COMPACT_MODE_IMAGE_SIZE = (self._calculateUiSize(20), self._calculateUiSize(20))
self.main.SF__SWITCH_BOX_RIGHT_PAD = self._calculateUiSize(10)
self.main.SF__SWITCH_BOX_PADX = (self.main.SF__LABEL_LEFT_PAD, self._calculateUiSize(10))
self.main.SF__SWITCH_BOX_WIDTH = self._calculateUiSize(40)
self.main.SF__SWITCH_BOX_HEIGHT = self._calculateUiSize(16)
@@ -98,6 +98,7 @@ class UiScalingManager():
self.main.SLS__BOX_TOP_PADY = self._calculateUiSize(16)
self.main.SIDEBAR_CONFIG_BUTTON_CORNER_RADIUS = self._calculateUiSize(6)
self.main.SIDEBAR_CONFIG_BUTTON_IMAGE_SIZE = self.main.SF__COMPACT_MODE_IMAGE_SIZE
self.main.SIDEBAR_CONFIG_BUTTON_PADX = self._calculateUiSize(10)
self.main.SIDEBAR_CONFIG_BUTTON_PADY = self._calculateUiSize(10)
self.main.SIDEBAR_CONFIG_BUTTON_IPADY = self._calculateUiSize(8)

View File

@@ -19,7 +19,6 @@ class VRCT_GUI(CTk):
def __init__(self):
super().__init__()
self.withdraw()
self.adjusted_event=None
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
@@ -45,6 +44,10 @@ class VRCT_GUI(CTk):
def _showGUI(self):
self.attributes("-alpha", 0)
self.deiconify()
self.geometry("{}x{}".format(
self.settings.main.uism.MAIN_AREA_MIN_WIDTH + self.settings.main.uism.SIDEBAR_MIN_WIDTH,
self.winfo_height()
))
setGeometryToCenterOfScreen(root_widget=self)
if self._view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE is True:
self._enableMainWindowSidebarCompactMode()
@@ -94,7 +97,7 @@ class VRCT_GUI(CTk):
)
self.main_window_cover = _CreateWindowCover(
attach_window=self,
attach_window=self.toplevel_wrapper,
settings=self.settings.main_window_cover,
view_variable=self._view_variable
)
@@ -266,18 +269,6 @@ class VRCT_GUI(CTk):
self.main_window_cover.geometry("{}x{}+{}+{}".format(width_new, height_new, x_pos, y_pos))
self.main_window_cover.lift()
if self.adjusted_event == str(e):
self.after(150, lambda: self.config_window.lift())
elif self.adjusted_event is None:
self.after(150, lambda: self.config_window.lift())
else:
pass
self.config_window.focus_set()
if e is not None:
self.adjusted_event=str(e)
def _showErrorMessage(self, target_widget):
self.error_message_window.show(target_widget=target_widget)