UI: Better support for linked data-blocks in search buttons
In RNA pointer search buttons (i.e. the ones with an eyedropper),
data-blocks were handled badly. It was not possible to select a linked
data-block that had the same name as a local one, which is especially
common with library overrides. Neither was there a hint to tell appart
linked data-blocks and which .blend file they come from.
These issues are addressed now, we show an "L" prefix and the .blend
file name in the search box (like in ID-templates).
Changes here are quite simple, since the heavy lifting was already done
through c20c203b82.
Addresses T73156.
This commit is contained in:
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include "BLT_translation.h"
|
#include "BLT_translation.h"
|
||||||
|
|
||||||
|
#include "BKE_lib_id.h"
|
||||||
#include "BKE_report.h"
|
#include "BKE_report.h"
|
||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
@@ -395,11 +396,12 @@ void ui_rna_collection_search_cb(const struct bContext *C,
|
|||||||
uiSearchItems *items)
|
uiSearchItems *items)
|
||||||
{
|
{
|
||||||
uiRNACollectionSearch *data = arg;
|
uiRNACollectionSearch *data = arg;
|
||||||
char *name;
|
|
||||||
int i = 0, iconid = 0, flag = RNA_property_flag(data->target_prop);
|
int i = 0, iconid = 0, flag = RNA_property_flag(data->target_prop);
|
||||||
ListBase *items_list = MEM_callocN(sizeof(ListBase), "items_list");
|
ListBase *items_list = MEM_callocN(sizeof(ListBase), "items_list");
|
||||||
CollItemSearch *cis;
|
CollItemSearch *cis;
|
||||||
const bool skip_filter = data->search_but && !data->search_but->changed;
|
const bool skip_filter = data->search_but && !data->search_but->changed;
|
||||||
|
char name_buf[UI_MAX_DRAW_STR];
|
||||||
|
char *name;
|
||||||
|
|
||||||
/* build a temporary list of relevant items first */
|
/* build a temporary list of relevant items first */
|
||||||
RNA_PROP_BEGIN (&data->search_ptr, itemptr, data->search_prop) {
|
RNA_PROP_BEGIN (&data->search_ptr, itemptr, data->search_prop) {
|
||||||
@@ -417,24 +419,31 @@ void ui_rna_collection_search_cb(const struct bContext *C,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Could use the string length here. */
|
|
||||||
name = RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL);
|
|
||||||
|
|
||||||
iconid = 0;
|
iconid = 0;
|
||||||
if (itemptr.type && RNA_struct_is_ID(itemptr.type)) {
|
if (itemptr.type && RNA_struct_is_ID(itemptr.type)) {
|
||||||
iconid = ui_id_icon_get(C, itemptr.data, false);
|
iconid = ui_id_icon_get(C, itemptr.data, false);
|
||||||
|
|
||||||
|
BKE_id_full_name_ui_prefix_get(name_buf, itemptr.data);
|
||||||
|
BLI_STATIC_ASSERT(sizeof(name_buf) >= MAX_ID_FULL_NAME_UI,
|
||||||
|
"Name string buffer should be big enough to hold full UI ID name");
|
||||||
|
name = name_buf;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
name = RNA_struct_name_get_alloc(&itemptr, name_buf, sizeof(name_buf), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
if (skip_filter || BLI_strcasestr(name, str)) {
|
if (skip_filter || BLI_strcasestr(name, str)) {
|
||||||
cis = MEM_callocN(sizeof(CollItemSearch), "CollectionItemSearch");
|
cis = MEM_callocN(sizeof(CollItemSearch), "CollectionItemSearch");
|
||||||
cis->data = itemptr.data;
|
cis->data = itemptr.data;
|
||||||
cis->name = MEM_dupallocN(name);
|
cis->name = BLI_strdup(name);
|
||||||
cis->index = i;
|
cis->index = i;
|
||||||
cis->iconid = iconid;
|
cis->iconid = iconid;
|
||||||
BLI_addtail(items_list, cis);
|
BLI_addtail(items_list, cis);
|
||||||
}
|
}
|
||||||
MEM_freeN(name);
|
if (name != name_buf) {
|
||||||
|
MEM_freeN(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
|||||||
Reference in New Issue
Block a user