diff options
author | Harley Acheson <harley.acheson@gmail.com> | 2020-10-19 21:28:38 +0300 |
---|---|---|
committer | Harley Acheson <harley.acheson@gmail.com> | 2020-10-19 21:28:38 +0300 |
commit | aa244a7a68db75111b4afc12b39c8d8c4297e528 (patch) | |
tree | 871a3cd2148d667c33bdfd75aa4a1aaf461c6c8b /source/blender/editors | |
parent | 1e3742749ebaf231a0c0c43a373cad6c740a0b91 (diff) |
UI: Simplified Categorized Menus
Menus with categories gain a dividing line and omit the title.
Differential Revision: https://developer.blender.org/D5135
Reviewed by Brecht Van Lommel
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/interface/interface.c | 52 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 1 |
2 files changed, 20 insertions, 33 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index afc9d9884f3..b3ed6ac09b3 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -4148,12 +4148,14 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu UI_block_layout_set_current(block, layout); int totitems = 0; + int categories = 0; int nbr_entries_nosepr = 0; for (const EnumPropertyItem *item = item_array; item->identifier; item++, totitems++) { if (!item->identifier[0]) { /* inconsistent, but menus with categories do not look good flipped */ if (item->name) { block->flag |= UI_BLOCK_NO_FLIP; + categories++; nbr_entries_nosepr++; } /* We do not want simple separators in nbr_entries_nosepr count */ @@ -4179,22 +4181,12 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu rows++; } - if (block->flag & UI_BLOCK_NO_FLIP) { + const char *title = RNA_property_ui_name(but->rnaprop); + + if (title[0] && (categories == 0) && (block->flag & UI_BLOCK_NO_FLIP)) { /* Title at the top for menus with categories. */ - uiDefBut(block, - UI_BTYPE_LABEL, - 0, - RNA_property_ui_name(but->rnaprop), - 0, - 0, - UI_UNIT_X * 5, - UI_UNIT_Y, - NULL, - 0.0, - 0.0, - 0, - 0, - ""); + uiDefBut( + block, UI_BTYPE_LABEL, 0, title, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); uiItemS(layout); } @@ -4203,10 +4195,13 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu /* create items */ uiLayout *split = uiLayoutSplit(layout, 0.0f, false); + bool new_column; + int column_end = 0; uiLayout *column = NULL; for (int a = 0; a < totitems; a++) { - if (a == column_end) { + new_column = (a == column_end); + if (new_column) { /* start new column, and find out where it ends in advance, so we * can flip the order of items properly per column */ column_end = totitems; @@ -4226,6 +4221,11 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu const EnumPropertyItem *item = &item_array[a]; + if (new_column && (categories > 0) && item->identifier[0]) { + uiItemL(column, "", ICON_NONE); + uiItemS(column); + } + if (!item->identifier[0]) { if (item->name) { if (item->icon) { @@ -4249,8 +4249,6 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu 0, ""); } - } - else { uiItemS(column); } } @@ -4291,23 +4289,11 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu } } - if (!(block->flag & UI_BLOCK_NO_FLIP)) { + if (title[0] && (categories == 0) && !(block->flag & UI_BLOCK_NO_FLIP)) { /* Title at the bottom for menus without categories. */ uiItemS(layout); - uiDefBut(block, - UI_BTYPE_LABEL, - 0, - RNA_property_ui_name(but->rnaprop), - 0, - 0, - UI_UNIT_X * 5, - UI_UNIT_Y, - NULL, - 0.0, - 0.0, - 0, - 0, - ""); + uiDefBut( + block, UI_BTYPE_LABEL, 0, title, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); } UI_block_layout_set_current(block, layout); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 3e276a69277..ad260274e78 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1542,6 +1542,7 @@ void uiItemsFullEnumO_items(uiLayout *layout, 0, 0, ""); + uiItemS(target); } ui_but_tip_from_enum_item(but, item); } |