[Bf-blender-cvs] [aa244a7a68d] master: UI: Simplified Categorized Menus

Harley Acheson noreply at git.blender.org
Mon Oct 19 20:30:04 CEST 2020


Commit: aa244a7a68db75111b4afc12b39c8d8c4297e528
Author: Harley Acheson
Date:   Mon Oct 19 11:28:38 2020 -0700
Branches: master
https://developer.blender.org/rBaa244a7a68db75111b4afc12b39c8d8c4297e528

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

===================================================================

M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_layout.c

===================================================================

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);
       }



More information about the Bf-blender-cvs mailing list