Reformat with Black
No functional changes.
This commit is contained in:
@@ -29,17 +29,17 @@ log = logging.getLogger(__name__)
|
||||
|
||||
strip_status_colour = {
|
||||
None: (0.7, 0.7, 0.7),
|
||||
'approved': (0.6392156862745098, 0.8784313725490196, 0.30196078431372547),
|
||||
'final': (0.9058823529411765, 0.9607843137254902, 0.8274509803921568),
|
||||
'in_progress': (1.0, 0.7450980392156863, 0.0),
|
||||
'on_hold': (0.796078431372549, 0.6196078431372549, 0.08235294117647059),
|
||||
'review': (0.8941176470588236, 0.9607843137254902, 0.9764705882352941),
|
||||
'todo': (1.0, 0.5019607843137255, 0.5019607843137255)
|
||||
"approved": (0.6392156862745098, 0.8784313725490196, 0.30196078431372547),
|
||||
"final": (0.9058823529411765, 0.9607843137254902, 0.8274509803921568),
|
||||
"in_progress": (1.0, 0.7450980392156863, 0.0),
|
||||
"on_hold": (0.796078431372549, 0.6196078431372549, 0.08235294117647059),
|
||||
"review": (0.8941176470588236, 0.9607843137254902, 0.9764705882352941),
|
||||
"todo": (1.0, 0.5019607843137255, 0.5019607843137255),
|
||||
}
|
||||
|
||||
CONFLICT_COLOUR = (0.576, 0.118, 0.035, 1.0) # RGBA tuple
|
||||
|
||||
gpu_vertex_shader = '''
|
||||
gpu_vertex_shader = """
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
|
||||
layout (location = 0) in vec2 pos;
|
||||
@@ -52,9 +52,9 @@ void main()
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(pos.x, pos.y, 0.0, 1.0);
|
||||
lineColor = color;
|
||||
}
|
||||
'''
|
||||
"""
|
||||
|
||||
gpu_fragment_shader = '''
|
||||
gpu_fragment_shader = """
|
||||
out vec4 fragColor;
|
||||
in vec4 lineColor;
|
||||
|
||||
@@ -62,7 +62,7 @@ void main()
|
||||
{
|
||||
fragColor = lineColor;
|
||||
}
|
||||
'''
|
||||
"""
|
||||
|
||||
Float2 = typing.Tuple[float, float]
|
||||
Float3 = typing.Tuple[float, float, float]
|
||||
@@ -70,25 +70,18 @@ Float4 = typing.Tuple[float, float, float, float]
|
||||
|
||||
|
||||
class AttractLineDrawer:
|
||||
|
||||
def __init__(self):
|
||||
self._format = gpu.types.GPUVertFormat()
|
||||
self._pos_id = self._format.attr_add(
|
||||
id="pos",
|
||||
comp_type="F32",
|
||||
len=2,
|
||||
fetch_mode="FLOAT")
|
||||
id="pos", comp_type="F32", len=2, fetch_mode="FLOAT"
|
||||
)
|
||||
self._color_id = self._format.attr_add(
|
||||
id="color",
|
||||
comp_type="F32",
|
||||
len=4,
|
||||
fetch_mode="FLOAT")
|
||||
id="color", comp_type="F32", len=4, fetch_mode="FLOAT"
|
||||
)
|
||||
|
||||
self.shader = gpu.types.GPUShader(gpu_vertex_shader, gpu_fragment_shader)
|
||||
|
||||
def draw(self,
|
||||
coords: typing.List[Float2],
|
||||
colors: typing.List[Float4]):
|
||||
def draw(self, coords: typing.List[Float2], colors: typing.List[Float4]):
|
||||
if not coords:
|
||||
return
|
||||
|
||||
@@ -114,11 +107,13 @@ def get_strip_rectf(strip) -> Float4:
|
||||
return x1, y1, x2, y2
|
||||
|
||||
|
||||
def underline_in_strip(strip_coords: Float4,
|
||||
pixel_size_x: float,
|
||||
color: Float4,
|
||||
out_coords: typing.List[Float2],
|
||||
out_colors: typing.List[Float4]):
|
||||
def underline_in_strip(
|
||||
strip_coords: Float4,
|
||||
pixel_size_x: float,
|
||||
color: Float4,
|
||||
out_coords: typing.List[Float2],
|
||||
out_colors: typing.List[Float4],
|
||||
):
|
||||
# Strip coords
|
||||
s_x1, s_y1, s_x2, s_y2 = strip_coords
|
||||
|
||||
@@ -142,9 +137,11 @@ def underline_in_strip(strip_coords: Float4,
|
||||
out_colors.append(color)
|
||||
|
||||
|
||||
def strip_conflict(strip_coords: Float4,
|
||||
out_coords: typing.List[Float2],
|
||||
out_colors: typing.List[Float4]):
|
||||
def strip_conflict(
|
||||
strip_coords: Float4,
|
||||
out_coords: typing.List[Float2],
|
||||
out_colors: typing.List[Float4],
|
||||
):
|
||||
"""Draws conflicting states between strips."""
|
||||
|
||||
s_x1, s_y1, s_x2, s_y2 = strip_coords
|
||||
@@ -191,8 +188,12 @@ def draw_callback_px(line_drawer: AttractLineDrawer):
|
||||
strip_coords = get_strip_rectf(strip)
|
||||
|
||||
# check if any of the coordinates are out of bounds
|
||||
if strip_coords[0] > xwin2 or strip_coords[2] < xwin1 or strip_coords[1] > ywin2 or \
|
||||
strip_coords[3] < ywin1:
|
||||
if (
|
||||
strip_coords[0] > xwin2
|
||||
or strip_coords[2] < xwin1
|
||||
or strip_coords[1] > ywin2
|
||||
or strip_coords[3] < ywin1
|
||||
):
|
||||
continue
|
||||
|
||||
# Draw
|
||||
@@ -217,9 +218,9 @@ def tag_redraw_all_sequencer_editors():
|
||||
# Py cant access notifiers
|
||||
for window in context.window_manager.windows:
|
||||
for area in window.screen.areas:
|
||||
if area.type == 'SEQUENCE_EDITOR':
|
||||
if area.type == "SEQUENCE_EDITOR":
|
||||
for region in area.regions:
|
||||
if region.type == 'WINDOW':
|
||||
if region.type == "WINDOW":
|
||||
region.tag_redraw()
|
||||
|
||||
|
||||
@@ -237,8 +238,11 @@ def callback_enable():
|
||||
return
|
||||
|
||||
line_drawer = AttractLineDrawer()
|
||||
cb_handle[:] = bpy.types.SpaceSequenceEditor.draw_handler_add(
|
||||
draw_callback_px, (line_drawer,), 'WINDOW', 'POST_VIEW'),
|
||||
cb_handle[:] = (
|
||||
bpy.types.SpaceSequenceEditor.draw_handler_add(
|
||||
draw_callback_px, (line_drawer,), "WINDOW", "POST_VIEW"
|
||||
),
|
||||
)
|
||||
|
||||
tag_redraw_all_sequencer_editors()
|
||||
|
||||
@@ -248,7 +252,7 @@ def callback_disable():
|
||||
return
|
||||
|
||||
try:
|
||||
bpy.types.SpaceSequenceEditor.draw_handler_remove(cb_handle[0], 'WINDOW')
|
||||
bpy.types.SpaceSequenceEditor.draw_handler_remove(cb_handle[0], "WINDOW")
|
||||
except ValueError:
|
||||
# Thrown when already removed.
|
||||
pass
|
||||
|
Reference in New Issue
Block a user