Skip to content

Commit

Permalink
feat: add overlay pinning option for all operators
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm committed Jan 26, 2022
1 parent 471126a commit 8bff7c4
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 7 deletions.
7 changes: 6 additions & 1 deletion bolt.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ def modal(self, context, event):
self.key_alt = event.alt
self.key_ctrl = event.ctrl

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

elif 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 == 'WHEELUPMOUSE':
if event.alt and event.ctrl:
self.offset += offset_factor
Expand Down Expand Up @@ -85,6 +89,7 @@ def invoke(self, context, event):
self.add_solidify_modifier()
self.set_cutter_visibility(context)

self.pin_overlay = False
init_overlay(self, event)
register_draw_handler(self, draw_text_callback)

Expand Down
7 changes: 6 additions & 1 deletion faux_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ def modal(self, context, event):

self.key_shift = event.shift

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

elif 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 == 'WHEELUPMOUSE':
self.width += width_factor
Expand Down Expand Up @@ -52,6 +56,7 @@ def invoke(self, context, event):
self.add_bevel_modifier(context)
self.add_weighted_normal_modifer(context)

self.pin_overlay = False
init_overlay(self, event)
register_draw_handler(self, draw_text_callback)

Expand Down
10 changes: 9 additions & 1 deletion new_sketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@ class ND_OT_new_sketch(bpy.types.Operator):


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

elif 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)

return {'FINISHED'}

elif event.alt and event.type == 'Z' and event.value == 'PRESS':
return {'PASS_THROUGH'}

elif event.type in {'LEFTMOUSE', 'E', 'G', 'WHEELUPMOUSE', 'WHEELDOWNMOUSE'} or event.ctrl:
return {'PASS_THROUGH'}

Expand All @@ -40,6 +47,7 @@ def invoke(self, context, event):

self.start_sketch_editing(context)

self.pin_overlay = False
init_overlay(self, event)
register_draw_handler(self, draw_text_callback)

Expand Down
6 changes: 5 additions & 1 deletion overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ def init_overlay(self, event):
self.overlay_y = event.mouse_y - self.region_offset_y + self.overlay_offset_y


def update_overlay(self, context, event):
def update_overlay(self, context, event, pinned=False, x_offset=400, lines=1):
self.overlay_x = event.mouse_x - self.region_offset_x + self.overlay_offset_x
self.overlay_y = event.mouse_y - self.region_offset_y + self.overlay_offset_y

if pinned:
self.overlay_x = context.region.width - x_offset
self.overlay_y = 45 + (lines * self.line_spacer)

region_buffer = 5

if event.mouse_region_x <= 0:
Expand Down
7 changes: 6 additions & 1 deletion sketch_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ def modal(self, context, event):
self.key_shift = event.shift
self.key_alt = event.alt

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

elif 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 == 'WHEELUPMOUSE':
if event.alt:
self.width += width_factor
Expand Down Expand Up @@ -60,6 +64,7 @@ def invoke(self, context, event):
self.add_vertex_group(context)
self.add_bevel_modifier(context)

self.pin_overlay = False
init_overlay(self, event)
register_draw_handler(self, draw_text_callback)

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

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

elif 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 == 'WHEELUPMOUSE':
if event.alt:
Expand Down Expand Up @@ -60,6 +64,7 @@ def invoke(self, context, event):
self.add_smooth_shading(context)
self.add_solidify_modifier(context)

self.pin_overlay = False
init_overlay(self, event)
register_draw_handler(self, draw_text_callback)

Expand Down
7 changes: 6 additions & 1 deletion view_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ class ND_OT_view_align(bpy.types.Operator):


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

elif 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 == 'LEFTMOUSE':
return {'PASS_THROUGH'}
Expand All @@ -37,6 +41,7 @@ def modal(self, context, event):
def invoke(self, context, event):
self.prepare_face_selection_mode(context)

self.pin_overlay = False
init_overlay(self, event)
register_draw_handler(self, draw_text_callback)

Expand Down

0 comments on commit 8bff7c4

Please sign in to comment.