From 5cd7295a419b18aabc2f5a21799c14f42766fb44 Mon Sep 17 00:00:00 2001 From: "Justin R. St-Amant" Date: Sat, 16 May 2020 16:19:12 -0500 Subject: [PATCH] fix(menu) wrong spacing for left expansion (#1656) * Fixed minor menu item-spacing issue * Changes to menu-item spacing as requested * refactor: Remove redundant else-if condition Co-authored-by: patrick96 --- src/modules/menu.cpp | 43 +++++++++++++++---------------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/src/modules/menu.cpp b/src/modules/menu.cpp index c351e59b..65a0d84e 100644 --- a/src/modules/menu.cpp +++ b/src/modules/menu.cpp @@ -74,38 +74,25 @@ namespace modules { builder->cmd_close(); } else if (tag == TAG_MENU && m_level > -1) { auto spacing = m_formatter->get(get_format())->spacing; + //Insert separator after menu-toggle and before menu-items for expand-right=true + if (m_expand_right && *m_labelseparator) { + builder->node(m_labelseparator); + builder->space(spacing); + } for (auto&& item : m_levels[m_level]->items) { - /* - * Depending on whether the menu items are to the left or right of the toggle label, the items need to be - * drawn before or after the spacings and the separator - * - * If the menu expands to the left, the separator should be drawn on the right side because otherwise the menu - * would look like this: - * | x | y - */ - if(!m_expand_right) { - builder->cmd(mousebtn::LEFT, item->exec); - builder->node(item->label); - builder->cmd_close(); - } - - if (*m_labelseparator) { - if (item != m_levels[m_level]->items[0]) { + builder->cmd(mousebtn::LEFT, item->exec); + builder->node(item->label); + builder->cmd_close(); + if (item != m_levels[m_level]->items.back()) { + builder->space(spacing); + if (*m_labelseparator) { + builder->node(m_labelseparator); builder->space(spacing); } - builder->node(m_labelseparator); + //Insert separator after last menu-item and before menu-toggle for expand-right=false + } else if (!m_expand_right && *m_labelseparator) { builder->space(spacing); - } - - /* - * If the menu expands to the right, the separator should be drawn on the left side because otherwise the menu - * would look like this: - * x | y | - */ - if(m_expand_right) { - builder->cmd(mousebtn::LEFT, item->exec); - builder->node(item->label); - builder->cmd_close(); + builder->node(m_labelseparator); } } } else {