[Bf-extensions-cvs] [7bc0fa6b] master: GPencil Tools: Canvas rotation improvements

Pullusb noreply at git.blender.org
Sun Jan 31 21:44:09 CET 2021


Commit: 7bc0fa6bf2d8fb564759a4b2c776eda098f61bd9
Author: Pullusb
Date:   Sun Jan 31 21:44:03 2021 +0100
Branches: master
https://developer.blender.org/rBA7bc0fa6bf2d8fb564759a4b2c776eda098f61bd9

GPencil Tools: Canvas rotation improvements

- Added operators to store/restore camera rotation (handy to quickly get back to a prefered angle)
- Use a modifier key to step the rotation by a user-chosen angle
- Addon preferences UI cleanup

===================================================================

M	greasepencil_tools/__init__.py
M	greasepencil_tools/prefs.py
M	greasepencil_tools/rotate_canvas.py
M	greasepencil_tools/ui_panels.py

===================================================================

diff --git a/greasepencil_tools/__init__.py b/greasepencil_tools/__init__.py
index 9ac882ba..adcc7aa7 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, 2, 2),
+"version": (1, 3, 0),
 "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 fff0f18c..533f5b99 100644
--- a/greasepencil_tools/prefs.py
+++ b/greasepencil_tools/prefs.py
@@ -23,6 +23,7 @@ from bpy.props import (
         EnumProperty,
         StringProperty,
         PointerProperty,
+        FloatProperty,
         # IntProperty,
         )
 
@@ -62,13 +63,6 @@ class GreasePencilAddonPrefs(bpy.types.AddonPreferences):
             default="Grease Pencil",
             update=update_panel)
 
-    pref_tabs : EnumProperty(
-        items=(('PREF', "Preferences", "Preferences properties of GP"),
-               ('TUTO', "Tutorial", "How to use the tool"),
-               # ('KEYMAP', "Keymap", "customise the default keymap"),
-               ),
-               default='PREF')
-
     # --- props
     use_clic_drag : BoolProperty(
         name='Use click drag directly on points',
@@ -131,95 +125,124 @@ class GreasePencilAddonPrefs(bpy.types.AddonPreferences):
             default = True,
             update=auto_rebind)
 
+    rc_angle_step: FloatProperty(
+        name="Angle Steps",
+        description="Step the rotation using this angle when using rotate canvas step modifier",
+        default=0.0872664600610733, # 5
+        min=0.01745329238474369, # 1
+        max=3.1415927410125732, # # 180
+        soft_min=0.01745329238474369, # 1
+        soft_max=1.5707963705062866, # 90
+        step=10, precision=1, subtype='ANGLE', unit='ROTATION')
+
     def draw(self, context):
             prefs = get_addon_prefs()
             layout = self.layout
             # layout.use_property_split = True
             row= layout.row(align=True)
-            row.prop(self, "pref_tabs", expand=True)
 
-            if self.pref_tabs == 'PREF':
+            ## TAB CATEGORY
+            box = layout.box()
+            row = box.row(align=True)
+            row.label(text="Panel Category:")
+            row.prop(self, "category", text="")
+
+            ## BOX DEFORM
+            box = layout.box()
+            row = box.row(align=True)
+            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')
+
+            box.prop(self, "auto_swap_deform_type")
+            box.label(text="Once 'M' is hit, auto swap is desactivated to stay in your chosen mode", icon='INFO')
+
+            ## ROTATE CANVAS
+            box = layout.box()
+            box.label(text='Rotate canvas:')
+
+            box.prop(self, "canvas_use_shortcut", text='Bind Shortcuts')
+
+            if self.canvas_use_shortcut:
+
+                row = box.row()
+                row.label(text="(Auto rebind when changing shortcut)")#icon=""
+                # row.operator("prefs.rebind_shortcut", text='Bind/Rebind shortcuts', icon='FILE_REFRESH')#EVENT_SPACEKEY
+                row = box.row(align = True)
+                row.prop(self, "use_ctrl", text='Ctrl')#, expand=True
+                row.prop(self, "use_alt", text='Alt')#, expand=True
+                row.prop(self, "use_shift", text='Shift')#, expand=True
+                row.prop(self, "mouse_click",text='')#expand=True
+
+                if not self.use_ctrl and not self.use_alt and not self.use_shift:
+                    box.label(text="Choose at least one modifier to combine with click (default: Ctrl+Alt)", icon="ERROR")# INFO
+                
+                if not all((self.use_ctrl, self.use_alt, self.use_shift)):
+                    row = box.row(align = True)
+                    snap_key_list = []
+                    if not self.use_ctrl:
+                        snap_key_list.append('Ctrl')
+                    if not self.use_shift:
+                        snap_key_list.append('Shift')
+                    if not self.use_alt:
+                        snap_key_list.append('Alt')
 
-                ## TAB CATEGORY
-                box = layout.box()
-                row = box.row(align=True)
-                row.label(text="Panel Category:")
-                row.prop(self, "category", text="")
+                    row.label(text=f"Step rotation with: {' or '.join(snap_key_list)}", icon='DRIVER_ROTATIONAL_DIFFERENCE')
+                    row.prop(self, "rc_angle_step", text='Angle Steps')
 
-                ## BOX DEFORM
-                box = layout.box()
-                box.label(text='Box Deform:')
-                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')
 
-                box.prop(self, "auto_swap_deform_type")
-                box.label(text="Once 'M' is hit, auto swap is desactivated to stay in your chosen mode", icon='INFO')
+            else:
+                box.label(text="No hotkey has been set automatically. Following operators needs to be set manually:", icon="ERROR")
+                box.label(text="view3d.rotate_canvas")
+            box.prop(self, 'canvas_use_hud')
 
-                ## ROTATE CANVAS
-                box = layout.box()
-                box.label(text='Rotate canvas:')
+            ## SCRUB TIMELINE
+            box = layout.box()
+            draw_ts_pref(prefs.ts, box)
 
-                box.prop(self, "canvas_use_shortcut", text='Bind Shortcuts')
 
-                if self.canvas_use_shortcut:
-
-                    row = box.row()
-                    row.label(text="(Auto rebind when changing shortcut)")#icon=""
-                    # row.operator("prefs.rebind_shortcut", text='Bind/Rebind shortcuts', icon='FILE_REFRESH')#EVENT_SPACEKEY
-                    row = box.row(align = True)
-                    row.prop(self, "use_ctrl", text='Ctrl')#, expand=True
-                    row.prop(self, "use_alt", text='Alt')#, expand=True
-                    row.prop(self, "use_shift", text='Shift')#, expand=True
-                    row.prop(self, "mouse_click",text='')#expand=True
-
-                    if not self.use_ctrl and not self.use_alt and not self.use_shift:
-                        box.label(text="Choose at least one modifier to combine with click (default: Ctrl+Alt)", icon="ERROR")# INFO
-
-                else:
-                    box.label(text="No hotkey has been set automatically. Following operators needs to be set manually:", icon="ERROR")
-                    box.label(text="view3d.rotate_canvas")
-                box.prop(self, 'canvas_use_hud')
-
-                ## SCRUB TIMELINE
-                box = layout.box()
-                draw_ts_pref(prefs.ts, box)
-
-            if self.pref_tabs == 'TUTO':
-
-                #**Behavior from context mode**
-                col = layout.column()
-                col.label(text='Box Deform Tool')
-                col.label(text="Usage:", icon='MOD_LATTICE')
-                col.label(text="Use the shortcut 'Ctrl+T' in available modes (listed below)")
-                col.label(text="The lattice box is generated facing your view (be sure to face canvas if you want to stay on it)")
-                col.label(text="Use shortcuts below to deform (a help will be displayed in the topbar)")
-
-                col.separator()
-                col.label(text="Shortcuts:", icon='HAND')
-                col.label(text="Spacebar / Enter : Confirm")
-                col.label(text="Delete / Backspace / Tab(twice) / Ctrl+T : Cancel")
-                col.label(text="M : Toggle between Linear and Spline mode at any moment")
-                col.label(text="1-9 top row number : Subdivide the box")
-                col.label(text="Ctrl + arrows-keys : Subdivide the box incrementally in individual X/Y axis")
-
-                col.separator()
-                col.label(text="Modes and deformation target:", icon='PIVOT_BOUNDBOX')
-                col.label(text="- Object mode : The whole GP object is deformed (including all frames)")
-                col.label(text="- GPencil Edit mode : Deform Selected points")
-                col.label(text="- Gpencil Paint : Deform last Strokes")
-                # col.label(text="- Lattice edit : Revive the modal after a ctrl+Z")
-
-                col.separator()
-                col.label(text="Notes:", icon='TEXT')
-                col.label(text="- If you return in box deform after applying (with a ctrl+Z), you need to hit 'Ctrl+T' again to revive the modal.")
-                col.label(text="- A cancel warning will be displayed the first time you hit Tab")
+# 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"
 
+    def draw(self, context):
+        layout = self.layout
+        # call another menu
+        #layout.operator("wm.call_menu", text="Unwrap").name = "VIEW3D_MT_uv_map"
+        #**Behavior from context mode**
+        col = layout.column()
+        col.label(text='Box Deform Tool')
+        col.label(text="Usage:", icon='MOD_LATTICE')
+        col.label(text="Use the shortcut 'Ctrl+T' in available modes (listed below)")
+        col.label(text="The lattice box is generated facing your view (be sure to face canvas if you want to stay on it)")
+        col.label(text="Use shortcuts below to deform (a help will be displayed in the topbar)")
+
+        col.separator()
+        col.label(text="Shortcuts:", icon='HAND')
+        col

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list