diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-02-08 13:14:26 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-02-08 13:14:26 +0300 |
commit | 345c6298e995ea618c34282ba6d7ab5af032f191 (patch) | |
tree | f4fbc4798e17d0f19efc28b51a41425d0c552be8 /release | |
parent | 14a19fed788af0cf3695eb5def92510841056e08 (diff) |
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
Diffstat (limited to 'release')
19 files changed, 114 insertions, 63 deletions
diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py index 04b3858bb0d..31938f3ad3e 100644 --- a/release/scripts/modules/bpy_extras/object_utils.py +++ b/release/scripts/modules/bpy_extras/object_utils.py @@ -119,6 +119,7 @@ def object_data_add(context, obdata, operator=None, name=None): :return: the newly created object in the scene. :rtype: :class:`bpy.types.Object` """ + workspace = context.workspace scene = context.scene layer = context.view_layer layer_collection = context.layer_collection @@ -146,9 +147,9 @@ def object_data_add(context, obdata, operator=None, name=None): # caused because entering edit-mode does not add a empty undo slot! if context.user_preferences.edit.use_enter_edit_mode: if not (obj_act and - obj_act.mode == 'EDIT' and - obj_act.type == obj_new.type): - + obj_act.type == obj_new.type and + workspace.object_mode == 'EDIT' + ): _obdata = bpy.data.meshes.new(name) obj_act = bpy.data.objects.new(_obdata.name, _obdata) obj_act.matrix_world = obj_new.matrix_world @@ -159,7 +160,10 @@ def object_data_add(context, obdata, operator=None, name=None): bpy.ops.ed.undo_push(message="Enter Editmode") # XXX - if obj_act and obj_act.mode == 'EDIT' and obj_act.type == obj_new.type: + if (obj_act and + obj_act.type == obj_new.type and + workspace.object_mode == 'EDIT' + ): bpy.ops.mesh.select_all(action='DESELECT') obj_act.select_set(action='SELECT') bpy.ops.object.mode_set(mode='OBJECT') @@ -249,9 +253,10 @@ def object_image_guess(obj, bm=None): first checking the texture-faces, then the material. """ # TODO, cycles/nodes materials + workspace = context.workspace me = obj.data if bm is None: - if obj.mode == 'EDIT': + if workspace.object_mode == 'EDIT': import bmesh bm = bmesh.from_edit_mesh(me) diff --git a/release/scripts/modules/keyingsets_utils.py b/release/scripts/modules/keyingsets_utils.py index 7ce5f3e029b..40e74e27ed2 100644 --- a/release/scripts/modules/keyingsets_utils.py +++ b/release/scripts/modules/keyingsets_utils.py @@ -57,9 +57,10 @@ def path_add_property(path, prop): # selected objects (active object must be in object mode) def RKS_POLL_selected_objects(ksi, context): + workspace = context.workspace ob = context.active_object if ob: - return ob.mode == 'OBJECT' + return workspace.object_mode == 'OBJECT' else: return bool(context.selected_objects) @@ -67,8 +68,9 @@ def RKS_POLL_selected_objects(ksi, context): # selected bones def RKS_POLL_selected_bones(ksi, context): # we must be in Pose Mode, and there must be some bones selected + workspace = context.workspace ob = context.active_object - if ob and ob.mode == 'POSE': + if ob and workspace.object_mode == 'POSE': if context.active_pose_bone or context.selected_pose_bones: return True @@ -87,8 +89,9 @@ def RKS_POLL_selected_items(ksi, context): # all selected objects or pose bones, depending on which we've got def RKS_ITER_selected_item(ksi, context, ks): + workspace = context.workspace ob = context.active_object - if ob and ob.mode == 'POSE': + if ob and workspace.object_mode == 'POSE': for bone in context.selected_pose_bones: ksi.generate(context, ks, bone) else: diff --git a/release/scripts/startup/bl_operators/freestyle.py b/release/scripts/startup/bl_operators/freestyle.py index 0cfe78879db..9b1d054cc15 100644 --- a/release/scripts/startup/bl_operators/freestyle.py +++ b/release/scripts/startup/bl_operators/freestyle.py @@ -53,6 +53,7 @@ class SCENE_OT_freestyle_fill_range_by_selection(bpy.types.Operator): def execute(self, context): import sys + workspace = context.workspace scene = context.scene view_layer = scene.view_layers.active lineset = view_layer.freestyle_settings.linesets.active @@ -79,7 +80,7 @@ class SCENE_OT_freestyle_fill_range_by_selection(bpy.types.Operator): return {'CANCELLED'} # Find selected vertices in editmesh ob = context.active_object - if ob.type == 'MESH' and ob.mode == 'EDIT' and ob.name != ref.name: + if ob.type == 'MESH' and workspace.object_mode == 'EDIT' and ob.name != ref.name: bpy.ops.object.mode_set(mode='OBJECT') selected_verts = [v for v in ob.data.vertices if v.select] bpy.ops.object.mode_set(mode='EDIT') @@ -143,6 +144,7 @@ class SCENE_OT_freestyle_add_edge_marks_to_keying_set(bpy.types.Operator): def execute(self, context): # active keying set + workspace = context.workspace scene = context.scene ks = scene.keying_sets.active if ks is None: @@ -150,7 +152,7 @@ class SCENE_OT_freestyle_add_edge_marks_to_keying_set(bpy.types.Operator): ks.bl_description = "" # add data paths to the keying set ob = context.active_object - ob_mode = ob.mode + ob_mode = workspace.object_mode mesh = ob.data bpy.ops.object.mode_set(mode='OBJECT', toggle=False) for i, edge in enumerate(mesh.edges): @@ -174,6 +176,7 @@ class SCENE_OT_freestyle_add_face_marks_to_keying_set(bpy.types.Operator): def execute(self, context): # active keying set + workspace = context.workspace scene = context.scene ks = scene.keying_sets.active if ks is None: @@ -181,7 +184,7 @@ class SCENE_OT_freestyle_add_face_marks_to_keying_set(bpy.types.Operator): ks.bl_description = "" # add data paths to the keying set ob = context.active_object - ob_mode = ob.mode + ob_mode = workspace.object_mode mesh = ob.data bpy.ops.object.mode_set(mode='OBJECT', toggle=False) for i, polygon in enumerate(mesh.polygons): diff --git a/release/scripts/startup/bl_operators/mesh.py b/release/scripts/startup/bl_operators/mesh.py index c7a11c23c3f..ccc592e80b8 100644 --- a/release/scripts/startup/bl_operators/mesh.py +++ b/release/scripts/startup/bl_operators/mesh.py @@ -57,8 +57,9 @@ class MeshMirrorUV(Operator): precision = self.precision double_warn = 0 + workspace = context.workspace ob = context.active_object - is_editmode = (ob.mode == 'EDIT') + is_editmode = (workspace.object_mode == 'EDIT') if is_editmode: bpy.ops.object.mode_set(mode='OBJECT', toggle=False) diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py index 566487d9d0e..58f3afa3d6c 100644 --- a/release/scripts/startup/bl_operators/object.py +++ b/release/scripts/startup/bl_operators/object.py @@ -63,12 +63,13 @@ class SelectPattern(Operator): pattern_match = (lambda a, b: fnmatch.fnmatchcase(a.upper(), b.upper())) is_ebone = False + workspace = context.workspace obj = context.object - if obj and obj.mode == 'POSE': + if obj and workspace.object_mode == 'POSE': items = obj.data.bones if not self.extend: bpy.ops.pose.select_all(action='DESELECT') - elif obj and obj.type == 'ARMATURE' and obj.mode == 'EDIT': + elif obj and obj.type == 'ARMATURE' and workspace.object_mode == 'EDIT': items = obj.data.edit_bones if not self.extend: bpy.ops.armature.select_all(action='DESELECT') @@ -248,6 +249,8 @@ class SubdivisionSet(Operator): if not relative and level < 0: self.level = level = 0 + workspace = context.workspace + def set_object_subd(obj): for mod in obj.modifiers: if mod.type == 'MULTIRES': @@ -257,18 +260,18 @@ class SubdivisionSet(Operator): for i in range(sub): bpy.ops.object.multires_subdivide(modifier="Multires") - if obj.mode == 'SCULPT': + if workspace.object_mode == 'SCULPT': if mod.sculpt_levels != level: mod.sculpt_levels = level - elif obj.mode == 'OBJECT': + elif workspace.object_mode == 'OBJECT': if mod.levels != level: mod.levels = level return else: - if obj.mode == 'SCULPT': + if workspace.object_mode == 'SCULPT': if mod.sculpt_levels + level <= mod.total_levels: mod.sculpt_levels += level - elif obj.mode == 'OBJECT': + elif workspace.object_mode == 'OBJECT': if mod.levels + level <= mod.total_levels: mod.levels += level return @@ -284,7 +287,7 @@ class SubdivisionSet(Operator): # add a new modifier try: - if obj.mode == 'SCULPT': + if workspace.object_mode == 'SCULPT': mod = obj.modifiers.new("Multires", 'MULTIRES') if level > 0: for i in range(0, level): @@ -467,8 +470,9 @@ class ShapeTransfer(Operator): @classmethod def poll(cls, context): + workspace = context.workspace obj = context.active_object - return (obj and obj.mode != 'EDIT') + return (obj and workspace.object_mode != 'EDIT') def execute(self, context): ob_act = context.active_object @@ -508,10 +512,11 @@ class JoinUVs(Operator): def _main(self, context): import array + workspace = context.workspace obj = context.active_object mesh = obj.data - is_editmode = (obj.mode == 'EDIT') + is_editmode = (workspace.object_mode == 'EDIT') if is_editmode: bpy.ops.object.mode_set(mode='OBJECT', toggle=False) diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py index ae64caca91e..9fa6dbf6eef 100644 --- a/release/scripts/startup/bl_operators/object_quick_effects.py +++ b/release/scripts/startup/bl_operators/object_quick_effects.py @@ -73,9 +73,10 @@ class QuickFur(Operator): ) def execute(self, context): + workspace = context.workspace fake_context = context.copy() mesh_objects = [obj for obj in context.selected_objects - if obj.type == 'MESH' and obj.mode == 'OBJECT'] + if obj.type == 'MESH' and workspace.object_mode == 'OBJECT'] if not mesh_objects: self.report({'ERROR'}, "Select at least one mesh object") diff --git a/release/scripts/startup/bl_operators/uvcalc_lightmap.py b/release/scripts/startup/bl_operators/uvcalc_lightmap.py index 61ceb3c04c4..dde98ce9013 100644 --- a/release/scripts/startup/bl_operators/uvcalc_lightmap.py +++ b/release/scripts/startup/bl_operators/uvcalc_lightmap.py @@ -558,8 +558,8 @@ def lightmap_uvpack(meshes, def unwrap(operator, context, **kwargs): - - is_editmode = (context.object.mode == 'EDIT') + workspace = context.workspace + is_editmode = (workspace.object_mode == 'EDIT') if is_editmode: bpy.ops.object.mode_set(mode='OBJECT', toggle=False) diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py index 25783653414..f648bebed26 100644 --- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py +++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py @@ -748,7 +748,8 @@ def main(context, USER_FILL_HOLES_QUALITY = 50 # Only for hole filling. USER_VIEW_INIT = 0 # Only for hole filling. - is_editmode = (context.active_object.mode == 'EDIT') + workspace = context.workspace + is_editmode = (workspace.object_mode == 'EDIT') if is_editmode: obList = [ob for ob in [context.active_object] if ob and ob.type == 'MESH'] else: @@ -781,7 +782,7 @@ def main(context, # Toggle Edit mode - is_editmode = (context.active_object.mode == 'EDIT') + is_editmode = (workspace.object_mode == 'EDIT') if is_editmode: bpy.ops.object.mode_set(mode='OBJECT') # Assume face select mode! an annoying hack to toggle face select mode because Mesh doesn't like faceSelectMode. diff --git a/release/scripts/startup/bl_operators/view3d.py b/release/scripts/startup/bl_operators/view3d.py index 18f91110053..e54ead6a5fc 100644 --- a/release/scripts/startup/bl_operators/view3d.py +++ b/release/scripts/startup/bl_operators/view3d.py @@ -30,8 +30,9 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator): @classmethod def poll(cls, context): + workspace = context.workspace obj = context.active_object - return (obj is not None and obj.mode == 'EDIT') + return (obj is not None and workspace.object_mode == 'EDIT') def execute(self, context): mesh = context.object.data @@ -68,8 +69,9 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator): @classmethod def poll(cls, context): + workspace = context.workspace obj = context.active_object - return (obj is not None and obj.mode == 'EDIT') + return (obj is not None and workspace.object_mode == 'EDIT') @staticmethod def extrude_region(context, use_vert_normals): @@ -117,8 +119,9 @@ class VIEW3D_OT_edit_mesh_extrude_shrink_fatten(Operator): @classmethod def poll(cls, context): + workspace = context.workspace obj = context.active_object - return (obj is not None and obj.mode == 'EDIT') + return (obj is not None and workspace.object_mode == 'EDIT') def execute(self, context): return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, True) @@ -173,7 +176,8 @@ class VIEW3D_OT_select_or_deselect_all(Operator): def poll(cls, context): active_object = context.active_object if active_object: - return active_object.mode in {'EDIT', 'OBJECT', 'POSE'} + workspace = context.workspace + return workspace.object_mode in {'EDIT', 'OBJECT', 'POSE'} return True def invoke(self, context, event): @@ -184,7 +188,9 @@ class VIEW3D_OT_select_or_deselect_all(Operator): active_object = context.active_object if active_object: - if active_object.mode == 'EDIT': + workspace = context.workspace + object_mode = workspace.object_mode + if object_mode == 'EDIT': if active_object.type == 'MESH': bpy.ops.mesh.select_all(action='DESELECT') elif active_object.type == 'CURVE': @@ -197,9 +203,9 @@ class VIEW3D_OT_select_or_deselect_all(Operator): bpy.ops.mball.select_all(action='DESELECT') elif active_object.type == 'ARMATURE': bpy.ops.armature.select_all(action='DESELECT') - elif active_object.mode == 'POSE': + elif object_mode == 'POSE': bpy.ops.pose.select_all(action='DESELECT') - elif active_object.mode == 'PARTICLE_EDIT': + elif object_mode == 'PARTICLE_EDIT': bpy.ops.particle.select_all(action='DESELECT') else: bpy.ops.object.select_all(action='DESELECT') diff --git a/release/scripts/startup/bl_ui/properties_constraint.py b/release/scripts/startup/bl_ui/properties_constraint.py index 9b61101778f..f374d95c493 100644 --- a/release/scripts/startup/bl_ui/properties_constraint.py +++ b/release/scripts/startup/bl_ui/properties_constraint.py @@ -910,8 +910,9 @@ class OBJECT_PT_constraints(ConstraintButtonsPanel, Panel): layout = self.layout obj = context.object + workspace = context.workspace - if obj.type == 'ARMATURE' and obj.mode == 'POSE': + if obj.type == 'ARMATURE' and workspace.object_mode == 'POSE': box = layout.box() box.alert = True # XXX: this should apply to the box background box.label(icon='INFO', text="Constraints for active bone do not live here") diff --git a/release/scripts/startup/bl_ui/properties_data_bone.py b/release/scripts/startup/bl_ui/properties_data_bone.py index f0ef0032059..e8f290772d8 100644 --- a/release/scripts/startup/bl_ui/properties_data_bone.py +++ b/release/scripts/startup/bl_ui/properties_data_bone.py @@ -58,7 +58,8 @@ class BONE_PT_transform(BoneButtonsPanel, Panel): return True ob = context.object - return ob and ob.mode == 'POSE' and context.bone + workspace = context.workspace + return ob and workspace.object_mode == 'POSE' and context.bone def draw(self, context): layout = self.layout @@ -110,7 +111,8 @@ class BONE_PT_transform_locks(BoneButtonsPanel, Panel): @classmethod def poll(cls, context): ob = context.object - return ob and ob.mode == 'POSE' and context.bone + workspace = context.workspace + return ob and workspace.object_mode == 'POSE' and context.bone def draw(self, context): layout = self.layout @@ -311,7 +313,8 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel, Panel): @classmethod def poll(cls, context): ob = context.object - return ob and ob.mode == 'POSE' and context.bone + workspace = context.workspace + return ob and workspace.object_mode == 'POSE' and context.bone def draw(self, context): layout = self.layout @@ -439,7 +442,8 @@ class BONE_PT_custom_props(BoneButtonsPanel, PropertyPanel, Panel): @property def _context_path(self): obj = bpy.context.object - if obj and obj.mode == 'POSE': + workspace = context.workspace + if obj and workspace.object_mode == 'POSE': return "active_pose_bone" else: return "active_bone" diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index 9f927fe3368..ee6e09039be 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -94,10 +94,13 @@ class MESH_UL_shape_keys(UIList): # key = data key_block = item if self.layout_type in {'DEFAULT', 'COMPACT'}: + workspace = context.workspace split = layout.split(0.66, False) split.prop(key_block, "name", text="", emboss=False, icon_value=icon) row = split.row(align=True) - if key_block.mute or (obj.mode == 'EDIT' and not (obj.use_shape_key_edit_mode and obj.type == 'MESH')): + if (key_block.mute or + (workspace.object_mode == 'EDIT' and not (obj.use_shape_key_edit_mode and obj.type == 'MESH')) + ): row.active = False if not item.id_data.use_relative: row.prop(key_block, "frame", text="", emboss=False) @@ -205,6 +208,7 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, Panel): def draw(self, context): layout = self.layout + workspace = context.workspace ob = context.object group = ob.vertex_groups.active @@ -225,7 +229,10 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, Panel): col.operator("object.vertex_group_move", icon='TRIA_UP', text="").direction = 'UP' col.operator("object.vertex_group_move", icon='TRIA_DOWN', text="").direction = 'DOWN' - if ob.vertex_groups and (ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex)): + if (ob.vertex_groups and + ((workspace.object_mode == 'EDIT') or + (workspace.object_mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex)) + ): row = layout.row() sub = row.row(align=True) @@ -251,6 +258,7 @@ class DATA_PT_face_maps(MeshButtonsPanel, Panel): def draw(self, context): layout = self.layout + workspace = context.workspace ob = context.object facemap = ob.face_maps.active @@ -269,7 +277,7 @@ class DATA_PT_face_maps(MeshButtonsPanel, Panel): col.operator("object.face_map_move", icon='TRIA_UP', text="").direction = 'UP' col.operator("object.face_map_move", icon='TRIA_DOWN', text="").direction = 'DOWN' - if ob.face_maps and (ob.mode == 'EDIT' and ob.type == 'MESH'): + if ob.face_maps and (workspace.object_mode == 'EDIT' and ob.type == 'MESH'): row = layout.row() sub = row.row(align=True) @@ -293,11 +301,12 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel): def draw(self, context): layout = self.layout + workspace = context.workspace ob = context.object key = ob.data.shape_keys kb = ob.active_shape_key - enable_edit = ob.mode != 'EDIT' + enable_edit = workspace.object_mode != 'EDIT' enable_edit_value = False if ob.show_only_shape_key is False: @@ -419,6 +428,7 @@ class DATA_PT_customdata(MeshButtonsPanel, Panel): def draw(self, context): layout = self.layout + workspace = context.workspace obj = context.object me = context.mesh col = layout.column() @@ -433,7 +443,7 @@ class DATA_PT_customdata(MeshButtonsPanel, Panel): col = layout.column() - col.enabled = (obj.mode != 'EDIT') + col.enabled = (workspace.object_mode != 'EDIT') col.prop(me, "use_customdata_vertex_bevel") col.prop(me, "use_customdata_edge_bevel") col.prop(me, "use_customdata_edge_crease") diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 3169878ffe3..599b7c943a4 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -414,6 +414,8 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): layout.label(text="Settings are inside the Physics tab") def HOOK(self, layout, ob, md): + from bpy import context + workspace = context.workspace use_falloff = (md.falloff_type != 'NONE') split = layout.split() @@ -445,7 +447,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): col = split.column() col.prop(md, "use_falloff_uniform") - if ob.mode == 'EDIT': + if workspace.object_mode == 'EDIT': row = col.row(align=True) row.operator("object.hook_reset", text="Reset") row.operator("object.hook_recenter", text="Recenter") @@ -601,6 +603,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): col.prop(md, "mirror_object", text="") def MULTIRES(self, layout, ob, md): + from bpy import context + workspace = context.workspace + layout.row().prop(md, "subdivision_type", expand=True) split = layout.split() @@ -611,7 +616,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): col = split.column() - col.enabled = ob.mode != 'EDIT' + col.enabled = workspace.object_mode != 'EDIT' col.operator("object.multires_subdivide", text="Subdivide") col.operator("object.multires_higher_levels_delete", text="Delete Higher") col.operator("object.multires_reshape", text="Reshape") diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index 9aed338bad4..2dc7bffa527 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -148,7 +148,7 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel, Panel): col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP' col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN' - if ob.mode == 'EDIT': + if context.workspace.object_mode == 'EDIT': row = layout.row(align=True) row.operator("object.material_slot_assign", text="Assign") row.operator("object.material_slot_select", text="Select") @@ -1094,7 +1094,7 @@ class EEVEE_MATERIAL_PT_context_material(MaterialButtonsPanel, Panel): col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP' col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN' - if ob.mode == 'EDIT': + if context.workspace.object_mode == 'EDIT': row = layout.row(align=True) row.operator("object.material_slot_assign", text="Assign") row.operator("object.material_slot_select", text="Select") diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 123e95c013c..14ecb86e577 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -1208,7 +1208,8 @@ class ImageScopesPanel: if sima.mode == 'PAINT': return False ob = context.active_object - if ob and ob.mode in {'TEXTURE_PAINT', 'EDIT'}: + workspace = context.workspace + if ob and workspace.object_mode in {'TEXTURE_PAINT', 'EDIT'}: return False return True diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index f032f6a899b..8c69e733a2d 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -48,10 +48,7 @@ class INFO_HT_header(Header): layout.template_ID(window, "workspace", new="workspace.workspace_add_menu", unlink="workspace.workspace_delete") layout.template_search_preview(window, "screen", workspace, "screens", new="screen.new", unlink="screen.delete", rows=2, cols=6) - if hasattr(window, 'object_mode'): - act_mode_item = bpy.types.Object.bl_rna.properties['mode'].enum_items[window.object_mode] - else: - act_mode_item = bpy.types.Object.bl_rna.properties['mode'].enum_items[layer.objects.active.mode] + act_mode_item = bpy.types.WorkSpace.bl_rna.properties['object_mode'].enum_items[workspace.object_mode] layout.operator_menu_enum("object.mode_set", "mode", text=act_mode_item.name, icon=act_mode_item.icon) row = layout.row() @@ -87,7 +84,7 @@ class INFO_HT_header(Header): return row.operator("wm.splash", text="", icon='BLENDER', emboss=False) - row.label(text=scene.statistics(context.view_layer), translate=False) + row.label(text=scene.statistics(workspace, context.view_layer), translate=False) class INFO_MT_editor_menus(Menu): 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': diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index e29971e1835..7a3b0f26edc 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -2051,7 +2051,7 @@ class VIEW3D_PT_tools_history(View3DPanel, Panel): row = col.row(align=True) row.operator("ed.undo") row.operator("ed.redo") - if obj is None or obj.mode != 'SCULPT': + if obj is None or workspace.object_mode != 'SCULPT': # Sculpt mode does not generate an undo menu it seems... col.operator("ed.undo_history") diff --git a/release/scripts/startup/keyingsets_builtins.py b/release/scripts/startup/keyingsets_builtins.py index 390c043bb31..0a6ece6eb5a 100644 --- a/release/scripts/startup/keyingsets_builtins.py +++ b/release/scripts/startup/keyingsets_builtins.py @@ -388,8 +388,9 @@ class BUILTIN_KSI_WholeCharacter(KeyingSetInfo): # poll - pose-mode on active object only def poll(ksi, context): - return ((context.active_object) and (context.active_object.pose) and - (context.active_object.mode == 'POSE')) + workspace = context.workspace + ob = context.active_object + return (ob and ob.pose and (workspace.object_mode == 'POSE')) # iterator - all bones regardless of selection def iterator(ksi, context, ks): |