[Bf-blender-cvs] [b89cabb3008] master: UI: hide redundant menu separators automatically
Harley Acheson
noreply at git.blender.org
Thu Apr 25 19:34:48 CEST 2019
Commit: b89cabb300816427273596736aa45ab9edca76b9
Author: Harley Acheson
Date: Thu Apr 25 14:40:53 2019 +0200
Branches: master
https://developer.blender.org/rBb89cabb300816427273596736aa45ab9edca76b9
UI: hide redundant menu separators automatically
Differential Revision: https://developer.blender.org/D4682
===================================================================
M source/blender/editors/include/UI_interface.h
M source/blender/editors/interface/interface_layout.c
M source/blender/editors/interface/interface_query.c
===================================================================
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index d6cfe7aea1f..18960853011 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -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 */
/**
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index cfedd40bfd1..935d89937e0 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.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;
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index e1f91be1631..a2180e63efb 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.c
@@ -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;
+}
+
/** \} */
/* -------------------------------------------------------------------- */
More information about the Bf-blender-cvs
mailing list