Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_workspace.c
| Show All 22 Lines | |||||
| */ | */ | ||||
| #include "RNA_define.h" | #include "RNA_define.h" | ||||
| #include "RNA_enum_types.h" | #include "RNA_enum_types.h" | ||||
| #include "RNA_types.h" | #include "RNA_types.h" | ||||
| #include "BKE_workspace.h" | #include "BKE_workspace.h" | ||||
| #include "ED_render.h" | |||||
| #include "RE_engine.h" | |||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "rna_internal.h" | #include "rna_internal.h" | ||||
| /* Allow accessing private members of DNA_workspace_types.h */ | |||||
| #define DNA_PRIVATE_WORKSPACE_ALLOW | |||||
| #include "DNA_workspace_types.h" | |||||
| #ifdef RNA_RUNTIME | #ifdef RNA_RUNTIME | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_workspace_types.h" | |||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| void rna_workspace_screens_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) | void rna_workspace_screens_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) | ||||
| { | { | ||||
| WorkSpace *workspace = ptr->id.data; | WorkSpace *workspace = ptr->id.data; | ||||
| rna_iterator_listbase_begin(iter, BKE_workspace_layouts_get(workspace), NULL); | rna_iterator_listbase_begin(iter, BKE_workspace_layouts_get(workspace), NULL); | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static void rna_workspace_render_layer_set(PointerRNA *ptr, PointerRNA value) | static void rna_workspace_render_layer_set(PointerRNA *ptr, PointerRNA value) | ||||
| { | { | ||||
| WorkSpace *workspace = ptr->data; | WorkSpace *workspace = ptr->data; | ||||
| BKE_workspace_render_layer_set(workspace, value.data); | BKE_workspace_render_layer_set(workspace, value.data); | ||||
| } | } | ||||
| static void rna_workspace_engine_set(PointerRNA *ptr, int value) | |||||
| { | |||||
| WorkSpace *workspace = (WorkSpace *)ptr->data; | |||||
| RenderEngineType *type = BLI_findlink(&R_engines, value); | |||||
| if (type != NULL) { | |||||
campbellbarton: Could `BLI_assert` if this isn't found. | |||||
| BKE_workspace_engine_set(workspace, type->idname); | |||||
| } | |||||
| } | |||||
| static EnumPropertyItem *rna_workspace_engine_itemf( | |||||
| bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) | |||||
| { | |||||
| RenderEngineType *type; | |||||
| EnumPropertyItem *item = NULL; | |||||
| EnumPropertyItem tmp = {0, "", 0, "", ""}; | |||||
| int a = 0, totitem = 0; | |||||
| for (type = R_engines.first; type; type = type->next, a++) { | |||||
| tmp.value = a; | |||||
| tmp.identifier = type->idname; | |||||
| tmp.name = type->name; | |||||
| RNA_enum_item_add(&item, &totitem, &tmp); | |||||
| } | |||||
| RNA_enum_item_end(&item, &totitem); | |||||
| *r_free = true; | |||||
| return item; | |||||
| } | |||||
| static int rna_workspace_engine_get(PointerRNA *ptr) | |||||
| { | |||||
| WorkSpace *workspace = (WorkSpace *)ptr->data; | |||||
| RenderEngineType *type; | |||||
| int a = 0; | |||||
| for (type = R_engines.first; type; type = type->next, a++) { | |||||
| if (STREQ(type->idname, workspace->engine)) { | |||||
| return a; | |||||
| } | |||||
| } | |||||
| return 0; | |||||
| } | |||||
| static void rna_workspace_engine_update(Main *bmain, Scene *UNUSED(unused), PointerRNA *UNUSED(ptr)) | |||||
| { | |||||
| ED_render_engine_changed(bmain); | |||||
| } | |||||
| static int rna_workspace_multiple_engines_get(PointerRNA *UNUSED(ptr)) | |||||
| { | |||||
| return (BLI_listbase_count(&R_engines) > 1); | |||||
| } | |||||
| #else /* RNA_RUNTIME */ | #else /* RNA_RUNTIME */ | ||||
| static void rna_def_workspace(BlenderRNA *brna) | static void rna_def_workspace(BlenderRNA *brna) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| static EnumPropertyItem engine_items[] = { | |||||
| {0, "BLENDER_RENDER", 0, "Blender Render", "Use the Blender internal rendering engine for rendering"}, | |||||
| {0, NULL, 0, NULL, NULL} | |||||
| }; | |||||
| srna = RNA_def_struct(brna, "WorkSpace", "ID"); | srna = RNA_def_struct(brna, "WorkSpace", "ID"); | ||||
| RNA_def_struct_sdna(srna, "WorkSpace"); | RNA_def_struct_sdna(srna, "WorkSpace"); | ||||
| RNA_def_struct_ui_text(srna, "Workspace", "Workspace data-block, defining the working environment for the user"); | RNA_def_struct_ui_text(srna, "Workspace", "Workspace data-block, defining the working environment for the user"); | ||||
| /* TODO: real icon, just to show something */ | /* TODO: real icon, just to show something */ | ||||
| RNA_def_struct_ui_icon(srna, ICON_RENDER_RESULT); | RNA_def_struct_ui_icon(srna, ICON_RENDER_RESULT); | ||||
| prop = RNA_def_property(srna, "screens", PROP_COLLECTION, PROP_NONE); | prop = RNA_def_property(srna, "screens", PROP_COLLECTION, PROP_NONE); | ||||
| RNA_def_property_collection_sdna(prop, NULL, "layouts", NULL); | RNA_def_property_collection_sdna(prop, NULL, "layouts", NULL); | ||||
| Show All 18 Lines | #endif | ||||
| prop = RNA_def_property(srna, "render_layer", PROP_POINTER, PROP_NONE); | prop = RNA_def_property(srna, "render_layer", PROP_POINTER, PROP_NONE); | ||||
| RNA_def_property_struct_type(prop, "SceneLayer"); | RNA_def_property_struct_type(prop, "SceneLayer"); | ||||
| RNA_def_property_pointer_funcs(prop, "rna_workspace_render_layer_get", "rna_workspace_render_layer_set", | RNA_def_property_pointer_funcs(prop, "rna_workspace_render_layer_get", "rna_workspace_render_layer_set", | ||||
| NULL, NULL); | NULL, NULL); | ||||
| RNA_def_property_ui_text(prop, "Active Render Layer", "The active render layer used in this workspace"); | RNA_def_property_ui_text(prop, "Active Render Layer", "The active render layer used in this workspace"); | ||||
| RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); | RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); | ||||
| RNA_def_property_update(prop, NC_SCREEN | ND_LAYER, NULL); | RNA_def_property_update(prop, NC_SCREEN | ND_LAYER, NULL); | ||||
| /* Engine. */ | |||||
| prop = RNA_def_property(srna, "engine", PROP_ENUM, PROP_NONE); | |||||
| RNA_def_property_enum_items(prop, engine_items); | |||||
| RNA_def_property_enum_funcs(prop, "rna_workspace_engine_get", "rna_workspace_engine_set", | |||||
| "rna_workspace_engine_itemf"); | |||||
| RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | |||||
| RNA_def_property_ui_text(prop, "Engine", "Engine to use for viewport drawing"); | |||||
| RNA_def_property_update(prop, NC_WINDOW, "rna_workspace_engine_update"); | |||||
| prop = RNA_def_property(srna, "has_multiple_engines", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_boolean_funcs(prop, "rna_workspace_multiple_engines_get", NULL); | |||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | |||||
| RNA_def_property_ui_text(prop, "Multiple Engines", "More than one rendering engine is available"); | |||||
| /* Flags */ | |||||
| prop = RNA_def_property(srna, "use_scene_settings", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | |||||
| RNA_def_property_boolean_sdna(prop, NULL, "flags", WORKSPACE_USE_SCENE_SETTINGS); | |||||
| RNA_def_property_ui_text(prop, "Scene Settings", | |||||
| "Use scene settings instead of workspace settings"); | |||||
| RNA_def_property_update(prop, NC_SCREEN | ND_LAYER, NULL); | |||||
| } | } | ||||
| static void rna_def_transform_orientation(BlenderRNA *brna) | static void rna_def_transform_orientation(BlenderRNA *brna) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| srna = RNA_def_struct(brna, "TransformOrientation", NULL); | srna = RNA_def_struct(brna, "TransformOrientation", NULL); | ||||
| Show All 19 Lines | |||||
Could BLI_assert if this isn't found.