From 3401ede7a5d780035b536ba21f0d12961fb69943 Mon Sep 17 00:00:00 2001 From: nutti Date: Thu, 24 Aug 2023 19:08:59 +0900 Subject: [PATCH] Fix: Faild to enable on Blender 3.3 (#177) --- src/screencast_keys/ops.py | 31 ++++++++++------------ src/screencast_keys/utils/compatibility.py | 8 ++++++ 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/screencast_keys/ops.py b/src/screencast_keys/ops.py index 572a31f..31de5f2 100644 --- a/src/screencast_keys/ops.py +++ b/src/screencast_keys/ops.py @@ -37,8 +37,11 @@ import gpu from . import common -from .common import (debug_print, fix_modifier_display_text, - output_debug_log, use_3d_polyline) +from .common import ( + debug_print, + fix_modifier_display_text, + output_debug_log +) from .utils.bl_class_registry import BlClassRegistry from .utils import compatibility as compat from . import c_structure as cstruct @@ -257,7 +260,7 @@ def circle_verts_num(r): for _ in range(n): x = x0 + r * math.cos(angle) y = y0 + r * math.sin(angle) - if not fill and use_3d_polyline(line_thickness): + if not fill: imm.immVertex3f(x, y, 0) else: imm.immVertex2f(x, y) @@ -319,12 +322,8 @@ def draw_line(p1, p2, color, shadow=False, shadow_color=None, imm.immLineWidth(line_thickness + 3.0) imm.immColor4f(*shadow_color) imm.immBegin(imm.GL_LINES) - if use_3d_polyline(line_thickness): - imm.immVertex3f(p1[0], p1[1], 0.0) - imm.immVertex3f(p2[0], p2[1], 0.0) - else: - imm.immVertex2f(*p1) - imm.immVertex2f(*p2) + imm.immVertex3f(p1[0], p1[1], 0.0) + imm.immVertex3f(p2[0], p2[1], 0.0) imm.immEnd() # Draw line. @@ -332,12 +331,8 @@ def draw_line(p1, p2, color, shadow=False, shadow_color=None, imm.immColor4f(*color) imm.immBegin(imm.GL_LINES) - if use_3d_polyline(line_thickness): - imm.immVertex3f(p1[0], p1[1], 0.0) - imm.immVertex3f(p2[0], p2[1], 0.0) - else: - imm.immVertex2f(*p1) - imm.immVertex2f(*p2) + imm.immVertex3f(p1[0], p1[1], 0.0) + imm.immVertex3f(p2[0], p2[1], 0.0) imm.immEnd() imm.immLineWidth(1.0) @@ -983,7 +978,8 @@ def draw_area_size(cls, context): font_size = prefs.font_size font_id = 0 # TODO: font_id should be constant. - blf.size(font_id, font_size) + dpi = user_prefs.system.dpi + compat.blf_size(font_id, font_size, dpi) # Calculate width/height of draw area. draw_area_width = 0 @@ -1410,7 +1406,8 @@ def draw_callback(cls, context): font_size = prefs.font_size font_id = 0 - blf.size(font_id, font_size) + dpi = user_prefs.system.dpi + compat.blf_size(font_id, font_size, dpi) # Clip 'TOOLS' and 'UI' region from 'WINDOW' region if need. # This prevents from drawing multiple time when diff --git a/src/screencast_keys/utils/compatibility.py b/src/screencast_keys/utils/compatibility.py index 11c8cdc..9701da1 100644 --- a/src/screencast_keys/utils/compatibility.py +++ b/src/screencast_keys/utils/compatibility.py @@ -20,6 +20,7 @@ import sys import bpy +import blf def check_version(major, minor, _): @@ -66,3 +67,10 @@ def add_if_exist(cls_name, space_name, space_types): add_if_exist("SpaceTimeline", 'TIMELINE', space_types) return space_types + + +def blf_size(font_id, font_size, dpi): + if check_version(3, 4, 0) >= 0: + blf.size(font_id, font_size) + else: + blf.size(font_id, font_size, dpi)