Fix T62216: order of items flipped in some menus like object mode.

This commit is contained in:
2019-03-05 14:35:52 +01:00
parent 683e64247f
commit cb7e66737d
2 changed files with 16 additions and 21 deletions

View File

@@ -3500,7 +3500,7 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu
int totitems = 0; int totitems = 0;
int columns, rows, a, b; int columns, rows, a, b;
int column_start = 0, column_end = 0; int column_end = 0;
int nbr_entries_nosepr = 0; int nbr_entries_nosepr = 0;
UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT); UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT);
@@ -3513,7 +3513,7 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu
for (item = item_array; item->identifier; item++, totitems++) { for (item = item_array; item->identifier; item++, totitems++) {
if (!item->identifier[0]) { if (!item->identifier[0]) {
/* inconsistent, but menus with labels do not look good flipped */ /* inconsistent, but menus with categories do not look good flipped */
if (item->name) { if (item->name) {
block->flag |= UI_BLOCK_NO_FLIP; block->flag |= UI_BLOCK_NO_FLIP;
nbr_entries_nosepr++; nbr_entries_nosepr++;
@@ -3537,10 +3537,12 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu
while (rows * columns < totitems) while (rows * columns < totitems)
rows++; rows++;
/* Title */ if (block->flag & UI_BLOCK_NO_FLIP) {
uiDefBut(block, UI_BTYPE_LABEL, 0, RNA_property_ui_name(but->rnaprop), /* Title at the top for menus with categories. */
0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); uiDefBut(block, UI_BTYPE_LABEL, 0, RNA_property_ui_name(but->rnaprop),
uiItemS(layout); 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
uiItemS(layout);
}
/* note, item_array[...] is reversed on access */ /* note, item_array[...] is reversed on access */
@@ -3551,7 +3553,6 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu
if (a == column_end) { if (a == column_end) {
/* start new column, and find out where it ends in advance, so we /* start new column, and find out where it ends in advance, so we
* can flip the order of items properly per column */ * can flip the order of items properly per column */
column_start = a;
column_end = totitems; column_end = totitems;
for (b = a + 1; b < totitems; b++) { for (b = a + 1; b < totitems; b++) {
@@ -3567,12 +3568,7 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu
column = uiLayoutColumn(split, false); column = uiLayoutColumn(split, false);
} }
if (block->flag & UI_BLOCK_NO_FLIP) { item = &item_array[a];
item = &item_array[a];
}
else {
item = &item_array[(column_start + column_end - 1 - a)];
}
if (!item->identifier[0]) { if (!item->identifier[0]) {
if (item->name) { if (item->name) {
@@ -3603,6 +3599,13 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu
} }
} }
if (!(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, "");
}
UI_block_layout_set_current(block, layout); UI_block_layout_set_current(block, layout);
if (free) { if (free) {

View File

@@ -222,14 +222,6 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT); UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT);
/* Flip layout because rna enum list ordered in reverse. */
if ((pup->but && pup->but->type != UI_BTYPE_PULLDOWN) &&
(UI_but_menutype_get(pup->but) == NULL) &&
(UI_but_is_tool(pup->but) == false))
{
UI_block_order_flip(block);
}
if (pup->popup) { if (pup->popup) {
uiBut *bt; uiBut *bt;
int offset[2]; int offset[2];