diff options
Diffstat (limited to 'source/blender/editors/interface/interface_templates.c')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 164 |
1 files changed, 98 insertions, 66 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 6bf0e36a3cc..00e9a75848a 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -6395,21 +6395,93 @@ void uiTemplateNodeSocket(uiLayout *layout, bContext *UNUSED(C), float color[4]) /** \name Cache File Template * \{ */ -void uiTemplateCacheFile(uiLayout *layout, - const bContext *C, - PointerRNA *ptr, - const char *propname) +void uiTemplateCacheFileVelocity(uiLayout *layout, PointerRNA *fileptr) { - if (!ptr->data) { - return; + /* Ensure that the context has a CacheFile as this may not be set inside of modifiers panels. */ + uiLayoutSetContextPointer(layout, "edit_cachefile", fileptr); + + uiItemR(layout, fileptr, "velocity_name", 0, NULL, ICON_NONE); + uiItemR(layout, fileptr, "velocity_unit", 0, NULL, ICON_NONE); +} + +void uiTemplateCacheFileProcedural(uiLayout *layout, const bContext *C, PointerRNA *fileptr) +{ + /* Ensure that the context has a CacheFile as this may not be set inside of modifiers panels. */ + uiLayoutSetContextPointer(layout, "edit_cachefile", fileptr); + + uiLayout *row, *sub; + + /* Only enable render procedural option if the active engine supports it. */ + const struct RenderEngineType *engine_type = CTX_data_engine_type(C); + + Scene *scene = CTX_data_scene(C); + const bool engine_supports_procedural = RE_engine_supports_alembic_procedural(engine_type, + scene); + + if (!engine_supports_procedural) { + row = uiLayoutRow(layout, false); + /* For Cycles, verify that experimental features are enabled. */ + if (BKE_scene_uses_cycles(scene) && !BKE_scene_uses_cycles_experimental_features(scene)) { + uiItemL( + row, + TIP_( + "The Cycles Alembic Procedural is only available with the experimental feature set"), + ICON_INFO); + } + else { + uiItemL( + row, TIP_("The active render engine does not have an Alembic Procedural"), ICON_INFO); + } } + row = uiLayoutRow(layout, false); + uiLayoutSetActive(row, engine_supports_procedural); + uiItemR(row, fileptr, "use_render_procedural", 0, NULL, ICON_NONE); + + const bool use_render_procedural = RNA_boolean_get(fileptr, "use_render_procedural"); + const bool use_prefetch = RNA_boolean_get(fileptr, "use_prefetch"); + + row = uiLayoutRow(layout, false); + uiLayoutSetEnabled(row, use_render_procedural); + uiItemR(row, fileptr, "use_prefetch", 0, NULL, ICON_NONE); + + sub = uiLayoutRow(layout, false); + uiLayoutSetEnabled(sub, use_prefetch && use_render_procedural); + uiItemR(sub, fileptr, "prefetch_cache_size", 0, NULL, ICON_NONE); +} + +void uiTemplateCacheFileTimeSettings(uiLayout *layout, PointerRNA *fileptr) +{ + /* Ensure that the context has a CacheFile as this may not be set inside of modifiers panels. */ + uiLayoutSetContextPointer(layout, "edit_cachefile", fileptr); + + uiLayout *row, *sub, *subsub; + + row = uiLayoutRow(layout, false); + uiItemR(row, fileptr, "is_sequence", 0, NULL, ICON_NONE); + + row = uiLayoutRowWithHeading(layout, true, IFACE_("Override Frame")); + sub = uiLayoutRow(row, true); + uiLayoutSetPropDecorate(sub, false); + uiItemR(sub, fileptr, "override_frame", 0, "", ICON_NONE); + subsub = uiLayoutRow(sub, true); + uiLayoutSetActive(subsub, RNA_boolean_get(fileptr, "override_frame")); + uiItemR(subsub, fileptr, "frame", 0, "", ICON_NONE); + uiItemDecoratorR(row, fileptr, "frame", 0); + + row = uiLayoutRow(layout, false); + uiItemR(row, fileptr, "frame_offset", 0, NULL, ICON_NONE); + uiLayoutSetActive(row, !RNA_boolean_get(fileptr, "is_sequence")); +} + +bool uiTemplateCacheFilePointer(PointerRNA *ptr, const char *propname, PointerRNA *r_file_ptr) +{ PropertyRNA *prop = RNA_struct_find_property(ptr, propname); if (!prop) { printf( "%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); - return; + return false; } if (RNA_property_type(prop) != PROP_POINTER) { @@ -6417,10 +6489,27 @@ void uiTemplateCacheFile(uiLayout *layout, __func__, RNA_struct_identifier(ptr->type), propname); + return false; + } + + *r_file_ptr = RNA_property_pointer_get(ptr, prop); + return true; +} + +void uiTemplateCacheFile(uiLayout *layout, + const bContext *C, + PointerRNA *ptr, + const char *propname) +{ + if (!ptr->data) { + return; + } + + PointerRNA fileptr; + if (!uiTemplateCacheFilePointer(ptr, propname, &fileptr)) { return; } - PointerRNA fileptr = RNA_property_pointer_get(ptr, prop); CacheFile *file = fileptr.data; uiLayoutSetContextPointer(layout, "edit_cachefile", &fileptr); @@ -6442,7 +6531,7 @@ void uiTemplateCacheFile(uiLayout *layout, SpaceProperties *sbuts = CTX_wm_space_properties(C); - uiLayout *row, *sub, *subsub; + uiLayout *row, *sub; uiLayoutSetPropSep(layout, true); @@ -6451,68 +6540,11 @@ void uiTemplateCacheFile(uiLayout *layout, sub = uiLayoutRow(row, true); uiItemO(sub, "", ICON_FILE_REFRESH, "cachefile.reload"); - row = uiLayoutRow(layout, false); - uiItemR(row, &fileptr, "is_sequence", 0, NULL, ICON_NONE); - - /* Only enable render procedural option if the active engine supports it. */ - const struct RenderEngineType *engine_type = CTX_data_engine_type(C); - - Scene *scene = CTX_data_scene(C); - const bool engine_supports_procedural = RE_engine_supports_alembic_procedural(engine_type, - scene); - - if (!engine_supports_procedural) { - row = uiLayoutRow(layout, false); - /* For Cycles, verify that experimental features are enabled. */ - if (BKE_scene_uses_cycles(scene) && !BKE_scene_uses_cycles_experimental_features(scene)) { - uiItemL( - row, - TIP_( - "The Cycles Alembic Procedural is only available with the experimental feature set"), - ICON_INFO); - } - else { - uiItemL( - row, TIP_("The active render engine does not have an Alembic Procedural"), ICON_INFO); - } - } - - row = uiLayoutRow(layout, false); - uiLayoutSetActive(row, engine_supports_procedural); - uiItemR(row, &fileptr, "use_render_procedural", 0, NULL, ICON_NONE); - - const bool use_render_procedural = RNA_boolean_get(&fileptr, "use_render_procedural"); - const bool use_prefetch = RNA_boolean_get(&fileptr, "use_prefetch"); - - row = uiLayoutRow(layout, false); - uiLayoutSetEnabled(row, use_render_procedural); - uiItemR(row, &fileptr, "use_prefetch", 0, NULL, ICON_NONE); - - sub = uiLayoutRow(layout, false); - uiLayoutSetEnabled(sub, use_prefetch && use_render_procedural); - uiItemR(sub, &fileptr, "prefetch_cache_size", 0, NULL, ICON_NONE); - - row = uiLayoutRowWithHeading(layout, true, IFACE_("Override Frame")); - sub = uiLayoutRow(row, true); - uiLayoutSetPropDecorate(sub, false); - uiItemR(sub, &fileptr, "override_frame", 0, "", ICON_NONE); - subsub = uiLayoutRow(sub, true); - uiLayoutSetActive(subsub, RNA_boolean_get(&fileptr, "override_frame")); - uiItemR(subsub, &fileptr, "frame", 0, "", ICON_NONE); - uiItemDecoratorR(row, &fileptr, "frame", 0); - - row = uiLayoutRow(layout, false); - uiItemR(row, &fileptr, "frame_offset", 0, NULL, ICON_NONE); - uiLayoutSetActive(row, !RNA_boolean_get(&fileptr, "is_sequence")); - if (sbuts->mainb == BCONTEXT_CONSTRAINT) { row = uiLayoutRow(layout, false); uiItemR(row, &fileptr, "scale", 0, IFACE_("Manual Scale"), ICON_NONE); } - uiItemR(layout, &fileptr, "velocity_name", 0, NULL, ICON_NONE); - uiItemR(layout, &fileptr, "velocity_unit", 0, NULL, ICON_NONE); - /* TODO: unused for now, so no need to expose. */ #if 0 row = uiLayoutRow(layout, false); |