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, 60 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 2cdcf7a604d..e3a71feb1a9 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -58,6 +58,8 @@ #include "BKE_depsgraph.h" #include "BKE_global.h" #include "BKE_idcode.h" +#include "BKE_idprop.h" +#include "BKE_layer.h" #include "BKE_library.h" #include "BKE_linestyle.h" #include "BKE_main.h" @@ -429,7 +431,8 @@ static void template_ID( but = uiDefBlockButN(block, id_search_menu, MEM_dupallocN(template), "", 0, 0, width, height, TIP_(template_id_browse_tip(type))); if (use_preview_icon) { - ui_def_but_icon(but, ui_id_icon_get(C, id, use_big_size), UI_HAS_ICON | UI_BUT_ICON_PREVIEW); + int icon = id ? ui_id_icon_get(C, id, use_big_size) : RNA_struct_ui_icon(type); + ui_def_but_icon(but, icon, UI_HAS_ICON | UI_BUT_ICON_PREVIEW); } else { ui_def_but_icon(but, RNA_struct_ui_icon(type), UI_HAS_ICON); @@ -1991,6 +1994,7 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event) case UICURVE_FUNC_HANDLE_AUTO_ANIM: /* set auto-clamped */ curvemap_handle_set(cuma, HD_AUTO_ANIM); curvemapping_changed(cumap, false); + break; case UICURVE_FUNC_EXTEND_HOZ: /* extend horiz */ cuma->flag &= ~CUMA_EXTEND_EXTRAPOLATE; curvemapping_changed(cumap, false); @@ -3732,6 +3736,7 @@ void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr) if (propptr.data) { uiBut *but = uiLayoutGetBlock(layout)->buttons.last; + WM_operator_properties_sanitize(&propptr, false); template_keymap_item_properties(layout, NULL, &propptr); /* attach callbacks to compensate for missing properties update, @@ -3748,6 +3753,60 @@ void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr) } } +/********************************* Overrides *************************************/ + +void uiTemplateOverrideProperty(uiLayout *layout, struct PointerRNA *collection_props_ptr, struct PointerRNA *scene_props_ptr, const char *name, const char *custom_template) +{ + bool is_set = false; + uiLayout *row, *col; + + PointerRNA *ptr; + PropertyRNA *prop; + + IDProperty *collection_props = collection_props_ptr->data; + + if (IDP_GetPropertyFromGroup(collection_props, name)) { + prop = RNA_struct_find_property(collection_props_ptr, name); + ptr = collection_props_ptr; + is_set = RNA_property_is_set(ptr, prop); + } + else { + /* property doesn't exist yet */ + prop = RNA_struct_find_property(scene_props_ptr, name); + ptr = scene_props_ptr; + } + + row = uiLayoutRow(layout, false); + col = uiLayoutColumn(row, false); + + uiLayoutSetEnabled(col, is_set); + + if (custom_template && STREQ(custom_template, "icon_view")) { + uiTemplateIconView(col, ptr, name, false, 5.0f); + } + else { + uiItemFullR(col, ptr, prop, -1, 0, 0, NULL, ICON_NONE); + } + + col = uiLayoutColumn(row, false); + uiBut *but; + uiBlock *block = uiLayoutGetBlock(col); + UI_block_emboss_set(block, UI_EMBOSS_NONE); + + if (is_set) { + but = uiDefIconButO(block, UI_BTYPE_BUT, "UI_OT_unuse_property_button", WM_OP_EXEC_DEFAULT, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); + } + else { + but = uiDefIconButO(block, UI_BTYPE_BUT, "UI_OT_use_property_button", WM_OP_EXEC_DEFAULT, ICON_ZOOMIN, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); + /* XXX - Using existing data struct to pass another RNAPointer */ + but->rnasearchpoin = *scene_props_ptr; + } + + but->rnapoin = *collection_props_ptr; + but->rnaprop = prop; + UI_block_emboss_set(block, UI_EMBOSS); +} + /********************************* Color management *************************************/ void uiTemplateColorspaceSettings(uiLayout *layout, PointerRNA *ptr, const char *propname) |