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-06 09:28:00 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-02-06 10:03:28 +0300
commit5ec016169b80cc8205740a5b3beb12f91be3182b (patch)
treecf3423e34d0a0d51b72b40d8efd3abe2cf5a5370 /source/blender/editors/screen/screen_ops.c
parent269ed0a770bf3627ba1e21d87d3d748c0765a531 (diff)
Object Mode: use eval_ctx for context/screen code
Diffstat (limited to 'source/blender/editors/screen/screen_ops.c')
-rw-r--r--source/blender/editors/screen/screen_ops.c70
1 files changed, 49 insertions, 21 deletions
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index e1480dbe967..9167c4c3d4d 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -68,6 +68,8 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "DEG_depsgraph.h"
+
#include "ED_armature.h"
#include "ED_clip.h"
#include "ED_image.h"
@@ -150,6 +152,8 @@ int ED_operator_scene_editable(bContext *C)
int ED_operator_objectmode(bContext *C)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
Scene *scene = CTX_data_scene(C);
Object *obact = CTX_data_active_object(C);
@@ -159,7 +163,7 @@ int ED_operator_objectmode(bContext *C)
return 0;
/* add a check for ob->mode too? */
- if (obact && (obact->mode != OB_MODE_OBJECT))
+ if (obact && (eval_ctx.object_mode != OB_MODE_OBJECT))
return 0;
return 1;
@@ -301,35 +305,43 @@ int ED_operator_console_active(bContext *C)
return ed_spacetype_test(C, SPACE_CONSOLE);
}
-static int ed_object_hidden(Object *ob)
+static int ed_object_hidden(const EvaluationContext *eval_ctx, Object *ob)
{
/* if hidden but in edit mode, we still display, can happen with animation */
- return ((ob->restrictflag & OB_RESTRICT_VIEW) && !(ob->mode & OB_MODE_EDIT));
+ return ((ob->restrictflag & OB_RESTRICT_VIEW) && !(eval_ctx->object_mode & OB_MODE_EDIT));
}
int ED_operator_object_active(bContext *C)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
- return ((ob != NULL) && !ed_object_hidden(ob));
+ return ((ob != NULL) && !ed_object_hidden(&eval_ctx, ob));
}
int ED_operator_object_active_editable(bContext *C)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
- return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob));
+ return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(&eval_ctx, ob));
}
int ED_operator_object_active_editable_mesh(bContext *C)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
- return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob) &&
+ return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(&eval_ctx, ob) &&
(ob->type == OB_MESH) && !ID_IS_LINKED(ob->data));
}
int ED_operator_object_active_editable_font(bContext *C)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
- return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob) &&
+ return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(&eval_ctx, ob) &&
(ob->type == OB_FONT));
}
@@ -374,11 +386,15 @@ int ED_operator_posemode_exclusive(bContext *C)
{
Object *obact = CTX_data_active_object(C);
- if (obact && !(obact->mode & OB_MODE_EDIT)) {
- Object *obpose;
- if ((obpose = BKE_object_pose_armature_get(obact))) {
- if (obact == obpose) {
- return 1;
+ if (obact) {
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+ if ((eval_ctx.object_mode & OB_MODE_EDIT) == 0) {
+ Object *obpose;
+ if ((obpose = BKE_object_pose_armature_get(obact))) {
+ if (obact == obpose) {
+ return 1;
+ }
}
}
}
@@ -392,9 +408,14 @@ int ED_operator_posemode_context(bContext *C)
{
Object *obpose = ED_pose_object_from_context(C);
- if (obpose && !(obpose->mode & OB_MODE_EDIT)) {
- if (BKE_object_pose_context_check(obpose)) {
- return 1;
+
+ if (obpose) {
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+ if ((eval_ctx.object_mode & OB_MODE_EDIT) == 0) {
+ if (BKE_object_pose_context_check(obpose)) {
+ return 1;
+ }
}
}
@@ -405,11 +426,16 @@ int ED_operator_posemode(bContext *C)
{
Object *obact = CTX_data_active_object(C);
- if (obact && !(obact->mode & OB_MODE_EDIT)) {
- Object *obpose;
- if ((obpose = BKE_object_pose_armature_get(obact))) {
- if ((obact == obpose) || (obact->mode & OB_MODE_WEIGHT_PAINT)) {
- return 1;
+
+ if (obact) {
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
+ if ((eval_ctx.object_mode & OB_MODE_EDIT) == 0) {
+ Object *obpose;
+ if ((obpose = BKE_object_pose_armature_get(obact))) {
+ if ((obact == obpose) || (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT)) {
+ return 1;
+ }
}
}
}
@@ -529,6 +555,8 @@ int ED_operator_editmball(bContext *C)
int ED_operator_mask(bContext *C)
{
+ EvaluationContext eval_ctx;
+ CTX_data_eval_ctx(C, &eval_ctx);
ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacedata.first) {
switch (sa->spacetype) {
@@ -547,7 +575,7 @@ int ED_operator_mask(bContext *C)
{
SpaceImage *sima = sa->spacedata.first;
ViewLayer *view_layer = CTX_data_view_layer(C);
- return ED_space_image_check_show_maskedit(view_layer, sima);
+ return ED_space_image_check_show_maskedit(sima, view_layer);
}
}
}