Skip to content

Commit

Permalink
Fix: Faild to enable on Blender 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
nutti committed Aug 24, 2023
1 parent 4a2ed30 commit d92aca0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/screencast_keys/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -319,25 +322,17 @@ 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.
imm.immLineWidth(line_thickness + 2.0 if shadow else line_thickness)
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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/screencast_keys/utils/compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import sys
import bpy
import blf


def check_version(major, minor, _):
Expand Down Expand Up @@ -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)

0 comments on commit d92aca0

Please sign in to comment.