From 97ddefd01ae0f1713d9763bc8c420d85ad8dec36 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 20 May 2019 10:53:32 +0200 Subject: [PATCH] Cosmetic refinement in conditional menu: avoid adding useless separators in menu. A useless separator is a separator added when no menuitem was previously added. --- common/tool/conditional_menu.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/tool/conditional_menu.cpp b/common/tool/conditional_menu.cpp index 4610029f13..558d936783 100644 --- a/common/tool/conditional_menu.cpp +++ b/common/tool/conditional_menu.cpp @@ -106,6 +106,9 @@ void CONDITIONAL_MENU::Evaluate( SELECTION& aSelection ) { Clear(); + // We try to avoid adding useless separators (when no menuitems between separators) + int menu_count = 0; // number of menus since the latest separator + for( const ENTRY& entry : m_entries ) { const SELECTION_CONDITION& cond = entry.Condition(); @@ -128,16 +131,21 @@ void CONDITIONAL_MENU::Evaluate( SELECTION& aSelection ) { case ENTRY::ACTION: menuItem = Add( *entry.Action(), entry.IsCheckmarkEntry() ); + menu_count++; break; case ENTRY::MENU: menuItem = Add( entry.Menu() ); + menu_count++; break; case ENTRY::WXITEM: menuItem = Append( entry.wxItem()->GetId(), entry.wxItem()->GetItemLabel(), entry.wxItem()->GetHelp(), entry.wxItem()->GetKind() ); + menu_count++; break; case ENTRY::SEPARATOR: - menuItem = AppendSeparator(); + if( menu_count ) + menuItem = AppendSeparator(); + menu_count = 0; break; default: assert( false );