diff --git a/radio/src/gui/colorlcd/layout.h b/radio/src/gui/colorlcd/layout.h index 6ee989802..4246b540e 100644 --- a/radio/src/gui/colorlcd/layout.h +++ b/radio/src/gui/colorlcd/layout.h @@ -111,6 +111,9 @@ class Layout: public LayoutBase // Re-calculate positions void adjustDecoration(); + // Updates settings for trims, sliders, pots, etc... + void decorate(); + protected: const LayoutFactory * factory = nullptr; ViewMainDecoration* decoration = nullptr; @@ -121,9 +124,6 @@ class Layout: public LayoutBase // Last time we refreshed the window uint32_t lastRefresh = 0; - // Updates settings for trims, sliders, pots, etc... - void decorate(); - void createDecoration(); // Get the available space for widgets diff --git a/radio/src/gui/colorlcd/view_main.cpp b/radio/src/gui/colorlcd/view_main.cpp index 4c02b4dca..71c4dd069 100644 --- a/radio/src/gui/colorlcd/view_main.cpp +++ b/radio/src/gui/colorlcd/view_main.cpp @@ -112,8 +112,7 @@ unsigned ViewMain::getCurrentMainView() const void ViewMain::setCurrentMainView(unsigned view) { if (view < getMainViewsCount()) { - g_model.view = view; - setScrollPositionX(g_model.view * pageWidth); + setScrollPositionX(view * pageWidth); TRACE("### switched to view #%i", g_model.view); } } @@ -142,10 +141,22 @@ void ViewMain::setScrollPositionX(coord_t value) { Window::setScrollPositionX(value); topbar->setLeft(getScrollPositionX()); + + auto pageIdx = getPageIndex(); + if (pageIdx != g_model.view) { + g_model.view = pageIdx; + // crude on/off for now + setTopbarVisible(customScreens[pageIdx]->hasTopbar()); + customScreens[pageIdx]->decorate(); + //TODO: compute topbar visibility + //auto relativeScrollPosition = getScrollPositionX() % pageWidth; + } } void ViewMain::setScrollPositionY(coord_t value) { + // this one is not used yet, but could + // usefull to place the screens upwards Window::setScrollPositionY(value); topbar->setTop(getScrollPositionY()); }