Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-09-20 12:53:17 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-09-20 14:05:28 +0300
commitc8b293ec057ea9e8fb445ba103cf973cbd03c9f0 (patch)
tree93a60931519c0ef67e5c1fe91c79c4f6862ea02a /source/blender/editors/interface/interface_query.c
parentf431c199541e400653e1f8f590934a22b9672dc6 (diff)
Fix T69097: Empty context menu for dimensions
Adjust empty menu check to skip the menu title.
Diffstat (limited to 'source/blender/editors/interface/interface_query.c')
-rw-r--r--source/blender/editors/interface/interface_query.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index 1c3d99d8bd2..457d01c5dc8 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.c
@@ -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)