diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_space.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 162 |
1 files changed, 105 insertions, 57 deletions
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index f2e856bf1ba..dbd74a0c0c0 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -208,6 +208,7 @@ static EnumPropertyItem buttons_context_items[] = { {BCONTEXT_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture"}, {BCONTEXT_PARTICLE, "PARTICLES", ICON_PARTICLES, "Particles", "Particle"}, {BCONTEXT_PHYSICS, "PHYSICS", ICON_PHYSICS, "Physics", "Physics"}, + {BCONTEXT_COLLECTION, "COLLECTION", ICON_COLLAPSEMENU, "Collection", "Collection"}, {0, NULL, 0, NULL, NULL} }; @@ -253,17 +254,23 @@ EnumPropertyItem rna_enum_file_sort_items[] = { #include "BKE_brush.h" #include "BKE_colortools.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" +#include "BKE_layer.h" +#include "BKE_global.h" #include "BKE_nla.h" #include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_icons.h" +#include "BKE_workspace.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" #include "ED_buttons.h" #include "ED_fileselect.h" #include "ED_image.h" #include "ED_node.h" +#include "ED_transform.h" #include "ED_screen.h" #include "ED_view3d.h" #include "ED_sequencer.h" @@ -403,43 +410,63 @@ static void rna_Space_view2d_sync_update(Main *UNUSED(bmain), Scene *UNUSED(scen } } -static PointerRNA rna_CurrentOrientation_get(PointerRNA *ptr) +static int rna_View3D_transform_orientation_get(PointerRNA *ptr) +{ + const View3D *v3d = (View3D *)ptr->data; + /* convert to enum value */ + return (v3d->twmode == V3D_MANIP_CUSTOM) ? (v3d->twmode + v3d->custom_orientation_index) : v3d->twmode; +} + +void rna_View3D_transform_orientation_set(PointerRNA *ptr, int value) { - Scene *scene = ((bScreen *)ptr->id.data)->scene; View3D *v3d = (View3D *)ptr->data; + BIF_selectTransformOrientationValue(v3d, value); +} - if (v3d->twmode < V3D_MANIP_CUSTOM) - return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, NULL); - else - return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, - BLI_findlink(&scene->transform_spaces, v3d->twmode - V3D_MANIP_CUSTOM)); +static PointerRNA rna_View3D_current_orientation_get(PointerRNA *ptr) +{ + View3D *v3d = (View3D *)ptr->data; + TransformOrientation *orientation; + + if (v3d->twmode < V3D_MANIP_CUSTOM) { + orientation = NULL; + } + else { + WorkSpace *workspace; + bScreen *screen = ptr->id.data; + + BKE_workspace_layout_find_global(G.main, screen, &workspace); + orientation = BKE_workspace_transform_orientation_find(workspace, v3d->custom_orientation_index); + } + + return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, orientation); } EnumPropertyItem *rna_TransformOrientation_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - Scene *scene = NULL; - ListBase *transform_spaces; - TransformOrientation *ts = NULL; + WorkSpace *workspace; + ListBase *transform_orientations; EnumPropertyItem tmp = {0, "", 0, "", ""}; EnumPropertyItem *item = NULL; int i = V3D_MANIP_CUSTOM, totitem = 0; RNA_enum_items_add(&item, &totitem, transform_orientation_items); - if (ptr->type == &RNA_SpaceView3D) - scene = ((bScreen *)ptr->id.data)->scene; - else - scene = CTX_data_scene(C); /* can't use scene from ptr->id.data because that enum is also used by operators */ - - if (scene) { - transform_spaces = &scene->transform_spaces; - ts = transform_spaces->first; + if (ptr->type == &RNA_SpaceView3D) { + bScreen *screen = ptr->id.data; + BKE_workspace_layout_find_global(G.main, screen, &workspace); + } + else { + /* can't use scene from ptr->id.data because that enum is also used by operators */ + workspace = CTX_wm_workspace(C); } - if (ts) { + transform_orientations = BKE_workspace_transform_orientations_get(workspace); + + if (BLI_listbase_is_empty(transform_orientations) == false) { RNA_enum_item_add_separator(&item, &totitem); - for (; ts; ts = ts->next) { + for (TransformOrientation *ts = transform_orientations->first; ts; ts = ts->next) { tmp.identifier = ts->name; tmp.name = ts->name; tmp.value = i++; @@ -458,8 +485,10 @@ static void rna_SpaceView3D_camera_update(Main *bmain, Scene *scene, PointerRNA { View3D *v3d = (View3D *)(ptr->data); if (v3d->scenelock) { + wmWindowManager *wm = bmain->wm.first; + scene->camera = v3d->camera; - BKE_screen_view3d_main_sync(&bmain->screen, scene); + WM_windows_scene_data_sync(&wm->windows, scene); } } @@ -471,8 +500,10 @@ static void rna_SpaceView3D_lock_camera_and_layers_set(PointerRNA *ptr, int valu v3d->scenelock = value; if (value) { + Scene *scene = ED_screen_scene_find(sc, G.main->wm.first); int bit; - v3d->lay = sc->scene->lay; + + v3d->lay = scene->lay; /* seek for layact */ bit = 0; while (bit < 32) { @@ -482,15 +513,15 @@ static void rna_SpaceView3D_lock_camera_and_layers_set(PointerRNA *ptr, int valu } bit++; } - v3d->camera = sc->scene->camera; + v3d->camera = scene->camera; } } static void rna_View3D_CursorLocation_get(PointerRNA *ptr, float *values) { View3D *v3d = (View3D *)(ptr->data); - bScreen *sc = (bScreen *)ptr->id.data; - Scene *scene = (Scene *)sc->scene; + bScreen *screen = ptr->id.data; + Scene *scene = ED_screen_scene_find(screen, G.main->wm.first); const float *loc = ED_view3d_cursor3d_get(scene, v3d); copy_v3_v3(values, loc); @@ -499,8 +530,8 @@ static void rna_View3D_CursorLocation_get(PointerRNA *ptr, float *values) static void rna_View3D_CursorLocation_set(PointerRNA *ptr, const float *values) { View3D *v3d = (View3D *)(ptr->data); - bScreen *sc = (bScreen *)ptr->id.data; - Scene *scene = (Scene *)sc->scene; + bScreen *screen = ptr->id.data; + Scene *scene = ED_screen_scene_find(screen, G.main->wm.first); float *cursor = ED_view3d_cursor3d_get(scene, v3d); copy_v3_v3(cursor, values); @@ -509,8 +540,8 @@ static void rna_View3D_CursorLocation_set(PointerRNA *ptr, const float *values) static float rna_View3D_GridScaleUnit_get(PointerRNA *ptr) { View3D *v3d = (View3D *)(ptr->data); - bScreen *sc = (bScreen *)ptr->id.data; - Scene *scene = (Scene *)sc->scene; + bScreen *screen = ptr->id.data; + Scene *scene = ED_screen_scene_find(screen, G.main->wm.first); return ED_view3d_grid_scale(scene, v3d, NULL); } @@ -531,7 +562,7 @@ static int rna_SpaceView3D_active_layer_get(PointerRNA *ptr) static void rna_SpaceView3D_layer_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) { - DAG_on_visible_update(bmain, false); + DEG_on_visible_update(bmain, false); } static void rna_SpaceView3D_viewport_shade_update(Main *bmain, Scene *scene, PointerRNA *ptr) @@ -694,12 +725,12 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value static int rna_SpaceView3D_viewport_shade_get(PointerRNA *ptr) { - Scene *scene = ((bScreen *)ptr->id.data)->scene; + Scene *scene = WM_windows_scene_get_from_screen(G.main->wm.first, ptr->id.data); RenderEngineType *type = RE_engines_find(scene->r.engine); View3D *v3d = (View3D *)ptr->data; int drawtype = v3d->drawtype; - if (drawtype == OB_RENDER && !(type && type->view_draw)) + if (drawtype == OB_RENDER && !(type && type->render_to_view)) return OB_SOLID; return drawtype; @@ -714,10 +745,11 @@ static void rna_SpaceView3D_viewport_shade_set(PointerRNA *ptr, int value) v3d->drawtype = value; } -static EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *UNUSED(C), PointerRNA *ptr, +static EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { - Scene *scene = ((bScreen *)ptr->id.data)->scene; + wmWindow *win = CTX_wm_window(C); + Scene *scene = WM_window_get_active_scene(win); RenderEngineType *type = RE_engines_find(scene->r.engine); EnumPropertyItem *item = NULL; @@ -729,7 +761,7 @@ static EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *UNUSED(C RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_TEXTURE); RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_MATERIAL); - if (type && type->view_draw) + if (type && type->render_to_view) RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_RENDER); RNA_enum_item_end(&item, &totitem); @@ -738,10 +770,10 @@ static EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *UNUSED(C return item; } -static EnumPropertyItem *rna_SpaceView3D_stereo3d_camera_itemf(bContext *UNUSED(C), PointerRNA *ptr, +static EnumPropertyItem *rna_SpaceView3D_stereo3d_camera_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) { - Scene *scene = ((bScreen *)ptr->id.data)->scene; + Scene *scene = CTX_data_scene(C); if (scene->r.views_format == SCE_VIEWS_FORMAT_MULTIVIEW) return multiview_camera_items; @@ -809,22 +841,28 @@ static int rna_SpaceImageEditor_show_uvedit_get(PointerRNA *ptr) { SpaceImage *sima = (SpaceImage *)(ptr->data); bScreen *sc = (bScreen *)ptr->id.data; - return ED_space_image_show_uvedit(sima, sc->scene->obedit); + Scene *scene = ED_screen_scene_find(sc, G.main->wm.first); + + return ED_space_image_show_uvedit(sima, scene->obedit); } static int rna_SpaceImageEditor_show_maskedit_get(PointerRNA *ptr) { SpaceImage *sima = (SpaceImage *)(ptr->data); bScreen *sc = (bScreen *)ptr->id.data; - return ED_space_image_check_show_maskedit(sc->scene, sima); + Scene *scene = ED_screen_scene_find(sc, G.main->wm.first); + SceneLayer *sl = BKE_scene_layer_context_active(scene); + + return ED_space_image_check_show_maskedit(sl, sima); } static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value) { SpaceImage *sima = (SpaceImage *)(ptr->data); bScreen *sc = (bScreen *)ptr->id.data; + Scene *scene = ED_screen_scene_find(sc, G.main->wm.first); - ED_space_image_set(sima, sc->scene, sc->scene->obedit, (Image *)value.data); + ED_space_image_set(sima, scene, scene->obedit, (Image *)value.data); } static void rna_SpaceImageEditor_mask_set(PointerRNA *ptr, PointerRNA value) @@ -1076,6 +1114,10 @@ static EnumPropertyItem *rna_SpaceProperties_context_itemf(bContext *UNUSED(C), RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_SCENE); } + if (sbuts->pathflag & (1 << BCONTEXT_COLLECTION)) { + RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_COLLECTION); + } + if (sbuts->pathflag & (1 << BCONTEXT_WORLD)) { RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_WORLD); } @@ -1261,10 +1303,11 @@ static void rna_SpaceDopeSheetEditor_action_set(PointerRNA *ptr, PointerRNA valu } } -static void rna_SpaceDopeSheetEditor_action_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_SpaceDopeSheetEditor_action_update(Main *bmain, bContext *C, Scene *UNUSED(scene), PointerRNA *ptr) { SpaceAction *saction = (SpaceAction *)(ptr->data); - Object *obact = (scene->basact) ? scene->basact->object : NULL; + SceneLayer *sl = CTX_data_scene_layer(C); + Object *obact = OBACT_NEW; /* we must set this action to be the one used by active object (if not pinned) */ if (obact /* && saction->pin == 0*/) { @@ -1330,16 +1373,17 @@ static void rna_SpaceDopeSheetEditor_action_update(Main *bmain, Scene *scene, Po } /* force depsgraph flush too */ - DAG_id_tag_update(&obact->id, OB_RECALC_OB | OB_RECALC_DATA); + DEG_id_tag_update(&obact->id, OB_RECALC_OB | OB_RECALC_DATA); /* Update relations as well, so new time source dependency is added. */ - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); } } -static void rna_SpaceDopeSheetEditor_mode_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +static void rna_SpaceDopeSheetEditor_mode_update(bContext *C, PointerRNA *ptr) { SpaceAction *saction = (SpaceAction *)(ptr->data); - Object *obact = (scene->basact) ? scene->basact->object : NULL; + SceneLayer *sl = CTX_data_scene_layer(C); + Object *obact = OBACT_NEW; /* special exceptions for ShapeKey Editor mode */ if (saction->mode == SACTCONT_SHAPEKEY) { @@ -2101,6 +2145,9 @@ static void rna_def_space_outliner(BlenderRNA *brna) {SO_USERDEF, "USER_PREFERENCES", 0, "User Preferences", "Display user preference data"}, {SO_ID_ORPHANS, "ORPHAN_DATA", 0, "Orphan Data", "Display data-blocks which are unused and/or will be lost when the file is reloaded"}, + {SO_ACT_LAYER, "ACT_LAYER", 0, "Active Render Layer", "Display the collections of the active render layer"}, + {SO_COLLECTIONS, "MASTER_COLLECTION", 0, "Master Collection Tree", "Display all collections based on the " + "master collection hierarchy"}, {0, NULL, 0, NULL, NULL} }; @@ -2645,13 +2692,14 @@ static void rna_def_space_view3d(BlenderRNA *brna) prop = RNA_def_property(srna, "transform_orientation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "twmode"); RNA_def_property_enum_items(prop, transform_orientation_items); - RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_TransformOrientation_itemf"); + RNA_def_property_enum_funcs(prop, "rna_View3D_transform_orientation_get", "rna_View3D_transform_orientation_set", + "rna_TransformOrientation_itemf"); RNA_def_property_ui_text(prop, "Transform Orientation", "Transformation orientation"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "current_orientation", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "TransformOrientation"); - RNA_def_property_pointer_funcs(prop, "rna_CurrentOrientation_get", NULL, NULL, NULL); + RNA_def_property_pointer_funcs(prop, "rna_View3D_current_orientation_get", NULL, NULL, NULL); RNA_def_property_ui_text(prop, "Current Transform Orientation", "Current transformation orientation"); prop = RNA_def_property(srna, "lock_camera_and_layers", PROP_BOOLEAN, PROP_NONE); @@ -3406,6 +3454,7 @@ static void rna_def_space_dopesheet(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceDopeSheetEditor_action_set", NULL, "rna_Action_actedit_assign_poll"); RNA_def_property_ui_text(prop, "Action", "Action displayed and edited in this space"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_SpaceDopeSheetEditor_action_update"); /* mode */ @@ -3413,6 +3462,7 @@ static void rna_def_space_dopesheet(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "mode"); RNA_def_property_enum_items(prop, mode_items); RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, "rna_SpaceDopeSheetEditor_mode_update"); /* display */ @@ -3856,6 +3906,7 @@ static void rna_def_fileselect_params(BlenderRNA *brna) "Particles Settings", "Show/hide Particle Settings data-blocks"}, {FILTER_ID_PAL, "PALETTE", ICON_COLOR, "Palettes", "Show/hide Palette data-blocks"}, {FILTER_ID_PC, "PAINT_CURVE", ICON_CURVE_BEZCURVE, "Paint Curves", "Show/hide Paint Curve data-blocks"}, + {FILTER_ID_LP, "LIGHT_PROBE", ICON_RADIO, "Light Probes", "Show/hide Light Probe data-blocks"}, {FILTER_ID_SCE, "SCENE", ICON_SCENE_DATA, "Scenes", "Show/hide Scene data-blocks"}, {FILTER_ID_SPK, "SPEAKER", ICON_SPEAKER, "Speakers", "Show/hide Speaker data-blocks"}, {FILTER_ID_SO, "SOUND", ICON_SOUND, "Sounds", "Show/hide Sound data-blocks"}, @@ -3863,6 +3914,7 @@ static void rna_def_fileselect_params(BlenderRNA *brna) {FILTER_ID_TXT, "TEXT", ICON_TEXT, "Texts", "Show/hide Text data-blocks"}, {FILTER_ID_VF, "FONT", ICON_FONT_DATA, "Fonts", "Show/hide Font data-blocks"}, {FILTER_ID_WO, "WORLD", ICON_WORLD_DATA, "Worlds", "Show/hide World data-blocks"}, + {FILTER_ID_WS, "WORK_SPACE", ICON_NONE, "Workspaces", "Show/hide workspace data-blocks"}, {0, NULL, 0, NULL, NULL} }; @@ -3880,7 +3932,7 @@ static void rna_def_fileselect_params(BlenderRNA *brna) "Show/hide materials, nodetrees, textures and Freestyle's linestyles"}, {FILTER_ID_IM | FILTER_ID_MC | FILTER_ID_MSK | FILTER_ID_SO, "IMAGE", ICON_IMAGE_DATA, "Images & Sounds", "Show/hide images, movie clips, sounds and masks"}, - {FILTER_ID_CA | FILTER_ID_LA | FILTER_ID_SPK | FILTER_ID_WO, + {FILTER_ID_CA | FILTER_ID_LA | FILTER_ID_SPK | FILTER_ID_WO | FILTER_ID_WS, "ENVIRONMENT", ICON_WORLD_DATA, "Environment", "Show/hide worlds, lamps, cameras and speakers"}, {FILTER_ID_BR | FILTER_ID_GD | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_CF, "MISC", ICON_GREASEPENCIL, "Miscellaneous", "Show/hide other data types"}, @@ -4395,14 +4447,10 @@ static void rna_def_space_node(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Backdrop Zoom", "Backdrop zoom factor"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); - prop = RNA_def_property(srna, "backdrop_x", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "backdrop_offset", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xof"); - RNA_def_property_ui_text(prop, "Backdrop X", "Backdrop X offset"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); - - prop = RNA_def_property(srna, "backdrop_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "yof"); - RNA_def_property_ui_text(prop, "Backdrop Y", "Backdrop Y offset"); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "Backdrop Offset", "Backdrop offset"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); prop = RNA_def_property(srna, "backdrop_channels", PROP_ENUM, PROP_NONE); |