diff --git a/extra/requirements_linux.txt b/extra/requirements_linux.txt index 42994c8fc..2e1d3bfd4 100644 --- a/extra/requirements_linux.txt +++ b/extra/requirements_linux.txt @@ -6,8 +6,8 @@ Pillow PlexAPI PyGObject pylast>=3.1.0 -PySDL2 -pysdl2-dll +PySDL3 +#pysdl3-dll requests Send2Trash unidecode diff --git a/extra/requirements_macos.txt b/extra/requirements_macos.txt index ea95c3c5f..6ec12c2ff 100644 --- a/extra/requirements_macos.txt +++ b/extra/requirements_macos.txt @@ -5,8 +5,8 @@ Pillow PlexAPI PyGObject pylast>=3.1.0 -PySDL2 -pysdl2-dll +PySDL3 +#pysdl3-dll requests Send2Trash unidecode diff --git a/extra/requirements_windows.txt b/extra/requirements_windows.txt index 8267eb981..feeca809a 100644 --- a/extra/requirements_windows.txt +++ b/extra/requirements_windows.txt @@ -9,8 +9,8 @@ PlexAPI PyGObject pyinstaller pylast>=3.1.0 -PySDL2 -pysdl2-dll +PySDL3 +#pysdl3-dll requests Send2Trash unidecode diff --git a/linux.spec b/linux.spec index f53d05e59..afa9135a9 100644 --- a/linux.spec +++ b/linux.spec @@ -19,7 +19,7 @@ a = Analysis( ("src/tauon/theme", "theme"), ("src/tauon/templates", "templates"), # This could only have SDL2.framework and SDL2_image.framework to save space... - (f".venv/lib/python{python_ver}/site-packages/sdl2dll/dll", "sdl2dll/dll"), +# (f".venv/lib/python{python_ver}/site-packages/sdl2dll/dll", "sdl2dll/dll"), # (f".venv/lib/python{python_ver}/site-packages/sdl2dll/dll/SDL2.framework", "sdl2dll/dll/SDL2.framework"), # (f".venv/lib/python{python_ver}/site-packages/sdl2dll/dll/SDL2_image.framework", "sdl2dll/dll/SDL2_image.framework"), ], diff --git a/requirements.txt b/requirements.txt index 1f39117e7..9754c2a6e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,8 +5,8 @@ Pillow # ; sys_platform != 'darwin' # Install Pillow from b PlexAPI PyGObject pylast>=3.1.0 -PySDL2 -pysdl2-dll # Don't rely on system SDL2 https://github.com/py-sdl/py-sdl2#requirements +PySDL3 +#pysdl3-dll # Don't rely on system SDL2 https://github.com/py-sdl/py-sdl2#requirements #python-magic # optional requests Send2Trash diff --git a/src/tauon/__main__.py b/src/tauon/__main__.py index b3ff0ff01..3227f4c7c 100755 --- a/src/tauon/__main__.py +++ b/src/tauon/__main__.py @@ -20,47 +20,11 @@ import os import pickle import sys -from ctypes import c_int, pointer +from ctypes import c_int, pointer, c_float, byref from pathlib import Path from gi.repository import GLib -from sdl2 import ( - SDL_BLENDMODE_BLEND, - SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, - SDL_HINT_RENDER_SCALE_QUALITY, - SDL_HINT_VIDEO_ALLOW_SCREENSAVER, - SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, - SDL_INIT_VIDEO, - SDL_MESSAGEBOX_ERROR, - SDL_RENDERER_ACCELERATED, - SDL_RENDERER_PRESENTVSYNC, - SDL_WINDOW_ALLOW_HIGHDPI, - SDL_WINDOW_BORDERLESS, - SDL_WINDOW_FULLSCREEN_DESKTOP, - SDL_WINDOW_HIDDEN, - SDL_WINDOW_RESIZABLE, - SDL_WINDOWPOS_UNDEFINED, - SDL_CreateRenderer, - SDL_CreateTextureFromSurface, - SDL_CreateWindow, - SDL_DestroyTexture, - SDL_FreeSurface, - SDL_GetError, - SDL_GetWindowSize, - SDL_GL_GetDrawableSize, - SDL_Init, - SDL_MaximizeWindow, - SDL_Rect, - SDL_RenderClear, - SDL_RenderCopy, - SDL_RenderPresent, - SDL_SetHint, - SDL_SetRenderDrawBlendMode, - SDL_SetRenderDrawColor, - SDL_SetWindowOpacity, - SDL_ShowSimpleMessageBox, -) -from sdl2.sdlimage import IMG_Load +import sdl3 install_directory: Path = Path(__file__).resolve().parent sys.path.append(str(install_directory.parent)) @@ -105,7 +69,6 @@ logging.info(f"{t_title} {t_version}") logging.info("Copyright 2015-2025 Taiko2k captain.gxj@gmail.com\n") -logging.info("Arguments: " + " ".join(sys.argv)) # Early arg processing def transfer_args_and_exit() -> None: @@ -236,11 +199,10 @@ def transfer_args_and_exit() -> None: if sys.platform == "win32" and sys.getwindowsversion().major < 10 or Path(user_directory / "nohidpi").is_file(): allow_hidpi = False -SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, b"1") -SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, b"1") -SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, b"0") -SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best".encode()) -# SDL_SetHint(b"SDL_VIDEO_WAYLAND_ALLOW_LIBDECOR", b"0") +sdl3.SDL_SetHint(sdl3.SDL_HINT_VIDEO_ALLOW_SCREENSAVER.encode(), b"1") +sdl3.SDL_SetHint(sdl3.SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH.encode(), b"1") +sdl3.SDL_SetHint(sdl3.SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR.encode(), b"0") +# sdl3.SDL_SetHint(b"SDL_VIDEO_WAYLAND_ALLOW_LIBDECOR", b"0") draw_border = True w = 1120 @@ -307,45 +269,44 @@ def transfer_args_and_exit() -> None: if Path(user_directory / "x11").exists(): os.environ["SDL_VIDEODRIVER"] = "x11" -SDL_Init(SDL_INIT_VIDEO) -err = SDL_GetError() + +sdl3.SDL_Init(sdl3.SDL_INIT_VIDEO | sdl3.SDL_INIT_EVENTS) + +err = sdl3.SDL_GetError() if err and "GLX" in err.decode(): logging.error(f"SDL init error: {err.decode()}") - SDL_ShowSimpleMessageBox( - SDL_MESSAGEBOX_ERROR, b"Tauon Music Box failed to start :(", + sdl3.SDL_ShowSimpleMessageBox( + sdl3.SDL_MESSAGEBOX_ERROR, b"Tauon Music Box failed to start :(", b"Error: " + err + b".\n If you're using Flatpak, try run `$ flatpak update`", None) sys.exit(1) window_title = t_title window_title = window_title.encode("utf-8") -flags = SDL_WINDOW_RESIZABLE - -if allow_hidpi: - flags |= SDL_WINDOW_ALLOW_HIGHDPI +flags = sdl3.SDL_WINDOW_RESIZABLE | sdl3.SDL_WINDOW_TRANSPARENT if draw_border and not fs_mode: - flags |= SDL_WINDOW_BORDERLESS + flags |= sdl3.SDL_WINDOW_BORDERLESS if fs_mode: - flags |= SDL_WINDOW_FULLSCREEN_DESKTOP + flags |= sdl3.SDL_WINDOW_FULLSCREEN_DESKTOP if old_window_position is None: - o_x = SDL_WINDOWPOS_UNDEFINED - o_y = SDL_WINDOWPOS_UNDEFINED + o_x = sdl3.SDL_WINDOWPOS_UNDEFINED + o_y = sdl3.SDL_WINDOWPOS_UNDEFINED else: o_x = old_window_position[0] o_y = old_window_position[1] if "--tray" in sys.argv: - flags |= SDL_WINDOW_HIDDEN + flags |= sdl3.SDL_WINDOW_HIDDEN -t_window = SDL_CreateWindow( +t_window = sdl3.SDL_CreateWindow( # todo use SDL_CreateWindowAndRenderer() window_title, - o_x, o_y, + # o_x, o_y, logical_size[0], logical_size[1], - flags) # | SDL_WINDOW_FULLSCREEN) + flags) if not t_window: logging.error("ERROR CREATING WINDOW!") @@ -355,52 +316,45 @@ def transfer_args_and_exit() -> None: logging.error(f"Size 0: {logical_size[0]}") logging.error(f"Size 1: {logical_size[1]}") logging.error(f"Flags: {flags}") - sdl_err = SDL_GetError().decode() - logging.error(f"SDL Error: {sdl_err}") - if sdl_err == "x11 not available": - x11_path = user_directory / "x11" - if x11_path.exists(): - logging.critical("Disabled Xwayland preference as X11 was not found - Known issue if on Flatpak - https://github.com/Taiko2k/Tauon/issues/1034") - x11_path.unlink() - os.environ["SDL_VIDEODRIVER"] = "wayland" - t_window = SDL_CreateWindow( - window_title, - o_x, o_y, - logical_size[0], logical_size[1], - flags) - if not t_window: - logging.error(f"Failed to create Wayland fallback window - SDL Error: {SDL_GetError()}") - sys.exit(1) - else: - logging.critical(f"Failed to find {x11_path} but got 'x11 not available' error, hm?") - sys.exit(1) - else: - sys.exit(1) + logging.error(f"SDL Error: {sdl3.SDL_GetError()}") + sys.exit(1) if maximized: - SDL_MaximizeWindow(t_window) + sdl3.SDL_MaximizeWindow(t_window) -renderer = SDL_CreateRenderer(t_window, 0, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC) +drivers = [] +i = 0 +while True: + x = sdl3.SDL_GetRenderDriver(i) + i += 1 + if x is None: + break + drivers.append(x) + +logging.debug(f"SDL availiable drivers: {drivers}") + +renderer = sdl3.SDL_CreateRenderer(t_window, b"opengl") # sdl3.SDL_RENDERER_PRESENTVSYNC if not renderer: logging.error("ERROR CREATING RENDERER!") logging.error(f"SDL Error: {SDL_GetError()}") sys.exit(1) -SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND) -SDL_SetWindowOpacity(t_window, window_opacity) +sdl3.SDL_SetRenderDrawBlendMode(renderer, sdl3.SDL_BLENDMODE_BLEND) +sdl3.SDL_SetWindowOpacity(t_window, window_opacity) -SDL_SetRenderDrawColor(renderer, 7, 7, 7, 255) -SDL_RenderClear(renderer) +sdl3.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) +sdl3.SDL_RenderClear(renderer) +logging.info(f"SDL window system: {sdl3.SDL_GetCurrentVideoDriver().decode()}") i_x = pointer(c_int(0)) i_y = pointer(c_int(0)) -SDL_GL_GetDrawableSize(t_window, i_x, i_y) +sdl3.SDL_GetWindowSizeInPixels(t_window, i_x, i_y) window_size[0] = i_x.contents.value window_size[1] = i_y.contents.value -SDL_GetWindowSize(t_window, i_x, i_y) +sdl3.SDL_GetWindowSize(t_window, i_x, i_y) logical_size[0] = i_x.contents.value logical_size[1] = i_y.contents.value @@ -414,18 +368,26 @@ def transfer_args_and_exit() -> None: img_path = img_path2 del img_path2 -raw_image = IMG_Load(str(img_path).encode()) -sdl_texture = SDL_CreateTextureFromSurface(renderer, raw_image) -w = raw_image.contents.w -h = raw_image.contents.h -rect = SDL_Rect(window_size[0] // 2 - w // 2, window_size[1] // 2 - h // 2, w, h) +sdl3.SDL_SetRenderDrawColor(renderer, 7, 7, 7, 255) +sdl3.SDL_RenderFillRect(renderer, None) + +raw_image = sdl3.IMG_Load(str(img_path).encode()) +texture = sdl3.SDL_CreateTextureFromSurface(renderer, raw_image) +i_x = c_float(0.0) +i_y = c_float(0.0) +sdl3.SDL_GetTextureSize(texture, byref(i_x), byref(i_y)) +w = i_x.value +h = i_y.value +rect = sdl3.SDL_FRect(window_size[0] // 2 - w // 2, window_size[1] // 2 - h // 2, w, h) +sdl3.SDL_RenderTexture(renderer, texture, None, rect) -SDL_RenderCopy(renderer, sdl_texture, None, rect) -SDL_RenderPresent(renderer) -SDL_FreeSurface(raw_image) -SDL_DestroyTexture(sdl_texture) + +sdl3.SDL_RenderPresent(renderer) + +sdl3.SDL_DestroySurface(raw_image) +sdl3.SDL_DestroyTexture(texture) holder = t_bootstrap.holder holder.t_window = t_window @@ -455,13 +417,14 @@ def transfer_args_and_exit() -> None: holder.log = log del raw_image -del sdl_texture +del texture del w del h del rect del flags del img_path + def main() -> None: """Launch Tauon by means of importing t_main.py""" from tauon.t_modules import t_main diff --git a/src/tauon/t_modules/t_draw.py b/src/tauon/t_modules/t_draw.py index d5b564f6e..64f37f0df 100644 --- a/src/tauon/t_modules/t_draw.py +++ b/src/tauon/t_modules/t_draw.py @@ -27,38 +27,10 @@ from typing import TYPE_CHECKING from PIL import Image -from sdl2 import ( - SDL_BLENDFACTOR_ONE, - SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, - SDL_BLENDOPERATION_ADD, - SDL_FLIP_VERTICAL, - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_BGR24, - SDL_PIXELFORMAT_RGB888, - SDL_ComposeCustomBlendMode, - SDL_CreateRGBSurfaceWithFormatFrom, - SDL_CreateTextureFromSurface, - SDL_DestroyTexture, - SDL_FreeSurface, - SDL_MapRGB, - SDL_QueryTexture, - SDL_Rect, - SDL_RenderCopy, - SDL_RenderCopyEx, - SDL_RenderDrawLine, - SDL_RenderFillRect, - SDL_RenderReadPixels, - SDL_SetColorKey, - SDL_SetRenderDrawColor, - SDL_SetTextureBlendMode, - rw_from_object, -) -from sdl2.sdlimage import IMG_Load_RW +import sdl3 from tauon.t_modules.t_extra import Timer, alpha_blend, coll_rect -if TYPE_CHECKING: - from sdl2 import SDL_Renderer try: from jxlpy import JXLImagePlugin @@ -94,14 +66,15 @@ import win32ui + class QuickThumbnail: - renderer: SDL_Renderer | None = None + renderer: sdl3.SDL_Renderer | None = None items: list[QuickThumbnail] = [] queue: list[QuickThumbnail] = [] def __init__(self) -> None: - self.rect = SDL_Rect(0, 0) + self.rect = sdl3.FSDL_Rect(0., 0.) self.texture = None self.surface = None self.size = 50 @@ -110,10 +83,10 @@ def __init__(self) -> None: def destruct(self) -> None: if self.surface: - SDL_FreeSurface(self.surface) + sdl3.SDL_DestroySurface(self.surface) self.surface = None if self.texture: - SDL_DestroyTexture(self.texture) + sdl3.SDL_DestroyTexture(self.texture) self.texture = None self.alive = False @@ -132,12 +105,12 @@ def read_and_thumbnail(self, f: str, width: int, height: int) -> None: def prime(self) -> None: - texture = SDL_CreateTextureFromSurface(self.renderer, self.surface) - SDL_FreeSurface(self.surface) + texture = sdl3.SDL_CreateTextureFromSurface(self.renderer, self.surface) + sdl3.SDL_DestroySurface(self.surface) self.surface = None tex_w = pointer(c_int(0)) tex_h = pointer(c_int(0)) - SDL_QueryTexture(texture, None, None, tex_w, tex_h) + sdl3.SDL_QueryTexture(texture, None, None, tex_w, tex_h) self.rect.w = int(tex_w.contents.value) self.rect.h = int(tex_h.contents.value) self.texture = texture @@ -155,7 +128,7 @@ def draw(self, x: int, y: int) -> bool | None: self.prime() self.rect.x = round(x) self.rect.y = round(y) - SDL_RenderCopy(self.renderer, self.texture, None, self.rect) + sdl3.SDL_RenderCopy(self.renderer, self.texture, None, self.rect) return True @@ -194,9 +167,9 @@ def native_bmp_to_sdl(hdc, bitmap_handle, width: int, height: int): # -> tuple[U raise OSError("native_bmp_to_pil failed: GetDIBits") # TODO(Martin): Add the rest of the types in this function: - logging.debug(f"IF YOU SEE THIS MESSAGE, ADD THESE TYPES TO native_bmp_to_sdl(): HDC: {type(hdc)}, bitmap_handle: {type(bitmap_handle)}, returnType:{type(SDL_CreateRGBSurfaceWithFormatFrom(ctypes.pointer(c_bits), width, height, 24, (width*3 + 3) & -4 , SDL_PIXELFORMAT_BGR24))}") + logging.debug(f"IF YOU SEE THIS MESSAGE, ADD THESE TYPES TO native_bmp_to_sdl(): HDC: {type(hdc)}, bitmap_handle: {type(bitmap_handle)}, returnType:{type(sdl3.SDL_CreateSurfaceFrom(width, height, sdl3.SDL_PIXELFORMAT_BGR24, ctypes.pointer(c_bits), (width*3 + 3) & -4))}") # We need to keep c_bits pass else it may be garbage collected - return SDL_CreateRGBSurfaceWithFormatFrom(ctypes.pointer(c_bits), width, height, 24, (width*3 + 3) & -4 , SDL_PIXELFORMAT_BGR24), c_bits + return sdl3.SDL_CreateSurfaceFrom(width, height, sdl3.SDL_PIXELFORMAT_BGR24, ctypes.pointer(c_bits), (width*3 + 3) & -4), c_bits class Win32Font: @@ -329,7 +302,7 @@ def __del__(self) -> None: class TDraw: - def __init__(self, renderer: SDL_Renderer | None = None) -> None: + def __init__(self, renderer: sdl3.SDL_Renderer | None = None) -> None: # All self.renderer = renderer @@ -337,11 +310,11 @@ def __init__(self, renderer: SDL_Renderer | None = None) -> None: self.force_subpixel_text = False # Drawing - self.sdl_rect = SDL_Rect(10, 10, 10, 10) + self.sdlrect = sdl3.SDL_FRect(10., 10., 10., 10.) # Text and Fonts - self.source_rect = SDL_Rect(0, 0, 0, 0) - self.dest_rect = SDL_Rect(0, 0, 0, 0) + self.source_rect = sdl3.SDL_FRect(0., 0., 0., 0.) + self.dest_rect = sdl3.SDL_FRect(0., 0., 0., 0.) if system == "Linux": @@ -365,67 +338,76 @@ def __init__(self, renderer: SDL_Renderer | None = None) -> None: self.was_truncated = False + def load_image(self, g: io.BinaryIO) -> sdl3.SDL_Surface: + + size = g.getbuffer().nbytes + pointer = ctypes.c_void_p(ctypes.addressof(ctypes.c_char.from_buffer(g.getbuffer()))) + stream = sdl3.SDL_IOFromMem(pointer, size) + + return sdl3.IMG_Load_IO(stream, closeio=True) + def rect_s(self, rectangle: tuple[int, int, int, int], colour: tuple[int, int, int, int], thickness: int) -> None: - SDL_SetRenderDrawColor(self.renderer, colour[0], colour[1], colour[2], colour[3]) + sdl3.SDL_SetRenderDrawColor(self.renderer, colour[0], colour[1], colour[2], colour[3]) x, y, w, h = (round(x) for x in rectangle) th = math.floor(thickness) - self.sdl_rect.x = x - th - self.sdl_rect.y = y - th - self.sdl_rect.w = th - self.sdl_rect.h = h + th - SDL_RenderFillRect(self.renderer, self.sdl_rect) # left - self.sdl_rect.x = x - th - self.sdl_rect.y = y + h - self.sdl_rect.w = w + th - self.sdl_rect.h = th - SDL_RenderFillRect(self.renderer, self.sdl_rect) # bottom - self.sdl_rect.x = x - self.sdl_rect.y = y - th - self.sdl_rect.w = w + th - self.sdl_rect.h = th - SDL_RenderFillRect(self.renderer, self.sdl_rect) # top - self.sdl_rect.x = x + w - self.sdl_rect.y = y - self.sdl_rect.w = th - self.sdl_rect.h = h + th - SDL_RenderFillRect(self.renderer, self.sdl_rect) # right + self.sdlrect.x = x - th + self.sdlrect.y = y - th + self.sdlrect.w = th + self.sdlrect.h = h + th + sdl3.SDL_RenderFillRect(self.renderer, self.sdlrect) # left + self.sdlrect.x = x - th + self.sdlrect.y = y + h + self.sdlrect.w = w + th + self.sdlrect.h = th + sdl3.SDL_RenderFillRect(self.renderer, self.sdlrect) # bottom + self.sdlrect.x = x + self.sdlrect.y = y - th + self.sdlrect.w = w + th + self.sdlrect.h = th + sdl3.SDL_RenderFillRect(self.renderer, self.sdlrect) # top + self.sdlrect.x = x + w + self.sdlrect.y = y + self.sdlrect.w = th + self.sdlrect.h = h + th + sdl3.SDL_RenderFillRect(self.renderer, self.sdlrect) # right def rect_a(self, location_xy: list[int], size_wh: list[int], colour: tuple[int, int, int, int]) -> None: self.rect((location_xy[0], location_xy[1], size_wh[0], size_wh[1]), colour) def rect(self, rectangle: tuple[int, int, int, int], colour: tuple[int, int, int, int]) -> None: - self.sdl_rect.x = round(rectangle[0]) - self.sdl_rect.y = round(rectangle[1]) - self.sdl_rect.w = round(rectangle[2]) - self.sdl_rect.h = round(rectangle[3]) + sdl3.SDL_SetRenderDrawColor(self.renderer, colour[0], colour[1], colour[2], colour[3]) + + self.sdlrect.x = float(rectangle[0]) + self.sdlrect.y = float(rectangle[1]) + self.sdlrect.w = float(rectangle[2]) + self.sdlrect.h = float(rectangle[3]) - SDL_SetRenderDrawColor(self.renderer, colour[0], colour[1], colour[2], colour[3]) #if fill: - SDL_RenderFillRect(self.renderer, self.sdl_rect) + sdl3.SDL_RenderFillRect(self.renderer, self.sdlrect) # else: - # SDL_RenderDrawRect(self.renderer, self.sdl_rect) + # sdl3.SDL_RenderDrawRect(self.renderer, self.sdlrect) def bordered_rect(self, rectangle: tuple[int, int, int, int], fill_colour: list[int], outer_colour: list[int], border_size: int) -> None: - self.sdl_rect.x = round(rectangle[0]) - border_size - self.sdl_rect.y = round(rectangle[1]) - border_size - self.sdl_rect.w = round(rectangle[2]) + border_size + border_size - self.sdl_rect.h = round(rectangle[3]) + border_size + border_size - SDL_SetRenderDrawColor(self.renderer, outer_colour[0], outer_colour[1], outer_colour[2], outer_colour[3]) - SDL_RenderFillRect(self.renderer, self.sdl_rect) - self.sdl_rect.x = round(rectangle[0]) - self.sdl_rect.y = round(rectangle[1]) - self.sdl_rect.w = round(rectangle[2]) - self.sdl_rect.h = round(rectangle[3]) - SDL_SetRenderDrawColor(self.renderer, fill_colour[0], fill_colour[1], fill_colour[2], fill_colour[3]) - SDL_RenderFillRect(self.renderer, self.sdl_rect) + self.sdlrect.x = round(rectangle[0]) - border_size + self.sdlrect.y = round(rectangle[1]) - border_size + self.sdlrect.w = round(rectangle[2]) + border_size + border_size + self.sdlrect.h = round(rectangle[3]) + border_size + border_size + sdl3.SDL_SetRenderDrawColor(self.renderer, outer_colour[0], outer_colour[1], outer_colour[2], outer_colour[3]) + sdl3.SDL_RenderFillRect(self.renderer, self.sdlrect) + self.sdlrect.x = round(rectangle[0]) + self.sdlrect.y = round(rectangle[1]) + self.sdlrect.w = round(rectangle[2]) + self.sdlrect.h = round(rectangle[3]) + sdl3.SDL_SetRenderDrawColor(self.renderer, fill_colour[0], fill_colour[1], fill_colour[2], fill_colour[3]) + sdl3.SDL_RenderFillRect(self.renderer, self.sdlrect) def line(self, x1: int, y1: int, x2: int, y2: int, colour: list[int]) -> None: - SDL_SetRenderDrawColor(self.renderer, colour[0], colour[1], colour[2], colour[3]) - SDL_RenderDrawLine(self.renderer, round(x1), round(y1), round(x2), round(y2)) + sdl3.SDL_SetRenderDrawColor(self.renderer, colour[0], colour[1], colour[2], colour[3]) + sdl3.SDL_RenderLine(self.renderer, round(x1), round(y1), round(x2), round(y2)) def get_text_w(self, text: str, font: int, height: bool = False) -> int: @@ -438,7 +420,7 @@ def clear_text_cache(self) -> None: for key in self.ttl: so = self.ttc[key] - SDL_DestroyTexture(so[1]) + sdl3.SDL_DestroyTexture(so[1]) self.ttc.clear() self.ttl.clear() @@ -524,10 +506,11 @@ def __render_text(self, key: dict, x: int, y: int, range_top: int, range_height: self.dest_rect.w = sd[0].w self.dest_rect.h = round(range_height) - SDL_RenderCopyEx(self.renderer, sd[1], self.source_rect, self.dest_rect, 0, None, 0) + #sdl3.SDL_RenderCopyEx(self.renderer, sd[1], self.source_rect, self.dest_rect, 0, None, 0) + sdl3.SDL_RenderTexture(self.renderer, sd[1], self.source_rect, self.dest_rect) return - SDL_RenderCopy(self.renderer, sd[1], None, sd[0]) + sdl3.SDL_RenderTexture(self.renderer, sd[1], None, sd[0]) def __draw_text_cairo( @@ -616,7 +599,7 @@ def __draw_text_cairo( data = ctypes.c_buffer(b"\x00" * (h * (w * 4))) if real_bg: - box = SDL_Rect(x, y - self.get_y_offset(text, font, max_x, wrap), w, h) + box = sdl3.SDL_FRect(x, y - self.get_y_offset(text, font, max_x, wrap), w, h) if align == 1: box.x = x - box.w @@ -624,7 +607,7 @@ def __draw_text_cairo( elif align == 2: box.x -= int(box.w / 2) - SDL_RenderReadPixels(self.renderer, box, SDL_PIXELFORMAT_RGB888, ctypes.pointer(data), (w * 4)) + sdl3.SDL_RenderReadPixels(self.renderer, box, sdl3.SDL_PIXELFORMAT_RGB888, ctypes.pointer(data), (w * 4)) if alpha_bg: surf = cairo.ImageSurface.create_for_data(data, cairo.FORMAT_ARGB32, w, h) @@ -703,23 +686,27 @@ def __draw_text_cairo( self.was_truncated = layout.is_ellipsized() if alpha_bg: - sdl_surface = SDL_CreateRGBSurfaceWithFormatFrom(ctypes.pointer(data), w, h, 32, w * 4, SDL_PIXELFORMAT_ARGB8888) + #sdl3.SDL_surface = sdl3.SDL_CreateRGBSurfaceWithFormatFrom(ctypes.pointer(data), w, h, 32, w * 4, sdl3.SDL_PIXELFORMAT_ARGB8888) + format = sdl3.SDL_PIXELFORMAT_ARGB8888 + surface = sdl3.SDL_CreateSurfaceFrom(w, h, format, ctypes.pointer(data), w * 4) else: - sdl_surface = SDL_CreateRGBSurfaceWithFormatFrom(ctypes.pointer(data), w, h, 24, w * 4, SDL_PIXELFORMAT_RGB888) + format = sdl3.SDL_PIXELFORMAT_XRGB8888 + surface = sdl3.SDL_CreateSurfaceFrom(w, h, format, ctypes.pointer(data), w * 4) # Here the background colour is keyed out allowing lines to overlap slightly if not real_bg and not alpha_bg: - ke = SDL_MapRGB(sdl_surface.contents.format, bg[0], bg[1], bg[2]) - SDL_SetColorKey(sdl_surface, True, ke) + format_details = sdl3.SDL_GetPixelFormatDetails(format) + ke = sdl3.SDL_MapRGB(format_details, None, bg[0], bg[1], bg[2]) + sdl3.SDL_SetSurfaceColorKey(surface, True, ke) - c = SDL_CreateTextureFromSurface(self.renderer, sdl_surface) - SDL_FreeSurface(sdl_surface) + c = sdl3.SDL_CreateTextureFromSurface(self.renderer, surface) + sdl3.SDL_DestroySurface(surface) if alpha_bg: - blend_mode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD) - SDL_SetTextureBlendMode(c, blend_mode) + blend_mode = sdl3.SDL_ComposeCustomBlendMode(sdl3.SDL_BLENDFACTOR_ONE, sdl3.SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, sdl3.SDL_BLENDOPERATION_ADD, sdl3.SDL_BLENDFACTOR_ONE, sdl3.SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, sdl3.SDL_BLENDOPERATION_ADD) + sdl3.SDL_SetTextureBlendMode(c, blend_mode) - dst = SDL_Rect(round(x), round(y)) + dst = sdl3.SDL_FRect(round(x), round(y)) dst.w = round(w) dst.h = round(h) dst.y = round(y) - y_off @@ -735,7 +722,7 @@ def __draw_text_cairo( if len(self.ttl) > 350: key = self.ttl[0] so = self.ttc[key] - SDL_DestroyTexture(so[1]) + sdl3.SDL_DestroyTexture(so[1]) del self.ttc[key] del self.ttl[0] if wrap: @@ -783,10 +770,10 @@ def __win_render_text(self, key: dict, x: int, y: int, range_top: int, range_hei self.dest_rect.w = sd[0].w self.dest_rect.h = round(range_height) - SDL_RenderCopyEx(self.renderer, sd[1], self.source_rect, self.dest_rect, 0, None, SDL_FLIP_VERTICAL) + sdl3.SDL_RenderCopyEx(self.renderer, sd[1], self.source_rect, self.dest_rect, 0, None, sdl3.SDL_FLIP_VERTICAL) return - SDL_RenderCopyEx(self.renderer, sd[1], None, sd[0], 0, None, SDL_FLIP_VERTICAL) + sdl3.SDL_RenderCopyEx(self.renderer, sd[1], None, sd[0], 0, None, sdl3.SDL_FLIP_VERTICAL) def __draw_text_windows( self, x: int, y: int, text: str, bg: list[int], fg: list[int], font: Win32Font | None = None, @@ -823,17 +810,17 @@ def __draw_text_windows( im, c_bits = f.renderText(text, bg, fg, wrap, max_x, max_y) s_image = im - ke = SDL_MapRGB(s_image.contents.format, bg[0], bg[1], bg[2]) - SDL_SetColorKey(s_image, True, ke) - c = SDL_CreateTextureFromSurface(self.renderer, s_image) + ke = sdl3.SDL_MapRGB(s_image.contents.format, bg[0], bg[1], bg[2]) + sdl3.SDL_SetColorKey(s_image, True, ke) + c = sdl3.SDL_CreateTextureFromSurface(self.renderer, s_image) tex_w = pointer(c_int(0)) tex_h = pointer(c_int(0)) - SDL_QueryTexture(c, None, None, tex_w, tex_h) - dst = SDL_Rect(round(x), round(y)) + sdl3.SDL_QueryTexture(c, None, None, tex_w, tex_h) + dst = sdl3.SDL_FRect(round(x), round(y)) dst.w = int(tex_w.contents.value) dst.h = int(tex_h.contents.value) - SDL_FreeSurface(s_image) + sdl3.SDL_DestroySurface(s_image) #im.close() if align == 1: @@ -842,8 +829,8 @@ def __draw_text_windows( elif align == 2: dst.x -= int(dst.w / 2) - #SDL_RenderCopy(renderer, c, None, dst) - #SDL_RenderCopyEx(self.renderer, c, None, dst, 0, None, SDL_FLIP_VERTICAL) + #sdl3.SDL_RenderCopy(renderer, c, None, dst) + #sdl3.SDL_RenderCopyEx(self.renderer, c, None, dst, 0, None, sdl3.SDL_FLIP_VERTICAL) #logging.info(perf_timer.get()) self.cache[key] = [dst, c] @@ -852,7 +839,7 @@ def __draw_text_windows( self.ca_li.append(key) if len(self.ca_li) > 350: - SDL_DestroyTexture(self.cache[self.ca_li[0]][1]) + sdl3.SDL_DestroyTexture(self.cache[self.ca_li[0]][1]) del self.cache[self.ca_li[0]] del self.ca_li[0] diff --git a/src/tauon/t_modules/t_main.py b/src/tauon/t_modules/t_main.py index 7dc5351ee..42b1e9e71 100644 --- a/src/tauon/t_modules/t_main.py +++ b/src/tauon/t_modules/t_main.py @@ -23,8 +23,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . + from __future__ import annotations + + import base64 import builtins import certifi @@ -49,6 +52,7 @@ import platform import random import re +import sdl3 import secrets import shlex import shutil @@ -65,7 +69,7 @@ import xml.etree.ElementTree as ET import zipfile from collections import OrderedDict -from ctypes import Structure, byref, c_char_p, c_double, c_int, c_uint32, c_void_p, pointer +from ctypes import Structure, byref, c_char_p, c_double, c_int, c_uint32, c_void_p, pointer, c_float from pathlib import Path from typing import TYPE_CHECKING @@ -78,184 +82,7 @@ import requests from bs4 import BeautifulSoup from PIL import Image, ImageDraw, ImageEnhance, ImageFilter -from sdl2 import ( - SDL_BLENDMODE_BLEND, - SDL_BLENDMODE_NONE, - SDL_BUTTON_LEFT, - SDL_BUTTON_MIDDLE, - SDL_BUTTON_RIGHT, - SDL_BUTTON_X1, - SDL_BUTTON_X2, - SDL_CONTROLLER_AXIS_LEFTY, - SDL_CONTROLLER_AXIS_RIGHTX, - SDL_CONTROLLER_AXIS_RIGHTY, - SDL_CONTROLLER_AXIS_TRIGGERLEFT, - SDL_CONTROLLER_BUTTON_A, - SDL_CONTROLLER_BUTTON_B, - SDL_CONTROLLER_BUTTON_DPAD_DOWN, - SDL_CONTROLLER_BUTTON_DPAD_LEFT, - SDL_CONTROLLER_BUTTON_DPAD_RIGHT, - SDL_CONTROLLER_BUTTON_DPAD_UP, - SDL_CONTROLLER_BUTTON_LEFTSHOULDER, - SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, - SDL_CONTROLLER_BUTTON_X, - SDL_CONTROLLER_BUTTON_Y, - SDL_CONTROLLERAXISMOTION, - SDL_CONTROLLERBUTTONDOWN, - SDL_CONTROLLERDEVICEADDED, - SDL_DROPFILE, - SDL_DROPTEXT, - SDL_FALSE, - SDL_HITTEST_DRAGGABLE, - SDL_HITTEST_NORMAL, - SDL_HITTEST_RESIZE_BOTTOM, - SDL_HITTEST_RESIZE_BOTTOMLEFT, - SDL_HITTEST_RESIZE_BOTTOMRIGHT, - SDL_HITTEST_RESIZE_LEFT, - SDL_HITTEST_RESIZE_RIGHT, - SDL_HITTEST_RESIZE_TOPLEFT, - SDL_HITTEST_RESIZE_TOPRIGHT, - SDL_INIT_EVERYTHING, - SDL_INIT_GAMECONTROLLER, - SDL_KEYDOWN, - SDL_KEYUP, - SDL_MOUSEBUTTONDOWN, - SDL_MOUSEBUTTONUP, - SDL_MOUSEMOTION, - SDL_MOUSEWHEEL, - SDL_PIXELFORMAT_ARGB8888, - SDL_QUIT, - SDL_RENDER_TARGETS_RESET, - SDL_SCANCODE_A, - SDL_SCANCODE_C, - SDL_SCANCODE_V, - SDL_SCANCODE_X, - SDL_SCANCODE_Z, - SDL_SYSTEM_CURSOR_ARROW, - SDL_SYSTEM_CURSOR_HAND, - SDL_SYSTEM_CURSOR_IBEAM, - SDL_SYSTEM_CURSOR_SIZENS, - SDL_SYSTEM_CURSOR_SIZENWSE, - SDL_SYSTEM_CURSOR_SIZEWE, - SDL_SYSWM_COCOA, - SDL_SYSWM_UNKNOWN, - SDL_SYSWM_WAYLAND, - SDL_SYSWM_X11, - SDL_TEXTEDITING, - SDL_TEXTINPUT, - SDL_TEXTUREACCESS_TARGET, - SDL_TRUE, - SDL_WINDOW_FULLSCREEN_DESKTOP, - SDL_WINDOW_INPUT_FOCUS, - SDL_WINDOWEVENT, - SDL_WINDOWEVENT_DISPLAY_CHANGED, - SDL_WINDOWEVENT_ENTER, - SDL_WINDOWEVENT_EXPOSED, - SDL_WINDOWEVENT_FOCUS_GAINED, - SDL_WINDOWEVENT_FOCUS_LOST, - SDL_WINDOWEVENT_LEAVE, - SDL_WINDOWEVENT_MAXIMIZED, - SDL_WINDOWEVENT_MINIMIZED, - SDL_WINDOWEVENT_RESIZED, - SDL_WINDOWEVENT_RESTORED, - SDL_WINDOWEVENT_SHOWN, - SDLK_BACKSPACE, - SDLK_DELETE, - SDLK_DOWN, - SDLK_END, - SDLK_HOME, - SDLK_KP_ENTER, - SDLK_LALT, - SDLK_LCTRL, - SDLK_LEFT, - SDLK_LGUI, - SDLK_LSHIFT, - SDLK_RALT, - SDLK_RCTRL, - SDLK_RETURN, - SDLK_RETURN2, - SDLK_RIGHT, - SDLK_RSHIFT, - SDLK_TAB, - SDLK_UP, - SDL_CaptureMouse, - SDL_CreateColorCursor, - SDL_CreateRGBSurfaceWithFormatFrom, - SDL_CreateSystemCursor, - SDL_CreateTexture, - SDL_CreateTextureFromSurface, - SDL_Delay, - SDL_DestroyTexture, - SDL_DestroyWindow, - SDL_Event, - SDL_FreeSurface, - SDL_GameControllerNameForIndex, - SDL_GameControllerOpen, - SDL_GetClipboardText, - SDL_GetCurrentVideoDriver, - SDL_GetGlobalMouseState, - SDL_GetKeyFromName, - SDL_GetMouseState, - SDL_GetScancodeFromName, - SDL_GetVersion, - SDL_GetWindowFlags, - SDL_GetWindowPosition, - SDL_GetWindowSize, - SDL_GetWindowWMInfo, - SDL_GL_GetDrawableSize, - SDL_HasClipboardText, - SDL_HideWindow, - SDL_HitTest, - SDL_InitSubSystem, - SDL_IsGameController, - SDL_MaximizeWindow, - SDL_MinimizeWindow, - SDL_PollEvent, - SDL_PumpEvents, - SDL_PushEvent, - SDL_QueryTexture, - SDL_Quit, - SDL_QuitSubSystem, - SDL_RaiseWindow, - SDL_Rect, - SDL_RenderClear, - SDL_RenderCopy, - SDL_RenderFillRect, - SDL_RenderPresent, - SDL_RestoreWindow, - SDL_SetClipboardText, - SDL_SetCursor, - SDL_SetRenderDrawBlendMode, - SDL_SetRenderDrawColor, - SDL_SetRenderTarget, - SDL_SetTextInputRect, - SDL_SetTextureAlphaMod, - SDL_SetTextureBlendMode, - SDL_SetTextureColorMod, - SDL_SetWindowAlwaysOnTop, - SDL_SetWindowBordered, - SDL_SetWindowFullscreen, - SDL_SetWindowHitTest, - SDL_SetWindowIcon, - SDL_SetWindowMinimumSize, - SDL_SetWindowOpacity, - SDL_SetWindowPosition, - SDL_SetWindowResizable, - SDL_SetWindowSize, - SDL_SetWindowTitle, - SDL_ShowWindow, - SDL_StartTextInput, - SDL_SysWMinfo, - SDL_version, - SDL_WaitEventTimeout, - SDLK_a, - SDLK_c, - SDLK_v, - SDLK_x, - SDLK_z, - rw_from_object, -) -from sdl2.sdlimage import IMG_Load, IMG_Load_RW, IMG_Quit + from send2trash import send2trash from unidecode import unidecode @@ -346,6 +173,9 @@ from pylast import Artist, LibreFMNetwork from PIL.ImageFile import ImageFile +gbc.disable() +ggc = 2 + # Log to debug as we don't care at all when user does not have this try: import colored_traceback.always @@ -762,17 +592,17 @@ def whicher(target: str) -> bool | str | None: pid = os.getpid() if not macos: - icon = IMG_Load(str(asset_directory / "icon-64.png").encode()) + icon = sdl3.IMG_Load(str(asset_directory / "icon-64.png").encode()) else: - icon = IMG_Load(str(asset_directory / "tau-mac.png").encode()) + icon = sdl3.IMG_Load(str(asset_directory / "tau-mac.png").encode()) -SDL_SetWindowIcon(t_window, icon) +sdl3.SDL_SetWindowIcon(t_window, icon) if not phone: if window_size[0] != logical_size[0]: - SDL_SetWindowMinimumSize(t_window, 560, 330) + sdl3.SDL_SetWindowMinimumSize(t_window, 560, 330) else: - SDL_SetWindowMinimumSize(t_window, round(560 * scale), round(330 * scale)) + sdl3.SDL_SetWindowMinimumSize(t_window, round(560 * scale), round(330 * scale)) max_window_tex = 1000 if window_size[0] > max_window_tex or window_size[1] > max_window_tex: @@ -782,45 +612,45 @@ def whicher(target: str) -> bool | str | None: while window_size[1] > max_window_tex: max_window_tex += 1000 -main_texture = SDL_CreateTexture( - renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, max_window_tex, +main_texture = sdl3.SDL_CreateTexture( + renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, max_window_tex, max_window_tex) -main_texture_overlay_temp = SDL_CreateTexture( - renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, +main_texture_overlay_temp = sdl3.SDL_CreateTexture( + renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, max_window_tex, max_window_tex) -overlay_texture_texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, 300, 300) -SDL_SetTextureBlendMode(overlay_texture_texture, SDL_BLENDMODE_BLEND) -SDL_SetRenderTarget(renderer, overlay_texture_texture) -SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) -SDL_RenderClear(renderer) -SDL_SetRenderTarget(renderer, None) +overlay_texture_texture = sdl3.SDL_CreateTexture(renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, 300, 300) +sdl3.SDL_SetTextureBlendMode(overlay_texture_texture, sdl3.SDL_BLENDMODE_BLEND) +sdl3.SDL_SetRenderTarget(renderer, overlay_texture_texture) +sdl3.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) +sdl3.SDL_RenderClear(renderer) +sdl3.SDL_SetRenderTarget(renderer, None) -tracklist_texture = SDL_CreateTexture( - renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, max_window_tex, +tracklist_texture = sdl3.SDL_CreateTexture( + renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, max_window_tex, max_window_tex) -tracklist_texture_rect = SDL_Rect(0, 0, max_window_tex, max_window_tex) -SDL_SetTextureBlendMode(tracklist_texture, SDL_BLENDMODE_BLEND) +tracklist_texture_rect = sdl3.SDL_FRect(0, 0, max_window_tex, max_window_tex) +sdl3.SDL_SetTextureBlendMode(tracklist_texture, sdl3.SDL_BLENDMODE_BLEND) -SDL_SetRenderTarget(renderer, None) +sdl3.SDL_SetRenderTarget(renderer, None) # Paint main texture -SDL_SetRenderTarget(renderer, main_texture) -SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255) +sdl3.SDL_SetRenderTarget(renderer, main_texture) +sdl3.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255) -SDL_SetRenderTarget(renderer, main_texture_overlay_temp) -SDL_SetTextureBlendMode(main_texture_overlay_temp, SDL_BLENDMODE_BLEND) -SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255) -SDL_RenderClear(renderer) +sdl3.SDL_SetRenderTarget(renderer, main_texture_overlay_temp) +sdl3.SDL_SetTextureBlendMode(main_texture_overlay_temp, sdl3.SDL_BLENDMODE_BLEND) +sdl3.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255) +sdl3.SDL_RenderClear(renderer) # -# SDL_SetRenderTarget(renderer, None) -# SDL_SetRenderDrawColor(renderer, 7, 7, 7, 255) -# SDL_RenderClear(renderer) -# #SDL_RenderPresent(renderer) +# sdl3.SDL_SetRenderTarget(renderer, None) +# sdl3.SDL_SetRenderDrawColor(renderer, 7, 7, 7, 255) +# sdl3.SDL_RenderClear(renderer) +# #sdl3.SDL_RenderPresent(renderer) # -# SDL_SetWindowOpacity(t_window, window_opacity) +# sdl3.SDL_SetWindowOpacity(t_window, window_opacity) class LoadImageAsset: @@ -834,23 +664,23 @@ def __init__(self, *, scaled_asset_directory: Path, path: str, is_full_path: boo self.scale_name = scale_name self.scaled_asset_directory: Path = scaled_asset_directory - raw_image = IMG_Load(self.path.encode()) - self.sdl_texture = SDL_CreateTextureFromSurface(renderer, raw_image) + raw_image = sdl3.IMG_Load(self.path.encode()) + self.texture = sdl3.SDL_CreateTextureFromSurface(renderer, raw_image) - p_w = pointer(c_int(0)) - p_h = pointer(c_int(0)) - SDL_QueryTexture(self.sdl_texture, None, None, p_w, p_h) + p_w = pointer(c_float(0.0)) + p_h = pointer(c_float(0.0)) + sdl3.SDL_GetTextureSize(self.texture, p_w, p_h) if is_full_path: - SDL_SetTextureAlphaMod(self.sdl_texture, prefs.custom_bg_opacity) + sdl3.SDL_SetTextureAlphaMod(self.texture, prefs.custom_bg_opacity) - self.rect = SDL_Rect(0, 0, p_w.contents.value, p_h.contents.value) - SDL_FreeSurface(raw_image) + self.rect = sdl3.SDL_FRect(0, 0, p_w.contents.value, p_h.contents.value) + sdl3.SDL_DestroySurface(raw_image) self.w = p_w.contents.value self.h = p_h.contents.value def reload(self) -> None: - SDL_DestroyTexture(self.sdl_texture) + sdl3.SDL_DestroyTexture(self.texture) if self.scale_name: self.path = str(self.scaled_asset_directory / self.scale_name) self.__init__(scaled_asset_directory=scaled_asset_directory, path=self.path, reload=True, scale_name=self.scale_name) @@ -858,7 +688,7 @@ def reload(self) -> None: def render(self, x: int, y: int, colour=None) -> None: self.rect.x = round(x) self.rect.y = round(y) - SDL_RenderCopy(renderer, self.sdl_texture, None, self.rect) + sdl3.SDL_RenderTexture(renderer, self.texture, None, self.rect) class WhiteModImageAsset: @@ -871,31 +701,31 @@ def __init__(self, *, scaled_asset_directory: Path, path: str, reload: bool = Fa self.scale_name = scale_name self.scaled_asset_directory: Path = scaled_asset_directory - raw_image = IMG_Load(path.encode()) - self.sdl_texture = SDL_CreateTextureFromSurface(renderer, raw_image) + raw_image = sdl3.IMG_Load(path.encode()) + self.texture = sdl3.SDL_CreateTextureFromSurface(renderer, raw_image) self.colour = [255, 255, 255, 255] - p_w = pointer(c_int(0)) - p_h = pointer(c_int(0)) - SDL_QueryTexture(self.sdl_texture, None, None, p_w, p_h) - self.rect = SDL_Rect(0, 0, p_w.contents.value, p_h.contents.value) - SDL_FreeSurface(raw_image) + p_w = pointer(c_float(0.0)) + p_h = pointer(c_float(0.0)) + sdl3.SDL_GetTextureSize(self.texture, p_w, p_h) + self.rect = sdl3.SDL_FRect(0, 0, p_w.contents.value, p_h.contents.value) + sdl3.SDL_DestroySurface(raw_image) self.w = p_w.contents.value self.h = p_h.contents.value def reload(self) -> None: - SDL_DestroyTexture(self.sdl_texture) + sdl3.SDL_DestroyTexture(self.texture) if self.scale_name: self.path = str(self.scaled_asset_directory / self.scale_name) self.__init__(scaled_asset_directory=scaled_asset_directory, path=self.path, reload=True, scale_name=self.scale_name) def render(self, x: int, y: int, colour) -> None: if colour != self.colour: - SDL_SetTextureColorMod(self.sdl_texture, colour[0], colour[1], colour[2]) - SDL_SetTextureAlphaMod(self.sdl_texture, colour[3]) + sdl3.SDL_SetTextureColorMod(self.texture, colour[0], colour[1], colour[2]) + sdl3.SDL_SetTextureAlphaMod(self.texture, colour[3]) self.colour = colour self.rect.x = round(x) self.rect.y = round(y) - SDL_RenderCopy(renderer, self.sdl_texture, None, self.rect) + sdl3.SDL_RenderTexture(renderer, self.texture, None, self.rect) loaded_asset_dc: dict[str, WhiteModImageAsset | LoadImageAsset] = {} @@ -923,16 +753,16 @@ def asset_loader( i_y = pointer(c_int(0)) time.sleep(0.02) - SDL_PumpEvents() - SDL_GetWindowSize(t_window, i_x, i_y) + sdl3.SDL_PumpEvents() + sdl3.SDL_GetWindowSize(t_window, i_x, i_y) logical_size[0] = i_x.contents.value logical_size[1] = i_y.contents.value - SDL_GL_GetDrawableSize(t_window, i_x, i_y) + sdl3.SDL_GL_GetDrawableSize(t_window, i_x, i_y) window_size[0] = i_x.contents.value window_size[1] = i_y.contents.value # loading_image.render(window_size[0] // 2 - loading_image.w // 2, window_size[1] // 2 - loading_image.h // 2) -# SDL_RenderPresent(renderer) +# sdl3.SDL_RenderPresent(renderer) if install_directory != config_directory and not (config_directory / "input.txt").is_file(): logging.warning("Input config file is missing, first run? Copying input.txt template from templates directory") @@ -975,7 +805,7 @@ def no_padding() -> int: return 0 wayland = True -if os.environ.get("SDL_VIDEODRIVER") != "wayland": +if os.environ.get("sdl3.SDL_VIDEODRIVER") != "wayland": wayland = False os.environ["GDK_BACKEND"] = "x11" @@ -1349,32 +1179,32 @@ def delay_frame(self, t): gui.frame_callback_list.append(TestTimer(t)) def destroy_textures(self): - SDL_DestroyTexture(self.spec4_tex) - SDL_DestroyTexture(self.spec1_tex) - SDL_DestroyTexture(self.spec2_tex) - SDL_DestroyTexture(self.spec_level_tex) + sdl3.SDL_DestroyTexture(self.spec4_tex) + sdl3.SDL_DestroyTexture(self.spec1_tex) + sdl3.SDL_DestroyTexture(self.spec2_tex) + sdl3.SDL_DestroyTexture(self.spec_level_tex) # def test_text_input(self): # if self.text_input_request and not self.text_input_active: - # SDL_StartTextInput() + # sdl3.SDL_StartTextInput() # self.update += 1 # if not self.text_input_request and self.text_input_active: - # SDL_StopTextInput() + # sdl3.SDL_StopTextInput() # self.text_input_request = False def rescale(self): self.spec_y = int(round(5 * self.scale)) self.spec_w = int(round(80 * self.scale)) self.spec_h = int(round(20 * self.scale)) - self.spec1_rec = SDL_Rect(0, self.spec_y, self.spec_w, self.spec_h) + self.spec1_rec = sdl3.SDL_FRect(0, self.spec_y, self.spec_w, self.spec_h) self.spec4_y = int(round(200 * self.scale)) self.spec4_w = int(round(322 * self.scale)) self.spec4_h = int(round(100 * self.scale)) - self.spec4_rec = SDL_Rect(0, self.spec4_y, self.spec4_w, self.spec4_h) + self.spec4_rec = sdl3.SDL_FRect(0, self.spec4_y, self.spec4_w, self.spec4_h) - self.bar = SDL_Rect(10, 10, round(3 * self.scale), 10) # spec bar bin - self.bar4 = SDL_Rect(10, 10, round(3 * self.scale), 10) # spec bar bin + self.bar = sdl3.SDL_FRect(10, 10, round(3 * self.scale), 10) # spec bar bin + self.bar4 = sdl3.SDL_FRect(10, 10, round(3 * self.scale), 10) # spec bar bin self.set_height = round(25 * self.scale) self.panelBY = round(51 * self.scale) self.panelY = round(30 * self.scale) @@ -1388,9 +1218,9 @@ def rescale(self): self.spec2 = [0] * self.spec2_y self.spec2_phase = 0 self.spec2_buffers = [] - self.spec2_rec = SDL_Rect(1230, round(4 * self.scale), self.spec2_w, self.spec2_y) - self.spec2_source = SDL_Rect(900, round(4 * self.scale), self.spec2_w, self.spec2_y) - self.spec2_dest = SDL_Rect(900, round(4 * self.scale), self.spec2_w, self.spec2_y) + self.spec2_rec = sdl3.SDL_FRect(1230, round(4 * self.scale), self.spec2_w, self.spec2_y) + self.spec2_source = sdl3.SDL_FRect(900, round(4 * self.scale), self.spec2_w, self.spec2_y) + self.spec2_dest = sdl3.SDL_FRect(900, round(4 * self.scale), self.spec2_w, self.spec2_y) self.spec2_position = 0 self.spec2_timer = Timer() self.spec2_timer.set() @@ -1400,18 +1230,18 @@ def rescale(self): self.level_s = 1 * self.scale self.level_ww = round(79 * self.scale) self.level_hh = round(18 * self.scale) - self.spec_level_rec = SDL_Rect( + self.spec_level_rec = sdl3.SDL_FRect( 0, round(self.level_y - 10 * self.scale), round(self.level_ww),round(self.level_hh)) - self.spec2_tex = SDL_CreateTexture( - renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, self.spec2_w, self.spec2_y) - self.spec4_tex = SDL_CreateTexture( - renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, self.spec4_w, self.spec4_y) - self.spec1_tex = SDL_CreateTexture( - renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, self.spec_w, self.spec_h) - self.spec_level_tex = SDL_CreateTexture( - renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, self.level_ww, self.level_hh) - SDL_SetTextureBlendMode(self.spec4_tex, SDL_BLENDMODE_BLEND) + self.spec2_tex = sdl3.SDL_CreateTexture( + renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, self.spec2_w, self.spec2_y) + self.spec4_tex = sdl3.SDL_CreateTexture( + renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, self.spec4_w, self.spec4_y) + self.spec1_tex = sdl3.SDL_CreateTexture( + renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, self.spec_w, self.spec_h) + self.spec_level_tex = sdl3.SDL_CreateTexture( + renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, self.level_ww, self.level_hh) + sdl3.SDL_SetTextureBlendMode(self.spec4_tex, sdl3.SDL_BLENDMODE_BLEND) self.artist_panel_height = 320 * self.scale self.last_artist_panel_height = self.artist_panel_height @@ -2076,9 +1906,9 @@ def load(self): key = items[1] else: if prefs.use_scancodes: - key = SDL_GetScancodeFromName(items[1].encode()) + key = sdl3.SDL_GetScancodeFromName(items[1].encode()) else: - key = SDL_GetKeyFromName(items[1].encode()) + key = sdl3.SDL_GetKeyFromName(items[1].encode()) if key == 0: continue @@ -2476,7 +2306,7 @@ def light_mode(self): def set_colour(colour): - SDL_SetRenderDrawColor(renderer, colour[0], colour[1], colour[2], colour[3]) + sdl3.SDL_SetRenderDrawColor(renderer, colour[0], colour[1], colour[2], colour[3]) def get_themes(deco: bool = False): @@ -2627,8 +2457,6 @@ def show_message(line1: str, line2: str ="", line3: str = "", mode: str = "info" # ----------------------------------------------------- # STATE LOADING # Loading of program data from previous run -gbc.disable() -ggc = 2 star_path1 = user_directory / "star.p" star_path2 = user_directory / "star.p.backup" @@ -2723,7 +2551,7 @@ def pumper(): return while pump: time.sleep(0.005) - SDL_PumpEvents() + sdl3.SDL_PumpEvents() shoot_pump = threading.Thread(target=pumper) @@ -3870,11 +3698,11 @@ def load_prefs(): # ---- -sss = SDL_SysWMinfo() -SDL_GetWindowWMInfo(t_window, sss) +# sss = sdl3.SDL_SysWMinfo() # removed in sdl3 +# sdl3.SDL_GetWindowWMInfo(t_window, sss) if prefs.use_gamepad: - SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) + sdl3.SDL_InitSubSystem(sdl3.SDL_INIT_GAMEPAD) smtc = False @@ -3913,16 +3741,19 @@ def auto_scale() -> None: old = prefs.scale_want - if prefs.x_scale: - if sss.subsystem in (SDL_SYSWM_WAYLAND, SDL_SYSWM_COCOA, SDL_SYSWM_UNKNOWN): - prefs.scale_want = window_size[0] / logical_size[0] - if old != prefs.scale_want: - logging.info("Applying scale based on buffer size") - elif sss.subsystem == SDL_SYSWM_X11: - if xdpi > 40: - prefs.scale_want = xdpi / 96 - if old != prefs.scale_want: - logging.info("Applying scale based on xft setting") + prefs.scale_want = window_size[0] / logical_size[0] + if old != prefs.scale_want: + logging.info("Applying scale based on buffer size") + # if prefs.x_scale: + # if sss.subsystem in (sdl3.SDL_SYSWM_WAYLAND, sdl3.SDL_SYSWM_COCOA, sdl3.SDL_SYSWM_UNKNOWN): + # prefs.scale_want = window_size[0] / logical_size[0] + # if old != prefs.scale_want: + # logging.info("Applying scale based on buffer size") + # elif sss.subsystem == sdl3.SDL_SYSWM_X11: + # if xdpi > 40: + # prefs.scale_want = xdpi / 96 + # if old != prefs.scale_want: + # logging.info("Applying scale based on xft setting") prefs.scale_want = round(round(prefs.scale_want / 0.05) * 0.05, 2) @@ -4028,14 +3859,14 @@ def scale_assets(scale_want: int, force: bool = False) -> None: def get_global_mouse(): i_y = pointer(c_int(0)) i_x = pointer(c_int(0)) - SDL_GetGlobalMouseState(i_x, i_y) + sdl3.SDL_GetGlobalMouseState(i_x, i_y) return i_x.contents.value, i_y.contents.value def get_window_position(): i_y = pointer(c_int(0)) i_x = pointer(c_int(0)) - SDL_GetWindowPosition(t_window, i_x, i_y) + sdl3.SDL_GetWindowPosition(t_window, i_x, i_y) return i_x.contents.value, i_y.contents.value @@ -6596,11 +6427,11 @@ def update_title_do() -> None: pctl.master_library[pctl.track_queue[pctl.queue_step]].title # line += " : : Tauon Music Box" line = line.encode("utf-8") - SDL_SetWindowTitle(t_window, line) + sdl3.SDL_SetWindowTitle(t_window, line) else: line = "Tauon Music Box" line = line.encode("utf-8") - SDL_SetWindowTitle(t_window, line) + sdl3.SDL_SetWindowTitle(t_window, line) def open_encode_out() -> None: @@ -8430,7 +8261,7 @@ def worker_render(self): if search_over.active: while QuickThumbnail.queue: img = QuickThumbnail.queue.pop(0) - response = urllib.request.urlopen(img.url, context=ssl_context) + response = urllib.request.urlopen(img.url, cafile=tauon.ca) source_image = io.BytesIO(response.read()) img.read_and_thumbnail(source_image, img.size, img.size) source_image.close() @@ -8569,6 +8400,7 @@ def worker_render(self): return False def render(self, track: TrackClass, location, size=None, force_offset=None) -> bool | None: + if gallery_load_delay.get() < 0.5: return None @@ -8608,14 +8440,13 @@ def render(self, track: TrackClass, location, size=None, force_offset=None) -> b if order[0] == 2: # finish processing - wop = rw_from_object(order[1]) - s_image = IMG_Load_RW(wop, 0) - c = SDL_CreateTextureFromSurface(renderer, s_image) - SDL_FreeSurface(s_image) - tex_w = pointer(c_int(size)) - tex_h = pointer(c_int(size)) - SDL_QueryTexture(c, None, None, tex_w, tex_h) - dst = SDL_Rect(x, y) + s_image = ddt.load_image(order[1]) + c = sdl3.SDL_CreateTextureFromSurface(renderer, s_image) + sdl3.SDL_DestroySurface(s_image) + tex_w = pointer(c_float(0)) + tex_h = pointer(c_float(0)) + sdl3.SDL_GetTextureSize(c, tex_w, tex_h) + dst = sdl3.SDL_FRect(x, y) dst.w = int(tex_w.contents.value) dst.h = int(tex_h.contents.value) @@ -8634,7 +8465,7 @@ def render(self, track: TrackClass, location, size=None, force_offset=None) -> b order[3].y = y order[3].x = int((size - order[3].w) / 2) + order[3].x order[3].y = int((size - order[3].h) / 2) + order[3].y - SDL_RenderCopy(renderer, order[2], None, order[3]) + sdl3.SDL_RenderTexture(renderer, order[2], None, order[3]) if (track, size, offset) in self.key_list: self.key_list.remove((track, size, offset)) @@ -8647,13 +8478,14 @@ def render(self, track: TrackClass, location, size=None, force_offset=None) -> b # while key in self.queue: # self.queue.remove(key) if self.gall[key][2] is not None: - SDL_DestroyTexture(self.gall[key][2]) + sdl3.SDL_DestroyTexture(self.gall[key][2]) del self.gall[key] del self.key_list[0] return True else: + if key not in self.queue: self.queue.append(key) if self.lock.locked(): @@ -8666,13 +8498,15 @@ def render(self, track: TrackClass, location, size=None, force_offset=None) -> b logging.exception("Unknown RuntimeError trying to release lock") except Exception: logging.exception("Unknown error trying to release lock") + return False class ThumbTracks: - def __init__(self) -> None: + def __init__(self): pass def path(self, track: TrackClass) -> str: + source, offset = tauon.gall_ren.get_file_source(track) if source is False: # No art @@ -8688,12 +8522,13 @@ def path(self, track: TrackClass) -> str: source_image = album_art_gen.get_source_raw(0, 0, track, subsource=source) - with Image.open(source_image) as im: - if im.mode != "RGB": - im = im.convert("RGB") - im.thumbnail((1000, 1000), Image.Resampling.LANCZOS) - im.save(t_path, "JPEG") - source_image.close() + im = Image.open(source_image) + if im.mode != "RGB": + im = im.convert("RGB") + im.thumbnail((1000, 1000), Image.Resampling.LANCZOS) + + im.save(t_path, "JPEG") + return t_path class Tauon: @@ -8709,7 +8544,7 @@ def __init__(self): # TODO(Martin) : Fix this by moving the class to root of the module self.cachement: player4.Cachement | None = None - self.dummy_event: SDL_Event = SDL_Event() + self.dummy_event: SDL_Event = sdl3.SDL_Event() self.translate = _ self.strings: Strings = strings self.pctl: PlayerCtl = pctl @@ -8904,24 +8739,24 @@ def exit(self, reason: str) -> None: self.wake() def min_to_tray(self) -> None: - SDL_HideWindow(t_window) + sdl3.SDL_HideWindow(t_window) gui.mouse_unknown = True def raise_window(self) -> None: - SDL_ShowWindow(t_window) - SDL_RaiseWindow(t_window) - SDL_RestoreWindow(t_window) + sdl3.SDL_ShowWindow(t_window) + sdl3.SDL_RaiseWindow(t_window) + sdl3.SDL_RestoreWindow(t_window) gui.lowered = False gui.update += 1 def focus_window(self) -> None: - SDL_RaiseWindow(t_window) + sdl3.SDL_RaiseWindow(t_window) def get_playing_playlist_id(self) -> int: return pl_to_id(pctl.active_playlist_playing) def wake(self) -> None: - SDL_PushEvent(ctypes.byref(self.dummy_event)) + sdl3.SDL_PushEvent(ctypes.byref(self.dummy_event)) tauon = Tauon() @@ -9904,14 +9739,14 @@ def __init__(self) -> None: self.active = False def up(self, systray: SysTrayIcon): - SDL_ShowWindow(t_window) - SDL_RaiseWindow(t_window) - SDL_RestoreWindow(t_window) + sdl3.SDL_ShowWindow(t_window) + sdl3.SDL_RaiseWindow(t_window) + sdl3.SDL_RestoreWindow(t_window) gui.lowered = False def down(self) -> None: if self.active: - SDL_HideWindow(t_window) + sdl3.SDL_HideWindow(t_window) def advance(self, systray: SysTrayIcon) -> None: pctl.advance() @@ -10157,13 +9992,13 @@ def do_maximize_button() -> None: global drag_mode if gui.fullscreen: gui.fullscreen = False - SDL_SetWindowFullscreen(t_window, 0) + sdl3.SDL_SetWindowFullscreen(t_window, 0) elif gui.maximized: gui.maximized = False - SDL_RestoreWindow(t_window) + sdl3.SDL_RestoreWindow(t_window) else: gui.maximized = True - SDL_MaximizeWindow(t_window) + sdl3.SDL_MaximizeWindow(t_window) mouse_down = False inp.mouse_click = False @@ -10176,11 +10011,11 @@ def do_minimize_button(): global drag_mode if macos: # hack - SDL_SetWindowBordered(t_window, True) - SDL_MinimizeWindow(t_window) - SDL_SetWindowBordered(t_window, False) + sdl3.SDL_SetWindowBordered(t_window, True) + sdl3.SDL_MinimizeWindow(t_window) + sdl3.SDL_SetWindowBordered(t_window, False) else: - SDL_MinimizeWindow(t_window) + sdl3.SDL_MinimizeWindow(t_window) mouse_down = False inp.mouse_click = False @@ -10419,10 +10254,10 @@ def draw_window_border(): # ------------------------------------------------------------------------------------------- # initiate SDL2 --------------------------------------------------------------------C-IS----- -cursor_hand = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND) -cursor_standard = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW) -cursor_shift = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE) -cursor_text = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM) +cursor_hand = sdl3.SDL_CreateSystemCursor(sdl3.SDL_SYSTEM_CURSOR_POINTER) +cursor_standard = sdl3.SDL_CreateSystemCursor(sdl3.SDL_SYSTEM_CURSOR_DEFAULT) +cursor_shift = sdl3.SDL_CreateSystemCursor(sdl3.SDL_SYSTEM_CURSOR_EW_RESIZE) +cursor_text = sdl3.SDL_CreateSystemCursor(sdl3.SDL_SYSTEM_CURSOR_TEXT) cursor_br_corner = cursor_standard cursor_right_side = cursor_standard @@ -10431,10 +10266,10 @@ def draw_window_border(): cursor_bottom_side = cursor_standard if msys: - cursor_br_corner = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE) + cursor_br_corner = sdl3.SDL_CreateSystemCursor(sdl3.SDL_SYSTEM_CURSOR_NWSE_RESIZE) cursor_right_side = cursor_shift cursor_left_side = cursor_shift - cursor_top_side = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS) + cursor_top_side = sdl3.SDL_CreateSystemCursor(sdl3.SDL_SYSTEM_CURSOR_NS_RESIZE) cursor_bottom_side = cursor_top_side elif not msys and system == "Linux" and "XCURSOR_THEME" in os.environ and "XCURSOR_SIZE" in os.environ: try: @@ -10465,10 +10300,11 @@ def get_xcursor(name: str): xcursor_theme = os.environ["XCURSOR_THEME"] xcursor_size = os.environ["XCURSOR_SIZE"] c1 = xcu.XcursorLibraryLoadImage(c_char_p(name.encode()), c_char_p(xcursor_theme.encode()), c_int(int(xcursor_size))).contents - sdl_surface = SDL_CreateRGBSurfaceWithFormatFrom(c1.pixels, c1.width, c1.height, 32, c1.width * 4, SDL_PIXELFORMAT_ARGB8888) - cursor = SDL_CreateColorCursor(sdl_surface, round(c1.xhot), round(c1.yhot)) + #sdl3.SDL_surface = sdl3.SDL_CreateRGBSurfaceWithFormatFrom(c1.pixels, c1.width, c1.height, 32, c1.width * 4, sdl3.SDL_PIXELFORMAT_ARGB8888) + sdl3.SDL_surface = sdl3.SDL_CreateSurfaceFrom(c1.width, c1.height, sdl3.SDL_PIXELFORMAT_ARGB8888, c1.pixels, c1.width * 4) + cursor = sdl3.SDL_CreateColorCursor(sdl3.SDL_surface, round(c1.xhot), round(c1.yhot)) xcu.XcursorImageDestroy(ctypes.byref(c1)) - SDL_FreeSurface(sdl_surface) + sdl3.SDL_DestroySurface(sdl3.SDL_surface) return cursor cursor_br_corner = get_xcursor("se-resize") @@ -10477,58 +10313,58 @@ def get_xcursor(name: str): cursor_left_side = get_xcursor("left_side") cursor_bottom_side = get_xcursor("bottom_side") - if SDL_GetCurrentVideoDriver() == b"wayland": + if sdl3.SDL_GetCurrentVideoDriver() == b"wayland": cursor_standard = get_xcursor("left_ptr") cursor_text = get_xcursor("xterm") cursor_shift = get_xcursor("sb_h_double_arrow") cursor_hand = get_xcursor("hand2") - SDL_SetCursor(cursor_standard) + sdl3.SDL_SetCursor(cursor_standard) except Exception: logging.exception("Error loading xcursor") if not maximized and gui.maximized: - SDL_MaximizeWindow(t_window) + sdl3.SDL_MaximizeWindow(t_window) -# logging.error(SDL_GetError()) +# logging.error(sdl3.SDL_GetError()) -# t_window = SDL_CreateShapedWindow( +# t_window = sdl3.SDL_CreateShapedWindow( # window_title, -# SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, +# sdl3.SDL_WINDOWPOS_CENTERED, sdl3.SDL_WINDOWPOS_CENTERED, # window_size[0], window_size[1], # flags) -# logging.error(SDL_GetError()) +# logging.error(sdl3.SDL_GetError()) if system == "Windows" or msys: gui.window_id = sss.info.win.window # try: -# SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, b"1") +# sdl3.SDL_SetHint(sdl3.SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, b"1") # # except Exception: # logging.exception("old version of SDL detected") # get window surface and set up renderer -# renderer = SDL_CreateRenderer(t_window, 0, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC) +# renderer = sdl3.SDL_CreateRenderer(t_window, 0, sdl3.SDL_RENDERER_ACCELERATED | sdl3.SDL_RENDERER_PRESENTVSYNC) -# renderer = SDL_CreateRenderer(t_window, 0, SDL_RENDERER_ACCELERATED) +# renderer = sdl3.SDL_CreateRenderer(t_window, 0, sdl3.SDL_RENDERER_ACCELERATED) # -# # window_surface = SDL_GetWindowSurface(t_window) +# # window_surface = sdl3.SDL_GetWindowSurface(t_window) # -# SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND) +# sdl3.SDL_SetRenderDrawBlendMode(renderer, sdl3.SDL_BLENDMODE_BLEND) # -# display_index = SDL_GetWindowDisplayIndex(t_window) -# display_bounds = SDL_Rect(0, 0) -# SDL_GetDisplayBounds(display_index, display_bounds) +# display_index = sdl3.SDL_GetWindowDisplayIndex(t_window) +# display_bounds = sdl3.SDL_FRect(0, 0) +# sdl3.SDL_GetDisplayBounds(display_index, display_bounds) # -# icon = IMG_Load(os.path.join(asset_directory, "icon-64.png").encode()) -# SDL_SetWindowIcon(t_window, icon) -# SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best".encode()) +# icon = sdl3.IMG_Load(os.path.join(asset_directory, "icon-64.png").encode()) +# sdl3.SDL_SetWindowIcon(t_window, icon) +# sdl3.SDL_SetHint(sdl3.SDL_HINT_RENDER_SCALE_QUALITY, "best".encode()) # -# SDL_SetWindowMinimumSize(t_window, round(560 * gui.scale), round(330 * gui.scale)) +# sdl3.SDL_SetWindowMinimumSize(t_window, round(560 * gui.scale), round(330 * gui.scale)) # # # gui.max_window_tex = 1000 @@ -10539,42 +10375,42 @@ def get_xcursor(name: str): # while window_size[1] > gui.max_window_tex: # gui.max_window_tex += 1000 # -# gui.ttext = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, gui.max_window_tex, gui.max_window_tex) +# gui.ttext = sdl3.SDL_CreateTexture(renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, gui.max_window_tex, gui.max_window_tex) # -# # gui.pl_surf = SDL_CreateRGBSurfaceWithFormat(0, gui.max_window_tex, gui.max_window_tex, 32, SDL_PIXELFORMAT_RGB888) +# # gui.pl_surf = sdl3.SDL_CreateRGBSurfaceWithFormat(0, gui.max_window_tex, gui.max_window_tex, 32, sdl3.SDL_PIXELFORMAT_RGB888) # -# SDL_SetTextureBlendMode(gui.ttext, SDL_BLENDMODE_BLEND) +# sdl3.SDL_SetTextureBlendMode(gui.ttext, sdl3.SDL_BLENDMODE_BLEND) # -# gui.spec2_tex = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, gui.spec2_w, gui.spec2_y) -# gui.spec1_tex = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, gui.spec_w, gui.spec_h) -# gui.spec4_tex = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, gui.spec4_w, gui.spec4_h) -# gui.spec_level_tex = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, gui.level_ww, gui.level_hh) +# gui.spec2_tex = sdl3.SDL_CreateTexture(renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, gui.spec2_w, gui.spec2_y) +# gui.spec1_tex = sdl3.SDL_CreateTexture(renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, gui.spec_w, gui.spec_h) +# gui.spec4_tex = sdl3.SDL_CreateTexture(renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, gui.spec4_w, gui.spec4_h) +# gui.spec_level_tex = sdl3.SDL_CreateTexture(renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, gui.level_ww, gui.level_hh) # -# SDL_SetTextureBlendMode(gui.spec4_tex, SDL_BLENDMODE_BLEND) +# sdl3.SDL_SetTextureBlendMode(gui.spec4_tex, sdl3.SDL_BLENDMODE_BLEND) # -# SDL_SetRenderTarget(renderer, None) +# sdl3.SDL_SetRenderTarget(renderer, None) # -# gui.main_texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, gui.max_window_tex, gui.max_window_tex) -# gui.main_texture_overlay_temp = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, gui.max_window_tex, gui.max_window_tex) +# gui.main_texture = sdl3.SDL_CreateTexture(renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, gui.max_window_tex, gui.max_window_tex) +# gui.main_texture_overlay_temp = sdl3.SDL_CreateTexture(renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, gui.max_window_tex, gui.max_window_tex) # -# SDL_SetRenderTarget(renderer, gui.main_texture) -# SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255) +# sdl3.SDL_SetRenderTarget(renderer, gui.main_texture) +# sdl3.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255) # -# SDL_SetRenderTarget(renderer, gui.main_texture_overlay_temp) -# SDL_SetTextureBlendMode(gui.main_texture_overlay_temp, SDL_BLENDMODE_BLEND) -# SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255) +# sdl3.SDL_SetRenderTarget(renderer, gui.main_texture_overlay_temp) +# sdl3.SDL_SetTextureBlendMode(gui.main_texture_overlay_temp, sdl3.SDL_BLENDMODE_BLEND) +# sdl3.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255) # -# SDL_RenderClear(renderer) +# sdl3.SDL_RenderClear(renderer) # -# gui.abc = SDL_Rect(0, 0, gui.max_window_tex, gui.max_window_tex) +# gui.abc = sdl3.SDL_FRect(0, 0, gui.max_window_tex, gui.max_window_tex) # gui.pl_update = 2 # -# SDL_SetWindowOpacity(t_window, prefs.window_opacity) +# sdl3.SDL_SetWindowOpacity(t_window, prefs.window_opacity) -# gui.spec1_tex = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, gui.spec_w, gui.spec_h) -# gui.spec4_tex = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, gui.spec4_w, gui.spec4_h) -# gui.spec_level_tex = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, gui.level_ww, gui.level_hh) -# SDL_SetTextureBlendMode(gui.spec4_tex, SDL_BLENDMODE_BLEND) +# gui.spec1_tex = sdl3.SDL_CreateTexture(renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, gui.spec_w, gui.spec_h) +# gui.spec4_tex = sdl3.SDL_CreateTexture(renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, gui.spec4_w, gui.spec4_h) +# gui.spec_level_tex = sdl3.SDL_CreateTexture(renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, gui.level_ww, gui.level_hh) +# sdl3.SDL_SetTextureBlendMode(gui.spec4_tex, sdl3.SDL_BLENDMODE_BLEND) def bass_player_thread(player): @@ -10881,8 +10717,8 @@ def prepare(self, w, h): fw = w + self.underscan im = Image.new("RGBA", (round(fw), round(fh)), 0x00000000) - draw = ImageDraw.Draw(im) - draw.rectangle(((self.underscan, self.underscan), (w + 2, h + 2)), fill="black") + d = ImageDraw.Draw(im) + d.rectangle(((self.underscan, self.underscan), (w + 2, h + 2)), fill="black") im = im.filter(ImageFilter.GaussianBlur(self.radius)) @@ -10891,20 +10727,21 @@ def prepare(self, w, h): im.save(g, "PNG") g.seek(0) - wop = rw_from_object(g) - s_image = IMG_Load_RW(wop, 0) - c = SDL_CreateTextureFromSurface(renderer, s_image) - SDL_SetTextureAlphaMod(c, self.opacity) - tex_w = pointer(c_int(0)) - tex_h = pointer(c_int(0)) - SDL_QueryTexture(c, None, None, tex_w, tex_h) + s_image = ddt.load_image(g) + + c = sdl3.SDL_CreateTextureFromSurface(renderer, s_image) + sdl3.SDL_SetTextureAlphaMod(c, self.opacity) - dst = SDL_Rect(0, 0) + tex_w = pointer(c_float(0)) + tex_h = pointer(c_float(0)) + sdl3.SDL_GetTextureSize(c, tex_w, tex_h) + + dst = sdl3.SDL_FRect(0, 0) dst.w = int(tex_w.contents.value) dst.h = int(tex_h.contents.value) - SDL_FreeSurface(s_image) + sdl3.SDL_DestroySurface(s_image) g.close() im.close() @@ -10918,7 +10755,7 @@ def render(self, x, y, w, h): unit = self.readys[(w, h)] unit[0].x = round(x) - round(self.underscan) unit[0].y = round(y) - round(self.underscan) - SDL_RenderCopy(renderer, unit[1], None, unit[0]) + sdl3.SDL_RenderTexture(renderer, unit[1], None, unit[0]) drop_shadow = DropShadow() @@ -11306,11 +11143,11 @@ def link_activate(x, y, link_pa, click=None): track_box = True -text_box_canvas_rect = SDL_Rect(0, 0, round(2000 * gui.scale), round(40 * gui.scale)) -text_box_canvas_hide_rect = SDL_Rect(0, 0, round(2000 * gui.scale), round(40 * gui.scale)) -text_box_canvas = SDL_CreateTexture( - renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, text_box_canvas_rect.w, text_box_canvas_rect.h) -SDL_SetTextureBlendMode(text_box_canvas, SDL_BLENDMODE_BLEND) +text_box_canvas_rect = sdl3.SDL_FRect(0, 0, round(2000 * gui.scale), round(40 * gui.scale)) +text_box_canvas_hide_rect = sdl3.SDL_FRect(0, 0, round(2000 * gui.scale), round(40 * gui.scale)) +text_box_canvas = sdl3.SDL_CreateTexture( + renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, round(text_box_canvas_rect.w), round(text_box_canvas_rect.h)) +sdl3.SDL_SetTextureBlendMode(text_box_canvas, sdl3.SDL_BLENDMODE_BLEND) def pixel_to_logical(x): @@ -11330,8 +11167,8 @@ def __init__(self) -> None: def paste(self) -> None: - if SDL_HasClipboardText(): - clip = SDL_GetClipboardText().decode("utf-8") + if sdl3.SDL_HasClipboardText(): + clip = sdl3.SDL_GetClipboardText().decode("utf-8") self.paste_text = clip def copy(self) -> None: @@ -11340,7 +11177,7 @@ def copy(self) -> None: if not text: text = self.text if text != "": - SDL_SetClipboardText(text.encode("utf-8")) + sdl3.SDL_SetClipboardText(text.encode("utf-8")) def set_text(self, text: str) -> None: @@ -11392,15 +11229,15 @@ def draw( # For now, this is set up so where 'width' is set > 0, the cursor position becomes editable, # otherwise it is fixed to end - SDL_SetRenderTarget(renderer, text_box_canvas) - SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE) - SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) + sdl3.SDL_SetRenderTarget(renderer, text_box_canvas) + sdl3.SDL_SetRenderDrawBlendMode(renderer, sdl3.SDL_BLENDMODE_NONE) + sdl3.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) text_box_canvas_rect.x = 0 text_box_canvas_rect.y = 0 - SDL_RenderFillRect(renderer, text_box_canvas_rect) + sdl3.SDL_RenderFillRect(renderer, text_box_canvas_rect) - SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND) + sdl3.SDL_SetRenderDrawBlendMode(renderer, sdl3.SDL_BLENDMODE_BLEND) selection_height *= gui.scale @@ -11526,7 +11363,7 @@ def d(): # Paste via ctrl-v if key_ctrl_down and key_v_press: - clip = SDL_GetClipboardText().decode("utf-8") + clip = sdl3.SDL_GetClipboardText().decode("utf-8") self.eliminate_selection() self.text = self.text[0: len(self.text) - self.cursor_position] + clip + self.text[len( self.text) - self.cursor_position:] @@ -11538,7 +11375,7 @@ def d(): if len(self.get_selection()) > 0: text = self.get_selection() if text != "": - SDL_SetClipboardText(text.encode("utf-8")) + sdl3.SDL_SetClipboardText(text.encode("utf-8")) self.eliminate_selection() if key_ctrl_down and key_a_press: @@ -11710,8 +11547,8 @@ def d(): tw, th = ddt.get_text_wh(editline, font, max_x=2000) ddt.rect((space + round(4 * gui.scale), th + round(2 * gui.scale), ex, round(1 * gui.scale)), [245, 245, 245, 255]) - rect = SDL_Rect(pixel_to_logical(x + space + tw + (5 * gui.scale)), pixel_to_logical(y + th + 4 * gui.scale), 1, 1) - SDL_SetTextInputRect(rect) + rect = sdl3.SDL_FRect(pixel_to_logical(x + space + tw + (5 * gui.scale)), pixel_to_logical(y + th + 4 * gui.scale), 1, 1) + sdl3.SDL_SetTextInputRect(rect) animate_monitor_timer.set() @@ -11719,23 +11556,23 @@ def d(): text_box_canvas_hide_rect.y = 0 # if self.offset: - SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE) + sdl3.SDL_SetRenderDrawBlendMode(renderer, sdl3.SDL_BLENDMODE_NONE) text_box_canvas_hide_rect.w = round(self.offset) - SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) - SDL_RenderFillRect(renderer, text_box_canvas_hide_rect) + sdl3.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) + sdl3.SDL_RenderFillRect(renderer, text_box_canvas_hide_rect) text_box_canvas_hide_rect.w = round(t_len) text_box_canvas_hide_rect.x = round(self.offset + width + round(5 * gui.scale)) - SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) - SDL_RenderFillRect(renderer, text_box_canvas_hide_rect) + sdl3.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) + sdl3.SDL_RenderFillRect(renderer, text_box_canvas_hide_rect) - SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND) - SDL_SetRenderTarget(renderer, gui.main_texture) + sdl3.SDL_SetRenderDrawBlendMode(renderer, sdl3.SDL_BLENDMODE_BLEND) + sdl3.SDL_SetRenderTarget(renderer, gui.main_texture) text_box_canvas_rect.x = round(x) text_box_canvas_rect.y = round(y) - SDL_RenderCopy(renderer, text_box_canvas, None, text_box_canvas_rect) + sdl3.SDL_RenderTexture(renderer, text_box_canvas, None, text_box_canvas_rect) class TextBox: @@ -11750,8 +11587,8 @@ def __init__(self) -> None: def paste(self) -> None: - if SDL_HasClipboardText(): - clip = SDL_GetClipboardText().decode("utf-8") + if sdl3.SDL_HasClipboardText(): + clip = sdl3.SDL_GetClipboardText().decode("utf-8") if "http://" in self.text and "http://" in clip: self.text = "" @@ -11769,7 +11606,7 @@ def copy(self) -> None: if not text: text = self.text if text != "": - SDL_SetClipboardText(text.encode("utf-8")) + sdl3.SDL_SetClipboardText(text.encode("utf-8")) def set_text(self, text): @@ -11934,7 +11771,7 @@ def d(): # Paste via ctrl-v if key_ctrl_down and key_v_press: - clip = SDL_GetClipboardText().decode("utf-8") + clip = sdl3.SDL_GetClipboardText().decode("utf-8") self.eliminate_selection() self.text = self.text[0: len(self.text) - self.cursor_position] + clip + self.text[len( self.text) - self.cursor_position:] @@ -11946,7 +11783,7 @@ def d(): if len(self.get_selection()) > 0: text = self.get_selection() if text != "": - SDL_SetClipboardText(text.encode("utf-8")) + sdl3.SDL_SetClipboardText(text.encode("utf-8")) self.eliminate_selection() if key_ctrl_down and key_a_press: @@ -12104,8 +11941,8 @@ def d(): ddt.rect((x + space + round(4 * gui.scale), (y + th) - round(4 * gui.scale), ex, round(1 * gui.scale)), [245, 245, 245, 255]) - rect = SDL_Rect(pixel_to_logical(x + space + tw + 5 * gui.scale), pixel_to_logical(y + th + 4 * gui.scale), 1, 1) - SDL_SetTextInputRect(rect) + rect = sdl3.SDL_FRect(pixel_to_logical(x + space + tw + 5 * gui.scale), pixel_to_logical(y + th + 4 * gui.scale), 1, 1) + sdl3.SDL_SetTextInputRect(rect) animate_monitor_timer.set() @@ -12159,7 +11996,7 @@ def d(): if rename_folder_previous: rename_folder.text = rename_folder_previous -temp_dest = SDL_Rect(0, 0) +temp_dest = sdl3.SDL_FRect(0, 0) def img_slide_update_gall(value, pause: bool = True) -> None: global album_mode_art_size @@ -12195,7 +12032,7 @@ def clear_img_cache(delete_disk: bool = True) -> None: break for key, value in tauon.gall_ren.gall.items(): - SDL_DestroyTexture(value[2]) + sdl3.SDL_DestroyTexture(value[2]) tauon.gall_ren.gall = {} if delete_disk: @@ -12209,7 +12046,7 @@ def clear_img_cache(delete_disk: bool = True) -> None: prefs.failed_artists.clear() for key, value in artist_list_box.thumb_cache.items(): if value: - SDL_DestroyTexture(value[0]) + sdl3.SDL_DestroyTexture(value[0]) artist_list_box.thumb_cache.clear() gui.update += 1 @@ -12234,7 +12071,7 @@ def clear_track_image_cache(track: TrackClass): keys = set() for key, value in tauon.gall_ren.gall.items(): if key[0] == track: - SDL_DestroyTexture(value[2]) + sdl3.SDL_DestroyTexture(value[2]) if key not in keys: keys.add(key) for key in keys: @@ -12443,7 +12280,7 @@ def fast_display(self, index, location, box, source: list[tuple[int, str]], offs temp_dest.y = int((box[1] - temp_dest.h) / 2) + temp_dest.y # render the image - SDL_RenderCopy(renderer, unit.texture, None, temp_dest) + sdl3.SDL_RenderTexture(renderer, unit.texture, None, temp_dest) style_overlay.hole_punches.append(temp_dest) gui.art_drawn_rect = (temp_dest.x, temp_dest.y, temp_dest.w, temp_dest.h) @@ -13183,23 +13020,21 @@ def display(self, track: TrackClass, location, box, fast: bool = False, theme_on g.close() return None - wop = rw_from_object(g) - s_image = IMG_Load_RW(wop, 0) + s_image = ddt.load_image(g) #logging.error(IMG_GetError()) - c = SDL_CreateTextureFromSurface(renderer, s_image) + c = sdl3.SDL_CreateTextureFromSurface(renderer, s_image) - tex_w = pointer(c_int(0)) - tex_h = pointer(c_int(0)) + tex_w = pointer(c_float(0)) + tex_h = pointer(c_float(0)) + sdl3.SDL_GetTextureSize(c, tex_w, tex_h) - SDL_QueryTexture(c, None, None, tex_w, tex_h) - - dst = SDL_Rect(round(location[0]), round(location[1])) + dst = sdl3.SDL_FRect(round(location[0]), round(location[1])) dst.w = int(tex_w.contents.value) dst.h = int(tex_h.contents.value) # Clean uo - SDL_FreeSurface(s_image) + sdl3.SDL_DestroySurface(s_image) source_image.close() g.close() # if close: @@ -13222,7 +13057,7 @@ def display(self, track: TrackClass, location, box, fast: bool = False, theme_on self.render(unit, location) if len(self.image_cache) > 5 or (prefs.colour_from_image and len(self.image_cache) > 1): - SDL_DestroyTexture(self.image_cache[0].texture) + sdl3.SDL_DestroyTexture(self.image_cache[0].texture) del self.image_cache[0] # temp fix @@ -13258,14 +13093,14 @@ def render(self, unit, location) -> None: style_overlay.hole_punches.append(rect) - SDL_RenderCopy(renderer, unit.texture, None, rect) + sdl3.SDL_RenderTexture(renderer, unit.texture, None, rect) gui.art_drawn_rect = (rect.x, rect.y, rect.w, rect.h) def clear_cache(self) -> None: for unit in self.image_cache: - SDL_DestroyTexture(unit.texture) + sdl3.SDL_DestroyTexture(unit.texture) self.image_cache.clear() self.source_cache.clear() @@ -13365,10 +13200,10 @@ def worker(self) -> None: def flush(self): if self.a_texture is not None: - SDL_DestroyTexture(self.a_texture) + sdl3.SDL_DestroyTexture(self.a_texture) self.a_texture = None if self.b_texture is not None: - SDL_DestroyTexture(self.b_texture) + sdl3.SDL_DestroyTexture(self.b_texture) self.b_texture = None self.min_on_timer.force_set(-0.2) self.parent_path = "None" @@ -13386,24 +13221,23 @@ def display(self) -> None: if self.stage == 1: wop = rw_from_object(self.im) - s_image = IMG_Load_RW(wop, 0) - - c = SDL_CreateTextureFromSurface(renderer, s_image) + s_image = sdl3.IMG_Load_RW(wop, 0) - tex_w = pointer(c_int(0)) - tex_h = pointer(c_int(0)) + c = sdl3.SDL_CreateTextureFromSurface(renderer, s_image) - SDL_QueryTexture(c, None, None, tex_w, tex_h) + tex_w = pointer(c_float(0)) + tex_h = pointer(c_float(0)) + sdl3.SDL_GetTextureSize(c, tex_w, tex_h) - dst = SDL_Rect(round(-40, 0)) + dst = sdl3.SDL_FRect(round(-40, 0)) dst.w = int(tex_w.contents.value) dst.h = int(tex_h.contents.value) # Clean uo - SDL_FreeSurface(s_image) + sdl3.SDL_DestroySurface(s_image) self.im.close() - # SDL_SetTextureAlphaMod(c, 10) + # sdl3.SDL_SetTextureAlphaMod(c, 10) self.fade_on_timer.set() if self.a_texture is not None: @@ -13446,9 +13280,9 @@ def display(self) -> None: return t = self.fade_on_timer.get() - SDL_SetRenderTarget(renderer, gui.main_texture_overlay_temp) - SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255) - SDL_RenderClear(renderer) + sdl3.SDL_SetRenderTarget(renderer, gui.main_texture_overlay_temp) + sdl3.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255) + sdl3.SDL_RenderClear(renderer) if self.a_texture is not None: if self.window_size != window_size: @@ -13462,10 +13296,10 @@ def display(self) -> None: if t < 0.4: - SDL_RenderCopy(renderer, self.b_texture, None, self.b_rect) + sdl3.SDL_RenderTexture(renderer, self.b_texture, None, self.b_rect) else: - SDL_DestroyTexture(self.b_texture) + sdl3.SDL_DestroyTexture(self.b_texture) self.b_texture = None self.b_rect = None @@ -13496,8 +13330,8 @@ def display(self) -> None: return if prefs.bg_showcase_only and not (prefs.mini_mode_mode == 5 and gui.mode == 3): - tb = SDL_Rect(0, 0, window_size[0], gui.panelY) - bb = SDL_Rect(0, window_size[1] - gui.panelBY, window_size[0], gui.panelBY) + tb = sdl3.SDL_FRect(0, 0, window_size[0], gui.panelY) + bb = sdl3.SDL_FRect(0, window_size[1] - gui.panelBY, window_size[0], gui.panelBY) self.hole_punches.append(tb) self.hole_punches.append(bb) @@ -13507,31 +13341,31 @@ def display(self) -> None: else: self.a_rect.x = -40 - SDL_SetRenderTarget(renderer, gui.main_texture_overlay_temp) + sdl3.SDL_SetRenderTarget(renderer, gui.main_texture_overlay_temp) - SDL_SetTextureAlphaMod(self.a_texture, fade) - SDL_RenderCopy(renderer, self.a_texture, None, self.a_rect) + sdl3.SDL_SetTextureAlphaMod(self.a_texture, fade) + sdl3.SDL_RenderTexture(renderer, self.a_texture, None, self.a_rect) - SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE) + sdl3.SDL_SetRenderDrawBlendMode(renderer, sdl3.SDL_BLENDMODE_NONE) - SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) + sdl3.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) for rect in self.hole_punches: - SDL_RenderFillRect(renderer, rect) + sdl3.SDL_RenderFillRect(renderer, rect) - SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND) + sdl3.SDL_SetRenderDrawBlendMode(renderer, sdl3.SDL_BLENDMODE_BLEND) - SDL_SetRenderTarget(renderer, gui.main_texture) + sdl3.SDL_SetRenderTarget(renderer, gui.main_texture) opacity = prefs.art_bg_opacity if prefs.mini_mode_mode == 5 and gui.mode == 3: opacity = 255 - SDL_SetTextureAlphaMod(gui.main_texture_overlay_temp, opacity) - SDL_RenderCopy(renderer, gui.main_texture_overlay_temp, None, None) + sdl3.SDL_SetTextureAlphaMod(gui.main_texture_overlay_temp, opacity) + sdl3.SDL_RenderTexture(renderer, gui.main_texture_overlay_temp, None, None) - SDL_SetRenderTarget(renderer, gui.main_texture) + sdl3.SDL_SetRenderTarget(renderer, gui.main_texture) else: - SDL_SetRenderTarget(renderer, gui.main_texture) + sdl3.SDL_SetRenderTarget(renderer, gui.main_texture) style_overlay = StyleOverlay() @@ -15805,7 +15639,7 @@ def toggle_synced_lyrics_deco(track): showcase_menu.add(MenuItem("Toggle synced", toggle_synced_lyrics, toggle_synced_lyrics_deco, pass_ref=True, pass_ref_deco=True)) def paste_lyrics_deco(): - if SDL_HasClipboardText(): + if sdl3.SDL_HasClipboardText(): line_colour = colours.menu_text else: line_colour = colours.menu_text_disabled @@ -15813,8 +15647,8 @@ def paste_lyrics_deco(): return [line_colour, colours.menu_background, None] def paste_lyrics(track_object: TrackClass): - if SDL_HasClipboardText(): - clip = SDL_GetClipboardText() + if sdl3.SDL_HasClipboardText(): + clip = sdl3.SDL_GetClipboardText() #logging.info(clip) track_object.lyrics = clip.decode("utf-8") else: @@ -16384,7 +16218,7 @@ def paste_deco(): line = None if len(cargo) > 0: active = True - elif SDL_HasClipboardText(): + elif sdl3.SDL_HasClipboardText(): text = copy_from_clipboard() if text.startswith(("/", "spotify")) or "file://" in text: active = True @@ -21212,7 +21046,7 @@ def cut_selection(): def clip_ar_al(index: int): line = pctl.master_library[index].artist + " - " + pctl.master_library[index].album - SDL_SetClipboardText(line.encode("utf-8")) + sdl3.SDL_SetClipboardText(line.encode("utf-8")) def clip_ar(index: int): @@ -21220,7 +21054,7 @@ def clip_ar(index: int): line = pctl.master_library[index].album_artist else: line = pctl.master_library[index].artist - SDL_SetClipboardText(line.encode("utf-8")) + sdl3.SDL_SetClipboardText(line.encode("utf-8")) def clip_title(index: int): @@ -21231,7 +21065,7 @@ def clip_title(index: int): else: line = n_track.parent_folder_name - SDL_SetClipboardText(line.encode("utf-8")) + sdl3.SDL_SetClipboardText(line.encode("utf-8")) selection_menu = Menu(200, show_icons=False) @@ -21492,11 +21326,11 @@ def ser_rym(index: int) -> None: def copy_to_clipboard(text: str) -> None: - SDL_SetClipboardText(text.encode(errors="surrogateescape")) + sdl3.SDL_SetClipboardText(text.encode(errors="surrogateescape")) def copy_from_clipboard(): - return SDL_GetClipboardText().decode() + return sdl3.SDL_GetClipboardText().decode() def clip_aar_al(index: int): @@ -21504,7 +21338,7 @@ def clip_aar_al(index: int): line = pctl.master_library[index].artist + " - " + pctl.master_library[index].album else: line = pctl.master_library[index].album_artist + " - " + pctl.master_library[index].album - SDL_SetClipboardText(line.encode("utf-8")) + sdl3.SDL_SetClipboardText(line.encode("utf-8")) def ser_gen_thread(tr): @@ -21569,7 +21403,7 @@ def ser_wiki(index: int) -> None: def clip_ar_tr(index: int) -> None: line = pctl.master_library[index].artist + " - " + pctl.master_library[index].title - SDL_SetClipboardText(line.encode("utf-8")) + sdl3.SDL_SetClipboardText(line.encode("utf-8")) # Copy metadata to clipboard @@ -22278,7 +22112,7 @@ def standard_size(): album_mode = False gui.rsp = True window_size = window_default_size - SDL_SetWindowSize(t_window, logical_size[0], logical_size[1]) + sdl3.SDL_SetWindowSize(t_window, logical_size[0], logical_size[1]) gui.rspw = 80 + int(window_size[0] * 0.18) update_layout = True @@ -27041,7 +26875,7 @@ def toggle_titlebar_line(mode: int = 0) -> bool | None: return update_title line = window_title - SDL_SetWindowTitle(t_window, line) + sdl3.SDL_SetWindowTitle(t_window, line) update_title ^= True if update_title: update_title_do() @@ -27154,9 +26988,9 @@ def toggle_borderless(mode: int = 0) -> bool | None: draw_border ^= True if draw_border: - SDL_SetWindowBordered(t_window, False) + sdl3.SDL_SetWindowBordered(t_window, False) else: - SDL_SetWindowBordered(t_window, True) + sdl3.SDL_SetWindowBordered(t_window, True) return None @@ -29222,7 +29056,7 @@ def last_fm_box(self, x0, y0, w0, h0): # artist_list_box.to_fetch = "" # for key, value in artist_list_box.thumb_cache.items(): # if value: - # SDL_DestroyTexture(value[0]) + # sdl3.SDL_DestroyTexture(value[0]) # artist_list_box.thumb_cache.clear() # artist_list_box.to_fetch = "" # @@ -33628,14 +33462,14 @@ def set_mini_mode(): inp.mouse_click = False if gui.maximized: - SDL_RestoreWindow(t_window) + sdl3.SDL_RestoreWindow(t_window) update_layout_do() if gui.mode < 3: old_window_position = get_window_position() if prefs.mini_mode_on_top: - SDL_SetWindowAlwaysOnTop(t_window, True) + sdl3.SDL_SetWindowAlwaysOnTop(t_window, True) gui.mode = 3 gui.vis = 0 @@ -33645,11 +33479,11 @@ def set_mini_mode(): i_y = pointer(c_int(0)) i_x = pointer(c_int(0)) - SDL_GetWindowPosition(t_window, i_x, i_y) + sdl3.SDL_GetWindowPosition(t_window, i_x, i_y) gui.save_position = (i_x.contents.value, i_y.contents.value) mini_mode.was_borderless = draw_border - SDL_SetWindowBordered(t_window, False) + sdl3.SDL_SetWindowBordered(t_window, False) size = (350, 429) if prefs.mini_mode_mode == 1: @@ -33671,17 +33505,17 @@ def set_mini_mode(): logical_size[0] = size[0] logical_size[1] = size[1] - SDL_SetWindowMinimumSize(t_window, 100, 100) + sdl3.SDL_SetWindowMinimumSize(t_window, 100, 100) - SDL_SetWindowResizable(t_window, False) - SDL_SetWindowSize(t_window, logical_size[0], logical_size[1]) + sdl3.SDL_SetWindowResizable(t_window, False) + sdl3.SDL_SetWindowSize(t_window, logical_size[0], logical_size[1]) if mini_mode.save_position: - SDL_SetWindowPosition(t_window, mini_mode.save_position[0], mini_mode.save_position[1]) + sdl3.SDL_SetWindowPosition(t_window, mini_mode.save_position[0], mini_mode.save_position[1]) i_x = pointer(c_int(0)) i_y = pointer(c_int(0)) - SDL_GL_GetDrawableSize(t_window, i_x, i_y) + sdl3.SDL_GL_GetDrawableSize(t_window, i_x, i_y) window_size[0] = i_x.contents.value window_size[1] = i_y.contents.value @@ -33696,26 +33530,26 @@ def restore_full_mode(): logging.info("RESTORE FULL") i_y = pointer(c_int(0)) i_x = pointer(c_int(0)) - SDL_GetWindowPosition(t_window, i_x, i_y) + sdl3.SDL_GetWindowPosition(t_window, i_x, i_y) mini_mode.save_position = [i_x.contents.value, i_y.contents.value] if not mini_mode.was_borderless: - SDL_SetWindowBordered(t_window, True) + sdl3.SDL_SetWindowBordered(t_window, True) logical_size[0] = gui.save_size[0] logical_size[1] = gui.save_size[1] - SDL_SetWindowPosition(t_window, gui.save_position[0], gui.save_position[1]) + sdl3.SDL_SetWindowPosition(t_window, gui.save_position[0], gui.save_position[1]) - SDL_SetWindowResizable(t_window, True) - SDL_SetWindowSize(t_window, logical_size[0], logical_size[1]) - SDL_SetWindowAlwaysOnTop(t_window, False) + sdl3.SDL_SetWindowResizable(t_window, True) + sdl3.SDL_SetWindowSize(t_window, logical_size[0], logical_size[1]) + sdl3.SDL_SetWindowAlwaysOnTop(t_window, False) # if macos: - # SDL_SetWindowMinimumSize(t_window, 560, 330) + # sdl3.SDL_SetWindowMinimumSize(t_window, 560, 330) # else: - SDL_SetWindowMinimumSize(t_window, 560, 330) + sdl3.SDL_SetWindowMinimumSize(t_window, 560, 330) restore_ignore_timer.set() # Hacky @@ -33728,17 +33562,17 @@ def restore_full_mode(): inp.mouse_click = False if gui.maximized: - SDL_MaximizeWindow(t_window) + sdl3.SDL_MaximizeWindow(t_window) time.sleep(0.05) - SDL_PumpEvents() - SDL_GetWindowSize(t_window, i_x, i_y) + sdl3.SDL_PumpEvents() + sdl3.SDL_GetWindowSize(t_window, i_x, i_y) logical_size[0] = i_x.contents.value logical_size[1] = i_y.contents.value #logging.info(window_size) - SDL_PumpEvents() - SDL_GL_GetDrawableSize(t_window, i_x, i_y) + sdl3.SDL_PumpEvents() + sdl3.SDL_GL_GetDrawableSize(t_window, i_x, i_y) window_size[0] = i_x.contents.value window_size[1] = i_y.contents.value @@ -34088,11 +33922,11 @@ def full_render(self): cv = 0 # update gui.playlist_current_visible_tracks # Draw the background - SDL_SetRenderTarget(renderer, gui.tracklist_texture) - SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) - SDL_RenderClear(renderer) + sdl3.SDL_SetRenderTarget(renderer, gui.tracklist_texture) + sdl3.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) + sdl3.SDL_RenderClear(renderer) - rect = (left, gui.panelY, width, window_size[1]) + rect = (left, gui.panelY, width, window_size[1] - (gui.panelBY + gui.panelY)) ddt.rect(rect, colours.playlist_panel_background) # This draws an optional background image @@ -34119,10 +33953,10 @@ def full_render(self): mx = 3 if gui.playlist_view_length < 10: mx = 2 - pctl.playlist_view_position -= mouse_wheel * mx + pctl.playlist_view_position -= int(mouse_wheel) * mx if gui.playlist_view_length > 40: - pctl.playlist_view_position -= mouse_wheel + pctl.playlist_view_position -= int(mouse_wheel) #if mouse_wheel: #logging.debug("Position changed by mouse wheel scroll: " + str(mouse_wheel)) @@ -35175,8 +35009,8 @@ def full_render(self): 1] - 55 and width + left > mouse_position[0] > gui.playlist_left + 15): playlist_menu.activate() - SDL_SetRenderTarget(renderer, gui.main_texture) - SDL_RenderCopy(renderer, gui.tracklist_texture, None, gui.tracklist_texture_rect) + sdl3.SDL_SetRenderTarget(renderer, gui.main_texture) + sdl3.SDL_RenderTexture(renderer, gui.tracklist_texture, None, gui.tracklist_texture_rect) if mouse_down is False: playlist_hold = False @@ -35186,7 +35020,7 @@ def full_render(self): def cache_render(self): - SDL_RenderCopy(renderer, gui.tracklist_texture, None, gui.tracklist_texture_rect) + sdl3.SDL_RenderTexture(renderer, gui.tracklist_texture, None, gui.tracklist_texture_rect) playlist_render = StandardPlaylist() @@ -35374,8 +35208,8 @@ def draw( self.held = True # p_y = pointer(c_int(0)) - # SDL_GetGlobalMouseState(None, p_y) - get_sdl_input.mouse_capture_want = True + # sdl3.SDL_GetGlobalMouseState(None, p_y) + input_sdl.mouse_capture_want = True self.source_click_y = mouse_position[1] self.source_bar_y = position @@ -35419,7 +35253,7 @@ def draw( self.held = False if self.held: - get_sdl_input.mouse_capture_want = True + input_sdl.mouse_capture_want = True new_y = mouse_position[1] gui.update += 1 @@ -37258,17 +37092,17 @@ def load_img(self, artist): g.seek(0) wop = rw_from_object(g) - s_image = IMG_Load_RW(wop, 0) - texture = SDL_CreateTextureFromSurface(renderer, s_image) - SDL_FreeSurface(s_image) - tex_w = pointer(c_int(0)) - tex_h = pointer(c_int(0)) - SDL_QueryTexture(texture, None, None, tex_w, tex_h) - sdl_rect = SDL_Rect(0, 0) - sdl_rect.w = int(tex_w.contents.value) - sdl_rect.h = int(tex_h.contents.value) - - self.thumb_cache[artist] = [texture, sdl_rect] + s_image = sdl3.IMG_Load_RW(wop, 0) + texture = sdl3.SDL_CreateTextureFromSurface(renderer, s_image) + sdl3.SDL_DestroySurface(s_image) + tex_w = pointer(c_float(0)) + tex_h = pointer(c_float(0)) + sdl3.SDL_GetTextureSize(texture, tex_w, tex_h) + rect = sdl3.SDL_FRect(0, 0) + rect.w = int(tex_w.contents.value) + rect.h = int(tex_h.contents.value) + + self.thumb_cache[artist] = [texture, rect] except Exception: logging.exception("Artist thumbnail processing error") self.thumb_cache[artist] = None @@ -37549,7 +37383,7 @@ def draw_card_with_thumbnail(self, artist, x, y, w, area, thin_mode, line1_colou tab_rect = (x, y - round(2 * gui.scale), round(190 * gui.scale), self.tab_h - round(1 * gui.scale)) for r in subtract_rect(tab_rect, rect): - r = SDL_Rect(r[0], r[1], r[2], r[3]) + r = sdl3.SDL_FRect(r[0], r[1], r[2], r[3]) style_overlay.hole_punches.append(r) ddt.rect(tab_rect, back_colour_2) @@ -37596,10 +37430,10 @@ def draw_card_with_thumbnail(self, artist, x, y, w, area, thin_mode, line1_colou if thumb is not None: thumb[1].x = thumb_x thumb[1].y = round(y) - SDL_RenderCopy(renderer, thumb[0], None, thumb[1]) + sdl3.SDL_RenderTexture(renderer, thumb[0], None, thumb[1]) drawn = True if prefs.art_bg: - rect = SDL_Rect(thumb_x, round(y), self.thumb_size, self.thumb_size) + rect = sdl3.SDL_FRect(thumb_x, round(y), self.thumb_size, self.thumb_size) if (rect.y + rect.h) > window_size[1] - gui.panelBY: diff = (rect.y + rect.h) - (window_size[1] - gui.panelBY) rect.h -= round(diff) @@ -39563,7 +39397,7 @@ def __init__(self): self.image_data = None self.texture = None - self.sdl_rect = None + self.srect = None self.size = (0, 0) def load(self, path, box_size=None): @@ -39592,27 +39426,27 @@ def draw(self, x, y): if self.image_data is not None: if self.texture is not None: - SDL_DestroyTexture(self.texture) + sdl3.SDL_DestroyTexture(self.texture) # Convert raw image to sdl texture #logging.info("Create Texture") wop = rw_from_object(self.image_data) - s_image = IMG_Load_RW(wop, 0) - self.texture = SDL_CreateTextureFromSurface(renderer, s_image) - SDL_FreeSurface(s_image) - tex_w = pointer(c_int(0)) - tex_h = pointer(c_int(0)) - SDL_QueryTexture(self.texture, None, None, tex_w, tex_h) - self.sdl_rect = SDL_Rect(round(x), round(y)) - self.sdl_rect.w = int(tex_w.contents.value) - self.sdl_rect.h = int(tex_h.contents.value) + s_image = sdl3.IMG_Load_RW(wop, 0) + self.texture = sdl3.SDL_CreateTextureFromSurface(renderer, s_image) + sdl3.SDL_DestroySurface(s_image) + tex_w = pointer(c_float(0)) + tex_h = pointer(c_float(0)) + sdl3.SDL_GetTextureSize(self.texture, tex_w, tex_h) + self.srect = sdl3.SDL_FRect(round(x), round(y)) + self.srect.w = int(tex_w.contents.value) + self.srect.h = int(tex_h.contents.value) self.image_data = None if self.texture is not None: - self.sdl_rect.x = round(x) - self.sdl_rect.y = round(y) - SDL_RenderCopy(renderer, self.texture, None, self.sdl_rect) - style_overlay.hole_punches.append(self.sdl_rect) + self.srect.x = round(x) + self.srect.y = round(y) + sdl3.SDL_RenderTexture(renderer, self.texture, None, self.srect) + style_overlay.hole_punches.append(self.srect) artist_picture_render = PictureRender() @@ -39763,8 +39597,8 @@ def draw(self, x, y, w, h): # self.th = th # self.w = w p_off = round(5 * gui.scale) - if artist_picture_render.show and artist_picture_render.sdl_rect: - p_off += artist_picture_render.sdl_rect.w + round(12 * gui.scale) + if artist_picture_render.show and artist_picture_render.srect: + p_off += artist_picture_render.srect.w + round(12 * gui.scale) text_max_w = w - (round(55 * gui.scale) + p_off) @@ -40098,7 +39932,7 @@ def loader(self): im.save(g, "PNG") g.seek(0) wop = rw_from_object(g) - s_image = IMG_Load_RW(wop, 0) + s_image = sdl3.IMG_Load_RW(wop, 0) self.cache[key] = [2, None, None, s_image] gui.update += 1 @@ -40114,21 +39948,21 @@ def draw(self, station, x, y, w): tauon.thread_manager.ready("radio-thumb") return 0 if r[0] == 2: - texture = SDL_CreateTextureFromSurface(renderer, r[3]) - SDL_FreeSurface(r[3]) - tex_w = pointer(c_int(0)) - tex_h = pointer(c_int(0)) - SDL_QueryTexture(texture, None, None, tex_w, tex_h) - sdl_rect = SDL_Rect(0, 0) - sdl_rect.w = int(tex_w.contents.value) - sdl_rect.h = int(tex_h.contents.value) + texture = sdl3.SDL_CreateTextureFromSurface(renderer, r[3]) + sdl3.SDL_DestroySurface(r[3]) + tex_w = pointer(c_float(0)) + tex_h = pointer(c_float(0)) + sdl3.SDL_GetTextureSize(texture, tex_w, tex_h) + rect = sdl3.SDL_FRect(0, 0) + rect.w = int(tex_w.contents.value) + rect.h = int(tex_h.contents.value) r[2] = texture - r[1] = sdl_rect + r[1] = rect r[0] = 1 if r[0] == 1: r[1].x = round(x) r[1].y = round(y) - SDL_RenderCopy(renderer, r[2], None, r[1]) + sdl3.SDL_RenderTexture(renderer, r[2], None, r[1]) return 1 return 0 @@ -40465,7 +40299,7 @@ def render(self): # Draw textured background if not light_mode and not colours.lm and prefs.showcase_overlay_texture: - rect = SDL_Rect() + rect = sdl3.SDL_FRect() rect.x = 0 rect.y = 0 rect.w = 300 @@ -40478,7 +40312,7 @@ def render(self): while xx < window_size[0]: rect.x = xx rect.y = yy - SDL_RenderCopy(renderer, overlay_texture_texture, None, rect) + sdl3.SDL_RenderTexture(renderer, overlay_texture_texture, None, rect) xx += 300 yy += 300 @@ -40547,7 +40381,7 @@ def render(self): (x - round(2 * gui.scale), y - round(2 * gui.scale), box + round(4 * gui.scale), box + round(4 * gui.scale)), [60, 60, 60, 135]) ddt.rect((x, y, box, box), colours.playlist_panel_background) - rect = SDL_Rect(round(x), round(y), round(box), round(box)) + rect = sdl3.SDL_FRect(round(x), round(y), round(box), round(box)) style_overlay.hole_punches.append(rect) # Draw album art in box @@ -40684,15 +40518,15 @@ def render(self): def render_vis(self, top=False): - SDL_SetRenderTarget(renderer, gui.spec4_tex) - SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) - SDL_RenderClear(renderer) + sdl3.SDL_SetRenderTarget(renderer, gui.spec4_tex) + sdl3.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) + sdl3.SDL_RenderClear(renderer) bx = 0 by = 50 * gui.scale if gui.vis_4_colour is not None: - SDL_SetRenderDrawColor( + sdl3.SDL_SetRenderDrawColor( renderer, gui.vis_4_colour[0], gui.vis_4_colour[1], gui.vis_4_colour[2], gui.vis_4_colour[3]) if (pctl.playing_time < 0.5 and (pctl.playing_state == 1 or pctl.playing_state == 3)) or ( @@ -40731,18 +40565,18 @@ def render_vis(self, top=False): gui.bar4.w = round(2 * gui.scale) gui.bar4.h = round(dis * 2 * gui.scale) - SDL_RenderFillRect(renderer, gui.bar4) + sdl3.SDL_RenderFillRect(renderer, gui.bar4) # Set distance between bars bx += 8 * gui.scale if top: - SDL_SetRenderTarget(renderer, None) + sdl3.SDL_SetRenderTarget(renderer, None) else: - SDL_SetRenderTarget(renderer, gui.main_texture) + sdl3.SDL_SetRenderTarget(renderer, gui.main_texture) - # SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND) - SDL_RenderCopy(renderer, gui.spec4_tex, None, gui.spec4_rec) + # sdl3.SDL_SetRenderDrawBlendMode(renderer, sdl3.SDL_BLENDMODE_BLEND) + sdl3.SDL_RenderTexture(renderer, gui.spec4_tex, None, gui.spec4_rec) showcase = Showcase() @@ -41575,17 +41409,17 @@ def hit_callback(win, point, data): if gui.mode == 3: if key_shift_down or key_shiftr_down: - return SDL_HITTEST_NORMAL + return sdl3.SDL_HITTEST_NORMAL # if prefs.mini_mode_mode == 5: - # return SDL_HITTEST_NORMAL + # return sdl3.SDL_HITTEST_NORMAL if prefs.mini_mode_mode in (4, 5) and x > window_size[1] - 5 * gui.scale and y > window_size[1] - 12 * gui.scale: - return SDL_HITTEST_NORMAL + return sdl3.SDL_HITTEST_NORMAL if y < gui.window_control_hit_area_h and x > window_size[ 0] - gui.window_control_hit_area_w: - return SDL_HITTEST_NORMAL + return sdl3.SDL_HITTEST_NORMAL # Square modes y1 = window_size[0] @@ -41597,20 +41431,20 @@ def hit_callback(win, point, data): if window_size[0] == window_size[1]: y1 = window_size[1] - 79 * gui.scale if y0 < y < y1 and not search_over.active: - return SDL_HITTEST_DRAGGABLE + return sdl3.SDL_HITTEST_DRAGGABLE - return SDL_HITTEST_NORMAL + return sdl3.SDL_HITTEST_NORMAL # Standard player mode if not gui.maximized: if y < 0 and x > window_size[0]: - return SDL_HITTEST_RESIZE_TOPRIGHT + return sdl3.SDL_HITTEST_RESIZE_TOPRIGHT if y < 0 and x < 1: - return SDL_HITTEST_RESIZE_TOPLEFT + return sdl3.SDL_HITTEST_RESIZE_TOPLEFT # if draw_border and y < 3 * gui.scale and x < window_size[0] - 40 * gui.scale and not gui.maximized: - # return SDL_HITTEST_RESIZE_TOP + # return sdl3.SDL_HITTEST_RESIZE_TOP if y < gui.panelY: @@ -41618,45 +41452,45 @@ def hit_callback(win, point, data): if y < gui.panelY - gui.panelY2: if prefs.left_window_control and x < 100 * gui.scale: - return SDL_HITTEST_NORMAL + return sdl3.SDL_HITTEST_NORMAL if x > window_size[0] - 100 * gui.scale and y < 30 * gui.scale: - return SDL_HITTEST_NORMAL - return SDL_HITTEST_DRAGGABLE + return sdl3.SDL_HITTEST_NORMAL + return sdl3.SDL_HITTEST_DRAGGABLE if top_panel.drag_zone_start_x > x or tab_menu.active: - return SDL_HITTEST_NORMAL - return SDL_HITTEST_DRAGGABLE + return sdl3.SDL_HITTEST_NORMAL + return sdl3.SDL_HITTEST_DRAGGABLE if top_panel.drag_zone_start_x < x < window_size[0] - (gui.offset_extra + 5): if tab_menu.active or mouse_up or mouse_down: # mouse up/down is workaround for Wayland - return SDL_HITTEST_NORMAL + return sdl3.SDL_HITTEST_NORMAL if (prefs.left_window_control and x > window_size[0] - (100 * gui.scale) and ( macos or system == "Windows" or msys)) or (not prefs.left_window_control and x > window_size[0] - (160 * gui.scale) and ( macos or system == "Windows" or msys)): - return SDL_HITTEST_NORMAL + return sdl3.SDL_HITTEST_NORMAL - return SDL_HITTEST_DRAGGABLE + return sdl3.SDL_HITTEST_DRAGGABLE if not gui.maximized: if x > window_size[0] - 20 * gui.scale and y > window_size[1] - 20 * gui.scale: - return SDL_HITTEST_RESIZE_BOTTOMRIGHT + return sdl3.SDL_HITTEST_RESIZE_BOTTOMRIGHT if x < 5 and y > window_size[1] - 5: - return SDL_HITTEST_RESIZE_BOTTOMLEFT + return sdl3.SDL_HITTEST_RESIZE_BOTTOMLEFT if y > window_size[1] - 5 * gui.scale: - return SDL_HITTEST_RESIZE_BOTTOM + return sdl3.SDL_HITTEST_RESIZE_BOTTOM if x > window_size[0] - 3 * gui.scale and y > 20 * gui.scale: - return SDL_HITTEST_RESIZE_RIGHT + return sdl3.SDL_HITTEST_RESIZE_RIGHT if x < 5 * gui.scale and y > 10 * gui.scale: - return SDL_HITTEST_RESIZE_LEFT - return SDL_HITTEST_NORMAL - return SDL_HITTEST_NORMAL + return sdl3.SDL_HITTEST_RESIZE_LEFT + return sdl3.SDL_HITTEST_NORMAL + return sdl3.SDL_HITTEST_NORMAL -c_hit_callback = SDL_HitTest(hit_callback) -SDL_SetWindowHitTest(t_window, c_hit_callback, 0) +c_hit_callback = sdl3.SDL_HitTest(hit_callback) +sdl3.SDL_SetWindowHitTest(t_window, c_hit_callback, 0) # -------------------------------------------------------------------------------------------- @@ -41707,7 +41541,7 @@ def hit_callback(win, point, data): update_layout = True -event = SDL_Event() + mouse_moved = False @@ -41719,10 +41553,8 @@ def hit_callback(win, point, data): and not item.startswith("-"): open_uri(item) -sv = SDL_version() -SDL_GetVersion(sv) -sdl_version = sv.major * 100 + sv.minor * 10 + sv.patch -logging.info("Using SDL version: " + str(sv.major) + "." + str(sv.minor) + "." + str(sv.patch)) +sdl_version = sdl3.SDL_GetVersion() +logging.info("Using SDL version: " + str(sdl_version)) # C-ML # if prefs.backend == 2: @@ -42234,97 +42066,97 @@ def update_layout_do(): while window_size[1] > gui.max_window_tex: gui.max_window_tex += 1000 - gui.tracklist_texture_rect = SDL_Rect(0, 0, gui.max_window_tex, gui.max_window_tex) + gui.tracklist_texture_rect = sdl3.SDL_FRect(0, 0, gui.max_window_tex, gui.max_window_tex) - SDL_DestroyTexture(gui.tracklist_texture) - SDL_RenderClear(renderer) - gui.tracklist_texture = SDL_CreateTexture( - renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, + sdl3.SDL_DestroyTexture(gui.tracklist_texture) + sdl3.SDL_RenderClear(renderer) + gui.tracklist_texture = sdl3.SDL_CreateTexture( + renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, gui.max_window_tex, gui.max_window_tex) - SDL_SetRenderTarget(renderer, gui.tracklist_texture) - SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) - SDL_RenderClear(renderer) - SDL_SetTextureBlendMode(gui.tracklist_texture, SDL_BLENDMODE_BLEND) + sdl3.SDL_SetRenderTarget(renderer, gui.tracklist_texture) + sdl3.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) + sdl3.SDL_RenderClear(renderer) + sdl3.SDL_SetTextureBlendMode(gui.tracklist_texture, sdl3.SDL_BLENDMODE_BLEND) - # SDL_SetRenderTarget(renderer, gui.main_texture) - # SDL_RenderClear(renderer) + # sdl3.SDL_SetRenderTarget(renderer, gui.main_texture) + # sdl3.SDL_RenderClear(renderer) - SDL_DestroyTexture(gui.main_texture) - gui.main_texture = SDL_CreateTexture( - renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, + sdl3.SDL_DestroyTexture(gui.main_texture) + gui.main_texture = sdl3.SDL_CreateTexture( + renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, sdl3.SDL_TEXTUREACCESS_TARGET, gui.max_window_tex, gui.max_window_tex) - SDL_SetTextureBlendMode(gui.main_texture, SDL_BLENDMODE_BLEND) - SDL_SetRenderTarget(renderer, gui.main_texture) - SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) - SDL_SetRenderTarget(renderer, gui.main_texture) - SDL_RenderClear(renderer) - - SDL_DestroyTexture(gui.main_texture_overlay_temp) - gui.main_texture_overlay_temp = SDL_CreateTexture( - renderer, SDL_PIXELFORMAT_ARGB8888, - SDL_TEXTUREACCESS_TARGET, gui.max_window_tex, + sdl3.SDL_SetTextureBlendMode(gui.main_texture, sdl3.SDL_BLENDMODE_BLEND) + sdl3.SDL_SetRenderTarget(renderer, gui.main_texture) + sdl3.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) + sdl3.SDL_SetRenderTarget(renderer, gui.main_texture) + sdl3.SDL_RenderClear(renderer) + + sdl3.SDL_DestroyTexture(gui.main_texture_overlay_temp) + gui.main_texture_overlay_temp = sdl3.SDL_CreateTexture( + renderer, sdl3.SDL_PIXELFORMAT_ARGB8888, + sdl3.SDL_TEXTUREACCESS_TARGET, gui.max_window_tex, gui.max_window_tex) - SDL_SetTextureBlendMode(gui.main_texture_overlay_temp, SDL_BLENDMODE_BLEND) - SDL_SetRenderTarget(renderer, gui.main_texture_overlay_temp) - SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) - SDL_SetRenderTarget(renderer, gui.main_texture_overlay_temp) - SDL_RenderClear(renderer) + sdl3.SDL_SetTextureBlendMode(gui.main_texture_overlay_temp, sdl3.SDL_BLENDMODE_BLEND) + sdl3.SDL_SetRenderTarget(renderer, gui.main_texture_overlay_temp) + sdl3.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0) + sdl3.SDL_SetRenderTarget(renderer, gui.main_texture_overlay_temp) + sdl3.SDL_RenderClear(renderer) update_set() if prefs.art_bg: tauon.thread_manager.ready("style") -# SDL_RenderClear(renderer) -# SDL_RenderPresent(renderer) +# sdl3.SDL_RenderClear(renderer) +# sdl3.SDL_RenderPresent(renderer) -# SDL_ShowWindow(t_window) +# sdl3.SDL_ShowWindow(t_window) # Clear spectogram texture -SDL_SetRenderTarget(renderer, gui.spec2_tex) -SDL_RenderClear(renderer) +sdl3.SDL_SetRenderTarget(renderer, gui.spec2_tex) +sdl3.SDL_RenderClear(renderer) ddt.rect((0, 0, 1000, 1000), [7, 7, 7, 255]) -SDL_SetRenderTarget(renderer, gui.spec1_tex) -SDL_RenderClear(renderer) +sdl3.SDL_SetRenderTarget(renderer, gui.spec1_tex) +sdl3.SDL_RenderClear(renderer) ddt.rect((0, 0, 1000, 1000), [7, 7, 7, 255]) -SDL_SetRenderTarget(renderer, gui.spec_level_tex) -SDL_RenderClear(renderer) +sdl3.SDL_SetRenderTarget(renderer, gui.spec_level_tex) +sdl3.SDL_RenderClear(renderer) ddt.rect((0, 0, 1000, 1000), [7, 7, 7, 255]) -SDL_SetRenderTarget(renderer, None) +sdl3.SDL_SetRenderTarget(renderer, None) -# SDL_RenderPresent(renderer) +# sdl3.SDL_RenderPresent(renderer) # time.sleep(3) class GetSDLInput: def __init__(self): - self.i_y = pointer(c_int(0)) - self.i_x = pointer(c_int(0)) self.mouse_capture_want = False self.mouse_capture = False def mouse(self): - SDL_PumpEvents() - SDL_GetMouseState(self.i_x, self.i_y) - return int(self.i_x.contents.value / logical_size[0] * window_size[0]), int( - self.i_y.contents.value / logical_size[0] * window_size[0]) + sdl3.SDL_PumpEvents() + i_y = pointer(c_float(0)) + i_x = pointer(c_float(0)) + sdl3.SDL_GetMouseState(i_x, i_y) + return int(i_x.contents.value / logical_size[0] * window_size[0]), int( + i_y.contents.value / logical_size[0] * window_size[0]) def test_capture_mouse(self): if not self.mouse_capture and self.mouse_capture_want: - SDL_CaptureMouse(SDL_TRUE) + sdl3.SDL_CaptureMouse(sdl3.SDL_TRUE) self.mouse_capture = True elif self.mouse_capture and not self.mouse_capture_want: - SDL_CaptureMouse(SDL_FALSE) + sdl3.SDL_CaptureMouse(sdl3.SDL_FALSE) self.mouse_capture = False @@ -42333,12 +42165,12 @@ def test_capture_mouse(self): gal_left = False gal_right = False -get_sdl_input = GetSDLInput() +input_sdl = GetSDLInput() def window_is_focused() -> bool: """Thread safe?""" - if SDL_GetWindowFlags(t_window) & SDL_WINDOW_INPUT_FOCUS: + if sdl3.SDL_GetWindowFlags(t_window) & sdl3.SDL_WINDOW_INPUT_FOCUS: return True return False @@ -42612,11 +42444,11 @@ def save_state() -> None: logging.exception("Unknown error encountered while writing database") -SDL_StartTextInput() +sdl3.SDL_StartTextInput(t_window) -# SDL_SetHint(SDL_HINT_IME_INTERNAL_EDITING, b"1") -# SDL_EventState(SDL_SYSWMEVENT, 1) +# sdl3.SDL_SetHint(sdl3.SDL_HINT_IME_INTERNAL_EDITING, b"1") +# sdl3.SDL_EventState(sdl3.SDL_SYSWMEVENT, 1) def test_show_add_home_music() -> None: @@ -42727,7 +42559,7 @@ def drop_file(target): global mouse_down global drag_mode - if system != "windows" and sdl_version >= 204: + if system != "windows" and sdl3.SDL_version >= 204: gmp = get_global_mouse() gwp = get_window_position() i_x = gmp[0] - gwp[0] @@ -42740,7 +42572,7 @@ def drop_file(target): i_y = pointer(c_int(0)) i_x = pointer(c_int(0)) - SDL_GetMouseState(i_x, i_y) + sdl3.SDL_GetMouseState(i_x, i_y) i_y = i_y.contents.value / logical_size[0] * window_size[0] i_x = i_x.contents.value / logical_size[0] * window_size[0] @@ -42830,7 +42662,7 @@ def drop_file(target): # switch_playlist(len(pctl.multi_playlist) - 1) -SDL_SetRenderTarget(renderer, overlay_texture_texture) +sdl3.SDL_SetRenderTarget(renderer, overlay_texture_texture) block_size = 3 @@ -42848,10 +42680,10 @@ def drop_file(target): y += block_size sync_target.text = prefs.sync_target -SDL_SetRenderTarget(renderer, None) +sdl3.SDL_SetRenderTarget(renderer, None) if msys: - SDL_SetWindowResizable(t_window, True) # Not sure why this is needed + sdl3.SDL_SetWindowResizable(t_window, True) # Not sure why this is needed # Generate theme buttons pref_box.themes.append((ColoursClass(), "Mindaro", 0)) @@ -42876,9 +42708,12 @@ def drop_file(target): # MAIN LOOP +event = sdl3.SDL_Event() + while pctl.running: # bm.get('main') # time.sleep(100) + if k_input: keymaps.hits.clear() @@ -42926,26 +42761,26 @@ def drop_file(target): # gui.update = 2 - while SDL_PollEvent(ctypes.byref(event)) != 0: + while sdl3.SDL_PollEvent(ctypes.byref(event)) != 0: - # if event.type == SDL_SYSWMEVENT: + # if event.type == sdl3.SDL_SYSWMEVENT: # logging.info(event.syswm.msg.contents) # Not implemented by pysdl2 - if event.type == SDL_CONTROLLERDEVICEADDED and prefs.use_gamepad: - if SDL_IsGameController(event.cdevice.which): - SDL_GameControllerOpen(event.cdevice.which) + if event.type == sdl3.SDL_EVENT_GAMEPAD_ADDED and prefs.use_gamepad: + if sdl3.SDL_IsGamepad(event.gdevice.which): + sdl3.SDL_OpenGamepad(event.gdevice.which) try: - logging.info(f"Found game controller: {SDL_GameControllerNameForIndex(event.cdevice.which).decode()}") + logging.info(f"Found game controller: {sdl3.SDL_GetGamepadNameForID(event.gdevice.which).decode()}") except Exception: logging.exception("Error getting game controller") - if event.type == SDL_CONTROLLERAXISMOTION and prefs.use_gamepad: - if event.caxis.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT: - rt = event.caxis.value > 5000 - if event.caxis.axis == SDL_CONTROLLER_AXIS_LEFTY: - if event.caxis.value < -10000: + if event.type == sdl3.SDL_EVENT_GAMEPAD_AXIS_MOTION and prefs.use_gamepad: + if event.gaxis.axis == sdl3.SDL_GAMEPAD_AXIS_LEFT_TRIGGER: + rt = event.gaxis.value > 5000 + if event.gaxis.axis == sdl3.SDL_GAMEPAD_AXIS_LEFTY: + if event.gaxis.value < -10000: new = -1 - elif event.caxis.value > 10000: + elif event.gaxis.value > 10000: new = 1 else: new = 0 @@ -42954,10 +42789,10 @@ def drop_file(target): c_yax = new power += 5 gui.update += 1 - if event.caxis.axis == SDL_CONTROLLER_AXIS_RIGHTX: - if event.caxis.value < -15000: + if event.gaxis.axis == sdl3.SDL_GAMEPAD_AXIS_RIGHTX: + if event.gaxis.value < -15000: new = -1 - elif event.caxis.value > 15000: + elif event.gaxis.value > 15000: new = 1 else: new = 0 @@ -42966,10 +42801,10 @@ def drop_file(target): c_xax = new power += 5 gui.update += 1 - if event.caxis.axis == SDL_CONTROLLER_AXIS_RIGHTY: - if event.caxis.value < -15000: + if event.gaxis.axis == sdl3.SDL_GAMEPAD_AXIS_RIGHTY: + if event.gaxis.value < -15000: new = -1 - elif event.caxis.value > 15000: + elif event.gaxis.value > 15000: new = 1 else: new = 0 @@ -42979,21 +42814,21 @@ def drop_file(target): power += 5 gui.update += 1 - if event.type == SDL_CONTROLLERBUTTONDOWN and prefs.use_gamepad: + if event.type == sdl3.SDL_EVENT_GAMEPAD_BUTTON_DOWN and prefs.use_gamepad: k_input = True power += 5 gui.update += 2 - if event.cbutton.button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: + if event.cbutton.button == sdl3.SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER: if rt: toggle_random() else: pctl.advance() - if event.cbutton.button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER: + if event.cbutton.button == sdl3.SDL_GAMEPAD_BUTTON_LEFT_SHOULDER: if rt: toggle_repeat() else: pctl.back() - if event.cbutton.button == SDL_CONTROLLER_BUTTON_A: + if event.cbutton.button == sdl3.SDL_GAMEPAD_BUTTON_SOUTH: if rt: pctl.show_current(highlight=True) elif pctl.playing_ready() and pctl.active_playlist_playing == pctl.active_playlist_viewing and \ @@ -43002,42 +42837,42 @@ def drop_file(target): pctl.play_pause() else: inp.key_return_press = True - if event.cbutton.button == SDL_CONTROLLER_BUTTON_X: + if event.cbutton.button == sdl3.SDL_GAMEPAD_BUTTON_WEST: if rt: random_track() else: toggle_gallery_keycontrol(always_exit=True) - if event.cbutton.button == SDL_CONTROLLER_BUTTON_Y: + if event.cbutton.button == sdl3.SDL_GAMEPAD_BUTTON_NORTH: if rt: pctl.advance(rr=True) else: pctl.play_pause() - if event.cbutton.button == SDL_CONTROLLER_BUTTON_B: + if event.cbutton.button == sdl3.SDL_GAMEPAD_BUTTON_EAST: if rt: pctl.revert() elif is_level_zero(): pctl.stop() else: key_esc_press = True - if event.cbutton.button == SDL_CONTROLLER_BUTTON_DPAD_UP: + if event.cbutton.button == sdl3.SDL_GAMEPAD_BUTTON_DPAD_UP: key_up_press = True - if event.cbutton.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN: + if event.cbutton.button == sdl3.SDL_GAMEPAD_BUTTON_DPAD_DOWN: key_down_press = True - if event.cbutton.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT: + if event.cbutton.button == sdl3.SDL_GAMEPAD_BUTTON_DPAD_LEFT: if gui.album_tab_mode: key_left_press = True elif is_level_zero() or quick_search_mode: cycle_playlist_pinned(1) - if event.cbutton.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT: + if event.cbutton.button == sdl3.SDL_GAMEPAD_BUTTON_DPAD_RIGHT: if gui.album_tab_mode: key_right_press = True elif is_level_zero() or quick_search_mode: cycle_playlist_pinned(-1) - if event.type == SDL_RENDER_TARGETS_RESET and not msys: + if event.type == sdl3.SDL_EVENT_RENDER_TARGETS_RESET and not msys: reset_render = True - if event.type == SDL_DROPTEXT: + if event.type == sdl3.SDL_EVENT_DROP_TEXT: power += 5 @@ -43045,7 +42880,7 @@ def drop_file(target): #logging.info(link) if pctl.playing_ready() and link.startswith("http"): - if system != "windows" and sdl_version >= 204: + if system != "windows" and sdl3.SDL_version >= 204: gmp = get_global_mouse() gwp = get_window_position() i_x = gmp[0] - gwp[0] @@ -43058,7 +42893,7 @@ def drop_file(target): i_y = pointer(c_int(0)) i_x = pointer(c_int(0)) - SDL_GetMouseState(i_x, i_y) + sdl3.SDL_GetMouseState(i_x, i_y) i_y = i_y.contents.value / logical_size[0] * window_size[0] i_x = i_x.contents.value / logical_size[0] * window_size[0] @@ -43081,7 +42916,7 @@ def drop_file(target): target = str(urllib.parse.unquote(line)).replace("file:///", "/") drop_file(target) - if event.type == SDL_DROPFILE: + if event.type == sdl3.SDL_EVENT_DROP_FILE: power += 5 dropped_file_sdl = event.drop.file @@ -43096,7 +42931,7 @@ def drop_file(target): gui.pl_update = 1 gui.update += 2 - elif event.type == SDL_QUIT: + elif event.type == sdl3.SDL_EVENT_QUIT: power += 5 if gui.tray_active and prefs.min_to_tray and not key_shift_down: @@ -43104,7 +42939,7 @@ def drop_file(target): else: tauon.exit("Window received exit signal") break - elif event.type == SDL_TEXTEDITING: + elif event.type == sdl3.SDL_EVENT_TEXT_EDITING: power += 5 #logging.info("edit text") editline = event.edit.text @@ -43113,13 +42948,13 @@ def drop_file(target): k_input = True gui.update += 1 - elif event.type == SDL_MOUSEMOTION: + elif event.type == sdl3.SDL_EVENT_MOUSE_MOTION: mouse_position[0] = int(event.motion.x / logical_size[0] * window_size[0]) mouse_position[1] = int(event.motion.y / logical_size[0] * window_size[0]) mouse_moved = True gui.mouse_unknown = False - elif event.type == SDL_MOUSEBUTTONDOWN: + elif event.type == sdl3.SDL_EVENT_MOUSE_BUTTON_DOWN: k_input = True focused = True @@ -43130,11 +42965,11 @@ def drop_file(target): if ggc == 2: # dont click on first full frame continue - if event.button.button == SDL_BUTTON_RIGHT: + if event.button.button == sdl3.SDL_BUTTON_RIGHT: right_click = True right_down = True #logging.info("RIGHT DOWN") - elif event.button.button == SDL_BUTTON_LEFT: + elif event.button.button == sdl3.SDL_BUTTON_LEFT: #logging.info("LEFT DOWN") # if mouse_position[1] > 1 and mouse_position[0] > 1: @@ -43143,21 +42978,21 @@ def drop_file(target): inp.mouse_click = True mouse_down = True - elif event.button.button == SDL_BUTTON_MIDDLE: + elif event.button.button == sdl3.SDL_BUTTON_MIDDLE: if not search_over.active: middle_click = True gui.update += 1 - elif event.button.button == SDL_BUTTON_X1: + elif event.button.button == sdl3.SDL_BUTTON_X1: keymaps.hits.append("MB4") - elif event.button.button == SDL_BUTTON_X2: + elif event.button.button == sdl3.SDL_BUTTON_X2: keymaps.hits.append("MB5") - elif event.type == SDL_MOUSEBUTTONUP: + elif event.type == sdl3.SDL_EVENT_MOUSE_BUTTON_UP: k_input = True power += 5 gui.update += 1 - if event.button.button == SDL_BUTTON_RIGHT: + if event.button.button == sdl3.SDL_BUTTON_RIGHT: right_down = False - elif event.button.button == SDL_BUTTON_LEFT: + elif event.button.button == sdl3.SDL_BUTTON_LEFT: if mouse_down: mouse_up = True mouse_up_position[0] = event.motion.x / logical_size[0] * window_size[0] @@ -43165,7 +43000,8 @@ def drop_file(target): mouse_down = False gui.update += 1 - elif event.type == SDL_KEYDOWN and key_focused == 0: + elif event.type == sdl3.SDL_EVENT_KEY_DOWN and key_focused == 0: + continue # TODO fix me k_input = True power += 5 gui.update += 2 @@ -43175,15 +43011,15 @@ def drop_file(target): keymaps.hits.append(event.key.keysym.sym) if prefs.use_scancodes: - if event.key.keysym.scancode == SDL_SCANCODE_V: + if event.key.keysym.scancode == sdl3.SDL_SCANCODE_V: key_v_press = True - elif event.key.keysym.scancode == SDL_SCANCODE_A: + elif event.key.keysym.scancode == sdl3.SDL_SCANCODE_A: key_a_press = True - elif event.key.keysym.scancode == SDL_SCANCODE_C: + elif event.key.keysym.scancode == sdl3.SDL_SCANCODE_C: key_c_press = True - elif event.key.keysym.scancode == SDL_SCANCODE_Z: + elif event.key.keysym.scancode == sdl3.SDL_SCANCODE_Z: key_z_press = True - elif event.key.keysym.scancode == SDL_SCANCODE_X: + elif event.key.keysym.scancode == sdl3.SDL_SCANCODE_X: key_x_press = True elif event.key.keysym.sym == SDLK_v: key_v_press = True @@ -43238,8 +43074,8 @@ def drop_file(target): key_meta = True key_focused = 1 - elif event.type == SDL_KEYUP: - + elif event.type == sdl3.SDL_EVENT_KEY_UP: + continue k_input = True power += 5 gui.update += 2 @@ -43264,7 +43100,7 @@ def drop_file(target): key_meta = False key_focused = 1 - elif event.type == SDL_TEXTINPUT: + elif event.type == sdl3.SDL_EVENT_TEXT_INPUT: k_input = True power += 5 input_text += event.text.text.decode("utf-8") @@ -43272,18 +43108,19 @@ def drop_file(target): gui.update += 1 #logging.info(input_text) - elif event.type == SDL_MOUSEWHEEL: + elif event.type == sdl3.SDL_EVENT_MOUSE_WHEEL: k_input = True power += 6 mouse_wheel += event.wheel.y + gui.update += 1 - elif event.type == SDL_WINDOWEVENT: + elif event.type >= sdl3.SDL_EVENT_WINDOW_FIRST and event.type <= sdl3.SDL_EVENT_WINDOW_LAST : power += 5 - #logging.info(event.window.event) + #logging.info(event.type) - if event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED: - #logging.info("SDL_WINDOWEVENT_FOCUS_GAINED") + if event.type == sdl3.SDL_EVENT_WINDOW_FOCUS_GAINED: + #logging.info("sdl3.SDL_WINDOWEVENT_FOCUS_GAINED") if system == "Linux" and not macos and not msys: gnome.focus() @@ -43298,19 +43135,19 @@ def drop_file(target): gui.pl_update = 1 gui.update += 1 - elif event.window.event == SDL_WINDOWEVENT_FOCUS_LOST: + elif event.type == sdl3.SDL_EVENT_WINDOW_FOCUS_LOST: close_all_menus() key_focused = 1 gui.update += 1 - elif event.window.event == SDL_WINDOWEVENT_DISPLAY_CHANGED: - # SDL_WINDOWEVENT_DISPLAY_CHANGED logs new display ID as data1 (0 or 1 or 2...), it not width, and data 2 is always 0 + elif event.type == sdl3.SDL_EVENT_WINDOW_DISPLAY_CHANGED: + # sdl3.SDL_WINDOWEVENT_DISPLAY_CHANGED logs new display ID as data1 (0 or 1 or 2...), it not width, and data 2 is always 0 pass - elif event.window.event == SDL_WINDOWEVENT_RESIZED: - # SDL_WINDOWEVENT_RESIZED logs width to data1 and height to data2 + elif event.type == sdl3.SDL_EVENT_WINDOW_RESIZED: + # sdl3.SDL_WINDOWEVENT_RESIZED logs width to data1 and height to data2 if event.window.data1 < 500: logging.error("Window width is less than 500, grrr why does this happen, stupid bug") - SDL_SetWindowSize(t_window, logical_size[0], logical_size[1]) + sdl3.SDL_SetWindowSize(t_window, logical_size[0], logical_size[1]) elif restore_ignore_timer.get() > 1: # Hacky gui.update = 2 @@ -43323,7 +43160,7 @@ def drop_file(target): i_x = pointer(c_int(0)) i_y = pointer(c_int(0)) - SDL_GL_GetDrawableSize(t_window, i_x, i_y) + sdl3.SDL_GetWindowSizeInPixels(t_window, i_x, i_y) window_size[0] = i_x.contents.value window_size[1] = i_y.contents.value @@ -43331,25 +43168,25 @@ def drop_file(target): update_layout = True - elif event.window.event == SDL_WINDOWEVENT_ENTER: + elif event.type == sdl3.SDL_EVENT_WINDOW_MOUSE_ENTER: #logging.info("ENTER") mouse_enter_window = True gui.mouse_in_window = True gui.update += 1 - # elif event.window.event == SDL_WINDOWEVENT_HIDDEN: + # elif event.type == sdl3.SDL_WINDOWEVENT_HIDDEN: # - elif event.window.event == SDL_WINDOWEVENT_EXPOSED: + elif event.type == sdl3.SDL_EVENT_WINDOW_EXPOSED: #logging.info("expose") gui.lowered = False - elif event.window.event == SDL_WINDOWEVENT_MINIMIZED: + elif event.type == sdl3.SDL_EVENT_WINDOW_MINIMIZED: gui.lowered = True # if prefs.min_to_tray: # tray.down() # tauon.thread_manager.sleep() - elif event.window.event == SDL_WINDOWEVENT_RESTORED: + elif event.type == sdl3.SDL_EVENT_WINDOW_RESTORED: gui.lowered = False gui.maximized = False @@ -43360,25 +43197,25 @@ def drop_file(target): update_title_do() #logging.info("restore") - elif event.window.event == SDL_WINDOWEVENT_SHOWN: + elif event.type == sdl3.SDL_EVENT_WINDOW_SHOWN: focused = True gui.pl_update = 1 gui.update += 1 - # elif event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED: + # elif event.type == sdl3.SDL_WINDOWEVENT_FOCUS_GAINED: # logging.info("FOCUS GAINED") # # input.mouse_enter_event = True # # gui.update += 1 # # k_input = True - elif event.window.event == SDL_WINDOWEVENT_MAXIMIZED: + elif event.type == sdl3.SDL_EVENT_WINDOW_MAXIMIZED: if gui.mode != 3: # workaround. sdl bug? gives event on window size set gui.maximized = True update_layout = True gui.pl_update = 1 gui.update += 1 - elif event.window.event == SDL_WINDOWEVENT_LEAVE: + elif event.type == sdl3.SDL_EVENT_WINDOW_MOUSE_LEAVE: gui.mouse_in_window = False gui.update += 1 power = 1000 @@ -43390,9 +43227,9 @@ def drop_file(target): if gui.request_raise: gui.request_raise = False logging.info("Raise") - SDL_ShowWindow(t_window) - SDL_RestoreWindow(t_window) - SDL_RaiseWindow(t_window) + sdl3.SDL_ShowWindow(t_window) + sdl3.SDL_RestoreWindow(t_window) + sdl3.SDL_RaiseWindow(t_window) gui.lowered = False # if tauon.thread_manager.sleeping: @@ -43440,7 +43277,7 @@ def drop_file(target): cursor_blink_timer.set() TextBox.cursor = True - SDL_Delay(3) + sdl3.SDL_Delay(3) power = 1000 if mouse_wheel or k_input or gui.pl_update or gui.update or top_panel.adds: # or mouse_moved: @@ -43473,7 +43310,7 @@ def drop_file(target): # gui.level_update = True # vis_update = True # else: - # SDL_Delay(5) + # sdl3.SDL_Delay(5) if not pctl.running: break @@ -43489,7 +43326,7 @@ def drop_file(target): else: sleep_timer.set() if sleep_timer.get() > 2: - SDL_WaitEventTimeout(None, 1000) + sdl3.SDL_WaitEventTimeout(None, 1000) continue else: power = 0 @@ -43502,8 +43339,8 @@ def drop_file(target): dl_mon.scan() if mouse_down and not coll((2, 2, window_size[0] - 4, window_size[1] - 4)): - #logging.info(SDL_GetMouseState(None, None)) - if SDL_GetGlobalMouseState(None, None) == 0: + #logging.info(sdl3.SDL_GetMouseState(None, None)) + if sdl3.SDL_GetGlobalMouseState(None, None) == 0: mouse_down = False mouse_up = True quick_drag = False @@ -43619,10 +43456,10 @@ def drop_file(target): if keymaps.test("toggle-fullscreen"): if not gui.fullscreen and gui.mode != 3: gui.fullscreen = True - SDL_SetWindowFullscreen(t_window, SDL_WINDOW_FULLSCREEN_DESKTOP) + sdl3.SDL_SetWindowFullscreen(t_window, sdl3.SDL_WINDOW_FULLSCREEN_DESKTOP) elif gui.fullscreen: gui.fullscreen = False - SDL_SetWindowFullscreen(t_window, 0) + sdl3.SDL_SetWindowFullscreen(t_window, 0) if keymaps.test("playlist-toggle-breaks"): # Toggle force off folder break for viewed playlist @@ -43658,7 +43495,7 @@ def drop_file(target): if gui.fullscreen and key_esc_press: gui.fullscreen = False - SDL_SetWindowFullscreen(t_window, 0) + sdl3.SDL_SetWindowFullscreen(t_window, 0) # Disable keys for text cursor control if not gui.rename_folder_box and not rename_track_box.active and not gui.rename_playlist_box and not radiobox.active and not pref_box.enabled and not trans_edit_box.active: @@ -44064,12 +43901,12 @@ def drop_file(target): if keymaps.test("opacity-up"): prefs.window_opacity += .05 prefs.window_opacity = min(prefs.window_opacity, 1) - SDL_SetWindowOpacity(t_window, prefs.window_opacity) + sdl3.SDL_SetWindowOpacity(t_window, prefs.window_opacity) if keymaps.test("opacity-down"): prefs.window_opacity -= .05 prefs.window_opacity = max(prefs.window_opacity, .30) - SDL_SetWindowOpacity(t_window, prefs.window_opacity) + sdl3.SDL_SetWindowOpacity(t_window, prefs.window_opacity) if keymaps.test("seek-forward"): pctl.seek_time(pctl.playing_time + prefs.seek_interval) @@ -44139,6 +43976,15 @@ def drop_file(target): # if focused is True: # mouse_down = False + # TODO testing only, remove me later + # gg = 5 + # aa = 80 + # colours.top_panel_background = [gg,gg,gg,aa] + # colours.side_panel_background = [gg,gg,gg,aa] + #colours.bottom_panel_colour = [gg,gg,gg,aa] + #colours.playlist_panel_background = [gg,gg,gg,aa] + #colours.playlist_box_background = [0, 0, 0, 100] + if inp.media_key: if inp.media_key == "Play": if pctl.playing_state == 0: @@ -44320,24 +44166,24 @@ def drop_file(target): item.reload() reset_render = False - SDL_SetRenderTarget(renderer, None) - SDL_SetRenderDrawColor( + sdl3.SDL_SetRenderTarget(renderer, None) + sdl3.SDL_SetRenderDrawColor( renderer, colours.top_panel_background[0], colours.top_panel_background[1], colours.top_panel_background[2], colours.top_panel_background[3]) - SDL_RenderClear(renderer) - SDL_SetRenderTarget(renderer, gui.main_texture) - SDL_RenderClear(renderer) + sdl3.SDL_RenderClear(renderer) + sdl3.SDL_SetRenderTarget(renderer, gui.main_texture) + sdl3.SDL_RenderClear(renderer) # perf_timer.set() gui.update_on_drag = False gui.pl_update_on_drag = False - # mouse_position[0], mouse_position[1] = get_sdl_input.mouse() + # mouse_position[0], mouse_position[1] = input_sdl.mouse() gui.showed_title = False if not gui.mouse_in_window and not bottom_bar1.volume_bar_being_dragged and not bottom_bar1.volume_hit and not bottom_bar1.seek_hit: - mouse_position[0] = -300 - mouse_position[1] = -300 + mouse_position[0] = -300. + mouse_position[1] = -300. if gui.clear_image_cache_next: gui.clear_image_cache_next -= 1 @@ -44352,7 +44198,7 @@ def drop_file(target): gui.layer_focus = 0 if inp.mouse_click or mouse_wheel or right_click: - mouse_position[0], mouse_position[1] = get_sdl_input.mouse() + mouse_position[0], mouse_position[1] = input_sdl.mouse() if inp.mouse_click: n_click_time = time.time() @@ -44372,6 +44218,7 @@ def drop_file(target): elif ggc == 1: ggc = 0 gbc.enable() + #logging.info("Enabling garbage collecting") if gui.mode == 4: @@ -44466,6 +44313,7 @@ def drop_file(target): update_layout_do() + # ALBUM GALLERY RENDERING: # Gallery view # C-AR @@ -45068,7 +44916,7 @@ def drop_file(target): bg=alpha_blend(back_colour, colours.gallery_background)) if prefs.art_bg and drawn_art: - rect = SDL_Rect(round(x), round(y), album_mode_art_size, album_mode_art_size) + rect = sdl3.SDL_FRect(round(x), round(y), album_mode_art_size, album_mode_art_size) if rect.y < gui.panelY: diff = round(gui.panelY - rect.y) rect.y += diff @@ -46105,8 +45953,8 @@ def drop_file(target): else: # p_y = pointer(c_int(0)) # p_x = pointer(c_int(0)) - # SDL_GetGlobalMouseState(p_x, p_y) - get_sdl_input.mouse_capture_want = True + # sdl3.SDL_GetGlobalMouseState(p_x, p_y) + input_sdl.mouse_capture_want = True scroll_hold = True # scroll_point = p_y.contents.value # mouse_position[1] @@ -46133,8 +45981,8 @@ def drop_file(target): gui.pl_update = 1 # p_y = pointer(c_int(0)) # p_x = pointer(c_int(0)) - # SDL_GetGlobalMouseState(p_x, p_y) - get_sdl_input.mouse_capture_want = True + # sdl3.SDL_GetGlobalMouseState(p_x, p_y) + input_sdl.mouse_capture_want = True sbp = mouse_position[1] - (scroll_point - scroll_bpoint) if sbp + sbl > ey: @@ -47127,14 +46975,14 @@ def drop_file(target): prefs.mini_mode_mode = 1 window_size[0] = int(330 * gui.scale) window_size[1] = int(330 * gui.scale) - SDL_SetWindowMinimumSize(t_window, window_size[0], window_size[1]) - SDL_SetWindowSize(t_window, window_size[0], window_size[1]) + sdl3.SDL_SetWindowMinimumSize(t_window, window_size[0], window_size[1]) + sdl3.SDL_SetWindowSize(t_window, window_size[0], window_size[1]) else: prefs.mini_mode_mode = 4 window_size[0] = int(320 * gui.scale) window_size[1] = int(90 * gui.scale) - SDL_SetWindowMinimumSize(t_window, window_size[0], window_size[1]) - SDL_SetWindowSize(t_window, window_size[0], window_size[1]) + sdl3.SDL_SetWindowMinimumSize(t_window, window_size[0], window_size[1]) + sdl3.SDL_SetWindowSize(t_window, window_size[0], window_size[1]) if prefs.mini_mode_mode == 5: mini_mode3.render() @@ -47312,26 +47160,26 @@ def drop_file(target): gui.cursor_is = gui.cursor_want if gui.cursor_is == 0: - SDL_SetCursor(cursor_standard) + sdl3.SDL_SetCursor(cursor_standard) elif gui.cursor_is == 1: - SDL_SetCursor(cursor_shift) + sdl3.SDL_SetCursor(cursor_shift) elif gui.cursor_is == 2: - SDL_SetCursor(cursor_text) + sdl3.SDL_SetCursor(cursor_text) elif gui.cursor_is == 3: - SDL_SetCursor(cursor_hand) + sdl3.SDL_SetCursor(cursor_hand) elif gui.cursor_is == 4: - SDL_SetCursor(cursor_br_corner) + sdl3.SDL_SetCursor(cursor_br_corner) elif gui.cursor_is == 8: - SDL_SetCursor(cursor_right_side) + sdl3.SDL_SetCursor(cursor_right_side) elif gui.cursor_is == 9: - SDL_SetCursor(cursor_top_side) + sdl3.SDL_SetCursor(cursor_top_side) elif gui.cursor_is == 10: - SDL_SetCursor(cursor_left_side) + sdl3.SDL_SetCursor(cursor_left_side) elif gui.cursor_is == 11: - SDL_SetCursor(cursor_bottom_side) + sdl3.SDL_SetCursor(cursor_bottom_side) - get_sdl_input.test_capture_mouse() - get_sdl_input.mouse_capture_want = False + input_sdl.test_capture_mouse() + input_sdl.mouse_capture_want = False # # Quick view # quick_view_box.render() @@ -47339,7 +47187,7 @@ def drop_file(target): # Drag icon next to cursor if quick_drag and mouse_down and not point_proximity_test( gui.drag_source_position, mouse_position, 15 * gui.scale): - i_x, i_y = get_sdl_input.mouse() + i_x, i_y = input_sdl.mouse() gui.drag_source_position = (0, 0) block_size = round(10 * gui.scale) @@ -47377,7 +47225,7 @@ def drop_file(target): # Drag pl tab next to cursor if (playlist_box.drag) and mouse_down and not point_proximity_test( gui.drag_source_position, mouse_position, 10 * gui.scale): - i_x, i_y = get_sdl_input.mouse() + i_x, i_y = input_sdl.mouse() gui.drag_source_position = (0, 0) ddt.rect( (i_x + 20 * gui.scale, i_y + 3 * gui.scale, int(50 * gui.scale), int(15 * gui.scale)), [50, 50, 50, 225]) @@ -47392,7 +47240,7 @@ def drop_file(target): gui.update_on_drag = True if not point_proximity_test(gui.set_label_point, mouse_position, 3): - i_x, i_y = get_sdl_input.mouse() + i_x, i_y = input_sdl.mouse() gui.set_label_point = (0, 0) w = ddt.get_text_w(gui.pl_st[gui.set_label_hold][0], 212) @@ -47411,8 +47259,8 @@ def drop_file(target): gui.update = min(gui.update, 1) gui.present = True - SDL_SetRenderTarget(renderer, None) - SDL_RenderCopy(renderer, gui.main_texture, None, gui.tracklist_texture_rect) + sdl3.SDL_SetRenderTarget(renderer, None) + sdl3.SDL_RenderTexture(renderer, gui.main_texture, None, gui.tracklist_texture_rect) if gui.turbo: gui.level_update = True @@ -47437,9 +47285,9 @@ def drop_file(target): if gui.level_update is True and not resize_mode and gui.mode != 3: gui.level_update = False - SDL_SetRenderTarget(renderer, None) + sdl3.SDL_SetRenderTarget(renderer, None) if not gui.present: - SDL_RenderCopy(renderer, gui.main_texture, None, gui.tracklist_texture_rect) + sdl3.SDL_RenderTexture(renderer, gui.main_texture, None, gui.tracklist_texture_rect) gui.present = True if gui.vis == 3: @@ -47455,7 +47303,7 @@ def drop_file(target): if len(gui.spec2_buffers) > 0 and vis_update: vis_update = False - SDL_SetRenderTarget(renderer, gui.spec2_tex) + sdl3.SDL_SetRenderTarget(renderer, gui.spec2_tex) for i, value in enumerate(gui.spec2_buffers[0]): ddt.rect( [gui.spec2_position, i, 1, 1], @@ -47472,7 +47320,7 @@ def drop_file(target): if gui.spec2_position > gui.spec2_w - 1: gui.spec2_position = 0 - SDL_SetRenderTarget(renderer, None) + sdl3.SDL_SetRenderTarget(renderer, None) # # else: @@ -47485,18 +47333,18 @@ def drop_file(target): gui.spec2_source.w = gui.spec2_position gui.spec2_dest.x = gui.spec2_rec.x + gui.spec2_rec.w - gui.spec2_position gui.spec2_dest.w = gui.spec2_position - SDL_RenderCopy(renderer, gui.spec2_tex, gui.spec2_source, gui.spec2_dest) + sdl3.SDL_RenderTexture(renderer, gui.spec2_tex, gui.spec2_source, gui.spec2_dest) gui.spec2_source.x = gui.spec2_position gui.spec2_source.y = 0 gui.spec2_source.w = gui.spec2_rec.w - gui.spec2_position gui.spec2_dest.x = gui.spec2_rec.x gui.spec2_dest.w = gui.spec2_rec.w - gui.spec2_position - SDL_RenderCopy(renderer, gui.spec2_tex, gui.spec2_source, gui.spec2_dest) + sdl3.SDL_RenderTexture(renderer, gui.spec2_tex, gui.spec2_source, gui.spec2_dest) else: - SDL_RenderCopy(renderer, gui.spec2_tex, None, gui.spec2_rec) + sdl3.SDL_RenderTexture(renderer, gui.spec2_tex, None, gui.spec2_rec) if pref_box.enabled: ddt.rect((gui.spec2_rec.x, gui.spec2_rec.y, gui.spec2_rec.w, gui.spec2_rec.h), [0, 0, 0, 90]) @@ -47556,7 +47404,7 @@ def drop_file(target): if not gui.test: - SDL_SetRenderTarget(renderer, gui.spec1_tex) + sdl3.SDL_SetRenderTarget(renderer, gui.spec1_tex) # ddt.rect_r(gui.spec_rect, colours.top_panel_background, True) ddt.rect((0, 0, gui.spec_w, gui.spec_h), colours.vis_bg) @@ -47565,7 +47413,7 @@ def drop_file(target): gui.bar.x = 0 on = 0 - SDL_SetRenderDrawColor( + sdl3.SDL_SetRenderDrawColor( renderer, colours.vis_colour[0], colours.vis_colour[1], colours.vis_colour[2], colours.vis_colour[3]) @@ -47590,15 +47438,15 @@ def drop_file(target): gui.bar.y = 0 + gui.spec_h - item gui.bar.h = item - SDL_RenderFillRect(renderer, gui.bar) + sdl3.SDL_RenderFillRect(renderer, gui.bar) gui.bar.x += round(4 * gui.scale) if pref_box.enabled: ddt.rect((0, 0, gui.spec_w, gui.spec_h), [0, 0, 0, 90]) - SDL_SetRenderTarget(renderer, None) - SDL_RenderCopy(renderer, gui.spec1_tex, None, gui.spec1_rec) + sdl3.SDL_SetRenderTarget(renderer, None) + sdl3.SDL_RenderTexture(renderer, gui.spec1_tex, None, gui.spec1_rec) if gui.vis == 1: @@ -47618,7 +47466,7 @@ def drop_file(target): else: tauon.level_train.clear() - SDL_SetRenderTarget(renderer, gui.spec_level_tex) + sdl3.SDL_SetRenderTarget(renderer, gui.spec_level_tex) x = window_size[0] - 20 * gui.scale - gui.offset_extra y = gui.level_y @@ -47772,16 +47620,16 @@ def drop_file(target): pass ddt.rect_a(((x - (w * t) - (s * t)), y), (w, w), cc) - SDL_SetRenderTarget(renderer, None) - SDL_RenderCopy(renderer, gui.spec_level_tex, None, gui.spec_level_rec) + sdl3.SDL_SetRenderTarget(renderer, None) + sdl3.SDL_RenderTexture(renderer, gui.spec_level_tex, None, gui.spec_level_rec) if gui.present: # Possible bug older version of SDL (2.0.16) Wayland, setting render target to None causer last copy # to fail when resizing? Not a big deal as it doesn't matter what the target is when presenting, just # set to something else - # SDL_SetRenderTarget(renderer, None) - SDL_SetRenderTarget(renderer, gui.main_texture) - SDL_RenderPresent(renderer) + # sdl3.SDL_SetRenderTarget(renderer, None) + sdl3.SDL_SetRenderTarget(renderer, gui.main_texture) + sdl3.SDL_RenderPresent(renderer) gui.present = False @@ -47838,15 +47686,15 @@ def drop_file(target): old_window_position = get_window_position() -SDL_DestroyTexture(gui.main_texture) -SDL_DestroyTexture(gui.tracklist_texture) -SDL_DestroyTexture(gui.spec2_tex) -SDL_DestroyTexture(gui.spec1_tex) -SDL_DestroyTexture(gui.spec_level_tex) +sdl3.SDL_DestroyTexture(gui.main_texture) +sdl3.SDL_DestroyTexture(gui.tracklist_texture) +sdl3.SDL_DestroyTexture(gui.spec2_tex) +sdl3.SDL_DestroyTexture(gui.spec1_tex) +sdl3.SDL_DestroyTexture(gui.spec_level_tex) ddt.clear_text_cache() clear_img_cache(False) -SDL_DestroyWindow(t_window) +sdl3.SDL_DestroyWindow(t_window) pctl.playerCommand = "unload" pctl.playerCommandReady = True @@ -47911,9 +47759,9 @@ def drop_file(target): logging.exception("No lock object to close") -IMG_Quit() -SDL_QuitSubSystem(SDL_INIT_EVERYTHING) -SDL_Quit() +#sdl3.IMG_Quit() +#sdl3.SDL_QuitSubSystem(sdl3.SDL_INIT_EVERYTHING) +sdl3.SDL_Quit() #logging.info("SDL unloaded") exit_timer = Timer() diff --git a/src/tauon/t_modules/t_themeload.py b/src/tauon/t_modules/t_themeload.py index 9596251b9..63730bb87 100644 --- a/src/tauon/t_modules/t_themeload.py +++ b/src/tauon/t_modules/t_themeload.py @@ -26,16 +26,6 @@ from typing import TYPE_CHECKING from PIL import Image -from sdl2 import ( - SDL_CreateTextureFromSurface, - SDL_DestroyTexture, - SDL_FreeSurface, - SDL_Rect, - SDL_RenderCopy, - SDL_SetTextureAlphaMod, - rw_from_object, -) -from sdl2.sdlimage import IMG_Load_RW from tauon.t_modules.t_extra import rgb_add_hls, test_lumi diff --git a/windows.spec b/windows.spec index 2068b211a..c8e4a0dd1 100644 --- a/windows.spec +++ b/windows.spec @@ -49,7 +49,7 @@ a = Analysis( ("TaskbarLib.tlb", "."), ("TauonSMTC.dll", "lib"), # This could only have SDL2.framework and SDL2_image.framework to save space... - (f".venv/lib/python{python_ver}/site-packages/sdl2dll/dll", "sdl2dll/dll"), +# (f".venv/lib/python{python_ver}/site-packages/sdl2dll/dll", "sdl2dll/dll"), ], hiddenimports=[ "pylast",