diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-02-06 09:28:00 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-02-06 10:03:28 +0300 |
commit | 5ec016169b80cc8205740a5b3beb12f91be3182b (patch) | |
tree | cf3423e34d0a0d51b72b40d8efd3abe2cf5a5370 /source/blender/editors/screen | |
parent | 269ed0a770bf3627ba1e21d87d3d748c0765a531 (diff) |
Object Mode: use eval_ctx for context/screen code
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_context.c | 16 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 70 |
3 files changed, 60 insertions, 27 deletions
diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt index 02584a4611b..29b9971eabb 100644 --- a/source/blender/editors/screen/CMakeLists.txt +++ b/source/blender/editors/screen/CMakeLists.txt @@ -26,6 +26,7 @@ set(INC ../../blenloader ../../blentranslation ../../bmesh + ../../depsgraph ../../gpu ../../imbuf ../../makesdna diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 4c62253bef6..e4c3a051a13 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -53,6 +53,8 @@ #include "BKE_sequencer.h" #include "BKE_workspace.h" +#include "DEG_depsgraph.h" + #include "RNA_access.h" #include "ED_armature.h" @@ -84,6 +86,8 @@ const char *screen_context_dir[] = { int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result) { + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); wmWindow *win = CTX_wm_window(C); bScreen *sc = CTX_wm_screen(C); ScrArea *sa = CTX_wm_area(C); @@ -371,31 +375,31 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "sculpt_object")) { - if (obact && (obact->mode & OB_MODE_SCULPT)) + if (obact && (eval_ctx.object_mode & OB_MODE_SCULPT)) { CTX_data_id_pointer_set(result, &obact->id); - + } return 1; } else if (CTX_data_equals(member, "vertex_paint_object")) { - if (obact && (obact->mode & OB_MODE_VERTEX_PAINT)) + if (obact && (eval_ctx.object_mode & OB_MODE_VERTEX_PAINT)) CTX_data_id_pointer_set(result, &obact->id); return 1; } else if (CTX_data_equals(member, "weight_paint_object")) { - if (obact && (obact->mode & OB_MODE_WEIGHT_PAINT)) + if (obact && (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT)) CTX_data_id_pointer_set(result, &obact->id); return 1; } else if (CTX_data_equals(member, "image_paint_object")) { - if (obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) + if (obact && (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT)) CTX_data_id_pointer_set(result, &obact->id); return 1; } else if (CTX_data_equals(member, "particle_edit_object")) { - if (obact && (obact->mode & OB_MODE_PARTICLE_EDIT)) + if (obact && (eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT)) CTX_data_id_pointer_set(result, &obact->id); return 1; 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); } } } |