[Bf-blender-cvs] [50ab5db1c35] greasepencil-object: Fix python object mode changes

Antonio Vazquez noreply at git.blender.org
Fri Feb 9 17:03:52 CET 2018


Commit: 50ab5db1c3546f6c619f4ebe621910e0e20e5c6c
Author: Antonio Vazquez
Date:   Fri Feb 9 17:03:40 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB50ab5db1c3546f6c619f4ebe621910e0e20e5c6c

Fix python object mode changes

After last changes, need to use workspace mode

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py

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

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index b6f92883b47..2d46f6f05e3 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -313,8 +313,8 @@ class GreasePencilEraserPanel:
     def poll(cls, context):
         if context.gpencil_data is None:
             return False
-
-        return context.active_object and context.active_object.mode == 'GPENCIL_PAINT'
+        workspace = context.workspace
+        return context.active_object and workspace.object_mode == 'GPENCIL_PAINT'
 
     @staticmethod
     def draw(self, context):
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 281b0b1c279..ab30199c0fd 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -194,10 +194,11 @@ class VIEW3D_MT_editor_menus(Menu):
     @staticmethod
     def draw_menus(layout, context):
         obj = context.active_object
+        workspace = context.workspace
         mode_string = context.mode
         edit_object = context.edit_object
         gp_edit = context.active_object and \
-                  context.active_object.mode in {'GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT', 'GPENCIL_WEIGHT'}
+                  workspace.object_mode in {'GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT', 'GPENCIL_WEIGHT'}
 
         layout.menu("VIEW3D_MT_view")
 
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index d59f21d36d6..fed2d862d33 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -66,8 +66,9 @@ def draw_vpaint_symmetry(layout, vpaint):
 
 # Most of these panels should not be visible in GP edit modes
 def is_not_gpencil_edit_mode(context):
+    workspace = context.workspace
     is_gpmode = context.active_object and \
-                context.active_object.mode in {'GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT', 'GPENCIL_WEIGHT'}
+                workspace.object_mode in {'GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT', 'GPENCIL_WEIGHT'}
     return not is_gpmode
 
 
@@ -2255,11 +2256,12 @@ class VIEW3D_PT_tools_grease_pencil_animation(Panel):
 
     @classmethod
     def poll(cls, context):
+        workspace = context.workspace
         if context.gpencil_data is None:
             return False
         elif context.space_data.type != 'VIEW_3D':
             return False
-        elif context.object.mode == 'OBJECT':
+        elif workspace.object_mode == 'OBJECT':
             return False
 
         return True
@@ -2463,9 +2465,10 @@ class VIEW3D_PT_tools_grease_pencil_appearance(Panel):
         if context.gpencil_data is None:
             return False
 
+        workspace = context.workspace
         if context.active_object:
             ob = context.active_object
-            return ob.mode in {'GPENCIL_PAINT', 'GPENCIL_SCULPT', 'GPENCIL_WEIGHT'}
+            return workspace.object_mode in {'GPENCIL_PAINT', 'GPENCIL_SCULPT', 'GPENCIL_WEIGHT'}
             
         return False
 
@@ -2474,15 +2477,16 @@ class VIEW3D_PT_tools_grease_pencil_appearance(Panel):
         layout = self.layout
         settings = context.tool_settings.gpencil_sculpt
         brush = settings.brush
+        workspace = context.workspace
 
         col = layout.column()
-        if context.active_object.mode == 'GPENCIL_PAINT':
+        if workspace.object_mode == 'GPENCIL_PAINT':
             drawingbrush = context.active_gpencil_brush
             col.prop(drawingbrush, "use_cursor", text="Show Brush")
             row = col.row(align=True)
             row.prop(drawingbrush, "cursor_color", text="Color")
 
-        if context.active_object.mode in ('GPENCIL_SCULPT', 'GPENCIL_WEIGHT'):
+        if workspace.object_mode in ('GPENCIL_SCULPT', 'GPENCIL_WEIGHT'):
             col.prop(brush, "use_cursor", text="Show Brush")
             row = col.row(align=True)
             row.prop(brush, "cursor_color_add", text="Add")



More information about the Bf-blender-cvs mailing list