Skip to content

Commit

Permalink
fix: ensure update_overlay function is called after every event type
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm committed Jan 28, 2022
1 parent c7e4d2c commit c5d59b0
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 32 deletions.
8 changes: 3 additions & 5 deletions blank_sketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ class ND_OT_blank_sketch(bpy.types.Operator):


def modal(self, context, event):
if not self.pin_overlay and event.type == 'MOUSEMOVE':
update_overlay(self, context, event)

elif event.type == 'P' and event.value == 'PRESS':
if event.type == 'P' and event.value == 'PRESS':
self.pin_overlay = not self.pin_overlay
update_overlay(self, context, event, pinned=self.pin_overlay, x_offset=280, lines=1)

elif event.type == 'SPACE':
self.finish(context)
Expand All @@ -41,6 +37,8 @@ def modal(self, context, event):
elif event.type == 'MIDDLEMOUSE' or (event.alt and event.type in {'LEFTMOUSE', 'RIGHTMOUSE'}) or event.type.startswith('NDOF'):
return {'PASS_THROUGH'}

update_overlay(self, context, event, pinned=self.pin_overlay, x_offset=280, lines=1)

return {'RUNNING_MODAL'}


Expand Down
9 changes: 3 additions & 6 deletions bolt.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ def modal(self, context, event):
self.key_alt = event.alt
self.key_ctrl = event.ctrl

if not self.pin_overlay and event.type == 'MOUSEMOVE':
update_overlay(self, context, event)

elif event.type == 'P' and event.value == 'PRESS':
if event.type == 'P' and event.value == 'PRESS':
self.pin_overlay = not self.pin_overlay
update_overlay(self, context, event, pinned=self.pin_overlay, x_offset=375, lines=4)

elif event.type in {'PLUS', 'EQUAL', 'NUMPAD_PLUS'} and event.value == 'PRESS':
if event.alt and event.ctrl:
Expand Down Expand Up @@ -77,8 +73,9 @@ def modal(self, context, event):

elif event.type == 'MIDDLEMOUSE' or (event.alt and event.type in {'LEFTMOUSE', 'RIGHTMOUSE'}) or event.type.startswith('NDOF'):
return {'PASS_THROUGH'}

self.operate(context)
update_overlay(self, context, event, pinned=self.pin_overlay, x_offset=375, lines=4)

return {'RUNNING_MODAL'}

Expand Down
8 changes: 2 additions & 6 deletions screw.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ def modal(self, context, event):
self.key_alt = event.alt
self.key_ctrl = event.ctrl

if not self.pin_overlay and event.type == 'MOUSEMOVE':
update_overlay(self, context, event)

elif event.type == 'P' and event.value == 'PRESS':
if event.type == 'P' and event.value == 'PRESS':
self.pin_overlay = not self.pin_overlay
update_overlay(self, context, event, pinned=self.pin_overlay, x_offset=360, lines=4)

elif event.type in {'PLUS', 'EQUAL', 'NUMPAD_PLUS'} and event.value == 'PRESS':
if event.alt and event.ctrl:
Expand All @@ -47,7 +43,6 @@ def modal(self, context, event):
self.angle = min(360, self.angle + angle_factor)
else:
self.segments = 4 if self.segments == 3 else self.segments + segment_factor


elif event.type == 'WHEELDOWNMOUSE':
if event.alt and event.ctrl:
Expand Down Expand Up @@ -76,6 +71,7 @@ def modal(self, context, event):
return {'PASS_THROUGH'}

self.operate(context)
update_overlay(self, context, event, pinned=self.pin_overlay, x_offset=360, lines=4)

return {'RUNNING_MODAL'}

Expand Down
7 changes: 2 additions & 5 deletions solidify.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ def modal(self, context, event):
self.key_shift = event.shift
self.key_alt = event.alt

if not self.pin_overlay and event.type == 'MOUSEMOVE':
update_overlay(self, context, event)

elif event.type == 'P' and event.value == 'PRESS':
if event.type == 'P' and event.value == 'PRESS':
self.pin_overlay = not self.pin_overlay
update_overlay(self, context, event, pinned=self.pin_overlay, x_offset=260, lines=2)

elif event.type in {'PLUS', 'EQUAL', 'NUMPAD_PLUS'} and event.value == 'PRESS':
self.base_thickness_factor = min(1, self.base_thickness_factor * 10.0)
Expand Down Expand Up @@ -56,6 +52,7 @@ def modal(self, context, event):
return {'PASS_THROUGH'}

self.operate(context)
update_overlay(self, context, event, pinned=self.pin_overlay, x_offset=260, lines=2)

return {'RUNNING_MODAL'}

Expand Down
7 changes: 2 additions & 5 deletions vertex_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ def modal(self, context, event):
self.key_shift = event.shift
self.key_alt = event.alt

if not self.pin_overlay and event.type == 'MOUSEMOVE':
update_overlay(self, context, event)

elif event.type == 'P' and event.value == 'PRESS':
if event.type == 'P' and event.value == 'PRESS':
self.pin_overlay = not self.pin_overlay
update_overlay(self, context, event, pinned=self.pin_overlay, x_offset=300, lines=2)

elif event.type in {'PLUS', 'EQUAL', 'NUMPAD_PLUS'} and event.value == 'PRESS':
self.base_width_factor = min(1, self.base_width_factor * 10.0)
Expand Down Expand Up @@ -56,6 +52,7 @@ def modal(self, context, event):
return {'PASS_THROUGH'}

self.operate(context)
update_overlay(self, context, event, pinned=self.pin_overlay, x_offset=300, lines=2)

return {'RUNNING_MODAL'}

Expand Down
7 changes: 2 additions & 5 deletions weighted_normal_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@ def modal(self, context, event):

self.key_shift = event.shift

if not self.pin_overlay and event.type == 'MOUSEMOVE':
update_overlay(self, context, event)

elif event.type == 'P' and event.value == 'PRESS':
if event.type == 'P' and event.value == 'PRESS':
self.pin_overlay = not self.pin_overlay
update_overlay(self, context, event, pinned=self.pin_overlay, x_offset=270, lines=1)

elif event.type in {'PLUS', 'EQUAL', 'NUMPAD_PLUS'} and event.value == 'PRESS':
self.base_width_factor = min(1, self.base_width_factor * 10.0)
Expand Down Expand Up @@ -49,6 +45,7 @@ def modal(self, context, event):
return {'PASS_THROUGH'}

self.operate(context)
update_overlay(self, context, event, pinned=self.pin_overlay, x_offset=270, lines=1)

return {'RUNNING_MODAL'}

Expand Down

0 comments on commit c5d59b0

Please sign in to comment.