diff options
Diffstat (limited to 'source/blender/editors/interface/interface_templates.c')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 00e9a75848a..8330f8c0db7 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -6474,6 +6474,67 @@ void uiTemplateCacheFileTimeSettings(uiLayout *layout, PointerRNA *fileptr) uiLayoutSetActive(row, !RNA_boolean_get(fileptr, "is_sequence")); } +static void cache_file_layer_item(uiList *UNUSED(ui_list), + bContext *UNUSED(C), + uiLayout *layout, + PointerRNA *UNUSED(dataptr), + PointerRNA *itemptr, + int UNUSED(icon), + PointerRNA *UNUSED(active_dataptr), + const char *UNUSED(active_propname), + int UNUSED(index), + int UNUSED(flt_flag)) +{ + uiLayout *row = uiLayoutRow(layout, true); + uiItemR(row, itemptr, "hide_layer", UI_ITEM_R_NO_BG, "", ICON_NONE); + uiItemR(row, itemptr, "filepath", UI_ITEM_R_NO_BG, "", ICON_NONE); +} + +uiListType *UI_UL_cache_file_layers() +{ + uiListType *list_type = (uiListType *)MEM_callocN(sizeof(*list_type), __func__); + + BLI_strncpy(list_type->idname, "UI_UL_cache_file_layers", sizeof(list_type->idname)); + list_type->draw_item = cache_file_layer_item; + + return list_type; +} + +void uiTemplateCacheFileLayers(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 = uiLayoutRow(layout, false); + uiLayout *col = uiLayoutColumn(row, true); + + uiTemplateList(col, + (bContext *)C, + "UI_UL_cache_file_layers", + "cache_file_layers", + fileptr, + "layers", + fileptr, + "active_index", + "", + 1, + 5, + UILST_LAYOUT_DEFAULT, + 1, + UI_TEMPLATE_LIST_FLAG_NONE); + + col = uiLayoutColumn(row, true); + uiItemO(col, "", ICON_ADD, "cachefile.layer_add"); + uiItemO(col, "", ICON_REMOVE, "cachefile.layer_remove"); + + CacheFile *file = fileptr->data; + if (BLI_listbase_count(&file->layers) > 1) { + uiItemS_ex(col, 1.0f); + uiItemO(col, "", ICON_TRIA_UP, "cachefile.layer_move"); + uiItemO(col, "", ICON_TRIA_DOWN, "cachefile.layer_move"); + } +} + bool uiTemplateCacheFilePointer(PointerRNA *ptr, const char *propname, PointerRNA *r_file_ptr) { PropertyRNA *prop = RNA_struct_find_property(ptr, propname); |