From 0ce0dd71024647acf4165757d8bdcff7042d79ee Mon Sep 17 00:00:00 2001 From: Tristan Strathearn Date: Mon, 25 Apr 2022 11:11:45 +1000 Subject: [PATCH] feat: add option to lock overlay pin state and position across all operators --- __init__.py | 24 ++++++++++++++++++++++++ lib/overlay.py | 10 ++++++++++ 2 files changed, 34 insertions(+) diff --git a/__init__.py b/__init__.py index 6bf7f36..3af408b 100644 --- a/__init__.py +++ b/__init__.py @@ -69,6 +69,26 @@ class NDPreferences(AddonPreferences): default=True, ) + lock_overlay_pinning: BoolProperty( + name="Lock Overlay Pinning", + default=False, + ) + + overlay_pinned: BoolProperty( + name="Overlay Pinned", + default=False, + ) + + overlay_pin_x: IntProperty( + name="Overlay Pin X Coordinate", + default=0, + ) + + overlay_pin_y: IntProperty( + name="Overlay Pin Y Coordinate", + default=0, + ) + axis_base_thickness: FloatProperty( name="Axis Base Thickness", default=2, @@ -210,6 +230,10 @@ def draw_ui(self, box): column = box.column(align=True) row = column.row() row.prop(self, "enable_quick_favourites") + + column = box.column(align=True) + row = column.row() + row.prop(self, "lock_overlay_pinning") column = box.column(align=True) row = column.row() diff --git a/lib/overlay.py b/lib/overlay.py index 7fc7e6b..fb343b6 100644 --- a/lib/overlay.py +++ b/lib/overlay.py @@ -38,6 +38,11 @@ def toggle_pin_overlay(cls, event): cls.pin_overlay = not cls.pin_overlay + if get_preferences().lock_overlay_pinning: + get_preferences().overlay_pinned = cls.pin_overlay + get_preferences().overlay_pin_x = cls.overlay_x + get_preferences().overlay_pin_y = cls.overlay_y + def toggle_operator_passthrough(cls): cls.operator_passthrough = not cls.operator_passthrough @@ -62,6 +67,11 @@ def init_overlay(cls, event): cls.operator_passthrough = False cls.mouse_warped = False + if get_preferences().lock_overlay_pinning: + cls.pin_overlay = get_preferences().overlay_pinned + cls.overlay_x = get_preferences().overlay_pin_x + cls.overlay_y = get_preferences().overlay_pin_y + def update_overlay(cls, context, event): if not cls.pin_overlay: