From 424f249d059c19073a2219b754314530ec1b2391 Mon Sep 17 00:00:00 2001 From: Taiko2k Date: Thu, 30 Jan 2025 16:28:54 +1300 Subject: [PATCH] tweak font rendering --- src/tauon/t_modules/t_draw.py | 14 +++++++++++--- src/tauon/t_modules/t_main.py | 16 ++++++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/tauon/t_modules/t_draw.py b/src/tauon/t_modules/t_draw.py index 64f37f0df..485d5dd31 100644 --- a/src/tauon/t_modules/t_draw.py +++ b/src/tauon/t_modules/t_draw.py @@ -532,6 +532,12 @@ def __draw_text_cairo( max_x = round(max_x) alpha_bg = self.alpha_bg + force_gray = self.force_gray + #real_bg = True + + if bg[3] < 200: + alpha_bg = True + force_gray = True x = round(location[0]) y = round(location[1]) @@ -599,7 +605,7 @@ def __draw_text_cairo( data = ctypes.c_buffer(b"\x00" * (h * (w * 4))) if real_bg: - box = sdl3.SDL_FRect(x, y - self.get_y_offset(text, font, max_x, wrap), w, h) + box = sdl3.SDL_Rect(x, y - self.get_y_offset(text, font, max_x, wrap), w, h) if align == 1: box.x = x - box.w @@ -607,7 +613,8 @@ def __draw_text_cairo( elif align == 2: box.x -= int(box.w / 2) - sdl3.SDL_RenderReadPixels(self.renderer, box, sdl3.SDL_PIXELFORMAT_RGB888, ctypes.pointer(data), (w * 4)) + ssurf = sdl3.SDL_RenderReadPixels(self.renderer, box) #, sdl3.SDL_PIXELFORMAT_XRGB8888, ctypes.pointer(data), (w * 4)) + data = ssurf.contents.pixels if alpha_bg: surf = cairo.ImageSurface.create_for_data(data, cairo.FORMAT_ARGB32, w, h) @@ -616,9 +623,10 @@ def __draw_text_cairo( context = cairo.Context(surf) - if self.force_gray: + if force_gray: options = context.get_font_options() options.set_antialias(cairo.ANTIALIAS_GRAY) + #options.set_hint_style(cairo.HINT_STYLE_NONE) context.set_font_options(options) elif self.force_subpixel_text: options = context.get_font_options() diff --git a/src/tauon/t_modules/t_main.py b/src/tauon/t_modules/t_main.py index 3a1e466fe..4b2ec24ba 100644 --- a/src/tauon/t_modules/t_main.py +++ b/src/tauon/t_modules/t_main.py @@ -4923,7 +4923,7 @@ def get_track_in_playlist(self, track_index: int, playlist_index: int) -> TrackC if playlist_index == -1: playlist_index = self.active_playlist_viewing try: - playlist = self.multi_playlist[playlist_index].playlist + playlist = self.multi_playlist[playlist_index].playlist_ids return self.get_track(playlist[track_index]) except IndexError: logging.exception("Failed getting track object by playlist_index and track_index!") @@ -36698,6 +36698,9 @@ def draw(self, x, y, w, h): # Background is insivible by default (for hightlighting if selected) bg = [0, 0, 0, 0] + if prefs.transparent_mode: + bg = rgb_add_hls(colours.playlist_box_background, 0, 0.09, 0) + bg[3] = 255 # Highlight if playlist selected (viewing) if i == pctl.active_playlist_viewing or (tab_menu.active and tab_menu.reference == i): @@ -36707,6 +36710,9 @@ def draw(self, x, y, w, h): bg = rgb_add_hls(colours.playlist_box_background, 0, 0.06, 0) if light_mode: bg = [0, 0, 0, 25] + if prefs.transparent_mode: + bg = rgb_add_hls(colours.playlist_box_background, 0, 0.03, 0) + bg[3] = 255 # Highlight target playlist when tragging tracks over if coll( @@ -37537,6 +37543,10 @@ def draw_card(self, artist, x, y, w): True): # or pctl.get_track(default_playlist[pctl.playlist_view_position]).artist == artist: ddt.rect(area, [50, 50, 50, 50]) bg = alpha_blend([50, 50, 50, 50], colours.side_panel_background) + if prefs.transparent_mode: + bg = rgb_add_hls(colours.playlist_box_background, 0, 0.2, 0) + ddt.rect(area, bg) + else: fade = 0 @@ -37552,6 +37562,8 @@ def draw_card(self, artist, x, y, w): ddt.rect(area, [50, 50, 50, fade]) bg = alpha_blend([50, 50, 50, fade], colours.side_panel_background) + if prefs.transparent_mode: + bg = colours.side_panel_background if prefs.artist_list_style == 1: self.draw_card_with_thumbnail(artist, x, y, w, area, thin_mode, line1_colour, line2_colour, light_mode, bg) @@ -44153,7 +44165,7 @@ def drop_file(target): colours.art_box[3] = 100 colours.window_frame[3] = 100 colours.bottom_panel_colour[3] = 190 - #colours.playlist_panel_background = aa + #colours.playlist_panel_background[3] = 220 #colours.playlist_box_background = [0, 0, 0, 100] prefs.theme_name = gui.theme_name