Skip to content

Commit

Permalink
feat: add mouse-value support to all non-keybound operator options
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm authored Nov 13, 2022
1 parent 9b9d7d8 commit 99b21a6
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 10 deletions.
9 changes: 8 additions & 1 deletion booleans/hydrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import bmesh
from .. lib.overlay import update_overlay, init_overlay, toggle_pin_overlay, toggle_operator_passthrough, register_draw_handler, unregister_draw_handler, draw_header, draw_property, draw_hint
from .. lib.events import capture_modifier_keys, pressed
from .. lib.preferences import get_preferences


class ND_OT_hydrate(bpy.types.Operator):
Expand Down Expand Up @@ -72,6 +73,11 @@ def modal(self, context, event):
elif self.key_movement_passthrough:
return {'PASS_THROUGH'}

if get_preferences().enable_mouse_values:
if self.key_no_modifiers:
self.active_collection = (self.active_collection + self.mouse_step) % (len(self.all_collections) + 1)
self.dirty = True

if self.dirty:
self.operate(context)

Expand All @@ -91,7 +97,7 @@ def invoke(self, context, event):

self.operate(context)

capture_modifier_keys(self)
capture_modifier_keys(self, None, event.mouse_x)

init_overlay(self, event)
register_draw_handler(self, draw_text_callback)
Expand Down Expand Up @@ -156,6 +162,7 @@ def draw_text_callback(self):
"Collection: {0}".format("N/A — Scene" if self.active_collection >= len(self.all_collections) else self.all_collections[self.active_collection]),
"Where to place the new object...",
active=True,
mouse_value=True,
alt_mode=False)

draw_hint(
Expand Down
2 changes: 1 addition & 1 deletion booleans/swap_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def invoke(self, context, event):
elif exact_solver_count == len(self.boolean_mods):
self.solve_mode = 'EXACT'

capture_modifier_keys(self)
capture_modifier_keys(self, None, event.mouse_x)

init_overlay(self, event)
register_draw_handler(self, draw_text_callback)
Expand Down
2 changes: 1 addition & 1 deletion replicate/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def invoke(self, context, event):

self.operate(context)

capture_modifier_keys(self)
capture_modifier_keys(self, None, event.mouse_x)

init_overlay(self, event)
register_draw_handler(self, draw_text_callback)
Expand Down
2 changes: 1 addition & 1 deletion sketch/geo_lift.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def invoke(self, context, event):

create_duplicate_liftable_geometry(context, {self.mode}, 'ND — Geo Lift', not event.shift)

capture_modifier_keys(self)
capture_modifier_keys(self, None, event.mouse_x)

init_overlay(self, event)
register_draw_handler(self, draw_text_callback)
Expand Down
2 changes: 1 addition & 1 deletion sketch/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def invoke(self, context, event):

self.inset_input_stream = new_stream()

capture_modifier_keys(self)
capture_modifier_keys(self, None, event.mouse_x)

init_overlay(self, event)
register_draw_handler(self, draw_text_callback)
Expand Down
11 changes: 8 additions & 3 deletions sketch/screw_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,16 @@ def modal(self, context, event):
return {'PASS_THROUGH'}

if get_preferences().enable_mouse_values:
if no_stream(self.offset_input_stream) and self.key_ctrl:
if self.key_no_modifiers:
self.head_type_index = (self.head_type_index + self.mouse_step) % len(self.objects)
self.update_head_type(context)
self.dirty = True
elif no_stream(self.offset_input_stream) and self.key_ctrl:
self.offset += self.mouse_value
self.dirty = True
elif no_stream(self.scale_input_stream) and self.key_alt:
self.scale += self.mouse_value

self.dirty = True
self.dirty = True

if self.dirty:
self.operate(context)
Expand Down Expand Up @@ -267,6 +271,7 @@ def draw_text_callback(self):
"Type: {0}".format(self.objects[self.head_type_index][1]),
"Browsing {} types...".format("custom" if self.objects[self.head_type_index][2] else "built-in"),
active=self.key_no_modifiers,
mouse_value=True,
alt_mode=False)

draw_property(
Expand Down
2 changes: 1 addition & 1 deletion sketch/view_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def invoke(self, context, event):

create_duplicate_liftable_geometry(context, {'FACE'}, 'ND — View Align', not event.shift)

capture_modifier_keys(self)
capture_modifier_keys(self, None, event.mouse_x)

init_overlay(self, event)
register_draw_handler(self, draw_text_callback)
Expand Down
13 changes: 12 additions & 1 deletion standalone/cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from .. lib.overlay import update_overlay, init_overlay, toggle_pin_overlay, toggle_operator_passthrough, register_draw_handler, unregister_draw_handler, draw_header, draw_property, draw_hint
from .. lib.events import capture_modifier_keys, pressed
from .. lib.collections import hide_utils_collection, isolate_in_utils_collection
from .. lib.preferences import get_preferences


class ND_OT_cycle(bpy.types.Operator):
Expand Down Expand Up @@ -96,6 +97,14 @@ def modal(self, context, event):
elif self.key_movement_passthrough:
return {'PASS_THROUGH'}

if get_preferences().enable_mouse_values:
if self.mod_cycle:
self.mod_current_index = max(-1, min(self.mod_current_index + self.mouse_step, self.mod_count - 1))
self.dirty = True
elif not self.mod_cycle and self.util_count > 0:
self.util_current_index = (self.util_current_index + self.mouse_step) % self.util_count
self.dirty = True

if self.dirty:
self.operate(context)

Expand Down Expand Up @@ -130,7 +139,7 @@ def invoke(self, context, event):

self.operate(context)

capture_modifier_keys(self)
capture_modifier_keys(self, None, event.mouse_x)

init_overlay(self, event)
register_draw_handler(self, draw_text_callback)
Expand Down Expand Up @@ -253,6 +262,7 @@ def draw_text_callback(self):
"Modifier: {0}".format("None" if self.mod_current_index == -1 else self.mod_names[self.mod_current_index]),
"Active: {0} / Total: {1}".format(self.mod_current_index + 1, self.mod_count),
active=True,
mouse_value=True,
alt_mode=False)
else:
draw_hint(self, "Whoops", "Looks like there are no modifiers to view.")
Expand All @@ -263,6 +273,7 @@ def draw_text_callback(self):
"Utility: {0}".format(self.util_mod_names[self.util_current_index]),
"Current: {0} / Total: {1}".format(self.util_current_index + 1, self.util_count),
active=True,
mouse_value=True,
alt_mode=False)

draw_hint(
Expand Down

0 comments on commit 99b21a6

Please sign in to comment.