diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2017-12-09 11:41:00 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2017-12-11 14:07:13 +0300 |
commit | 48fe46943e03a0d96e7fe6ff4d5a7a070a779503 (patch) | |
tree | f6e8ea5e70ed70c5d9e7e4081ca1fce2def1deaa /source/blender/editors/interface/interface_templates.c | |
parent | 6475f163ecf137b3bfc8a64405e194eef44d8746 (diff) |
Add a new button in ID template to generate an override, and new icon placeholder.
Note that due to mess with inkscape (see T53516), I cannot generate a new icon
currently. :(
Commit related to T53501.
Diffstat (limited to 'source/blender/editors/interface/interface_templates.c')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index dc55f7a1f43..ec31e94446f 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -61,6 +61,7 @@ #include "BKE_idprop.h" #include "BKE_layer.h" #include "BKE_library.h" +#include "BKE_library_override.h" #include "BKE_linestyle.h" #include "BKE_main.h" #include "BKE_modifier.h" @@ -392,6 +393,20 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) } } break; + case UI_ID_OVERRIDE: + if (id) { + Main *bmain = CTX_data_main(C); + ID *override_id = BKE_override_static_create_from(bmain, id); + if (override_id != NULL) { + BKE_main_id_clear_newpoins(bmain); + + /* Assign new pointer, takes care of updates/notifiers */ + RNA_id_pointer_create(override_id, &idptr); + RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr); + RNA_property_update(C, &template_ui->ptr, template_ui->prop); + } + } + break; case UI_ID_ALONE: if (id) { const bool do_scene_obj = (GS(id->name) == ID_OB) && @@ -524,13 +539,27 @@ static void template_ID( UI_but_flag_enable(but, UI_BUT_DISABLED); } else { + const bool disabled = (!id_make_local(CTX_data_main(C), id, true /* test */, false) || + (idfrom && idfrom->lib)); but = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_LIBRARY_DATA_DIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Direct linked library data-block, click to make local")); - if (!id_make_local(CTX_data_main(C), id, true /* test */, false) || (idfrom && idfrom->lib)) + if (disabled) { UI_but_flag_enable(but, UI_BUT_DISABLED); - } + } + else { + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_LOCAL)); + } - UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_LOCAL)); + but = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_LIBRARY_DATA_OVERRIDE, 0, 0, UI_UNIT_X, UI_UNIT_Y, + NULL, 0, 0, 0, 0, + TIP_("Direct linked library data-block, click to create static override")); + if (disabled) { + UI_but_flag_enable(but, UI_BUT_DISABLED); + } + else { + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_OVERRIDE)); + } + } } if (id->us > 1) { |