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 <p.ziegler96@gmail.com>
This commit is contained in:
Justin R. St-Amant 2020-05-16 16:19:12 -05:00 committed by GitHub
parent 4e9598f09b
commit 5cd7295a41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,38 +74,25 @@ namespace modules {
builder->cmd_close(); builder->cmd_close();
} else if (tag == TAG_MENU && m_level > -1) { } else if (tag == TAG_MENU && m_level > -1) {
auto spacing = m_formatter->get(get_format())->spacing; auto spacing = m_formatter->get(get_format())->spacing;
for (auto&& item : m_levels[m_level]->items) { //Insert separator after menu-toggle and before menu-items for expand-right=true
/* if (m_expand_right && *m_labelseparator) {
* 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 <label-toggle>
*/
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->space(spacing);
}
builder->node(m_labelseparator); builder->node(m_labelseparator);
builder->space(spacing); builder->space(spacing);
} }
for (auto&& item : m_levels[m_level]->items) {
/*
* If the menu expands to the right, the separator should be drawn on the left side because otherwise the menu
* would look like this:
* <label-toggle> x | y |
*/
if(m_expand_right) {
builder->cmd(mousebtn::LEFT, item->exec); builder->cmd(mousebtn::LEFT, item->exec);
builder->node(item->label); builder->node(item->label);
builder->cmd_close(); builder->cmd_close();
if (item != m_levels[m_level]->items.back()) {
builder->space(spacing);
if (*m_labelseparator) {
builder->node(m_labelseparator);
builder->space(spacing);
}
//Insert separator after last menu-item and before menu-toggle for expand-right=false
} else if (!m_expand_right && *m_labelseparator) {
builder->space(spacing);
builder->node(m_labelseparator);
} }
} }
} else { } else {