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.
This commit is contained in:
Bastien Montagne 2017-12-09 09:41:00 +01:00
parent 6475f163ec
commit 48fe46943e
3 changed files with 34 additions and 6 deletions

View File

@ -257,9 +257,7 @@ DEF_ICON(STRANDS)
DEF_ICON(LIBRARY_DATA_INDIRECT)
DEF_ICON(GREASEPENCIL)
DEF_ICON(LINE_DATA)
#ifndef DEF_ICON_BLANK_SKIP
DEF_ICON(BLANK084)
#endif
DEF_ICON(LIBRARY_DATA_OVERRIDE)
DEF_ICON(GROUP_BONE)
DEF_ICON(GROUP_VERTEX)
DEF_ICON(GROUP_VCOL)

View File

@ -667,6 +667,7 @@ void UI_but_string_info_get(struct bContext *C, uiBut *but, ...) ATTR_SENTINEL(0
#define UI_ID_FAKE_USER (1 << 8)
#define UI_ID_PIN (1 << 9)
#define UI_ID_PREVIEWS (1 << 10)
#define UI_ID_OVERRIDE (1 << 11)
#define UI_ID_FULL (UI_ID_RENAME | UI_ID_BROWSE | UI_ID_ADD_NEW | UI_ID_OPEN | UI_ID_ALONE | UI_ID_DELETE | UI_ID_LOCAL)
int UI_icon_from_id(struct ID *id);

View File

@ -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) {