From 345c6298e995ea618c34282ba6d7ab5af032f191 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 Feb 2018 21:14:26 +1100 Subject: Object Mode: move to workspace struct - Read-only access can often use EvaluationContext.object_mode - Write access to go to WorkSpace.object_mode. - Some TODO's remain (marked as "TODO/OBMODE") - Add-ons will need updating (context.active_object.mode -> context.workspace.object_mode) - There will be small/medium issues that still need resolving this does work on a basic level though. See D3037 --- release/scripts/startup/bl_ui/space_view3d.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'release/scripts/startup/bl_ui/space_view3d.py') diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 9fd620eec76..a4c452857f2 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -48,7 +48,7 @@ class VIEW3D_HT_header(Header): layout.template_header_3D() if obj: - mode = obj.mode + mode = context.workspace.object_mode # Particle edit if mode == 'PARTICLE_EDIT': row.prop(toolsettings.particle_edit, "select_mode", text="", expand=True) @@ -317,8 +317,9 @@ class VIEW3D_MT_transform_armature(VIEW3D_MT_transform_base): VIEW3D_MT_transform_base.draw(self, context) # armature specific extensions follow... + workspace = context.workspace obj = context.object - if obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'}: + if obj.type == 'ARMATURE' and workspace.object_mode in {'EDIT', 'POSE'}: if obj.data.draw_type == 'BBONE': layout.separator() @@ -1955,7 +1956,10 @@ class VIEW3D_MT_vertex_group(Menu): layout.operator("object.vertex_group_assign_new") ob = context.active_object - if ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex): + workspace = context.workspace + if ((workspace.object_mode == 'EDIT') or + (workspace.object_mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex) + ): if ob.vertex_groups.active: layout.separator() @@ -3388,7 +3392,7 @@ class VIEW3D_PT_view3d_properties(Panel): if lock_object: if lock_object.type == 'ARMATURE': col.prop_search(view, "lock_bone", lock_object.data, - "edit_bones" if lock_object.mode == 'EDIT' + "edit_bones" if context.mode == 'EDIT_ARMATURE' else "bones", text="") else: @@ -3441,12 +3445,13 @@ class VIEW3D_PT_view3d_name(Panel): def draw(self, context): layout = self.layout + workspace = context.workspace ob = context.active_object row = layout.row() row.label(text="", icon='OBJECT_DATA') row.prop(ob, "name", text="") - if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}: + if ob.type == 'ARMATURE' and workspace.object_mode in {'EDIT', 'POSE'}: bone = context.active_bone if bone: row = layout.row() @@ -3764,7 +3769,8 @@ class VIEW3D_PT_etch_a_ton(Panel): def poll(cls, context): scene = context.space_data ob = context.active_object - return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT' + workspace = context.workspace + return scene and ob and (ob.type == 'ARMATURE') and (workspace.object_mode == 'EDIT') def draw_header(self, context): layout = self.layout @@ -3820,7 +3826,8 @@ class VIEW3D_PT_context_properties(Panel): def _active_context_member(context): obj = context.object if obj: - mode = obj.mode + workspace = context.workspace + mode = workspace.object_mode if mode == 'POSE': return "active_pose_bone" elif mode == 'EDIT' and obj.type == 'ARMATURE': -- cgit v1.2.3