From 7ba7127699cd75138bcffa776347eda9196140c7 Mon Sep 17 00:00:00 2001 From: Malte Langermann <54738901+gagarinlg@users.noreply.github.com> Date: Sat, 1 Oct 2022 03:26:18 +0200 Subject: [PATCH] fix(gui): also horiz center pop up menus when they have a toolbar (#68) --- radio/src/thirdparty/libopenui/src/menu.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/menu.cpp b/radio/src/thirdparty/libopenui/src/menu.cpp index a8dadf402..19d6adcdd 100644 --- a/radio/src/thirdparty/libopenui/src/menu.cpp +++ b/radio/src/thirdparty/libopenui/src/menu.cpp @@ -248,6 +248,7 @@ Menu::Menu(Window * parent, bool multiple): void Menu::setToolbar(Window * window) { toolbar = window; + updatePosition(); toolbar->setLeft(content->left() - toolbar->width()); toolbar->setTop(content->top()); toolbar->setHeight(content->height()); @@ -257,8 +258,10 @@ void Menu::updatePosition() { coord_t height = content->body.getContentHeight(); - if (!toolbar) { - // there is no navigation bar at the left, we may center the window on screen + if (toolbar) { + content->setLeft((LCD_W - content->width() + toolbar->width())/2); + } else { + content->setLeft((LCD_W - content->width())/2); auto headerHeight = content->getHeaderHeight(); auto bodyHeight = min(height, MENUS_MAX_HEIGHT - headerHeight); content->setTop((LCD_H - headerHeight - bodyHeight) / 2);