Code cleanup: Re-use Grease Pencil panel for 3D view as well.
authorThomas Dinges <blender@dingto.org>
Mon, 24 Feb 2014 19:53:37 +0000 (20:53 +0100)
committerThomas Dinges <blender@dingto.org>
Mon, 24 Feb 2014 19:53:37 +0000 (20:53 +0100)
release/scripts/startup/bl_ui/properties_grease_pencil_common.py
release/scripts/startup/bl_ui/space_view3d_toolbar.py

index 97173f8c3050e1b6ec0194e0ecbdffd2ebcaa86a..5dd1f94747c835b7d810de160bd6f082013e02cf 100644 (file)
@@ -42,3 +42,9 @@ class GreasePencilPanel():
         row = col.row(align=True)
         row.prop(context.tool_settings, "use_grease_pencil_sessions")
 
+        if context.space_data.type == 'VIEW_3D':
+            col.separator()
+
+            col.label(text="Measure:")
+            col.operator("view3d.ruler")
+
index db20057318fd75fb5d613d36eaf89c3c2fe81ab1..b7e0cc5235df9efde5ec57d74ce532fadef18ccc 100644 (file)
@@ -19,6 +19,7 @@
 # <pep8 compliant>
 import bpy
 from bpy.types import Menu, Panel
+from bl_ui.properties_grease_pencil_common import GreasePencilPanel
 from bl_ui.properties_paint_common import (
         UnifiedPaintPanel,
         brush_texture_settings,
@@ -50,26 +51,6 @@ def draw_keyframing_tools(context, layout):
     row.operator("anim.keyframe_delete_v3d", text="Remove")
 
 
-# Grease Pencil tools
-def draw_gpencil_tools(context, layout):
-    col = layout.column(align=True)
-
-    row = col.row(align=True)
-    row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
-    row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
-    row = col.row(align=True)
-    row.operator("gpencil.draw", text="Poly").mode = 'DRAW_POLY'
-    row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
-
-    col.separator()
-
-    col.prop(context.tool_settings, "use_grease_pencil_sessions")
-
-    col.separator()
-
-    col.label(text="Measure:")
-    col.operator("view3d.ruler")
-
 # ********** default tools for object-mode ****************
 
 
@@ -1614,13 +1595,10 @@ class VIEW3D_PT_tools_particlemode(View3DPanel, Panel):
 
 
 # Grease Pencil tools
-class VIEW3D_PT_tools_greasepencil(View3DPanel, Panel):
+class VIEW3D_PT_tools_grease_pencil(GreasePencilPanel, Panel):
+    bl_space_type = 'VIEW_3D'
+    bl_region_type = 'TOOLS'
     bl_category = "Grease Pencil"
-    bl_label = "Grease Pencil"
-
-    def draw(self, context):
-        layout = self.layout
-        draw_gpencil_tools(context, layout)
 
 
 if __name__ == "__main__":  # only for live edit.