Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPullusb <bernou.samuel@gmail.com>2021-02-10 23:52:30 +0300
committerPullusb <bernou.samuel@gmail.com>2021-02-10 23:53:22 +0300
commit32adcd8c5928785e8be4ec64e86afd12f9551699 (patch)
treea50f0f19028078865a796ddc5e309403301db3db /greasepencil_tools
parente5a2d98c827b54052688c90113a12e5c661149c3 (diff)
GPencil Tools: Canvas rotation fixes
- Changed canvas rotation reset method (was hard to trigger with a tablet pen). - Default angle steps increased to 15 degrees. - HUD now appear only in active viewport as it should
Diffstat (limited to 'greasepencil_tools')
-rw-r--r--greasepencil_tools/__init__.py2
-rw-r--r--greasepencil_tools/prefs.py8
-rw-r--r--greasepencil_tools/rotate_canvas.py8
3 files changed, 12 insertions, 6 deletions
diff --git a/greasepencil_tools/__init__.py b/greasepencil_tools/__init__.py
index ab6ec9fc..330a9856 100644
--- a/greasepencil_tools/__init__.py
+++ b/greasepencil_tools/__init__.py
@@ -21,7 +21,7 @@ bl_info = {
"name": "Grease Pencil Tools",
"description": "Extra tools for Grease Pencil",
"author": "Samuel Bernou, Antonio Vazquez, Daniel Martinez Lara, Matias Mendiola",
-"version": (1, 3, 1),
+"version": (1, 3, 2),
"blender": (2, 91, 0),
"location": "Sidebar > Grease Pencil > Grease Pencil Tools",
"warning": "",
diff --git a/greasepencil_tools/prefs.py b/greasepencil_tools/prefs.py
index 533f5b99..701fea3f 100644
--- a/greasepencil_tools/prefs.py
+++ b/greasepencil_tools/prefs.py
@@ -128,9 +128,9 @@ class GreasePencilAddonPrefs(bpy.types.AddonPreferences):
rc_angle_step: FloatProperty(
name="Angle Steps",
description="Step the rotation using this angle when using rotate canvas step modifier",
- default=0.0872664600610733, # 5
+ default=0.2617993877991494, # 15
min=0.01745329238474369, # 1
- max=3.1415927410125732, # # 180
+ max=3.1415927410125732, # 180
soft_min=0.01745329238474369, # 1
soft_max=1.5707963705062866, # 90
step=10, precision=1, subtype='ANGLE', unit='ROTATION')
@@ -153,7 +153,7 @@ class GreasePencilAddonPrefs(bpy.types.AddonPreferences):
row.label(text='Box Deform:')
row.operator("wm.call_menu", text="", icon='QUESTION').name = "GPT_MT_box_deform_doc"
box.prop(self, "use_clic_drag")
- # box.separator()
+
box.prop(self, "default_deform_type")
box.label(text="Deformer type can be changed during modal with 'M' key, this is for default behavior", icon='INFO')
@@ -204,7 +204,7 @@ class GreasePencilAddonPrefs(bpy.types.AddonPreferences):
draw_ts_pref(prefs.ts, box)
-# def box_deform_tuto(layout):
+
class GPT_MT_box_deform_doc(bpy.types.Menu):
# bl_idname = "OBJECT_MT_custom_menu"
bl_label = "Box Deform Infos Sheet"
diff --git a/greasepencil_tools/rotate_canvas.py b/greasepencil_tools/rotate_canvas.py
index dcafc2fb..b1b9e19a 100644
--- a/greasepencil_tools/rotate_canvas.py
+++ b/greasepencil_tools/rotate_canvas.py
@@ -5,6 +5,7 @@ import math
import mathutils
from bpy_extras.view3d_utils import location_3d_to_region_2d
from bpy.props import BoolProperty, EnumProperty
+from time import time
## draw utils
import gpu
import bgl
@@ -25,6 +26,8 @@ def step_value(value, step):
def draw_callback_px(self, context):
# 50% alpha, 2 pixel width line
+ if context.area != self.current_area:
+ return
shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR')
bgl.glEnable(bgl.GL_BLEND)
bgl.glLineWidth(2)
@@ -116,7 +119,8 @@ class RC_OT_RotateCanvas(bpy.types.Operator):
context.space_data.region_3d.view_rotation = rot.to_quaternion()
if event.type in {'RIGHTMOUSE', 'LEFTMOUSE', 'MIDDLEMOUSE'} and event.value == 'RELEASE':
- if not self.angle:
+ # Trigger reset : Less than 150ms and less than 2 degrees move
+ if time() - self.timer < 0.15 and abs(math.degrees(self.angle)) < 2:
# self.report({'INFO'}, 'Reset')
aim = context.space_data.region_3d.view_rotation @ mathutils.Vector((0.0, 0.0, 1.0))#view vector
z_up_quat = aim.to_track_quat('Z','Y')#track Z, up Y
@@ -143,6 +147,7 @@ class RC_OT_RotateCanvas(bpy.types.Operator):
return {'RUNNING_MODAL'}
def invoke(self, context, event):
+ self.current_area = context.area
prefs = get_addon_prefs()
self.hud = prefs.canvas_use_hud
self.angle = 0.0
@@ -190,6 +195,7 @@ class RC_OT_RotateCanvas(bpy.types.Operator):
# round to closer degree and convert back to radians
self.snap_step = math.radians(round(math.degrees(prefs.rc_angle_step)))
+ self.timer = time()
args = (self, context)
if self.hud:
self._handle = bpy.types.SpaceView3D.draw_handler_add(draw_callback_px, args, 'WINDOW', 'POST_PIXEL')