UI: Place "New Collection" item above list in Move/Link to Collection menu

This way "New Collection" is always assigned the same shortcut (N).
Whereas previously it would be automatically assigned the leftover key
from the list of available collections.

Nice side effect is that since N is next to M in most keyboard layouts,
moving to a new collection is super fast by hitting M then N.

{F8630575, size=full}

Paper-cut pointed out by DerekWatts on [devtalk](https://devtalk.blender.org/t/blender-ui-paper-cuts/2596/4211) (thanks!):
{F8630492, size=full}

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D8067
This commit is contained in:
Pablo Vazquez 2020-06-18 17:00:05 +02:00
parent 6899cb3c07
commit 667ef9917f
Notes: blender-bot 2023-02-13 19:59:04 +01:00
Referenced by issue #84440, Shortcut keys are not right in Move to Collection
1 changed files with 10 additions and 8 deletions

View File

@ -1771,15 +1771,8 @@ static void move_to_collection_menu_create(bContext *UNUSED(C), uiLayout *layout
const char *name = BKE_collection_ui_name_get(menu->collection);
UI_block_flag_enable(uiLayoutGetBlock(layout), UI_BLOCK_IS_FLIP);
uiItemIntO(layout, name, ICON_NONE, menu->ot->idname, "collection_index", menu->index);
uiItemS(layout);
for (MoveToCollectionData *submenu = menu->submenus.first; submenu != NULL;
submenu = submenu->next) {
move_to_collection_menus_items(layout, submenu);
}
uiItemS(layout);
// uiItemS(layout);
WM_operator_properties_create_ptr(&menu->ptr, menu->ot);
RNA_int_set(&menu->ptr, "collection_index", menu->index);
@ -1787,6 +1780,15 @@ static void move_to_collection_menu_create(bContext *UNUSED(C), uiLayout *layout
uiItemFullO_ptr(
layout, menu->ot, "New Collection", ICON_ADD, menu->ptr.data, WM_OP_INVOKE_DEFAULT, 0, NULL);
uiItemS(layout);
uiItemIntO(layout, name, ICON_SCENE_DATA, menu->ot->idname, "collection_index", menu->index);
for (MoveToCollectionData *submenu = menu->submenus.first; submenu != NULL;
submenu = submenu->next) {
move_to_collection_menus_items(layout, submenu);
}
}
static void move_to_collection_menus_items(uiLayout *layout, MoveToCollectionData *menu)