Blender Kitsu: Fix PyGPU Key #60

Merged
Nick Alberelli merged 1 commits from fix/blender-kitsu-PyGPU-keys into main 2023-05-30 14:31:32 +02:00

View File

@ -37,8 +37,10 @@ rect_coords = ((0, 0), (1, 0), (1, 1), (0, 1))
# elements does not make sense. # elements does not make sense.
# See register() and unregister(). # See register() and unregister().
if not bpy.app.background: if not bpy.app.background:
ucolor_2d_shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') ucolor_2d_shader = gpu.shader.from_builtin("UNIFORM_COLOR") # TEST THIS HOTFX
ucolor_2d_rect_batch = batch_for_shader(ucolor_2d_shader, 'TRI_FAN', {"pos": rect_coords}) ucolor_2d_rect_batch = batch_for_shader(
ucolor_2d_shader, "TRI_FAN", {"pos": rect_coords}
)
Float2 = typing.Tuple[float, float] Float2 = typing.Tuple[float, float]
@ -92,7 +94,6 @@ def draw_line_in_strip(strip_coords: Float4, height_factor: float, color: Float4
def draw_callback_px(): def draw_callback_px():
context = bpy.context context = bpy.context
sqe = context.scene.sequence_editor sqe = context.scene.sequence_editor
if not sqe: if not sqe:
@ -105,7 +106,9 @@ def draw_callback_px():
if strip.kitsu.initialized or strip.kitsu.linked: if strip.kitsu.initialized or strip.kitsu.linked:
try: try:
color = tuple(context.scene.kitsu.sequence_colors[strip.kitsu.sequence_id].color) color = tuple(
context.scene.kitsu.sequence_colors[strip.kitsu.sequence_id].color
)
except KeyError: except KeyError:
color = (1, 1, 1) color = (1, 1, 1)
@ -126,7 +129,11 @@ def register():
if bpy.app.background: if bpy.app.background:
# Do not register anything if Blender runs in the background (no UI needed). # Do not register anything if Blender runs in the background (no UI needed).
return return
draw_handles.append(bpy.types.SpaceSequenceEditor.draw_handler_add(draw_callback_px, (), "WINDOW", "POST_VIEW")) draw_handles.append(
bpy.types.SpaceSequenceEditor.draw_handler_add(
draw_callback_px, (), "WINDOW", "POST_VIEW"
)
)
def unregister(): def unregister():
@ -134,7 +141,7 @@ def unregister():
return return
for handle in reversed(draw_handles): for handle in reversed(draw_handles):
try: try:
bpy.types.SpaceSequenceEditor.draw_handler_remove(handle, 'WINDOW') bpy.types.SpaceSequenceEditor.draw_handler_remove(handle, "WINDOW")
except ValueError: except ValueError:
# Not sure why, but sometimes the handler seems to already be removed...?? # Not sure why, but sometimes the handler seems to already be removed...??
pass pass