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 /source/blender/makesrna/intern/rna_wm.c | |
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 'source/blender/makesrna/intern/rna_wm.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_wm.c | 35 |
1 files changed, 11 insertions, 24 deletions
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"); |