Skip to content

Commit

Permalink
feat: replace overlay fixed pin location with pin-in-place functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm committed Mar 27, 2022
1 parent f34b62d commit 2763a33
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 99 deletions.
10 changes: 3 additions & 7 deletions generators/ring_and_bolt.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ def modal(self, context, event):
toggle_operator_passthrough(self)

elif self.key_toggle_pin_overlay:
toggle_pin_overlay(self)
toggle_pin_overlay(self, event)

elif self.key_cancel:
self.revert(context)

return {'CANCELLED'}

elif self.operator_passthrough:
self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'PASS_THROUGH'}

Expand Down Expand Up @@ -81,15 +81,11 @@ def modal(self, context, event):
return {'PASS_THROUGH'}

self.operate(context)
self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'RUNNING_MODAL'}


def update_overlay_wrapper(self, context, event):
update_overlay(self, context, event, x_offset=300, lines=3)


def invoke(self, context, event):
self.base_inner_radius_factor = 0.001
self.base_width_factor = 0.001
Expand Down
10 changes: 3 additions & 7 deletions generators/screw_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ def modal(self, context, event):
toggle_operator_passthrough(self)

elif self.key_toggle_pin_overlay:
toggle_pin_overlay(self)
toggle_pin_overlay(self, event)

elif self.key_cancel:
self.revert(context)

return {'CANCELLED'}

elif self.operator_passthrough:
self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'PASS_THROUGH'}

Expand Down Expand Up @@ -80,14 +80,10 @@ def modal(self, context, event):
return {'PASS_THROUGH'}

self.operate(context)
self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'RUNNING_MODAL'}


def update_overlay_wrapper(self, context, event):
update_overlay(self, context, event, x_offset=290, lines=3)


def invoke(self, context, event):
self.base_offset_factor = 0.01
Expand Down
45 changes: 23 additions & 22 deletions lib/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def redraw_regions():
region.tag_redraw()


def toggle_pin_overlay(cls):
def toggle_pin_overlay(cls, event):
cls.overlay_x = event.mouse_x - cls.region_offset_x + cls.overlay_offset_x
cls.overlay_y = event.mouse_y - cls.region_offset_y + cls.overlay_offset_y

cls.pin_overlay = not cls.pin_overlay


Expand All @@ -56,41 +59,39 @@ def init_overlay(cls, event):
cls.operator_passthrough = False


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

if cls.pin_overlay:
cls.overlay_x = context.region.width - x_offset
cls.overlay_y = 45 + (lines * cls.line_spacer)
def update_overlay(cls, context, event):
if not cls.pin_overlay:
cls.overlay_x = event.mouse_x - cls.region_offset_x + cls.overlay_offset_x
cls.overlay_y = event.mouse_y - cls.region_offset_y + cls.overlay_offset_y

redraw_regions()


def draw_header(cls):
is_summoned = getattr(cls, "summoned", False)

if cls.operator_passthrough:
blf.size(0, 12, 72)
blf.color(0, 238/255, 59/255, 43/255, 1.0)
blf.position(0, cls.overlay_x + 1, cls.overlay_y + 26, 0)
blf.draw(0, "PAUSE")

if is_summoned and not cls.operator_passthrough:
blf.size(0, 12, 72)
blf.color(0, 82/255, 224/255, 82/255, 1.0)
blf.position(0, cls.overlay_x + 1, cls.overlay_y + 26, 0)
blf.draw(0, "RECALL")

blf.size(0, 24, 72)

if cls.operator_passthrough:
blf.color(0, 238/255, 59/255, 43/255, 1.0)
elif is_summoned and not cls.operator_passthrough:
blf.color(0, 82/255, 224/255, 82/255, 1.0)
else:
blf.color(0, 255/255, 135/255, 55/255, 1.0)

if cls.operator_passthrough or is_summoned or cls.pin_overlay:
blf.size(0, 11, 72)
blf.position(0, cls.overlay_x + 1, cls.overlay_y + 26, 0)

states = []
if cls.operator_passthrough:
states.append("PAUSED")
if is_summoned:
states.append("RECALL")
if cls.pin_overlay:
states.append("PINNED")

blf.draw(0, " // ".join(states))

blf.size(0, 24, 72)
blf.position(0, cls.overlay_x, cls.overlay_y, 0)
blf.draw(0, "ND — " + cls.bl_label)

Expand Down
10 changes: 3 additions & 7 deletions power_mods/screw.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ def modal(self, context, event):
toggle_operator_passthrough(self)

elif self.key_toggle_pin_overlay:
toggle_pin_overlay(self)
toggle_pin_overlay(self, event)

elif self.key_cancel:
self.revert(context)

return {'CANCELLED'}

elif self.operator_passthrough:
self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'PASS_THROUGH'}

Expand Down Expand Up @@ -83,14 +83,10 @@ def modal(self, context, event):
return {'PASS_THROUGH'}

self.operate(context)
self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'RUNNING_MODAL'}


def update_overlay_wrapper(self, context, event):
update_overlay(self, context, event, x_offset=340, lines=4)


def invoke(self, context, event):
self.base_offset_factor = 0.01
Expand Down
10 changes: 3 additions & 7 deletions power_mods/solidify.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ def modal(self, context, event):
toggle_operator_passthrough(self)

elif self.key_toggle_pin_overlay:
toggle_pin_overlay(self)
toggle_pin_overlay(self, event)

elif self.key_cancel:
self.revert(context)

return {'CANCELLED'}

elif self.operator_passthrough:
self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'PASS_THROUGH'}

Expand Down Expand Up @@ -76,14 +76,10 @@ def modal(self, context, event):
return {'PASS_THROUGH'}

self.operate(context)
self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'RUNNING_MODAL'}


def update_overlay_wrapper(self, context, event):
update_overlay(self, context, event, x_offset=300, lines=3)


def invoke(self, context, event):
self.base_thickness_factor = 0.01
Expand Down
10 changes: 3 additions & 7 deletions power_mods/vertex_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ def modal(self, context, event):
toggle_operator_passthrough(self)

elif self.key_toggle_pin_overlay:
toggle_pin_overlay(self)
toggle_pin_overlay(self, event)

elif self.key_cancel:
self.revert(context)

return {'CANCELLED'}

elif self.operator_passthrough:
self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'PASS_THROUGH'}

Expand Down Expand Up @@ -76,14 +76,10 @@ def modal(self, context, event):
return {'PASS_THROUGH'}

self.operate(context)
self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'RUNNING_MODAL'}


def update_overlay_wrapper(self, context, event):
update_overlay(self, context, event, x_offset=300, lines=3)


def invoke(self, context, event):
self.base_width_factor = 0.01
Expand Down
10 changes: 3 additions & 7 deletions power_mods/weighted_normal_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ def modal(self, context, event):
toggle_operator_passthrough(self)

elif self.key_toggle_pin_overlay:
toggle_pin_overlay(self)
toggle_pin_overlay(self, event)

elif self.key_cancel:
self.revert(context)

return {'CANCELLED'}

elif self.operator_passthrough:
self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'PASS_THROUGH'}

Expand All @@ -59,14 +59,10 @@ def modal(self, context, event):
return {'PASS_THROUGH'}

self.operate(context)
self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'RUNNING_MODAL'}


def update_overlay_wrapper(self, context, event):
update_overlay(self, context, event, x_offset=270, lines=1)


def invoke(self, context, event):
self.base_width_factor = 0.001
Expand Down
10 changes: 3 additions & 7 deletions sketching/blank_sketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ def modal(self, context, event):
toggle_operator_passthrough(self)

elif self.key_toggle_pin_overlay:
toggle_pin_overlay(self)
toggle_pin_overlay(self, event)

elif self.key_cancel:
self.revert(context)

return {'CANCELLED'}

elif self.operator_passthrough:
self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'PASS_THROUGH'}

Expand All @@ -39,15 +39,11 @@ def modal(self, context, event):
elif self.key_movement_passthrough:
return {'PASS_THROUGH'}

self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'RUNNING_MODAL'}


def update_overlay_wrapper(self, context, event):
update_overlay(self, context, event, x_offset=280, lines=1)


def invoke(self, context, event):
add_single_vertex_object(self, context, "Sketch")
align_object_to_3d_cursor(self, context)
Expand Down
10 changes: 3 additions & 7 deletions sketching/geo_lift.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def modal(self, context, event):
toggle_operator_passthrough(self)

elif self.key_toggle_pin_overlay:
toggle_pin_overlay(self)
toggle_pin_overlay(self, event)

elif self.key_cancel:
self.clean_up(context)
Expand Down Expand Up @@ -49,7 +49,7 @@ def modal(self, context, event):
self.set_selection_mode(context)

elif self.operator_passthrough:
self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'PASS_THROUGH'}

Expand All @@ -62,14 +62,10 @@ def modal(self, context, event):
elif self.key_movement_passthrough:
return {'PASS_THROUGH'}

self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'RUNNING_MODAL'}


def update_overlay_wrapper(self, context, event):
update_overlay(self, context, event, x_offset=260, lines=2)


def invoke(self, context, event):
self.selection_type = 2 # ['VERT', 'EDGE', 'FACE']
Expand Down
10 changes: 3 additions & 7 deletions sketching/view_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ def modal(self, context, event):
toggle_operator_passthrough(self)

elif self.key_toggle_pin_overlay:
toggle_pin_overlay(self)
toggle_pin_overlay(self, event)

elif self.key_cancel:
self.clean_up(context)

return {'CANCELLED'}

elif self.operator_passthrough:
self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'PASS_THROUGH'}

Expand Down Expand Up @@ -63,14 +63,10 @@ def modal(self, context, event):
elif self.key_movement_passthrough:
return {'PASS_THROUGH'}

self.update_overlay_wrapper(context, event)
update_overlay(self, context, event)

return {'RUNNING_MODAL'}


def update_overlay_wrapper(self, context, event):
update_overlay(self, context, event, x_offset=320, lines=2)


def invoke(self, context, event):
self.selection_type = 2 # ['VERT', 'EDGE', 'FACE']
Expand Down
Loading

0 comments on commit 2763a33

Please sign in to comment.