fix(gui): also horiz center pop up menus when they have a toolbar (#68)

This commit is contained in:
Malte Langermann
2022-10-01 11:26:18 +10:00
committed by GitHub
parent 01d7036e78
commit 7ba7127699
+5 -2
View File
@@ -248,6 +248,7 @@ Menu::Menu(Window * parent, bool multiple):
void Menu::setToolbar(Window * window) void Menu::setToolbar(Window * window)
{ {
toolbar = window; toolbar = window;
updatePosition();
toolbar->setLeft(content->left() - toolbar->width()); toolbar->setLeft(content->left() - toolbar->width());
toolbar->setTop(content->top()); toolbar->setTop(content->top());
toolbar->setHeight(content->height()); toolbar->setHeight(content->height());
@@ -257,8 +258,10 @@ void Menu::updatePosition()
{ {
coord_t height = content->body.getContentHeight(); coord_t height = content->body.getContentHeight();
if (!toolbar) { if (toolbar) {
// there is no navigation bar at the left, we may center the window on screen content->setLeft((LCD_W - content->width() + toolbar->width())/2);
} else {
content->setLeft((LCD_W - content->width())/2);
auto headerHeight = content->getHeaderHeight(); auto headerHeight = content->getHeaderHeight();
auto bodyHeight = min<coord_t>(height, MENUS_MAX_HEIGHT - headerHeight); auto bodyHeight = min<coord_t>(height, MENUS_MAX_HEIGHT - headerHeight);
content->setTop((LCD_H - headerHeight - bodyHeight) / 2); content->setTop((LCD_H - headerHeight - bodyHeight) / 2);