Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-02-08 13:14:26 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-02-08 13:14:26 +0300
commit345c6298e995ea618c34282ba6d7ab5af032f191 (patch)
treef4fbc4798e17d0f19efc28b51a41425d0c552be8 /release/scripts/startup/bl_ui
parent14a19fed788af0cf3695eb5def92510841056e08 (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/scripts/startup/bl_ui')
-rw-r--r--release/scripts/startup/bl_ui/properties_constraint.py3
-rw-r--r--release/scripts/startup/bl_ui/properties_data_bone.py12
-rw-r--r--release/scripts/startup/bl_ui/properties_data_mesh.py20
-rw-r--r--release/scripts/startup/bl_ui/properties_data_modifier.py9
-rw-r--r--release/scripts/startup/bl_ui/properties_material.py4
-rw-r--r--release/scripts/startup/bl_ui/space_image.py3
-rw-r--r--release/scripts/startup/bl_ui/space_info.py7
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py21
-rw-r--r--release/scripts/startup/bl_ui/space_view3d_toolbar.py2
9 files changed, 53 insertions, 28 deletions
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")