diff --git a/operators/mouse_cut.py b/operators/mouse_cut.py index 57664010..3136b848 100644 --- a/operators/mouse_cut.py +++ b/operators/mouse_cut.py @@ -12,7 +12,6 @@ from .utils.draw import draw_line, draw_arrow_head, get_color_gizmo_primary from .utils.doc import doc_name, doc_idname, doc_brief, doc_description - if not bpy.app.background: SHADER = gpu.shader.from_builtin("2D_UNIFORM_COLOR") @@ -344,28 +343,17 @@ def draw( bgl.glLineWidth(3) draw_line(SHADER, start, end, color) - draw_line(SHADER, Vector((start.x, min_bottom)), Vector( - (start.x, max_top)), color) - draw_line(SHADER, Vector((end.x, min_bottom)), Vector((end.x, max_top)), - color) + draw_line(SHADER, Vector((start.x, min_bottom)), Vector((start.x, max_top)), color) + draw_line(SHADER, Vector((end.x, min_bottom)), Vector((end.x, max_top)), color) if draw_arrows: - first_arrow_center = Vector( - [start.x + ((end.x - start.x) * 0.25), start.y]) - second_arrow_center = Vector( - [end.x - ((end.x - start.x) * 0.25), start.y]) + first_arrow_center = Vector([start.x + ((end.x - start.x) * 0.25), start.y]) + second_arrow_center = Vector([end.x - ((end.x - start.x) * 0.25), start.y]) arrow_size = Vector([10, 20]) bgl.glLineWidth(6) - draw_arrow_head(SHADER, - first_arrow_center, - arrow_size, - color=color) - draw_arrow_head(SHADER, - second_arrow_center, - arrow_size, - points_right=False, - color=color) + draw_arrow_head(SHADER, first_arrow_center, arrow_size, color=color) + draw_arrow_head(SHADER, second_arrow_center, arrow_size, points_right=False, color=color) bgl.glLineWidth(1) bgl.glDisable(bgl.GL_BLEND) diff --git a/operators/mouse_trim.py b/operators/mouse_trim.py index 12f0deab..26d3e078 100644 --- a/operators/mouse_trim.py +++ b/operators/mouse_trim.py @@ -112,7 +112,6 @@ def invoke(self, context, event): else: context.scene.frame_current = self.frame_start if self.frame_start else frame - # FIXME: Workaround Blender 2.80's audio bug, remove when fixed in Blender for s in bpy.context.sequences: if s.lock: diff --git a/operators/utils/draw.py b/operators/utils/draw.py index 8af36438..7afa9d93 100644 --- a/operators/utils/draw.py +++ b/operators/utils/draw.py @@ -40,34 +40,33 @@ def draw_line(shader, start, end, color=(1.0, 1.0, 1.0, 1.0)): def draw_rectangle(shader, origin, size, color=(1.0, 1.0, 1.0, 1.0)): - vertices = ((origin.x, origin.y), (origin.x + size.x, origin.y), - (origin.x, origin.y + size.y), (origin.x + size.x, - origin.y + size.y)) + vertices = ( + (origin.x, origin.y), + (origin.x + size.x, origin.y), + (origin.x, origin.y + size.y), + (origin.x + size.x, origin.y + size.y), + ) indices = ((0, 1, 2), (2, 1, 3)) - batch = batch_for_shader(shader, - 'TRIS', {"pos": vertices}, - indices=indices) + batch = batch_for_shader(shader, "TRIS", {"pos": vertices}, indices=indices) shader.bind() - shader.uniform_float('color', color) + shader.uniform_float("color", color) batch.draw(shader) def draw_triangle(point_1, point_2, point_3, color=(1.0, 1.0, 1.0, 1.0)): vertices = (point_1, point_2, point_3) - indices = ((0, 1, 2), ) - shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') - batch = batch_for_shader(shader, - 'TRIS', {"pos": vertices}, - indices=indices) + indices = ((0, 1, 2),) + shader = gpu.shader.from_builtin("2D_UNIFORM_COLOR") + batch = batch_for_shader(shader, "TRIS", {"pos": vertices}, indices=indices) shader.bind() - shader.uniform_float('color', color) + shader.uniform_float("color", color) batch.draw(shader) -def draw_text(x, y, size, text, justify='left', color=(1.0, 1.0, 1.0, 1.0)): +def draw_text(x, y, size, text, justify="left", color=(1.0, 1.0, 1.0, 1.0)): font_id = 0 blf.color(font_id, *color) - if justify == 'right': + if justify == "right": text_width, text_height = blf.dimensions(font_id, text) else: text_width = 0 @@ -76,11 +75,7 @@ def draw_text(x, y, size, text, justify='left', color=(1.0, 1.0, 1.0, 1.0)): blf.draw(font_id, text) -def draw_arrow_head(shader, - center, - size, - points_right=True, - color=(1.0, 1.0, 1.0, 1.0)): +def draw_arrow_head(shader, center, size, points_right=True, color=(1.0, 1.0, 1.0, 1.0)): """ Draws a triangular arrow using two Vectors: - the triangle's center @@ -88,11 +83,9 @@ def draw_arrow_head(shader, """ direction = 1 if points_right else -1 - point_upper = Vector( - [center.x - size.x / 2 * direction, center.y + size.y / 2]) + point_upper = Vector([center.x - size.x / 2 * direction, center.y + size.y / 2]) point_tip = Vector([center.x + size.x / 2 * direction, center.y]) - point_lower = Vector( - [center.x - size.x / 2 * direction, center.y - size.y / 2]) + point_lower = Vector([center.x - size.x / 2 * direction, center.y - size.y / 2]) draw_line(shader, point_upper, point_tip, color) draw_line(shader, point_tip, point_lower, color)