Fix T69097: Empty context menu for dimensions
Adjust empty menu check to skip the menu title.
This commit is contained in:
parent
f431c19954
commit
c8b293ec05
Notes:
blender-bot
2023-06-21 19:23:24 +02:00
Referenced by issue #70111, brush.weight_paint_capabilities uses a cached value for the gradient and sample weight tool Referenced by issue #69097, Right-clicking on Sidebar > Dimensions controls spawn an empty menu
|
@ -524,6 +524,7 @@ bool UI_but_is_tool(const uiBut *but);
|
|||
bool UI_but_is_utf8(const uiBut *but);
|
||||
#define UI_but_is_decorator(but) ((but)->func == ui_but_anim_decorate_cb)
|
||||
|
||||
bool UI_block_is_empty_ex(const uiBlock *block, const bool skip_title);
|
||||
bool UI_block_is_empty(const uiBlock *block);
|
||||
bool UI_block_can_add_separator(const uiBlock *block);
|
||||
|
||||
|
|
|
@ -463,14 +463,33 @@ bool ui_block_is_popup_any(const uiBlock *block)
|
|||
return (ui_block_is_menu(block) || ui_block_is_popover(block) || ui_block_is_pie_menu(block));
|
||||
}
|
||||
|
||||
bool UI_block_is_empty(const uiBlock *block)
|
||||
static const uiBut *ui_but_next_non_separator(const uiBut *but)
|
||||
{
|
||||
for (const uiBut *but = block->buttons.first; but; but = but->next) {
|
||||
for (; but; but = but->next) {
|
||||
if (!ELEM(but->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE)) {
|
||||
return false;
|
||||
return but;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool UI_block_is_empty_ex(const uiBlock *block, const bool skip_title)
|
||||
{
|
||||
const uiBut *but = block->buttons.first;
|
||||
if (skip_title) {
|
||||
/* Skip the first label, since popups often have a title,
|
||||
* we may want to consider the block empty in this case. */
|
||||
but = ui_but_next_non_separator(but);
|
||||
if (but && but->type == UI_BTYPE_LABEL) {
|
||||
but = but->next;
|
||||
}
|
||||
}
|
||||
return (ui_but_next_non_separator(but) == NULL);
|
||||
}
|
||||
|
||||
bool UI_block_is_empty(const uiBlock *block)
|
||||
{
|
||||
return UI_block_is_empty_ex(block, false);
|
||||
}
|
||||
|
||||
bool UI_block_can_add_separator(const uiBlock *block)
|
||||
|
|
|
@ -474,7 +474,7 @@ void UI_popup_menu_end(bContext *C, uiPopupMenu *pup)
|
|||
|
||||
bool UI_popup_menu_end_or_cancel(bContext *C, uiPopupMenu *pup)
|
||||
{
|
||||
if (!UI_block_is_empty(pup->block)) {
|
||||
if (!UI_block_is_empty_ex(pup->block, true)) {
|
||||
UI_popup_menu_end(C, pup);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue