[Bf-blender-cvs] [cc7bbda849a] greasepencil-object: Annotations: WIP first steps towards toolbar support

Joshua Leung noreply at git.blender.org
Tue Jul 3 17:48:39 CEST 2018


Commit: cc7bbda849a1cedde69a2b6184c4a6efc2385055
Author: Joshua Leung
Date:   Wed Jul 4 03:33:56 2018 +1200
Branches: greasepencil-object
https://developer.blender.org/rBcc7bbda849a1cedde69a2b6184c4a6efc2385055

Annotations: WIP first steps towards toolbar support

This adds a toolbar entry for activating the annotations tools
as active tools. Many things are WIP still (e.g. tool settings
are yet to come, as the necessary props aren't defined in DNA/RNA yet).

Todo's:
* Icons are missing.  The necessary icons *do* exist right now
  in the icon_geom.blend file, but I can't get them to export/generate
  .dat files that we can use in the UI here.  That said, the placeholder
  names (from that file) are now used.

* Key mappings need work/testing. They seem to work well enough as-is
  already though

* Tool settings (in topbar) are not implemented yet. Coming soon
  (aka tomorrow, after I get some sleep)

* Non-3D view toolbar support

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

M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py

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

diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 110611cf7ab..cc30d1d372c 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -125,6 +125,77 @@ class _defs_view3d_generic:
         )
 
 
+class _defs_annotate:
+    @classmethod
+    def draw_settings_common(cls, context, layout, tool):
+        pass
+
+    @ToolDef.from_fn
+    def scribble():
+        def draw_settings(context, layout, tool):
+            pass
+
+        return dict(
+            text="Annotate (Scribble)",
+            icon="ops.gpencil.draw",
+            keymap=(
+                ("gpencil.annotate",
+                 dict(mode='DRAW', wait_for_input=False),
+                 dict(type='EVT_TWEAK_A', value='ANY')),
+            ),
+            draw_settings=draw_settings,
+        )
+
+    @ToolDef.from_fn
+    def line():
+        def draw_settings(context, layout, tool):
+            # XXX: Reuse
+            pass
+
+        return dict(
+            text="Draw Line",
+            icon="ops.gpencil.drawline",
+            keymap=(
+                ("gpencil.annotate",
+                 dict(mode='DRAW_STRAIGHT', wait_for_input=False),
+                 dict(type='EVT_TWEAK_A', value='ANY')),
+            ),
+        )
+
+    @ToolDef.from_fn
+    def poly():
+        def draw_settings(context, layout, tool):
+            # XXX: Reuse
+            pass
+
+        return dict(
+            text="Draw Polygon",
+            icon="ops.gpencil.drawpoly",
+            keymap=(
+                ("gpencil.annotate",
+                 dict(mode='DRAW_POLY', wait_for_input=False),
+                 dict(type='ACTIONMOUSE', value='PRESS')),
+            ),
+        )
+
+    @ToolDef.from_fn
+    def eraser():
+        def draw_settings(context, layout, tool):
+            # XXX: Reuse
+            pass
+
+        return dict(
+            text="Eraser",
+            icon="ops.gpencil.draweraser",
+            #cursor='...',  # XXX: Always show brush circle when enabled
+            keymap=(
+                ("gpencil.annotate",
+                 dict(mode='ERASER', wait_for_input=False),
+                 dict(type='ACTIONMOUSE', value='PRESS')),
+            ),
+        )
+
+
 class _defs_transform:
 
     @ToolDef.from_fn
@@ -960,6 +1031,15 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
         ),
     )
 
+    _tools_annotate = (
+        (
+            _defs_annotate.scribble,
+            _defs_annotate.line,
+            _defs_annotate.poly,
+            _defs_annotate.eraser,
+        ),
+    )
+
     _tools = {
         None: [
             _defs_view3d_generic.cursor,
@@ -969,21 +1049,27 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
             *_tools_select,
             None,
             *_tools_transform,
+            None,
+            *_tools_annotate,
         ],
         'POSE': [
             *_tools_select,
             *_tools_transform,
             None,
+            *_tools_annotate,
+            None,
             (
                 _defs_pose.breakdown,
                 _defs_pose.push,
                 _defs_pose.relax,
-            )
+            ),
         ],
         'EDIT_ARMATURE': [
             *_tools_select,
             None,
             *_tools_transform,
+            None,
+            *_tools_annotate,
             _defs_edit_armature.roll,
             (
                 _defs_edit_armature.bone_size,
@@ -993,13 +1079,15 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
             (
                 _defs_edit_armature.extrude,
                 _defs_edit_armature.extrude_cursor,
-            )
+            ),
         ],
         'EDIT_MESH': [
             *_tools_select,
             None,
             *_tools_transform,
             None,
+            *_tools_annotate,
+            None,
             _defs_edit_mesh.cube_add,
             None,
             (
@@ -1044,6 +1132,8 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
             None,
             *_tools_transform,
             None,
+            *_tools_annotate,
+            None,
             _defs_edit_curve.draw,
             _defs_edit_curve.extrude_cursor,
         ],



More information about the Bf-blender-cvs mailing list