Topbar visibility works now on start as well (no matter the configured screens)

This commit is contained in:
Raphael Coeffic
2021-04-18 07:58:27 +02:00
parent 50d6e113f2
commit e3b1a84343
3 changed files with 17 additions and 11 deletions
+5 -1
View File
@@ -106,6 +106,8 @@ void loadDefaultLayout()
void loadCustomScreens()
{
unsigned i = 0;
auto viewMain = ViewMain::instance();
while (i < MAX_CUSTOM_SCREENS) {
auto& screen = customScreens[i];
@@ -118,12 +120,14 @@ void loadCustomScreens()
}
// layout is ok, let's add it
auto viewMain = ViewMain::instance();
screen->attach(viewMain);
viewMain->setMainViewsCount(i + 1);
screen->setLeft(viewMain->getMainViewLeftPos(i));
i++;
}
viewMain->setCurrentMainView(0);
viewMain->setTopbarVisible(customScreens[0]->hasTopbar());
}
//
+7 -5
View File
@@ -145,11 +145,13 @@ void ViewMain::setScrollPositionX(coord_t value)
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;
if (customScreens[pageIdx]) {
// crude on/off for now
setTopbarVisible(customScreens[pageIdx]->hasTopbar());
customScreens[pageIdx]->decorate();
//TODO: compute topbar visibility
//auto relativeScrollPosition = getScrollPositionX() % pageWidth;
}
}
}
+5 -5
View File
@@ -62,6 +62,11 @@ class ViewMain: public Window
coord_t getMainViewLeftPos(unsigned view) const;
unsigned getCurrentMainView() const;
void setCurrentMainView(unsigned view);
void nextMainView();
void previousMainView();
protected:
static ViewMain * _instance;
@@ -70,11 +75,6 @@ class ViewMain: public Window
friend class SetupWidgetsPage;
unsigned getCurrentMainView() const;
void setCurrentMainView(unsigned view);
void nextMainView();
void previousMainView();
void setScrollPositionX(coord_t value) override;
void setScrollPositionY(coord_t value) override;