UI: hide redundant menu separators automatically

Differential Revision: https://developer.blender.org/D4682
temp-vr-draw-thread
Harley Acheson 4 years ago committed by Brecht Van Lommel
parent 905f2d84af
commit b89cabb300

@ -520,6 +520,7 @@ bool UI_but_is_tool(const uiBut *but);
#define UI_but_is_decorator(but) ((but)->func == ui_but_anim_decorate_cb)
bool UI_block_is_empty(const uiBlock *block);
bool UI_block_can_add_separator(const uiBlock *block);
/* interface_region_menu_popup.c */
/**

@ -2968,6 +2968,9 @@ void uiItemS_ex(uiLayout *layout, float factor)
{
uiBlock *block = layout->root->block;
bool is_menu = ui_block_is_menu(block);
if (is_menu && !UI_block_can_add_separator(block)) {
return;
}
int space = (is_menu) ? 0.45f * UI_UNIT_X : 0.3f * UI_UNIT_X;
space *= factor;

@ -473,6 +473,15 @@ bool UI_block_is_empty(const uiBlock *block)
return true;
}
bool UI_block_can_add_separator(const uiBlock *block)
{
if (ui_block_is_menu(block)) {
const uiBut *but = block->buttons.last;
return (but && !ELEM(but->type, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR));
}
return true;
}
/** \} */
/* -------------------------------------------------------------------- */

Loading…
Cancel
Save