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 /source/blender/makesrna/intern
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 'source/blender/makesrna/intern')
-rw-r--r--source/blender/makesrna/intern/rna_brush.c12
-rw-r--r--source/blender/makesrna/intern/rna_layer.c23
-rw-r--r--source/blender/makesrna/intern/rna_object.c13
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c5
-rw-r--r--source/blender/makesrna/intern/rna_scene.c1
-rw-r--r--source/blender/makesrna/intern/rna_space.c7
-rw-r--r--source/blender/makesrna/intern/rna_texture.c4
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c5
-rw-r--r--source/blender/makesrna/intern/rna_wm.c35
-rw-r--r--source/blender/makesrna/intern/rna_workspace.c4
10 files changed, 65 insertions, 44 deletions
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 5336a63fb76..aa37c9ffa88 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -31,6 +31,7 @@
#include "DNA_texture_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
+#include "DNA_workspace_types.h"
#include "BLI_math.h"
@@ -43,6 +44,8 @@
#include "WM_types.h"
+#include "DEG_depsgraph.h"
+
static const EnumPropertyItem prop_direction_items[] = {
{0, "ADD", 0, "Add", "Add effect of brush"},
{BRUSH_DIR_IN, "SUBTRACT", 0, "Subtract", "Subtract effect of brush"},
@@ -373,21 +376,23 @@ static void rna_Brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR
static void rna_Brush_main_tex_update(bContext *C, PointerRNA *ptr)
{
+ const WorkSpace *workspace = CTX_wm_workspace(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Brush *br = (Brush *)ptr->data;
- BKE_paint_invalidate_overlay_tex(scene, view_layer, br->mtex.tex);
+ BKE_paint_invalidate_overlay_tex(scene, view_layer, br->mtex.tex, workspace->object_mode);
rna_Brush_update(bmain, scene, ptr);
}
static void rna_Brush_secondary_tex_update(bContext *C, PointerRNA *ptr)
{
Main *bmain = CTX_data_main(C);
+ const WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Brush *br = (Brush *)ptr->data;
- BKE_paint_invalidate_overlay_tex(scene, view_layer, br->mask_mtex.tex);
+ BKE_paint_invalidate_overlay_tex(scene, view_layer, br->mask_mtex.tex, workspace->object_mode);
rna_Brush_update(bmain, scene, ptr);
}
@@ -449,8 +454,9 @@ static void rna_TextureSlot_brush_angle_update(bContext *C, PointerRNA *ptr)
MTex *mtex = ptr->data;
/* skip invalidation of overlay for stencil mode */
if (mtex->mapping != MTEX_MAP_MODE_STENCIL) {
+ const WorkSpace *workspace = CTX_wm_workspace(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- BKE_paint_invalidate_overlay_tex(scene, view_layer, mtex->tex);
+ BKE_paint_invalidate_overlay_tex(scene, view_layer, mtex->tex, workspace->object_mode);
}
rna_TextureSlot_update(C, ptr);
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c
index 6930aa115c7..a3d570df40a 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -64,6 +64,7 @@ const EnumPropertyItem rna_enum_collection_type_items[] = {
#include "DNA_group_types.h"
#include "DNA_object_types.h"
+#include "DNA_workspace_types.h"
#include "RNA_access.h"
@@ -72,6 +73,7 @@ const EnumPropertyItem rna_enum_collection_type_items[] = {
#include "BKE_node.h"
#include "BKE_scene.h"
#include "BKE_mesh.h"
+#include "BKE_workspace.h"
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
@@ -835,6 +837,23 @@ static void rna_LayerObjects_active_object_set(PointerRNA *ptr, PointerRNA value
view_layer->basact = NULL;
}
+static void rna_LayerObjects_active_object_update(struct bContext *C, PointerRNA *ptr)
+{
+ wmWindow *win = CTX_wm_window(C);
+ Scene *scene = WM_window_get_active_scene(win);
+
+ if (scene != ptr->id.data) {
+ return;
+ }
+
+ WorkSpace *workspace = WM_window_get_active_workspace(win);
+ ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
+ if (scene->obedit) {
+ ED_object_editmode_exit(C, EM_FREEDATA);
+ }
+ ED_object_base_activate(C, view_layer->basact);
+}
+
static IDProperty *rna_ViewLayer_idprops(PointerRNA *ptr, bool create)
{
ViewLayer *view_layer = (ViewLayer *)ptr->data;
@@ -2129,11 +2148,11 @@ static void rna_def_layer_objects(BlenderRNA *brna, PropertyRNA *cprop)
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_pointer_funcs(prop, "rna_LayerObjects_active_object_get", "rna_LayerObjects_active_object_set", NULL, NULL);
- RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK | PROP_CONTEXT_UPDATE);
RNA_def_property_ui_text(prop, "Active Object", "Active object for this layer");
/* Could call: ED_object_base_activate(C, rl->basact);
* but would be a bad level call and it seems the notifier is enough */
- RNA_def_property_update(prop, NC_SCENE | ND_OB_ACTIVE, NULL);
+ RNA_def_property_update(prop, NC_SCENE | ND_OB_ACTIVE, "rna_LayerObjects_active_object_update");
prop = RNA_def_property(srna, "selected", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "object_bases", NULL);
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 6b495c61258..195db6ec429 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -337,7 +337,7 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value)
Object *ob = (Object *)ptr->data;
ID *id = value.data;
- if (ob->mode & OB_MODE_EDIT) {
+ if (BKE_object_is_in_editmode(ob)) {
return;
}
@@ -1394,7 +1394,10 @@ static void rna_Object_constraints_clear(Object *object)
static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, ReportList *reports,
const char *name, int type)
{
- return ED_object_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type);
+ Main *bmain = CTX_data_main(C);
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+ return ED_object_modifier_add(reports, bmain, CTX_data_scene(C), object, eval_ctx.object_mode, name, type);
}
static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, PointerRNA *md_ptr)
@@ -2419,12 +2422,6 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Type", "Type of Object");
- prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "mode");
- RNA_def_property_enum_items(prop, rna_enum_object_mode_items);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Mode", "Object interaction mode");
-
prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER);
RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000);
RNA_def_property_array(prop, 8);
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index 941cef0eafe..32edabe37d9 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -53,6 +53,7 @@ static const EnumPropertyItem effector_shape_items[] = {
#include "BLI_math_base.h"
+#include "BKE_main.h"
/* type specific return values only used from functions */
static const EnumPropertyItem curve_shape_items[] = {
@@ -523,7 +524,7 @@ static void rna_FieldSettings_shape_update(Main *bmain, Scene *scene, PointerRNA
{
if (!particle_id_check(ptr)) {
Object *ob = (Object *)ptr->id.data;
- ED_object_check_force_modifiers(bmain, scene, ob);
+ ED_object_check_force_modifiers(bmain, scene, ob, bmain->eval_ctx->object_mode);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
}
@@ -710,7 +711,7 @@ static void rna_CollisionSettings_dependency_update(Main *bmain, Scene *scene, P
/* add/remove modifier as needed */
if (ob->pd->deflect && !md)
- ED_object_modifier_add(NULL, bmain, scene, ob, NULL, eModifierType_Collision);
+ ED_object_modifier_add(NULL, bmain, scene, ob, bmain->eval_ctx->object_mode , NULL, eModifierType_Collision);
else if (!ob->pd->deflect && md)
ED_object_modifier_remove(NULL, bmain, ob, md);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index c2bf62da043..90c653fdf2a 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -6964,6 +6964,7 @@ void RNA_def_scene(BlenderRNA *brna)
/* Statistics */
func = RNA_def_function(srna, "statistics", "ED_info_stats_string");
+ parm = RNA_def_pointer(func, "workspace", "WorkSpace", "", "Active workspace");
parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Active layer");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
parm = RNA_def_string(func, "statistics", NULL, 0, "Statistics", "");
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 7d17af4addb..b4a42b3a909 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -866,10 +866,11 @@ static int rna_SpaceImageEditor_show_maskedit_get(PointerRNA *ptr)
{
SpaceImage *sima = (SpaceImage *)(ptr->data);
bScreen *sc = (bScreen *)ptr->id.data;
- Scene *scene = ED_screen_scene_find(sc, G.main->wm.first);
+ wmWindow *window = NULL;
+ Scene *scene = ED_screen_scene_find_with_window(sc, G.main->wm.first, &window);
ViewLayer *view_layer = BKE_view_layer_context_active_PLACEHOLDER(scene);
-
- return ED_space_image_check_show_maskedit(sima, view_layer);
+ const WorkSpace *workspace = WM_window_get_active_workspace(window);
+ return ED_space_image_check_show_maskedit(sima, workspace, view_layer);
}
static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value)
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index 42e3e2c83fb..e2e44a8ac5c 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -37,6 +37,7 @@
#include "DNA_node_types.h"
#include "DNA_particle_types.h"
#include "DNA_scene_types.h" /* MAXFRAME only */
+#include "DNA_workspace_types.h"
#include "BLI_utildefines.h"
@@ -247,10 +248,11 @@ void rna_TextureSlot_update(bContext *C, PointerRNA *ptr)
break;
case ID_BR:
{
+ const WorkSpace *workspace = CTX_wm_workspace(C);
Scene *scene = CTX_data_scene(C);
MTex *mtex = ptr->data;
ViewLayer *view_layer = CTX_data_view_layer(C);
- BKE_paint_invalidate_overlay_tex(scene, view_layer, mtex->tex);
+ BKE_paint_invalidate_overlay_tex(scene, view_layer, mtex->tex, workspace->object_mode);
WM_main_add_notifier(NC_BRUSH, id);
break;
}
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 1ae946fda9e..69997883c42 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -364,8 +364,11 @@ static void rna_UserDef_weight_color_update(Main *bmain, Scene *scene, PointerRN
vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, btheme->tv3d.vertex_unreferenced);
for (ob = bmain->object.first; ob; ob = ob->id.next) {
- if (ob->mode & OB_MODE_WEIGHT_PAINT)
+ /* TODO/OBMODE (not urgent) */
+ // if (ob->mode & OB_MODE_WEIGHT_PAINT)
+ {
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ }
}
rna_userdef_update(bmain, scene, ptr);
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index bcb5bb524f0..f3cf2bb0d64 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -473,6 +473,7 @@ const EnumPropertyItem rna_enum_wm_report_items[] = {
#include "DNA_workspace_types.h"
#include "ED_screen.h"
+#include "ED_object.h"
#include "UI_interface.h"
@@ -778,28 +779,21 @@ static void rna_Window_view_layer_set(PointerRNA *ptr, PointerRNA value)
BKE_workspace_view_layer_set(workspace, value.data, scene);
}
-#ifdef USE_WORKSPACE_MODE
-
-static int rna_Window_object_mode_get(PointerRNA *ptr)
-{
- wmWindow *win = ptr->data;
- Scene *scene = WM_window_get_active_scene(win);
- WorkSpace *workspace = WM_window_get_active_workspace(win);
-
- return (int)BKE_workspace_object_mode_get(workspace, scene);
-}
-
-static void rna_Window_object_mode_set(PointerRNA *ptr, int value)
+static void rna_Window_view_layer_update(struct bContext *C, PointerRNA *ptr)
{
wmWindow *win = ptr->data;
Scene *scene = WM_window_get_active_scene(win);
WorkSpace *workspace = WM_window_get_active_workspace(win);
+ ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
- BKE_workspace_object_mode_set(workspace, scene, value);
+ eObjectMode object_mode = workspace->object_mode;
+ if (scene->obedit) {
+ ED_object_editmode_exit(C, EM_FREEDATA);
+ }
+ workspace->object_mode = object_mode;
+ ED_object_base_activate(C, view_layer->basact);
}
-#endif /* USE_WORKSPACE_MODE */
-
static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr)
{
wmKeyMapItem *kmi = ptr->data;
@@ -2083,15 +2077,8 @@ static void rna_def_window(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "ViewLayer");
RNA_def_property_pointer_funcs(prop, "rna_Window_view_layer_get", "rna_Window_view_layer_set", NULL, NULL);
RNA_def_property_ui_text(prop, "Active View Layer", "The active workspace view layer showing in the window");
- RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
- RNA_def_property_update(prop, NC_SCREEN | ND_LAYER, NULL);
-
-#ifdef USE_WORKSPACE_MODE
- prop = RNA_def_property(srna, "object_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, rna_enum_object_mode_items);
- RNA_def_property_enum_funcs(prop, "rna_Window_object_mode_get", "rna_Window_object_mode_set", NULL);
- RNA_def_property_ui_text(prop, "Mode", "Object interaction mode used in this window");
-#endif
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL | PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCREEN | ND_LAYER, "rna_Window_view_layer_update");
prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "posx");
diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c
index 0bed91f2807..5e0a4b97981 100644
--- a/source/blender/makesrna/intern/rna_workspace.c
+++ b/source/blender/makesrna/intern/rna_workspace.c
@@ -121,6 +121,10 @@ static void rna_def_workspace(BlenderRNA *brna)
"rna_workspace_transform_orientations_item_get", NULL, NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Transform Orientations", "");
+ prop = RNA_def_property(srna, "object_mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, rna_enum_object_mode_items);
+ RNA_def_property_ui_text(prop, "Mode", "Object interaction mode used in this window");
+
/* View Render */
prop = RNA_def_property(srna, "view_render", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);