Fix #115275: Allow Wrapping of Single Column Enum Menus #115283
|
@ -4355,13 +4355,25 @@ static void ui_def_but_rna__menu(bContext *C, uiLayout *layout, void *but_p)
|
|||
}
|
||||
if (item->name && item->name[0]) {
|
||||
float item_width = BLF_width(BLF_default(), item->name, BLF_DRAW_STR_DUMMY_MAX);
|
||||
col_width = MAX2(col_width, item_width + (120.0f * UI_SCALE_FAC));
|
||||
col_width = MAX2(col_width, item_width + (100.0f * UI_SCALE_FAC));
|
||||
}
|
||||
rows = MAX2(rows, col_rows);
|
||||
}
|
||||
text_width += col_width;
|
||||
text_width /= but->block->aspect;
|
||||
|
||||
/* Wrap long single-column lists. */
|
||||
if (categories == 0) {
|
||||
columns = MAX2((totitems + 20) / 20, 1);
|
||||
if (columns > 8) {
|
||||
columns = (totitems + 25) / 25;
|
||||
}
|
||||
rows = MAX2(totitems / columns, 1);
|
||||
while (rows * columns < totitems) {
|
||||
rows++;
|
||||
}
|
||||
}
|
||||
|
||||
/* If the estimated width is greater than available size, collapse to one column. */
|
||||
if (columns > 1 && text_width > win->sizex) {
|
||||
columns = 1;
|
||||
|
|
Loading…
Reference in New Issue