UI: Show color tagged collection icons in menus
Draw color tagged collection icons in the link to collection, add collection instance, collection instance search, and remove collection menus. Manifest Task: https://developer.blender.org/T77777 Differential Revision: https://developer.blender.org/D8622
This commit is contained in:
parent
452a1c7b38
commit
4c3813fb32
Notes:
blender-bot
2023-02-14 08:35:51 +01:00
Referenced by issue #77408, Continued Outliner Improvements Design
|
@ -2170,6 +2170,9 @@ int ui_id_icon_get(const bContext *C, ID *id, const bool big)
|
|||
case ID_SCR:
|
||||
iconid = ui_id_screen_get_icon(C, id);
|
||||
break;
|
||||
case ID_GR:
|
||||
iconid = UI_collection_color_icon_get((Collection *)id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@
|
|||
#include "RNA_define.h"
|
||||
#include "RNA_enum_types.h"
|
||||
|
||||
#include "UI_interface_icons.h"
|
||||
|
||||
#include "object_intern.h"
|
||||
|
||||
/********************* 3d view operators ***********************/
|
||||
|
@ -94,7 +96,7 @@ static const EnumPropertyItem *collection_object_active_itemf(bContext *C,
|
|||
collection = NULL;
|
||||
while ((collection = BKE_collection_object_find(bmain, scene, collection, ob))) {
|
||||
item_tmp.identifier = item_tmp.name = collection->id.name + 2;
|
||||
/* item_tmp.icon = ICON_ARMATURE_DATA; */
|
||||
item_tmp.icon = UI_collection_color_icon_get(collection);
|
||||
item_tmp.value = i;
|
||||
RNA_enum_item_add(&item, &totitem, &item_tmp);
|
||||
i++;
|
||||
|
|
|
@ -100,6 +100,8 @@
|
|||
#include "RNA_define.h"
|
||||
#include "RNA_enum_types.h"
|
||||
|
||||
#include "UI_interface_icons.h"
|
||||
|
||||
#include "CLG_log.h"
|
||||
|
||||
/* for menu/popup icons etc etc*/
|
||||
|
@ -1832,7 +1834,7 @@ static void move_to_collection_menus_free(MoveToCollectionData **menu)
|
|||
*menu = NULL;
|
||||
}
|
||||
|
||||
static void move_to_collection_menu_create(bContext *UNUSED(C), uiLayout *layout, void *menu_v)
|
||||
static void move_to_collection_menu_create(bContext *C, uiLayout *layout, void *menu_v)
|
||||
{
|
||||
MoveToCollectionData *menu = menu_v;
|
||||
const char *name = BKE_collection_ui_name_get(menu->collection);
|
||||
|
@ -1848,7 +1850,11 @@ static void move_to_collection_menu_create(bContext *UNUSED(C), uiLayout *layout
|
|||
|
||||
uiItemS(layout);
|
||||
|
||||
uiItemIntO(layout, name, ICON_SCENE_DATA, menu->ot->idname, "collection_index", menu->index);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
const int icon = (menu->collection == scene->master_collection) ?
|
||||
ICON_SCENE_DATA :
|
||||
UI_collection_color_icon_get(menu->collection);
|
||||
uiItemIntO(layout, name, icon, menu->ot->idname, "collection_index", menu->index);
|
||||
|
||||
for (MoveToCollectionData *submenu = menu->submenus.first; submenu != NULL;
|
||||
submenu = submenu->next) {
|
||||
|
@ -1858,17 +1864,18 @@ static void move_to_collection_menu_create(bContext *UNUSED(C), uiLayout *layout
|
|||
|
||||
static void move_to_collection_menus_items(uiLayout *layout, MoveToCollectionData *menu)
|
||||
{
|
||||
const int icon = UI_collection_color_icon_get(menu->collection);
|
||||
|
||||
if (BLI_listbase_is_empty(&menu->submenus)) {
|
||||
uiItemIntO(layout,
|
||||
menu->collection->id.name + 2,
|
||||
ICON_NONE,
|
||||
icon,
|
||||
menu->ot->idname,
|
||||
"collection_index",
|
||||
menu->index);
|
||||
}
|
||||
else {
|
||||
uiItemMenuF(
|
||||
layout, menu->collection->id.name + 2, ICON_NONE, move_to_collection_menu_create, menu);
|
||||
uiItemMenuF(layout, menu->collection->id.name + 2, icon, move_to_collection_menu_create, menu);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3991,6 +3991,12 @@ static const EnumPropertyItem *rna_id_itemf(bContext *UNUSED(C),
|
|||
if (local == false || !ID_IS_LINKED(id)) {
|
||||
item_tmp.identifier = item_tmp.name = id->name + 2;
|
||||
item_tmp.value = i++;
|
||||
|
||||
/* Show collection color tag icons in menus. */
|
||||
if (GS(id->name) == ID_GR) {
|
||||
item_tmp.icon = UI_collection_color_icon_get((Collection *)id);
|
||||
}
|
||||
|
||||
RNA_enum_item_add(&item, &totitem, &item_tmp);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue