diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_main_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_main_api.c | 90 |
1 files changed, 85 insertions, 5 deletions
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index c110dbff6c4..5b898d7fd40 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -78,12 +78,15 @@ #include "BKE_paint.h" #include "BKE_font.h" #include "BKE_node.h" -#include "BKE_depsgraph.h" #include "BKE_speaker.h" +#include "BKE_lightprobe.h" #include "BKE_movieclip.h" #include "BKE_mask.h" #include "BKE_gpencil.h" #include "BKE_linestyle.h" +#include "BKE_workspace.h" + +#include "DEG_depsgraph_query.h" #include "DNA_armature_types.h" #include "DNA_camera_types.h" @@ -93,6 +96,7 @@ #include "DNA_mesh_types.h" #include "DNA_speaker_types.h" #include "DNA_sound_types.h" +#include "DNA_lightprobe_types.h" #include "DNA_text_types.h" #include "DNA_texture_types.h" #include "DNA_group_types.h" @@ -115,6 +119,8 @@ # include "BPY_extern.h" #endif +#include "WM_api.h" + static void rna_idname_validate(const char *name, char *r_name) { @@ -169,14 +175,15 @@ static void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports (scene_new = scene->id.next)) { if (do_unlink) { - bScreen *sc = CTX_wm_screen(C); - if (sc->scene == scene) { + wmWindow *win = CTX_wm_window(C); + + if (WM_window_get_active_scene(win) == scene) { #ifdef WITH_PYTHON BPy_BEGIN_ALLOW_THREADS; #endif - ED_screen_set_scene(C, sc, scene_new); + WM_window_change_active_scene(bmain, C, win, scene_new); #ifdef WITH_PYTHON BPy_END_ALLOW_THREADS; @@ -568,13 +575,23 @@ static FreestyleLineStyle *rna_Main_linestyles_new(Main *bmain, const char *name return linestyle; } +static LightProbe *rna_Main_lightprobe_new(Main *bmain, const char *name) +{ + char safe_name[MAX_ID_NAME - 2]; + rna_idname_validate(name, safe_name); + + LightProbe *probe = BKE_lightprobe_add(bmain, safe_name); + id_us_min(&probe->id); + return probe; +} + /* tag and is_updated functions, all the same */ #define RNA_MAIN_ID_TAG_FUNCS_DEF(_func_name, _listbase_name, _id_type) \ static void rna_Main_##_func_name##_tag(Main *bmain, int value) { \ BKE_main_id_tag_listbase(&bmain->_listbase_name, LIB_TAG_DOIT, value); \ } \ static int rna_Main_##_func_name##_is_updated_get(PointerRNA *ptr) { \ - return DAG_id_type_tagged(ptr->data, _id_type) != 0; \ + return DEG_id_type_tagged(ptr->data, _id_type) != 0; \ } RNA_MAIN_ID_TAG_FUNCS_DEF(cameras, camera, ID_CA) @@ -610,6 +627,8 @@ RNA_MAIN_ID_TAG_FUNCS_DEF(masks, mask, ID_MSK) RNA_MAIN_ID_TAG_FUNCS_DEF(linestyle, linestyle, ID_LS) RNA_MAIN_ID_TAG_FUNCS_DEF(cachefiles, cachefiles, ID_CF) RNA_MAIN_ID_TAG_FUNCS_DEF(paintcurves, paintcurves, ID_PC) +RNA_MAIN_ID_TAG_FUNCS_DEF(workspaces, workspaces, ID_WS) +RNA_MAIN_ID_TAG_FUNCS_DEF(lightprobes, lightprobe, ID_LP) #undef RNA_MAIN_ID_TAG_FUNCS_DEF @@ -1587,6 +1606,7 @@ void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_funcs(prop, "rna_Main_particles_is_updated_get", NULL); } + void RNA_def_main_palettes(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; @@ -1818,4 +1838,64 @@ void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_boolean_funcs(prop, "rna_Main_linestyle_is_updated_get", NULL); } +void RNA_def_main_workspaces(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + PropertyRNA *prop; + + RNA_def_property_srna(cprop, "BlendDataWorkSpaces"); + srna = RNA_def_struct(brna, "BlendDataWorkSpaces", NULL); + RNA_def_struct_sdna(srna, "Main"); + RNA_def_struct_ui_text(srna, "Main Workspaces", "Collection of workspaces"); + + func = RNA_def_function(srna, "tag", "rna_Main_workspaces_tag"); + parm = RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + + prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_workspaces_is_updated_get", NULL); +} + +void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + PropertyRNA *prop; + + RNA_def_property_srna(cprop, "BlendDataProbes"); + srna = RNA_def_struct(brna, "BlendDataProbes", NULL); + RNA_def_struct_sdna(srna, "Main"); + RNA_def_struct_ui_text(srna, "Main Light Probes", "Collection of light probes"); + + func = RNA_def_function(srna, "new", "rna_Main_lightprobe_new"); + RNA_def_function_ui_description(func, "Add a new probe to the main database"); + parm = RNA_def_string(func, "name", "Probe", 0, "", "New name for the data-block"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "lightprobe", "LightProbe", "", "New light probe data-block"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_Main_ID_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a probe from the current blendfile"); + parm = RNA_def_pointer(func, "lightprobe", "LightProbe", "", "Probe to remove"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); + RNA_def_boolean(func, "do_unlink", true, "", + "Unlink all usages of this probe before deleting it " + "(WARNING: will also delete objects instancing that light probe data)"); + + func = RNA_def_function(srna, "tag", "rna_Main_lightprobes_tag"); + parm = RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + + prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_lightprobes_is_updated_get", NULL); +} + #endif |